{
  "elementsLearnedData": [],
  "elementsTestData": [],
  "flow": {
    "id": "BE76E071-A850-46B2-AAD1-DF9DA072BB85",
    "name": "Microsoft Teams: flagged results reviewed daily"
  },
  "flowVersion": {
    "clientMetadata": {
      "viewport": {
        "x": -45.698386199220934,
        "y": -341.7473567056205,
        "zoom": 0.78
      },
      "autoSave": false,
      "descriptions": {
        "flow": "Each morning, gathers the past day's Healthie lab results with a value the lab flagged and sends each ordering provider one Teams card with a Reviewed button. Results not marked reviewed by the end of the day become high-priority Healthie tasks for the provider.",
        "initialData": "",
        "initialDataFields": {}
      }
    },
    "description": "Each morning, gathers the past day's Healthie lab results with a value the lab flagged and sends each ordering provider one Teams card with a Reviewed button. Results not marked reviewed by the end of the day become Healthie tasks.",
    "elements": [
      {
        "clientMetadata": {
          "elementId": "data-bucket",
          "isFirstElement": false,
          "blockDefinitionId": "data-bucket",
          "fieldKeys": {
            "orders": "830a5ebf-e4d1-4fe4-ad10-df98eb40a174",
            "cursor": "0706e3b2-c8d3-4ae8-8b26-f1c284367725",
            "more": "a35bb579-1c63-4fa0-a9f2-2a81c7de13f5",
            "pagesRead": "a2b9552e-7217-4834-add5-63712e7ae822",
            "oldestRead": "bc97b19c-f0fd-48cc-b38a-6f9031d107d7"
          },
          "position": {
            "x": 832,
            "y": 49
          }
        },
        "flowElementId": "D9D0E6C4-3486-4D93-A43B-2ED6364D49E7",
        "groupId": "463EC34A-FF3D-4B0B-B246-0428170C1719",
        "id": "2AE88820-3D27-4CD4-B82F-1F18EF40D18B",
        "metaInfo": {
          "bucketName": "Default",
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "fields": [
            {
              "name": "orders",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Kept",
                    "subPathSegments": [
                      {
                        "key": "orders",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "D61C0547-1002-488D-8B5A-DFD3FF8CE4A3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "cursor",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Kept",
                    "subPathSegments": [
                      {
                        "key": "cursor",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "D61C0547-1002-488D-8B5A-DFD3FF8CE4A3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "more",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Kept",
                    "subPathSegments": [
                      {
                        "key": "more",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "D61C0547-1002-488D-8B5A-DFD3FF8CE4A3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pagesRead",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Kept",
                    "subPathSegments": [
                      {
                        "key": "pagesRead",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "D61C0547-1002-488D-8B5A-DFD3FF8CE4A3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "oldestRead",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Kept",
                    "subPathSegments": [
                      {
                        "key": "oldestRead",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "D61C0547-1002-488D-8B5A-DFD3FF8CE4A3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "savePage",
          "storeResult": true
        },
        "name": "Save the page",
        "nextElementIds": [],
        "nextGroupIds": [],
        "type": "DATA_BUCKET"
      },
      {
        "clientMetadata": {
          "elementId": "data-bucket",
          "isFirstElement": true,
          "blockDefinitionId": "data-bucket",
          "fieldKeys": {
            "cursor": "a34c47e4-a8d7-4274-8dee-4643f2a6ed77",
            "more": "fd4d9bfc-ad27-42c7-9cc5-10b1b64668a9",
            "orders": "3696adb6-78ea-4100-a80c-148706e62f73",
            "pagesRead": "ccc35295-7260-4c8c-976b-54c374b53ada",
            "oldestRead": "a90ced0c-56fb-4836-8f44-7e6f3815d33f"
          },
          "position": {
            "x": 452,
            "y": 499
          }
        },
        "flowElementId": "D59AA6F1-F65F-45AC-91CB-A000811C7E39",
        "groupId": null,
        "id": "3986DFE0-F7A3-4A25-A94E-C777A941EED2",
        "metaInfo": {
          "bucketName": "Default",
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "fields": [
            {
              "name": "cursor",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EMPTY_STRING",
                    "label": null,
                    "type": "KEYWORD",
                    "value": ""
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "more",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "yes"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "orders",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EMPTY_LIST",
                    "label": null,
                    "type": "KEYWORD",
                    "value": "arrays.create()"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pagesRead",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 0
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "oldestRead",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EMPTY_STRING",
                    "label": null,
                    "type": "KEYWORD",
                    "value": ""
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "start",
          "storeResult": true
        },
        "name": "Start the list",
        "nextElementIds": [],
        "nextGroupIds": [
          "463EC34A-FF3D-4B0B-B246-0428170C1719"
        ],
        "type": "DATA_BUCKET"
      },
      {
        "clientMetadata": {
          "elementId": "wait",
          "isFirstElement": false,
          "blockDefinitionId": "wait",
          "mode": "ADVANCED",
          "position": {
            "x": 772,
            "y": 839
          }
        },
        "flowElementId": "07314F90-1456-446F-A6EF-72F9710D916A",
        "groupId": null,
        "id": "38928FF2-BE05-4071-811D-0FDA0AB0F975",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "delay": {
            "expression": [
              {
                "id": "ELEMENT_RESULT",
                "label": "Day end",
                "subPathSegments": [
                  {
                    "key": "seconds",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "A2D3F5C4-2B2E-4F83-B0C1-F7A1C1857329"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": "DOUBLE"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "waitEnd",
          "storeResult": true
        },
        "name": "Wait until the end of the day",
        "nextElementIds": [
          "2E8423F6-892F-41AE-B945-528654ADDB98"
        ],
        "nextGroupIds": [],
        "type": "WAIT"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Time left in the review day Result"
          },
          "position": {
            "x": 432,
            "y": 839
          }
        },
        "flowElementId": "C9E78065-7A2C-4CD9-9557-586F461E8D84",
        "groupId": null,
        "id": "A2D3F5C4-2B2E-4F83-B0C1-F7A1C1857329",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "endOfDay",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "End of review day",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "End of review day"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "timeZone",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Practice time zone",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Practice time zone"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "// Seconds from now until the end of the review day in the practice's time zone.\nconst [h, m] = String(endOfDay || '17:00').split(':').map((n) => Number(n) || 0);\nconst parts = Object.fromEntries(new Intl.DateTimeFormat('en-US', { timeZone: timeZone || 'America/New_York', hourCycle: 'h23', year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit' }).formatToParts(new Date()).map((p) => [p.type, p.value]));\nconst nowSec = (Number(parts.hour) % 24) * 3600 + Number(parts.minute) * 60 + Number(parts.second);\nconst endSec = h * 3600 + m * 60;\nreturn { seconds: Math.max(60, endSec - nowSec), today: `${parts.year}-${parts.month}-${parts.day}` };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Day end",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Time left in the review day",
        "nextElementIds": [
          "38928FF2-BE05-4071-811D-0FDA0AB0F975"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Lists lab orders in Healthie, most recently updated first, each with its results and their values (test, value, units, reference range, abnormal flag), so a flow can check a patient's labs. Narrow them by patient, keywords or status.",
          "elementId": "EXTENSION:::SHARED:::default:::healthie:::listLabOrders",
          "isFirstElement": true,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "List recently updated lab orders Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::listLabOrders",
          "legacyElementId": null,
          "methodName": "listLabOrders",
          "position": {
            "x": 110,
            "y": 40
          }
        },
        "flowElementId": "3D2A4D51-3F81-45A0-BE8E-3B78D64D82A7",
        "groupId": "463EC34A-FF3D-4B0B-B246-0428170C1719",
        "id": "FBFD8773-CA8D-4451-A3D5-96F1ADE732BB",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "patientId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "keywords",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "status",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sortBy",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "UPDATED_AT_DESC"
                  }
                ],
                "mode": "BASIC",
                "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": [
                  {
                    "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                    "label": "Default - cursor",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.dataBuckets.Default.cursor",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "dataBuckets",
                        "optional": false
                      },
                      {
                        "key": "Default",
                        "optional": false
                      },
                      {
                        "key": "cursor",
                        "optional": false
                      }
                    ]
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "listLabOrders",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Page",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "List recently updated lab orders",
        "nextElementIds": [
          "D61C0547-1002-488D-8B5A-DFD3FF8CE4A3"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Group flagged results by provider Result"
          },
          "position": {
            "x": 1501,
            "y": 669
          }
        },
        "flowElementId": "19E5444A-DB5B-4DFF-96E4-96F9D47A4897",
        "groupId": null,
        "id": "2606DC0B-8396-48FF-939A-9BB62BF8CDD2",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "orders",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                    "label": "Default - orders",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.dataBuckets.Default.orders",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "dataBuckets",
                        "optional": false
                      },
                      {
                        "key": "Default",
                        "optional": false
                      },
                      {
                        "key": "orders",
                        "optional": false
                      }
                    ]
                  }
                ],
                "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
              }
            },
            {
              "name": "endOfDay",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "End of review day",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "End of review day"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "criticalCodes",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Critical flag codes",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Critical flag codes"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "// Reads the lab's own flags on each result from the past day and groups them by ordering provider.\n// A value whose flag is in Critical flag codes, or whose interpretation says critical, is marked critical.\nconst codes = String(criticalCodes || 'HH, LL, AA, C, CR, CRIT, PANIC').split(/[,;\\s]+/).map((s) => s.trim().toUpperCase()).filter(Boolean);\nconst since = Date.now() - 24 * 3600 * 1000;\nconst chart = (id) => `https://secure.gethealthie.com/users/${id}`;\nconst byProvider = new Map();\nconst seen = new Set();\nfor (const o of orders || []) {\n  for (const r of o.lab_results || []) {\n    if (!r || seen.has(String(r.id))) continue;\n    const created = Date.parse(r.created_at || '');\n    if (created && created < since) continue;\n    const flagged = [];\n    let critical = 0;\n    for (const req of r.lab_observation_requests || []) {\n      for (const v of req.lab_observation_results || []) {\n        const flag = String(v.abnormal_flag || '').trim();\n        const interp = String(v.interpretation || '').toUpperCase();\n        const isCritical = (flag !== '' && codes.includes(flag.toUpperCase())) || interp.includes('CRITICAL');\n        const isFlagged = isCritical || (flag && !['N', 'NORMAL'].includes(flag.toUpperCase())) || v.is_abnormal === true || interp === 'ABNORMAL';\n        if (!isFlagged) continue;\n        if (isCritical) critical += 1;\n        const value = v.quantitative_result != null && v.quantitative_result !== '' ? v.quantitative_result : (v.qualitative_result || '');\n        flagged.push(`${isCritical ? 'CRITICAL ' : ''}${req.lab_analyte || 'Test'}: ${value}${v.units ? ' ' + v.units : ''}, lab flag ${flag || interp.toLowerCase()}${v.reference_range ? ', lab range ' + v.reference_range : ''}`);\n      }\n    }\n    if (!flagged.length) continue;\n    seen.add(String(r.id));\n    const prov = o.orderer || {};\n    const key = String(prov.id || 'none');\n    if (!byProvider.has(key)) byProvider.set(key, { id: key, name: prov.full_name || 'No ordering provider on the order', items: [] });\n    byProvider.get(key).items.push({ patientId: String((o.patient && o.patient.id) || ''), patientName: (o.patient && o.patient.full_name) || 'Patient', lab: o.lab || 'Lab result', company: o.lab_company || '', received: r.created_at || '', flagged, critical });\n  }\n}\nconst providers = [...byProvider.values()].map((p) => {\n  p.items.sort((a, b) => b.critical - a.critical);\n  const link = `${answerLink}?execution=${encodeURIComponent(executionId)}&${new URLSearchParams({ reviewed: 'yes', provider: p.id }).toString()}`;\n  const body = [{ type: 'TextBlock', text: `${p.name}: ${p.items.length} ${p.items.length === 1 ? 'result' : 'results'} from the past day with values the lab flagged`, weight: 'Bolder', size: 'Medium', wrap: true }];\n  for (const it of p.items.slice(0, 40)) {\n    body.push({ type: 'TextBlock', text: `[${it.patientName}](${chart(it.patientId)}), ${it.lab}${it.company ? ' from ' + it.company : ''}`, weight: 'Bolder', wrap: true, spacing: 'Medium' });\n    for (const line of it.flagged) body.push({ type: 'TextBlock', text: line, wrap: true, spacing: 'None', color: line.startsWith('CRITICAL') ? 'Attention' : 'Default' });\n  }\n  if (p.items.length > 40) body.push({ type: 'TextBlock', text: `And ${p.items.length - 40} more in Healthie.`, wrap: true });\n  body.push({ type: 'TextBlock', text: `Press Reviewed once you have gone through them. Anything not marked reviewed by ${endOfDay} becomes a Healthie task for you.`, wrap: true, isSubtle: true });\n  return {\n    id: p.id,\n    name: p.name,\n    subject: `Lab flags to review: ${p.name}`,\n    card: { type: 'AdaptiveCard', $schema: 'http://adaptivecards.io/schemas/adaptive-card.json', version: '1.4', body, actions: [{ type: 'Action.OpenUrl', title: 'Reviewed', url: link }] },\n    tasks: p.items.map((it) => ({\n      assignees: p.id !== 'none' ? [p.id] : [],\n      patientId: it.patientId,\n      content: `Review lab result: ${it.lab}${it.company ? ' from ' + it.company : ''}, received ${String(it.received).slice(0, 10)}. Values the lab flagged: ${it.flagged.join('; ')}. Not marked reviewed in Teams.`,\n    })),\n  };\n});\nreturn { providers, count: providers.length };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Review",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Group flagged results by provider",
        "nextElementIds": [
          "A44A6C99-9636-4E04-8977-8568327399DF"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "data-bucket",
          "isFirstElement": false,
          "blockDefinitionId": "data-bucket",
          "fieldKeys": {
            "reviewed": "23027c9f-14f6-4570-9223-cab6c23ee852",
            "reviewedCount": "4affd4d8-b99b-4f0d-adfd-b2fd06e6f90a"
          },
          "position": {
            "x": 850,
            "y": 220
          }
        },
        "flowElementId": "A85CB9CF-4209-4E2B-84B2-A55694882FEA",
        "groupId": "3CF7EE4A-DDC6-40A3-A9A0-9601FFA8324F",
        "id": "13ACB42F-049E-467B-9492-717EF8A24A12",
        "metaInfo": {
          "bucketName": "Default",
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "fields": [
            {
              "name": "reviewed",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Reviewed",
                    "subPathSegments": [
                      {
                        "key": "list",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "AEF4DEB1-4B91-420F-9FA9-0E4A3C72C649"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "reviewedCount",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Reviewed",
                    "subPathSegments": [
                      {
                        "key": "count",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "AEF4DEB1-4B91-420F-9FA9-0E4A3C72C649"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "saveRev",
          "storeResult": true
        },
        "name": "Save the reviewed list",
        "nextElementIds": [],
        "nextGroupIds": [],
        "type": "DATA_BUCKET"
      },
      {
        "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": true,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Task: review the flagged result Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::healthie:::createTask",
          "legacyElementId": null,
          "methodName": "createTask",
          "position": {
            "x": 110,
            "y": 400
          }
        },
        "flowElementId": "E0A9E889-A72F-4F75-ABAA-587C2FF30D46",
        "groupId": "A44D20D7-9E4E-488E-B4DF-E0BE9F632240",
        "id": "62C862E5-737E-4D0B-BBD6-2DE3EB885FFD",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "content",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": [
                      {
                        "key": "content",
                        "optional": false
                      }
                    ],
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "A44D20D7-9E4E-488E-B4DF-E0BE9F632240"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "patientId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": [
                      {
                        "key": "patientId",
                        "optional": false
                      }
                    ],
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "A44D20D7-9E4E-488E-B4DF-E0BE9F632240"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "assigneeIds",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": [
                      {
                        "key": "assignees",
                        "optional": false
                      }
                    ],
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "A44D20D7-9E4E-488E-B4DF-E0BE9F632240"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "dueDate",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Day end",
                    "subPathSegments": [
                      {
                        "key": "today",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "A2D3F5C4-2B2E-4F83-B0C1-F7A1C1857329"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "highPriority",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_TRUE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": true
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "createTask",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Review task",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "healthie",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Task: review the flagged result",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "external-callback",
          "isFirstElement": true,
          "blockDefinitionId": "external-callback",
          "position": {
            "x": 110,
            "y": 220
          }
        },
        "flowElementId": "8EE7B9BB-00F6-471D-8A8E-404F622F261D",
        "groupId": "3CF7EE4A-DDC6-40A3-A9A0-9601FFA8324F",
        "id": "E40071B2-7029-4FE8-ADEC-D961BD57E156",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": null,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "resultAlias": "Click",
          "slaConditions": [],
          "storeResult": true,
          "type": "CALLBACK"
        },
        "name": "Wait for a Reviewed click",
        "nextElementIds": [
          "AEF4DEB1-4B91-420F-9FA9-0E4A3C72C649"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Add the provider to the reviewed list Result"
          },
          "position": {
            "x": 442,
            "y": 220
          }
        },
        "flowElementId": "EDC75554-E35B-422D-9364-4585E93F6138",
        "groupId": "3CF7EE4A-DDC6-40A3-A9A0-9601FFA8324F",
        "id": "AEF4DEB1-4B91-420F-9FA9-0E4A3C72C649",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "reviewed",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                    "label": "Default - reviewed",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.dataBuckets.Default.reviewed",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "dataBuckets",
                        "optional": false
                      },
                      {
                        "key": "Default",
                        "optional": false
                      },
                      {
                        "key": "reviewed",
                        "optional": false
                      }
                    ]
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "click",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Click",
                    "subPathSegments": null,
                    "type": "TRIGGER_DATA",
                    "value": "E40071B2-7029-4FE8-ADEC-D961BD57E156"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const list = Array.isArray(reviewed) ? reviewed.map(String) : [];\nconst id = String((click && click.provider) || '');\nif (id && !list.includes(id)) list.push(id);\nreturn { list, count: list.length };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Reviewed",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Add the provider to the reviewed list",
        "nextElementIds": [
          "13ACB42F-049E-467B-9492-717EF8A24A12"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Find results not reviewed Result"
          },
          "position": {
            "x": 1129,
            "y": 839
          }
        },
        "flowElementId": "5FDD54E1-DC46-435B-B818-CA44792B4AF0",
        "groupId": null,
        "id": "2E8423F6-892F-41AE-B945-528654ADDB98",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "reviewed",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                    "label": "Default - reviewed",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.dataBuckets.Default.reviewed",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "dataBuckets",
                        "optional": false
                      },
                      {
                        "key": "Default",
                        "optional": false
                      },
                      {
                        "key": "reviewed",
                        "optional": false
                      }
                    ]
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "providers",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Review",
                    "subPathSegments": [
                      {
                        "key": "providers",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "2606DC0B-8396-48FF-939A-9BB62BF8CDD2"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const done = new Set((Array.isArray(reviewed) ? reviewed : []).map(String));\nconst items = [];\nfor (const p of providers || []) if (!done.has(String(p.id))) items.push(...p.tasks);\nreturn { items, count: items.length };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Not reviewed",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Find results not reviewed",
        "nextElementIds": [],
        "nextGroupIds": [
          "A44D20D7-9E4E-488E-B4DF-E0BE9F632240"
        ],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "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": true,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Send the provider's card Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::microsoft-teams:::sendAdaptiveCardToChannel",
          "legacyElementId": "JS###v1###MicrosoftTeamsService###sendAdaptiveCardToChannel",
          "methodName": "sendAdaptiveCardToChannel",
          "position": {
            "x": 110,
            "y": 760
          }
        },
        "flowElementId": "C7376B28-93D2-47FB-BEC8-04F6514373EC",
        "groupId": "661C831B-99A4-46E7-8877-1A25F1FBA1C1",
        "id": "84F93E09-C7A4-46B1-B2D9-7AE4101B5728",
        "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": "card",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": [
                      {
                        "key": "card",
                        "optional": false
                      }
                    ],
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "661C831B-99A4-46E7-8877-1A25F1FBA1C1"
                  }
                ],
                "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": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": [
                      {
                        "key": "subject",
                        "optional": false
                      }
                    ],
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "661C831B-99A4-46E7-8877-1A25F1FBA1C1"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Send the provider's card', 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": "Provider post",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "microsoft-teams",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Send the provider's card",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Keep the past day's orders Result"
          },
          "position": {
            "x": 488,
            "y": 49
          }
        },
        "flowElementId": "50C5D5BE-9710-4C3A-896F-47EE248C5BE7",
        "groupId": "463EC34A-FF3D-4B0B-B246-0428170C1719",
        "id": "D61C0547-1002-488D-8B5A-DFD3FF8CE4A3",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "page",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Page",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "FBFD8773-CA8D-4451-A3D5-96F1ADE732BB"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "collected",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                    "label": "Default - orders",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.dataBuckets.Default.orders",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "dataBuckets",
                        "optional": false
                      },
                      {
                        "key": "Default",
                        "optional": false
                      },
                      {
                        "key": "orders",
                        "optional": false
                      }
                    ]
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pagesRead",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                    "label": "Default - pagesRead",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.dataBuckets.Default.pagesRead",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "dataBuckets",
                        "optional": false
                      },
                      {
                        "key": "Default",
                        "optional": false
                      },
                      {
                        "key": "pagesRead",
                        "optional": false
                      }
                    ]
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "oldestRead",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                    "label": "Default - oldestRead",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.dataBuckets.Default.oldestRead",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "dataBuckets",
                        "optional": false
                      },
                      {
                        "key": "Default",
                        "optional": false
                      },
                      {
                        "key": "oldestRead",
                        "optional": false
                      }
                    ]
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "// Keeps the orders updated in the past 24 hours and pages on while there are more.\nconst since = Date.now() - 24 * 3600 * 1000;\nconst list = Array.isArray(collected) ? collected.slice() : [];\nconst orders = (page && page.lab_orders) || [];\nlet older = false;\nlet oldest = oldestRead || '';\nfor (const o of orders) {\n  const stamp = o.updated_at || o.created_at || '';\n  const updated = Date.parse(stamp);\n  if (updated && updated < since) { older = true; continue; }\n  if (stamp) oldest = stamp;\n  list.push(o);\n}\nconst next = Boolean(page && page.has_next_page && page.next_cursor && !older);\nreturn { orders: list, cursor: next ? page.next_cursor : '', more: next ? 'yes' : 'no', pagesRead: (Number(pagesRead) || 0) + 1, oldestRead: oldest };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Kept",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Keep the past day's orders",
        "nextElementIds": [
          "2AE88820-3D27-4CD4-B82F-1F18EF40D18B"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1145,
            "y": 669
          }
        },
        "flowElementId": "97F73480-07B9-408A-8138-1E01229083C2",
        "groupId": null,
        "id": "A44A6C99-9636-4E04-8977-8568327399DF",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "3a2d30ca-e2ec-4e2f-829e-f5df09e94138",
                "nestedOperation": null,
                "operation": ">",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Review",
                      "subPathSegments": [
                        {
                          "key": "count",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "2606DC0B-8396-48FF-939A-9BB62BF8CDD2"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "INT",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "NUMBER",
                        "label": null,
                        "type": "INPUT",
                        "value": 0
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "3a2d30ca-e2ec-4e2f-829e-f5df09e94138"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Has flagged",
          "storeResult": false,
          "thenComponent": {
            "componentId": "661C831B-99A4-46E7-8877-1A25F1FBA1C1",
            "componentType": "GROUP"
          }
        },
        "name": "Any flagged results?",
        "nextElementIds": [],
        "nextGroupIds": [
          "661C831B-99A4-46E7-8877-1A25F1FBA1C1"
        ],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "data-bucket",
          "isFirstElement": false,
          "blockDefinitionId": "data-bucket",
          "fieldKeys": {
            "reviewed": "b29fc2f5-1372-44b1-b427-c6d3a95b9989",
            "reviewedCount": "39d996a1-e506-4512-b91f-637e1e696b1e"
          },
          "position": {
            "x": 447,
            "y": 669
          }
        },
        "flowElementId": "1CB4C52C-1235-4597-8125-98949AA68680",
        "groupId": null,
        "id": "0EFC781C-5EAC-4C13-A7BF-E616F9DF2AF1",
        "metaInfo": {
          "bucketName": "Default",
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "fields": [
            {
              "name": "reviewed",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EMPTY_LIST",
                    "label": null,
                    "type": "KEYWORD",
                    "value": "arrays.create()"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "reviewedCount",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 0
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "startRev",
          "storeResult": true
        },
        "name": "Start the reviewed list",
        "nextElementIds": [
          "A2D3F5C4-2B2E-4F83-B0C1-F7A1C1857329"
        ],
        "nextGroupIds": [
          "3CF7EE4A-DDC6-40A3-A9A0-9601FFA8324F"
        ],
        "type": "DATA_BUCKET"
      },
      {
        "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 results lead the review is incomplete Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::microsoft-teams:::sendChannelMessage",
          "legacyElementId": "JS###v1###MicrosoftTeamsService###sendChannelMessage",
          "methodName": "sendChannelMessage",
          "position": {
            "x": 1465,
            "y": 490
          }
        },
        "flowElementId": "EC6C86BA-2451-46C1-9211-EF9FF5DB8C63",
        "groupId": null,
        "id": "D0E950F8-82EF-42BE-B7C7-3A5075400BA4",
        "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": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "This morning's review stopped at its page limit after "
                  },
                  {
                    "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                    "label": "Default - pagesRead",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.dataBuckets.Default.pagesRead",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "dataBuckets",
                        "optional": false
                      },
                      {
                        "key": "Default",
                        "optional": false
                      },
                      {
                        "key": "pagesRead",
                        "optional": false
                      }
                    ]
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " pages of Healthie lab orders, back to orders updated at "
                  },
                  {
                    "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                    "label": "Default - oldestRead",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.dataBuckets.Default.oldestRead",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "dataBuckets",
                        "optional": false
                      },
                      {
                        "key": "Default",
                        "optional": false
                      },
                      {
                        "key": "oldestRead",
                        "optional": false
                      }
                    ]
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ". Results updated before that in the past 24 hours got no card and will get no task. Please check them in Healthie. The cards for the orders that were read follow."
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "subject",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "Results lead: this morning's lab flag review is incomplete"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Tell the results lead the review is incomplete', 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": "Incomplete note",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "microsoft-teams",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Tell the results lead the review is incomplete",
        "nextElementIds": [
          "2606DC0B-8396-48FF-939A-9BB62BF8CDD2"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1125,
            "y": 499
          }
        },
        "flowElementId": "1377ED69-E8BC-425B-8794-FDCD4BCB2F11",
        "groupId": null,
        "id": "D4A01D3B-D109-4D4A-8FE2-F2B961632934",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "515f78d1-dd13-4caa-936d-39bc72c8e284",
                "nestedOperation": null,
                "operation": "equal",
                "property": {
                  "expression": [
                    {
                      "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                      "label": "Default - more",
                      "subPathSegments": null,
                      "type": "EXECUTION_CONTEXT_PATH",
                      "value": "executionContext.dataBuckets.Default.more",
                      "valueSegments": [
                        {
                          "key": "executionContext",
                          "optional": false
                        },
                        {
                          "key": "dataBuckets",
                          "optional": false
                        },
                        {
                          "key": "Default",
                          "optional": false
                        },
                        {
                          "key": "more",
                          "optional": false
                        }
                      ]
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "TEXT",
                        "label": null,
                        "type": "INPUT",
                        "value": "yes"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "515f78d1-dd13-4caa-936d-39bc72c8e284"
            ]
          },
          "elseComponent": {
            "componentId": "2606DC0B-8396-48FF-939A-9BB62BF8CDD2",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Hit page limit",
          "storeResult": false,
          "thenComponent": {
            "componentId": "D0E950F8-82EF-42BE-B7C7-3A5075400BA4",
            "componentType": "ELEMENT"
          }
        },
        "name": "Stopped at the page limit?",
        "nextElementIds": [
          "D0E950F8-82EF-42BE-B7C7-3A5075400BA4",
          "2606DC0B-8396-48FF-939A-9BB62BF8CDD2"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      }
    ],
    "firstElementId": "3986DFE0-F7A3-4A25-A94E-C777A941EED2",
    "groups": [
      {
        "clientMetadata": {
          "elementId": "repeat",
          "isFirstElement": false,
          "blockDefinitionId": "repeat",
          "viewport": {
            "x": -70,
            "y": 0,
            "zoom": 1
          },
          "position": {
            "x": 786,
            "y": 499
          }
        },
        "flowElementId": "F9FF95E8-CD98-41ED-B790-C1CEAA783009",
        "groupId": null,
        "id": "463EC34A-FF3D-4B0B-B246-0428170C1719",
        "loopType": "REPEAT",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "a7570c68-b63f-4df5-bd19-2e4b255049d6",
                "nestedOperation": null,
                "operation": "equal",
                "property": {
                  "expression": [
                    {
                      "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                      "label": "Default - more",
                      "subPathSegments": null,
                      "type": "EXECUTION_CONTEXT_PATH",
                      "value": "executionContext.dataBuckets.Default.more",
                      "valueSegments": [
                        {
                          "key": "executionContext",
                          "optional": false
                        },
                        {
                          "key": "dataBuckets",
                          "optional": false
                        },
                        {
                          "key": "Default",
                          "optional": false
                        },
                        {
                          "key": "more",
                          "optional": false
                        }
                      ]
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "TEXT",
                        "label": null,
                        "type": "INPUT",
                        "value": "yes"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "a7570c68-b63f-4df5-bd19-2e4b255049d6"
            ]
          },
          "enabled": true,
          "firstElementId": "FBFD8773-CA8D-4451-A3D5-96F1ADE732BB",
          "maxIterations": 40,
          "onFailElemId": null,
          "resultAlias": "pager",
          "storeResult": true
        },
        "name": "Page through lab orders",
        "nextElementIds": [
          "D4A01D3B-D109-4D4A-8FE2-F2B961632934"
        ],
        "nextGroupIds": [],
        "type": "LOOP"
      },
      {
        "clientMetadata": {
          "elementId": "list-iterator",
          "isFirstElement": false,
          "blockDefinitionId": "list-iterator",
          "viewport": {
            "x": -70,
            "y": -720,
            "zoom": 1
          },
          "position": {
            "x": 799,
            "y": 669
          }
        },
        "flowElementId": "14E07BD6-5884-4E91-8937-50466CCACC0F",
        "groupId": null,
        "id": "661C831B-99A4-46E7-8877-1A25F1FBA1C1",
        "loopType": "LIST_ITERATOR",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": "Block: 'For each provider', Error: Children have error",
            "valid": false
          },
          "enabled": true,
          "firstElementId": "84F93E09-C7A4-46B1-B2D9-7AE4101B5728",
          "list": {
            "expression": [
              {
                "id": "ELEMENT_RESULT",
                "label": "Review",
                "subPathSegments": [
                  {
                    "key": "providers",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "2606DC0B-8396-48FF-939A-9BB62BF8CDD2"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "onFailElemId": null,
          "resultAlias": "each",
          "storeResult": true
        },
        "name": "For each provider",
        "nextElementIds": [
          "0EFC781C-5EAC-4C13-A7BF-E616F9DF2AF1"
        ],
        "nextGroupIds": [],
        "type": "LOOP"
      },
      {
        "clientMetadata": {
          "elementId": "list-iterator",
          "isFirstElement": false,
          "blockDefinitionId": "list-iterator",
          "viewport": {
            "x": -70,
            "y": -360,
            "zoom": 1
          },
          "position": {
            "x": 1519,
            "y": 839
          }
        },
        "flowElementId": "BA28F93D-F1B7-4AFF-B715-550BED6B34D5",
        "groupId": null,
        "id": "A44D20D7-9E4E-488E-B4DF-E0BE9F632240",
        "loopType": "LIST_ITERATOR",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "enabled": true,
          "firstElementId": "62C862E5-737E-4D0B-BBD6-2DE3EB885FFD",
          "list": {
            "expression": [
              {
                "id": "ELEMENT_RESULT",
                "label": "Not reviewed",
                "subPathSegments": [
                  {
                    "key": "items",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "2E8423F6-892F-41AE-B945-528654ADDB98"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "onFailElemId": null,
          "resultAlias": "eachOpen",
          "storeResult": true
        },
        "name": "For each result not reviewed",
        "nextElementIds": [],
        "nextGroupIds": [],
        "type": "LOOP"
      },
      {
        "clientMetadata": {
          "elementId": "repeat",
          "isFirstElement": false,
          "blockDefinitionId": "repeat",
          "viewport": {
            "x": -70,
            "y": -180,
            "zoom": 1
          },
          "position": {
            "x": 110,
            "y": 669
          }
        },
        "flowElementId": "4794376E-65F8-492E-9867-DB6BD26C7AE3",
        "groupId": null,
        "id": "3CF7EE4A-DDC6-40A3-A9A0-9601FFA8324F",
        "loopType": "REPEAT",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "2fd385f0-2719-489e-85b9-94ea4d7bccbb",
                "nestedOperation": null,
                "operation": "<",
                "property": {
                  "expression": [
                    {
                      "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                      "label": "Default - reviewedCount",
                      "subPathSegments": null,
                      "type": "EXECUTION_CONTEXT_PATH",
                      "value": "executionContext.dataBuckets.Default.reviewedCount",
                      "valueSegments": [
                        {
                          "key": "executionContext",
                          "optional": false
                        },
                        {
                          "key": "dataBuckets",
                          "optional": false
                        },
                        {
                          "key": "Default",
                          "optional": false
                        },
                        {
                          "key": "reviewedCount",
                          "optional": false
                        }
                      ]
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "INT",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "ELEMENT_RESULT",
                        "label": "Review",
                        "subPathSegments": [
                          {
                            "key": "count",
                            "optional": false
                          }
                        ],
                        "type": "ELEMENT_LINK",
                        "value": "2606DC0B-8396-48FF-939A-9BB62BF8CDD2"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "2fd385f0-2719-489e-85b9-94ea4d7bccbb"
            ]
          },
          "enabled": true,
          "firstElementId": "E40071B2-7029-4FE8-ADEC-D961BD57E156",
          "maxIterations": 200,
          "onFailElemId": null,
          "resultAlias": "collect",
          "storeResult": true
        },
        "name": "Collect Reviewed clicks",
        "nextElementIds": [],
        "nextGroupIds": [],
        "type": "LOOP"
      }
    ],
    "id": "91500C64-49A6-4B8A-8E70-056608BE85CF",
    "metaInfo": {
      "clientValidationState": {
        "errorMessage": "Please fix problems before start. Blocks with issues have red badge in the top-right corner of a block, hover it to see what needs to be done.",
        "valid": false
      },
      "errorMessage": "Please fix problems before start. Blocks with issues have red badge in the top-right corner of a block, hover it to see what needs to be done.",
      "executionStaticData": [
        {
          "description": "The URL of the block Wait for a Reviewed click. The Reviewed buttons open it.",
          "error": null,
          "name": "Answer link",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "The team that holds the results review channel.",
          "error": null,
          "name": "Teams team ID",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "The Teams channel your providers read results in.",
          "error": null,
          "name": "Results review channel ID",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "Your practice's time zone, such as America/Chicago.",
          "error": null,
          "name": "Practice time zone",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "The time of day, in 24-hour format, after which results not marked reviewed become Healthie tasks.",
          "error": null,
          "name": "End of review day",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "The abnormal flag codes your labs print for a critical value, separated by commas. Those values are marked critical on the card.",
          "error": null,
          "name": "Critical flag codes",
          "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:33.185Z"
}
