{
  "elementsLearnedData": [],
  "elementsTestData": [],
  "flow": {
    "id": "8121BB66-0FC3-467D-A916-EA0F53E08D00",
    "name": "Zendesk: patient refill request to prescribers"
  },
  "flowVersion": {
    "clientMetadata": {
      "viewport": {
        "x": -31.778140293637847,
        "y": 13.898858075040785,
        "zoom": 0.65
      },
      "autoSave": false,
      "descriptions": {
        "flow": "When a patient asks for a refill by email or web form, matches them in Healthie on name and birth date, adds the medication list and visits to the ticket as an internal note and routes it to the prescriber group. When a prescriber tags it visit_needed, adds a Healthie appointment request and tells the patient a visit is needed first. A near, double or missing match stays with a person.",
        "initialData": "",
        "initialDataFields": {}
      }
    },
    "description": "When a patient asks for a refill by email or web form, matches them in Healthie on name and birth date, adds the medication list and visits to the ticket as an internal note and routes it to the prescriber group. When a prescriber tags it visit_needed, adds a Healthie appointment request and tells the patient a visit is needed first. A near, double or missing match stays with a person.",
    "elements": [
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Write the chart note Result"
          },
          "position": {
            "x": 1601,
            "y": 819
          }
        },
        "flowElementId": "E68B1A62-0CB9-40DD-A0ED-E2AE4BE2BC94",
        "groupId": null,
        "id": "ECD700F2-62A2-4B89-BF62-5B49772CADFE",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "request",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Request",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E41907FA-C2EA-4C35-B642-E83FCDFCE449"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "match",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Match",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "CBA4E34F-D962-4A2F-BDD9-3AAD07DBA648"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "meds",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Medications",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "4E238D30-152D-4634-8C79-9370C1CDC6C8"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "lastVisit",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Last visit",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "2956EEF3-C822-4F71-8FCF-EC8B182B5FBE"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "nextVisit",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Next visit",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "E515FC15-3E08-42BB-869B-6677DE80CA7B"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "ticket",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Ticket",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "C167AB98-E147-467E-935B-2AC34B00D3B0"
                  }
                ],
                "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 = request || {};\nconst m = match || {};\nconst name = [r.patientFirstName, r.patientLastName].filter(Boolean).join(' ') || 'unknown patient';\nconst asked = (Array.isArray(r.medications) ? r.medications : []).filter(Boolean);\nconst chartMeds = (meds && meds.medications) || [];\nconst medsList = chartMeds.map((x) => [x.name, x.dosage, x.directions].filter(Boolean).join(', '));\nconst firstWord = (s) => String(s || '').trim().split(/\\s+/)[0].toLowerCase();\nconst notOnChart = asked.filter((a) => firstWord(a) && !chartMeds.some((x) => String(x.name || '').toLowerCase().includes(firstWord(a))));\nconst past = ((lastVisit && lastVisit.appointments) || [])[0];\nconst next = nextVisit && nextVisit.has_upcoming ? nextVisit.next_appointment : null;\nconst visit = (a) => (a ? [fmt(a.date), a.appointment_type && a.appointment_type.name, a.provider && a.provider.full_name && `with ${a.provider.full_name}`].filter(Boolean).join(', ') : 'none on the chart');\nconst paras = [\n  [\n    `Refill request from ${r.writtenBy === 'someone else' ? 'someone writing for the patient' : 'the patient'}, matched to one Healthie chart on name and birth date.`,\n    `Patient: ${name}, born ${fmt(r.patientDateOfBirth)}`,\n    `Healthie chart: ${chartLink}${m.patientId}`,\n    `Asks to refill: ${asked.length ? asked.join('; ') : 'no medication named'}`,\n    r.pharmacy ? `Pharmacy named: ${r.pharmacy}` : '',\n  ].filter(Boolean).join('\\n'),\n  ['Medications on the chart:', ...(medsList.length ? medsList.map((x) => `- ${x}`) : ['- none listed']), notOnChart.length ? `Not on the chart's medication list: ${notOnChart.join('; ')}` : ''].filter(Boolean).join('\\n'),\n  `Last visit: ${visit(past)}\\nNext visit: ${visit(next)}`,\n  'For the prescriber: renew it through your e-prescribing system and reply to the patient as usual. If the patient needs a visit first, add the tag visit_needed. FlowRunner then adds an appointment request in Healthie and tells the patient a visit is needed.',\n];\nconst text = paras.join('\\n\\n');\nconst html = paras.map((p) => `<p>${esc(p).replace(/\\n/g, '<br>').replace(/(https:\\/\\/[^\\s<]+)/g, '<a href=\"$1\">$1</a>')}</p>`).join('');\nconst tags = [...new Set([...((ticket && ticket.tags) || []), 'rx_refill_request'])];\nreturn { text, html, tags, medications: asked.join(', ') || 'the requested prescription' };\n"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Note",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Write the chart note",
        "nextElementIds": [
          "D981EE58-2686-4984-BC18-1508F3B779FC"
        ],
        "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": 1160,
            "y": 210
          }
        },
        "flowElementId": "FE8EE92A-1C14-43BF-8779-5838B2044C9B",
        "groupId": null,
        "id": "315B0C56-0760-414F-8CC3-6498DFD9CA96",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "firstName",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "lastName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Request",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E41907FA-C2EA-4C35-B642-E83FCDFCE449"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dateOfBirth",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Request",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientDateOfBirth",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E41907FA-C2EA-4C35-B642-E83FCDFCE449"
                  }
                ],
                "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": [
          "2916A35F-02CC-402F-8E1C-CCAFBE76DBC7"
        ],
        "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": 760,
            "y": 210
          }
        },
        "flowElementId": "D1CADED6-B614-4B6F-B3F0-6D4E67EF02C0",
        "groupId": null,
        "id": "2916A35F-02CC-402F-8E1C-CCAFBE76DBC7",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "firstName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Request",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientFirstName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E41907FA-C2EA-4C35-B642-E83FCDFCE449"
                  }
                ],
                "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": "Request",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientDateOfBirth",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E41907FA-C2EA-4C35-B642-E83FCDFCE449"
                  }
                ],
                "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": [
          "CBA4E34F-D962-4A2F-BDD9-3AAD07DBA648"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Lists the medications on a patient's Healthie chart: name, dosage, directions, frequency, route, dates and whether each is active.",
          "elementId": "EXTENSION:::SHARED:::default:::healthie:::listMedications",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Read the medication list Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::listMedications",
          "legacyElementId": null,
          "methodName": "listMedications",
          "position": {
            "x": 798,
            "y": 510
          }
        },
        "flowElementId": "1443A111-5F13-4DB9-B9B9-6AFA70D83C01",
        "groupId": null,
        "id": "4E238D30-152D-4634-8C79-9370C1CDC6C8",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "patientId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Match",
                    "subPathSegments": [
                      {
                        "key": "patientId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "CBA4E34F-D962-4A2F-BDD9-3AAD07DBA648"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "activeOnly",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_TRUE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": true
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pageSize",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 50
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "cursor",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "listMedications",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Medications",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Read the medication list",
        "nextElementIds": [
          "2956EEF3-C822-4F71-8FCF-EC8B182B5FBE"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Updates an existing ticket's subject, status, priority, type, due date (tasks only), assignee, group, or tags. Only the fields you provide are changed; tags, when provided, replace the ticket's existing tags. Returns the updated ticket.",
          "elementId": "EXTENSION:::SHARED:::default:::zendesk:::updateTicket",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Tag for a chart check Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::zendesk:::updateTicket",
          "legacyElementId": "JS###v1###Zendesk###updateTicket",
          "methodName": "updateTicket",
          "position": {
            "x": 1206,
            "y": 640
          }
        },
        "flowElementId": "A94F8834-E36A-4B15-953C-6878873DE803",
        "groupId": null,
        "id": "18CC722C-1313-4F19-AAEB-B6C877EA3F44",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "ticketId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "New ticket",
                    "subPathSegments": [
                      {
                        "key": "ticketId",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "1E6FE9FE-4CC0-4A5C-B079-94B49683BC84"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "subject",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "status",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "priority",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "type",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dueAt",
              "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",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Match note",
                    "subPathSegments": [
                      {
                        "key": "tags",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "A2030318-D3FC-4672-9E13-80C29FE6777E"
                  }
                ],
                "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": "updateTicket",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Tagged",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "zendesk",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Tag for a chart check",
        "nextElementIds": [
          "2FC306FB-11BA-4015-985C-463767623A2A"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Match the patient Result"
          },
          "position": {
            "x": 435,
            "y": 219
          }
        },
        "flowElementId": "32AC622A-AA17-418D-A5A5-BB4FCA90BC0F",
        "groupId": null,
        "id": "CBA4E34F-D962-4A2F-BDD9-3AAD07DBA648",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "request",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Request",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E41907FA-C2EA-4C35-B642-E83FCDFCE449"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "exact",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Exact search",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "36031336-9DA6-40F6-9C70-A4D2A3F5E21F"
                  }
                ],
                "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": "315B0C56-0760-414F-8CC3-6498DFD9CA96"
                  }
                ],
                "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": "2916A35F-02CC-402F-8E1C-CCAFBE76DBC7"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "practiceTz",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Practice time zone",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Practice time zone"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const norm = (s) => String(s || '').trim().toLowerCase();\nconst r = request || {};\nconst dob = String(r.patientDateOfBirth || '').trim();\n// Match on name plus birth date only. A search with an empty birth date returns everyone with the name, so those searches only count when the message gives one.\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};\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);\nlet chartReason = '';\nif (!dob) chartReason = 'the message gives no birth date';\nelse if (exactList.length > 1) chartReason = 'more than one chart has this name and birth date';\nelse if (exactList.length === 0 && candidates.length) chartReason = 'a chart looks like the same patient, but the name or birth date differs';\nelse if (exactList.length === 0) chartReason = 'no chart in Healthie has this name and birth date';\nconst patient = exactList.length === 1 ? exactList[0] : null;\nreturn { patientId: patient ? String(patient.id) : '', timezone: (patient && patient.timezone) || practiceTz || 'America/New_York', chartReason, candidates };\n"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Match",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Match the patient",
        "nextElementIds": [
          "02D89CF5-7B19-4B7B-BAAA-AEEACB3CFF87"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Fires when a ticket is created or updated in Zendesk. Provisions a Zendesk webhook plus a business-rule trigger that posts the ticket's ID (a number, like Get Ticket's), subject, status, priority, type, tags, requester, assignee, and URL to FlowRunner in real time. A flow activated before tags were added receives them once it is activated again.",
          "elementId": "EXTENSION:::SHARED:::default:::zendesk:::onTicketEvent",
          "isFirstElement": true,
          "blockDefinitionId": "api-service-trigger",
          "newElementId": "EXTENSION:::SHARED:::default:::zendesk:::onTicketEvent",
          "legacyElementId": "JS###v1###Zendesk###onTicketEvent",
          "methodName": "onTicketEvent",
          "position": {
            "x": 110,
            "y": 40
          }
        },
        "flowElementId": "22684326-8FE2-43B6-BC03-8267FB71EC87",
        "groupId": null,
        "id": "1E6FE9FE-4CC0-4A5C-B079-94B49683BC84",
        "metaInfo": {
          "callbackUrl": null,
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": null,
          "connectionId": null,
          "eventName": "onTicketEvent",
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "New ticket",
          "scope": "SINGLE_APP",
          "serviceId": "zendesk",
          "slaConditions": [],
          "staticData": {
            "event": "created"
          },
          "storeResult": true,
          "subtype": "REALTIME",
          "type": "CUSTOM"
        },
        "name": "New ticket",
        "nextElementIds": [
          "C23F99D5-247A-48E7-991E-7AC7B29124C6"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "notes": "Lists a patient's appointments in Healthie, with every provider: upcoming ones soonest first, or past ones newest first. Narrow them by dates, type, provider or status. The result says whether the patient has an upcoming appointment and which one is next, so a flow can check that a patient has booked.",
          "elementId": "EXTENSION:::SHARED:::default:::healthie:::listAppointments",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Find the last visit Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::listAppointments",
          "legacyElementId": null,
          "methodName": "listAppointments",
          "position": {
            "x": 1209,
            "y": 510
          }
        },
        "flowElementId": "B213B2A2-474E-4D01-9A95-636FCD16F64A",
        "groupId": null,
        "id": "2956EEF3-C822-4F71-8FCF-EC8B182B5FBE",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "patientId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Match",
                    "subPathSegments": [
                      {
                        "key": "patientId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "CBA4E34F-D962-4A2F-BDD9-3AAD07DBA648"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "timeframe",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "past"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "fromDate",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "toDate",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "appointmentTypeId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "providerId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "includeCanceled",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sortBy",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pageSize",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 1
                  }
                ],
                "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": "listAppointments",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Last visit",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Find the last visit",
        "nextElementIds": [
          "E515FC15-3E08-42BB-869B-6677DE80CA7B"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "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": "Read the ticket Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::zendesk:::getTicket",
          "legacyElementId": "JS###v1###Zendesk###getTicket",
          "methodName": "getTicket",
          "position": {
            "x": 810,
            "y": 40
          }
        },
        "flowElementId": "C7D2CCDF-0DE3-4D7D-A345-473DF8A89FAC",
        "groupId": null,
        "id": "C167AB98-E147-467E-935B-2AC34B00D3B0",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "ticketId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "New ticket",
                    "subPathSegments": [
                      {
                        "key": "ticketId",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "1E6FE9FE-4CC0-4A5C-B079-94B49683BC84"
                  }
                ],
                "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",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "zendesk",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Read the ticket",
        "nextElementIds": [
          "E41907FA-C2EA-4C35-B642-E83FCDFCE449"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Updates an existing ticket's subject, status, priority, type, due date (tasks only), assignee, group, or tags. Only the fields you provide are changed; tags, when provided, replace the ticket's existing tags. Returns the updated ticket.",
          "elementId": "EXTENSION:::SHARED:::default:::zendesk:::updateTicket",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Route to the prescribers Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::zendesk:::updateTicket",
          "legacyElementId": "JS###v1###Zendesk###updateTicket",
          "methodName": "updateTicket",
          "position": {
            "x": 1196,
            "y": 810
          }
        },
        "flowElementId": "ECAEB4F1-3635-484E-9D0D-0F76C8FC01DD",
        "groupId": null,
        "id": "D981EE58-2686-4984-BC18-1508F3B779FC",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "ticketId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "New ticket",
                    "subPathSegments": [
                      {
                        "key": "ticketId",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "1E6FE9FE-4CC0-4A5C-B079-94B49683BC84"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "subject",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "status",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "priority",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "type",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dueAt",
              "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",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Note",
                    "subPathSegments": [
                      {
                        "key": "tags",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "ECD700F2-62A2-4B89-BF62-5B49772CADFE"
                  }
                ],
                "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": "updateTicket",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Routed",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "zendesk",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Route to the prescribers",
        "nextElementIds": [
          "F599FC4E-6389-4F69-B847-66AB9E155478"
        ],
        "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": "Find the patient's chart Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::searchPatients",
          "legacyElementId": null,
          "methodName": "searchPatients",
          "position": {
            "x": 1591,
            "y": 210
          }
        },
        "flowElementId": "AA4E444D-777A-4338-91F0-C7C4F7313D44",
        "groupId": null,
        "id": "36031336-9DA6-40F6-9C70-A4D2A3F5E21F",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "firstName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Request",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientFirstName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E41907FA-C2EA-4C35-B642-E83FCDFCE449"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "lastName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Request",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E41907FA-C2EA-4C35-B642-E83FCDFCE449"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dateOfBirth",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Request",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientDateOfBirth",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E41907FA-C2EA-4C35-B642-E83FCDFCE449"
                  }
                ],
                "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": [
          "315B0C56-0760-414F-8CC3-6498DFD9CA96"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "ai-agent",
          "isFirstElement": false,
          "blockDefinitionId": "ai-agent",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Read the request Result"
          },
          "tools": {},
          "position": {
            "x": 1209,
            "y": 49
          }
        },
        "flowElementId": "9D8DE1CF-7288-4B82-9858-8658CA80332B",
        "groupId": null,
        "id": "E41907FA-C2EA-4C35-B642-E83FCDFCE449",
        "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": "Request",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "systemPrompt": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "You read new support tickets at a prescribing practice and decide whether a patient, or someone writing for a patient such as a parent or caregiver, is asking for a prescription refill or renewal. You only report what the message says. You never give or suggest medical advice and never judge whether a refill should be given. Reply with JSON only, with these fields:\nisRefillRequest: true if the message asks to refill or renew a prescription; false for anything else, such as a question from a pharmacy, a question about symptoms or side effects, billing or scheduling\npatientFirstName: the patient's first name as written (the patient's, not the writer's when someone writes for them)\npatientLastName: the patient's last name as written\npatientDateOfBirth: the patient's date of birth as YYYY-MM-DD, or empty text when the message does not give it\nmedications: a list of the medications the message asks to refill, each as written, with the strength when given; an empty list when none is named\npharmacy: the pharmacy the message names, or empty text\nwrittenBy: \"patient\" or \"someone else\"\nsummary: one plain sentence saying what the message asks\nNever guess a value that is not in the message; use empty text."
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "tools": [],
          "type": "AI_AGENT",
          "userPrompt": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "Ticket subject: "
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Ticket",
                "subPathSegments": [
                  {
                    "key": "subject",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "C167AB98-E147-467E-935B-2AC34B00D3B0"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "\nFrom: "
              },
              {
                "id": "RESULT",
                "label": "New ticket",
                "subPathSegments": [
                  {
                    "key": "requesterName",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "1E6FE9FE-4CC0-4A5C-B079-94B49683BC84"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": " <"
              },
              {
                "id": "RESULT",
                "label": "New ticket",
                "subPathSegments": [
                  {
                    "key": "requesterEmail",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "1E6FE9FE-4CC0-4A5C-B079-94B49683BC84"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": ">\n\nMessage:\n"
              },
              {
                "id": "ELEMENT_RESULT",
                "label": "Ticket",
                "subPathSegments": [
                  {
                    "key": "description",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "C167AB98-E147-467E-935B-2AC34B00D3B0"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          }
        },
        "name": "Read the request",
        "nextElementIds": [
          "252B003C-1FF3-4A47-9B1C-E48D3DF59A69"
        ],
        "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": "Add the chart note Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::zendesk:::addCommentToTicket",
          "legacyElementId": "JS###v1###Zendesk###addCommentToTicket",
          "methodName": "addCommentToTicket",
          "position": {
            "x": 810,
            "y": 810
          }
        },
        "flowElementId": "66133A5D-3519-49A7-894A-889842CF2555",
        "groupId": null,
        "id": "F599FC4E-6389-4F69-B847-66AB9E155478",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "ticketId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "New ticket",
                    "subPathSegments": [
                      {
                        "key": "ticketId",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "1E6FE9FE-4CC0-4A5C-B079-94B49683BC84"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "commentBody",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Note",
                    "subPathSegments": [
                      {
                        "key": "text",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "ECD700F2-62A2-4B89-BF62-5B49772CADFE"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "htmlBody",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Note",
                    "subPathSegments": [
                      {
                        "key": "html",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "ECD700F2-62A2-4B89-BF62-5B49772CADFE"
                  }
                ],
                "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": "Chart note",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "zendesk",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Add the chart note",
        "nextElementIds": [
          "F7B0C31C-0909-43B9-AD27-5E6020267229"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1601,
            "y": 49
          }
        },
        "flowElementId": "6936269A-96D8-437B-B50D-7417987F2D7B",
        "groupId": null,
        "id": "252B003C-1FF3-4A47-9B1C-E48D3DF59A69",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "b5ad07d0-9f43-4652-9b63-69d505854330",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Request",
                      "subPathSegments": [
                        {
                          "key": "output",
                          "optional": false
                        },
                        {
                          "key": "isRefillRequest",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "E41907FA-C2EA-4C35-B642-E83FCDFCE449"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "b5ad07d0-9f43-4652-9b63-69d505854330"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Is refill",
          "storeResult": false,
          "thenComponent": {
            "componentId": "36031336-9DA6-40F6-9C70-A4D2A3F5E21F",
            "componentType": "ELEMENT"
          }
        },
        "name": "Refill request?",
        "nextElementIds": [
          "36031336-9DA6-40F6-9C70-A4D2A3F5E21F"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Write the match note Result"
          },
          "position": {
            "x": 808,
            "y": 649
          }
        },
        "flowElementId": "ABFC05BE-7E3E-430E-BB28-35A6CC78D6BC",
        "groupId": null,
        "id": "A2030318-D3FC-4672-9E13-80C29FE6777E",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "request",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Request",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E41907FA-C2EA-4C35-B642-E83FCDFCE449"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "match",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Match",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "CBA4E34F-D962-4A2F-BDD9-3AAD07DBA648"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "ticket",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Ticket",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "C167AB98-E147-467E-935B-2AC34B00D3B0"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const fmt = (d) => { const m = /^(\\d{4})-(\\d{2})-(\\d{2})/.exec(d || ''); return m ? `${m[2]}/${m[3]}/${m[1]}` : (d || 'not given'); };\nconst chartLink = 'https://secure.gethealthie.com/users/';\nconst r = request || {};\nconst m = match || {};\nconst name = [r.patientFirstName, r.patientLastName].filter(Boolean).join(' ') || 'no name given';\nconst cands = m.candidates || [];\nconst asked = (Array.isArray(r.medications) ? r.medications : []).filter(Boolean);\nconst text = [\n  `Refill request, but FlowRunner did not match it to a Healthie chart: ${m.chartReason || 'no exact match'}.`,\n  `Patient named: ${name}, born ${fmt(r.patientDateOfBirth)}. Asks to refill: ${asked.length ? asked.join('; ') : 'no medication named'}.`,\n  cands.length ? ['Charts that may be this patient:', ...cands.map((p) => `- ${p.name}, born ${fmt(p.dob)}, chart ID ${p.id} (${p.reasons.join(', ')}): ${chartLink}${p.id}`)].join('\\n') : 'No chart in Healthie looks like this patient.',\n  'Find the right chart, asking the patient for their date of birth if they did not give it, then route this ticket to the prescribers by hand.',\n].join('\\n\\n');\nconst tags = [...new Set([...((ticket && ticket.tags) || []), 'rx_refill_request', 'chart_check'])];\nreturn { text, tags };\n"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Match note",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Write the match note",
        "nextElementIds": [
          "18CC722C-1313-4F19-AAEB-B6C877EA3F44"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 435,
            "y": 519
          }
        },
        "flowElementId": "7E60A5C7-FE99-4911-9B78-6D08616DC0C7",
        "groupId": null,
        "id": "02D89CF5-7B19-4B7B-BAAA-AEEACB3CFF87",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "8850ab4b-1162-4093-8ef7-87728cde877c",
                "nestedOperation": null,
                "operation": "isNotEmpty",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Match",
                      "subPathSegments": [
                        {
                          "key": "patientId",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "CBA4E34F-D962-4A2F-BDD9-3AAD07DBA648"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": []
              }
            ],
            "grouping": [
              "8850ab4b-1162-4093-8ef7-87728cde877c"
            ]
          },
          "elseComponent": {
            "componentId": "A2030318-D3FC-4672-9E13-80C29FE6777E",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "One chart",
          "storeResult": false,
          "thenComponent": {
            "componentId": "4E238D30-152D-4634-8C79-9370C1CDC6C8",
            "componentType": "ELEMENT"
          }
        },
        "name": "One exact chart?",
        "nextElementIds": [
          "A2030318-D3FC-4672-9E13-80C29FE6777E",
          "4E238D30-152D-4634-8C79-9370C1CDC6C8"
        ],
        "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": "Ask a person to pick the chart Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::zendesk:::addCommentToTicket",
          "legacyElementId": "JS###v1###Zendesk###addCommentToTicket",
          "methodName": "addCommentToTicket",
          "position": {
            "x": 1569,
            "y": 380
          }
        },
        "flowElementId": "31654727-32C0-424A-AD4F-C6C1E3A33789",
        "groupId": null,
        "id": "2FC306FB-11BA-4015-985C-463767623A2A",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "ticketId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "New ticket",
                    "subPathSegments": [
                      {
                        "key": "ticketId",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "1E6FE9FE-4CC0-4A5C-B079-94B49683BC84"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "commentBody",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Match note",
                    "subPathSegments": [
                      {
                        "key": "text",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "A2030318-D3FC-4672-9E13-80C29FE6777E"
                  }
                ],
                "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": "Chart question",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "zendesk",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Ask a person to pick the chart",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 411,
            "y": 49
          }
        },
        "flowElementId": "103B2651-65D1-483E-A2C0-CEB688A24455",
        "groupId": null,
        "id": "C23F99D5-247A-48E7-991E-7AC7B29124C6",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "4133bdfa-14c2-40ee-943e-9297fe90a652",
                "nestedOperation": null,
                "operation": "notContains",
                "property": {
                  "expression": [
                    {
                      "id": "RESULT",
                      "label": "New ticket",
                      "subPathSegments": [
                        {
                          "key": "tags",
                          "optional": false
                        }
                      ],
                      "type": "TRIGGER_DATA",
                      "value": "1E6FE9FE-4CC0-4A5C-B079-94B49683BC84"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "TEXT",
                        "label": null,
                        "type": "INPUT",
                        "value": "pharmacy_rx"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              },
              {
                "id": "00f5ad72-b89d-4c73-91a7-9bbfad0ce149",
                "nestedOperation": null,
                "operation": "notContains",
                "property": {
                  "expression": [
                    {
                      "id": "RESULT",
                      "label": "New ticket",
                      "subPathSegments": [
                        {
                          "key": "tags",
                          "optional": false
                        }
                      ],
                      "type": "TRIGGER_DATA",
                      "value": "1E6FE9FE-4CC0-4A5C-B079-94B49683BC84"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "TEXT",
                        "label": null,
                        "type": "INPUT",
                        "value": "referral_intake"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "4133bdfa-14c2-40ee-943e-9297fe90a652",
              "AND",
              "00f5ad72-b89d-4c73-91a7-9bbfad0ce149"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Is patient ticket",
          "storeResult": false,
          "thenComponent": {
            "componentId": "C167AB98-E147-467E-935B-2AC34B00D3B0",
            "componentType": "ELEMENT"
          }
        },
        "name": "Not one of our flow tickets?",
        "nextElementIds": [
          "C167AB98-E147-467E-935B-2AC34B00D3B0"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Lists a patient's appointments in Healthie, with every provider: upcoming ones soonest first, or past ones newest first. Narrow them by dates, type, provider or status. The result says whether the patient has an upcoming appointment and which one is next, so a flow can check that a patient has booked.",
          "elementId": "EXTENSION:::SHARED:::default:::healthie:::listAppointments",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Find the next visit Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::listAppointments",
          "legacyElementId": null,
          "methodName": "listAppointments",
          "position": {
            "x": 1601,
            "y": 510
          }
        },
        "flowElementId": "02916A15-9854-4837-959C-139BDB779EEF",
        "groupId": null,
        "id": "E515FC15-3E08-42BB-869B-6677DE80CA7B",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "patientId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Match",
                    "subPathSegments": [
                      {
                        "key": "patientId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "CBA4E34F-D962-4A2F-BDD9-3AAD07DBA648"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "timeframe",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "upcoming"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "fromDate",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "toDate",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "appointmentTypeId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "providerId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "includeCanceled",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sortBy",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pageSize",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 1
                  }
                ],
                "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": "listAppointments",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Next visit",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Find the next visit",
        "nextElementIds": [
          "ECD700F2-62A2-4B89-BF62-5B49772CADFE"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Adds a request to Healthie's appointment request list for your scheduling team, for an existing patient or for someone not yet in Healthie, with the reason and the times that suit them.",
          "elementId": "EXTENSION:::SHARED:::default:::healthie:::createAppointmentRequest",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Request a visit in Healthie Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::createAppointmentRequest",
          "legacyElementId": null,
          "methodName": "createAppointmentRequest",
          "position": {
            "x": 1190,
            "y": 980
          }
        },
        "flowElementId": "C624C3E2-D0F8-411D-9382-7855BFBD0127",
        "groupId": null,
        "id": "714A8E4D-BB29-4B84-8576-C4C0712B51B0",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "reason",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "Visit needed before a refill of "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Note",
                    "subPathSegments": [
                      {
                        "key": "medications",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "ECD700F2-62A2-4B89-BF62-5B49772CADFE"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " (Zendesk ticket "
                  },
                  {
                    "id": "RESULT",
                    "label": "New ticket",
                    "subPathSegments": [
                      {
                        "key": "ticketId",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "1E6FE9FE-4CC0-4A5C-B079-94B49683BC84"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ")"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "timezone",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Match",
                    "subPathSegments": [
                      {
                        "key": "timezone",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "CBA4E34F-D962-4A2F-BDD9-3AAD07DBA648"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "patientId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Match",
                    "subPathSegments": [
                      {
                        "key": "patientId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "CBA4E34F-D962-4A2F-BDD9-3AAD07DBA648"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "firstName",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "lastName",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "email",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "phone",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "providerId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "appointmentTypeId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "contactType",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "state",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "slots",
              "type": "COMPLEX_LIST",
              "value": []
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "createAppointmentRequest",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Visit request",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Request a visit in Healthie",
        "nextElementIds": [
          "4A207211-01EC-4C15-A863-DBE00E602B2E"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "router",
          "isFirstElement": false,
          "blockDefinitionId": "router",
          "casesViewMode": {
            "51249815-f313-4378-bdb5-767a0c7d3683": "SIMPLE",
            "3370cdb4-9b9a-4dca-938d-953e56c18cdd": "SIMPLE"
          },
          "position": {
            "x": 804,
            "y": 989
          }
        },
        "flowElementId": "DA41E44C-E1DE-4E2B-B23A-C774EB713BF1",
        "groupId": null,
        "id": "7F89D408-07AF-4EED-919B-86DB87080AF7",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Decision",
          "storeResult": true,
          "switchCases": [
            {
              "defaultCase": false,
              "id": "51249815-f313-4378-bdb5-767a0c7d3683",
              "label": "Visit needed",
              "nextComponents": [
                {
                  "componentId": "714A8E4D-BB29-4B84-8576-C4C0712B51B0",
                  "componentType": "ELEMENT"
                }
              ],
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "visit"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "defaultCase": false,
              "id": "3370cdb4-9b9a-4dca-938d-953e56c18cdd",
              "label": "Still open after 14 days",
              "nextComponents": [
                {
                  "componentId": "FD42A355-6CD8-48A9-9566-BEDE8B09E955",
                  "componentType": "ELEMENT"
                }
              ],
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "waiting"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "defaultCase": true,
              "id": "d0075ced-52e2-4e95-95ef-31c22bb8fcd6",
              "label": "Everything Else",
              "nextComponents": [],
              "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": "Prescriber's decision?",
        "nextElementIds": [
          "714A8E4D-BB29-4B84-8576-C4C0712B51B0",
          "FD42A355-6CD8-48A9-9566-BEDE8B09E955"
        ],
        "nextGroupIds": [],
        "type": "VALUE_ROUTER"
      },
      {
        "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 watch ended Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::zendesk:::addCommentToTicket",
          "legacyElementId": "JS###v1###Zendesk###addCommentToTicket",
          "methodName": "addCommentToTicket",
          "position": {
            "x": 1203,
            "y": 1110
          }
        },
        "flowElementId": "F1968892-A707-46D9-B8E7-A0C3ADD80883",
        "groupId": null,
        "id": "FD42A355-6CD8-48A9-9566-BEDE8B09E955",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "ticketId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "New ticket",
                    "subPathSegments": [
                      {
                        "key": "ticketId",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "1E6FE9FE-4CC0-4A5C-B079-94B49683BC84"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "commentBody",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "FlowRunner stopped watching this refill request after 14 days. If the patient needs a visit first, add the appointment request in Healthie and tell the patient by hand."
                  }
                ],
                "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": "Watch note",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "zendesk",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Note the watch ended",
        "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": "Tell the patient a visit comes first Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::zendesk:::addCommentToTicket",
          "legacyElementId": "JS###v1###Zendesk###addCommentToTicket",
          "methodName": "addCommentToTicket",
          "position": {
            "x": 1557,
            "y": 980
          }
        },
        "flowElementId": "1DBD6563-D8C6-47CA-80F5-D967F0032E59",
        "groupId": null,
        "id": "4A207211-01EC-4C15-A863-DBE00E602B2E",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "ticketId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "New ticket",
                    "subPathSegments": [
                      {
                        "key": "ticketId",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "1E6FE9FE-4CC0-4A5C-B079-94B49683BC84"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "commentBody",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "Thank you for your refill request. Your prescriber needs to see you before this prescription can be renewed, so we have asked our scheduling team to set up a visit. They will contact you to book a time."
                  }
                ],
                "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_TRUE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": true
                  }
                ],
                "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": "Patient reply",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "zendesk",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Tell the patient a visit comes first",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Visit needed or solved? Result"
          },
          "position": {
            "x": 710,
            "y": 319
          }
        },
        "flowElementId": "68542246-A3F4-46E6-8277-ECD91B7B80FB",
        "groupId": "4C8D2573-51D8-47A7-BCA2-1AA6866B58A2",
        "id": "BF03AC07-6C95-4AF1-9348-82B2DAF48706",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "now",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Ticket now",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "5BEA299F-3EAA-4FD8-BC96-B0D992390836"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "// A prescriber's visit_needed tag wins over a solved status, so a ticket tagged and solved together still books the visit.\nconst tags = (now && now.tags) || [];\nconst status = String((now && now.status) || '').toLowerCase();\nif (tags.includes('visit_needed')) return { decision: 'visit' };\nif (status === 'solved' || status === 'closed') return { decision: 'done' };\nreturn { decision: 'waiting' };\n"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "State",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Visit needed or solved?",
        "nextElementIds": [
          "6A67CFE3-556A-4C47-BDA5-EA54D214DF34"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "data-bucket",
          "isFirstElement": false,
          "blockDefinitionId": "data-bucket",
          "fieldKeys": {
            "decision": "3377c66e-242f-4ccf-9efe-fd23e9929e05"
          },
          "position": {
            "x": 435,
            "y": 819
          }
        },
        "flowElementId": "025EF9FB-D06A-4161-BE6D-368449E3BF75",
        "groupId": null,
        "id": "F7B0C31C-0909-43B9-AD27-5E6020267229",
        "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
              }
            }
          ],
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "startw",
          "storeResult": true
        },
        "name": "Start watching",
        "nextElementIds": [],
        "nextGroupIds": [
          "4C8D2573-51D8-47A7-BCA2-1AA6866B58A2"
        ],
        "type": "DATA_BUCKET"
      },
      {
        "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": 410,
            "y": 310
          }
        },
        "flowElementId": "9B93F0AB-5A96-4788-900B-569461F2180D",
        "groupId": "4C8D2573-51D8-47A7-BCA2-1AA6866B58A2",
        "id": "5BEA299F-3EAA-4FD8-BC96-B0D992390836",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "ticketId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "New ticket",
                    "subPathSegments": [
                      {
                        "key": "ticketId",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "1E6FE9FE-4CC0-4A5C-B079-94B49683BC84"
                  }
                ],
                "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": [
          "BF03AC07-6C95-4AF1-9348-82B2DAF48706"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "wait",
          "isFirstElement": true,
          "blockDefinitionId": "wait",
          "mode": "SIMPLE",
          "position": {
            "x": 110,
            "y": 319
          }
        },
        "flowElementId": "D2475B22-3A23-4439-9467-9F71684672B1",
        "groupId": "4C8D2573-51D8-47A7-BCA2-1AA6866B58A2",
        "id": "6692C100-ABAE-4938-B9CB-0B0D7B79B9BB",
        "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": "w15",
          "storeResult": true
        },
        "name": "Wait 15 minutes",
        "nextElementIds": [
          "5BEA299F-3EAA-4FD8-BC96-B0D992390836"
        ],
        "nextGroupIds": [],
        "type": "WAIT"
      },
      {
        "clientMetadata": {
          "elementId": "data-bucket",
          "isFirstElement": false,
          "blockDefinitionId": "data-bucket",
          "fieldKeys": {
            "decision": "04f2360e-f6ef-494d-bf63-9e508fa78396"
          },
          "position": {
            "x": 1030,
            "y": 319
          }
        },
        "flowElementId": "94ABAA27-DD9F-4616-B182-A7B6AC2731BA",
        "groupId": "4C8D2573-51D8-47A7-BCA2-1AA6866B58A2",
        "id": "6A67CFE3-556A-4C47-BDA5-EA54D214DF34",
        "metaInfo": {
          "bucketName": "Default",
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "fields": [
            {
              "name": "decision",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "State",
                    "subPathSegments": [
                      {
                        "key": "decision",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "BF03AC07-6C95-4AF1-9348-82B2DAF48706"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "keep",
          "storeResult": true
        },
        "name": "Keep the decision",
        "nextElementIds": [],
        "nextGroupIds": [],
        "type": "DATA_BUCKET"
      }
    ],
    "firstElementId": "1E6FE9FE-4CC0-4A5C-B079-94B49683BC84",
    "groups": [
      {
        "clientMetadata": {
          "elementId": "repeat",
          "isFirstElement": false,
          "blockDefinitionId": "repeat",
          "viewport": {
            "x": -70,
            "y": -270,
            "zoom": 1
          },
          "position": {
            "x": 410,
            "y": 989
          }
        },
        "flowElementId": "0BE762B2-0602-4783-8336-32FE5CFD88C6",
        "groupId": null,
        "id": "4C8D2573-51D8-47A7-BCA2-1AA6866B58A2",
        "loopType": "REPEAT",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "5ea11d84-2635-404e-999b-c953f06bb1f0",
                "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": [
              "5ea11d84-2635-404e-999b-c953f06bb1f0"
            ]
          },
          "enabled": true,
          "firstElementId": "6692C100-ABAE-4938-B9CB-0B0D7B79B9BB",
          "maxIterations": 1344,
          "onFailElemId": null,
          "resultAlias": "loop",
          "storeResult": true
        },
        "name": "Until the prescriber decides",
        "nextElementIds": [
          "7F89D408-07AF-4EED-919B-86DB87080AF7"
        ],
        "nextGroupIds": [],
        "type": "LOOP"
      }
    ],
    "id": "97DDF89A-9FF5-40E7-8D4E-68BF6DF2F739",
    "metaInfo": {
      "clientValidationState": {
        "errorMessage": null,
        "valid": true
      },
      "errorMessage": null,
      "executionStaticData": [
        {
          "description": "Your Anthropic API key, used to read the tickets.",
          "error": null,
          "name": "Anthropic key",
          "type": "API_KEY",
          "value": null
        },
        {
          "description": "The IANA time zone used for an appointment request when the patient's chart has none.",
          "error": null,
          "name": "Practice time zone",
          "type": "STRING",
          "value": ""
        }
      ],
      "initialData": null,
      "initialDataDefaultValues": {},
      "ownerFlowVersionId": null,
      "schedule": null,
      "sharedMemory": {
        "anchor": {
          "missingAnchorPolicy": null,
          "path": null,
          "type": "FLOW_MEMORY"
        },
        "expirationInSec": null
      },
      "wasLive": false
    }
  },
  "slaCalendars": [],
  "slaGoals": [],
  "subFlows": [],
  "exportDate": "2026-12-03T04:11:52.270Z"
}
