{
  "elementsLearnedData": [],
  "elementsTestData": [],
  "flow": {
    "id": "FC4B0365-3CA2-4422-9267-AED6E5029B72",
    "name": "AWS Textract: Healthie lab PDFs read for review"
  },
  "flowVersion": {
    "clientMetadata": {
      "viewport": {
        "x": -29.510268562401265,
        "y": 14.723538704581358,
        "zoom": 0.63
      },
      "autoSave": false,
      "descriptions": {
        "flow": "When a document is filed in the lab results folder of a Healthie chart, checks it is not already on a lab order, stores it in S3 so Textract reads every page, and lines up each value with its units, range and the lab's flag. Any lab-flagged value goes to Slack at once. The provider gets one review task listing flagged values, values outside the lab's printed range and cells Textract was unsure of. A report whose name or birth date differs from the chart goes to intake in Slack. Nothing is filed again.",
        "initialData": "",
        "initialDataFields": {}
      }
    },
    "description": "Reads every page of each lab result PDF filed in a Healthie lab results folder with Textract and gives the provider a review task with lab-flagged values, values outside the printed range and cells to check against the page.",
    "elements": [
      {
        "clientMetadata": {
          "notes": "Lists lab orders in Healthie, most recently updated first, each with its results and their values (test, value, units, reference range, abnormal flag), so a flow can check a patient's labs. Narrow them by patient, keywords or status.",
          "elementId": "EXTENSION:::SHARED:::default:::healthie:::listLabOrders",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Check the patient's lab orders Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::listLabOrders",
          "legacyElementId": null,
          "methodName": "listLabOrders",
          "position": {
            "x": 1926,
            "y": 40
          }
        },
        "flowElementId": "C4574787-9A22-404F-B877-78A8C41D749D",
        "groupId": null,
        "id": "D0CA6E5A-F352-4315-B605-6AB4E060AA55",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "patientId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Doc",
                    "subPathSegments": [
                      {
                        "key": "document",
                        "optional": false
                      },
                      {
                        "key": "rel_user_id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "F60737F8-957C-41E8-9D81-299B1147C5F9"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "keywords",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "status",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sortBy",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "UPDATED_AT_DESC"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pageSize",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 25
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "cursor",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "listLabOrders",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Lab orders",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Check the patient's lab orders",
        "nextElementIds": [
          "D4A8A974-BDCD-46FB-BBED-39CA6B0C29FA"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 734,
            "y": 499
          }
        },
        "flowElementId": "B406E7C4-D646-49EC-BECA-44FAE0CEA643",
        "groupId": "06CAFD90-694D-470B-88E4-232A12F94310",
        "id": "60F230D1-5DC9-4DF0-8FA1-1EB410DACECD",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "bdd70be4-798c-41d7-9816-28e2f3b2dee7",
                "nestedOperation": null,
                "operation": "equal",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Analysis",
                      "subPathSegments": [
                        {
                          "key": "jobStatus",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "E65CDFFC-87A3-4F9B-AA9B-807CBD1ACE27"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "TEXT",
                        "label": null,
                        "type": "INPUT",
                        "value": "IN_PROGRESS"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "bdd70be4-798c-41d7-9816-28e2f3b2dee7"
            ]
          },
          "elseComponent": {
            "componentId": "DA200F19-B488-4EB2-BC57-70519C2D3897",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "still",
          "storeResult": false,
          "thenComponent": null
        },
        "name": "Still reading?",
        "nextElementIds": [
          "DA200F19-B488-4EB2-BC57-70519C2D3897"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Downloads a file from a given URL and uploads it to an S3 bucket. Useful for transferring files from external sources directly into S3 without manual download steps.",
          "elementId": "EXTENSION:::SHARED:::default:::s3:::uploadObjectFromUrl",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Store the report for Textract Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::s3:::uploadObjectFromUrl",
          "legacyElementId": "JS###v1###S3CompatibleStorage###uploadObjectFromUrl",
          "methodName": "uploadObjectFromUrl",
          "position": {
            "x": 775,
            "y": 210
          }
        },
        "flowElementId": "B9620D73-4FE6-4CC3-B5FE-2BA5C8E5D712",
        "groupId": null,
        "id": "A7DC8571-2FED-4004-9880-DBCA752218F0",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "bucketName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "S3 bucket",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "S3 bucket"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "objectKey",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "lab-results/healthie-"
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Gate",
                    "subPathSegments": [
                      {
                        "key": "documentId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "D4A8A974-BDCD-46FB-BBED-39CA6B0C29FA"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sourceUrl",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Report file",
                    "subPathSegments": [
                      {
                        "key": "file",
                        "optional": false
                      },
                      {
                        "key": "url",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "07359311-6887-4D3A-B8A9-34B2B94FEC71"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "contentType",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Gate",
                    "subPathSegments": [
                      {
                        "key": "contentType",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "D4A8A974-BDCD-46FB-BBED-39CA6B0C29FA"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "storageClass",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "uploadObjectFromUrl",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Stored",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "s3",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Store the report for Textract",
        "nextElementIds": [
          "62D35910-DD82-4804-904B-A5AB1771E116"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "break-repeat",
          "isFirstElement": false,
          "blockDefinitionId": "break-repeat",
          "position": {
            "x": 1049,
            "y": 669
          }
        },
        "flowElementId": "455AA313-DB98-43AF-918C-61C34F7196B8",
        "groupId": "06CAFD90-694D-470B-88E4-232A12F94310",
        "id": "7149F825-8909-4157-9E64-B99C667B7A0B",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "brk",
          "storeResult": true
        },
        "name": "Done reading",
        "nextElementIds": [],
        "nextGroupIds": [],
        "type": "BREAK"
      },
      {
        "clientMetadata": {
          "elementId": "data-bucket",
          "isFirstElement": false,
          "blockDefinitionId": "data-bucket",
          "fieldKeys": {
            "Reading done": "356899f0-0ab1-417b-9053-680155cb0e21",
            "Textract result": "a35ced5e-3475-4095-b212-9051e3049fab"
          },
          "position": {
            "x": 1034,
            "y": 499
          }
        },
        "flowElementId": "52B7EEE4-CF79-40C4-8361-355CAF18F0B1",
        "groupId": "06CAFD90-694D-470B-88E4-232A12F94310",
        "id": "DA200F19-B488-4EB2-BC57-70519C2D3897",
        "metaInfo": {
          "bucketName": "Default",
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "fields": [
            {
              "name": "Reading done",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "yes"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "Textract result",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Analysis",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "E65CDFFC-87A3-4F9B-AA9B-807CBD1ACE27"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "keep",
          "storeResult": true
        },
        "name": "Keep what Textract read",
        "nextElementIds": [
          "7149F825-8909-4157-9E64-B99C667B7A0B"
        ],
        "nextGroupIds": [],
        "type": "DATA_BUCKET"
      },
      {
        "clientMetadata": {
          "notes": "Lists the documents on a patient's Healthie chart, such as referrals, signed forms and lab results, newest first. Narrow the list by folder, name or sharing, and page through it with the next cursor.",
          "elementId": "EXTENSION:::SHARED:::default:::healthie:::listPatientDocuments",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Look in the lab results folder Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::listPatientDocuments",
          "legacyElementId": null,
          "methodName": "listPatientDocuments",
          "position": {
            "x": 1555,
            "y": 40
          }
        },
        "flowElementId": "437861AB-C6A6-480C-B14D-9363E0D22576",
        "groupId": null,
        "id": "216A4180-EA3E-4BC5-83CA-9B696D429F29",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "patientId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Doc",
                    "subPathSegments": [
                      {
                        "key": "document",
                        "optional": false
                      },
                      {
                        "key": "rel_user_id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "F60737F8-957C-41E8-9D81-299B1147C5F9"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "folderId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "keywords",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sharing",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sortBy",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "CREATED_AT_DESC"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pageSize",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 50
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "cursor",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "listPatientDocuments",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Folder",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Look in the lab results folder",
        "nextElementIds": [
          "D0CA6E5A-F352-4315-B605-6AB4E060AA55"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "wait",
          "isFirstElement": true,
          "blockDefinitionId": "wait",
          "mode": "SIMPLE",
          "position": {
            "x": 110,
            "y": 499
          }
        },
        "flowElementId": "86B0B279-D28E-4C3A-B763-687AB6BF7F52",
        "groupId": "06CAFD90-694D-470B-88E4-232A12F94310",
        "id": "1D038F2A-A131-4D8A-8BC4-F1428C677CCD",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "delay": {
            "expression": [
              {
                "id": "NUMBER",
                "label": null,
                "type": "INPUT",
                "value": 10
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": "DOUBLE"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "pause",
          "storeResult": true
        },
        "name": "Give Textract a moment",
        "nextElementIds": [
          "E65CDFFC-87A3-4F9B-AA9B-807CBD1ACE27"
        ],
        "nextGroupIds": [],
        "type": "WAIT"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Decide whether to read it Result"
          },
          "position": {
            "x": 1943,
            "y": 219
          }
        },
        "flowElementId": "C58D47AE-F937-41B7-86B1-CF45A5653B58",
        "groupId": null,
        "id": "D4A8A974-BDCD-46FB-BBED-39CA6B0C29FA",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "doc",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Doc",
                    "subPathSegments": null,
                    "type": "TRIGGER_DATA",
                    "value": "F60737F8-957C-41E8-9D81-299B1147C5F9"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "folder",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Folder",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "216A4180-EA3E-4BC5-83CA-9B696D429F29"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "labOrders",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Lab orders",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "D0CA6E5A-F352-4315-B605-6AB4E060AA55"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const d = (doc && doc.document) || {};\nconst id = String((doc && doc.resource_id) || d.id || '');\nconst inFolder = ((folder && folder.documents) || []).some((x) => String(x.id) === id);\nconst recorded = ((labOrders && labOrders.lab_orders) || []).some((o) => (o.document && String(o.document.id) === id) || (o.lab_results || []).some((r) => r.document && String(r.document.id) === id));\nconst type = String(d.file_content_type || '').toLowerCase();\nconst readable = /pdf|png|jpe?g|tiff/.test(type) || /\\.(pdf|png|jpe?g|tiff?)$/i.test(String(d.display_name || ''));\nreturn { read: Boolean(id) && inFolder && !recorded && readable, documentId: id, inFolder, alreadyRecorded: recorded, readable, contentType: type || 'application/pdf' };\n"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Gate",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Decide whether to read it",
        "nextElementIds": [
          "5CE350D4-1460-4BCC-BDF2-B13D8494F05A"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Fires when a document is uploaded to Healthie, such as a signed form, a lab result or a file a patient shared, with the document's name, type and patient.",
          "elementId": "EXTENSION:::SHARED:::default:::healthie:::onNewDocument",
          "isFirstElement": true,
          "blockDefinitionId": "api-service-trigger",
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::onNewDocument",
          "legacyElementId": null,
          "methodName": "onNewDocument",
          "position": {
            "x": 784,
            "y": 40
          }
        },
        "flowElementId": "E9341392-6B2D-4EE5-8FD6-B8D1B48DA8D5",
        "groupId": null,
        "id": "F60737F8-957C-41E8-9D81-299B1147C5F9",
        "metaInfo": {
          "callbackUrl": null,
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": null,
          "connectionId": null,
          "eventName": "onNewDocument",
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Doc",
          "scope": "SINGLE_APP",
          "serviceId": "healthie",
          "slaConditions": [],
          "staticData": {},
          "storeResult": true,
          "subtype": "REALTIME",
          "type": "CUSTOM"
        },
        "name": "New document on a chart",
        "nextElementIds": [
          "197D37EF-C5FD-41B9-AB94-C20A7744AF37"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "notes": "Starts an asynchronous document analysis job over a document stored in Amazon S3 (used for multi-page PDFs and TIFFs, up to 500 MB / 3000 pages). Choose one or more feature types (FORMS, TABLES, QUERIES, SIGNATURES, LAYOUT). Returns a JobId. Poll Get Document Analysis with that JobId until JobStatus is SUCCEEDED. The document must be in an S3 bucket in the same region as this integration.",
          "elementId": "EXTENSION:::SHARED:::default:::aws-textract:::startDocumentAnalysis",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Start reading every page Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::aws-textract:::startDocumentAnalysis",
          "legacyElementId": "JS###v1###Textract###startDocumentAnalysis",
          "methodName": "startDocumentAnalysis",
          "position": {
            "x": 787,
            "y": 380
          }
        },
        "flowElementId": "98C3D126-7C38-418A-ADFE-F6E9FFBDBC5F",
        "groupId": null,
        "id": "62D35910-DD82-4804-904B-A5AB1771E116",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "featureTypes",
              "type": "SIMPLE_LIST",
              "value": [
                {
                  "expression": [
                    {
                      "id": "TEXT",
                      "label": null,
                      "type": "INPUT",
                      "value": "TABLES"
                    }
                  ],
                  "mode": "BASIC",
                  "parseJsonString": false,
                  "resultType": null
                },
                {
                  "expression": [
                    {
                      "id": "TEXT",
                      "label": null,
                      "type": "INPUT",
                      "value": "QUERIES"
                    }
                  ],
                  "mode": "BASIC",
                  "parseJsonString": false,
                  "resultType": null
                }
              ]
            },
            {
              "name": "s3Bucket",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Stored",
                    "subPathSegments": [
                      {
                        "key": "bucketName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "A7DC8571-2FED-4004-9880-DBCA752218F0"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "s3Name",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Stored",
                    "subPathSegments": [
                      {
                        "key": "objectKey",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "A7DC8571-2FED-4004-9880-DBCA752218F0"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "queries",
              "type": "COMPLEX_LIST",
              "value": [
                {
                  "type": "OBJECT",
                  "value": [
                    {
                      "name": "Text",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "What is the patient's full name?"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    },
                    {
                      "name": "Alias",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "PATIENT_NAME"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    }
                  ]
                },
                {
                  "type": "OBJECT",
                  "value": [
                    {
                      "name": "Text",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "What is the patient's date of birth?"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    },
                    {
                      "name": "Alias",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "PATIENT_DOB"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    }
                  ]
                },
                {
                  "type": "OBJECT",
                  "value": [
                    {
                      "name": "Text",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "Who is the ordering provider or physician?"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    },
                    {
                      "name": "Alias",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "ORDERING_PROVIDER"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    }
                  ]
                },
                {
                  "type": "OBJECT",
                  "value": [
                    {
                      "name": "Text",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "Which laboratory performed the tests?"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    },
                    {
                      "name": "Alias",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "LAB_NAME"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    }
                  ]
                },
                {
                  "type": "OBJECT",
                  "value": [
                    {
                      "name": "Text",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "What is the accession number or specimen ID?"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    },
                    {
                      "name": "Alias",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "ACCESSION"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    }
                  ]
                },
                {
                  "type": "OBJECT",
                  "value": [
                    {
                      "name": "Text",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "When was the specimen collected?"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    },
                    {
                      "name": "Alias",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "COLLECTED"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    }
                  ]
                },
                {
                  "type": "OBJECT",
                  "value": [
                    {
                      "name": "Text",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "When did the lab receive the specimen?"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    },
                    {
                      "name": "Alias",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "RECEIVED"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    }
                  ]
                },
                {
                  "type": "OBJECT",
                  "value": [
                    {
                      "name": "Text",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "When was the report released or reported?"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    },
                    {
                      "name": "Alias",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "REPORTED"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    }
                  ]
                },
                {
                  "type": "OBJECT",
                  "value": [
                    {
                      "name": "Text",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "Is the report final, preliminary or corrected?"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    },
                    {
                      "name": "Alias",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "REPORT_STATUS"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    }
                  ]
                }
              ]
            },
            {
              "name": "clientRequestToken",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "healthie-"
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Gate",
                    "subPathSegments": [
                      {
                        "key": "documentId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "D4A8A974-BDCD-46FB-BBED-39CA6B0C29FA"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "jobTag",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "healthie-lab"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "startDocumentAnalysis",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Job",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "aws-textract",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Start reading every page",
        "nextElementIds": [
          "1B947839-D93E-4EC0-819E-5111964E339C"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Saves a document from a patient's Healthie chart to FlowRunner file storage and returns its file URL, so a flow can fax, email or archive it. The saved file is named after the document, prefixed with its Healthie ID.",
          "elementId": "EXTENSION:::SHARED:::default:::healthie:::downloadDocument",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Download the report Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::downloadDocument",
          "legacyElementId": null,
          "methodName": "downloadDocument",
          "position": {
            "x": 1193,
            "y": 210
          }
        },
        "flowElementId": "0E51DFCE-F9E4-481F-8402-3AD9892DF245",
        "groupId": null,
        "id": "07359311-6887-4D3A-B8A9-34B2B94FEC71",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "patientId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "documentId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Gate",
                    "subPathSegments": [
                      {
                        "key": "documentId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "D4A8A974-BDCD-46FB-BBED-39CA6B0C29FA"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "fileOptions",
              "type": "OBJECT",
              "value": [
                {
                  "name": "scope",
                  "type": "SIMPLE",
                  "value": {
                    "expression": [
                      {
                        "id": "TEXT",
                        "label": null,
                        "type": "INPUT",
                        "value": "FLOW"
                      }
                    ],
                    "mode": "BASIC",
                    "parseJsonString": false,
                    "resultType": null
                  }
                }
              ]
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "downloadDocument",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Report file",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Download the report",
        "nextElementIds": [
          "A7DC8571-2FED-4004-9880-DBCA752218F0"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "wait",
          "isFirstElement": false,
          "blockDefinitionId": "wait",
          "mode": "SIMPLE",
          "position": {
            "x": 1164,
            "y": 49
          }
        },
        "flowElementId": "77015D31-7DE5-4973-A966-1CDA2D949492",
        "groupId": null,
        "id": "197D37EF-C5FD-41B9-AB94-C20A7744AF37",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "delay": {
            "expression": [
              {
                "id": "NUMBER",
                "label": null,
                "type": "INPUT",
                "value": 120
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": "DOUBLE"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "pause0",
          "storeResult": true
        },
        "name": "Give other steps time to save",
        "nextElementIds": [
          "216A4180-EA3E-4BC5-83CA-9B696D429F29"
        ],
        "nextGroupIds": [],
        "type": "WAIT"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1572,
            "y": 219
          }
        },
        "flowElementId": "49610A7E-613C-415D-8028-89456271CBAF",
        "groupId": null,
        "id": "5CE350D4-1460-4BCC-BDF2-B13D8494F05A",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "c2094545-bb65-419f-8dbe-fcf7dc491b27",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Gate",
                      "subPathSegments": [
                        {
                          "key": "read",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "D4A8A974-BDCD-46FB-BBED-39CA6B0C29FA"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "c2094545-bb65-419f-8dbe-fcf7dc491b27"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "readit",
          "storeResult": false,
          "thenComponent": {
            "componentId": "07359311-6887-4D3A-B8A9-34B2B94FEC71",
            "componentType": "ELEMENT"
          }
        },
        "name": "New lab report to read?",
        "nextElementIds": [
          "07359311-6887-4D3A-B8A9-34B2B94FEC71"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "data-bucket",
          "isFirstElement": false,
          "blockDefinitionId": "data-bucket",
          "fieldKeys": {
            "Reading done": "95eba9d3-d686-4abc-8a67-6905a1deccab",
            "Textract result": "26d3a3c0-48da-423e-bcce-76918e871167"
          },
          "position": {
            "x": 1193,
            "y": 389
          }
        },
        "flowElementId": "82EE0ADA-9EA1-48EA-9FB7-0CED0B84DEA3",
        "groupId": null,
        "id": "1B947839-D93E-4EC0-819E-5111964E339C",
        "metaInfo": {
          "bucketName": "Default",
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "fields": [
            {
              "name": "Reading done",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "no"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "Textract result",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EMPTY_OBJECT",
                    "label": null,
                    "type": "KEYWORD",
                    "value": "general.createObject()"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "bucket0",
          "storeResult": true
        },
        "name": "Not read yet",
        "nextElementIds": [],
        "nextGroupIds": [
          "06CAFD90-694D-470B-88E4-232A12F94310"
        ],
        "type": "DATA_BUCKET"
      },
      {
        "clientMetadata": {
          "notes": "Retrieves the results of an asynchronous document analysis job started by Start Document Analysis. Returns the JobStatus (IN_PROGRESS, SUCCEEDED, FAILED, or PARTIAL_SUCCESS). When SUCCEEDED, this operation automatically paginates through all result pages and returns the full set of Blocks plus convenience extractions across the whole document: form key-value pairs, a query-to-answer map with a matching query-to-confidence map (queryConfidence, 0-100, null where a query has no answer), and simplified table rows. Poll this operation until JobStatus is no longer IN_PROGRESS.",
          "elementId": "EXTENSION:::SHARED:::default:::aws-textract:::getDocumentAnalysis",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Check the reading Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::aws-textract:::getDocumentAnalysis",
          "legacyElementId": "JS###v1###Textract###getDocumentAnalysis",
          "methodName": "getDocumentAnalysis",
          "position": {
            "x": 434,
            "y": 490
          }
        },
        "flowElementId": "AF7A5112-6559-4689-AB9A-016C1EDDCDF7",
        "groupId": "06CAFD90-694D-470B-88E4-232A12F94310",
        "id": "E65CDFFC-87A3-4F9B-AA9B-807CBD1ACE27",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "jobId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Job",
                    "subPathSegments": [
                      {
                        "key": "jobId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "62D35910-DD82-4804-904B-A5AB1771E116"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "getDocumentAnalysis",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Analysis",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "aws-textract",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Check the reading",
        "nextElementIds": [
          "60F230D1-5DC9-4DF0-8FA1-1EB410DACECD"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1959,
            "y": 689
          }
        },
        "flowElementId": "0E4620D4-D7A2-42DC-AEA0-39F252D44E12",
        "groupId": null,
        "id": "BDBF73D7-EF99-4DDA-BC79-CA1859F40612",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "89c2cc04-469d-4dea-9641-8973dfd313fb",
                "nestedOperation": null,
                "operation": "equal",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Read",
                      "subPathSegments": [
                        {
                          "key": "status",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "49E067B4-CB58-4AD6-991E-99C382C76DBE"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "TEXT",
                        "label": null,
                        "type": "INPUT",
                        "value": "SUCCEEDED"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "89c2cc04-469d-4dea-9641-8973dfd313fb"
            ]
          },
          "elseComponent": {
            "componentId": "7BA3366C-05F6-46E6-BF48-0CC7FEBE8C91",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "readok",
          "storeResult": false,
          "thenComponent": {
            "componentId": "C6414BB6-02AA-463C-8D71-2538FDA83D7E",
            "componentType": "ELEMENT"
          }
        },
        "name": "Read every page?",
        "nextElementIds": [
          "C6414BB6-02AA-463C-8D71-2538FDA83D7E",
          "7BA3366C-05F6-46E6-BF48-0CC7FEBE8C91"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Check every value Result"
          },
          "position": {
            "x": 802,
            "y": 689
          }
        },
        "flowElementId": "A89B59B1-E8C8-47D2-B5CC-3D07EE8893DA",
        "groupId": null,
        "id": "326BAA81-40AF-4889-9DF4-3B19A1D8D1B6",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "report",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Report",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C6414BB6-02AA-463C-8D71-2538FDA83D7E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "read",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Read",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "49E067B4-CB58-4AD6-991E-99C382C76DBE"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "alertNote",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "The report is on the patient's Healthie chart and the provider gets a review task."
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const r0 = report || {};\nconst norm = (s) => String(s == null ? '' : s).replace(/\\s+/g, ' ').trim();\nconst key = (s) => norm(s).toLowerCase();\nconst cellSet = new Set(((read && read.cells) || []).map(key));\nconst unsureCells = (read && read.unsureCells) || [];\nconst unsureSet = new Set(unsureCells.map((c) => key(c.text)));\nconst num = (s) => { const m = /^[<>]?=?\\s*(-?\\d+(?:\\.\\d+)?)$/.exec(norm(s).replace(/,/g, '')); return m ? Number(m[1]) : null; };\nconst bounds = (range) => {\n  const r = norm(range).replace(/,/g, '');\n  let m = /^(-?\\d+(?:\\.\\d+)?)\\s*(?:-|–|to)\\s*(-?\\d+(?:\\.\\d+)?)/i.exec(r);\n  if (m) return { low: Number(m[1]), high: Number(m[2]) };\n  m = /^(<=|≤|<|less than|under)\\s*(-?\\d+(?:\\.\\d+)?)/i.exec(r);\n  if (m) return { high: Number(m[2]), highOpen: !/=|≤/.test(m[1]) };\n  m = /^(>=|≥|>|greater than|over)\\s*(-?\\d+(?:\\.\\d+)?)/i.exec(r);\n  if (m) return { low: Number(m[2]), lowOpen: !/=|≥/.test(m[1]) };\n  return null;\n};\nconst outside = (value, range) => {\n  if (/^[<>]/.test(norm(value))) return false;\n  const v = num(value); const b = bounds(range);\n  if (v === null || !b) return false;\n  if (b.low != null && (b.lowOpen ? v <= b.low : v < b.low)) return true;\n  if (b.high != null && (b.highOpen ? v >= b.high : v > b.high)) return true;\n  return false;\n};\nconst DRCHRONO_FLAGS = ['N', 'L', 'LL', 'H', 'HH', '<', '>', 'A', 'AA', 'S', 'R', 'I', 'NEG', 'POS'];\nconst results = (Array.isArray(r0.results) ? r0.results : []).filter((r) => norm(r.test) && norm(r.value)).map((r) => {\n  const flag = norm(r.flag);\n  const value = norm(r.value);\n  const labFlagged = !/^(n|normal)?$/i.test(flag);\n  const critical = /\\b(HH|LL|AA)\\b|crit|panic/i.test(flag);\n  const asPrinted = [value, flag ? `${value} ${flag}` : '', flag ? `${value}${flag}` : ''].filter(Boolean).some((s) => cellSet.has(key(s)));\n  const unsureHere = [r.test, value, r.units, r.range, flag].filter((s) => norm(s)).some((s) => unsureSet.has(key(s)));\n  return {\n    test: norm(r.test), code: norm(r.code), value, units: norm(r.units), range: norm(r.range), flag,\n    labFlagged, critical, outsideRange: outside(value, r.range), asPrinted,\n    needsCheck: !asPrinted || unsureHere,\n    why: !asPrinted ? 'not found as printed in the tables Textract read' : (unsureHere ? 'Textract was unsure of this cell' : ''),\n  };\n});\nconst line = (r) => `${r.test}: ${r.value}${r.units ? ' ' + r.units : ''}${r.range ? ` (lab range ${r.range})` : ''}${r.flag ? `, lab flag ${r.flag}` : ''}`;\nconst flagged = results.filter((r) => r.labFlagged);\nconst critical = results.filter((r) => r.critical);\nconst outsideOnly = results.filter((r) => r.outsideRange && !r.labFlagged);\nconst toCheck = results.filter((r) => r.needsCheck);\nconst used = new Set(results.flatMap((r) => [r.test, r.value, r.units, r.range, r.flag]).filter(Boolean).map(key));\nconst otherUnsure = unsureCells.filter((c) => !used.has(key(c.text))).slice(0, 15);\nconst sections = [];\nif (critical.length) sections.push('Flagged critical by the lab:\\n' + critical.map((r) => '- ' + line(r)).join('\\n'));\nconst flaggedOnly = flagged.filter((r) => !r.critical);\nif (flaggedOnly.length) sections.push('Flagged by the lab:\\n' + flaggedOnly.map((r) => '- ' + line(r)).join('\\n'));\nif (outsideOnly.length) sections.push('Outside the lab\\'s printed range, with no lab flag:\\n' + outsideOnly.map((r) => '- ' + line(r)).join('\\n'));\nconst notFound = results.filter((r) => !r.asPrinted);\nif (notFound.length) sections.push('Could not be matched to the tables Textract read, so read these on the page itself:\\n' + notFound.map((r) => '- ' + line(r)).join('\\n'));\nconst unsureRows = toCheck.filter((r) => r.asPrinted);\nif (unsureRows.length || otherUnsure.length) sections.push('Check these against the page:\\n' + unsureRows.map((r) => `- ${line(r)} (${r.why})`).concat(otherUnsure.map((c) => `- \"${c.text}\" on page ${c.page} (Textract was ${c.confidence}% sure)`)).join('\\n'));\nsections.push('Every value on the report:\\n' + results.map((r) => '- ' + line(r)).join('\\n'));\nconst who = `${norm(r0.patientFirstName)} ${norm(r0.patientLastName)}`.trim() || 'a patient';\nconst dob = norm(r0.patientDateOfBirth) || 'birth date not printed';\nconst alertLines = [\n  `*${critical.length ? 'Critical lab value' : 'Lab-flagged value'}* for ${who}, born ${dob}`,\n  `${norm(r0.panelName) || 'Lab result'} from ${norm(r0.labName) || 'the lab'}${norm(r0.orderingProvider) ? `, ordered by ${norm(r0.orderingProvider)}` : ''}${norm(r0.collectionDate) ? `, collected ${norm(r0.collectionDate)}` : ''}`,\n  ...critical.map((r) => '• ' + line(r)),\n  ...flagged.filter((r) => !r.critical).map((r) => '• ' + line(r)),\n];\nif (flagged.some((r) => r.needsCheck)) alertLines.push('Some of these cells were hard to read. Check them against the report.');\nalertLines.push('The values are copied from the report with the lab\\'s own flags. ' + (alertNote || ''));\nreturn {\n  results, count: results.length,\n  anyFlagged: flagged.length > 0, anyCritical: critical.length > 0, anyToCheck: toCheck.length + otherUnsure.length > 0,\n  reviewText: sections.join('\\n\\n'),\n  alertText: alertLines.join('\\n'),\n  drchronoResults: results.filter((r) => r.asPrinted).map((r) => {\n    const b = bounds(r.range);\n    const two = b && b.low != null && b.high != null && !b.lowOpen && !b.highOpen;\n    const flagUpper = r.flag.toUpperCase();\n    return {\n      observationCode: r.code, observationDescription: r.test, value: r.value,\n      valueIsNumeric: num(r.value) !== null && !/^[<>]/.test(r.value),\n      unit: r.units, normalRange: two ? `${b.low} ${b.high}` : '',\n      abnormalStatus: !r.labFlagged ? '' : (DRCHRONO_FLAGS.includes(flagUpper) ? flagUpper : (r.critical ? 'AA' : 'A')),\n      isAbnormal: r.labFlagged,\n      comments: [r.range && !two ? `Lab range as printed: ${r.range}` : '', r.flag && !DRCHRONO_FLAGS.includes(flagUpper) ? `Lab flag as printed: ${r.flag}` : '', r.needsCheck ? `Check against the report: ${r.why}` : ''].filter(Boolean).join('. '),\n    };\n  }),\n  healthieResults: results.filter((r) => r.asPrinted).map((r) => ({\n    analyte: r.test,\n    value: num(r.value) !== null && !/^[<>]/.test(r.value) ? r.value : '',\n    qualitativeResult: num(r.value) !== null && !/^[<>]/.test(r.value) ? '' : r.value,\n    units: r.units, referenceRange: r.range, abnormalFlag: r.labFlagged ? r.flag : '',\n    notes: r.needsCheck ? `Check against the report: ${r.why}` : '',\n  })),\n};\n"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Checked",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Check every value",
        "nextElementIds": [
          "A9C71DDC-34FF-4C97-AB63-C58B5E7DC1D5",
          "FF6035CC-EC7E-4C97-853F-771F9A2F6942"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "ai-agent",
          "isFirstElement": false,
          "blockDefinitionId": "ai-agent",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Line up the results Result"
          },
          "tools": {},
          "position": {
            "x": 1583,
            "y": 689
          }
        },
        "flowElementId": "7B967103-ED3B-45B7-8969-5BF5E5A6C1B9",
        "groupId": null,
        "id": "C6414BB6-02AA-463C-8D71-2538FDA83D7E",
        "metaInfo": {
          "aiApiKey": null,
          "aiModel": "claude-sonnet-5",
          "aiProvider": "ANTHROPIC",
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "dynamicAiApiKey": {
            "expression": [
              {
                "id": "PLACEHOLDER_DATA",
                "label": "Anthropic key",
                "subPathSegments": null,
                "type": "EXECUTION_CONTEXT_STATIC_DATA",
                "value": "Anthropic key"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "files": [],
          "forceParsedOutput": true,
          "langSmithSettings": {
            "enabled": false,
            "apiKey": null,
            "projectName": null,
            "label": "FlowRunner AI-Agent",
            "accountCluster": "US"
          },
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "messagesHistoryEnabled": false,
          "messagesHistoryLimit": 15,
          "onFailElemId": null,
          "resultAlias": "Report",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "systemPrompt": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "You arrange a lab report that Amazon Textract has already read. You get Textract's answers to questions about the report and every table it found, row by row, with cells separated by |. Reply with JSON only, with these fields:\nisLabResult: true if the document is a lab result report with test values; false for anything else, such as a lab order or requisition, a specimen rejection notice or a cover sheet\npatientFirstName: the patient's first name as printed\npatientLastName: the patient's last name as printed\npatientDateOfBirth: the patient's date of birth as YYYY-MM-DD, or empty text if it is not printed\norderingProvider: the ordering provider's full name as printed, without titles such as Dr. or MD, or empty text\nlabName: the lab that performed the tests, such as Quest Diagnostics, or empty text\npanelName: the panel or test that was ordered, such as Comprehensive Metabolic Panel; several panels joined with a comma\npanelCode: the lab's code for that panel if it is printed, otherwise empty text\naccessionNumber: the accession number or specimen ID, or empty text\ncollectionDate, receivedDate, reportedDate: each as YYYY-MM-DDTHH:MM:SS in the time printed on the report, or empty text when it is not printed\nreportStatus: final, preliminary or corrected, as printed, or empty text\nresults: one entry per result row in the tables, in the order printed, each with test (the name as printed), code (a LOINC or lab code only when the row prints one, otherwise empty text), value (the result exactly as printed, without its flag), units, range (the reference range exactly as printed), flag (the abnormal or critical flag exactly as printed in the row, such as H, L, HH, LL, A or CRIT, or empty text when the row has none)\nRules: copy every value, unit, range and flag exactly as Textract gives it. Never correct, convert or round a value. When a value and its flag share a cell, such as 182 H, put 182 in value and H in flag. Never add a flag the report does not print, and never say whether a value is normal. Leave out header rows, comments and footers. Never guess a value that is not in the text."
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "tools": [],
          "type": "AI_AGENT",
          "userPrompt": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "The document "
              },
              {
                "id": "RESULT",
                "label": "Doc",
                "subPathSegments": [
                  {
                    "key": "document",
                    "optional": false
                  },
                  {
                    "key": "display_name",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "F60737F8-957C-41E8-9D81-299B1147C5F9"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": " was filed in the lab results folder of a patient's Healthie chart. Textract read all "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Read",
                "subPathSegments": [
                  {
                    "key": "pages",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "49E067B4-CB58-4AD6-991E-99C382C76DBE"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": " pages.\n\nAnswers to questions about the report:\n"
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Read",
                "subPathSegments": [
                  {
                    "key": "queriesText",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "49E067B4-CB58-4AD6-991E-99C382C76DBE"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\n\nTables, row by row:\n"
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Read",
                "subPathSegments": [
                  {
                    "key": "tablesText",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "49E067B4-CB58-4AD6-991E-99C382C76DBE"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          }
        },
        "name": "Line up the results",
        "nextElementIds": [
          "5AB5E95C-2827-4318-AF2F-53222CB3B6A7"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Sends messages to Slack channels with optional Block Kit rich layouts. Supports plain text with Slack formatting, or advanced Block Kit JSON for buttons, menus, and interactive elements. Returns the message timestamp and channel ID for later updates or tracking.",
          "elementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "isFirstElement": false,
          "dynamicOptionLabels": {
            "channelId": {}
          },
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Tell the care team it is not a result Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "legacyElementId": "JS###v1###Slack###sendMessageToChannel",
          "methodName": "sendMessageToChannel",
          "position": {
            "x": 756,
            "y": 550
          }
        },
        "flowElementId": "AE2788A0-4061-42BC-935C-D120ED5AB3E9",
        "groupId": null,
        "id": "F35C9728-C679-4686-8335-AD9FB6751BCD",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "channelId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ""
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "messageText",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Doc",
                    "subPathSegments": [
                      {
                        "key": "document",
                        "optional": false
                      },
                      {
                        "key": "display_name",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "F60737F8-957C-41E8-9D81-299B1147C5F9"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " is in the lab results folder of "
                  },
                  {
                    "id": "RESULT",
                    "label": "Doc",
                    "subPathSegments": [
                      {
                        "key": "document",
                        "optional": false
                      },
                      {
                        "key": "rel_user",
                        "optional": false
                      },
                      {
                        "key": "full_name",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "F60737F8-957C-41E8-9D81-299B1147C5F9"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "'s Healthie chart, but it does not read as a lab result, so no review task was made. <https://secure.gethealthie.com/users/"
                  },
                  {
                    "id": "RESULT",
                    "label": "Doc",
                    "subPathSegments": [
                      {
                        "key": "document",
                        "optional": false
                      },
                      {
                        "key": "rel_user_id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "F60737F8-957C-41E8-9D81-299B1147C5F9"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "|Open the chart> to check it."
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "threadId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sendAsBot",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "botName",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "botIcon",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "replyBroadcast",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "imageURL",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "blocks",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "sendMessageToChannel",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Other note",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Tell the care team it is not a result",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Sends messages to Slack channels with optional Block Kit rich layouts. Supports plain text with Slack formatting, or advanced Block Kit JSON for buttons, menus, and interactive elements. Returns the message timestamp and channel ID for later updates or tracking.",
          "elementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "isFirstElement": false,
          "dynamicOptionLabels": {
            "channelId": {}
          },
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Tell the care team it could not be read Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "legacyElementId": "JS###v1###Slack###sendMessageToChannel",
          "methodName": "sendMessageToChannel",
          "position": {
            "x": 1539,
            "y": 810
          }
        },
        "flowElementId": "B14B325B-4125-48A5-BBB0-FF6D2862346D",
        "groupId": null,
        "id": "7BA3366C-05F6-46E6-BF48-0CC7FEBE8C91",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "channelId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ""
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "messageText",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "No review task was made for "
                  },
                  {
                    "id": "RESULT",
                    "label": "Doc",
                    "subPathSegments": [
                      {
                        "key": "document",
                        "optional": false
                      },
                      {
                        "key": "display_name",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "F60737F8-957C-41E8-9D81-299B1147C5F9"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " in the lab results folder of "
                  },
                  {
                    "id": "RESULT",
                    "label": "Doc",
                    "subPathSegments": [
                      {
                        "key": "document",
                        "optional": false
                      },
                      {
                        "key": "rel_user",
                        "optional": false
                      },
                      {
                        "key": "full_name",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "F60737F8-957C-41E8-9D81-299B1147C5F9"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "'s Healthie chart: "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Read",
                    "subPathSegments": [
                      {
                        "key": "problem",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "49E067B4-CB58-4AD6-991E-99C382C76DBE"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ". <https://secure.gethealthie.com/users/"
                  },
                  {
                    "id": "RESULT",
                    "label": "Doc",
                    "subPathSegments": [
                      {
                        "key": "document",
                        "optional": false
                      },
                      {
                        "key": "rel_user_id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "F60737F8-957C-41E8-9D81-299B1147C5F9"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "|Open the chart> and review it by hand."
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "threadId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sendAsBot",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "botName",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "botIcon",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "replyBroadcast",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "imageURL",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "blocks",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "sendMessageToChannel",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Unread note",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Tell the care team it was not read",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Gather what Textract read Result"
          },
          "position": {
            "x": 1939,
            "y": 389
          }
        },
        "flowElementId": "ED017155-13F4-4B99-ADB5-EB7667FE9003",
        "groupId": null,
        "id": "49E067B4-CB58-4AD6-991E-99C382C76DBE",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "analysis",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                    "label": "Default - Textract result",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.dataBuckets.Default.Textract result",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "dataBuckets",
                        "optional": false
                      },
                      {
                        "key": "Default",
                        "optional": false
                      },
                      {
                        "key": "Textract result",
                        "optional": false
                      }
                    ]
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "confidenceFloor",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Confidence floor",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Confidence floor"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const a = analysis || {};\nconst blocks = Array.isArray(a.blocks) ? a.blocks : [];\nconst byId = new Map(blocks.map((b) => [b.Id, b]));\nconst words = (b) => ((b && b.Relationships) || []).filter((r) => r.Type === 'CHILD').flatMap((r) => r.Ids || []).map((id) => byId.get(id)).filter((c) => c && c.BlockType === 'WORD');\nconst floor = Number(confidenceFloor) || 90;\nconst unsureCells = [];\nfor (const b of blocks) {\n  if (b.BlockType !== 'CELL') continue;\n  const w = words(b);\n  const text = w.map((x) => x.Text).join(' ').trim();\n  if (!text) continue;\n  const confidence = Math.min(...w.map((x) => (typeof x.Confidence === 'number' ? x.Confidence : 100)));\n  if (confidence < floor) unsureCells.push({ text, page: b.Page || 1, confidence: Math.round(confidence) });\n}\nconst clean = (c) => String(c == null ? '' : c).replace(/\\s+/g, ' ').trim();\nconst tables = (Array.isArray(a.tables) ? a.tables : []).map((t) => (Array.isArray(t.rows) ? t.rows : []).map((r) => (Array.isArray(r) ? r : []).map(clean)));\nconst cells = tables.flat(2).filter(Boolean);\nconst tablesText = tables.map((rows, i) => `Table ${i + 1}\\n` + rows.map((r) => r.join(' | ')).join('\\n')).join('\\n\\n');\nconst queries = a.queries || {};\nconst queriesText = Object.keys(queries).map((k) => `${k}: ${queries[k] == null ? '(no answer)' : queries[k]}`).join('\\n');\nconst status = a.jobStatus || '';\nconst problem = status === 'SUCCEEDED' ? '' : (status === 'FAILED' ? 'Textract could not read it' : (status === 'PARTIAL_SUCCESS' ? 'Textract read only part of it' : 'Textract had not finished reading it after 15 minutes, so the reading timed out'));\nreturn { status, problem, pages: a.pages || 0, tableCount: tables.length, tablesText, queriesText, cells, unsureCells };\n"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Read",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Gather what Textract read",
        "nextElementIds": [
          "BDBF73D7-EF99-4DDA-BC79-CA1859F40612"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1193,
            "y": 689
          }
        },
        "flowElementId": "14E4FAF5-1C89-463C-91BB-926BC18B9DDB",
        "groupId": null,
        "id": "5AB5E95C-2827-4318-AF2F-53222CB3B6A7",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "77f1378a-e415-4800-9d6d-ae248496b0f5",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Report",
                      "subPathSegments": [
                        {
                          "key": "output",
                          "optional": false
                        },
                        {
                          "key": "isLabResult",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "C6414BB6-02AA-463C-8D71-2538FDA83D7E"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "77f1378a-e415-4800-9d6d-ae248496b0f5"
            ]
          },
          "elseComponent": {
            "componentId": "F35C9728-C679-4686-8335-AD9FB6751BCD",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "islab",
          "storeResult": false,
          "thenComponent": {
            "componentId": "326BAA81-40AF-4889-9DF4-3B19A1D8D1B6",
            "componentType": "ELEMENT"
          }
        },
        "name": "Lab result?",
        "nextElementIds": [
          "326BAA81-40AF-4889-9DF4-3B19A1D8D1B6",
          "F35C9728-C679-4686-8335-AD9FB6751BCD"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Creates a to-do in Healthie for your staff, such as \"Call patient to schedule intake\", optionally linked to a patient, assigned to team members and given a due date.",
          "elementId": "EXTENSION:::SHARED:::default:::healthie:::createTask",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Review task for the provider Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::createTask",
          "legacyElementId": null,
          "methodName": "createTask",
          "position": {
            "x": 1557,
            "y": 980
          }
        },
        "flowElementId": "21BBA140-F952-457A-B56F-8C65EA26D9AA",
        "groupId": null,
        "id": "B61213F4-42D1-4766-BE02-99E5C2B8C3C1",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "content",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Review",
                    "subPathSegments": [
                      {
                        "key": "content",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "7D8DFC37-A3D8-4BFD-B4DA-5D5762584DB0"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "patientId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Doc",
                    "subPathSegments": [
                      {
                        "key": "document",
                        "optional": false
                      },
                      {
                        "key": "rel_user_id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "F60737F8-957C-41E8-9D81-299B1147C5F9"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "assigneeIds",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Review",
                    "subPathSegments": [
                      {
                        "key": "assignees",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "7D8DFC37-A3D8-4BFD-B4DA-5D5762584DB0"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dueDate",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "highPriority",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Review",
                    "subPathSegments": [
                      {
                        "key": "highPriority",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "7D8DFC37-A3D8-4BFD-B4DA-5D5762584DB0"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "createTask",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Review task",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Review task for the provider",
        "nextElementIds": [
          "13C9E40E-2145-40BC-862C-DB29BDEF9668"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Sends messages to Slack channels with optional Block Kit rich layouts. Supports plain text with Slack formatting, or advanced Block Kit JSON for buttons, menus, and interactive elements. Returns the message timestamp and channel ID for later updates or tracking.",
          "elementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "isFirstElement": false,
          "dynamicOptionLabels": {
            "channelId": {}
          },
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Ask intake to check the chart Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "legacyElementId": "JS###v1###Slack###sendMessageToChannel",
          "methodName": "sendMessageToChannel",
          "position": {
            "x": 1930,
            "y": 1150
          }
        },
        "flowElementId": "80C75A98-CDEA-4D0C-BAE5-0A35E75EA85B",
        "groupId": null,
        "id": "24D8637B-656A-4E4B-99A9-36B4A4196050",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "channelId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ""
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "messageText",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Review",
                    "subPathSegments": [
                      {
                        "key": "mismatchText",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "7D8DFC37-A3D8-4BFD-B4DA-5D5762584DB0"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "threadId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sendAsBot",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "botName",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "botIcon",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "replyBroadcast",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "imageURL",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "blocks",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "sendMessageToChannel",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Chart check",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Tell intake to check the chart",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Sends messages to Slack channels with optional Block Kit rich layouts. Supports plain text with Slack formatting, or advanced Block Kit JSON for buttons, menus, and interactive elements. Returns the message timestamp and channel ID for later updates or tracking.",
          "elementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "isFirstElement": false,
          "dynamicOptionLabels": {
            "channelId": {}
          },
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Tell the provider now Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "legacyElementId": "JS###v1###Slack###sendMessageToChannel",
          "methodName": "sendMessageToChannel",
          "position": {
            "x": 110,
            "y": 680
          }
        },
        "flowElementId": "5C1168D3-4E3D-4985-B14B-1D506600CCC9",
        "groupId": null,
        "id": "51B845A0-7D85-4D45-986F-AAF7DE02C3A7",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "channelId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ""
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "messageText",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Checked",
                    "subPathSegments": [
                      {
                        "key": "alertText",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "326BAA81-40AF-4889-9DF4-3B19A1D8D1B6"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "\n<https://secure.gethealthie.com/users/"
                  },
                  {
                    "id": "RESULT",
                    "label": "Doc",
                    "subPathSegments": [
                      {
                        "key": "document",
                        "optional": false
                      },
                      {
                        "key": "rel_user_id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "F60737F8-957C-41E8-9D81-299B1147C5F9"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "|Open the chart>"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "threadId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sendAsBot",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "botName",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "botIcon",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "replyBroadcast",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "imageURL",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "blocks",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "sendMessageToChannel",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Alert",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Tell the provider now",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Compare the report with the chart Result"
          },
          "position": {
            "x": 1147,
            "y": 989
          }
        },
        "flowElementId": "40DE82E4-24F6-4DAE-99EF-79C6A9A1B0B0",
        "groupId": null,
        "id": "7D8DFC37-A3D8-4BFD-B4DA-5D5762584DB0",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "report",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Report",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C6414BB6-02AA-463C-8D71-2538FDA83D7E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "patient",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Patient",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "A9C71DDC-34FF-4C97-AB63-C58B5E7DC1D5"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "checked",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Checked",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "326BAA81-40AF-4889-9DF4-3B19A1D8D1B6"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "providers",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Ordering providers",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Ordering providers"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "docName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Doc",
                    "subPathSegments": [
                      {
                        "key": "document",
                        "optional": false
                      },
                      {
                        "key": "display_name",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "F60737F8-957C-41E8-9D81-299B1147C5F9"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "chartLink",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "https://secure.gethealthie.com/users/"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const s = (v) => String(v == null ? '' : v).trim();\nconst n = (v) => s(v).toLowerCase().replace(/[^a-z]/g, '');\nconst p = patient || {};\nconst reportName = `${s(report.patientFirstName)} ${s(report.patientLastName)}`.trim() || 'no name printed';\nconst reportDob = s(report.patientDateOfBirth).slice(0, 10);\nconst chartName = s(p.full_name) || `${s(p.first_name)} ${s(p.last_name)}`.trim();\nconst chartDob = s(p.dob).slice(0, 10);\nconst matches = n(report.patientFirstName) === n(p.first_name) && n(report.patientLastName) === n(p.last_name) && Boolean(reportDob) && reportDob === chartDob;\nconst map = providers && typeof providers === 'object' ? providers : {};\nconst provider = s(report.orderingProvider).toLowerCase();\nconst key = Object.keys(map).find((k) => k !== 'default' && k.trim() && provider.includes(k.trim().toLowerCase()));\nconst assignee = s((key && map[key]) || p.dietitian_id || map.default);\nconst panel = s(report.panelName) || 'lab result';\nconst mismatch = matches ? '' : `Check that this report is on the right chart. The report names ${reportName}, born ${reportDob || 'date not printed'}. The chart is ${chartName}, born ${chartDob || 'unknown'}.`;\nconst content = [\n  `Review lab result: ${panel} for ${chartName}`,\n  mismatch,\n  `From ${s(report.labName) || 'the lab'}, ordered by ${s(report.orderingProvider) || 'a provider not printed on the report'}. Document: ${s(docName)}, in the lab results folder.`,\n  assignee ? '' : 'No provider was found for this task. Assign it to the ordering provider.',\n  checked.count ? '' : 'No values could be read from the tables on this report. Read the report itself.',\n  '',\n  checked.reviewText,\n].filter((x, i) => x !== '' || i === 5).join('\\n');\nreturn {\n  content,\n  assignees: assignee ? [assignee] : [],\n  highPriority: Boolean(checked.anyFlagged) || !matches,\n  matches,\n  mismatchText: `*A lab report may be on the wrong Healthie chart.* ${mismatch} <${chartLink}${s(p.id)}|Open the chart>`,\n};\n"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Review",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Compare the report with the chart",
        "nextElementIds": [
          "B61213F4-42D1-4766-BE02-99E5C2B8C3C1"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1938,
            "y": 989
          }
        },
        "flowElementId": "6FDD5134-BFD5-40BC-8D32-CE733C43ACBD",
        "groupId": null,
        "id": "13C9E40E-2145-40BC-862C-DB29BDEF9668",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "0a7deafa-213d-4a19-a5e2-913953f7da27",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Review",
                      "subPathSegments": [
                        {
                          "key": "matches",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "7D8DFC37-A3D8-4BFD-B4DA-5D5762584DB0"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "0a7deafa-213d-4a19-a5e2-913953f7da27"
            ]
          },
          "elseComponent": {
            "componentId": "24D8637B-656A-4E4B-99A9-36B4A4196050",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "same",
          "storeResult": false,
          "thenComponent": null
        },
        "name": "Report matches the chart?",
        "nextElementIds": [
          "24D8637B-656A-4E4B-99A9-36B4A4196050"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Gets a patient's demographics from Healthie: name, date of birth, contact details, record ID, assigned provider and address.",
          "elementId": "EXTENSION:::SHARED:::default:::healthie:::getPatient",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Get the patient's chart Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::getPatient",
          "legacyElementId": null,
          "methodName": "getPatient",
          "position": {
            "x": 795,
            "y": 980
          }
        },
        "flowElementId": "6E84B99F-7322-4848-93B8-2AB142B4C270",
        "groupId": null,
        "id": "A9C71DDC-34FF-4C97-AB63-C58B5E7DC1D5",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "patientId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Doc",
                    "subPathSegments": [
                      {
                        "key": "document",
                        "optional": false
                      },
                      {
                        "key": "rel_user_id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "F60737F8-957C-41E8-9D81-299B1147C5F9"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "getPatient",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Patient",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Get the patient's chart",
        "nextElementIds": [
          "7D8DFC37-A3D8-4BFD-B4DA-5D5762584DB0"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 415,
            "y": 689
          }
        },
        "flowElementId": "4E69E4F8-98F0-4FA9-A9B9-0B95E3D8F8CB",
        "groupId": null,
        "id": "FF6035CC-EC7E-4C97-853F-771F9A2F6942",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "99e35797-66da-4e8c-8997-94677fb6f67c",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Checked",
                      "subPathSegments": [
                        {
                          "key": "anyFlagged",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "326BAA81-40AF-4889-9DF4-3B19A1D8D1B6"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "99e35797-66da-4e8c-8997-94677fb6f67c"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "anyflag",
          "storeResult": false,
          "thenComponent": {
            "componentId": "51B845A0-7D85-4D45-986F-AAF7DE02C3A7",
            "componentType": "ELEMENT"
          }
        },
        "name": "Any value the lab flagged?",
        "nextElementIds": [
          "51B845A0-7D85-4D45-986F-AAF7DE02C3A7"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      }
    ],
    "firstElementId": "F60737F8-957C-41E8-9D81-299B1147C5F9",
    "groups": [
      {
        "clientMetadata": {
          "elementId": "repeat",
          "isFirstElement": false,
          "blockDefinitionId": "repeat",
          "viewport": {
            "x": -70,
            "y": -450,
            "zoom": 1
          },
          "position": {
            "x": 1565,
            "y": 389
          }
        },
        "flowElementId": "DECC3E3F-7512-4645-AF74-FA68411EC824",
        "groupId": null,
        "id": "06CAFD90-694D-470B-88E4-232A12F94310",
        "loopType": "REPEAT",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "35850f99-3f19-4928-a86f-5444f32626ab",
                "nestedOperation": null,
                "operation": "notEqual",
                "property": {
                  "expression": [
                    {
                      "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                      "label": "Default - Reading done",
                      "subPathSegments": null,
                      "type": "EXECUTION_CONTEXT_PATH",
                      "value": "executionContext.dataBuckets.Default.Reading done",
                      "valueSegments": [
                        {
                          "key": "executionContext",
                          "optional": false
                        },
                        {
                          "key": "dataBuckets",
                          "optional": false
                        },
                        {
                          "key": "Default",
                          "optional": false
                        },
                        {
                          "key": "Reading done",
                          "optional": false
                        }
                      ]
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "TEXT",
                        "label": null,
                        "type": "INPUT",
                        "value": "yes"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "35850f99-3f19-4928-a86f-5444f32626ab"
            ]
          },
          "enabled": true,
          "firstElementId": "1D038F2A-A131-4D8A-8BC4-F1428C677CCD",
          "maxIterations": 90,
          "onFailElemId": null,
          "resultAlias": "loop",
          "storeResult": true
        },
        "name": "Wait for Textract to finish",
        "nextElementIds": [
          "49E067B4-CB58-4AD6-991E-99C382C76DBE"
        ],
        "nextGroupIds": [],
        "type": "LOOP"
      }
    ],
    "id": "532300F3-9FFB-4A9B-94CC-0BDFACEBEE05",
    "metaInfo": {
      "clientValidationState": {
        "errorMessage": null,
        "valid": true
      },
      "errorMessage": null,
      "executionStaticData": [
        {
          "description": "The Anthropic key the AI step uses.",
          "error": null,
          "name": "Anthropic key",
          "type": "API_KEY",
          "value": null
        },
        {
          "description": "An S3 bucket in the same AWS region as your Textract settings, where each report is stored so Textract can read every page.",
          "error": null,
          "name": "S3 bucket",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "Cells Textract read with less confidence than this (0 to 100) are listed on the review task to check against the page.",
          "error": null,
          "name": "Confidence floor",
          "type": "INT",
          "value": ""
        },
        {
          "description": "Healthie provider IDs keyed by the last name printed on reports as the ordering provider. A name not listed gives the task to the patient's own provider in Healthie, then to default.",
          "error": null,
          "name": "Ordering providers",
          "type": "OBJECT",
          "value": ""
        }
      ],
      "initialData": null,
      "initialDataDefaultValues": {},
      "ownerFlowVersionId": null,
      "schedule": null,
      "sharedMemory": {
        "anchor": {
          "missingAnchorPolicy": null,
          "path": null,
          "type": "FLOW_MEMORY"
        },
        "expirationInSec": null
      },
      "wasLive": false
    }
  },
  "slaCalendars": [],
  "slaGoals": [],
  "subFlows": [],
  "exportDate": "2026-12-02T03:31:51.320Z"
}
