{
  "elementsLearnedData": [],
  "elementsTestData": [],
  "flow": {
    "id": "50C33AA3-954C-4341-93E4-D945FC3BE87B",
    "name": "Jotform: unfinished form chased before the visit"
  },
  "flowVersion": {
    "clientMetadata": {
      "viewport": {
        "x": -65.26315789473684,
        "y": -103.54066985645932,
        "zoom": 0.96
      },
      "autoSave": false,
      "descriptions": {
        "flow": "When a patient's first visit is booked in Healthie, waits until two days before it and looks in Jotform for their new-patient form, matched on last name plus birth date or email. If the visit is still booked and the form is missing, texts the patient the form link with Twilio. If the form is still missing the day before the visit, or there is no phone number to text, gives the front desk a high-priority Healthie task to call the patient.",
        "initialData": "",
        "initialDataFields": {}
      }
    },
    "description": "When a patient's first visit is booked in Healthie, waits until two days before it and checks Jotform for their new-patient form. If it is missing, texts the patient the link with Twilio; if it is still missing a day later, gives the front desk a Healthie task to call.",
    "elements": [
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 848,
            "y": 159
          }
        },
        "flowElementId": "6C6F7FF1-DFBB-414B-8806-42696B3CF528",
        "groupId": null,
        "id": "ADCF5F64-42D1-4E5E-BB95-5DC92F19B819",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "450c0f10-29aa-4d53-929a-b08c97f3d911",
                "nestedOperation": null,
                "operation": "equal",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Past visits",
                      "subPathSegments": [
                        {
                          "key": "total_count",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "C12B2EAC-B26C-4FB9-BB47-E49F944735FB"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "INT",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "NUMBER",
                        "label": null,
                        "type": "INPUT",
                        "value": 0
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "450c0f10-29aa-4d53-929a-b08c97f3d911"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Is first visit",
          "storeResult": false,
          "thenComponent": {
            "componentId": "46BFF954-854B-4F20-B1DC-8BD0D2729BDE",
            "componentType": "ELEMENT"
          }
        },
        "name": "First visit?",
        "nextElementIds": [
          "46BFF954-854B-4F20-B1DC-8BD0D2729BDE"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": true,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Time left Result"
          },
          "position": {
            "x": 110,
            "y": 40
          }
        },
        "flowElementId": "DA70AB95-9F72-4A66-A17A-C8A5DF17C1CD",
        "groupId": "73D3F651-AB1F-48F4-B345-3D2ADE6A02EC",
        "id": "B80E4228-6E74-4A70-882A-D2F4D395E4BC",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "target",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Timing",
                    "subPathSegments": [
                      {
                        "key": "firstCheckAt",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "09012B9F-47A3-48A2-ACCC-36FF32440531"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "// One wait lasts at most 7 days, so a visit booked further out waits in steps.\nconst left = target - Math.floor(Date.now() / 1000);\nreturn { seconds: Math.max(1, Math.min(604800, left)) };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Time left",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Time left",
        "nextElementIds": [
          "1A79747F-464F-43AE-86AB-283C6D7D6CAB"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Work out when to check Result"
          },
          "position": {
            "x": 1212,
            "y": 329
          }
        },
        "flowElementId": "FDAD8062-B3F4-415B-B972-857BD66C1E2F",
        "groupId": null,
        "id": "09012B9F-47A3-48A2-ACCC-36FF32440531",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "visitDate",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Appointment",
                    "subPathSegments": [
                      {
                        "key": "appointment",
                        "optional": false
                      },
                      {
                        "key": "date",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "700AECBE-475A-4DD8-8344-E757100FDBEC"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "patientTz",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Patient",
                    "subPathSegments": [
                      {
                        "key": "timezone",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "46BFF954-854B-4F20-B1DC-8BD0D2729BDE"
                  }
                ],
                "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": "// The first check is two days before the visit, the second one day before.\nconst visit = new Date(visitDate);\nif (isNaN(visit.getTime())) throw new Error('The appointment has no date.');\nconst day = 24 * 60 * 60;\nconst visitSec = Math.floor(visit.getTime() / 1000);\nlet visitText;\ntry {\n  visitText = visit.toLocaleString('en-US', { timeZone: patientTz || practiceTz || 'UTC', weekday: 'long', month: 'long', day: 'numeric', hour: 'numeric', minute: '2-digit' });\n} catch (e) {\n  visitText = visit.toISOString().slice(0, 16).replace('T', ' ') + ' UTC';\n}\n// Look back 180 days, so a form filled in before the visit was booked counts.\nconst since = new Date(Date.now() - 180 * day * 1000).toISOString().slice(0, 10) + ' 00:00:00';\nreturn {\n  visitSec,\n  firstCheckAt: visitSec - 2 * day,\n  secondCheckAt: visitSec - day,\n  visitText,\n  filters: JSON.stringify({ 'created_at:gt': since }),\n  dueDate: new Date((visitSec - 3 * 60 * 60) * 1000).toISOString(),\n};"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Timing",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Work out when to check",
        "nextElementIds": [],
        "nextGroupIds": [
          "73D3F651-AB1F-48F4-B345-3D2ADE6A02EC"
        ],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 140,
            "y": 839
          }
        },
        "flowElementId": "50BC5CFB-1E4A-44D6-927E-73E8B1BE4CAF",
        "groupId": null,
        "id": "FA9EB409-8500-4EE5-ADB3-86864BAC9241",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "cfc90470-fa73-461e-967f-54c291bd54e2",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Second form check",
                      "subPathSegments": [
                        {
                          "key": "formDone",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "153326F4-263E-4E2D-AD84-D2847262726F"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "cfc90470-fa73-461e-967f-54c291bd54e2"
            ]
          },
          "elseComponent": {
            "componentId": "0273992C-A886-4325-85BD-7B9AC2F4A5D7",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Form done now",
          "storeResult": false,
          "thenComponent": null
        },
        "name": "Form done now?",
        "nextElementIds": [
          "0273992C-A886-4325-85BD-7B9AC2F4A5D7"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Match the form again Result"
          },
          "position": {
            "x": 137,
            "y": 669
          }
        },
        "flowElementId": "5612A373-4E47-4D8F-AE32-BB0A9CCBD0C2",
        "groupId": null,
        "id": "153326F4-263E-4E2D-AD84-D2847262726F",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "forms",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Forms now",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "C0635269-601D-4144-BB33-A52A2F18CEB0"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "patient",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Patient",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "46BFF954-854B-4F20-B1DC-8BD0D2729BDE"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "// A form counts when it has the patient's last name and their birth date or email.\nconst p = patient || {};\nconst last = String(p.last_name || '').trim().toLowerCase();\nconst email = String(p.email || '').trim().toLowerCase();\nconst parts = String(p.dob || '').slice(0, 10).split('-').map(Number);\nconst months = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'];\nconst isDob = (text) => {\n  if (parts.length !== 3 || !parts[0]) return false;\n  const t = text.toLowerCase();\n  const nums = (t.match(/[0-9]+/g) || []).map(Number);\n  return nums.includes(parts[0]) && nums.includes(parts[2]) && (nums.includes(parts[1]) || t.includes(months[parts[1] - 1]));\n};\nconst values = (s) => Object.values(s.answers || {})\n  .filter((a) => a && a.answer !== undefined && a.answer !== '')\n  .map((a) => String(a.prettyFormat || (typeof a.answer === 'object' ? JSON.stringify(a.answer) : a.answer)));\nconst matches = (s) => {\n  const vals = values(s);\n  const all = vals.join(' ').toLowerCase();\n  if (!last || !all.includes(last)) return false;\n  return vals.some(isDob) || (email !== '' && all.includes(email));\n};\nconst list = ((forms && forms.content) || []).filter((s) => s && s.status === 'ACTIVE');\nconst form = list.find(matches);\nreturn { formDone: Boolean(form), submissionId: form ? String(form.id) : '' };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Second form check",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Match the form again",
        "nextElementIds": [
          "FA9EB409-8500-4EE5-ADB3-86864BAC9241"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 848,
            "y": 499
          }
        },
        "flowElementId": "693C5108-9A73-41F9-B16E-7B9261145B52",
        "groupId": null,
        "id": "B4404BF3-9E3A-4055-BD11-BD2E81E423DF",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "20f083d7-24ac-4438-bcbe-83ae3f66c09f",
                "nestedOperation": null,
                "operation": "isNotEmpty",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Patient",
                      "subPathSegments": [
                        {
                          "key": "phone_number",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "46BFF954-854B-4F20-B1DC-8BD0D2729BDE"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": []
              }
            ],
            "grouping": [
              "20f083d7-24ac-4438-bcbe-83ae3f66c09f"
            ]
          },
          "elseComponent": {
            "componentId": "0273992C-A886-4325-85BD-7B9AC2F4A5D7",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Has phone",
          "storeResult": false,
          "thenComponent": {
            "componentId": "7915A2FF-6F37-4439-9FEE-73DE758EA9EA",
            "componentType": "ELEMENT"
          }
        },
        "name": "Phone on file?",
        "nextElementIds": [
          "0273992C-A886-4325-85BD-7B9AC2F4A5D7",
          "7915A2FF-6F37-4439-9FEE-73DE758EA9EA"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Match the form to the patient Result"
          },
          "position": {
            "x": 110,
            "y": 499
          }
        },
        "flowElementId": "66D0C714-2B42-4DEF-AA16-FEB696870D19",
        "groupId": null,
        "id": "243C60BE-BB9F-404E-9EA6-BC7EA20D9D39",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "forms",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Recent forms",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "57F76141-F098-47F4-909B-2CC00F0249E0"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "patient",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Patient",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "46BFF954-854B-4F20-B1DC-8BD0D2729BDE"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "upcoming",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Upcoming visits",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "83F85ADC-48B7-472A-B90B-0CD992A033DD"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "appointmentId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Appointment",
                    "subPathSegments": [
                      {
                        "key": "appointment",
                        "optional": false
                      },
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "700AECBE-475A-4DD8-8344-E757100FDBEC"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "// A form counts when it has the patient's last name and their birth date or email.\nconst p = patient || {};\nconst last = String(p.last_name || '').trim().toLowerCase();\nconst email = String(p.email || '').trim().toLowerCase();\nconst parts = String(p.dob || '').slice(0, 10).split('-').map(Number);\nconst months = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'];\nconst isDob = (text) => {\n  if (parts.length !== 3 || !parts[0]) return false;\n  const t = text.toLowerCase();\n  const nums = (t.match(/[0-9]+/g) || []).map(Number);\n  return nums.includes(parts[0]) && nums.includes(parts[2]) && (nums.includes(parts[1]) || t.includes(months[parts[1] - 1]));\n};\nconst values = (s) => Object.values(s.answers || {})\n  .filter((a) => a && a.answer !== undefined && a.answer !== '')\n  .map((a) => String(a.prettyFormat || (typeof a.answer === 'object' ? JSON.stringify(a.answer) : a.answer)));\nconst matches = (s) => {\n  const vals = values(s);\n  const all = vals.join(' ').toLowerCase();\n  if (!last || !all.includes(last)) return false;\n  return vals.some(isDob) || (email !== '' && all.includes(email));\n};\nconst list = ((forms && forms.content) || []).filter((s) => s && s.status === 'ACTIVE');\nconst form = list.find(matches);\nconst booked = ((upcoming && upcoming.appointments) || []).some((a) => String(a.id) === String(appointmentId));\nreturn { formDone: Boolean(form), submissionId: form ? String(form.id) : '', stillBooked: booked };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Form check",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Match the form to the patient",
        "nextElementIds": [
          "5B8B66FB-004F-44B4-9E4D-188DA2A6EA03"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Gets a list of form responses with pagination and filtering options. Includes detailed submission data, answers, and metadata.",
          "elementId": "EXTENSION:::SHARED:::default:::jotform:::getFormSubmissions",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Look for the patient's form Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::jotform:::getFormSubmissions",
          "legacyElementId": "JS###v1###Jotform###getFormSubmissions",
          "methodName": "getFormSubmissions",
          "position": {
            "x": 119,
            "y": 320
          }
        },
        "flowElementId": "D01730E7-6B49-42C9-871A-EC5B5EDAAD2B",
        "groupId": null,
        "id": "57F76141-F098-47F4-909B-2CC00F0249E0",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "id",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Intake form ID",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Intake form ID"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "offset",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "limit",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 1000
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "filters",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Timing",
                    "subPathSegments": [
                      {
                        "key": "filters",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "09012B9F-47A3-48A2-ACCC-36FF32440531"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "orderBy",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "created_at"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Look for the patient's form', Error: The placeholder \"Intake form ID\" has no value",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "getFormSubmissions",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Recent forms",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "jotform",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Look for the patient's form",
        "nextElementIds": [
          "243C60BE-BB9F-404E-9EA6-BC7EA20D9D39"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "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": "Check the visit is still on Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::listAppointments",
          "legacyElementId": null,
          "methodName": "listAppointments",
          "position": {
            "x": 472,
            "y": 320
          }
        },
        "flowElementId": "6F24B494-C03B-4CCC-92B5-5C5046F50C7F",
        "groupId": null,
        "id": "83F85ADC-48B7-472A-B90B-0CD992A033DD",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "patientId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Appointment",
                    "subPathSegments": [
                      {
                        "key": "appointment",
                        "optional": false
                      },
                      {
                        "key": "user",
                        "optional": false
                      },
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "700AECBE-475A-4DD8-8344-E757100FDBEC"
                  }
                ],
                "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": 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": "listAppointments",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Upcoming visits",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Check the visit is still on",
        "nextElementIds": [
          "57F76141-F098-47F4-909B-2CC00F0249E0"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Sends an SMS message to a specified phone number using Twilio's messaging service. Twilio requires the recipient in E.164 format (+14155552671); a US/Canada number written without +1 is completed only when sending from a +1 number.",
          "elementId": "EXTENSION:::SHARED:::default:::twilio:::sendSms",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Text the patient the form link Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::twilio:::sendSms",
          "legacyElementId": "JS###v1###TwilioService###sendSms",
          "methodName": "sendSms",
          "position": {
            "x": 1196,
            "y": 490
          }
        },
        "flowElementId": "3B9D7774-CAF5-4CED-A0A4-459AE0D6AF78",
        "groupId": null,
        "id": "7915A2FF-6F37-4439-9FEE-73DE758EA9EA",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "to",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Patient",
                    "subPathSegments": [
                      {
                        "key": "phone_number",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "46BFF954-854B-4F20-B1DC-8BD0D2729BDE"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "from",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Texting number",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Texting number"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "body",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "Hi "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Patient",
                    "subPathSegments": [
                      {
                        "key": "first_name",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "46BFF954-854B-4F20-B1DC-8BD0D2729BDE"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ", this is "
                  },
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Practice name",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Practice name"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ". Please fill in your new-patient form before your first visit on "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Timing",
                    "subPathSegments": [
                      {
                        "key": "visitText",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "09012B9F-47A3-48A2-ACCC-36FF32440531"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ": "
                  },
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Intake form link",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Intake form link"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "mediaUrl",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Text the patient the form link', Error: The placeholder \"Texting number\" has no value",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "sendSms",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Text sent",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "twilio",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Text the patient the form link",
        "nextElementIds": [
          "08A3374A-9347-45A1-9C9D-4AEAB338CB79"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Write the front desk task Result"
          },
          "position": {
            "x": 470,
            "y": 839
          }
        },
        "flowElementId": "C9317737-1958-4A82-81BB-3E58AA4C86F4",
        "groupId": null,
        "id": "0273992C-A886-4325-85BD-7B9AC2F4A5D7",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": "Block: 'Write the front desk task', Error: The placeholder \"Intake form link\" has no value",
            "valid": false
          },
          "codeArguments": [
            {
              "name": "first",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Patient",
                    "subPathSegments": [
                      {
                        "key": "first_name",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "46BFF954-854B-4F20-B1DC-8BD0D2729BDE"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "last",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Patient",
                    "subPathSegments": [
                      {
                        "key": "last_name",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "46BFF954-854B-4F20-B1DC-8BD0D2729BDE"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "phone",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Patient",
                    "subPathSegments": [
                      {
                        "key": "phone_number",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "46BFF954-854B-4F20-B1DC-8BD0D2729BDE"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "visitText",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Timing",
                    "subPathSegments": [
                      {
                        "key": "visitText",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "09012B9F-47A3-48A2-ACCC-36FF32440531"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "texted",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Text sent",
                    "subPathSegments": [
                      {
                        "key": "sid",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "7915A2FF-6F37-4439-9FEE-73DE758EA9EA"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "link",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Intake form link",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Intake form link"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const who = [first, last].filter(Boolean).join(' ') || 'the patient';\nconst lines = [\n  `Call ${who} about the new-patient form before their first visit on ${visitText}.`,\n  texted ? `The form is still not done. The link was texted to ${phone} two days before the visit.` : 'The form is not done and there is no phone number on file to text the link to.',\n  `Form link: ${link}`,\n];\nreturn { content: lines.join(String.fromCharCode(10)) };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Task details",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Write the front desk task",
        "nextElementIds": [
          "7167E844-5957-4607-A19F-46438AE6195F"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "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": "Check for earlier visits Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::listAppointments",
          "legacyElementId": null,
          "methodName": "listAppointments",
          "position": {
            "x": 478,
            "y": 150
          }
        },
        "flowElementId": "AB215D16-49F0-40E6-99DB-9D05201D8596",
        "groupId": null,
        "id": "C12B2EAC-B26C-4FB9-BB47-E49F944735FB",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "patientId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Appointment",
                    "subPathSegments": [
                      {
                        "key": "appointment",
                        "optional": false
                      },
                      {
                        "key": "user",
                        "optional": false
                      },
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "700AECBE-475A-4DD8-8344-E757100FDBEC"
                  }
                ],
                "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": "Past visits",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Check for earlier visits",
        "nextElementIds": [
          "ADCF5F64-42D1-4E5E-BB95-5DC92F19B819"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Gets a patient's demographics from Healthie: name, date of birth, contact details, record ID, assigned provider and address.",
          "elementId": "EXTENSION:::SHARED:::default:::healthie:::getPatient",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Get the patient Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::getPatient",
          "legacyElementId": null,
          "methodName": "getPatient",
          "position": {
            "x": 1225,
            "y": 150
          }
        },
        "flowElementId": "883CD9A5-16D5-48D5-8BDD-13F30C7AE8DF",
        "groupId": null,
        "id": "46BFF954-854B-4F20-B1DC-8BD0D2729BDE",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "patientId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Appointment",
                    "subPathSegments": [
                      {
                        "key": "appointment",
                        "optional": false
                      },
                      {
                        "key": "user",
                        "optional": false
                      },
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "700AECBE-475A-4DD8-8344-E757100FDBEC"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "getPatient",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Patient",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Get the patient",
        "nextElementIds": [
          "09012B9F-47A3-48A2-ACCC-36FF32440531"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "wait",
          "isFirstElement": false,
          "blockDefinitionId": "wait",
          "mode": "ADVANCED",
          "position": {
            "x": 410,
            "y": 40
          }
        },
        "flowElementId": "19D4B7D6-22EC-420A-BB44-C822E20B0AE0",
        "groupId": "73D3F651-AB1F-48F4-B345-3D2ADE6A02EC",
        "id": "1A79747F-464F-43AE-86AB-283C6D7D6CAB",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "delay": {
            "expression": [
              {
                "id": "ELEMENT_RESULT",
                "label": "Time left",
                "subPathSegments": [
                  {
                    "key": "seconds",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "B80E4228-6E74-4A70-882A-D2F4D395E4BC"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": "DOUBLE"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "w1",
          "storeResult": true
        },
        "name": "Wait",
        "nextElementIds": [],
        "nextGroupIds": [],
        "type": "WAIT"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Work out the second check Result"
          },
          "position": {
            "x": 1202,
            "y": 669
          }
        },
        "flowElementId": "529AE0AD-2D51-4DC8-B8DD-4C8E2A5639FA",
        "groupId": null,
        "id": "08A3374A-9347-45A1-9C9D-4AEAB338CB79",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "target",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Timing",
                    "subPathSegments": [
                      {
                        "key": "secondCheckAt",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "09012B9F-47A3-48A2-ACCC-36FF32440531"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const left = target - Math.floor(Date.now() / 1000);\nreturn { seconds: Math.max(60, Math.min(604800, left)) };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Second check time",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Work out the second check",
        "nextElementIds": [
          "DF7A3F98-7EFC-4B87-A0B1-9F7EB19C6AD9"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Creates a to-do in Healthie for your staff, such as \"Call patient to schedule intake\", optionally linked to a patient, assigned to team members and given a due date.",
          "elementId": "EXTENSION:::SHARED:::default:::healthie:::createTask",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Ask the front desk to call Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::createTask",
          "legacyElementId": null,
          "methodName": "createTask",
          "position": {
            "x": 833,
            "y": 830
          }
        },
        "flowElementId": "12F921E6-2637-420E-AB1A-EE5883EAF0A8",
        "groupId": null,
        "id": "7167E844-5957-4607-A19F-46438AE6195F",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "content",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Task details",
                    "subPathSegments": [
                      {
                        "key": "content",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "0273992C-A886-4325-85BD-7B9AC2F4A5D7"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "patientId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Appointment",
                    "subPathSegments": [
                      {
                        "key": "appointment",
                        "optional": false
                      },
                      {
                        "key": "user",
                        "optional": false
                      },
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "700AECBE-475A-4DD8-8344-E757100FDBEC"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dueDate",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Timing",
                    "subPathSegments": [
                      {
                        "key": "dueDate",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "09012B9F-47A3-48A2-ACCC-36FF32440531"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "highPriority",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_TRUE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": true
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "createTask",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Front desk task",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Ask the front desk to call",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "wait",
          "isFirstElement": false,
          "blockDefinitionId": "wait",
          "mode": "ADVANCED",
          "position": {
            "x": 834,
            "y": 669
          }
        },
        "flowElementId": "35902804-B2E2-4E0A-9B68-758A952F9A16",
        "groupId": null,
        "id": "DF7A3F98-7EFC-4B87-A0B1-9F7EB19C6AD9",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "delay": {
            "expression": [
              {
                "id": "ELEMENT_RESULT",
                "label": "Second check time",
                "subPathSegments": [
                  {
                    "key": "seconds",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "08A3374A-9347-45A1-9C9D-4AEAB338CB79"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": "DOUBLE"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "w2",
          "storeResult": true
        },
        "name": "Wait until the day before",
        "nextElementIds": [
          "C0635269-601D-4144-BB33-A52A2F18CEB0"
        ],
        "nextGroupIds": [],
        "type": "WAIT"
      },
      {
        "clientMetadata": {
          "notes": "Gets a list of form responses with pagination and filtering options. Includes detailed submission data, answers, and metadata.",
          "elementId": "EXTENSION:::SHARED:::default:::jotform:::getFormSubmissions",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Look for the form again Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::jotform:::getFormSubmissions",
          "legacyElementId": "JS###v1###Jotform###getFormSubmissions",
          "methodName": "getFormSubmissions",
          "position": {
            "x": 475,
            "y": 660
          }
        },
        "flowElementId": "643CB526-6C90-4111-AC61-E7C4C323A97F",
        "groupId": null,
        "id": "C0635269-601D-4144-BB33-A52A2F18CEB0",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "id",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Intake form ID",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Intake form ID"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "offset",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "limit",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 1000
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "filters",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Timing",
                    "subPathSegments": [
                      {
                        "key": "filters",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "09012B9F-47A3-48A2-ACCC-36FF32440531"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "orderBy",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "created_at"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Look for the form again', Error: The placeholder \"Intake form ID\" has no value",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "getFormSubmissions",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Forms now",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "jotform",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Look for the form again",
        "nextElementIds": [
          "153326F4-263E-4E2D-AD84-D2847262726F"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Fires when an appointment is booked in Healthie, with the appointment's date, patient, provider and type, so a flow can send reminders, prepare paperwork or update other systems.",
          "elementId": "EXTENSION:::SHARED:::default:::healthie:::onNewAppointment",
          "isFirstElement": true,
          "blockDefinitionId": "api-service-trigger",
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::onNewAppointment",
          "legacyElementId": null,
          "methodName": "onNewAppointment",
          "position": {
            "x": 122,
            "y": 150
          }
        },
        "flowElementId": "5F09EBDF-276D-42AE-ABED-22C05F5F4522",
        "groupId": null,
        "id": "700AECBE-475A-4DD8-8344-E757100FDBEC",
        "metaInfo": {
          "callbackUrl": null,
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": null,
          "connectionId": null,
          "eventName": "onNewAppointment",
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Appointment",
          "scope": "SINGLE_APP",
          "serviceId": "healthie",
          "slaConditions": [],
          "staticData": {},
          "storeResult": true,
          "subtype": "REALTIME",
          "type": "CUSTOM"
        },
        "name": "New appointment booked",
        "nextElementIds": [
          "C12B2EAC-B26C-4FB9-BB47-E49F944735FB"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 485,
            "y": 499
          }
        },
        "flowElementId": "AC2C7AAC-9EBE-43DD-9233-220F05B371BB",
        "groupId": null,
        "id": "5B8B66FB-004F-44B4-9E4D-188DA2A6EA03",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "4ce4fbe1-08a1-426b-bbf5-e5411160b5b8",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Form check",
                      "subPathSegments": [
                        {
                          "key": "stillBooked",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "243C60BE-BB9F-404E-9EA6-BC7EA20D9D39"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              },
              {
                "id": "41c04b56-23bb-498c-934e-04b822f34399",
                "nestedOperation": null,
                "operation": "isFalse",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Form check",
                      "subPathSegments": [
                        {
                          "key": "formDone",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "243C60BE-BB9F-404E-9EA6-BC7EA20D9D39"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "4ce4fbe1-08a1-426b-bbf5-e5411160b5b8",
              "AND",
              "41c04b56-23bb-498c-934e-04b822f34399"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Form missing",
          "storeResult": false,
          "thenComponent": {
            "componentId": "B4404BF3-9E3A-4055-BD11-BD2E81E423DF",
            "componentType": "ELEMENT"
          }
        },
        "name": "Form still missing?",
        "nextElementIds": [
          "B4404BF3-9E3A-4055-BD11-BD2E81E423DF"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      }
    ],
    "firstElementId": "700AECBE-475A-4DD8-8344-E757100FDBEC",
    "groups": [
      {
        "clientMetadata": {
          "elementId": "repeat",
          "isFirstElement": false,
          "blockDefinitionId": "repeat",
          "viewport": {
            "x": -70,
            "y": 0,
            "zoom": 1
          },
          "position": {
            "x": 800,
            "y": 329
          }
        },
        "flowElementId": "371BAF1A-F0A6-40EA-AB71-C288E5D1B756",
        "groupId": null,
        "id": "73D3F651-AB1F-48F4-B345-3D2ADE6A02EC",
        "loopType": "REPEAT",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "fd92220b-000c-472d-af4e-33e1bfc874f1",
                "nestedOperation": null,
                "operation": "<",
                "property": {
                  "expression": [
                    {
                      "id": "TIMESTAMP",
                      "label": null,
                      "type": "KEYWORD",
                      "value": "dateTime.timestamp()"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "INT",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "ELEMENT_RESULT",
                        "label": "Timing",
                        "subPathSegments": [
                          {
                            "key": "firstCheckAt",
                            "optional": false
                          }
                        ],
                        "type": "ELEMENT_LINK",
                        "value": "09012B9F-47A3-48A2-ACCC-36FF32440531"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "fd92220b-000c-472d-af4e-33e1bfc874f1"
            ]
          },
          "enabled": true,
          "firstElementId": "B80E4228-6E74-4A70-882A-D2F4D395E4BC",
          "maxIterations": 20,
          "onFailElemId": null,
          "resultAlias": "rep",
          "storeResult": true
        },
        "name": "Wait until two days before the visit",
        "nextElementIds": [
          "83F85ADC-48B7-472A-B90B-0CD992A033DD"
        ],
        "nextGroupIds": [],
        "type": "LOOP"
      }
    ],
    "id": "D9EDCCAB-A4C3-4011-B9E5-458EEDA2BB3A",
    "metaInfo": {
      "clientValidationState": {
        "errorMessage": "Please fix problems before start. Blocks with issues have red badge in the top-right corner of a block, hover it to see what needs to be done.",
        "valid": false
      },
      "errorMessage": "Block 'Write the front desk task' has an invalid configuration. Code Argument 'link' has invalid value. Placeholder Data 'Intake form link': value is required",
      "executionStaticData": [
        {
          "description": "The ID of your new-patient intake form in Jotform: the number at the end of the form's URL.",
          "error": null,
          "name": "Intake form ID",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "The link patients open to fill in your new-patient form, sent in the text.",
          "error": "Placeholder Data 'Intake form link': value is required",
          "name": "Intake form link",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "Your practice's name as patients know it, used in the text.",
          "error": null,
          "name": "Practice name",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "Your practice's time zone as an IANA name, used for the visit time when the patient has none in Healthie.",
          "error": null,
          "name": "Practice time zone",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "Your Twilio number the text comes from, in E.164 format such as +14155550100.",
          "error": null,
          "name": "Texting number",
          "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-01T05:36:29.266Z"
}
