{
  "elementsLearnedData": [],
  "elementsTestData": [],
  "flow": {
    "id": "2E452D5D-41CE-46AB-B42C-2264AD9EF02C",
    "name": "Formstack: health history red flags to clinician"
  },
  "flowVersion": {
    "clientMetadata": {
      "viewport": {
        "x": -45.9375,
        "y": 8.75,
        "zoom": 0.78
      },
      "autoSave": false,
      "descriptions": {
        "flow": "When a new patient submits the health history form in Formstack, checks each answer against the practice's own red-flag list. When an answer matches, finds the patient in DrChrono by name and birth date and gives the clinician a task with the flagged answers, due before the first visit. When there is no single exact match, the intake coordinator picks the chart in Slack first.",
        "initialData": "",
        "initialDataFields": {}
      }
    },
    "description": "When a new patient submits the health history form in Formstack, checks each answer against the practice's own red-flag list. When an answer matches, finds the patient in DrChrono by name and birth date and gives the clinician a task with the flagged answers, due before the first visit. When there is no single exact match, the intake coordinator picks the chart in Slack first.",
    "elements": [
      {
        "clientMetadata": {
          "notes": "Finds patients by name, date of birth, email or chart ID. Name matching is partial and ignores case. Returns one page of results; pass Next Page Cursor to read the next one.",
          "elementId": "EXTENSION:::SHARED:::default:::drchrono:::searchPatients",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Find the patient in DrChrono Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::drchrono:::searchPatients",
          "legacyElementId": null,
          "methodName": "searchPatients",
          "position": {
            "x": 1269,
            "y": 210
          }
        },
        "flowElementId": "58136C46-C252-46A6-97B8-919E0080270D",
        "groupId": null,
        "id": "30E6FF96-3C14-4437-BED0-27E478CBAA1F",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "firstName",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "lastName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "History",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0554CA4E-F94A-4ED0-A1EC-1467D35A2189"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dateOfBirth",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "History",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientDateOfBirth",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0554CA4E-F94A-4ED0-A1EC-1467D35A2189"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "email",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "chartId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "doctor",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pageSize",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 25
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "cursor",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Find the patient in DrChrono', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "searchPatients",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "By last name",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "drchrono",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Find the patient in DrChrono",
        "nextElementIds": [
          "23A55E18-155D-4898-B231-5FF8905699AF"
        ],
        "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 chart Result"
          },
          "position": {
            "x": 1296,
            "y": 559
          }
        },
        "flowElementId": "53F08D64-555F-4D72-AAF7-C18B50B532F5",
        "groupId": null,
        "id": "ADFF27D4-CFAA-4531-965F-AF7D85C2CC4A",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "charts",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Charts",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "C8705686-4F21-45D8-94B9-70EA5F21D6CE"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "answer",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Coordinator answer",
                    "subPathSegments": null,
                    "type": "TRIGGER_DATA",
                    "value": "3DEE27E7-D847-493E-9A1C-3697212A087C"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const list = (charts && charts.candidates) || [];\nlet c = null;\nif (charts && charts.single && list[0]) {\n  c = list[0];\n} else if (answer && answer.decision === 'existing' && answer.patient) {\n  c = list.find((x) => String(x.id) === String(answer.patient));\n  if (!c) throw new Error('The chart in the answer is not one of the charts offered in Slack.');\n}\nif (!c) throw new Error('No chart to link the task to.');\nlet dueTime = charts.dueToday;\nconst m = /^(\\d{4}-\\d{2}-\\d{2})/.exec(c.firstVisit || '');\nif (m) {\n  const d = new Date(`${m[1]}T00:00:00Z`);\n  d.setUTCDate(d.getUTCDate() - 1);\n  const dayBefore = d.toISOString().slice(0, 10);\n  if (dayBefore > charts.today) dueTime = `${dayBefore}T17:00:00`;\n}\nreturn {\n  patientId: c.id,\n  dueTime,\n  visitNote: m ? `DrChrono shows the first visit on ${m[1]}.` : 'DrChrono shows no first visit date for this patient yet.',\n};"
              }
            ],
            "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 chart",
        "nextElementIds": [
          "F5FC9DA5-1C13-4E72-A8C9-DA69785BE3EF"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Creates a task in DrChrono's task center, assigned to a user or a group and linked to a patient, appointment or document. A referral is usually filed as a document plus a task.",
          "elementId": "EXTENSION:::SHARED:::default:::drchrono:::createTask",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Task without a chart Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::drchrono:::createTask",
          "legacyElementId": null,
          "methodName": "createTask",
          "position": {
            "x": 1622,
            "y": 380
          }
        },
        "flowElementId": "44503B1E-CB12-45DD-AD09-48C554A13815",
        "groupId": null,
        "id": "C174C79E-8ABD-4214-8695-574C044DA4B3",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "title",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "Review red-flag answers on "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "History",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientFirstName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0554CA4E-F94A-4ED0-A1EC-1467D35A2189"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "History",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0554CA4E-F94A-4ED0-A1EC-1467D35A2189"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "'s health history (no chart linked)"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "status",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "category",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "assigneeUser",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "assigneeGroup",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "priority",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "30"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dueTime",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Charts",
                    "subPathSegments": [
                      {
                        "key": "dueToday",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C8705686-4F21-45D8-94B9-70EA5F21D6CE"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "patient",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "appointment",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "document",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "note",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "The intake coordinator found no DrChrono chart for "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "History",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientFirstName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0554CA4E-F94A-4ED0-A1EC-1467D35A2189"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "History",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0554CA4E-F94A-4ED0-A1EC-1467D35A2189"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ", born "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "History",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientDateOfBirth",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0554CA4E-F94A-4ED0-A1EC-1467D35A2189"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ", so this task is not linked to one. The health history form submitted in Formstack on "
                  },
                  {
                    "id": "RESULT",
                    "label": "Submission",
                    "subPathSegments": [
                      {
                        "key": "timestamp",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "E20479DF-E2AF-4250-AC08-3C2F1D33DD1E"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " has answers on your red-flag list: "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Charts",
                    "subPathSegments": [
                      {
                        "key": "flagText",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C8705686-4F21-45D8-94B9-70EA5F21D6CE"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ". Please review before the first visit. The full form is in Formstack, submission "
                  },
                  {
                    "id": "RESULT",
                    "label": "Submission",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "E20479DF-E2AF-4250-AC08-3C2F1D33DD1E"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "."
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Task without a chart', Error: Status is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "createTask",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Unlinked task",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "drchrono",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Task without a chart",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Retrieves a single form by id, including its full field definitions. The returned fields map each field id to its label and type. This mapping is how you interpret submission data, which stores values keyed by field id (see Get Submission). Uses the Formstack V2025 API (GET /forms/{formId}).",
          "elementId": "EXTENSION:::SHARED:::default:::formstack:::getForm",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Get the form's questions Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::formstack:::getForm",
          "legacyElementId": "JS###v1###FormstackService###getForm",
          "methodName": "getForm",
          "position": {
            "x": 534,
            "y": 40
          }
        },
        "flowElementId": "76549674-172E-45F5-B518-881A8E5B306E",
        "groupId": null,
        "id": "153084F6-7756-4838-821D-F0091865B8C0",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "formId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Submission",
                    "subPathSegments": [
                      {
                        "key": "formId",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "E20479DF-E2AF-4250-AC08-3C2F1D33DD1E"
                  }
                ],
                "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": "getForm",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Form",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "formstack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Get the form's questions",
        "nextElementIds": [
          "0554CA4E-F94A-4ED0-A1EC-1467D35A2189"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Finds patients by name, date of birth, email or chart ID. Name matching is partial and ignores case. Returns one page of results; pass Next Page Cursor to read the next one.",
          "elementId": "EXTENSION:::SHARED:::default:::drchrono:::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:::drchrono:::searchPatients",
          "legacyElementId": null,
          "methodName": "searchPatients",
          "position": {
            "x": 869,
            "y": 210
          }
        },
        "flowElementId": "2CF6CCAC-11F6-4FDA-A045-115D22D00184",
        "groupId": null,
        "id": "23A55E18-155D-4898-B231-5FF8905699AF",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "firstName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "History",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientFirstName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0554CA4E-F94A-4ED0-A1EC-1467D35A2189"
                  }
                ],
                "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": "History",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientDateOfBirth",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0554CA4E-F94A-4ED0-A1EC-1467D35A2189"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "email",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "chartId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "doctor",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pageSize",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 25
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "cursor",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Search by first name and birth date', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "searchPatients",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "By first name",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "drchrono",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Search by first name and birth date",
        "nextElementIds": [
          "C8705686-4F21-45D8-94B9-70EA5F21D6CE"
        ],
        "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": 528,
            "y": 380
          }
        },
        "flowElementId": "DCC785E5-6207-4F72-951E-36D97BAAE35A",
        "groupId": null,
        "id": "93338017-6F8C-4900-AB01-FFF6D9A7F56C",
        "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 card",
                    "subPathSegments": [
                      {
                        "key": "text",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E0FB8396-0E69-4C3E-8A57-F868E6C25D72"
                  }
                ],
                "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": "EXPRESSION",
                "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": "EXPRESSION",
                "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 card",
                    "subPathSegments": [
                      {
                        "key": "blocks",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E0FB8396-0E69-4C3E-8A57-F868E6C25D72"
                  }
                ],
                "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": [
          "3DEE27E7-D847-493E-9A1C-3697212A087C"
        ],
        "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": 110,
            "y": 389
          }
        },
        "flowElementId": "37C7F762-67D3-4D74-B4D5-431FF8D6F88E",
        "groupId": null,
        "id": "E0FB8396-0E69-4C3E-8A57-F868E6C25D72",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "history",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "History",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0554CA4E-F94A-4ED0-A1EC-1467D35A2189"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "charts",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Charts",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "C8705686-4F21-45D8-94B9-70EA5F21D6CE"
                  }
                ],
                "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]}` : 'not given'; };\nconst link = (params) => `${answerLink}?execution=${encodeURIComponent(executionId)}&${new URLSearchParams(params).toString()}`;\nconst r = history || {};\nconst c0 = charts || {};\nconst list = c0.candidates || [];\nconst name = [r.patientFirstName, r.patientLastName].filter(Boolean).join(' ') || 'a patient who left no name';\nconst lines = [`*A health history form needs a clinician's review: ${name}, born ${fmt(r.patientDateOfBirth)}*`, 'An answer on it matches your red-flag list. Pick the patient\\'s chart so the clinician\\'s task is linked to it.'];\nif (list.length) {\n  lines.push(c0.exactCount > 1 ? 'More than one chart in DrChrono has this name and birth date:' : 'No exact match in DrChrono, but these charts share the birth date and a name:');\n  for (const c of list) {\n    const where = [c.city, c.state].filter(Boolean).join(' ');\n    lines.push(`• ${c.name}, born ${fmt(c.dob)}, chart ${c.chartId}${where ? `, ${where}` : ''}`);\n  }\n} else {\n  lines.push('No chart in DrChrono has this name and birth date.');\n}\nconst buttons = list.map((c, i) => ({ type: 'button', ...(i === 0 ? { style: 'primary' } : {}), text: { type: 'plain_text', text: `Link to chart ${c.chartId}`.slice(0, 75) }, url: link({ decision: 'existing', patient: c.id }) }));\nbuttons.push({ type: 'button', text: { type: 'plain_text', text: 'No chart, send the task without one' }, url: link({ decision: 'none' }) });\nreturn {\n  text: `Health history from ${name} needs a clinician: which chart?`,\n  blocks: [\n    { type: 'section', text: { type: 'mrkdwn', text: lines.join('\\n') } },\n    { type: 'actions', elements: buttons },\n  ],\n};"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Question card",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Write the question for the coordinator",
        "nextElementIds": [
          "93338017-6F8C-4900-AB01-FFF6D9A7F56C"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "external-callback",
          "isFirstElement": false,
          "blockDefinitionId": "external-callback",
          "position": {
            "x": 875,
            "y": 389
          }
        },
        "flowElementId": "6FCBEA78-F43F-4166-9CCE-21681F8C6768",
        "groupId": null,
        "id": "3DEE27E7-D847-493E-9A1C-3697212A087C",
        "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": [
          "5BA94EAE-CB6D-4314-960C-99C11C57F0FE"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 169,
            "y": 219
          }
        },
        "flowElementId": "DDEA820E-D593-4AB4-B298-B177F3C16EE1",
        "groupId": null,
        "id": "D4ACDA4E-A21B-441F-8C9A-6EA4372C2C71",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "7ac22bdb-1be7-4924-afb0-08b45ee488f2",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Charts",
                      "subPathSegments": [
                        {
                          "key": "single",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "C8705686-4F21-45D8-94B9-70EA5F21D6CE"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "7ac22bdb-1be7-4924-afb0-08b45ee488f2"
            ]
          },
          "elseComponent": {
            "componentId": "E0FB8396-0E69-4C3E-8A57-F868E6C25D72",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Is one match",
          "storeResult": false,
          "thenComponent": {
            "componentId": "ADFF27D4-CFAA-4531-965F-AF7D85C2CC4A",
            "componentType": "ELEMENT"
          }
        },
        "name": "One exact match?",
        "nextElementIds": [
          "E0FB8396-0E69-4C3E-8A57-F868E6C25D72",
          "ADFF27D4-CFAA-4531-965F-AF7D85C2CC4A"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1296,
            "y": 49
          }
        },
        "flowElementId": "7E573F04-9021-4C0E-A24A-6AB395E739BD",
        "groupId": null,
        "id": "29159A0F-CE07-41F3-9686-9267D9DEE9C4",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "57e22f9c-7ac4-4f7e-94bc-dcbda3307749",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "History",
                      "subPathSegments": [
                        {
                          "key": "output",
                          "optional": false
                        },
                        {
                          "key": "hasRedFlag",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "0554CA4E-F94A-4ED0-A1EC-1467D35A2189"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "57e22f9c-7ac4-4f7e-94bc-dcbda3307749"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Has red flag",
          "storeResult": false,
          "thenComponent": {
            "componentId": "30E6FF96-3C14-4437-BED0-27E478CBAA1F",
            "componentType": "ELEMENT"
          }
        },
        "name": "Red-flag answer?",
        "nextElementIds": [
          "30E6FF96-3C14-4437-BED0-27E478CBAA1F"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Compare the charts Result"
          },
          "position": {
            "x": 549,
            "y": 219
          }
        },
        "flowElementId": "637CBCE3-A82E-4A98-B3C0-DFCCCDC5B6BE",
        "groupId": null,
        "id": "C8705686-4F21-45D8-94B9-70EA5F21D6CE",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "history",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "History",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0554CA4E-F94A-4ED0-A1EC-1467D35A2189"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "byLast",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "By last name",
                    "subPathSegments": [
                      {
                        "key": "results",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "30E6FF96-3C14-4437-BED0-27E478CBAA1F"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "byFirst",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "By first name",
                    "subPathSegments": [
                      {
                        "key": "results",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "23A55E18-155D-4898-B231-5FF8905699AF"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "tz",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Practice time zone",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Practice time zone"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const norm = (s) => String(s || '').trim().toLowerCase();\nconst r = history || {};\nconst seen = new Map();\nfor (const p of [...(byLast || []), ...(byFirst || [])]) {\n  if (p && p.id != null && !seen.has(String(p.id))) seen.set(String(p.id), p);\n}\nconst sameBirthDate = r.patientDateOfBirth ? [...seen.values()].filter((p) => p.date_of_birth === r.patientDateOfBirth) : [];\nconst exact = sameBirthDate.filter((p) => norm(p.first_name) === norm(r.patientFirstName) && norm(p.last_name) === norm(r.patientLastName));\nconst pick = (exact.length ? exact : sameBirthDate).slice(0, 3);\nconst parts = Object.fromEntries(new Intl.DateTimeFormat('en-CA', { timeZone: tz || 'UTC', year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', hourCycle: 'h23' }).formatToParts(new Date()).map((x) => [x.type, x.value]));\nconst today = `${parts.year}-${parts.month}-${parts.day}`;\nconst dueToday = Number(parts.hour) < 17 ? `${today}T17:00:00` : `${today}T23:59:00`;\nconst flagText = (r.redFlags || []).map((f) => `${f.question}: \"${f.answer}\" (on your list as ${f.flag})`).join('; ');\nreturn {\n  single: exact.length === 1,\n  exactCount: exact.length,\n  candidates: pick.map((p) => ({ id: p.id, chartId: p.chart_id, name: `${p.first_name} ${p.last_name}`, dob: p.date_of_birth, city: p.city, state: p.state, firstVisit: p.date_of_first_appointment })),\n  today,\n  dueToday,\n  flagText,\n};"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Charts",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Compare the charts",
        "nextElementIds": [
          "D4ACDA4E-A21B-441F-8C9A-6EA4372C2C71"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Continuously monitors a Formstack form for new submissions and triggers downstream workflows for each one. Emits the raw submission object, including its field values keyed by field id (use Get Form or List Form Fields to map ids to labels). The first cycle only records a watermark and emits nothing, so the existing backlog is not replayed. Uses the Formstack V2025 API.",
          "elementId": "EXTENSION:::SHARED:::default:::formstack:::onNewSubmission",
          "isFirstElement": true,
          "blockDefinitionId": "EXTENSION:::SHARED:::default:::formstack:::onNewSubmission",
          "newElementId": "EXTENSION:::SHARED:::default:::formstack:::onNewSubmission",
          "legacyElementId": "JS###v1###FormstackService###onNewSubmission",
          "methodName": "onNewSubmission",
          "position": {
            "x": 157,
            "y": 40
          }
        },
        "flowElementId": "AADE2D68-7130-45DE-A6F3-8B2E3771BD40",
        "groupId": null,
        "id": "E20479DF-E2AF-4250-AC08-3C2F1D33DD1E",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": "Block: 'New health history form', Error: Form ID is required",
            "valid": false
          },
          "condition": null,
          "connectionId": null,
          "dynamicData": [],
          "eventName": "onNewSubmission",
          "frequency": {
            "repeat": {
              "every": 300
            },
            "schedule": "custom"
          },
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Submission",
          "serviceId": "formstack",
          "slaConditions": [],
          "staticData": {},
          "storeResult": true,
          "subtype": "POLLING",
          "type": "CUSTOM"
        },
        "name": "New health history form",
        "nextElementIds": [
          "153084F6-7756-4838-821D-F0091865B8C0"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "elementId": "ai-agent",
          "isFirstElement": false,
          "blockDefinitionId": "ai-agent",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Check for red-flag answers Result"
          },
          "tools": {},
          "position": {
            "x": 896,
            "y": 49
          }
        },
        "flowElementId": "8FA48805-04B3-41CA-A6FA-CC6A718C43EC",
        "groupId": null,
        "id": "0554CA4E-F94A-4ED0-A1EC-1467D35A2189",
        "metaInfo": {
          "aiApiKey": null,
          "aiModel": "claude-sonnet-5",
          "aiProvider": "ANTHROPIC",
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "dynamicAiApiKey": {
            "expression": [
              {
                "id": "PLACEHOLDER_DATA",
                "label": "Anthropic key",
                "subPathSegments": null,
                "type": "EXECUTION_CONTEXT_STATIC_DATA",
                "value": "Anthropic key"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "files": [],
          "forceParsedOutput": true,
          "langSmithSettings": {
            "enabled": false,
            "apiKey": null,
            "projectName": null,
            "label": "FlowRunner AI-Agent",
            "accountCluster": "US"
          },
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "messagesHistoryEnabled": false,
          "messagesHistoryLimit": 15,
          "onFailElemId": null,
          "resultAlias": "History",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "systemPrompt": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "You read a health history form that a new patient filled in on a medical practice's Formstack form before their first visit. The submission's answers are keyed by field id; the form's questions give each field id its label. Compare each answer with the practice's red-flag list below and report the answers that match an item on it. Do not assess, diagnose or rank anything, and do not flag an answer that matches nothing on the list.\nRed-flag list: "
              },
              {
                "id": "PLACEHOLDER_DATA",
                "label": "Red-flag answers",
                "subPathSegments": null,
                "type": "EXECUTION_CONTEXT_STATIC_DATA",
                "value": "Red-flag answers"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\nReply with JSON only, with these fields:\npatientFirstName: the patient's first name as written\npatientLastName: the patient's last name as written\npatientDateOfBirth: the patient's date of birth as YYYY-MM-DD, or empty text\nredFlags: a list with one entry per matching answer, each {\"question\": the question as labeled on the form, \"answer\": the patient's answer as written, \"flag\": the item on the red-flag list it matches}; an empty list when none match\nhasRedFlag: true if redFlags has any entry, otherwise false\nNever guess a value that is not in the submission."
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "tools": [],
          "type": "AI_AGENT",
          "userPrompt": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "Form: "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Form",
                "subPathSegments": [
                  {
                    "key": "name",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "153084F6-7756-4838-821D-F0091865B8C0"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\nQuestions on the form: "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Form",
                "subPathSegments": [
                  {
                    "key": "fields",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "153084F6-7756-4838-821D-F0091865B8C0"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\nSubmission "
              },
              {
                "id": "RESULT",
                "label": "Submission",
                "subPathSegments": [
                  {
                    "key": "id",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "E20479DF-E2AF-4250-AC08-3C2F1D33DD1E"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": ", received "
              },
              {
                "id": "RESULT",
                "label": "Submission",
                "subPathSegments": [
                  {
                    "key": "timestamp",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "E20479DF-E2AF-4250-AC08-3C2F1D33DD1E"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": ": "
              },
              {
                "id": "RESULT",
                "label": "Submission",
                "subPathSegments": [
                  {
                    "key": "data",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "E20479DF-E2AF-4250-AC08-3C2F1D33DD1E"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          }
        },
        "name": "Check for red-flag answers",
        "nextElementIds": [
          "29159A0F-CE07-41F3-9686-9267D9DEE9C4"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Creates a task in DrChrono's task center, assigned to a user or a group and linked to a patient, appointment or document. A referral is usually filed as a document plus a task.",
          "elementId": "EXTENSION:::SHARED:::default:::drchrono:::createTask",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Task for the clinician Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::drchrono:::createTask",
          "legacyElementId": null,
          "methodName": "createTask",
          "position": {
            "x": 918,
            "y": 550
          }
        },
        "flowElementId": "FF287C41-BBBE-492E-91F7-CBD0F5221404",
        "groupId": null,
        "id": "F5FC9DA5-1C13-4E72-A8C9-DA69785BE3EF",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "title",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "Review red-flag answers on "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "History",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientFirstName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0554CA4E-F94A-4ED0-A1EC-1467D35A2189"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "History",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0554CA4E-F94A-4ED0-A1EC-1467D35A2189"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "'s health history"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "status",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "category",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "assigneeUser",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "assigneeGroup",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "priority",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "30"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dueTime",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Chart",
                    "subPathSegments": [
                      {
                        "key": "dueTime",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "ADFF27D4-CFAA-4531-965F-AF7D85C2CC4A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "patient",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Chart",
                    "subPathSegments": [
                      {
                        "key": "patientId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "ADFF27D4-CFAA-4531-965F-AF7D85C2CC4A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "appointment",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "document",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "note",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "The health history form submitted in Formstack on "
                  },
                  {
                    "id": "RESULT",
                    "label": "Submission",
                    "subPathSegments": [
                      {
                        "key": "timestamp",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "E20479DF-E2AF-4250-AC08-3C2F1D33DD1E"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " has answers on your red-flag list: "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Charts",
                    "subPathSegments": [
                      {
                        "key": "flagText",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C8705686-4F21-45D8-94B9-70EA5F21D6CE"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ". "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Chart",
                    "subPathSegments": [
                      {
                        "key": "visitNote",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "ADFF27D4-CFAA-4531-965F-AF7D85C2CC4A"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " Please review before the first visit. The full form is in Formstack, submission "
                  },
                  {
                    "id": "RESULT",
                    "label": "Submission",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "E20479DF-E2AF-4250-AC08-3C2F1D33DD1E"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "."
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Task for the clinician', Error: Status is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "createTask",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Clinician task",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "drchrono",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Task for the clinician",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1296,
            "y": 389
          }
        },
        "flowElementId": "A01321A0-6F6E-422D-A9A3-FF52201B1D50",
        "groupId": null,
        "id": "5BA94EAE-CB6D-4314-960C-99C11C57F0FE",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "724b62b1-432f-4181-9c07-d8954102fe62",
                "nestedOperation": null,
                "operation": "equal",
                "property": {
                  "expression": [
                    {
                      "id": "RESULT",
                      "label": "Coordinator answer",
                      "subPathSegments": [
                        {
                          "key": "decision",
                          "optional": false
                        }
                      ],
                      "type": "TRIGGER_DATA",
                      "value": "3DEE27E7-D847-493E-9A1C-3697212A087C"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "TEXT",
                        "label": null,
                        "type": "INPUT",
                        "value": "existing"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "724b62b1-432f-4181-9c07-d8954102fe62"
            ]
          },
          "elseComponent": {
            "componentId": "C174C79E-8ABD-4214-8695-574C044DA4B3",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Is chart picked",
          "storeResult": false,
          "thenComponent": {
            "componentId": "ADFF27D4-CFAA-4531-965F-AF7D85C2CC4A",
            "componentType": "ELEMENT"
          }
        },
        "name": "Chart picked?",
        "nextElementIds": [
          "ADFF27D4-CFAA-4531-965F-AF7D85C2CC4A",
          "C174C79E-8ABD-4214-8695-574C044DA4B3"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      }
    ],
    "firstElementId": "E20479DF-E2AF-4250-AC08-3C2F1D33DD1E",
    "groups": [],
    "id": "E6988FFA-7514-48D5-B5A7-271C19852F60",
    "metaInfo": {
      "clientValidationState": {
        "errorMessage": "Please fix problems before start. Blocks with issues have red badge in the top-right corner of a block, hover it to see what needs to be done.",
        "valid": false
      },
      "errorMessage": "Please fix problems before start. Blocks with issues have red badge in the top-right corner of a block, hover it to see what needs to be done.",
      "executionStaticData": [
        {
          "description": "The Anthropic key the AI step uses to read the form.",
          "error": null,
          "name": "Anthropic key",
          "type": "API_KEY",
          "value": null
        },
        {
          "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": "Your clinicians' list of answers that need a look before the first visit, separated by semicolons.",
          "error": null,
          "name": "Red-flag answers",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "Your practice's time zone, used for task due times.",
          "error": null,
          "name": "Practice time zone",
          "type": "STRING",
          "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-01T03:31:05.116Z"
}
