{
  "version": "1.0.0",
  "exportedAt": "2026-06-10T03:53:35.867Z",
  "workflow": {
    "name": "HIMSS - EVBV (Stedi)",
    "description": ""
  },
  "flow": {
    "tab": {
      "id": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
      "type": "tab",
      "label": "HIMSS - EVBV (Stedi)",
      "disabled": false,
      "info": ""
    },
    "nodes": [
      {
        "id": "1a32cf0eae223fe8",
        "type": "group",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "name": "",
        "style": {
          "stroke": "#000000",
          "fill": "#d1d1d1",
          "label": true
        },
        "nodes": [
          "89c710221498c7e7",
          "b8e2e2362b21e1a6",
          "d39e566101e806cb",
          "c8957d1ae1f20ba4"
        ],
        "x": 68,
        "y": 39,
        "w": 2464,
        "h": 328
      },
      {
        "id": "grp_elig_api",
        "type": "group",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "name": "⑦ Eligibility Check API — POST /api/eligibility",
        "style": {
          "stroke": "#16877a",
          "fill": "#d4f1ec",
          "fill-opacity": "0.5",
          "label": true,
          "color": "#16877a"
        },
        "nodes": [
          "elig_in",
          "elig_set",
          "elig_stedi",
          "elig_fmt",
          "elig_resp",
          "elig_catch",
          "elig_cresp"
        ],
        "x": 74,
        "y": 439,
        "w": 1252,
        "h": 162
      },
      {
        "id": "b8e2e2362b21e1a6",
        "type": "group",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "1a32cf0eae223fe8",
        "name": "Appointment Booked → Check Coverage",
        "style": {
          "label": true,
          "stroke": "#addb7b",
          "fill": "#e3f3d3",
          "color": "#92d04f"
        },
        "nodes": [
          "5494386402443586",
          "ec9eda2d01f9d045",
          "dbbd2e2f41b1332c",
          "403019cb58539b09",
          "bacbecc9e14dc960",
          "feafafda0638faae"
        ],
        "x": 94,
        "y": 119,
        "w": 972,
        "h": 222
      },
      {
        "id": "d39e566101e806cb",
        "type": "group",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "1a32cf0eae223fe8",
        "name": "Check Coverage With Insurer (Real-Time)",
        "style": {
          "stroke": "#9363b7",
          "fill": "#dbcbe7",
          "label": true,
          "color": "#6f2fa0"
        },
        "nodes": [
          "83b8aaa5f26064b2",
          "3048e9fd10cdef08",
          "ac57bd2c417c679b"
        ],
        "x": 1124,
        "y": 199,
        "w": 592,
        "h": 142
      },
      {
        "id": "c8957d1ae1f20ba4",
        "type": "group",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "1a32cf0eae223fe8",
        "name": "Mapping and Write Back ",
        "style": {
          "label": true,
          "stroke": "#3f93cf",
          "fill": "#bfdbef",
          "color": "#0070c0"
        },
        "nodes": [
          "ad81220912e8c542",
          "f89e5e1aa9966d9f",
          "a72e196321c0f070",
          "224bee1790fd2491"
        ],
        "x": 1814,
        "y": 139,
        "w": 692,
        "h": 202
      },
      {
        "id": "89c710221498c7e7",
        "type": "comment",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "1a32cf0eae223fe8",
        "name": "Step 1: A New Appointment Triggers This",
        "info": "This workflow processes appointment booking messages and performs real-time eligibility verification",
        "x": 400,
        "y": 80,
        "wires": []
      },
      {
        "id": "5494386402443586",
        "type": "http in",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "b8e2e2362b21e1a6",
        "name": "POST /eligibility-check",
        "url": "/eligibility-check",
        "method": "post",
        "upload": false,
        "swaggerDoc": "",
        "x": 260,
        "y": 220,
        "wires": [
          [
            "ec9eda2d01f9d045"
          ]
        ]
      },
      {
        "id": "ec9eda2d01f9d045",
        "type": "ec-hl7-parser",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "b8e2e2362b21e1a6",
        "name": "Read Appointment Details",
        "outputField": "",
        "outputFieldType": "msg",
        "x": 570,
        "y": 220,
        "wires": [
          [
            "dbbd2e2f41b1332c",
            "bacbecc9e14dc960"
          ]
        ]
      },
      {
        "id": "dbbd2e2f41b1332c",
        "type": "debug",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "b8e2e2362b21e1a6",
        "name": "Log Appointment Data",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 560,
        "y": 160,
        "wires": []
      },
      {
        "id": "403019cb58539b09",
        "type": "inject",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "b8e2e2362b21e1a6",
        "name": "Appointment Scheduled",
        "props": [
          {
            "p": "payload"
          }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "MSH|^~\\&|MESA_OP|XYZ_HOSPITAL|iFW|ABC_HOSPITAL|20110613061611||SIU^S12|24916560|P|2.3||||||| SCH|10345^10345|2196178^2196178|||10345|OFFICE^Office visit|reason for the appointment|OFFICE|60|m|^^60^20110617084500^20110617093000|||||9^DENT^ARTHUR^||||9^DENT^COREY^|||||Scheduled PID|1||AETNA9wcSu||Doe^John||19781012|M|||1 Broadway Ave^^Fort Wayne^IN^46804||(260)555-1234|||S||999999999|||||||||||||||||||| IN1|1||60054||Provider Name||||||||||||Doe^John||19781012|1 Broadway Ave^^Fort Wayne^IN^46804||||||||||||||||||||||||AETNA9wcSu|||||||M|||||||||1999999984 PID|2||AETNA9wcSu||Doe^Jordan||20010714|U|||||||||||||||||||||||||||||||| PV1|1|O|||||1^Smith^Miranda^A^MD^^^^|2^Withers^Peter^D^MD^^^^||||||||||30||||||||||||||||||||||||||||||||99158|| RGS|1|A AIG|1|A|1^White, Charles|D^^ AIL|1|A|OFFICE^^^OFFICE|^Main Office||20110614084500|||45|m^Minutes||Scheduled AIP|1|A|1^White^Charles^A^MD^^^^|D^White, Douglas||20110614084500|||45|m^Minutes||Scheduled",
        "payloadType": "str",
        "x": 250,
        "y": 280,
        "wires": [
          [
            "ec9eda2d01f9d045"
          ]
        ]
      },
      {
        "id": "bacbecc9e14dc960",
        "type": "ec-hl7-mapper",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "b8e2e2362b21e1a6",
        "name": "Build Eligibility Request",
        "templateType": "custom",
        "template": "{% assign pidSegmentLists = hl7v2Data | get_segment_lists: 'PID' -%}\n{% assign firstPID = pidSegmentLists.PID[0] -%}\n{% assign in1SegmentLists = hl7v2Data | get_related_segment_list: firstPID, 'IN1' -%}\n{% assign firstIN1 = in1SegmentLists.IN1[0] -%}\n{% assign pv1SegmentLists = hl7v2Data | get_related_segment_list: firstPID, 'PV1' -%}\n{% assign firstPV1 = pv1SegmentLists.PV1[0] -%}\n{\n    \"tradingPartnerServiceId\": \"{{ firstIN1.3.1.Value }}\",\n    \"provider\": {\n        \"organizationName\": \"Provider Name\",\n        \"npi\": \"1999999984\"\n    },\n    \"subscriber\": {\n        \"firstName\": \"{{ firstPID.5.2.Value }}\",\n        \"lastName\": \"{{ firstPID.5.1.Value }}\",\n        \"memberId\": \"{{ firstPID.3.1.Value }}\"\n    },\n    \"dependents\": [\n        {% if pidSegmentLists.PID.size > 1 -%}\n        {% assign dependentPID = pidSegmentLists.PID[1] -%}\n        {\n            \"firstName\": \"{{ dependentPID.5.2.Value }}\",\n            \"lastName\": \"{{ dependentPID.5.1.Value }}\",\n            \"dateOfBirth\": \"{{ dependentPID.7.1.Value }}\"\n        }\n        {% endif -%}\n    ],\n    \"encounter\": {\n        \"serviceTypeCodes\": [\"30\"]\n    }\n}",
        "outputFormat": "json",
        "inputField": "payload",
        "inputFieldType": "msg",
        "outputField": "payload",
        "outputFieldType": "msg",
        "x": 890,
        "y": 220,
        "wires": [
          [
            "feafafda0638faae",
            "3048e9fd10cdef08"
          ]
        ]
      },
      {
        "id": "feafafda0638faae",
        "type": "debug",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "b8e2e2362b21e1a6",
        "name": "Log Extracted Patient Info",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 900,
        "y": 300,
        "wires": []
      },
      {
        "id": "83b8aaa5f26064b2",
        "type": "debug",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "d39e566101e806cb",
        "name": "Log Insurer's Response",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1580,
        "y": 300,
        "wires": []
      },
      {
        "id": "3048e9fd10cdef08",
        "type": "change",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "d39e566101e806cb",
        "name": "Set Patient Insurance Data",
        "rules": [
          {
            "t": "set",
            "p": "payload.ins",
            "pt": "msg",
            "to": "payload",
            "tot": "msg",
            "dc": true
          }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1270,
        "y": 240,
        "wires": [
          [
            "ac57bd2c417c679b"
          ]
        ]
      },
      {
        "id": "ac57bd2c417c679b",
        "type": "ec-stedi-eligibility",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "d39e566101e806cb",
        "name": "Check Insurance Coverage",
        "interface": "stedi",
        "integrationId": "",
        "integrationMetadata": {
          "ehr": "stedi",
          "type": "stedi",
          "scopes": ""
        },
        "customApiUrl": "",
        "outputField": "",
        "outputFieldType": "msg",
        "x": 1530,
        "y": 240,
        "wires": [
          [
            "ad81220912e8c542",
            "83b8aaa5f26064b2"
          ]
        ]
      },
      {
        "id": "ad81220912e8c542",
        "type": "function",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "c8957d1ae1f20ba4",
        "name": "Format Eligibility Response",
        "func": "// Format Stedi eligibility response into comprehensive text report\nconst response = msg.payload;\n\nlet resultText = \"\\n═══════════════════════════════════════════════════════════\\n\";\nresultText += \"  ELIGIBILITY & BENEFITS VERIFICATION RESULTS\\n\";\nresultText += \"═══════════════════════════════════════════════════════════\\n\\n\";\n\n// Check for errors first\nif (response.errors && response.errors.length > 0) {\n    resultText += \"❌ ERRORS DETECTED\\n\";\n    resultText += \"─────────────────────────────────────────────────────────\\n\";\n    response.errors.forEach((error, index) => {\n        resultText += `${index + 1}. ${error.description || error.message || JSON.stringify(error)}\\n`;\n    });\n    resultText += \"\\n\";\n}\n\n// Subscriber Information\nresultText += \"👤 SUBSCRIBER INFORMATION\\n\";\nresultText += \"─────────────────────────────────────────────────────────\\n\";\nif (response.subscriber) {\n    const sub = response.subscriber;\n    resultText += `Name: ${sub.firstName || ''} ${sub.middleName || ''} ${sub.lastName || ''}\\n`.replace(/\\s+/g, ' ');\n    resultText += `Member ID: ${sub.memberId || 'N/A'}\\n`;\n    if (sub.groupNumber) {\n        resultText += `Group Number: ${sub.groupNumber}\\n`;\n    }\n    if (sub.entityIdentifier) {\n        resultText += `Entity: ${sub.entityIdentifier}\\n`;\n    }\n}\nresultText += \"\\n\";\n\n// Dependent Information\nif (response.dependents && response.dependents.length > 0) {\n    resultText += \"👨‍👩‍👧‍👦 DEPENDENT INFORMATION\\n\";\n    resultText += \"─────────────────────────────────────────────────────────\\n\";\n    response.dependents.forEach((dep, idx) => {\n        resultText += `\\nDependent ${idx + 1}:\\n`;\n        resultText += `  Name: ${dep.firstName || ''} ${dep.middleName || ''} ${dep.lastName || ''}\\n`.replace(/\\s+/g, ' ');\n        if (dep.dateOfBirth) {\n            resultText += `  Date of Birth: ${dep.dateOfBirth}\\n`;\n        }\n        if (dep.gender) {\n            resultText += `  Gender: ${dep.gender}\\n`;\n        }\n        if (dep.relationToSubscriber) {\n            resultText += `  Relationship: ${dep.relationToSubscriber}\\n`;\n        }\n        if (dep.address) {\n            resultText += `  Address: ${dep.address.address1 || ''}${dep.address.address2 ? ', ' + dep.address.address2 : ''}\\n`;\n            resultText += `           ${dep.address.city || ''}, ${dep.address.state || ''} ${dep.address.postalCode || ''}\\n`;\n        }\n    });\n    resultText += \"\\n\";\n}\n\n// Provider Information\nresultText += \"🏥 PROVIDER INFORMATION\\n\";\nresultText += \"─────────────────────────────────────────────────────────\\n\";\nif (response.provider) {\n    const prov = response.provider;\n    resultText += `Name: ${prov.providerName || 'N/A'}\\n`;\n    if (prov.npi) {\n        resultText += `NPI: ${prov.npi}\\n`;\n    }\n    if (prov.entityIdentifier) {\n        resultText += `Type: ${prov.entityIdentifier}\\n`;\n    }\n}\nresultText += \"\\n\";\n\n// Payer Information\nresultText += \"💳 PAYER INFORMATION\\n\";\nresultText += \"─────────────────────────────────────────────────────────\\n\";\nif (response.payer) {\n    const payer = response.payer;\n    resultText += `Name: ${payer.name || 'N/A'}\\n`;\n    if (payer.payorIdentification) {\n        resultText += `Payor ID: ${payer.payorIdentification}\\n`;\n    }\n}\nresultText += \"\\n\";\n\n// Plan Information\nresultText += \"📋 PLAN INFORMATION\\n\";\nresultText += \"═════════════════════════════════════════════════════════\\n\";\nif (response.planInformation) {\n    if (response.planInformation.planNumber) {\n        resultText += `Plan Number: ${response.planInformation.planNumber}\\n`;\n    }\n}\nif (response.planDateInformation) {\n    const dates = response.planDateInformation;\n    if (dates.planBegin) {\n        resultText += `Plan Begin: ${dates.planBegin}\\n`;\n    }\n    if (dates.eligibilityBegin) {\n        resultText += `Eligibility Begin: ${dates.eligibilityBegin}\\n`;\n    }\n    if (dates.service) {\n        resultText += `Service Date: ${dates.service}\\n`;\n    }\n}\nresultText += \"\\n\";\n\n// Plan Status\nif (response.planStatus && response.planStatus.length > 0) {\n    resultText += \"✅ PLAN STATUS\\n\";\n    resultText += \"─────────────────────────────────────────────────────────\\n\";\n    response.planStatus.forEach((status, idx) => {\n        resultText += `${idx + 1}. ${status.status || 'Unknown'}\\n`;\n        if (status.planDetails) {\n            resultText += `   Plan: ${status.planDetails}\\n`;\n        }\n        if (status.serviceTypeCodes && status.serviceTypeCodes.length > 0) {\n            resultText += `   Service Codes: ${status.serviceTypeCodes.join(', ')}\\n`;\n        }\n    });\n    resultText += \"\\n\";\n}\n\n// Benefits Summary - Group by benefit type\nif (response.benefitsInformation && response.benefitsInformation.length > 0) {\n    resultText += \"💰 BENEFITS INFORMATION\\n\";\n    resultText += \"═════════════════════════════════════════════════════════\\n\\n\";\n    \n    // Group benefits by code (A=Coinsurance, B=Copayment, C=Deductible, G=Out of Pocket, F=Limitations, H=Unlimited, I=Non-Covered)\n    const deductibles = response.benefitsInformation.filter(b => b.code === 'C');\n    const outOfPocket = response.benefitsInformation.filter(b => b.code === 'G');\n    const copayments = response.benefitsInformation.filter(b => b.code === 'B');\n    const coinsurance = response.benefitsInformation.filter(b => b.code === 'A');\n    const limitations = response.benefitsInformation.filter(b => b.code === 'F');\n    const unlimited = response.benefitsInformation.filter(b => b.code === 'H');\n    const nonCovered = response.benefitsInformation.filter(b => b.code === 'I');\n    \n    // Deductibles\n    if (deductibles.length > 0) {\n        resultText += \"🔹 DEDUCTIBLES\\n\";\n        resultText += \"─────────────────────────────────────────────────────────\\n\";\n        \n        // In-Network\n        const inNetworkDed = deductibles.filter(d => d.inPlanNetworkIndicatorCode === 'Y');\n        if (inNetworkDed.length > 0) {\n            resultText += \"\\nIn-Network:\\n\";\n            inNetworkDed.forEach(ded => {\n                const level = ded.coverageLevel || 'N/A';\n                const amount = ded.benefitAmount || '0';\n                const timeQual = ded.timeQualifier || '';\n                const services = ded.serviceTypes ? ded.serviceTypes.join(', ') : 'General';\n                resultText += `  ${level} - $${amount}`;\n                if (timeQual) resultText += ` (${timeQual})`;\n                resultText += ` - ${services}\\n`;\n            });\n        }\n        \n        // Out-of-Network\n        const outNetworkDed = deductibles.filter(d => d.inPlanNetworkIndicatorCode === 'N');\n        if (outNetworkDed.length > 0) {\n            resultText += \"\\nOut-of-Network:\\n\";\n            outNetworkDed.forEach(ded => {\n                const level = ded.coverageLevel || 'N/A';\n                const amount = ded.benefitAmount || '0';\n                const timeQual = ded.timeQualifier || '';\n                const services = ded.serviceTypes ? ded.serviceTypes.join(', ') : 'General';\n                resultText += `  ${level} - $${amount}`;\n                if (timeQual) resultText += ` (${timeQual})`;\n                resultText += ` - ${services}\\n`;\n            });\n        }\n        resultText += \"\\n\";\n    }\n    \n    // Out of Pocket\n    if (outOfPocket.length > 0) {\n        resultText += \"🔹 OUT OF POCKET MAXIMUM\\n\";\n        resultText += \"─────────────────────────────────────────────────────────\\n\";\n        \n        // In-Network\n        const inNetworkOOP = outOfPocket.filter(o => o.inPlanNetworkIndicatorCode === 'Y');\n        if (inNetworkOOP.length > 0) {\n            resultText += \"\\nIn-Network:\\n\";\n            inNetworkOOP.forEach(oop => {\n                const level = oop.coverageLevel || 'N/A';\n                const amount = oop.benefitAmount || '0';\n                const timeQual = oop.timeQualifier || '';\n                const services = oop.serviceTypes ? oop.serviceTypes.join(', ') : 'General';\n                resultText += `  ${level} - $${amount}`;\n                if (timeQual) resultText += ` (${timeQual})`;\n                resultText += ` - ${services}\\n`;\n                if (oop.additionalInformation && oop.additionalInformation.length > 0) {\n                    oop.additionalInformation.forEach(info => {\n                        resultText += `    ℹ️  ${info.description}\\n`;\n                    });\n                }\n            });\n        }\n        \n        // Out-of-Network\n        const outNetworkOOP = outOfPocket.filter(o => o.inPlanNetworkIndicatorCode === 'N');\n        if (outNetworkOOP.length > 0) {\n            resultText += \"\\nOut-of-Network:\\n\";\n            outNetworkOOP.forEach(oop => {\n                const level = oop.coverageLevel || 'N/A';\n                const amount = oop.benefitAmount || '0';\n                const timeQual = oop.timeQualifier || '';\n                resultText += `  ${level} - $${amount}`;\n                if (timeQual) resultText += ` (${timeQual})`;\n                resultText += \"\\n\";\n            });\n        }\n        resultText += \"\\n\";\n    }\n    \n    // Copayments\n    if (copayments.length > 0) {\n        resultText += \"🔹 COPAYMENTS (In-Network)\\n\";\n        resultText += \"─────────────────────────────────────────────────────────\\n\";\n        const inNetworkCopay = copayments.filter(c => c.inPlanNetworkIndicatorCode === 'Y');\n        \n        // Group by service type\n        const copayByService = {};\n        inNetworkCopay.forEach(copay => {\n            const services = copay.serviceTypes || ['General'];\n            services.forEach(service => {\n                if (!copayByService[service]) {\n                    copayByService[service] = [];\n                }\n                copayByService[service].push(copay);\n            });\n        });\n        \n        Object.keys(copayByService).forEach(service => {\n            resultText += `\\n${service}:\\n`;\n            copayByService[service].forEach(copay => {\n                const amount = copay.benefitAmount || '0';\n                resultText += `  $${amount}`;\n                if (copay.additionalInformation && copay.additionalInformation.length > 0) {\n                    const info = copay.additionalInformation.map(i => i.description).join(', ');\n                    resultText += ` - ${info}`;\n                }\n                resultText += \"\\n\";\n            });\n        });\n        resultText += \"\\n\";\n    }\n    \n    // Coinsurance\n    if (coinsurance.length > 0) {\n        resultText += \"🔹 COINSURANCE (In-Network)\\n\";\n        resultText += \"─────────────────────────────────────────────────────────\\n\";\n        const inNetworkCoins = coinsurance.filter(c => c.inPlanNetworkIndicatorCode === 'Y');\n        \n        // Group by service type\n        const coinsByService = {};\n        inNetworkCoins.forEach(coins => {\n            const services = coins.serviceTypes || ['General'];\n            services.forEach(service => {\n                if (!coinsByService[service]) {\n                    coinsByService[service] = [];\n                }\n                coinsByService[service].push(coins);\n            });\n        });\n        \n        Object.keys(coinsByService).forEach(service => {\n            resultText += `\\n${service}:\\n`;\n            coinsByService[service].forEach(coins => {\n                const percent = coins.benefitPercent || '0';\n                resultText += `  ${percent}% patient responsibility`;\n                if (coins.additionalInformation && coins.additionalInformation.length > 0) {\n                    const info = coins.additionalInformation.map(i => i.description).join(', ');\n                    resultText += ` - ${info}`;\n                }\n                resultText += \"\\n\";\n            });\n        });\n        resultText += \"\\n\";\n    }\n    \n    // Limitations\n    if (limitations.length > 0) {\n        resultText += \"⚠️  LIMITATIONS & RESTRICTIONS\\n\";\n        resultText += \"─────────────────────────────────────────────────────────\\n\";\n        limitations.forEach((lim, idx) => {\n            if (lim.additionalInformation && lim.additionalInformation.length > 0) {\n                lim.additionalInformation.forEach(info => {\n                    resultText += `• ${info.description}\\n`;\n                });\n            } else if (lim.benefitAmount) {\n                const services = lim.serviceTypes ? lim.serviceTypes.join(', ') : 'General';\n                resultText += `• ${services}: ${lim.benefitAmount}`;\n                if (lim.timeQualifier) resultText += ` per ${lim.timeQualifier}`;\n                resultText += \"\\n\";\n            }\n        });\n        resultText += \"\\n\";\n    }\n    \n    // Unlimited\n    if (unlimited.length > 0) {\n        resultText += \"♾️  UNLIMITED BENEFITS\\n\";\n        resultText += \"─────────────────────────────────────────────────────────\\n\";\n        unlimited.forEach(unlim => {\n            const services = unlim.serviceTypes ? unlim.serviceTypes.join(', ') : 'General';\n            resultText += `• ${services}\\n`;\n        });\n        resultText += \"\\n\";\n    }\n    \n    // Non-Covered\n    if (nonCovered.length > 0) {\n        resultText += \"❌ NON-COVERED SERVICES\\n\";\n        resultText += \"─────────────────────────────────────────────────────────\\n\";\n        nonCovered.forEach(nc => {\n            if (nc.additionalInformation && nc.additionalInformation.length > 0) {\n                nc.additionalInformation.forEach(info => {\n                    resultText += `• ${info.description}\\n`;\n                });\n            } else {\n                const services = nc.serviceTypes ? nc.serviceTypes.join(', ') : 'General';\n                resultText += `• ${services}\\n`;\n            }\n        });\n        resultText += \"\\n\";\n    }\n}\n\n// Transaction Details\nresultText += \"📊 TRANSACTION DETAILS\\n\";\nresultText += \"─────────────────────────────────────────────────────────\\n\";\nif (response.id) {\n    resultText += `Transaction ID: ${response.id}\\n`;\n}\nif (response.controlNumber) {\n    resultText += `Control Number: ${response.controlNumber}\\n`;\n}\nif (response.tradingPartnerServiceId) {\n    resultText += `Trading Partner Service ID: ${response.tradingPartnerServiceId}\\n`;\n}\nif (response.meta) {\n    if (response.meta.traceId) {\n        resultText += `Trace ID: ${response.meta.traceId}\\n`;\n    }\n    if (response.meta.applicationMode) {\n        resultText += `Mode: ${response.meta.applicationMode}\\n`;\n    }\n}\nresultText += `Timestamp: ${new Date().toISOString()}\\n`;\n\nresultText += \"\\n═══════════════════════════════════════════════════════════\\n\";\nresultText += \"  END OF ELIGIBILITY VERIFICATION REPORT\\n\";\nresultText += \"═══════════════════════════════════════════════════════════\\n\";\n\n// Set the formatted text as payload\nmsg.payload = resultText;\n\n// Keep the raw response for reference\nmsg.rawStediResponse = response;\n\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1960,
        "y": 300,
        "wires": [
          [
            "a72e196321c0f070",
            "f89e5e1aa9966d9f",
            "224bee1790fd2491"
          ]
        ]
      },
      {
        "id": "f89e5e1aa9966d9f",
        "type": "debug",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "c8957d1ae1f20ba4",
        "name": "Generate Report for Health System",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 2310,
        "y": 180,
        "wires": []
      },
      {
        "id": "a72e196321c0f070",
        "type": "http response",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "c8957d1ae1f20ba4",
        "name": "Return Eligibility Report",
        "statusCode": "200",
        "headers": {
          "content-type": "text/plain; charset=utf-8"
        },
        "x": 2270,
        "y": 300,
        "wires": []
      },
      {
        "id": "224bee1790fd2491",
        "type": "http request",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "d": true,
        "g": "c8957d1ae1f20ba4",
        "name": "Write To Health App Backend",
        "method": "POST",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "https://your-health-system.example.com/webhook",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 2290,
        "y": 240,
        "wires": [
          []
        ]
      },
      {
        "id": "elig_in",
        "type": "http in",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "grp_elig_api",
        "name": "POST /api/eligibility",
        "url": "/api/eligibility",
        "method": "post",
        "upload": false,
        "skipBodyParsing": false,
        "swaggerDoc": "",
        "x": 190,
        "y": 480,
        "wires": [
          [
            "elig_set"
          ]
        ]
      },
      {
        "id": "elig_set",
        "type": "function",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "grp_elig_api",
        "name": "Set eligibility request (→ payload.ins)",
        "func": "// 270 request comes in as the POST JSON body. ec-stedi-eligibility reads msg.payload.ins\nconst body = msg.payload || (msg.req && msg.req.body) || {};\nif (!body || !body.subscriber) {\n  msg.statusCode = 400; msg.headers = { 'Content-Type': 'application/json' };\n  msg.payload = { error: 'invalid_request', message: 'POST a 270 body containing at least { subscriber }' };\n  return [null, msg];\n}\nmsg.payload = { ins: body };\nreturn [msg, null];",
        "outputs": 2,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 450,
        "y": 480,
        "wires": [
          [
            "elig_stedi"
          ],
          [
            "elig_resp"
          ]
        ]
      },
      {
        "id": "elig_stedi",
        "type": "ec-stedi-eligibility",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "grp_elig_api",
        "name": "Check Insurance Coverage (Real-Time)",
        "interface": "stedi",
        "integrationId": "",
        "integrationMetadata": {
          "ehr": "stedi",
          "type": "stedi",
          "scopes": ""
        },
        "customApiUrl": "",
        "outputField": "",
        "outputFieldType": "msg",
        "x": 780,
        "y": 480,
        "wires": [
          [
            "elig_fmt"
          ]
        ]
      },
      {
        "id": "elig_fmt",
        "type": "function",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "grp_elig_api",
        "name": "Build Coverage Report",
        "func": "// 271 result is on msg.payload; pass it through with a quick active flag.\nconst r = msg.payload || {};\nmsg.statusCode = 200; msg.headers = { 'Content-Type': 'application/json' };\nmsg.payload = { eligibility: r, stedi: msg.stedi || null };\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1050,
        "y": 480,
        "wires": [
          [
            "elig_resp"
          ]
        ]
      },
      {
        "id": "elig_resp",
        "type": "http response",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "grp_elig_api",
        "name": "respond",
        "statusCode": "",
        "headers": {},
        "x": 1240,
        "y": 480,
        "wires": []
      },
      {
        "id": "elig_catch",
        "type": "catch",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "grp_elig_api",
        "name": "catch",
        "scope": [
          "elig_stedi",
          "elig_set",
          "elig_fmt"
        ],
        "uncaught": false,
        "x": 500,
        "y": 560,
        "wires": [
          [
            "elig_cresp"
          ]
        ]
      },
      {
        "id": "elig_cresp",
        "type": "function",
        "z": "workflow_077be1c4-54af-42d0-a469-5ee059fa33c9",
        "g": "grp_elig_api",
        "name": "Error → respond",
        "func": "msg.statusCode = 200; msg.headers = { 'Content-Type': 'application/json' };\nmsg.payload = { error: (msg.error && msg.error.message) || 'eligibility_error' };\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 760,
        "y": 560,
        "wires": [
          [
            "elig_resp"
          ]
        ]
      }
    ]
  },
  "requirements": [
    {
      "ehr": "stedi",
      "type": "stedi"
    }
  ]
}