{
  "elementsLearnedData": [],
  "elementsTestData": [],
  "flow": {
    "id": "6C587AD8-ADE1-4A29-9295-A35A42F81A03",
    "name": "Zendesk: referral held in an intake ticket"
  },
  "flowVersion": {
    "clientMetadata": {
      "viewport": {
        "x": -29.510268562401265,
        "y": 14.723538704581358,
        "zoom": 0.63
      },
      "autoSave": false,
      "descriptions": {
        "flow": "When a referral faxed through Documo needs a person (something missing, a near or double chart match, no birth date), opens an internal ticket in the Zendesk intake group with the fax and what is missing, waits until the ticket is solved, then files the referral in Healthie as the coordinator's note says. A complete referral with an exact match or no match at all is filed without a ticket.",
        "initialData": "",
        "initialDataFields": {}
      }
    },
    "description": "When a referral faxed through Documo needs a person (something missing, a near or double chart match, no birth date), opens an internal ticket in the Zendesk intake group with the fax and what is missing, waits until the ticket is solved, then files the referral in Healthie as the coordinator's note says. A complete referral with an exact match or no match at all is filed without a ticket.",
    "elements": [
      {
        "clientMetadata": {
          "notes": "Fires when Documo finishes receiving a fax. The event carries the fax record (message ID, status, result code, fax number, caller ID, CSID, pages, times) and, for a successful fax, its PDF saved to FlowRunner file storage at workspace scope in \"file\" (URL, name, content type, size). \"file\" is null for a failed fax, or when the PDF could not be fetched, with the reason in \"fileError\"; use Download Fax with the message ID then. Optionally only fires for one receiving number or one outcome.",
          "elementId": "EXTENSION:::SHARED:::default:::documo:::onNewInboundFax",
          "isFirstElement": true,
          "blockDefinitionId": "api-service-trigger",
          "newElementId": "EXTENSION:::SHARED:::default:::documo:::onNewInboundFax",
          "legacyElementId": null,
          "methodName": "onNewInboundFax",
          "position": {
            "x": 136,
            "y": 40
          }
        },
        "flowElementId": "4DFF29DD-27B6-4E7C-8DE3-475B5D0926B3",
        "groupId": null,
        "id": "3507E7E5-1D4A-42DE-AABA-EE665377A0A0",
        "metaInfo": {
          "callbackUrl": null,
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": null,
          "connectionId": null,
          "eventName": "onNewInboundFax",
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Fax",
          "scope": "SINGLE_APP",
          "serviceId": "documo",
          "slaConditions": [],
          "staticData": {
            "status": "success"
          },
          "storeResult": true,
          "subtype": "REALTIME",
          "type": "CUSTOM"
        },
        "name": "New fax received",
        "nextElementIds": [
          "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 906,
            "y": 49
          }
        },
        "flowElementId": "1DA355D1-E6AE-48F2-B92A-7287D15D42FE",
        "groupId": null,
        "id": "BE096CCE-9736-4F9B-9716-130F6E1AF1AE",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "4a37f97f-4d2b-4061-96d7-462582cd7614",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Referral",
                      "subPathSegments": [
                        {
                          "key": "output",
                          "optional": false
                        },
                        {
                          "key": "isReferral",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "4a37f97f-4d2b-4061-96d7-462582cd7614"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Is referral",
          "storeResult": false,
          "thenComponent": {
            "componentId": "554FBD60-65F8-4F9E-856D-AA2076B9EAA6",
            "componentType": "ELEMENT"
          }
        },
        "name": "Referral?",
        "nextElementIds": [
          "554FBD60-65F8-4F9E-856D-AA2076B9EAA6"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "ai-agent",
          "isFirstElement": false,
          "blockDefinitionId": "ai-agent",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Read the referral Result"
          },
          "tools": {},
          "position": {
            "x": 509,
            "y": 49
          }
        },
        "flowElementId": "C4F48909-F605-459B-AAC2-A91EF90F41F6",
        "groupId": null,
        "id": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02",
        "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": [
            {
              "mimeType": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "file",
                        "optional": false
                      },
                      {
                        "key": "contentType",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "3507E7E5-1D4A-42DE-AABA-EE665377A0A0"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": "STRING"
              },
              "url": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "file",
                        "optional": false
                      },
                      {
                        "key": "url",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "3507E7E5-1D4A-42DE-AABA-EE665377A0A0"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": "STRING"
              }
            }
          ],
          "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": "Referral",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "systemPrompt": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "You read faxes that arrive at a healthcare intake team and decide whether a fax is a new patient referral from another provider's office. You also check the referral against the intake team's must-haves: "
              },
              {
                "id": "PLACEHOLDER_DATA",
                "label": "Referral must-haves",
                "subPathSegments": null,
                "type": "EXECUTION_CONTEXT_STATIC_DATA",
                "value": "Referral must-haves"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": ". From the attached fax, reply with JSON only, with these fields:\nisReferral: true if the fax refers a patient to this practice for care; false for anything else, such as a records request, a lab report, a prior authorization or an advertisement\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\npatientEmail: the patient's email address, or empty text\npatientPhone: the patient's phone number with area code, or empty text\npatientGender: Male, Female or Other, only if the referral states it, otherwise empty text\npatientTimezone: the IANA time zone of the patient's address, such as America/Chicago; if the referral does not show where the patient lives, use "
              },
              {
                "id": "PLACEHOLDER_DATA",
                "label": "Practice time zone",
                "subPathSegments": null,
                "type": "EXECUTION_CONTEXT_STATIC_DATA",
                "value": "Practice time zone"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\nphysicianFirstName: the referring provider's first name\nphysicianLastName: the referring provider's last name\nphysicianNpi: the referring provider's 10-digit NPI, or empty text\nphysicianPractice: the referring office or clinic, or empty text\nphysicianFax: the referring office's fax number, or empty text\nphysicianPhone: the referring office's phone number, or empty text\nphysicianSpeciality: their specialty, or empty text\nreason: the reason for the referral, in one short sentence\nmissing: a list of the must-haves this fax does not include or that are unreadable, each in a few plain words such as \"insurance card back\" or \"signed order\"; an empty list when everything is there\nNever guess a value that is not on the fax. Do not judge whether the patient should be accepted; only report what is on the fax and what is missing."
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "tools": [],
          "type": "AI_AGENT",
          "userPrompt": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "Fax received from caller ID "
              },
              {
                "id": "RESULT",
                "label": "Fax",
                "subPathSegments": [
                  {
                    "key": "faxCallerId",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "3507E7E5-1D4A-42DE-AABA-EE665377A0A0"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": " at "
              },
              {
                "id": "RESULT",
                "label": "Fax",
                "subPathSegments": [
                  {
                    "key": "createdAt",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "3507E7E5-1D4A-42DE-AABA-EE665377A0A0"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": ", "
              },
              {
                "id": "RESULT",
                "label": "Fax",
                "subPathSegments": [
                  {
                    "key": "pagesCount",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "3507E7E5-1D4A-42DE-AABA-EE665377A0A0"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": " pages. Today is "
              },
              {
                "id": "GET_CURRENT_DATE",
                "label": null,
                "type": "GET_CURRENT_DATE_TIME",
                "value": null
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": ". The fax is attached."
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          }
        },
        "name": "Read the referral",
        "nextElementIds": [
          "BE096CCE-9736-4F9B-9716-130F6E1AF1AE"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Records on the patient's Healthie profile that they were referred by a physician, with the reason for the referral.",
          "elementId": "EXTENSION:::SHARED:::default:::healthie:::createReferral",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Record the referral Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::createReferral",
          "legacyElementId": null,
          "methodName": "createReferral",
          "position": {
            "x": 906,
            "y": 980
          }
        },
        "flowElementId": "6FB1DBC6-71FD-4E67-863D-1981B9E16053",
        "groupId": null,
        "id": "3D48C320-20E1-4745-A35A-4A96C2E11334",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "patientId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Chart",
                    "subPathSegments": [
                      {
                        "key": "patientId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "263BA318-920F-4E6B-AF4E-68F9D07340EE"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "referringPhysicianId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Physician",
                    "subPathSegments": [
                      {
                        "key": "referring_physician",
                        "optional": false
                      },
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E59570E0-0CE8-40CA-A931-C556F1C8D9B9"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "reason",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "reason",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "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": "createReferral",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Referral record",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Record the referral",
        "nextElementIds": [
          "460BC6E7-76DC-4F29-A738-EB43B6342FAE"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Looks for existing patients by first name, last name, date of birth and email, optionally narrowed by phone number, so an incoming referral is matched to the right chart before a new patient is created. Every term you fill in must match. Healthie does not search by phone number itself, so give at least one other term with it.",
          "elementId": "EXTENSION:::SHARED:::default:::healthie:::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:::healthie:::searchPatients",
          "legacyElementId": null,
          "methodName": "searchPatients",
          "position": {
            "x": 856,
            "y": 210
          }
        },
        "flowElementId": "63619344-6EC3-4C60-A067-B8BEE169F0E1",
        "groupId": null,
        "id": "2FA61E4C-817A-463C-B5A9-DE94BF7A1FB1",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "firstName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientFirstName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "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": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientDateOfBirth",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "email",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "phoneNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "status",
              "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": null,
            "valid": true
          },
          "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": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Search by first name and birth date",
        "nextElementIds": [
          "53A9295C-0A69-4381-8D30-EF4F0FE2799C"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Creates a new patient in Healthie, assigned to a provider. Leave Email empty for a patient without one; Healthie then records that the email was skipped.",
          "elementId": "EXTENSION:::SHARED:::default:::healthie:::createPatient",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Create the patient Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::createPatient",
          "legacyElementId": null,
          "methodName": "createPatient",
          "position": {
            "x": 906,
            "y": 680
          }
        },
        "flowElementId": "317A3337-1944-43ED-87C5-5738BD273C56",
        "groupId": null,
        "id": "21189107-6C21-4963-AB6E-5D699F981EF3",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "firstName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientFirstName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "lastName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "legalName",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dateOfBirth",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientDateOfBirth",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "email",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientEmail",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "phoneNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientPhone",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "gender",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientGender",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "providerId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "recordIdentifier",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "timezone",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientTimezone",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dontSendWelcome",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_TRUE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": true
                  }
                ],
                "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": "createPatient",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "New patient",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Create the patient",
        "nextElementIds": [
          "263BA318-920F-4E6B-AF4E-68F9D07340EE"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Check what needs a person Result"
          },
          "position": {
            "x": 484,
            "y": 219
          }
        },
        "flowElementId": "BA261988-D49F-44C2-8DA4-CD1D75059C78",
        "groupId": null,
        "id": "53A9295C-0A69-4381-8D30-EF4F0FE2799C",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "referral",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "exact",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Exact search",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "554FBD60-65F8-4F9E-856D-AA2076B9EAA6"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "byLastName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "By last name",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "CAC5C709-C89C-4C6D-8E78-1FAE41B7919C"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "byFirstName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "By first name",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "2FA61E4C-817A-463C-B5A9-DE94BF7A1FB1"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const norm = (s) => String(s || '').trim().toLowerCase();\nconst r = referral || {};\nconst dob = String(r.patientDateOfBirth || '').trim();\nconst missing = (Array.isArray(r.missing) ? r.missing : []).filter(Boolean);\nconst reasons = [];\nif (missing.length) reasons.push(`Missing from the referral: ${missing.join(', ')}`);\nif (!dob) reasons.push('No date of birth on the referral, so the chart cannot be matched');\nconst exactList = ((exact && exact.patients) || []).filter((p) => dob && norm(p.first_name) === norm(r.patientFirstName) && norm(p.last_name) === norm(r.patientLastName) && String(p.dob || '') === dob);\nconst found = new Map();\nconst add = (result, why) => {\n  for (const p of (result && result.patients) || []) {\n    if (!p || !p.id) continue;\n    const id = String(p.id);\n    const c = found.get(id) || { id, name: p.full_name || [p.first_name, p.last_name].filter(Boolean).join(' '), dob: p.dob || '', reasons: [] };\n    if (!c.reasons.includes(why)) c.reasons.push(why);\n    found.set(id, c);\n  }\n};\n// A search with an empty birth date returns everyone with the name, so only count the searches when the referral has one.\nif (dob) {\n  add({ patients: exactList }, 'same name and birth date');\n  add(byLastName, 'same last name and birth date');\n  add(byFirstName, 'same first name and birth date');\n}\nconst candidates = [...found.values()].sort((a, b) => b.reasons.length - a.reasons.length).slice(0, 5);\nif (exactList.length > 1) reasons.push('More than one chart has this name and birth date');\nelse if (dob && exactList.length === 0 && candidates.length) reasons.push('A chart looks like the same person, but the name or birth date differs');\nlet route = 'ticket';\nif (!reasons.length) route = exactList.length === 1 ? 'file' : 'new';\nreturn { route, reasons, missing, candidates, exactId: exactList.length === 1 ? String(exactList[0].id) : '' };\n"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Check",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Check what needs a person",
        "nextElementIds": [
          "6235CAEB-B299-42CE-92EB-0C522A6E12FB"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Finds the referring physician named on a referral in Healthie, by NPI or by name, and adds them when they are not there yet. Use the physician's ID in Create Referral.",
          "elementId": "EXTENSION:::SHARED:::default:::healthie:::findOrCreateReferringPhysician",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Find or add the referring physician Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::findOrCreateReferringPhysician",
          "legacyElementId": null,
          "methodName": "findOrCreateReferringPhysician",
          "position": {
            "x": 461,
            "y": 980
          }
        },
        "flowElementId": "A400D164-799F-4428-94D1-7990B9FB3BD6",
        "groupId": null,
        "id": "E59570E0-0CE8-40CA-A931-C556F1C8D9B9",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "npi",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "physicianNpi",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "firstName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "physicianFirstName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "lastName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "physicianLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "businessName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "physicianPractice",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "faxNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "physicianFax",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "phoneNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "physicianPhone",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "email",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "speciality",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "physicianSpeciality",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "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": "findOrCreateReferringPhysician",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Physician",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Find or add the referring physician",
        "nextElementIds": [
          "3D48C320-20E1-4745-A35A-4A96C2E11334"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Downloads a file, such as a faxed or emailed referral PDF, and files it as a document on the patient's Healthie chart, optionally in a folder and shared with the patient. Healthie has no document type list, so use the description and the folder to say what it is.",
          "elementId": "EXTENSION:::SHARED:::default:::healthie:::uploadDocument",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "File the referral on the chart Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::uploadDocument",
          "legacyElementId": null,
          "methodName": "uploadDocument",
          "position": {
            "x": 110,
            "y": 980
          }
        },
        "flowElementId": "B4B3691B-46BC-44B2-AE39-8B9F3BC1597C",
        "groupId": null,
        "id": "04530AE6-B495-4375-A801-0714897D64D8",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "patientId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Chart",
                    "subPathSegments": [
                      {
                        "key": "patientId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "263BA318-920F-4E6B-AF4E-68F9D07340EE"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "fileUrl",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Fax PDF",
                    "subPathSegments": [
                      {
                        "key": "url",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "A5A563FF-3720-4EC3-89CA-BEF3FB4B9DA8"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "fileName",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "displayName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "Referral from "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "physicianFirstName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "physicianLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "description",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "Referral from "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "physicianFirstName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "physicianLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "physicianPractice",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ", received by fax on "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "createdAt",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "3507E7E5-1D4A-42DE-AABA-EE665377A0A0"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "folderId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "includeInCharting",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "shareWithPatient",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "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": "uploadDocument",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Filed referral",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "File the referral on the chart",
        "nextElementIds": [
          "E59570E0-0CE8-40CA-A931-C556F1C8D9B9"
        ],
        "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": 509,
            "y": 689
          }
        },
        "flowElementId": "F3E85BCA-10BE-4D4B-89F0-8C8F154C42D0",
        "groupId": null,
        "id": "263BA318-920F-4E6B-AF4E-68F9D07340EE",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "created",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "New patient",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "21189107-6C21-4963-AB6E-5D699F981EF3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "answerDecision",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                    "label": "Default - decision",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.dataBuckets.Default.decision",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "dataBuckets",
                        "optional": false
                      },
                      {
                        "key": "Default",
                        "optional": false
                      },
                      {
                        "key": "decision",
                        "optional": false
                      }
                    ]
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "answerPatientId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                    "label": "Default - patientId",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.dataBuckets.Default.patientId",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "dataBuckets",
                        "optional": false
                      },
                      {
                        "key": "Default",
                        "optional": false
                      },
                      {
                        "key": "patientId",
                        "optional": false
                      }
                    ]
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "check",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Check",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "53A9295C-0A69-4381-8D30-EF4F0FE2799C"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const chartLink = 'https://secure.gethealthie.com/users/';\nif (created && created.id) return { patientId: String(created.id), name: created.full_name || '', link: `${chartLink}${created.id}`, source: 'new chart' };\nconst picked = String(answerPatientId || '').replace(/\\D/g, '');\nif (answerDecision === 'existing') {\n  if (!picked) throw new Error('The coordinator chose an existing chart but no chart ID was found in the note.');\n  return { patientId: picked, name: '', link: `${chartLink}${picked}`, source: 'chart named by the intake coordinator' };\n}\nif (check && check.exactId) return { patientId: String(check.exactId), name: '', link: `${chartLink}${check.exactId}`, source: 'matching chart' };\nthrow new Error('No chart to file the referral on.');\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": [
          "A5A563FF-3720-4EC3-89CA-BEF3FB4B9DA8"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Downloads a fax's document as PDF (or TIFF) and saves it to FlowRunner file storage. Returns the file's URL, name, content type and size, ready to attach, store or parse in the next step.",
          "elementId": "EXTENSION:::SHARED:::default:::documo:::downloadFax",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Get the fax PDF Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::documo:::downloadFax",
          "legacyElementId": null,
          "methodName": "downloadFax",
          "position": {
            "x": 136,
            "y": 680
          }
        },
        "flowElementId": "A34961EF-25B9-4AED-9137-714CCE78CEA3",
        "groupId": null,
        "id": "A5A563FF-3720-4EC3-89CA-BEF3FB4B9DA8",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "messageId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "messageId",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "3507E7E5-1D4A-42DE-AABA-EE665377A0A0"
                  }
                ],
                "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": "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": null,
          "packageId": "default",
          "resultAlias": "Fax PDF",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "documo",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Get the fax PDF",
        "nextElementIds": [
          "04530AE6-B495-4375-A801-0714897D64D8"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "router",
          "isFirstElement": false,
          "blockDefinitionId": "router",
          "casesViewMode": {
            "687c59a3-849a-4610-a00a-6d8e98966f52": "SIMPLE",
            "374d692f-b925-4fef-94dc-32c2a976b167": "SIMPLE"
          },
          "position": {
            "x": 136,
            "y": 219
          }
        },
        "flowElementId": "60FBCB6C-6E1F-4BFD-8DF9-82D9829C7899",
        "groupId": null,
        "id": "6235CAEB-B299-42CE-92EB-0C522A6E12FB",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Next step",
          "storeResult": true,
          "switchCases": [
            {
              "defaultCase": false,
              "id": "687c59a3-849a-4610-a00a-6d8e98966f52",
              "label": "Exact match, nothing missing",
              "nextComponents": [
                {
                  "componentId": "263BA318-920F-4E6B-AF4E-68F9D07340EE",
                  "componentType": "ELEMENT"
                }
              ],
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "file"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "defaultCase": false,
              "id": "374d692f-b925-4fef-94dc-32c2a976b167",
              "label": "New patient, nothing missing",
              "nextComponents": [
                {
                  "componentId": "21189107-6C21-4963-AB6E-5D699F981EF3",
                  "componentType": "ELEMENT"
                }
              ],
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "new"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "defaultCase": true,
              "id": "ca486e9a-3a44-4a98-9882-7449c7dade42",
              "label": "Everything Else",
              "nextComponents": [
                {
                  "componentId": "F4DAD9C2-7BAD-47F9-A055-54139A9EF27A",
                  "componentType": "ELEMENT"
                }
              ],
              "type": "SIMPLE",
              "value": null
            }
          ],
          "switchExpression": {
            "expression": [
              {
                "id": "ELEMENT_RESULT",
                "label": "Check",
                "subPathSegments": [
                  {
                    "key": "route",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "53A9295C-0A69-4381-8D30-EF4F0FE2799C"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          }
        },
        "name": "Person needed?",
        "nextElementIds": [
          "263BA318-920F-4E6B-AF4E-68F9D07340EE",
          "21189107-6C21-4963-AB6E-5D699F981EF3",
          "F4DAD9C2-7BAD-47F9-A055-54139A9EF27A"
        ],
        "nextGroupIds": [],
        "type": "VALUE_ROUTER"
      },
      {
        "clientMetadata": {
          "notes": "Looks for existing patients by first name, last name, date of birth and email, optionally narrowed by phone number, so an incoming referral is matched to the right chart before a new patient is created. Every term you fill in must match. Healthie does not search by phone number itself, so give at least one other term with it.",
          "elementId": "EXTENSION:::SHARED:::default:::healthie:::searchPatients",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Find the patient's chart Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::searchPatients",
          "legacyElementId": null,
          "methodName": "searchPatients",
          "position": {
            "x": 1295,
            "y": 40
          }
        },
        "flowElementId": "EA9EB877-FD82-4D4F-8F9B-21E7E657E5D5",
        "groupId": null,
        "id": "554FBD60-65F8-4F9E-856D-AA2076B9EAA6",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "firstName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientFirstName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "lastName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dateOfBirth",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientDateOfBirth",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "email",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "phoneNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "status",
              "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": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "searchPatients",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Exact search",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Find the patient's chart",
        "nextElementIds": [
          "CAC5C709-C89C-4C6D-8E78-1FAE41B7919C"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Looks for existing patients by first name, last name, date of birth and email, optionally narrowed by phone number, so an incoming referral is matched to the right chart before a new patient is created. Every term you fill in must match. Healthie does not search by phone number itself, so give at least one other term with it.",
          "elementId": "EXTENSION:::SHARED:::default:::healthie:::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:::healthie:::searchPatients",
          "legacyElementId": null,
          "methodName": "searchPatients",
          "position": {
            "x": 1256,
            "y": 210
          }
        },
        "flowElementId": "ECC8EAB9-2517-4628-8F5B-B7439599CE04",
        "groupId": null,
        "id": "CAC5C709-C89C-4C6D-8E78-1FAE41B7919C",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "firstName",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "lastName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dateOfBirth",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientDateOfBirth",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "email",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "phoneNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "status",
              "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": null,
            "valid": true
          },
          "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": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Search by last name and birth date",
        "nextElementIds": [
          "2FA61E4C-817A-463C-B5A9-DE94BF7A1FB1"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Creates a new Zendesk ticket with a first comment. Supports setting priority, type, status, requester (by email, the user is created if it does not exist), assignee, group, tags, custom fields, and file attachments on the first comment (by file URL, or by tokens from Upload Attachment). Returns the created ticket.",
          "elementId": "EXTENSION:::SHARED:::default:::zendesk:::createTicket",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Open the intake ticket Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::zendesk:::createTicket",
          "legacyElementId": "JS###v1###Zendesk###createTicket",
          "methodName": "createTicket",
          "position": {
            "x": 503,
            "y": 380
          }
        },
        "flowElementId": "42C9AADD-26B7-4294-8CA2-D2DB00B7FC11",
        "groupId": null,
        "id": "6CABF3EE-2B5B-4E53-A3BD-1950411DD86B",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "subject",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Ticket text",
                    "subPathSegments": [
                      {
                        "key": "subject",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "F4DAD9C2-7BAD-47F9-A055-54139A9EF27A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "commentBody",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Ticket text",
                    "subPathSegments": [
                      {
                        "key": "text",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "F4DAD9C2-7BAD-47F9-A055-54139A9EF27A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "htmlBody",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Ticket text",
                    "subPathSegments": [
                      {
                        "key": "html",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "F4DAD9C2-7BAD-47F9-A055-54139A9EF27A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "publicComment",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "priority",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "normal"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "type",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "task"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "status",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "requesterEmail",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "requesterName",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "assigneeId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "groupId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "tags",
              "type": "SIMPLE_LIST",
              "value": [
                {
                  "expression": [
                    {
                      "id": "TEXT",
                      "label": null,
                      "type": "INPUT",
                      "value": "referral_intake"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                }
              ]
            },
            {
              "name": "customFields",
              "type": "COMPLEX_LIST",
              "value": []
            },
            {
              "name": "attachmentUrls",
              "type": "SIMPLE_LIST",
              "value": [
                {
                  "expression": [
                    {
                      "id": "RESULT",
                      "label": "Fax",
                      "subPathSegments": [
                        {
                          "key": "file",
                          "optional": false
                        },
                        {
                          "key": "url",
                          "optional": false
                        }
                      ],
                      "type": "TRIGGER_DATA",
                      "value": "3507E7E5-1D4A-42DE-AABA-EE665377A0A0"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                }
              ]
            },
            {
              "name": "uploadTokens",
              "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": "createTicket",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Ticket",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "zendesk",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Open the intake ticket",
        "nextElementIds": [
          "E0C4E8AB-EB93-4FE0-BCBD-87E0F5335076"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "data-bucket",
          "isFirstElement": false,
          "blockDefinitionId": "data-bucket",
          "fieldKeys": {
            "decision": "726370aa-3a32-4f0d-a38c-b5e06a8461a6",
            "patientId": "99070303-01f7-46ac-a216-0f67782d9997",
            "note": "1c9f51fe-390b-4e45-a7ee-fbd4e635e588"
          },
          "position": {
            "x": 906,
            "y": 389
          }
        },
        "flowElementId": "FD4A7E38-F1A0-4996-B723-C7345DEB925D",
        "groupId": null,
        "id": "E0C4E8AB-EB93-4FE0-BCBD-87E0F5335076",
        "metaInfo": {
          "bucketName": "Default",
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "fields": [
            {
              "name": "decision",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "waiting"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "patientId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EMPTY_STRING",
                    "label": null,
                    "type": "KEYWORD",
                    "value": ""
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "note",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EMPTY_STRING",
                    "label": null,
                    "type": "KEYWORD",
                    "value": ""
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "db1",
          "storeResult": true
        },
        "name": "Start waiting",
        "nextElementIds": [],
        "nextGroupIds": [
          "E07DFEA7-343E-4623-BF5A-6850C06BB8D4"
        ],
        "type": "DATA_BUCKET"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Write the ticket Result"
          },
          "position": {
            "x": 136,
            "y": 389
          }
        },
        "flowElementId": "B07BBB00-29AA-4272-A9E1-B913014B6F53",
        "groupId": null,
        "id": "F4DAD9C2-7BAD-47F9-A055-54139A9EF27A",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "referral",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "check",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Check",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "53A9295C-0A69-4381-8D30-EF4F0FE2799C"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "receivedAt",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "createdAt",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "3507E7E5-1D4A-42DE-AABA-EE665377A0A0"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const esc = (s) => String(s == null ? '' : s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\"/g, '&quot;');\nconst fmt = (d) => { const m = /^(\\d{4})-(\\d{2})-(\\d{2})/.exec(d || ''); return m ? `${m[2]}/${m[3]}/${m[1]}` : (d || 'not given'); };\nconst chartLink = 'https://secure.gethealthie.com/users/';\nconst r = referral || {};\nconst c = check || {};\nconst name = [r.patientFirstName, r.patientLastName].filter(Boolean).join(' ') || 'unknown patient';\nconst physician = [r.physicianFirstName, r.physicianLastName].filter(Boolean).join(' ');\nconst office = [physician, r.physicianPractice].filter(Boolean).join(', ') || 'the referring office';\nconst contact = [r.physicianPhone && `phone ${r.physicianPhone}`, r.physicianFax && `fax ${r.physicianFax}`].filter(Boolean).join(', ');\nconst first = (c.missing && c.missing.length) ? `missing ${c.missing.join(', ')}` : (c.reasons && c.reasons[0]) || 'needs a person';\nconst subject = `Referral for ${name}, born ${fmt(r.patientDateOfBirth)}: ${first}`.slice(0, 150);\nconst reasons = c.reasons || [];\nconst candidates = c.candidates || [];\nconst answers = ['File on chart <chart ID>', 'New patient', 'Not accepted, and why'];\nconst text = [\n  `Referral for ${name}, born ${fmt(r.patientDateOfBirth)}, from ${office}${contact ? ` (${contact})` : ''}. Faxed ${receivedAt}. The fax is attached.`,\n  r.reason ? `Reason given: ${r.reason}` : '',\n  '',\n  'Why it needs you:',\n  ...reasons.map((x) => `- ${x}`),\n  '',\n  candidates.length ? 'Charts in Healthie that may be this patient:' : 'No chart in Healthie looks like this patient.',\n  ...candidates.map((p) => `- ${p.name}, born ${fmt(p.dob)}, chart ID ${p.id} (${p.reasons.join(', ')}): ${chartLink}${p.id}`),\n  '',\n  'Get anything missing from the referring office first. Then add an internal note that says one of these, and solve the ticket:',\n  ...answers.map((a) => `- ${a}`),\n  'When the ticket is solved, FlowRunner files the referral in Healthie as your note says.',\n].filter((l, i, a) => !(l === '' && a[i - 1] === '')).join('\\n');\nconst html = [\n  `<p><strong>Referral for ${esc(name)}, born ${esc(fmt(r.patientDateOfBirth))}</strong>, from ${esc(office)}${contact ? ` (${esc(contact)})` : ''}. Faxed ${esc(receivedAt)}. The fax is attached.</p>`,\n  r.reason ? `<p>Reason given: ${esc(r.reason)}</p>` : '',\n  `<p><strong>Why it needs you</strong></p><ul>${reasons.map((x) => `<li>${esc(x)}</li>`).join('')}</ul>`,\n  candidates.length\n    ? `<p><strong>Charts in Healthie that may be this patient</strong></p><ul>${candidates.map((p) => `<li><a href=\"${chartLink}${esc(p.id)}\">${esc(p.name)}</a>, born ${esc(fmt(p.dob))}, chart ID ${esc(p.id)}: ${esc(p.reasons.join(', '))}</li>`).join('')}</ul>`\n    : '<p>No chart in Healthie looks like this patient.</p>',\n  `<p><strong>When you're done</strong>: get anything missing from the referring office first. Then add an internal note that says one of these, and solve the ticket:</p><ul>${answers.map((a) => `<li>${esc(a)}</li>`).join('')}</ul>`,\n  '<p>When the ticket is solved, FlowRunner files the referral in Healthie as your note says.</p>',\n].join('');\nreturn { subject, text, html };\n"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Ticket text",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Write the ticket",
        "nextElementIds": [
          "6CABF3EE-2B5B-4E53-A3BD-1950411DD86B"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "wait",
          "isFirstElement": true,
          "blockDefinitionId": "wait",
          "mode": "SIMPLE",
          "position": {
            "x": 116,
            "y": 479
          }
        },
        "flowElementId": "5B5F9B0E-4D07-4666-A2F6-C64F6B9FE830",
        "groupId": "E07DFEA7-343E-4623-BF5A-6850C06BB8D4",
        "id": "60873D5D-7DF0-4FD5-BFD4-17B3C0AA91A7",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "delay": {
            "expression": [
              {
                "id": "NUMBER",
                "label": null,
                "type": "INPUT",
                "value": 900
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": "DOUBLE"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "w",
          "storeResult": true
        },
        "name": "Wait 15 minutes",
        "nextElementIds": [
          "EC08E0DB-5CFB-4BFD-9C8D-39597AEF088B"
        ],
        "nextGroupIds": [],
        "type": "WAIT"
      },
      {
        "clientMetadata": {
          "elementId": "ai-agent",
          "isFirstElement": false,
          "blockDefinitionId": "ai-agent",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Read the coordinator's answer Result"
          },
          "tools": {},
          "position": {
            "x": 722,
            "y": 779
          }
        },
        "flowElementId": "3E858307-36BA-44FB-B37B-12B8E43B07D9",
        "groupId": "E07DFEA7-343E-4623-BF5A-6850C06BB8D4",
        "id": "DC316D32-4AF8-4F84-9BDE-856E54622549",
        "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": "Answer",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "systemPrompt": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "You read the notes an intake coordinator wrote on a Zendesk ticket about a faxed referral. The coordinator was asked to add an internal note that says one of: File on chart <chart ID>, New patient, or Not accepted, and why. Read the notes and take the latest one that gives an answer. Reply with JSON only, with these fields:\ndecision: \"existing\" when the note says to file the referral on an existing chart and gives its chart ID; \"new\" when it says to create a new patient; \"decline\" when it says the referral is not accepted; \"unclear\" when no note gives one of these answers, when the latest answers conflict, or when it names an existing chart without a chart ID\npatientId: the chart ID the note gives, digits only, when decision is \"existing\"; otherwise empty text\nnote: the coordinator's answer in one short sentence, in their words\nNever pick a chart yourself and never guess a chart ID that is not written in a note."
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "tools": [],
          "type": "AI_AGENT",
          "userPrompt": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "Ticket "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Ticket",
                "subPathSegments": [
                  {
                    "key": "id",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "6CABF3EE-2B5B-4E53-A3BD-1950411DD86B"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": ". Charts the ticket offered:\n"
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Coordinator notes",
                "subPathSegments": [
                  {
                    "key": "offered",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "221B07CB-2435-4143-A692-1DEDD56911E1"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\n\nNotes written after the ticket was opened, oldest first:\n"
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Coordinator notes",
                "subPathSegments": [
                  {
                    "key": "text",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "221B07CB-2435-4143-A692-1DEDD56911E1"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          }
        },
        "name": "Read the coordinator's answer",
        "nextElementIds": [
          "45F2F9AD-E579-4119-BBE5-4A62D6B4E8F7"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Gather the coordinator's notes Result"
          },
          "position": {
            "x": 1091,
            "y": 779
          }
        },
        "flowElementId": "807946A9-77F8-4FB8-B78F-62E0169DAC11",
        "groupId": "E07DFEA7-343E-4623-BF5A-6850C06BB8D4",
        "id": "221B07CB-2435-4143-A692-1DEDD56911E1",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "comments",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Ticket notes",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "9C76CB3F-E054-411C-84C2-068AA5B92B6A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "check",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Check",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "53A9295C-0A69-4381-8D30-EF4F0FE2799C"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "// The first comment is the flow's own ticket text, and the flow's own reminders start with a fixed sentence;\n// only the other notes carry the coordinator's answer.\nconst reminder = 'This ticket was solved, but no note says where to file the referral.';\nconst list = ((comments && comments.comments) || []).slice(1).filter((c) => !String(c.body || '').trim().startsWith(reminder));\nconst lines = list.map((c, i) => `Note ${i + 1}, ${c.created_at || ''}, ${c.public ? 'public reply' : 'internal note'}:\\n${String(c.body || '').trim()}`);\nconst offered = ((check && check.candidates) || []).map((p) => `${p.name}, born ${p.dob}, chart ID ${p.id}`);\nreturn { count: list.length, text: lines.join('\\n\\n') || 'No notes after the first one.', offered: offered.join('\\n') || 'none' };\n"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Coordinator notes",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Gather the coordinator's notes",
        "nextElementIds": [
          "DC316D32-4AF8-4F84-9BDE-856E54622549"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 757,
            "y": 479
          }
        },
        "flowElementId": "46EA9193-A2E5-40EE-ADD4-E09DC17A1EBB",
        "groupId": "E07DFEA7-343E-4623-BF5A-6850C06BB8D4",
        "id": "2D686791-9421-49B8-8E1D-FE95A556933D",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "229153b5-224c-4df7-b91a-f8c7451ed22f",
                "nestedOperation": null,
                "operation": "equal",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Ticket now",
                      "subPathSegments": [
                        {
                          "key": "status",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "EC08E0DB-5CFB-4BFD-9C8D-39597AEF088B"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "TEXT",
                        "label": null,
                        "type": "INPUT",
                        "value": "solved"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              },
              {
                "id": "00d42865-8445-4f59-b427-cc7034215a17",
                "nestedOperation": null,
                "operation": "equal",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Ticket now",
                      "subPathSegments": [
                        {
                          "key": "status",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "EC08E0DB-5CFB-4BFD-9C8D-39597AEF088B"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "TEXT",
                        "label": null,
                        "type": "INPUT",
                        "value": "closed"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "229153b5-224c-4df7-b91a-f8c7451ed22f",
              "OR",
              "00d42865-8445-4f59-b427-cc7034215a17"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Is solved",
          "storeResult": false,
          "thenComponent": {
            "componentId": "9C76CB3F-E054-411C-84C2-068AA5B92B6A",
            "componentType": "ELEMENT"
          }
        },
        "name": "Ticket solved?",
        "nextElementIds": [
          "9C76CB3F-E054-411C-84C2-068AA5B92B6A"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "data-bucket",
          "isFirstElement": false,
          "blockDefinitionId": "data-bucket",
          "fieldKeys": {
            "decision": "7a14685d-8830-45fb-a1ff-46264852c852",
            "patientId": "d21f0380-5e70-497e-9e47-a3109ed15a7e",
            "note": "4d711fc7-b7e2-494b-828c-852137170744"
          },
          "position": {
            "x": 116,
            "y": 779
          }
        },
        "flowElementId": "6BB551B8-AACE-43F9-A718-8DC79DA279B9",
        "groupId": "E07DFEA7-343E-4623-BF5A-6850C06BB8D4",
        "id": "7342B188-FE42-4910-B2C1-D742B7AAFACD",
        "metaInfo": {
          "bucketName": "Default",
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "fields": [
            {
              "name": "decision",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Answer",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "decision",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "DC316D32-4AF8-4F84-9BDE-856E54622549"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "patientId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Answer",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "DC316D32-4AF8-4F84-9BDE-856E54622549"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "note",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Answer",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "note",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "DC316D32-4AF8-4F84-9BDE-856E54622549"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "keep",
          "storeResult": true
        },
        "name": "Keep the answer",
        "nextElementIds": [
          "035F1A39-A0D1-4E9D-AA54-7FB2679B3AE4"
        ],
        "nextGroupIds": [],
        "type": "DATA_BUCKET"
      },
      {
        "clientMetadata": {
          "notes": "Lists all comments on a ticket in chronological order, including each comment's author, plain-text and HTML bodies, public/private flag, and attachments.",
          "elementId": "EXTENSION:::SHARED:::default:::zendesk:::listTicketComments",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Read the ticket notes Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::zendesk:::listTicketComments",
          "legacyElementId": "JS###v1###Zendesk###listTicketComments",
          "methodName": "listTicketComments",
          "position": {
            "x": 1123,
            "y": 470
          }
        },
        "flowElementId": "805F7C4A-0239-46E0-9A74-AF50B607B18B",
        "groupId": "E07DFEA7-343E-4623-BF5A-6850C06BB8D4",
        "id": "9C76CB3F-E054-411C-84C2-068AA5B92B6A",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "ticketId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Ticket",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "6CABF3EE-2B5B-4E53-A3BD-1950411DD86B"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "perPage",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 100
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "page",
              "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": "listTicketComments",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Ticket notes",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "zendesk",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Read the ticket notes",
        "nextElementIds": [
          "221B07CB-2435-4143-A692-1DEDD56911E1"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Adds a comment (public reply or private internal note) to an existing ticket, optionally with file attachments (by file URL, or by tokens from Upload Attachment) and a new ticket status in the same update. Returns the updated ticket.",
          "elementId": "EXTENSION:::SHARED:::default:::zendesk:::addCommentToTicket",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Ask for a clear answer Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::zendesk:::addCommentToTicket",
          "legacyElementId": "JS###v1###Zendesk###addCommentToTicket",
          "methodName": "addCommentToTicket",
          "position": {
            "x": 110,
            "y": 640
          }
        },
        "flowElementId": "23EFC85D-32E0-41B9-8C17-2CD709A7E038",
        "groupId": "E07DFEA7-343E-4623-BF5A-6850C06BB8D4",
        "id": "8D0163D3-B0C1-4BE9-8923-B8BC16D948AF",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "ticketId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Ticket",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "6CABF3EE-2B5B-4E53-A3BD-1950411DD86B"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "commentBody",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "This ticket was solved, but no note says where to file the referral. Add an internal note that says File on chart <chart ID>, New patient, or Not accepted and why, then solve the ticket again. FlowRunner is still waiting."
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "htmlBody",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "publicComment",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "status",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "open"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "attachmentUrls",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "uploadTokens",
              "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": "addCommentToTicket",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Reopened ticket",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "zendesk",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Ask for a clear answer",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "break-repeat",
          "isFirstElement": false,
          "blockDefinitionId": "break-repeat",
          "position": {
            "x": 116,
            "y": 949
          }
        },
        "flowElementId": "B5B4C276-7A7F-4345-B133-A34A343851D0",
        "groupId": "E07DFEA7-343E-4623-BF5A-6850C06BB8D4",
        "id": "035F1A39-A0D1-4E9D-AA54-7FB2679B3AE4",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "brk",
          "storeResult": true
        },
        "name": "Stop waiting",
        "nextElementIds": [],
        "nextGroupIds": [],
        "type": "BREAK"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 422,
            "y": 779
          }
        },
        "flowElementId": "F9C0228C-EFFE-4FED-80E8-35A9C50146E7",
        "groupId": "E07DFEA7-343E-4623-BF5A-6850C06BB8D4",
        "id": "45F2F9AD-E579-4119-BBE5-4A62D6B4E8F7",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "b07d49ba-1d97-4863-bf17-59fedc1bc7d6",
                "nestedOperation": null,
                "operation": "notEqual",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Answer",
                      "subPathSegments": [
                        {
                          "key": "output",
                          "optional": false
                        },
                        {
                          "key": "decision",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "DC316D32-4AF8-4F84-9BDE-856E54622549"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "TEXT",
                        "label": null,
                        "type": "INPUT",
                        "value": "unclear"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "b07d49ba-1d97-4863-bf17-59fedc1bc7d6"
            ]
          },
          "elseComponent": {
            "componentId": "8D0163D3-B0C1-4BE9-8923-B8BC16D948AF",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Is clear",
          "storeResult": false,
          "thenComponent": {
            "componentId": "7342B188-FE42-4910-B2C1-D742B7AAFACD",
            "componentType": "ELEMENT"
          }
        },
        "name": "Clear answer?",
        "nextElementIds": [
          "8D0163D3-B0C1-4BE9-8923-B8BC16D948AF",
          "7342B188-FE42-4910-B2C1-D742B7AAFACD"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Retrieves a single Zendesk ticket by ID, including subject, description, status, priority, requester, assignee, group, tags, and custom fields.",
          "elementId": "EXTENSION:::SHARED:::default:::zendesk:::getTicket",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Check the ticket Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::zendesk:::getTicket",
          "legacyElementId": "JS###v1###Zendesk###getTicket",
          "methodName": "getTicket",
          "position": {
            "x": 422,
            "y": 470
          }
        },
        "flowElementId": "A896D1FB-787B-40B7-A59B-BCA0E06385F5",
        "groupId": "E07DFEA7-343E-4623-BF5A-6850C06BB8D4",
        "id": "EC08E0DB-5CFB-4BFD-9C8D-39597AEF088B",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "ticketId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Ticket",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "6CABF3EE-2B5B-4E53-A3BD-1950411DD86B"
                  }
                ],
                "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": "getTicket",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Ticket now",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "zendesk",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Check the ticket",
        "nextElementIds": [
          "2D686791-9421-49B8-8E1D-FE95A556933D"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Adds a comment (public reply or private internal note) to an existing ticket, optionally with file attachments (by file URL, or by tokens from Upload Attachment) and a new ticket status in the same update. Returns the updated ticket.",
          "elementId": "EXTENSION:::SHARED:::default:::zendesk:::addCommentToTicket",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Note the wait ran out Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::zendesk:::addCommentToTicket",
          "legacyElementId": "JS###v1###Zendesk###addCommentToTicket",
          "methodName": "addCommentToTicket",
          "position": {
            "x": 904,
            "y": 550
          }
        },
        "flowElementId": "4A0066B4-8F8E-49A3-BE9E-12C8D7F1B195",
        "groupId": null,
        "id": "9D75CF8D-F67A-49DB-B016-F60C9912B9AB",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "ticketId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Ticket",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "6CABF3EE-2B5B-4E53-A3BD-1950411DD86B"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "commentBody",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "FlowRunner stopped waiting for this ticket after 30 days, so the referral was not filed in Healthie. File it by hand from the attached fax."
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "htmlBody",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "publicComment",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "status",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "attachmentUrls",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "uploadTokens",
              "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": "addCommentToTicket",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Wait ended note",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "zendesk",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Note the wait ran out",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "router",
          "isFirstElement": false,
          "blockDefinitionId": "router",
          "casesViewMode": {
            "907b1432-c185-4bf4-b9cd-6956e34016e4": "SIMPLE",
            "cf258dfd-2d8b-41c7-9f68-9bdfa2f59500": "SIMPLE",
            "b193d75d-e322-48ee-95ec-9db2da3616c3": "SIMPLE"
          },
          "position": {
            "x": 1297,
            "y": 689
          }
        },
        "flowElementId": "D9D26175-6DF5-449F-A52C-ED5002602140",
        "groupId": null,
        "id": "1CDC4EB8-B3BC-4594-B976-7BD99AAE1F96",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Coordinator decision",
          "storeResult": true,
          "switchCases": [
            {
              "defaultCase": false,
              "id": "907b1432-c185-4bf4-b9cd-6956e34016e4",
              "label": "File on a chart",
              "nextComponents": [
                {
                  "componentId": "263BA318-920F-4E6B-AF4E-68F9D07340EE",
                  "componentType": "ELEMENT"
                }
              ],
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "existing"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "defaultCase": false,
              "id": "cf258dfd-2d8b-41c7-9f68-9bdfa2f59500",
              "label": "New patient",
              "nextComponents": [
                {
                  "componentId": "21189107-6C21-4963-AB6E-5D699F981EF3",
                  "componentType": "ELEMENT"
                }
              ],
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "new"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "defaultCase": false,
              "id": "b193d75d-e322-48ee-95ec-9db2da3616c3",
              "label": "Not accepted",
              "nextComponents": [
                {
                  "componentId": "A4253BE4-763B-436B-BCE3-65B4F54BBFBC",
                  "componentType": "ELEMENT"
                }
              ],
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "decline"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "defaultCase": true,
              "id": "3df53489-462a-42fb-ab02-9c36f14e7856",
              "label": "Everything Else",
              "nextComponents": [
                {
                  "componentId": "9D75CF8D-F67A-49DB-B016-F60C9912B9AB",
                  "componentType": "ELEMENT"
                }
              ],
              "type": "SIMPLE",
              "value": null
            }
          ],
          "switchExpression": {
            "expression": [
              {
                "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                "label": "Default - decision",
                "subPathSegments": null,
                "type": "EXECUTION_CONTEXT_PATH",
                "value": "executionContext.dataBuckets.Default.decision",
                "valueSegments": [
                  {
                    "key": "executionContext",
                    "optional": false
                  },
                  {
                    "key": "dataBuckets",
                    "optional": false
                  },
                  {
                    "key": "Default",
                    "optional": false
                  },
                  {
                    "key": "decision",
                    "optional": false
                  }
                ]
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          }
        },
        "name": "Coordinator's answer?",
        "nextElementIds": [
          "263BA318-920F-4E6B-AF4E-68F9D07340EE",
          "21189107-6C21-4963-AB6E-5D699F981EF3",
          "A4253BE4-763B-436B-BCE3-65B4F54BBFBC",
          "9D75CF8D-F67A-49DB-B016-F60C9912B9AB"
        ],
        "nextGroupIds": [],
        "type": "VALUE_ROUTER"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1305,
            "y": 989
          }
        },
        "flowElementId": "A4DC0B27-B196-4D21-B751-EAD31447A917",
        "groupId": null,
        "id": "460BC6E7-76DC-4F29-A738-EB43B6342FAE",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "709fda53-61a7-4ab5-8ac8-4a6a030caa56",
                "nestedOperation": null,
                "operation": "isNotEmpty",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Ticket",
                      "subPathSegments": [
                        {
                          "key": "id",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "6CABF3EE-2B5B-4E53-A3BD-1950411DD86B"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": []
              }
            ],
            "grouping": [
              "709fda53-61a7-4ab5-8ac8-4a6a030caa56"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Had ticket",
          "storeResult": false,
          "thenComponent": {
            "componentId": "E5F9107A-59E7-485D-BE2C-62AB5C11320A",
            "componentType": "ELEMENT"
          }
        },
        "name": "Came from a ticket?",
        "nextElementIds": [
          "E5F9107A-59E7-485D-BE2C-62AB5C11320A"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Adds a comment (public reply or private internal note) to an existing ticket, optionally with file attachments (by file URL, or by tokens from Upload Attachment) and a new ticket status in the same update. Returns the updated ticket.",
          "elementId": "EXTENSION:::SHARED:::default:::zendesk:::addCommentToTicket",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Note the referral was not filed Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::zendesk:::addCommentToTicket",
          "legacyElementId": "JS###v1###Zendesk###addCommentToTicket",
          "methodName": "addCommentToTicket",
          "position": {
            "x": 874,
            "y": 810
          }
        },
        "flowElementId": "FE30D425-DF62-4618-8E6F-78D87E0AF167",
        "groupId": null,
        "id": "A4253BE4-763B-436B-BCE3-65B4F54BBFBC",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "ticketId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Ticket",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "6CABF3EE-2B5B-4E53-A3BD-1950411DD86B"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "commentBody",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "Not filed in Healthie, as your note says: "
                  },
                  {
                    "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                    "label": "Default - note",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.dataBuckets.Default.note",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "dataBuckets",
                        "optional": false
                      },
                      {
                        "key": "Default",
                        "optional": false
                      },
                      {
                        "key": "note",
                        "optional": false
                      }
                    ]
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "htmlBody",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "publicComment",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "status",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "attachmentUrls",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "uploadTokens",
              "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": "addCommentToTicket",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Declined note",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "zendesk",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Note the referral was not filed",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Adds a comment (public reply or private internal note) to an existing ticket, optionally with file attachments (by file URL, or by tokens from Upload Attachment) and a new ticket status in the same update. Returns the updated ticket.",
          "elementId": "EXTENSION:::SHARED:::default:::zendesk:::addCommentToTicket",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Note where it was filed Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::zendesk:::addCommentToTicket",
          "legacyElementId": "JS###v1###Zendesk###addCommentToTicket",
          "methodName": "addCommentToTicket",
          "position": {
            "x": 1296,
            "y": 1150
          }
        },
        "flowElementId": "5FE7146B-7064-4B17-A6AA-8CD81DCAAA6B",
        "groupId": null,
        "id": "E5F9107A-59E7-485D-BE2C-62AB5C11320A",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "ticketId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Ticket",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "6CABF3EE-2B5B-4E53-A3BD-1950411DD86B"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "commentBody",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "Filed in Healthie on chart "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Chart",
                    "subPathSegments": [
                      {
                        "key": "patientId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "263BA318-920F-4E6B-AF4E-68F9D07340EE"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " ("
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Chart",
                    "subPathSegments": [
                      {
                        "key": "source",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "263BA318-920F-4E6B-AF4E-68F9D07340EE"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "): "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Chart",
                    "subPathSegments": [
                      {
                        "key": "link",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "263BA318-920F-4E6B-AF4E-68F9D07340EE"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ". The referral from "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "physicianFirstName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Referral",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "physicianLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E289DBF3-6AA4-4F81-B538-4E92D2FA6B02"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " is recorded on the patient's profile."
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "htmlBody",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "publicComment",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "status",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "attachmentUrls",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "uploadTokens",
              "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": "addCommentToTicket",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Filed note",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "zendesk",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Note where it was filed",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      }
    ],
    "firstElementId": "3507E7E5-1D4A-42DE-AABA-EE665377A0A0",
    "groups": [
      {
        "clientMetadata": {
          "elementId": "repeat",
          "isFirstElement": false,
          "blockDefinitionId": "repeat",
          "viewport": {
            "x": -70,
            "y": -430,
            "zoom": 1
          },
          "position": {
            "x": 1292,
            "y": 389
          }
        },
        "flowElementId": "2190CAAD-66E2-4CC3-A326-89A0D27B4E96",
        "groupId": null,
        "id": "E07DFEA7-343E-4623-BF5A-6850C06BB8D4",
        "loopType": "REPEAT",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "7116ce82-3162-4136-bdaa-f1fc8cbe0e79",
                "nestedOperation": null,
                "operation": "equal",
                "property": {
                  "expression": [
                    {
                      "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                      "label": "Default - decision",
                      "subPathSegments": null,
                      "type": "EXECUTION_CONTEXT_PATH",
                      "value": "executionContext.dataBuckets.Default.decision",
                      "valueSegments": [
                        {
                          "key": "executionContext",
                          "optional": false
                        },
                        {
                          "key": "dataBuckets",
                          "optional": false
                        },
                        {
                          "key": "Default",
                          "optional": false
                        },
                        {
                          "key": "decision",
                          "optional": false
                        }
                      ]
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "TEXT",
                        "label": null,
                        "type": "INPUT",
                        "value": "waiting"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "7116ce82-3162-4136-bdaa-f1fc8cbe0e79"
            ]
          },
          "enabled": true,
          "firstElementId": "60873D5D-7DF0-4FD5-BFD4-17B3C0AA91A7",
          "maxIterations": 2880,
          "onFailElemId": null,
          "resultAlias": "loop",
          "storeResult": true
        },
        "name": "Until the ticket is solved",
        "nextElementIds": [
          "1CDC4EB8-B3BC-4594-B976-7BD99AAE1F96"
        ],
        "nextGroupIds": [],
        "type": "LOOP"
      }
    ],
    "id": "48A4BBA4-0029-411E-A316-183F198B42BF",
    "metaInfo": {
      "clientValidationState": {
        "errorMessage": null,
        "valid": true
      },
      "errorMessage": null,
      "executionStaticData": [
        {
          "description": "Your Anthropic key, used to read the referral and the coordinator's note.",
          "error": null,
          "name": "Anthropic key",
          "type": "API_KEY",
          "value": null
        },
        {
          "description": "Your practice's time zone, used for a new patient whose address doesn't show one.",
          "error": null,
          "name": "Practice time zone",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "What every referral must include before it is filed without a person. A referral missing any of these opens a ticket.",
          "error": null,
          "name": "Referral must-haves",
          "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:32:47.584Z"
}
