{
  "elementsLearnedData": [],
  "elementsTestData": [],
  "flow": {
    "id": "A0225AC5-EA69-470C-A845-81F9B50BC93C",
    "name": "AWS Textract: discharge med list into CareTend"
  },
  "flowVersion": {
    "clientMetadata": {
      "viewport": {
        "x": -4,
        "y": 24,
        "zoom": 0.4
      },
      "autoSave": false,
      "descriptions": {
        "flow": "A multi-page hospital discharge medication list faxed to the SRFax line for a home health or infusion admission is read with AWS Textract (Start Document Analysis, tables and queries), and an AI step lists each medication as printed. The patient is matched in CareTend on name and birth date; a near, double or missing match goes to the intake coordinator in Slack, and the flow never creates a patient. The list is filed on the patient, and the clinician named in the Admitting clinician setting confirms each medication in a Slack direct message. Only the confirmed ones are added with Create Medication Profile; medications the list says to stop are shown and never added. When nobody is named or the clinician is not found in Slack, the clinical team's channel gets the list with no buttons and a CareTend task is created to enter the medications by hand.",
        "initialData": "",
        "initialDataFields": {}
      }
    },
    "description": "",
    "elements": [
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1198,
            "y": 170
          }
        },
        "flowElementId": "011A4988-8DB7-428A-AE0E-C34540F438E2",
        "groupId": null,
        "id": "884E3A4D-5587-4955-8A8E-659E8737F01C",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "c7382d66-2f01-4240-9189-3f5beb5d1fc0",
                "nestedOperation": null,
                "operation": "isNotEmpty",
                "property": {
                  "expression": [
                    {
                      "id": "RESULT",
                      "label": "Fax",
                      "subPathSegments": [
                        {
                          "key": "file",
                          "optional": false
                        },
                        {
                          "key": "url",
                          "optional": false
                        }
                      ],
                      "type": "TRIGGER_DATA",
                      "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": []
              }
            ],
            "grouping": [
              "c7382d66-2f01-4240-9189-3f5beb5d1fc0"
            ]
          },
          "elseComponent": {
            "componentId": "C3888890-93CC-41BB-8392-C4A4ED7A72DB",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "cPdf",
          "storeResult": false,
          "thenComponent": {
            "componentId": "BC0EAD20-D741-45E4-83B7-468A12359FF1",
            "componentType": "ELEMENT"
          }
        },
        "name": "Fax PDF saved?",
        "nextElementIds": [
          "BC0EAD20-D741-45E4-83B7-468A12359FF1",
          "C3888890-93CC-41BB-8392-C4A4ED7A72DB"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Fires once for each new fax received by your SRFax account, with the fax's details (Fax ID, sender number, receive time, page count, size) and its PDF saved to FlowRunner file storage at workspace scope, returned in \"file\" with the saved file's URL, name, content type and size. It does not change the fax's read status in SRFax. Optionally only fires for faxes received on chosen fax numbers. The first poll only records the faxes already there; faxes arriving after it are emitted, up to 10 per poll.",
          "elementId": "EXTENSION:::SHARED:::default:::srfax:::onNewInboundFax",
          "isFirstElement": true,
          "blockDefinitionId": "EXTENSION:::SHARED:::default:::srfax:::onNewInboundFax",
          "newElementId": "EXTENSION:::SHARED:::default:::srfax:::onNewInboundFax",
          "legacyElementId": null,
          "methodName": "onNewInboundFax",
          "position": {
            "x": 789,
            "y": 161
          }
        },
        "flowElementId": "E98A06F4-CCBE-46F2-95A8-3A417D783EB3",
        "groupId": null,
        "id": "292E1713-CAF4-4228-B80B-A2CE12FF9A06",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": null,
          "connectionId": null,
          "dynamicData": [],
          "eventName": "onNewInboundFax",
          "frequency": {
            "repeat": {
              "every": 300
            },
            "schedule": "custom"
          },
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Fax",
          "serviceId": "srfax",
          "slaConditions": [],
          "staticData": {},
          "storeResult": true,
          "subtype": "POLLING",
          "type": "CUSTOM"
        },
        "name": "New fax on SRFax",
        "nextElementIds": [
          "884E3A4D-5587-4955-8A8E-659E8737F01C"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "elementId": "data-bucket",
          "isFirstElement": false,
          "blockDefinitionId": "data-bucket",
          "fieldKeys": {
            "Reading done": "229bceff-76ce-4090-8964-4ac1217a8509",
            "Textract result": "0ee3146a-f534-4ebd-9d71-8b90813d9524",
            "Reading error": "909f6a24-48fc-42fe-a3f1-bb4e8b881075"
          },
          "position": {
            "x": 2005,
            "y": 170
          }
        },
        "flowElementId": "19FEFDF0-9E8C-4D69-A902-827AD96E9CD2",
        "groupId": null,
        "id": "C6C0F2C8-D1DC-4BFC-87CE-66D2E90D6592",
        "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
              }
            },
            {
              "name": "Reading error",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "none"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "bucket0",
          "storeResult": true
        },
        "name": "Not read yet",
        "nextElementIds": [],
        "nextGroupIds": [
          "70B37F1E-5412-47EE-9AB5-09158EB65A4B"
        ],
        "type": "DATA_BUCKET"
      },
      {
        "clientMetadata": {
          "elementId": "wait",
          "isFirstElement": true,
          "blockDefinitionId": "wait",
          "mode": "SIMPLE",
          "position": {
            "x": 110,
            "y": 449
          }
        },
        "flowElementId": "E6E92809-8ED9-46C2-8685-5CF4250B5818",
        "groupId": "70B37F1E-5412-47EE-9AB5-09158EB65A4B",
        "id": "B03B64BA-B778-43F6-B55B-31004C374957",
        "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": "waitT",
          "storeResult": true
        },
        "name": "Give Textract a moment",
        "nextElementIds": [
          "A1E7EC00-3D82-420A-85CF-0BE285F487EF"
        ],
        "nextGroupIds": [],
        "type": "WAIT"
      },
      {
        "clientMetadata": {
          "notes": "Starts an asynchronous document analysis job over a document 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. Give the document as an S3 Bucket and S3 Object Name, or as a FlowRunner File URL: the file is then uploaded to the connection's Staging S3 Bucket (or the S3 Bucket given here) under flowrunner-textract/, and the result also returns that s3Bucket and s3Name. The staged object is not deleted, because Textract reads it after this action returns: expire it with an S3 lifecycle rule on the prefix, or delete it once the job has finished. The bucket must be in the same region as this integration, and the credentials need s3:PutObject and s3:GetObject on it.",
          "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": 1588,
            "y": 161
          }
        },
        "flowElementId": "7C678702-12C5-439F-B4A6-794C2364BDEE",
        "groupId": null,
        "id": "BC0EAD20-D741-45E4-83B7-468A12359FF1",
        "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": "fileUrl",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "file",
                        "optional": false
                      },
                      {
                        "key": "url",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "s3Bucket",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "s3Name",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "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": "Which hospital is discharging the patient?"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    },
                    {
                      "name": "Alias",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "HOSPITAL"
                          }
                        ],
                        "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 discharge date?"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    },
                    {
                      "name": "Alias",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "DISCHARGE_DATE"
                          }
                        ],
                        "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 attending or discharging physician?"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    },
                    {
                      "name": "Alias",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "ATTENDING"
                          }
                        ],
                        "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 title of this document?"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    },
                    {
                      "name": "Alias",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "DOC_TITLE"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    }
                  ]
                },
                {
                  "type": "OBJECT",
                  "value": [
                    {
                      "name": "Text",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "Where is the patient being discharged to?"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    },
                    {
                      "name": "Alias",
                      "type": "SIMPLE",
                      "value": {
                        "expression": [
                          {
                            "id": "TEXT",
                            "label": null,
                            "type": "INPUT",
                            "value": "DESTINATION"
                          }
                        ],
                        "mode": "EXPRESSION",
                        "parseJsonString": false,
                        "resultType": null
                      }
                    }
                  ]
                }
              ]
            },
            {
              "name": "clientRequestToken",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "srfax-"
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "FaxDetailsID",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "jobTag",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "discharge-meds"
                  }
                ],
                "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": "3BCD44BA-FE9C-46F0-8E64-580F92A5E457",
          "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": [
          "C6C0F2C8-D1DC-4BFC-87CE-66D2E90D6592"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "ai-agent",
          "isFirstElement": false,
          "blockDefinitionId": "ai-agent",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Read the medication list Result"
          },
          "tools": {},
          "position": {
            "x": 777,
            "y": 340
          }
        },
        "flowElementId": "818F80ED-7945-4446-8E64-498A0E470AE9",
        "groupId": null,
        "id": "C2915390-7A92-4B9B-B309-862C4BAF0C1D",
        "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": "AAE0E137-EBCD-47FE-972F-392936ABAAC1",
          "resultAlias": "Meds",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "systemPrompt": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "You arrange a hospital discharge medication list that Amazon Textract has already read from a fax. A discharge medication list is the list of medications a hospital gives a patient at discharge; hospitals also call it a discharge medication reconciliation, discharge summary medications or after visit summary. It often runs several pages. You get Textract's answers to questions about the document, every table it found row by row with cells separated by |, the plain lines of text, and the cells Textract was unsure of. Reply with JSON only, with these fields:\nreadable: false when the text is too sparse, garbled or cut off to tell what the document is or to read its medications; otherwise true\nisDischargeMedList: true if the document is a hospital discharge medication list or a discharge summary that lists the discharge medications and it can be read; false for anything else, such as a referral form, a prescription, a lab result, a fill history or a cover sheet, and false when readable is false\npatientFirstName, patientLastName: the patient's names as printed\npatientDateOfBirth: the patient's date of birth as YYYY-MM-DD, or empty text if it is not printed\nhospital, dischargeDate (YYYY-MM-DD, or as printed when it is unclear), attending: as printed, or empty text\nmedications: one entry per medication, in the order printed, each with drug (the drug name as printed, without the strength), strength (as printed, such as 40 mg), dose (the amount per dose as printed, or empty text), route (as printed, or empty text), frequency (as printed, or empty text), directions (the full instructions as printed), instruction (continue, new, changed or stop, only when the list prints it; otherwise empty text), unsure (true when any cell of the row is in the list of cells Textract was unsure of)\nRules: copy everything exactly as Textract gives it. Use the tables first and the lines of text only for medications that are not in a table. A medication the list says to stop goes in with instruction stop. Never correct a drug name, strength, dose or date, never convert units, never merge two rows, never add a medication that is not printed, and never say whether a medication is right for the patient. Leave out header rows, allergies, diagnoses, notes and footers."
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "tools": [],
          "type": "AI_AGENT",
          "userPrompt": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "A fax came in on the SRFax line from "
              },
              {
                "id": "RESULT",
                "label": "Fax",
                "subPathSegments": [
                  {
                    "key": "CallerID",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": " "
              },
              {
                "id": "RESULT",
                "label": "Fax",
                "subPathSegments": [
                  {
                    "key": "RemoteID",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": ". Textract read "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Read",
                "subPathSegments": [
                  {
                    "key": "pages",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "8A5973C0-10C8-4AC9-91DB-CAB2330B3CF7"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": " pages.\n\nAnswers to questions about the document:\n"
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Read",
                "subPathSegments": [
                  {
                    "key": "queriesText",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "8A5973C0-10C8-4AC9-91DB-CAB2330B3CF7"
              },
              {
                "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": "8A5973C0-10C8-4AC9-91DB-CAB2330B3CF7"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\n\nLines of text:\n"
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Read",
                "subPathSegments": [
                  {
                    "key": "linesText",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "8A5973C0-10C8-4AC9-91DB-CAB2330B3CF7"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\n\nCells Textract was unsure of:\n"
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Read",
                "subPathSegments": [
                  {
                    "key": "unsureText",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "8A5973C0-10C8-4AC9-91DB-CAB2330B3CF7"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          }
        },
        "name": "Read the medication list",
        "nextElementIds": [
          "24DE420D-D115-4C67-91BB-164F31165C81"
        ],
        "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": 1582,
            "y": 340
          }
        },
        "flowElementId": "9399CEB3-A31B-4F19-A62C-13CC3A625F23",
        "groupId": null,
        "id": "8A5973C0-10C8-4AC9-91DB-CAB2330B3CF7",
        "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
              }
            },
            {
              "name": "readingError",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                    "label": "Default - Reading error",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.dataBuckets.Default.Reading error",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "dataBuckets",
                        "optional": false
                      },
                      {
                        "key": "Default",
                        "optional": false
                      },
                      {
                        "key": "Reading error",
                        "optional": false
                      }
                    ]
                  }
                ],
                "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 tablesText = tables.map((rows, i) => `Table ${i + 1}\\n` + rows.map((r) => r.join(' | ')).join('\\n')).join('\\n\\n') || '(no tables found)';\nconst linesText = blocks.filter((b) => b.BlockType === 'LINE').map((b) => `p${b.Page || 1}: ${clean(b.Text)}`).join('\\n').slice(0, 30000);\nconst queries = a.queries || {};\nconst queriesText = Object.keys(queries).map((k) => `${k}: ${queries[k] == null ? '(no answer)' : queries[k]}`).join('\\n');\nconst unsureText = unsureCells.length ? unsureCells.map((c) => `\"${c.text}\" on page ${c.page} (${c.confidence}%)`).join('\\n') : 'none';\nconst status = a.jobStatus || '';\nconst chars = blocks.filter((b) => b.BlockType === 'WORD').map((b) => String(b.Text || '')).join('').replace(/\\s/g, '').length;\nconst err = clean(readingError) === 'none' ? '' : clean(readingError);\nlet 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.'));\nif (err) problem = `Textract returned an error while reading it: ${err}`;\nelse if (!problem && chars < 80) problem = 'Textract found almost no text on it, so it may be blank or too faint to read.';\nreturn { status, problem, pages: a.pages || 0, chars, tableCount: tables.length, tablesText, linesText, queriesText, unsureCells, unsureText };\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": [
          "AE809AF9-449A-4EC0-8933-E8557CBE718B"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 769,
            "y": 900
          }
        },
        "flowElementId": "91363A89-3823-47E1-8A32-A1A2DAE793D7",
        "groupId": null,
        "id": "24DE420D-D115-4C67-91BB-164F31165C81",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "80216016-3fc9-4afa-ab97-942091a45e84",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Meds",
                      "subPathSegments": [
                        {
                          "key": "output",
                          "optional": false
                        },
                        {
                          "key": "isDischargeMedList",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "80216016-3fc9-4afa-ab97-942091a45e84"
            ]
          },
          "elseComponent": {
            "componentId": "CF2BB9DB-559F-4153-8141-171B92A4BA91",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "cList",
          "storeResult": false,
          "thenComponent": {
            "componentId": "C860E76C-7D69-4B83-884B-A1A61EDA214F",
            "componentType": "ELEMENT"
          }
        },
        "name": "Discharge medication list?",
        "nextElementIds": [
          "CF2BB9DB-559F-4153-8141-171B92A4BA91",
          "C860E76C-7D69-4B83-884B-A1A61EDA214F"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "error-handler",
          "isFirstElement": false,
          "blockDefinitionId": "error-handler",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Textract could not start Result"
          },
          "position": {
            "x": 1994,
            "y": 40
          }
        },
        "flowElementId": "335F6788-7DC2-4F4A-A13F-86DFF7B67DC8",
        "groupId": null,
        "id": "3BCD44BA-FE9C-46F0-8E64-580F92A5E457",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Textract error",
          "saveToVariable": null,
          "storeResult": true
        },
        "name": "Textract could not start",
        "nextElementIds": [
          "C3888890-93CC-41BB-8392-C4A4ED7A72DB"
        ],
        "nextGroupIds": [],
        "type": "ERROR_HANDLER"
      },
      {
        "clientMetadata": {
          "elementId": "data-bucket",
          "isFirstElement": false,
          "blockDefinitionId": "data-bucket",
          "fieldKeys": {
            "Reading done": "164e1510-c130-46eb-8334-c2e42430b758",
            "Textract result": "e8d41ce0-18b7-4939-957e-278596d1999b"
          },
          "position": {
            "x": 1073,
            "y": 449
          }
        },
        "flowElementId": "0B4E08E4-85E6-4C23-845C-1DBE943DD351",
        "groupId": "70B37F1E-5412-47EE-9AB5-09158EB65A4B",
        "id": "9312F963-6513-4256-B242-E27C62E083E4",
        "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": "A1E7EC00-3D82-420A-85CF-0BE285F487EF"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "keep",
          "storeResult": true
        },
        "name": "Keep what Textract read",
        "nextElementIds": [
          "8F8F4E00-D245-42BA-AE7C-6B5B940F2396"
        ],
        "nextGroupIds": [],
        "type": "DATA_BUCKET"
      },
      {
        "clientMetadata": {
          "elementId": "break-repeat",
          "isFirstElement": false,
          "blockDefinitionId": "break-repeat",
          "position": {
            "x": 1402,
            "y": 449
          }
        },
        "flowElementId": "29CDD5D2-BED6-4AFE-819B-333705D4D329",
        "groupId": "70B37F1E-5412-47EE-9AB5-09158EB65A4B",
        "id": "8F8F4E00-D245-42BA-AE7C-6B5B940F2396",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "brk",
          "storeResult": true
        },
        "name": "Done reading",
        "nextElementIds": [],
        "nextGroupIds": [],
        "type": "BREAK"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 754,
            "y": 449
          }
        },
        "flowElementId": "221E47B5-94D8-47FD-87E8-EB8E6F1139F5",
        "groupId": "70B37F1E-5412-47EE-9AB5-09158EB65A4B",
        "id": "35FCBE56-63C0-4F07-8036-02F88CDEA56E",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "c6218b4f-feb4-4bc4-9fd0-7306b72c018b",
                "nestedOperation": null,
                "operation": "equal",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Analysis",
                      "subPathSegments": [
                        {
                          "key": "jobStatus",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "A1E7EC00-3D82-420A-85CF-0BE285F487EF"
                    }
                  ],
                  "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": [
              "c6218b4f-feb4-4bc4-9fd0-7306b72c018b"
            ]
          },
          "elseComponent": {
            "componentId": "9312F963-6513-4256-B242-E27C62E083E4",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "cStill",
          "storeResult": false,
          "thenComponent": null
        },
        "name": "Still reading?",
        "nextElementIds": [
          "9312F963-6513-4256-B242-E27C62E083E4"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1198,
            "y": 340
          }
        },
        "flowElementId": "616ADD7A-713C-4C41-8305-CD1EBA64CD12",
        "groupId": null,
        "id": "AE809AF9-449A-4EC0-8933-E8557CBE718B",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "31a5423b-087a-4a88-b6cc-52401ba7579d",
                "nestedOperation": null,
                "operation": "isEmpty",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Read",
                      "subPathSegments": [
                        {
                          "key": "problem",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "8A5973C0-10C8-4AC9-91DB-CAB2330B3CF7"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": []
              }
            ],
            "grouping": [
              "31a5423b-087a-4a88-b6cc-52401ba7579d"
            ]
          },
          "elseComponent": {
            "componentId": "C3888890-93CC-41BB-8392-C4A4ED7A72DB",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "cPages",
          "storeResult": false,
          "thenComponent": {
            "componentId": "C2915390-7A92-4B9B-B309-862C4BAF0C1D",
            "componentType": "ELEMENT"
          }
        },
        "name": "Read every page?",
        "nextElementIds": [
          "C3888890-93CC-41BB-8392-C4A4ED7A72DB",
          "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "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,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Tell intake: fax not read Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "legacyElementId": "JS###v1###Slack###sendMessageToChannel",
          "methodName": "sendMessageToChannel",
          "position": {
            "x": 1592,
            "y": 501
          }
        },
        "flowElementId": "29C64618-145F-4317-9811-37EBDE2E6719",
        "groupId": null,
        "id": "C3888890-93CC-41BB-8392-C4A4ED7A72DB",
        "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": "*A fax on the SRFax line could not be read.* It came from "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "CallerID",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "RemoteID",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " with "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "Pages",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " pages (SRFax fax ID "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "FaxDetailsID",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "). "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Read",
                    "subPathSegments": [
                      {
                        "key": "problem",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "8A5973C0-10C8-4AC9-91DB-CAB2330B3CF7"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Textract error",
                    "subPathSegments": [
                      {
                        "key": "message",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "3BCD44BA-FE9C-46F0-8E64-580F92A5E457"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "\nIf it is a hospital discharge medication list, please file it and have a clinician review it by hand. Nothing was added to any patient. "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "file",
                        "optional": false
                      },
                      {
                        "key": "url",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
                  }
                ],
                "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": "Intake note",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Tell intake: fax not read",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "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": 440
          }
        },
        "flowElementId": "979A06B7-9789-45F7-826F-203C41490F83",
        "groupId": "70B37F1E-5412-47EE-9AB5-09158EB65A4B",
        "id": "A1E7EC00-3D82-420A-85CF-0BE285F487EF",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "jobId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Job",
                    "subPathSegments": [
                      {
                        "key": "jobId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "BC0EAD20-D741-45E4-83B7-468A12359FF1"
                  }
                ],
                "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": "7FA07F18-F490-4A36-B2E2-5AB7D1FA3677",
          "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": [
          "35FCBE56-63C0-4F07-8036-02F88CDEA56E"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 2392,
            "y": 2230
          }
        },
        "flowElementId": "75AEBB13-FA10-49B4-A2D4-720ADEEFD6C1",
        "groupId": null,
        "id": "14876F2F-B9AD-45D9-98DE-C874BCE025F9",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "385233c7-c225-4a3c-86eb-bbb0c1900a61",
                "nestedOperation": null,
                "operation": ">",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Confirmed",
                      "subPathSegments": [
                        {
                          "key": "count",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "9AFDDEE8-BF2A-4D92-856E-C70B3B836EE1"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "INT",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "NUMBER",
                        "label": null,
                        "type": "INPUT",
                        "value": 0
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "385233c7-c225-4a3c-86eb-bbb0c1900a61"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "cAny",
          "storeResult": false,
          "thenComponent": {
            "componentId": "4A3B4E23-54E5-4C88-8E87-EE5F1CEF7746",
            "componentType": "GROUP"
          }
        },
        "name": "Any to add?",
        "nextElementIds": [],
        "nextGroupIds": [
          "4A3B4E23-54E5-4C88-8E87-EE5F1CEF7746"
        ],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "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,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Tell intake: not filed Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "legacyElementId": "JS###v1###Slack###sendMessageToChannel",
          "methodName": "sendMessageToChannel",
          "position": {
            "x": 2392,
            "y": 1701
          }
        },
        "flowElementId": "9D1022EB-15DE-4526-B83D-45C98BAB4F56",
        "groupId": null,
        "id": "415AD554-4FE7-4733-9041-D85761F4B1DB",
        "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": "*A step failed for the discharge medication list for "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientFirstName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "*, from "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "hospital",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ". Step: "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Step error",
                    "subPathSegments": [
                      {
                        "key": "source",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "041839C5-1477-42FE-B207-00F2FD6143F3"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ". The service said: "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Step error",
                    "subPathSegments": [
                      {
                        "key": "message",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "041839C5-1477-42FE-B207-00F2FD6143F3"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ". Nothing was added to the medication profile. Please file it and have a clinician review it by hand. SRFax fax ID "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "FaxDetailsID",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "."
                  }
                ],
                "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": "Step note",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Tell intake: not filed",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Adds a medication to a CareTend patient's medication profile, such as the specialty drug on an incoming prescription. Returns the new medication profile ID. Lookup fields must match values configured in CareTend.",
          "elementId": "EXTENSION:::SHARED:::default:::wellsky-caretend:::createMedicationProfile",
          "isFirstElement": true,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Add it to the medication profile Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::wellsky-caretend:::createMedicationProfile",
          "legacyElementId": null,
          "methodName": "createMedicationProfile",
          "position": {
            "x": 119,
            "y": 1860
          }
        },
        "flowElementId": "75B054CF-85F5-48D4-A850-86402CAD21CF",
        "groupId": "4A3B4E23-54E5-4C88-8E87-EE5F1CEF7746",
        "id": "52760762-C90A-4131-AFD1-A20B6BB856AB",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "medicalRecordNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Chart",
                    "subPathSegments": [
                      {
                        "key": "mrn",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "A9792BD4-EF6B-4EAA-85FF-2828E50BDB8A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "therapyType",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Therapy type",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Therapy type"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "name",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": [
                      {
                        "key": "name",
                        "optional": false
                      }
                    ],
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "4A3B4E23-54E5-4C88-8E87-EE5F1CEF7746"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "strength",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": [
                      {
                        "key": "strength",
                        "optional": false
                      }
                    ],
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "4A3B4E23-54E5-4C88-8E87-EE5F1CEF7746"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "unitOfMeasure",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "frequency",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "route",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "medicationProfileClass",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "startDate",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "stopDate",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "isPrimary",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "comments",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": [
                      {
                        "key": "comments",
                        "optional": false
                      }
                    ],
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "4A3B4E23-54E5-4C88-8E87-EE5F1CEF7746"
                  }
                ],
                "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": "createMedicationProfile",
          "onFailElemId": "A772AD6A-5D10-4188-8770-8FC0AA4B1BB5",
          "packageId": "default",
          "resultAlias": "Added",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "wellsky-caretend",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Add it to the medication profile",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Finds CareTend patients matching the given criteria, such as an MRN, a name and date of birth, a phone number or a policy number. Returns one page of matches with the total count. Use it to check whether a referred patient already exists before creating one.",
          "elementId": "EXTENSION:::SHARED:::default:::wellsky-caretend:::searchPatients",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Search by last name and birth date Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::wellsky-caretend:::searchPatients",
          "legacyElementId": null,
          "methodName": "searchPatients",
          "position": {
            "x": 1956,
            "y": 1061
          }
        },
        "flowElementId": "DCBF5949-A20B-4929-BFB6-6666F490F763",
        "groupId": null,
        "id": "FA8E2F3A-FB33-41D3-A7D4-0FC43B71FB5F",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "medicalRecordNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "externalRecordNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "firstName",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "lastName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dateOfBirth",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientDateOfBirth",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "phoneNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "policyNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "addressZipCode",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "companyId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "includeInactive",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sortBy",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sortDirection",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pageNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pageSize",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 10
                  }
                ],
                "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": "searchPatients",
          "onFailElemId": "041839C5-1477-42FE-B207-00F2FD6143F3",
          "packageId": "default",
          "resultAlias": "By last name",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "wellsky-caretend",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Search by last name and birth date",
        "nextElementIds": [
          "9057AC3D-DA2C-461A-8EFF-448D86C0F455"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "error-handler",
          "isFirstElement": false,
          "blockDefinitionId": "error-handler",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "CareTend refused the medication Result"
          },
          "position": {
            "x": 110,
            "y": 1999
          }
        },
        "flowElementId": "86A76958-89D1-4928-8D1D-025A90949D25",
        "groupId": "4A3B4E23-54E5-4C88-8E87-EE5F1CEF7746",
        "id": "A772AD6A-5D10-4188-8770-8FC0AA4B1BB5",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Add error",
          "saveToVariable": null,
          "storeResult": true
        },
        "name": "CareTend refused the medication",
        "nextElementIds": [
          "8F19EF17-CBAA-48A8-A892-208FF0D99F69"
        ],
        "nextGroupIds": [],
        "type": "ERROR_HANDLER"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 2005,
            "y": 1240
          }
        },
        "flowElementId": "303D75B3-0D0F-4791-B297-6C9EC06F4AE7",
        "groupId": null,
        "id": "95D246CB-E4D8-4EA6-B28D-35E4848F8312",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "c8a31b80-ecc4-43e4-a7ba-80da9b6fc1b9",
                "nestedOperation": null,
                "operation": "isNotEmpty",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Chart",
                      "subPathSegments": [
                        {
                          "key": "mrn",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "A9792BD4-EF6B-4EAA-85FF-2828E50BDB8A"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": []
              }
            ],
            "grouping": [
              "c8a31b80-ecc4-43e4-a7ba-80da9b6fc1b9"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "cChart",
          "storeResult": false,
          "thenComponent": {
            "componentId": "0BCACD26-72D9-4A82-85F3-2C98A6995C09",
            "componentType": "ELEMENT"
          }
        },
        "name": "Patient picked?",
        "nextElementIds": [
          "0BCACD26-72D9-4A82-85F3-2C98A6995C09"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "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,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Tell the clinician: not added Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "legacyElementId": "JS###v1###Slack###sendMessageToChannel",
          "methodName": "sendMessageToChannel",
          "position": {
            "x": 131,
            "y": 2120
          }
        },
        "flowElementId": "09D6E8E9-9974-475E-982F-061AEFDA05DE",
        "groupId": "4A3B4E23-54E5-4C88-8E87-EE5F1CEF7746",
        "id": "8F19EF17-CBAA-48A8-A892-208FF0D99F69",
        "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": "*CareTend did not add "
                  },
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": [
                      {
                        "key": "name",
                        "optional": false
                      }
                    ],
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "4A3B4E23-54E5-4C88-8E87-EE5F1CEF7746"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " "
                  },
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": [
                      {
                        "key": "strength",
                        "optional": false
                      }
                    ],
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "4A3B4E23-54E5-4C88-8E87-EE5F1CEF7746"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " to the medication profile of "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Chart",
                    "subPathSegments": [
                      {
                        "key": "name",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "A9792BD4-EF6B-4EAA-85FF-2828E50BDB8A"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ", MRN "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Chart",
                    "subPathSegments": [
                      {
                        "key": "mrn",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "A9792BD4-EF6B-4EAA-85FF-2828E50BDB8A"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ".* It was confirmed in Slack from the discharge list, which is filed on the patient. CareTend said: "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Add error",
                    "subPathSegments": [
                      {
                        "key": "message",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "A772AD6A-5D10-4188-8770-8FC0AA4B1BB5"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ". Please enter it by hand. SRFax fax ID "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "FaxDetailsID",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "."
                  }
                ],
                "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": "Not added note",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Tell the clinician: not added",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Write the card for the clinician Result"
          },
          "position": {
            "x": 756,
            "y": 1540
          }
        },
        "flowElementId": "A255932E-F307-49A4-8E01-0C38A0A07A19",
        "groupId": null,
        "id": "DE56B5AA-128C-4493-8F14-C49A7A1B2738",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "chart",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Chart",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "A9792BD4-EF6B-4EAA-85FF-2828E50BDB8A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "list",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "faxUrl",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Fresh copy",
                    "subPathSegments": [
                      {
                        "key": "url",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0BCACD26-72D9-4A82-85F3-2C98A6995C09"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "members",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Members",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "CBAB4E5B-0070-4002-8553-62C0F39DAAEE"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "clinician",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Admitting clinician",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Admitting clinician"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "answerLink",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Clinician answer link",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Clinician answer link"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "executionId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EXECUTION_ID",
                    "label": null,
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.executionId",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "executionId",
                        "optional": false
                      }
                    ]
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const s = (v) => String(v == null ? '' : v).replace(/\\s+/g, ' ').trim();\nconst link = (params) => `${answerLink}?execution=${encodeURIComponent(executionId)}&${new URLSearchParams(params).toString()}`;\nconst fmt = (d) => { const m = /^(\\d{4})-(\\d{2})-(\\d{2})/.exec(s(d)); return m ? `${m[2]}/${m[3]}/${m[1]}` : (s(d) || 'not printed'); };\nconst want = s(clinician).toLowerCase();\nconst pool = Array.isArray(members) ? members : ((members && (members.members || members.users || members.results || members.items)) || []);\n// Only the named person counts: an exact Slack member ID or email match, never a bot.\nconst member = want && want !== 'none' ? pool.find((m) => m && !m.isBot && !m.botId && s(m.userId) && (s(m.userId).toLowerCase() === want || s(m.email).toLowerCase() === want)) : null;\nconst memberId = member ? s(member.userId) : '';\nconst clinicianName = member ? (s(member.displayName) || s(member.username) || s(member.email)) : '';\nconst all = (list && list.medications) || [];\nconst isStop = (m) => s(m.instruction).toLowerCase() === 'stop';\nconst stop = all.filter(isStop);\nconst keep = all.filter((m) => !isStop(m));\nconst meds = keep.slice(0, 20);\nconst label = (m) => [s(m.drug), s(m.strength)].filter(Boolean).join(' ');\nconst title = `*Hospital discharge medication list for ${chart.name}, born ${fmt(chart.dob)}, MRN ${chart.mrn}*`;\nconst from = `From ${s(list.hospital) || 'the hospital'}, discharged ${fmt(list.dischargeDate)}${s(list.attending) ? `, attending ${s(list.attending)}` : ''}. <${faxUrl}|Open the fax>. It is filed on the patient in CareTend.`;\nconst askHead = [title, from, meds.length ? 'Please check each medication against the fax. Nothing goes on the CareTend medication profile until you choose.' : 'No medication to continue was read from the list. Please check the fax.'].join('\\n');\nconst infoHead = [title, from, 'No admitting clinician is named in the flow or found in Slack, so nothing is added from here. A CareTend task asks for the list to be checked and the medications entered by hand.'].join('\\n');\nconst items = meds.map((m, i) => {\n  const parts = [\n    `*${i + 1}. ${label(m)}*`,\n    [s(m.dose) && `Dose ${s(m.dose)}`, s(m.route) && `route ${s(m.route)}`, s(m.frequency)].filter(Boolean).join(', '),\n    s(m.directions) && `Directions: ${s(m.directions)}`,\n    s(m.instruction) && `The list marks it ${s(m.instruction)}.`,\n  ];\n  if (m.unsure) parts.push('_Textract was unsure of part of this row. Check the fax._');\n  return parts.filter(Boolean).join('\\n');\n});\nif (keep.length > meds.length) items.push(`${keep.length - meds.length} more are on the fax and not listed here. Enter those by hand in CareTend after you check them.`);\nif (stop.length) items.push(`The list says to stop: ${stop.map(label).join(', ')}. These are shown for your information and are never added.`);\nconst sectionsFor = (head) => { const out = []; let buf = head; for (const t of items) { if ((buf + '\\n\\n' + t).length > 2800) { out.push(buf); buf = t; } else buf += '\\n\\n' + t; } out.push(buf); return out.map((t) => ({ type: 'section', text: { type: 'mrkdwn', text: t } })); };\nconst btn = (text, params, style) => ({ type: 'button', ...(style ? { style } : {}), text: { type: 'plain_text', text: text.slice(0, 75) }, url: link(params) });\nconst buttons = [];\nif (meds.length) {\n  buttons.push(btn(meds.length === 1 ? 'Add it' : `Add all ${meds.length}`, { decision: 'all' }, 'primary'));\n  if (meds.length > 1) meds.forEach((m, i) => buttons.push(btn(`Add only ${i + 1}: ${label(m)}`, { decision: 'one', item: String(i + 1) })));\n  buttons.push(btn('Add none', { decision: 'none' }));\n  if (meds.length > 1) buttons.push(btn(\"Some of them: I'll enter them in CareTend\", { decision: 'manual' }));\n} else buttons.push(btn('Noted', { decision: 'none' }));\nconst blocks = sectionsFor(askHead);\nfor (let i = 0; i < buttons.length; i += 25) blocks.push({ type: 'actions', elements: buttons.slice(i, i + 25) });\nconst infoBlocks = sectionsFor(infoHead);\nconst taskNotes = [`Discharge medication list from ${s(list.hospital) || 'the hospital'}, discharged ${fmt(list.dischargeDate)}, filed on the patient. Check each medication against the fax and enter the ones a clinician confirms:`, ...keep.map((m) => `- ${label(m)}${s(m.directions) ? `: ${s(m.directions)}` : ''}`), stop.length ? `The list says to stop: ${stop.map(label).join(', ')}.` : ''].filter(Boolean).join('\\n').slice(0, 3000);\nreturn { memberId, clinicianName, meds, text: `Discharge medication list for ${chart.name}: ${meds.length} medication${meds.length === 1 ? '' : 's'} to confirm`, blocks, infoBlocks, taskNotes, taskStart: new Date().toISOString() };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Card",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Write the card for the clinician",
        "nextElementIds": [
          "86A73F2F-324F-4979-932F-2B83D3906C7B"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "error-handler",
          "isFirstElement": false,
          "blockDefinitionId": "error-handler",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "CareTend or SRFax refused Result"
          },
          "position": {
            "x": 1981,
            "y": 1710
          }
        },
        "flowElementId": "6302FC70-AF75-4158-BCE6-4FEC5FD40CB0",
        "groupId": null,
        "id": "041839C5-1477-42FE-B207-00F2FD6143F3",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Step error",
          "saveToVariable": null,
          "storeResult": true
        },
        "name": "CareTend or SRFax refused",
        "nextElementIds": [
          "415AD554-4FE7-4733-9041-D85761F4B1DB"
        ],
        "nextGroupIds": [],
        "type": "ERROR_HANDLER"
      },
      {
        "clientMetadata": {
          "notes": "Downloads a received or sent fax as a PDF or TIFF and saves it to FlowRunner file storage, returning the saved file's URL, name, content type and size. Optionally marks the fax as read in SRFax.",
          "elementId": "EXTENSION:::SHARED:::default:::srfax:::downloadFax",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Get a fresh copy of the fax Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::srfax:::downloadFax",
          "legacyElementId": null,
          "methodName": "downloadFax",
          "position": {
            "x": 1984,
            "y": 1531
          }
        },
        "flowElementId": "65FABFA3-152A-4BFA-9278-88565C1FD583",
        "groupId": null,
        "id": "0BCACD26-72D9-4A82-85F3-2C98A6995C09",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "direction",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "IN"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "fax",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "FaxDetailsID",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "format",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "PDF"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "markAsViewed",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "subUserId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "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": "downloadFax",
          "onFailElemId": "041839C5-1477-42FE-B207-00F2FD6143F3",
          "packageId": "default",
          "resultAlias": "Fresh copy",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "srfax",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Get a fresh copy of the fax",
        "nextElementIds": [
          "BCB45C10-3006-4609-A505-33E2855E5539"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "external-callback",
          "isFirstElement": false,
          "blockDefinitionId": "external-callback",
          "position": {
            "x": 1154,
            "y": 1240
          }
        },
        "flowElementId": "4D2748D9-2F04-4FEE-925A-D3DFA30F6AFD",
        "groupId": null,
        "id": "3598C70F-6783-46A2-9E38-08DD07C2E012",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": null,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "resultAlias": "Coordinator answer",
          "slaConditions": [],
          "storeResult": true,
          "type": "CALLBACK"
        },
        "name": "Wait for the coordinator's answer",
        "nextElementIds": [
          "A9792BD4-EF6B-4EAA-85FF-2828E50BDB8A"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "notes": "Finds CareTend patients matching the given criteria, such as an MRN, a name and date of birth, a phone number or a policy number. Returns one page of matches with the total count. Use it to check whether a referred patient already exists before creating one.",
          "elementId": "EXTENSION:::SHARED:::default:::wellsky-caretend:::searchPatients",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Search by name without birth date Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::wellsky-caretend:::searchPatients",
          "legacyElementId": null,
          "methodName": "searchPatients",
          "position": {
            "x": 1151,
            "y": 1061
          }
        },
        "flowElementId": "EF99E9D0-3037-49EE-A58D-874CE466C47A",
        "groupId": null,
        "id": "1786B732-FAE2-4CD6-B240-A49E76EF16CE",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "medicalRecordNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "externalRecordNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "firstName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientFirstName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "lastName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dateOfBirth",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "phoneNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "policyNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "addressZipCode",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "companyId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "includeInactive",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sortBy",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sortDirection",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pageNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pageSize",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 10
                  }
                ],
                "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": "searchPatients",
          "onFailElemId": "041839C5-1477-42FE-B207-00F2FD6143F3",
          "packageId": "default",
          "resultAlias": "By name",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "wellsky-caretend",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Search by name without birth date",
        "nextElementIds": [
          "B4D6F4C1-3480-4C70-A20A-575AC0DE4774"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Check the match Result"
          },
          "position": {
            "x": 1602,
            "y": 900
          }
        },
        "flowElementId": "AE03A1F6-E146-48CA-A040-A50223D26CF7",
        "groupId": null,
        "id": "43A8FDFD-ED02-4592-BCF7-9EFB66E68DE5",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "search",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Exact search",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "C860E76C-7D69-4B83-884B-A1A61EDA214F"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "first",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientFirstName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "last",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dob",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientDateOfBirth",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const norm = (s) => String(s || '').toLowerCase().replace(/[^a-z]/g, '');\nconst day = (d) => String(d || '').slice(0, 10);\nconst rows = (search && ((search.result && search.result.data) || search.data)) || [];\nconst same = dob ? rows.filter((p) => day(p.dateOfBirth) === day(dob) && norm(p.firstName) === norm(first) && norm(p.lastName) === norm(last)) : [];\nif (same.length === 1) {\n  const p = same[0];\n  return { exact: true, patientId: String(p.patientId), mrn: String(p.medicalRecordNumber || ''), name: [p.firstName, p.lastName].filter(Boolean).join(' '), dob: day(p.dateOfBirth) };\n}\nreturn { exact: false, sameCount: same.length, reason: same.length > 1 ? `${same.length} patients in CareTend have this name and birth date.` : (dob ? 'No patient in CareTend has this exact name and birth date.' : 'The fax shows no birth date, so it cannot be matched on name and birth date.') };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Match",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Check the match",
        "nextElementIds": [
          "A8BA4CBA-A016-4DD7-9367-7E649136EDBF"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Write the question for the coordinator Result"
          },
          "position": {
            "x": 730,
            "y": 1070
          }
        },
        "flowElementId": "6DA1EFBB-AA86-4CE3-968A-19AC05620E5D",
        "groupId": null,
        "id": "B4D6F4C1-3480-4C70-A20A-575AC0DE4774",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "match",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Match",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "43A8FDFD-ED02-4592-BCF7-9EFB66E68DE5"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "exactSearch",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Exact search",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "C860E76C-7D69-4B83-884B-A1A61EDA214F"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "byLast",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "By last name",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "FA8E2F3A-FB33-41D3-A7D4-0FC43B71FB5F"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "byFirst",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "By first name",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "9057AC3D-DA2C-461A-8EFF-448D86C0F455"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "byName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "By name",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "1786B732-FAE2-4CD6-B240-A49E76EF16CE"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "first",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientFirstName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "last",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dob",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientDateOfBirth",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "hospital",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "hospital",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "faxUrl",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "file",
                        "optional": false
                      },
                      {
                        "key": "url",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "faxId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "FaxDetailsID",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "answerLink",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Answer link",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Answer link"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "executionId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EXECUTION_ID",
                    "label": null,
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.executionId",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "executionId",
                        "optional": false
                      }
                    ]
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const fmt = (d) => { const m = /^(\\d{4})-(\\d{2})-(\\d{2})/.exec(d || ''); return m ? `${m[2]}/${m[3]}/${m[1]}` : (d || 'not given'); };\nconst link = (params) => `${answerLink}?execution=${encodeURIComponent(executionId)}&${new URLSearchParams(params).toString()}`;\nconst rowsOf = (r) => (r && ((r.result && r.result.data) || r.data)) || [];\nconst found = new Map();\nconst add = (result, why) => {\n  for (const p of rowsOf(result)) {\n    if (!p || !p.patientId) continue;\n    const id = String(p.patientId);\n    const c = found.get(id) || { id, mrn: String(p.medicalRecordNumber || ''), name: [p.firstName, p.lastName].filter(Boolean).join(' '), dob: String(p.dateOfBirth || '').slice(0, 10), reasons: [] };\n    if (!c.reasons.includes(why)) c.reasons.push(why);\n    found.set(id, c);\n  }\n};\n// A search with an empty term matches far more widely, so only count a search the fax gave every term for.\nif (first && last && dob) add(exactSearch, 'same name and birth date');\nif (last && dob) add(byLast, 'same last name and birth date');\nif (first && dob) add(byFirst, 'same first name and birth date');\nif (first && last) add(byName, 'same first and last name');\nconst candidates = [...found.values()].sort((a, b) => b.reasons.length - a.reasons.length).slice(0, 5);\nconst name = [first, last].filter(Boolean).join(' ') || 'an unnamed patient';\nconst lines = [`*Hospital discharge medication list for ${name}, born ${fmt(dob)}*, from ${hospital || 'a hospital'}.`, (match && match.reason) || 'No single patient matches.'];\nlines.push(candidates.length ? 'Patients in CareTend who may be this patient:' : 'No patient in CareTend comes close. The flow never creates a patient from a discharge list, so this one needs to be handled by hand.');\nfor (const c of candidates) lines.push(`• ${c.name}, born ${fmt(c.dob)}, MRN ${c.mrn}: ${c.reasons.join(', ')}`);\nlines.push(`<${faxUrl}|Open the fax> (SRFax fax ID ${faxId}). Nothing is filed or added until you pick a patient.`);\nconst buttons = candidates.map((c, i) => ({ type: 'button', ...(i === 0 ? { style: 'primary' } : {}), text: { type: 'plain_text', text: `It is ${c.name}, MRN ${c.mrn}`.slice(0, 75) }, url: link({ decision: 'patient', patient: c.id }) }));\nbuttons.push({ type: 'button', text: { type: 'plain_text', text: candidates.length ? \"None of these, I'll handle it\" : \"I'll handle it by hand\" }, url: link({ decision: 'none' }) });\nreturn { text: `Discharge medication list for ${name}: which CareTend patient?`, blocks: [{ type: 'section', text: { type: 'mrkdwn', text: lines.join('\\n').slice(0, 2900) } }, { type: 'actions', elements: buttons }], candidates };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Question",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Write the question for the coordinator",
        "nextElementIds": [
          "868F2520-2E8E-471F-B54E-ADEB439FE041"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "external-callback",
          "isFirstElement": false,
          "blockDefinitionId": "external-callback",
          "position": {
            "x": 1570,
            "y": 2230
          }
        },
        "flowElementId": "811AB67D-368C-4693-91B0-0563D0845EF0",
        "groupId": null,
        "id": "072610F1-47AA-42CB-B1E7-90FD5D6C7648",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": null,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "resultAlias": "Clinician answer",
          "slaConditions": [],
          "storeResult": true,
          "type": "CALLBACK"
        },
        "name": "Wait for the clinician's answer",
        "nextElementIds": [
          "9AFDDEE8-BF2A-4D92-856E-C70B3B836EE1"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "notes": "Uploads a file to CareTend as a patient document, such as a prescription, a referral form or an insurance card, and attaches it to a patient, an order or another record. The file is downloaded from the URL you give. Returns the new document ID.",
          "elementId": "EXTENSION:::SHARED:::default:::wellsky-caretend:::uploadPatientDocument",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "File the list on the patient Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::wellsky-caretend:::uploadPatientDocument",
          "legacyElementId": null,
          "methodName": "uploadPatientDocument",
          "position": {
            "x": 1586,
            "y": 1531
          }
        },
        "flowElementId": "FD3A1962-A31E-48D4-8DA1-9C21C076AC6C",
        "groupId": null,
        "id": "BCB45C10-3006-4609-A505-33E2855E5539",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "fileUrl",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Fresh copy",
                    "subPathSegments": [
                      {
                        "key": "url",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0BCACD26-72D9-4A82-85F3-2C98A6995C09"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "description",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "Discharge medication list, "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "hospital",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "companyIds",
              "type": "SIMPLE_LIST",
              "value": [
                {
                  "expression": [
                    {
                      "id": "PLACEHOLDER_DATA",
                      "label": "CareTend company ID",
                      "subPathSegments": null,
                      "type": "EXECUTION_CONTEXT_STATIC_DATA",
                      "value": "CareTend company ID"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                }
              ]
            },
            {
              "name": "assignmentType",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "patient"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "assignedEntityId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Chart",
                    "subPathSegments": [
                      {
                        "key": "patientId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "A9792BD4-EF6B-4EAA-85FF-2828E50BDB8A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "category",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "incomingDocumentPath",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "keywords",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "notes",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "Faxed from "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "CallerID",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "RemoteID",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ", SRFax fax ID "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "FaxDetailsID",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ". Discharged "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "dischargeDate",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ". Patient matched: "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Chart",
                    "subPathSegments": [
                      {
                        "key": "how",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "A9792BD4-EF6B-4EAA-85FF-2828E50BDB8A"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ". Medications go on the profile only after a clinician confirms each one in Slack."
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "receivedDate",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "activeDate",
              "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": "uploadPatientDocument",
          "onFailElemId": "041839C5-1477-42FE-B207-00F2FD6143F3",
          "packageId": "default",
          "resultAlias": "Filed",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "wellsky-caretend",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "File the list on the patient",
        "nextElementIds": [
          "CBAB4E5B-0070-4002-8553-62C0F39DAAEE"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Settle on the patient Result"
          },
          "position": {
            "x": 1602,
            "y": 1240
          }
        },
        "flowElementId": "0572EDD7-965B-44C6-B42E-5FB00B1A475E",
        "groupId": null,
        "id": "A9792BD4-EF6B-4EAA-85FF-2828E50BDB8A",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "match",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Match",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "43A8FDFD-ED02-4592-BCF7-9EFB66E68DE5"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "question",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Question",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "B4D6F4C1-3480-4C70-A20A-575AC0DE4774"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "answer",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Coordinator answer",
                    "subPathSegments": null,
                    "type": "TRIGGER_DATA",
                    "value": "3598C70F-6783-46A2-9E38-08DD07C2E012"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "let chart = null;\nif (match && match.exact) chart = { patientId: match.patientId, mrn: match.mrn, name: match.name, dob: match.dob, how: 'exact match on name and birth date' };\nelse if (answer && answer.decision === 'patient') {\n  const c = ((question && question.candidates) || []).find((x) => String(x.id) === String(answer.patient));\n  if (c) chart = { patientId: c.id, mrn: c.mrn, name: c.name, dob: c.dob, how: 'picked by the intake coordinator' };\n}\nreturn chart || { patientId: '', mrn: '', how: 'left for intake to handle by hand' };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Chart",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Settle on the patient",
        "nextElementIds": [
          "95D246CB-E4D8-4EA6-B28D-35E4848F8312"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Finds CareTend patients matching the given criteria, such as an MRN, a name and date of birth, a phone number or a policy number. Returns one page of matches with the total count. Use it to check whether a referred patient already exists before creating one.",
          "elementId": "EXTENSION:::SHARED:::default:::wellsky-caretend:::searchPatients",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Search by first name and birth date Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::wellsky-caretend:::searchPatients",
          "legacyElementId": null,
          "methodName": "searchPatients",
          "position": {
            "x": 1552,
            "y": 1061
          }
        },
        "flowElementId": "27E4853F-5DD5-4673-B4B1-F7878E04B2EC",
        "groupId": null,
        "id": "9057AC3D-DA2C-461A-8EFF-448D86C0F455",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "medicalRecordNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "externalRecordNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "firstName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientFirstName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "lastName",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dateOfBirth",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientDateOfBirth",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "phoneNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "policyNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "addressZipCode",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "companyId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "includeInactive",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sortBy",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sortDirection",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pageNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pageSize",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 10
                  }
                ],
                "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": "searchPatients",
          "onFailElemId": "041839C5-1477-42FE-B207-00F2FD6143F3",
          "packageId": "default",
          "resultAlias": "By first name",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "wellsky-caretend",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Search by first name and birth date",
        "nextElementIds": [
          "1786B732-FAE2-4CD6-B240-A49E76EF16CE"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Pick the confirmed medications Result"
          },
          "position": {
            "x": 1967,
            "y": 2230
          }
        },
        "flowElementId": "6692B853-7528-4536-B283-5F09080455CA",
        "groupId": null,
        "id": "9AFDDEE8-BF2A-4D92-856E-C70B3B836EE1",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "card",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Card",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "DE56B5AA-128C-4493-8F14-C49A7A1B2738"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "answer",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Clinician answer",
                    "subPathSegments": null,
                    "type": "TRIGGER_DATA",
                    "value": "072610F1-47AA-42CB-B1E7-90FD5D6C7648"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "list",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "faxId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "FaxDetailsID",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const s = (v) => String(v == null ? '' : v).replace(/\\s+/g, ' ').trim();\nconst meds = (card && card.meds) || [];\nconst d = s(answer && answer.decision);\nlet chosen = [];\nif (d === 'all') chosen = meds;\nelse if (d === 'one') { const m = meds[Number(answer.item) - 1]; if (m) chosen = [m]; }\nconst source = `the ${s(list && list.hospital) || 'hospital'} discharge medication list${s(list && list.dischargeDate) ? ` of ${s(list.dischargeDate)}` : ''}, SRFax fax ID ${faxId}`;\nconst today = new Date().toISOString().slice(0, 10);\nconst who = s(card && card.clinicianName) || 'the admitting clinician';\nreturn {\n  decision: d,\n  count: chosen.length,\n  meds: chosen.map((m) => ({\n    name: s(m.drug),\n    strength: s(m.strength),\n    comments: [`From ${source}.`, s(m.dose) && `Dose: ${s(m.dose)}.`, s(m.route) && `Route: ${s(m.route)}.`, s(m.frequency) && `Frequency: ${s(m.frequency)}.`, s(m.directions) && `Directions as printed: ${s(m.directions)}.`, s(m.instruction) && `The list marks it ${s(m.instruction)}.`, `Confirmed in a Slack direct message to ${who} on ${today}.`].filter(Boolean).join(' '),\n  })),\n};"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Confirmed",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Pick the confirmed medications",
        "nextElementIds": [
          "14876F2F-B9AD-45D9-98DE-C874BCE025F9"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 2005,
            "y": 900
          }
        },
        "flowElementId": "CA22A061-F52A-420C-B305-73C040CC3B24",
        "groupId": null,
        "id": "A8BA4CBA-A016-4DD7-9367-7E649136EDBF",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "944af930-cd2b-4d71-bfe0-ee437dc21fdf",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Match",
                      "subPathSegments": [
                        {
                          "key": "exact",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "43A8FDFD-ED02-4592-BCF7-9EFB66E68DE5"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "944af930-cd2b-4d71-bfe0-ee437dc21fdf"
            ]
          },
          "elseComponent": {
            "componentId": "FA8E2F3A-FB33-41D3-A7D4-0FC43B71FB5F",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "cMatch",
          "storeResult": false,
          "thenComponent": {
            "componentId": "A9792BD4-EF6B-4EAA-85FF-2828E50BDB8A",
            "componentType": "ELEMENT"
          }
        },
        "name": "One clear match?",
        "nextElementIds": [
          "A9792BD4-EF6B-4EAA-85FF-2828E50BDB8A",
          "FA8E2F3A-FB33-41D3-A7D4-0FC43B71FB5F"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Finds CareTend patients matching the given criteria, such as an MRN, a name and date of birth, a phone number or a policy number. Returns one page of matches with the total count. Use it to check whether a referred patient already exists before creating one.",
          "elementId": "EXTENSION:::SHARED:::default:::wellsky-caretend:::searchPatients",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Find the patient in CareTend Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::wellsky-caretend:::searchPatients",
          "legacyElementId": null,
          "methodName": "searchPatients",
          "position": {
            "x": 1171,
            "y": 891
          }
        },
        "flowElementId": "890BAA4C-3D1B-4044-8028-AB38209FA1E6",
        "groupId": null,
        "id": "C860E76C-7D69-4B83-884B-A1A61EDA214F",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "medicalRecordNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "externalRecordNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "firstName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientFirstName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "lastName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dateOfBirth",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Meds",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientDateOfBirth",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "phoneNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "policyNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "addressZipCode",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "companyId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "includeInactive",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sortBy",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sortDirection",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pageNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pageSize",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 10
                  }
                ],
                "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": "searchPatients",
          "onFailElemId": "041839C5-1477-42FE-B207-00F2FD6143F3",
          "packageId": "default",
          "resultAlias": "Exact search",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "wellsky-caretend",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Find the patient in CareTend",
        "nextElementIds": [
          "43A8FDFD-ED02-4592-BCF7-9EFB66E68DE5"
        ],
        "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,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Ask the intake coordinator Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "legacyElementId": "JS###v1###Slack###sendMessageToChannel",
          "methodName": "sendMessageToChannel",
          "position": {
            "x": 769,
            "y": 1231
          }
        },
        "flowElementId": "63E61049-FB52-4B16-8574-F66D58651C3B",
        "groupId": null,
        "id": "868F2520-2E8E-471F-B54E-ADEB439FE041",
        "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": "Question",
                    "subPathSegments": [
                      {
                        "key": "text",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B4D6F4C1-3480-4C70-A20A-575AC0DE4774"
                  }
                ],
                "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": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Question",
                    "subPathSegments": [
                      {
                        "key": "blocks",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B4D6F4C1-3480-4C70-A20A-575AC0DE4774"
                  }
                ],
                "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": "Question to coordinator",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Ask the intake coordinator",
        "nextElementIds": [
          "3598C70F-6783-46A2-9E38-08DD07C2E012"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "error-handler",
          "isFirstElement": false,
          "blockDefinitionId": "error-handler",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Textract returned an error Result"
          },
          "position": {
            "x": 734,
            "y": 579
          }
        },
        "flowElementId": "3549CDF7-EA6A-4A36-A9A0-A03D7B8BC9B9",
        "groupId": "70B37F1E-5412-47EE-9AB5-09158EB65A4B",
        "id": "7FA07F18-F490-4A36-B2E2-5AB7D1FA3677",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Check error",
          "saveToVariable": null,
          "storeResult": true
        },
        "name": "Textract returned an error",
        "nextElementIds": [
          "75E7F398-1F3B-47BC-9C54-1FBF43ECAB10"
        ],
        "nextGroupIds": [],
        "type": "ERROR_HANDLER"
      },
      {
        "clientMetadata": {
          "notes": "Filters users based on a search string. Matches Slack ID or email exactly, and username or display name partially, all case-insensitive.",
          "elementId": "EXTENSION:::SHARED:::default:::slack:::findMembers",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Find the admitting clinician in Slack Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::findMembers",
          "legacyElementId": "JS###v1###Slack###findMembers",
          "methodName": "findMembers",
          "position": {
            "x": 1148,
            "y": 1531
          }
        },
        "flowElementId": "953F0545-7F94-4227-970D-DF8459E1D5D2",
        "groupId": null,
        "id": "CBAB4E5B-0070-4002-8553-62C0F39DAAEE",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "search",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Admitting clinician",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Admitting clinician"
                  }
                ],
                "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": "findMembers",
          "onFailElemId": "3F5C5478-3B09-4607-80F3-92D29971376E",
          "packageId": "default",
          "resultAlias": "Members",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Find the admitting clinician in Slack",
        "nextElementIds": [
          "DE56B5AA-128C-4493-8F14-C49A7A1B2738"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "break-repeat",
          "isFirstElement": false,
          "blockDefinitionId": "break-repeat",
          "position": {
            "x": 1402,
            "y": 579
          }
        },
        "flowElementId": "48E89EBB-66E8-4048-941D-9084391EA7D9",
        "groupId": "70B37F1E-5412-47EE-9AB5-09158EB65A4B",
        "id": "8BF1D50C-90F4-4B39-AE4A-5D8C37CF06BD",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "brk2",
          "storeResult": true
        },
        "name": "Stop reading",
        "nextElementIds": [],
        "nextGroupIds": [],
        "type": "BREAK"
      },
      {
        "clientMetadata": {
          "elementId": "error-handler",
          "isFirstElement": false,
          "blockDefinitionId": "error-handler",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "AI step failed Result"
          },
          "position": {
            "x": 430,
            "y": 340
          }
        },
        "flowElementId": "D0628458-CBF2-4C7B-AC46-5010E749AA07",
        "groupId": null,
        "id": "AAE0E137-EBCD-47FE-972F-392936ABAAC1",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "AI error",
          "saveToVariable": null,
          "storeResult": true
        },
        "name": "AI step failed",
        "nextElementIds": [
          "A1228BE5-9875-4439-AE62-255E035D31D9"
        ],
        "nextGroupIds": [],
        "type": "ERROR_HANDLER"
      },
      {
        "clientMetadata": {
          "notes": "Creates a scheduled task in CareTend for one or more employees or whole departments, optionally linked to a patient, such as \"Verify benefits for new referral\". Give either an end time or a duration, and at least one employee or department.",
          "elementId": "EXTENSION:::SHARED:::default:::wellsky-caretend:::createTask",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Task: enter the medications by hand Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::wellsky-caretend:::createTask",
          "legacyElementId": null,
          "methodName": "createTask",
          "position": {
            "x": 1548,
            "y": 2091
          }
        },
        "flowElementId": "96ACB5E4-D293-48D6-8C41-E3CC9E98CB27",
        "groupId": null,
        "id": "41A89AF8-8067-4BDE-99C2-6BCC9BE372AC",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "subject",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "Check the discharge medication list and enter the medications"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "startDateTime",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Card",
                    "subPathSegments": [
                      {
                        "key": "taskStart",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "DE56B5AA-128C-4493-8F14-C49A7A1B2738"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "durationMinutes",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 30
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "endDateTime",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "employeeIds",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "departmentIds",
              "type": "SIMPLE_LIST",
              "value": [
                {
                  "expression": [
                    {
                      "id": "PLACEHOLDER_DATA",
                      "label": "CareTend department ID",
                      "subPathSegments": null,
                      "type": "EXECUTION_CONTEXT_STATIC_DATA",
                      "value": "CareTend department ID"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                }
              ]
            },
            {
              "name": "medicalRecordNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Chart",
                    "subPathSegments": [
                      {
                        "key": "mrn",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "A9792BD4-EF6B-4EAA-85FF-2828E50BDB8A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "taskType",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "notes",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Card",
                    "subPathSegments": [
                      {
                        "key": "taskNotes",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "DE56B5AA-128C-4493-8F14-C49A7A1B2738"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "reminderMinutes",
              "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": "createTask",
          "onFailElemId": "041839C5-1477-42FE-B207-00F2FD6143F3",
          "packageId": "default",
          "resultAlias": "Review task",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "wellsky-caretend",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Task: enter the medications by hand",
        "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,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Tell intake: list not read Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "legacyElementId": "JS###v1###Slack###sendMessageToChannel",
          "methodName": "sendMessageToChannel",
          "position": {
            "x": 110,
            "y": 331
          }
        },
        "flowElementId": "C4403A42-5D47-4666-BB29-DC429BAA5C7B",
        "groupId": null,
        "id": "A1228BE5-9875-4439-AE62-255E035D31D9",
        "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": "*A fax on the SRFax line was not read.* The AI step that lists the medications failed: "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "AI error",
                    "subPathSegments": [
                      {
                        "key": "message",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "AAE0E137-EBCD-47FE-972F-392936ABAAC1"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ". It came from "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "CallerID",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "RemoteID",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " with "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "Pages",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " pages (SRFax fax ID "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "FaxDetailsID",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "). If it is a hospital discharge medication list, please file it and have a clinician review it by hand. Nothing was added to any patient. "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "file",
                        "optional": false
                      },
                      {
                        "key": "url",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "292E1713-CAF4-4228-B80B-A2CE12FF9A06"
                  }
                ],
                "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": "AI note",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Tell intake: list not read",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "error-handler",
          "isFirstElement": false,
          "blockDefinitionId": "error-handler",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Clinician not found Result"
          },
          "position": {
            "x": 789,
            "y": 1410
          }
        },
        "flowElementId": "90448170-E202-4EA3-9891-C438982797D1",
        "groupId": null,
        "id": "3F5C5478-3B09-4607-80F3-92D29971376E",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Find error",
          "saveToVariable": null,
          "storeResult": true
        },
        "name": "Clinician not found",
        "nextElementIds": [
          "DE56B5AA-128C-4493-8F14-C49A7A1B2738"
        ],
        "nextGroupIds": [],
        "type": "ERROR_HANDLER"
      },
      {
        "clientMetadata": {
          "notes": "Sends a direct message to a user on Slack 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:::sendDirectMessage",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Ask the admitting clinician Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendDirectMessage",
          "legacyElementId": "JS###v1###Slack###sendDirectMessage",
          "methodName": "sendDirectMessage",
          "position": {
            "x": 1178,
            "y": 2221
          }
        },
        "flowElementId": "5FCD0642-FC04-423A-A5CB-09D5DC7942FD",
        "groupId": null,
        "id": "928C00A8-3311-4153-ACB7-EB686924EC4B",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "userId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Card",
                    "subPathSegments": [
                      {
                        "key": "memberId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "DE56B5AA-128C-4493-8F14-C49A7A1B2738"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "messageText",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Card",
                    "subPathSegments": [
                      {
                        "key": "text",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "DE56B5AA-128C-4493-8F14-C49A7A1B2738"
                  }
                ],
                "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": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Card",
                    "subPathSegments": [
                      {
                        "key": "blocks",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "DE56B5AA-128C-4493-8F14-C49A7A1B2738"
                  }
                ],
                "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": "sendDirectMessage",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Question to clinician",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Ask the admitting clinician",
        "nextElementIds": [
          "072610F1-47AA-42CB-B1E7-90FD5D6C7648"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 789,
            "y": 2230
          }
        },
        "flowElementId": "1773BAE0-5B32-4BEE-9E0A-7FEC0111AA51",
        "groupId": null,
        "id": "86A73F2F-324F-4979-932F-2B83D3906C7B",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "bb3141b3-bea0-4085-8ca5-6f7857efe0b7",
                "nestedOperation": null,
                "operation": "isNotEmpty",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Card",
                      "subPathSegments": [
                        {
                          "key": "memberId",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "DE56B5AA-128C-4493-8F14-C49A7A1B2738"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": []
              }
            ],
            "grouping": [
              "bb3141b3-bea0-4085-8ca5-6f7857efe0b7"
            ]
          },
          "elseComponent": {
            "componentId": "004DBEF1-C98C-4ADB-98AB-D36410256504",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "cDM",
          "storeResult": false,
          "thenComponent": {
            "componentId": "928C00A8-3311-4153-ACB7-EB686924EC4B",
            "componentType": "ELEMENT"
          }
        },
        "name": "Clinician in Slack?",
        "nextElementIds": [
          "928C00A8-3311-4153-ACB7-EB686924EC4B",
          "004DBEF1-C98C-4ADB-98AB-D36410256504"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "data-bucket",
          "isFirstElement": false,
          "blockDefinitionId": "data-bucket",
          "fieldKeys": {
            "Reading done": "bc88e8bf-f43a-4038-a6c9-e1192b0c99a8",
            "Reading error": "cb1c0425-d201-466c-9793-91f7ff349991"
          },
          "position": {
            "x": 1088,
            "y": 579
          }
        },
        "flowElementId": "2A1C8E51-BB98-4ED0-8014-583EC054FADD",
        "groupId": "70B37F1E-5412-47EE-9AB5-09158EB65A4B",
        "id": "75E7F398-1F3B-47BC-9C54-1FBF43ECAB10",
        "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": "Reading error",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Check error",
                    "subPathSegments": [
                      {
                        "key": "message",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "7FA07F18-F490-4A36-B2E2-5AB7D1FA3677"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "stopErr",
          "storeResult": true
        },
        "name": "Keep the error",
        "nextElementIds": [
          "8BF1D50C-90F4-4B39-AE4A-5D8C37CF06BD"
        ],
        "nextGroupIds": [],
        "type": "DATA_BUCKET"
      },
      {
        "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,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Tell the clinical team Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "legacyElementId": "JS###v1###Slack###sendMessageToChannel",
          "methodName": "sendMessageToChannel",
          "position": {
            "x": 1198,
            "y": 2351
          }
        },
        "flowElementId": "EE66D947-470C-4431-AF66-283C18553A77",
        "groupId": null,
        "id": "004DBEF1-C98C-4ADB-98AB-D36410256504",
        "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": "Card",
                    "subPathSegments": [
                      {
                        "key": "text",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "DE56B5AA-128C-4493-8F14-C49A7A1B2738"
                  }
                ],
                "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": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Card",
                    "subPathSegments": [
                      {
                        "key": "infoBlocks",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "DE56B5AA-128C-4493-8F14-C49A7A1B2738"
                  }
                ],
                "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": "Team note",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Tell the clinical team",
        "nextElementIds": [
          "41A89AF8-8067-4BDE-99C2-6BCC9BE372AC"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1198,
            "y": 770
          }
        },
        "flowElementId": "003F6984-A28A-4412-96E7-74F2750D8BB9",
        "groupId": null,
        "id": "CF2BB9DB-559F-4153-8141-171B92A4BA91",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "eb279d06-fd66-4c25-93c0-f756a30bf838",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Meds",
                      "subPathSegments": [
                        {
                          "key": "output",
                          "optional": false
                        },
                        {
                          "key": "readable",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "C2915390-7A92-4B9B-B309-862C4BAF0C1D"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "eb279d06-fd66-4c25-93c0-f756a30bf838"
            ]
          },
          "elseComponent": {
            "componentId": "C3888890-93CC-41BB-8392-C4A4ED7A72DB",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "cReadable",
          "storeResult": false,
          "thenComponent": null
        },
        "name": "Could it be read?",
        "nextElementIds": [
          "C3888890-93CC-41BB-8392-C4A4ED7A72DB"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      }
    ],
    "firstElementId": "292E1713-CAF4-4228-B80B-A2CE12FF9A06",
    "groups": [
      {
        "clientMetadata": {
          "elementId": "repeat",
          "isFirstElement": false,
          "blockDefinitionId": "repeat",
          "viewport": {
            "x": -57.96437659033079,
            "y": -351.85750636132315,
            "zoom": 0.89
          },
          "position": {
            "x": 1987,
            "y": 340
          }
        },
        "flowElementId": "CDD953BA-FB50-4E47-A6A7-771263E0D484",
        "groupId": null,
        "id": "70B37F1E-5412-47EE-9AB5-09158EB65A4B",
        "loopType": "REPEAT",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "18408e91-f179-472d-bf43-bf0f6672238d",
                "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": [
              "18408e91-f179-472d-bf43-bf0f6672238d"
            ]
          },
          "enabled": true,
          "firstElementId": "B03B64BA-B778-43F6-B55B-31004C374957",
          "maxIterations": 90,
          "onFailElemId": null,
          "resultAlias": "loop",
          "storeResult": true
        },
        "name": "Wait for Textract to finish",
        "nextElementIds": [
          "8A5973C0-10C8-4AC9-91DB-CAB2330B3CF7"
        ],
        "nextGroupIds": [],
        "type": "LOOP"
      },
      {
        "clientMetadata": {
          "elementId": "list-iterator",
          "isFirstElement": false,
          "blockDefinitionId": "list-iterator",
          "viewport": {
            "x": -70,
            "y": -1820,
            "zoom": 1
          },
          "position": {
            "x": 2353,
            "y": 2530
          }
        },
        "flowElementId": "EC690DDA-3337-4439-A8C3-4B0162FBA474",
        "groupId": null,
        "id": "4A3B4E23-54E5-4C88-8E87-EE5F1CEF7746",
        "loopType": "LIST_ITERATOR",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "enabled": true,
          "firstElementId": "52760762-C90A-4131-AFD1-A20B6BB856AB",
          "list": {
            "expression": [
              {
                "id": "ELEMENT_RESULT",
                "label": "Confirmed",
                "subPathSegments": [
                  {
                    "key": "meds",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "9AFDDEE8-BF2A-4D92-856E-C70B3B836EE1"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "onFailElemId": null,
          "resultAlias": "each",
          "storeResult": true
        },
        "name": "Add each confirmed medication",
        "nextElementIds": [],
        "nextGroupIds": [],
        "type": "LOOP"
      }
    ],
    "id": "9831658B-2EAC-4B2A-9BA9-79F31A5B72A9",
    "metaInfo": {
      "clientValidationState": {
        "errorMessage": null,
        "valid": true
      },
      "errorMessage": null,
      "executionStaticData": [
        {
          "description": "Your Anthropic API key, used by the AI step that reads the medication list.",
          "error": null,
          "name": "Anthropic key",
          "type": "API_KEY",
          "value": null
        },
        {
          "description": "Textract confidence (0 to 100) below which a cell is marked unsure on the clinician's card.",
          "error": null,
          "name": "Confidence floor",
          "type": "INT",
          "value": ""
        },
        {
          "description": "The CareTend company the discharge list is filed under.",
          "error": null,
          "name": "CareTend company ID",
          "type": "INT",
          "value": ""
        },
        {
          "description": "A value of your CareTend Therapy Type lookup, used for each medication added to the profile.",
          "error": null,
          "name": "Therapy type",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "The URL of the block Wait for the coordinator's answer. The Slack buttons open it.",
          "error": null,
          "name": "Answer link",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "The URL of the block Wait for the clinician's answer. The Slack buttons open it.",
          "error": null,
          "name": "Clinician answer link",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "The Slack member ID or email of the admitting clinician who confirms the medications. Only this person gets the card with the add buttons, as a direct message. With none, or nobody found, the list goes to the channel with no add buttons and a CareTend task.",
          "error": null,
          "name": "Admitting clinician",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "The CareTend department that gets the task to enter the medications by hand when no admitting clinician is found in Slack.",
          "error": null,
          "name": "CareTend department ID",
          "type": "INT",
          "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-03T04:14:28.048Z"
}
