{
  "elementsLearnedData": [],
  "elementsTestData": [],
  "flow": {
    "id": "0C9E9307-6C98-4ECF-B6E7-03F1F1506792",
    "name": "Microsoft Teams: faxed lab result chart picked"
  },
  "flowVersion": {
    "clientMetadata": {
      "viewport": {
        "x": -21.281337047353766,
        "y": 17.715877437325904,
        "zoom": 0.56
      },
      "autoSave": false,
      "descriptions": {
        "flow": "Reads each lab result faxed to your Documo line and matches the patient in Healthie on name and birth date. One exact match is recorded straight away. A near, double or missing match goes to the intake coordinator as a Teams card to pick the chart. The result is recorded with Record Lab Result under the chart's assigned provider, who gets a review task, and any value the lab flagged is also posted in the results channel in Teams. A fax with no saved PDF, or one that cannot be read, goes to the intake channel with its Documo fax ID.",
        "initialData": "",
        "initialDataFields": {}
      }
    },
    "description": "Reads each lab result faxed to your Documo line and matches the patient in Healthie on name and birth date. A near, double or missing match goes to the intake coordinator as a Teams card to pick the chart; the result is then recorded on that chart with a review task.",
    "elements": [
      {
        "clientMetadata": {
          "notes": "Fires when Documo finishes receiving a fax. The event carries the fax record (message ID, status, result code, fax number, caller ID, CSID, pages, times) and, for a successful fax, its PDF saved to FlowRunner file storage at workspace scope in \"file\" (URL, name, content type, size). \"file\" is null for a failed fax, or when the PDF could not be fetched, with the reason in \"fileError\"; use Download Fax with the message ID then. Optionally only fires for one receiving number or one outcome.",
          "elementId": "EXTENSION:::SHARED:::default:::documo:::onNewInboundFax",
          "isFirstElement": true,
          "blockDefinitionId": "api-service-trigger",
          "newElementId": "EXTENSION:::SHARED:::default:::documo:::onNewInboundFax",
          "legacyElementId": null,
          "methodName": "onNewInboundFax",
          "position": {
            "x": 980,
            "y": 40
          }
        },
        "flowElementId": "7081E653-8169-4241-B5B7-97A3E5A4076E",
        "groupId": null,
        "id": "C063BA73-4F40-43DA-94FB-9185A60670A5",
        "metaInfo": {
          "callbackUrl": null,
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": null,
          "connectionId": null,
          "eventName": "onNewInboundFax",
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Fax",
          "scope": "SINGLE_APP",
          "serviceId": "documo",
          "slaConditions": [],
          "staticData": {
            "status": "success"
          },
          "storeResult": true,
          "subtype": "REALTIME",
          "type": "CUSTOM"
        },
        "name": "New fax received",
        "nextElementIds": [
          "EB611803-423C-497D-82C8-6B73230A4720"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 980,
            "y": 349
          }
        },
        "flowElementId": "31384FA8-87CC-48DE-9E6E-CA73D6F84C53",
        "groupId": null,
        "id": "51F443EE-F33C-438A-8E20-5EB5F0594AA7",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "1fe071c2-4af6-4552-bcd5-b15e6a15b09d",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Lab report",
                      "subPathSegments": [
                        {
                          "key": "output",
                          "optional": false
                        },
                        {
                          "key": "isLabResult",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "B6DC96F8-6A98-4912-B59C-ADC26C1B5832"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "1fe071c2-4af6-4552-bcd5-b15e6a15b09d"
            ]
          },
          "elseComponent": {
            "componentId": "09F70800-D125-45BF-BA60-125A36866B7F",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Is lab result",
          "storeResult": false,
          "thenComponent": {
            "componentId": "0CA66556-AC7E-4273-88D2-ED9901780EE1",
            "componentType": "ELEMENT"
          }
        },
        "name": "Lab result?",
        "nextElementIds": [
          "09F70800-D125-45BF-BA60-125A36866B7F",
          "0CA66556-AC7E-4273-88D2-ED9901780EE1"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Posts an Adaptive Card to a team channel as the signed-in user, with optional text above it and an optional subject line. Use it for actionable notices such as an invoice exception card with Approve and Dispute buttons. Buttons must be Action.OpenUrl: Microsoft Graph supports only that action on a card a user posts, and other actions need a bot. Uses the same ChannelMessage.Send permission as Send Channel Message.",
          "elementId": "EXTENSION:::SHARED:::default:::microsoft-teams:::sendAdaptiveCardToChannel",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Ask the intake coordinator Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::microsoft-teams:::sendAdaptiveCardToChannel",
          "legacyElementId": "JS###v1###MicrosoftTeamsService###sendAdaptiveCardToChannel",
          "methodName": "sendAdaptiveCardToChannel",
          "position": {
            "x": 551,
            "y": 680
          }
        },
        "flowElementId": "B07A2392-60C7-4FDC-83B3-7C5FE171EA25",
        "groupId": null,
        "id": "6A758743-775B-492C-A7B5-0B76ACAD9721",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "teamId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Teams team ID",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Teams team ID"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "channelId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Intake channel ID",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Intake channel ID"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "card",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Question card",
                    "subPathSegments": [
                      {
                        "key": "card",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "F9A91ED7-7E1A-47D6-9BEC-B61924DB932E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "text",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "subject",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Question card",
                    "subPathSegments": [
                      {
                        "key": "subject",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "F9A91ED7-7E1A-47D6-9BEC-B61924DB932E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Ask the intake coordinator', Error: The placeholder \"Teams team ID\" has no value",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "sendAdaptiveCardToChannel",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Coordinator post",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "microsoft-teams",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Ask the intake coordinator",
        "nextElementIds": [
          "E3DD87A4-16D2-4C62-BA79-160EDA33D685"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Sends a reply to an existing message in a team channel as the signed-in user. Supports plain text or HTML content.",
          "elementId": "EXTENSION:::SHARED:::default:::microsoft-teams:::replyToChannelMessage",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Leave it to the coordinator Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::microsoft-teams:::replyToChannelMessage",
          "legacyElementId": "JS###v1###MicrosoftTeamsService###replyToChannelMessage",
          "methodName": "replyToChannelMessage",
          "position": {
            "x": 551,
            "y": 980
          }
        },
        "flowElementId": "B276A0E6-89EA-45D4-B855-024B56E22585",
        "groupId": null,
        "id": "D85ADE52-DC26-4FD1-B08C-96F7DC45E73E",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "teamId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Teams team ID",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Teams team ID"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "channelId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Intake channel ID",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Intake channel ID"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "messageId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Coordinator post",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "6A758743-775B-492C-A7B5-0B76ACAD9721"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "contentType",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "html"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "content",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "Nothing was recorded. The result is yours to file by hand: <a href=\""
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "file",
                        "optional": false
                      },
                      {
                        "key": "url",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "C063BA73-4F40-43DA-94FB-9185A60670A5"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "\">open the fax</a>, or find Documo fax ID "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "messageId",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "C063BA73-4F40-43DA-94FB-9185A60670A5"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " in Documo."
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Leave it to the coordinator', Error: The placeholder \"Teams team ID\" has no value",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "replyToChannelMessage",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Left note",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "microsoft-teams",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Leave it to the coordinator",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Sort the matches Result"
          },
          "position": {
            "x": 571,
            "y": 519
          }
        },
        "flowElementId": "58AF0CD8-72A6-4FFF-A60C-E1E73A35A518",
        "groupId": null,
        "id": "2DCBC65A-E809-49FE-9A20-EA385FECE94D",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "exact",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Exact search",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "0CA66556-AC7E-4273-88D2-ED9901780EE1"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "byDob",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "By birth date",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "6ACC557B-07F3-4DBA-A32E-404971155265"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "byName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "By name",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "D6AFC773-94FB-4A0F-9C88-7780DAF4D7F5"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "first",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Lab report",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientFirstName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B6DC96F8-6A98-4912-B59C-ADC26C1B5832"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "last",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Lab report",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B6DC96F8-6A98-4912-B59C-ADC26C1B5832"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dob",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Lab report",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientDateOfBirth",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B6DC96F8-6A98-4912-B59C-ADC26C1B5832"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "// Matches on name plus birth date. Anything short of one exact match goes to a person.\nconst norm = (s) => String(s || '').toLowerCase().replace(/[^a-z]/g, '');\nconst iso = (d) => { const s = String(d || '').trim(); let m = /^(\\d{4})-(\\d{2})-(\\d{2})/.exec(s); if (m) return `${m[1]}-${m[2]}-${m[3]}`; m = /^(\\d{1,2})\\/(\\d{1,2})\\/(\\d{4})$/.exec(s); if (m) return `${m[3]}-${m[1].padStart(2, '0')}-${m[2].padStart(2, '0')}`; return s; };\nconst want = { first: norm(first), last: norm(last), dob: iso(dob) };\nconst found = new Map();\nconst add = (res, why) => {\n  for (const p of (res && res.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 || '', first: norm(p.first_name), last: norm(p.last_name), pdob: iso(p.dob), reasons: [] };\n    if (!c.reasons.includes(why)) c.reasons.push(why);\n    found.set(id, c);\n  }\n};\n// A search with an empty term returns too much, so only count searches the fax gave values for.\nif (want.first && want.last && want.dob) add(exact, 'same name and birth date');\nif (want.last && want.dob) add(byDob, 'same last name and birth date');\nif (want.first && want.last) add(byName, 'same first and last name');\nconst all = [...found.values()];\nconst exactOnes = want.dob ? all.filter((c) => c.first === want.first && c.last === want.last && c.pdob === want.dob) : [];\nconst status = exactOnes.length === 1 ? 'exact' : exactOnes.length > 1 ? 'double' : all.length ? 'near' : 'none';\nconst candidates = (exactOnes.length > 1 ? exactOnes : all).sort((a, b) => b.reasons.length - a.reasons.length).slice(0, 4).map(({ id, name, dob, reasons }) => ({ id, name, dob, reasons }));\nreturn { clean: status === 'exact', status, patientId: status === 'exact' ? exactOnes[0].id : '', candidates };"
              }
            ],
            "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": "Sort the matches",
        "nextElementIds": [
          "1C1D82BE-02BC-4E1A-8BBE-744EB8E31DCE"
        ],
        "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 and last name Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::searchPatients",
          "legacyElementId": null,
          "methodName": "searchPatients",
          "position": {
            "x": 129,
            "y": 510
          }
        },
        "flowElementId": "352A2FBC-79AD-4385-B9CC-5993237103DA",
        "groupId": null,
        "id": "D6AFC773-94FB-4A0F-9C88-7780DAF4D7F5",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "firstName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Lab report",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientFirstName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B6DC96F8-6A98-4912-B59C-ADC26C1B5832"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "lastName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Lab report",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B6DC96F8-6A98-4912-B59C-ADC26C1B5832"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dateOfBirth",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "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 name",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Search by first and last name",
        "nextElementIds": [
          "2DCBC65A-E809-49FE-9A20-EA385FECE94D"
        ],
        "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 chart Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::getPatient",
          "legacyElementId": null,
          "methodName": "getPatient",
          "position": {
            "x": 980,
            "y": 850
          }
        },
        "flowElementId": "F843A447-8FB4-4C67-B110-B19C6E50EDFC",
        "groupId": null,
        "id": "43ED3DDB-026C-44BA-86A1-6A61A93DF0E9",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "patientId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Chart",
                    "subPathSegments": [
                      {
                        "key": "patientId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "BBFE57AC-3DE3-473D-8935-71A127514D8C"
                  }
                ],
                "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 chart",
        "nextElementIds": [
          "078C469A-CD32-4377-885B-99D0A741B80A"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 980,
            "y": 519
          }
        },
        "flowElementId": "3157475F-4A9E-4CD7-AB7A-012C0FC737DA",
        "groupId": null,
        "id": "1C1D82BE-02BC-4E1A-8BBE-744EB8E31DCE",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "b2c71bda-5337-4f7c-b476-815d39944b26",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Match",
                      "subPathSegments": [
                        {
                          "key": "clean",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "2DCBC65A-E809-49FE-9A20-EA385FECE94D"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "b2c71bda-5337-4f7c-b476-815d39944b26"
            ]
          },
          "elseComponent": {
            "componentId": "F9A91ED7-7E1A-47D6-9BEC-B61924DB932E",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Is clean",
          "storeResult": false,
          "thenComponent": {
            "componentId": "BBFE57AC-3DE3-473D-8935-71A127514D8C",
            "componentType": "ELEMENT"
          }
        },
        "name": "One exact match?",
        "nextElementIds": [
          "F9A91ED7-7E1A-47D6-9BEC-B61924DB932E",
          "BBFE57AC-3DE3-473D-8935-71A127514D8C"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "ai-agent",
          "isFirstElement": false,
          "blockDefinitionId": "ai-agent",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Read the lab result Result"
          },
          "tools": {},
          "position": {
            "x": 1325,
            "y": 349
          }
        },
        "flowElementId": "D5CDA621-9FA2-4802-B964-7F6FEFCE635E",
        "groupId": null,
        "id": "B6DC96F8-6A98-4912-B59C-ADC26C1B5832",
        "metaInfo": {
          "aiApiKey": null,
          "aiModel": "claude-sonnet-5",
          "aiProvider": "ANTHROPIC",
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "dynamicAiApiKey": {
            "expression": [
              {
                "id": "PLACEHOLDER_DATA",
                "label": "Anthropic key",
                "subPathSegments": null,
                "type": "EXECUTION_CONTEXT_STATIC_DATA",
                "value": "Anthropic key"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "files": [
            {
              "mimeType": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "file",
                        "optional": false
                      },
                      {
                        "key": "contentType",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "C063BA73-4F40-43DA-94FB-9185A60670A5"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": "STRING"
              },
              "url": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "file",
                        "optional": false
                      },
                      {
                        "key": "url",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "C063BA73-4F40-43DA-94FB-9185A60670A5"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": "STRING"
              }
            }
          ],
          "forceParsedOutput": true,
          "langSmithSettings": {
            "enabled": false,
            "apiKey": null,
            "projectName": null,
            "label": "FlowRunner AI-Agent",
            "accountCluster": "US"
          },
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "messagesHistoryEnabled": false,
          "messagesHistoryLimit": 15,
          "onFailElemId": "D3A5462C-E25C-448D-8837-D029F589A26B",
          "resultAlias": "Lab report",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "systemPrompt": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "You read faxes that arrive at a medical practice and decide whether a fax is a lab result report from a lab. You never judge what a value means. You copy what the lab printed. From the attached fax, reply with JSON only, with these fields:\nisLabResult: true if the fax reports results for one patient's lab tests\nisOtherDocument: true only if the fax is readable and is plainly something other than a lab result, such as a lab order, a requisition, a specimen rejection notice, a referral or an advertisement; false if it is a lab result or if you cannot read enough of it to tell\npatientFirstName: the patient's first name as printed\npatientLastName: the patient's last name as printed\npatientDateOfBirth: the patient's date of birth as YYYY-MM-DD, or empty text\nlabCompany: the lab that ran the tests, such as Quest Diagnostics\npanel: the panel or test ordered, such as Comprehensive Metabolic Panel; if several, join them with commas\norderingProvider: the ordering provider's name as printed, or empty text\norderingProviderNpi: the ordering provider's NPI, or empty text\naccessionNumber: the lab's accession or specimen number, or empty text\ncollectedDate: the collection date as YYYY-MM-DD, or empty text\nresults: a list with one entry per test value, each {\"analyte\": the test name as printed, \"value\": the result as printed, \"units\": the units as printed or empty text, \"referenceRange\": the lab's printed reference range or empty text, \"abnormalFlag\": the flag the lab printed next to the value, such as H, L, HH, LL, A or Critical, exactly as printed, or empty text when the lab printed none, \"notes\": any comment the lab printed for that value, or empty text}; an empty list if you cannot read the values\nNever add a flag the lab did not print. Never guess a value that is not on the fax."
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "tools": [],
          "type": "AI_AGENT",
          "userPrompt": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "Fax received from caller ID "
              },
              {
                "id": "RESULT",
                "label": "Fax",
                "subPathSegments": [
                  {
                    "key": "faxCallerId",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "C063BA73-4F40-43DA-94FB-9185A60670A5"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": " at "
              },
              {
                "id": "RESULT",
                "label": "Fax",
                "subPathSegments": [
                  {
                    "key": "createdAt",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "C063BA73-4F40-43DA-94FB-9185A60670A5"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": ", "
              },
              {
                "id": "RESULT",
                "label": "Fax",
                "subPathSegments": [
                  {
                    "key": "pagesCount",
                    "optional": false
                  }
                ],
                "type": "TRIGGER_DATA",
                "value": "C063BA73-4F40-43DA-94FB-9185A60670A5"
              },
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": " pages. The fax is attached."
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          }
        },
        "name": "Read the lab result",
        "nextElementIds": [
          "51F443EE-F33C-438A-8E20-5EB5F0594AA7"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Write the card for the coordinator Result"
          },
          "position": {
            "x": 935,
            "y": 689
          }
        },
        "flowElementId": "80B04984-BAF1-4707-8944-515EF1929489",
        "groupId": null,
        "id": "F9A91ED7-7E1A-47D6-9BEC-B61924DB932E",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "report",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Lab report",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B6DC96F8-6A98-4912-B59C-ADC26C1B5832"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "match",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Match",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "2DCBC65A-E809-49FE-9A20-EA385FECE94D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "faxUrl",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "file",
                        "optional": false
                      },
                      {
                        "key": "url",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "C063BA73-4F40-43DA-94FB-9185A60670A5"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "faxId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "messageId",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "C063BA73-4F40-43DA-94FB-9185A60670A5"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "answerLink",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Answer link",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Answer link"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "executionId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EXECUTION_ID",
                    "label": null,
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.executionId",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "executionId",
                        "optional": false
                      }
                    ]
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const fmt = (d) => { const m = /^(\\d{4})-(\\d{2})-(\\d{2})/.exec(d || ''); return m ? `${m[2]}/${m[3]}/${m[1]}` : (d || 'not on the fax'); };\nconst chart = (id) => `https://secure.gethealthie.com/users/${id}`;\nconst link = (params) => `${answerLink}?execution=${encodeURIComponent(executionId)}&${new URLSearchParams(params).toString()}`;\nconst r = report || {};\nconst name = [r.patientFirstName, r.patientLastName].filter(Boolean).join(' ') || 'No name on the fax';\nconst why = { double: 'More than one Healthie chart has this name and birth date.', near: 'No chart has this exact name and birth date. These look close:', none: 'No Healthie chart matches this name or birth date.' }[match.status] || 'Please pick the chart.';\nconst list = match.candidates || [];\nconst body = [\n  { type: 'TextBlock', text: 'Faxed lab result: which chart is it?', weight: 'Bolder', size: 'Medium', wrap: true },\n  { type: 'FactSet', facts: [\n    { title: 'Patient on the fax', value: name },\n    { title: 'Born', value: fmt(r.patientDateOfBirth) },\n    { title: 'Lab', value: [r.panel, r.labCompany].filter(Boolean).join(', ') || 'not readable' },\n    { title: 'Ordering provider on the fax', value: r.orderingProvider || 'not printed' },\n    { title: 'Collected', value: fmt(r.collectedDate) },\n    { title: 'Documo fax ID', value: String(faxId || '') },\n  ] },\n  { type: 'TextBlock', text: why, wrap: true },\n  ...list.map((c) => ({ type: 'TextBlock', wrap: true, spacing: 'Small', text: `[${c.name}](${chart(c.id)}), born ${fmt(c.dob)}: ${c.reasons.join(', ')}` })),\n  { type: 'TextBlock', text: [`[Open the fax](${faxUrl})`, list.length ? 'Pick the chart to record the result on. Nothing is recorded until you do.' : 'Nothing is recorded. File it by hand once you find the patient.'].join('. '), wrap: true, isSubtle: true },\n];\nconst actions = list.map((c) => ({ type: 'Action.OpenUrl', title: `Record on ${c.name}'s chart`.slice(0, 60), url: link({ decision: 'chart', patient: c.id }) }));\nactions.push({ type: 'Action.OpenUrl', title: list.length ? 'None of these' : 'I will file it by hand', url: link({ decision: 'none' }) });\nreturn {\n  subject: `Faxed lab result for ${name}: pick the chart`,\n  card: { type: 'AdaptiveCard', $schema: 'http://adaptivecards.io/schemas/adaptive-card.json', version: '1.4', body, actions },\n};"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Question card",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Write the card for the coordinator",
        "nextElementIds": [
          "6A758743-775B-492C-A7B5-0B76ACAD9721"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 159,
            "y": 859
          }
        },
        "flowElementId": "6EB12212-FCA2-4CC5-B23B-5DE0F5180BDB",
        "groupId": null,
        "id": "944F65C2-9090-443A-B957-BD6192106EC0",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "e773820f-1096-4171-bf93-1e4fd962b521",
                "nestedOperation": null,
                "operation": "equal",
                "property": {
                  "expression": [
                    {
                      "id": "RESULT",
                      "label": "Pick",
                      "subPathSegments": [
                        {
                          "key": "decision",
                          "optional": false
                        }
                      ],
                      "type": "TRIGGER_DATA",
                      "value": "E3DD87A4-16D2-4C62-BA79-160EDA33D685"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "TEXT",
                        "label": null,
                        "type": "INPUT",
                        "value": "chart"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "e773820f-1096-4171-bf93-1e4fd962b521"
            ]
          },
          "elseComponent": {
            "componentId": "D85ADE52-DC26-4FD1-B08C-96F7DC45E73E",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Is picked",
          "storeResult": false,
          "thenComponent": {
            "componentId": "BBFE57AC-3DE3-473D-8935-71A127514D8C",
            "componentType": "ELEMENT"
          }
        },
        "name": "Chart picked?",
        "nextElementIds": [
          "BBFE57AC-3DE3-473D-8935-71A127514D8C",
          "D85ADE52-DC26-4FD1-B08C-96F7DC45E73E"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Sends a message to a team channel as the signed-in user. Supports plain text or HTML content and an optional subject line.",
          "elementId": "EXTENSION:::SHARED:::default:::microsoft-teams:::sendChannelMessage",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Tell the ordering provider in Teams Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::microsoft-teams:::sendChannelMessage",
          "legacyElementId": "JS###v1###MicrosoftTeamsService###sendChannelMessage",
          "methodName": "sendChannelMessage",
          "position": {
            "x": 507,
            "y": 1320
          }
        },
        "flowElementId": "E38B8944-6E2F-475E-B4EA-614EE548D6C0",
        "groupId": null,
        "id": "333165E6-416C-4A5B-B100-7C37779378F2",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "teamId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Teams team ID",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Teams team ID"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "channelId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Results review channel ID",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Results review channel ID"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "contentType",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "html"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "content",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Values",
                    "subPathSegments": [
                      {
                        "key": "teamsHtml",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "078C469A-CD32-4377-885B-99D0A741B80A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "subject",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Values",
                    "subPathSegments": [
                      {
                        "key": "subject",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "078C469A-CD32-4377-885B-99D0A741B80A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Post the lab flags in the results channel', Error: The placeholder \"Teams team ID\" has no value",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "sendChannelMessage",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Provider note",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "microsoft-teams",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Post the lab flags in the results channel",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Records a lab result that arrived as a file, such as a faxed PDF, on a patient's Healthie chart: the file is filed as a chart document, then a lab order is created for it with the panel, the lab company and the ordering provider, and with any result values you give (test, value, units, reference range, abnormal flag). Healthie has no public mutation that adds values to an existing result, so give them here. If the lab order cannot be created, the error names the document already filed.",
          "elementId": "EXTENSION:::SHARED:::default:::healthie:::recordLabResult",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Record the result on the chart Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::recordLabResult",
          "legacyElementId": null,
          "methodName": "recordLabResult",
          "position": {
            "x": 539,
            "y": 1150
          }
        },
        "flowElementId": "FC2E6A3E-1F6E-4C4D-8FBE-99ED1B876A84",
        "groupId": null,
        "id": "01916C76-4526-49BC-A06B-4AD072135EB5",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "patientId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Chart",
                    "subPathSegments": [
                      {
                        "key": "patientId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "BBFE57AC-3DE3-473D-8935-71A127514D8C"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "fileUrl",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "file",
                        "optional": false
                      },
                      {
                        "key": "url",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "C063BA73-4F40-43DA-94FB-9185A60670A5"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "fileName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "file",
                        "optional": false
                      },
                      {
                        "key": "fileName",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "C063BA73-4F40-43DA-94FB-9185A60670A5"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "lab",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Values",
                    "subPathSegments": [
                      {
                        "key": "lab",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "078C469A-CD32-4377-885B-99D0A741B80A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "labCompany",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Values",
                    "subPathSegments": [
                      {
                        "key": "labCompany",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "078C469A-CD32-4377-885B-99D0A741B80A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "ordererId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Values",
                    "subPathSegments": [
                      {
                        "key": "ordererId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "078C469A-CD32-4377-885B-99D0A741B80A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "results",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Values",
                    "subPathSegments": [
                      {
                        "key": "results",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "078C469A-CD32-4377-885B-99D0A741B80A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "folderId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "description",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Values",
                    "subPathSegments": [
                      {
                        "key": "description",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "078C469A-CD32-4377-885B-99D0A741B80A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "shareWithPatient",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "recordLabResult",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Recorded",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Record the result on the chart",
        "nextElementIds": [
          "0940A951-5C02-4178-80F1-B59784E2F2BD"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Settle on the chart Result"
          },
          "position": {
            "x": 571,
            "y": 859
          }
        },
        "flowElementId": "59453A62-5401-4F38-80D3-A3F9D7F4E716",
        "groupId": null,
        "id": "BBFE57AC-3DE3-473D-8935-71A127514D8C",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "matched",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Match",
                    "subPathSegments": [
                      {
                        "key": "patientId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "2DCBC65A-E809-49FE-9A20-EA385FECE94D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "picked",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Pick",
                    "subPathSegments": [
                      {
                        "key": "patient",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "E3DD87A4-16D2-4C62-BA79-160EDA33D685"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const id = String(picked || matched || '');\nif (!id) throw new Error('No chart was settled on.');\nreturn { patientId: id, pickedByPerson: Boolean(picked) };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Chart",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Settle on the chart",
        "nextElementIds": [
          "43ED3DDB-026C-44BA-86A1-6A61A93DF0E9"
        ],
        "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": "Task: review the result Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::createTask",
          "legacyElementId": null,
          "methodName": "createTask",
          "position": {
            "x": 151,
            "y": 1150
          }
        },
        "flowElementId": "8D54B198-72EA-43C4-9FDD-26144C4E36E3",
        "groupId": null,
        "id": "0940A951-5C02-4178-80F1-B59784E2F2BD",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "content",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Values",
                    "subPathSegments": [
                      {
                        "key": "taskContent",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "078C469A-CD32-4377-885B-99D0A741B80A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "patientId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Chart",
                    "subPathSegments": [
                      {
                        "key": "patientId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "BBFE57AC-3DE3-473D-8935-71A127514D8C"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "assigneeIds",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Values",
                    "subPathSegments": [
                      {
                        "key": "assignees",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "078C469A-CD32-4377-885B-99D0A741B80A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dueDate",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "highPriority",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Values",
                    "subPathSegments": [
                      {
                        "key": "highPriority",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "078C469A-CD32-4377-885B-99D0A741B80A"
                  }
                ],
                "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": "Review task",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Task: review the result",
        "nextElementIds": [
          "E47F152A-4CAD-4EFA-90B6-0323DEDE9C34"
        ],
        "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": 110,
            "y": 340
          }
        },
        "flowElementId": "2F271559-824A-4BD3-BACB-ABC854DB9D24",
        "groupId": null,
        "id": "6ACC557B-07F3-4DBA-A32E-404971155265",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "firstName",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "lastName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Lab report",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B6DC96F8-6A98-4912-B59C-ADC26C1B5832"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dateOfBirth",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Lab report",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientDateOfBirth",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B6DC96F8-6A98-4912-B59C-ADC26C1B5832"
                  }
                ],
                "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 birth date",
          "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": [
          "D6AFC773-94FB-4A0F-9C88-7780DAF4D7F5"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "external-callback",
          "isFirstElement": false,
          "blockDefinitionId": "external-callback",
          "position": {
            "x": 125,
            "y": 689
          }
        },
        "flowElementId": "A05DF2B3-0F20-48C0-8C76-E79629EE0024",
        "groupId": null,
        "id": "E3DD87A4-16D2-4C62-BA79-160EDA33D685",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": null,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "resultAlias": "Pick",
          "slaConditions": [],
          "storeResult": true,
          "type": "CALLBACK"
        },
        "name": "Wait for the coordinator's pick",
        "nextElementIds": [
          "944F65C2-9090-443A-B957-BD6192106EC0"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Line up the values Result"
          },
          "position": {
            "x": 980,
            "y": 1159
          }
        },
        "flowElementId": "AE9D5C99-E155-49EA-B41C-E51B5BF8412C",
        "groupId": null,
        "id": "078C469A-CD32-4377-885B-99D0A741B80A",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": "Block: 'Line up the values', Error: The placeholder \"Default provider ID\" has no value",
            "valid": false
          },
          "codeArguments": [
            {
              "name": "report",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Lab report",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B6DC96F8-6A98-4912-B59C-ADC26C1B5832"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "patient",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Patient",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "43ED3DDB-026C-44BA-86A1-6A61A93DF0E9"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "defaultProvider",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Default provider ID",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Default provider ID"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "// Copies the lab's values and flags as printed. It never judges a value.\nconst r = report || {};\nconst p = patient || {};\nconst isFlag = (f) => { const s = String(f || '').trim().toUpperCase(); return s !== '' && s !== 'N' && s !== 'NORMAL'; };\nconst results = (r.results || []).filter((v) => v && v.analyte).map((v) => {\n  const raw = String(v.value == null ? '' : v.value).trim();\n  const numeric = /^-?\\d+(\\.\\d+)?$/.test(raw);\n  const row = { analyte: v.analyte, units: v.units || '', referenceRange: v.referenceRange || '', abnormalFlag: v.abnormalFlag || '', notes: v.notes || '' };\n  if (numeric) row.value = raw; else row.qualitativeResult = raw;\n  return row;\n});\nconst flagged = results.filter((v) => isFlag(v.abnormalFlag));\nconst line = (v) => `${v.analyte}: ${v.value || v.qualitativeResult || ''}${v.units ? ' ' + v.units : ''}, lab flag ${v.abnormalFlag}${v.referenceRange ? ', lab range ' + v.referenceRange : ''}`;\n// The task and the lab order go to the chart's assigned provider, or the flow setting Default provider ID.\nconst providerId = String(p.dietitian_id || defaultProvider || '');\nconst name = p.full_name || [p.first_name, p.last_name].filter(Boolean).join(' ');\nconst lab = r.panel || 'Lab result';\nconst labCompany = r.labCompany || 'Lab on the fax';\nconst received = r.collectedDate ? `collected ${r.collectedDate}` : 'received by fax';\nconst orderedBy = r.orderingProvider ? ` Ordering provider on the fax: ${r.orderingProvider}.` : '';\nlet taskContent;\nif (!results.length) taskContent = `Review faxed lab result: ${lab} from ${labCompany}, ${received}. No values could be read from the fax. Check the PDF on the chart.${orderedBy}`;\nelse if (flagged.length) taskContent = `Review faxed lab result: ${lab} from ${labCompany}, ${received}. Values the lab flagged: ${flagged.map(line).join('; ')}.${orderedBy}`;\nelse taskContent = `Review faxed lab result: ${lab} from ${labCompany}, ${received}. The lab printed no flags on the values read.${orderedBy}`;\nconst esc = (s) => String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;');\nconst teamsHtml = `<b>Faxed lab result with values the lab flagged</b><br>Patient: <a href=\"https://secure.gethealthie.com/users/${esc(p.id || '')}\">${esc(name)}</a>, born ${esc(p.dob || '')}<br>Ordering provider on the fax: ${esc(r.orderingProvider || 'not printed')}<br>${esc(lab)} from ${esc(labCompany)}${r.accessionNumber ? ', accession ' + esc(r.accessionNumber) : ''}<br>${flagged.map((v) => esc(line(v))).join('<br>')}<br>It is recorded on the chart, with a review task for the chart's provider.`;\nreturn {\n  results,\n  anyFlagged: flagged.length > 0,\n  highPriority: flagged.length > 0 || results.length === 0,\n  ordererId: providerId,\n  assignees: providerId ? [providerId] : [],\n  lab,\n  labCompany,\n  description: `${lab} from ${labCompany}${r.accessionNumber ? ', accession ' + r.accessionNumber : ''}, ${received}`,\n  taskContent,\n  subject: `Lab flags on a faxed result: ${name}`,\n  teamsHtml,\n};"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Values",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Line up the values",
        "nextElementIds": [
          "01916C76-4526-49BC-A06B-4AD072135EB5"
        ],
        "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": 562,
            "y": 340
          }
        },
        "flowElementId": "C58C7F1D-EA28-4217-BD6B-DB16CA3A58D2",
        "groupId": null,
        "id": "0CA66556-AC7E-4273-88D2-ED9901780EE1",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "firstName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Lab report",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientFirstName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B6DC96F8-6A98-4912-B59C-ADC26C1B5832"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "lastName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Lab report",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientLastName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B6DC96F8-6A98-4912-B59C-ADC26C1B5832"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dateOfBirth",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Lab report",
                    "subPathSegments": [
                      {
                        "key": "output",
                        "optional": false
                      },
                      {
                        "key": "patientDateOfBirth",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B6DC96F8-6A98-4912-B59C-ADC26C1B5832"
                  }
                ],
                "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": [
          "6ACC557B-07F3-4DBA-A32E-404971155265"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 128,
            "y": 1329
          }
        },
        "flowElementId": "1B9CA329-3EFA-45D0-8688-5F243CCBC887",
        "groupId": null,
        "id": "E47F152A-4CAD-4EFA-90B6-0323DEDE9C34",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "8e68ea48-4927-43cd-a440-00eeee464a60",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Values",
                      "subPathSegments": [
                        {
                          "key": "anyFlagged",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "078C469A-CD32-4377-885B-99D0A741B80A"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "8e68ea48-4927-43cd-a440-00eeee464a60"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Has lab flag",
          "storeResult": false,
          "thenComponent": {
            "componentId": "333165E6-416C-4A5B-B100-7C37779378F2",
            "componentType": "ELEMENT"
          }
        },
        "name": "Any value flagged by the lab?",
        "nextElementIds": [
          "333165E6-416C-4A5B-B100-7C37779378F2"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 525,
            "y": 219
          }
        },
        "flowElementId": "890C22D6-135C-4F82-B2BA-22756610862C",
        "groupId": null,
        "id": "09F70800-D125-45BF-BA60-125A36866B7F",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "ae8d360e-64f9-4f7b-81c0-ce3b712e5c39",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Lab report",
                      "subPathSegments": [
                        {
                          "key": "output",
                          "optional": false
                        },
                        {
                          "key": "isOtherDocument",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "B6DC96F8-6A98-4912-B59C-ADC26C1B5832"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "ae8d360e-64f9-4f7b-81c0-ce3b712e5c39"
            ]
          },
          "elseComponent": {
            "componentId": "A5B16341-4E6E-4545-A372-4ADA90FA4D31",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Is other document",
          "storeResult": false,
          "thenComponent": null
        },
        "name": "Plainly another kind of document?",
        "nextElementIds": [
          "A5B16341-4E6E-4545-A372-4ADA90FA4D31"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Sends a message to a team channel as the signed-in user. Supports plain text or HTML content and an optional subject line.",
          "elementId": "EXTENSION:::SHARED:::default:::microsoft-teams:::sendChannelMessage",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Send the unreadable fax to intake Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::microsoft-teams:::sendChannelMessage",
          "legacyElementId": "JS###v1###MicrosoftTeamsService###sendChannelMessage",
          "methodName": "sendChannelMessage",
          "position": {
            "x": 114,
            "y": 210
          }
        },
        "flowElementId": "C0C88EE1-3CF4-4776-86EC-431650827306",
        "groupId": null,
        "id": "A5B16341-4E6E-4545-A372-4ADA90FA4D31",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "teamId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Teams team ID",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Teams team ID"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "channelId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Intake channel ID",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Intake channel ID"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "contentType",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "html"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "content",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "A fax on the Documo line could not be read, so nothing was recorded. Documo fax ID "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "messageId",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "C063BA73-4F40-43DA-94FB-9185A60670A5"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ", from caller ID "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "faxCallerId",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "C063BA73-4F40-43DA-94FB-9185A60670A5"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ", received "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "createdAt",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "C063BA73-4F40-43DA-94FB-9185A60670A5"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ", "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "pagesCount",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "C063BA73-4F40-43DA-94FB-9185A60670A5"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " pages. "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "fileError",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "C063BA73-4F40-43DA-94FB-9185A60670A5"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " Please open it in Documo and file it by hand."
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "subject",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "Fax that could not be read: Documo fax ID "
                  },
                  {
                    "id": "RESULT",
                    "label": "Fax",
                    "subPathSegments": [
                      {
                        "key": "messageId",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "C063BA73-4F40-43DA-94FB-9185A60670A5"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Send the unreadable fax to intake', Error: The placeholder \"Teams team ID\" has no value",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "sendChannelMessage",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Unreadable note",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "microsoft-teams",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Send the unreadable fax to intake",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "error-handler",
          "isFirstElement": false,
          "blockDefinitionId": "error-handler",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Fax could not be read Result"
          },
          "position": {
            "x": 976,
            "y": 219
          }
        },
        "flowElementId": "05EDFE70-3752-4DA0-81BD-33B8B0AF37BC",
        "groupId": null,
        "id": "D3A5462C-E25C-448D-8837-D029F589A26B",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Read error",
          "saveToVariable": null,
          "storeResult": true
        },
        "name": "Fax could not be read",
        "nextElementIds": [
          "A5B16341-4E6E-4545-A372-4ADA90FA4D31"
        ],
        "nextGroupIds": [],
        "type": "ERROR_HANDLER"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1325,
            "y": 49
          }
        },
        "flowElementId": "2B5D1B4D-F324-485C-B620-374849862925",
        "groupId": null,
        "id": "EB611803-423C-497D-82C8-6B73230A4720",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "bcbcf21f-91c6-4823-85ce-7baa5b06c433",
                "nestedOperation": null,
                "operation": "isNotEmpty",
                "property": {
                  "expression": [
                    {
                      "id": "RESULT",
                      "label": "Fax",
                      "subPathSegments": [
                        {
                          "key": "file",
                          "optional": false
                        },
                        {
                          "key": "url",
                          "optional": false
                        }
                      ],
                      "type": "TRIGGER_DATA",
                      "value": "C063BA73-4F40-43DA-94FB-9185A60670A5"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": []
              }
            ],
            "grouping": [
              "bcbcf21f-91c6-4823-85ce-7baa5b06c433"
            ]
          },
          "elseComponent": {
            "componentId": "A5B16341-4E6E-4545-A372-4ADA90FA4D31",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Has fax file",
          "storeResult": false,
          "thenComponent": {
            "componentId": "B6DC96F8-6A98-4912-B59C-ADC26C1B5832",
            "componentType": "ELEMENT"
          }
        },
        "name": "Fax PDF saved?",
        "nextElementIds": [
          "B6DC96F8-6A98-4912-B59C-ADC26C1B5832",
          "A5B16341-4E6E-4545-A372-4ADA90FA4D31"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      }
    ],
    "firstElementId": "C063BA73-4F40-43DA-94FB-9185A60670A5",
    "groups": [],
    "id": "F8A59678-B494-42C6-9B37-90BE21A789EA",
    "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 'Line up the values' has an invalid configuration. Code Argument 'defaultProvider' has invalid value. Placeholder Data 'Default provider ID': value is required",
      "executionStaticData": [
        {
          "description": "",
          "error": null,
          "name": "Anthropic key",
          "type": "API_KEY",
          "value": null
        },
        {
          "description": "The URL of the block Wait for the coordinator's pick. The card's buttons open it.",
          "error": null,
          "name": "Answer link",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "The team that holds the intake and results review channels.",
          "error": null,
          "name": "Teams team ID",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "The Teams channel the intake coordinator watches.",
          "error": null,
          "name": "Intake channel ID",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "The Teams channel your providers read results in.",
          "error": null,
          "name": "Results review channel ID",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "The Healthie provider a result is recorded under, and whose task it becomes, when the chart has no assigned provider.",
          "error": "Placeholder Data 'Default provider ID': value is required",
          "name": "Default provider ID",
          "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-02T03:33:40.393Z"
}
