@tellescope/react-components 1.235.0 → 1.235.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/CMS/ContentViewer.d.ts.map +1 -1
- package/lib/cjs/CMS/ContentViewer.js +26 -22
- package/lib/cjs/CMS/ContentViewer.js.map +1 -1
- package/lib/cjs/Forms/inputs.d.ts.map +1 -1
- package/lib/cjs/Forms/inputs.js +220 -100
- package/lib/cjs/Forms/inputs.js.map +1 -1
- package/lib/cjs/Forms/inputs.v2.js +1 -1
- package/lib/esm/CMS/ContentViewer.d.ts.map +1 -1
- package/lib/esm/CMS/ContentViewer.js +27 -23
- package/lib/esm/CMS/ContentViewer.js.map +1 -1
- package/lib/esm/CMS/components.d.ts +1 -0
- package/lib/esm/CMS/components.d.ts.map +1 -1
- package/lib/esm/Forms/form_responses.d.ts +1 -0
- package/lib/esm/Forms/form_responses.d.ts.map +1 -1
- package/lib/esm/Forms/forms.d.ts +3 -3
- package/lib/esm/Forms/forms.v2.d.ts +3 -3
- package/lib/esm/Forms/hooks.d.ts +1 -0
- package/lib/esm/Forms/hooks.d.ts.map +1 -1
- package/lib/esm/Forms/inputs.d.ts +1 -1
- package/lib/esm/Forms/inputs.d.ts.map +1 -1
- package/lib/esm/Forms/inputs.js +220 -100
- package/lib/esm/Forms/inputs.js.map +1 -1
- package/lib/esm/Forms/inputs.v2.d.ts +1 -1
- package/lib/esm/Forms/inputs.v2.js +1 -1
- package/lib/esm/controls.d.ts +2 -2
- package/lib/esm/inputs.d.ts +1 -1
- package/lib/esm/inputs.native.d.ts +1 -0
- package/lib/esm/inputs.native.d.ts.map +1 -1
- package/lib/esm/state.d.ts +315 -315
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +44 -44
- package/src/CMS/ContentViewer.tsx +16 -2
- package/src/Forms/inputs.tsx +189 -76
- package/src/Forms/inputs.v2.tsx +1 -1
package/lib/esm/Forms/inputs.js
CHANGED
|
@@ -361,6 +361,7 @@ export var InsuranceInput = function (_a) {
|
|
|
361
361
|
var _a, _b, _d;
|
|
362
362
|
return ((((_a = addressQuestion === null || addressQuestion === void 0 ? void 0 : addressQuestion.answer) === null || _a === void 0 ? void 0 : _a.type) === 'Address' ? (_d = (_b = addressQuestion === null || addressQuestion === void 0 ? void 0 : addressQuestion.answer) === null || _b === void 0 ? void 0 : _b.value) === null || _d === void 0 ? void 0 : _d.state : undefined) || (enduser === null || enduser === void 0 ? void 0 : enduser.state));
|
|
363
363
|
}, [enduser === null || enduser === void 0 ? void 0 : enduser.state, addressQuestion]);
|
|
364
|
+
// load from database
|
|
364
365
|
var loadRef = useRef(false); // so session changes don't cause
|
|
365
366
|
useEffect(function () {
|
|
366
367
|
var _a, _b;
|
|
@@ -390,6 +391,7 @@ export var InsuranceInput = function (_a) {
|
|
|
390
391
|
})
|
|
391
392
|
.catch(console.error);
|
|
392
393
|
}, [session, state, (_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.dataSource]);
|
|
394
|
+
// load from 3rd-party on search only
|
|
393
395
|
var searchRef = useRef(query);
|
|
394
396
|
useEffect(function () {
|
|
395
397
|
var _a, _b, _d, _e;
|
|
@@ -442,7 +444,8 @@ export var InsuranceInput = function (_a) {
|
|
|
442
444
|
if (databaseRecord) {
|
|
443
445
|
onDatabaseSelect === null || onDatabaseSelect === void 0 ? void 0 : onDatabaseSelect([databaseRecord]);
|
|
444
446
|
}
|
|
445
|
-
|
|
447
|
+
// don't lose existing payerId on back-and-forth navigation
|
|
448
|
+
onChange(__assign(__assign({}, value), { payerName: v || '', payerId: ((value === null || value === void 0 ? void 0 : value.payerName) === v && (value === null || value === void 0 ? void 0 : value.payerId) ? value.payerId : '') || ((_b = payers.find(function (p) { return p.name === v; })) === null || _b === void 0 ? void 0 : _b.id) || '', payerType: ((_d = payers.find(function (p) { return p.name === v; })) === null || _d === void 0 ? void 0 : _d.type) || '' }), field.id);
|
|
446
449
|
}, renderInput: function (params) {
|
|
447
450
|
var _a, _b;
|
|
448
451
|
return (_jsx(TextField, __assign({}, params, { InputProps: __assign(__assign({}, params.InputProps), { sx: (inputProps || defaultInputProps).sx }), required: !field.isOptional, size: "small", label: "Insurer", placeholder: (((_a = field.options) === null || _a === void 0 ? void 0 : _a.dataSource) === CANVAS_TITLE || ((_b = field.options) === null || _b === void 0 ? void 0 : _b.dataSource) === BRIDGE_TITLE) ? "Search insurer..." : "Insurer" })));
|
|
@@ -473,17 +476,17 @@ var StringSelector = function (_a) {
|
|
|
473
476
|
}) }))] })));
|
|
474
477
|
};
|
|
475
478
|
export var BridgeEligibilityInput = function (_a) {
|
|
476
|
-
var _b, _d, _e, _f;
|
|
479
|
+
var _b, _d, _e, _f, _g, _h, _j;
|
|
477
480
|
var field = _a.field, value = _a.value, onChange = _a.onChange, responses = _a.responses, enduser = _a.enduser, inputProps = _a.inputProps, enduserId = _a.enduserId, props = __rest(_a, ["field", "value", "onChange", "responses", "enduser", "inputProps", "enduserId"]);
|
|
478
481
|
var session = useResolvedSession();
|
|
479
|
-
var
|
|
480
|
-
var
|
|
481
|
-
var
|
|
482
|
+
var _k = useState(false), loading = _k[0], setLoading = _k[1];
|
|
483
|
+
var _l = useState(false), polling = _l[0], setPolling = _l[1];
|
|
484
|
+
var _m = useState(), error = _m[0], setError = _m[1];
|
|
482
485
|
// single-page form must require button-click to check, but 1-page-at-a-time enduser sessions should auto-check
|
|
483
486
|
var isEnduserSession = session.type === 'enduser';
|
|
484
487
|
var eligibilityType = ((_b = field.options) === null || _b === void 0 ? void 0 : _b.bridgeEligibilityType) || 'Soft';
|
|
485
488
|
// Extract payerId from Insurance question response
|
|
486
|
-
var
|
|
489
|
+
var _o = useMemo(function () {
|
|
487
490
|
var _a, _b, _d, _e;
|
|
488
491
|
var insuranceResponse = responses === null || responses === void 0 ? void 0 : responses.find(function (r) { var _a, _b, _d; return ((_a = r.answer) === null || _a === void 0 ? void 0 : _a.type) === 'Insurance' && ((_d = (_b = r.answer) === null || _b === void 0 ? void 0 : _b.value) === null || _d === void 0 ? void 0 : _d.payerId); });
|
|
489
492
|
if (((_a = insuranceResponse === null || insuranceResponse === void 0 ? void 0 : insuranceResponse.answer) === null || _a === void 0 ? void 0 : _a.type) === 'Insurance') {
|
|
@@ -495,7 +498,7 @@ export var BridgeEligibilityInput = function (_a) {
|
|
|
495
498
|
}
|
|
496
499
|
// existing payer id is automatically resolved on the backend as default
|
|
497
500
|
return [];
|
|
498
|
-
}, [responses]), payerId =
|
|
501
|
+
}, [responses]), payerId = _o[0], memberId = _o[1], payerName = _o[2];
|
|
499
502
|
// Extract state from Address question or enduser
|
|
500
503
|
var state = useMemo(function () {
|
|
501
504
|
var _a, _b;
|
|
@@ -506,48 +509,80 @@ export var BridgeEligibilityInput = function (_a) {
|
|
|
506
509
|
}
|
|
507
510
|
// enduser state is automatically resolved on the backend as default
|
|
508
511
|
}, [responses]);
|
|
509
|
-
// Soft eligibility check function
|
|
512
|
+
// Soft eligibility check function - supports multiple service type IDs
|
|
510
513
|
var checkProviderEligibility = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
511
|
-
var
|
|
512
|
-
var _a;
|
|
513
|
-
return __generator(this, function (
|
|
514
|
-
switch (
|
|
514
|
+
var serviceTypeIds, results, allUserIds, uniqueUserIds, aggregatedStatus, err_1;
|
|
515
|
+
var _a, _b;
|
|
516
|
+
return __generator(this, function (_d) {
|
|
517
|
+
switch (_d.label) {
|
|
515
518
|
case 0:
|
|
516
|
-
|
|
517
|
-
if (!
|
|
518
|
-
setError('Bridge Service Type
|
|
519
|
+
serviceTypeIds = (_a = field.options) === null || _a === void 0 ? void 0 : _a.bridgeServiceTypeIds;
|
|
520
|
+
if (!serviceTypeIds || serviceTypeIds.length === 0) {
|
|
521
|
+
setError('Bridge Service Type IDs not configured');
|
|
519
522
|
return [2 /*return*/];
|
|
520
523
|
}
|
|
521
524
|
// payerId and state can be automatically resolved on the backend, if already saved on Enduser, so not required here
|
|
522
525
|
setLoading(true);
|
|
523
526
|
setError(undefined);
|
|
524
|
-
|
|
527
|
+
_d.label = 1;
|
|
525
528
|
case 1:
|
|
526
|
-
|
|
527
|
-
return [4 /*yield*/,
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
529
|
+
_d.trys.push([1, 3, 4, 5]);
|
|
530
|
+
return [4 /*yield*/, Promise.all(serviceTypeIds.map(function (serviceTypeId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
531
|
+
var data, err_2;
|
|
532
|
+
return __generator(this, function (_a) {
|
|
533
|
+
switch (_a.label) {
|
|
534
|
+
case 0:
|
|
535
|
+
_a.trys.push([0, 2, , 3]);
|
|
536
|
+
return [4 /*yield*/, session.api.integrations.proxy_read({
|
|
537
|
+
id: enduserId,
|
|
538
|
+
integration: BRIDGE_TITLE,
|
|
539
|
+
type: 'provider-eligibility',
|
|
540
|
+
query: JSON.stringify({
|
|
541
|
+
serviceTypeId: serviceTypeId,
|
|
542
|
+
payerId: payerId,
|
|
543
|
+
state: state,
|
|
544
|
+
}),
|
|
545
|
+
})];
|
|
546
|
+
case 1:
|
|
547
|
+
data = (_a.sent()).data;
|
|
548
|
+
return [2 /*return*/, {
|
|
549
|
+
serviceTypeId: serviceTypeId,
|
|
550
|
+
status: (data === null || data === void 0 ? void 0 : data.status) || 'unknown',
|
|
551
|
+
userIds: (data === null || data === void 0 ? void 0 : data.userIds) || [],
|
|
552
|
+
}];
|
|
553
|
+
case 2:
|
|
554
|
+
err_2 = _a.sent();
|
|
555
|
+
console.error("Provider eligibility check failed for ".concat(serviceTypeId, ":"), err_2);
|
|
556
|
+
return [2 /*return*/, {
|
|
557
|
+
serviceTypeId: serviceTypeId,
|
|
558
|
+
status: 'error',
|
|
559
|
+
userIds: [],
|
|
560
|
+
error: err_2 === null || err_2 === void 0 ? void 0 : err_2.message,
|
|
561
|
+
}];
|
|
562
|
+
case 3: return [2 /*return*/];
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
}); }))
|
|
566
|
+
// Aggregate results - union of userIds across all service types
|
|
538
567
|
];
|
|
539
568
|
case 2:
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
569
|
+
results = _d.sent();
|
|
570
|
+
allUserIds = results.flatMap(function (r) { return r.userIds; });
|
|
571
|
+
uniqueUserIds = Array.from(new Set(allUserIds));
|
|
572
|
+
aggregatedStatus = results.some(function (r) { return r.status === 'ELIGIBLE'; })
|
|
573
|
+
? 'ELIGIBLE'
|
|
574
|
+
: ((_b = results.find(function (r) { return r.status !== 'error'; })) === null || _b === void 0 ? void 0 : _b.status) || 'unknown';
|
|
575
|
+
// Store aggregated userIds in shared variable for Appointment Booking to use
|
|
576
|
+
setBridgeEligibilityUserIds(uniqueUserIds);
|
|
577
|
+
// Update the answer with aggregated results
|
|
544
578
|
onChange({
|
|
545
|
-
|
|
546
|
-
|
|
579
|
+
payerId: payerId,
|
|
580
|
+
status: aggregatedStatus,
|
|
581
|
+
userIds: uniqueUserIds,
|
|
547
582
|
}, field.id);
|
|
548
583
|
return [3 /*break*/, 5];
|
|
549
584
|
case 3:
|
|
550
|
-
err_1 =
|
|
585
|
+
err_1 = _d.sent();
|
|
551
586
|
setError((err_1 === null || err_1 === void 0 ? void 0 : err_1.message) || 'Failed to check eligibility');
|
|
552
587
|
console.error('Provider eligibility check failed:', err_1);
|
|
553
588
|
return [3 /*break*/, 5];
|
|
@@ -558,16 +593,16 @@ export var BridgeEligibilityInput = function (_a) {
|
|
|
558
593
|
}
|
|
559
594
|
});
|
|
560
595
|
}); }, [session, field, payerId, state, onChange, enduserId]);
|
|
561
|
-
// Hard eligibility check function with polling
|
|
596
|
+
// Hard eligibility check function with polling - supports multiple service type IDs
|
|
562
597
|
var checkServiceEligibility = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
563
|
-
var
|
|
598
|
+
var serviceTypeIds, initiatedChecks_1, pollForAllResults, err_3;
|
|
564
599
|
var _a;
|
|
565
600
|
return __generator(this, function (_b) {
|
|
566
601
|
switch (_b.label) {
|
|
567
602
|
case 0:
|
|
568
|
-
|
|
569
|
-
if (!
|
|
570
|
-
setError('Bridge Service Type
|
|
603
|
+
serviceTypeIds = (_a = field.options) === null || _a === void 0 ? void 0 : _a.bridgeServiceTypeIds;
|
|
604
|
+
if (!serviceTypeIds || serviceTypeIds.length === 0) {
|
|
605
|
+
setError('Bridge Service Type IDs not configured');
|
|
571
606
|
return [2 /*return*/];
|
|
572
607
|
}
|
|
573
608
|
setLoading(true);
|
|
@@ -575,35 +610,69 @@ export var BridgeEligibilityInput = function (_a) {
|
|
|
575
610
|
_b.label = 1;
|
|
576
611
|
case 1:
|
|
577
612
|
_b.trys.push([1, 3, , 4]);
|
|
578
|
-
return [4 /*yield*/,
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
613
|
+
return [4 /*yield*/, Promise.all(serviceTypeIds.map(function (serviceTypeId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
614
|
+
var data, serviceEligibilityId, err_4;
|
|
615
|
+
return __generator(this, function (_a) {
|
|
616
|
+
switch (_a.label) {
|
|
617
|
+
case 0:
|
|
618
|
+
_a.trys.push([0, 2, , 3]);
|
|
619
|
+
return [4 /*yield*/, session.api.integrations.proxy_read({
|
|
620
|
+
id: enduserId,
|
|
621
|
+
integration: BRIDGE_TITLE,
|
|
622
|
+
type: 'service-eligibility',
|
|
623
|
+
query: JSON.stringify({
|
|
624
|
+
serviceTypeId: serviceTypeId,
|
|
625
|
+
payerId: payerId,
|
|
626
|
+
memberId: memberId,
|
|
627
|
+
state: state,
|
|
628
|
+
}),
|
|
629
|
+
})];
|
|
630
|
+
case 1:
|
|
631
|
+
data = (_a.sent()).data;
|
|
632
|
+
serviceEligibilityId = data === null || data === void 0 ? void 0 : data.id;
|
|
633
|
+
if (!serviceEligibilityId) {
|
|
634
|
+
throw new Error('No service eligibility ID returned');
|
|
635
|
+
}
|
|
636
|
+
return [2 /*return*/, {
|
|
637
|
+
serviceTypeId: serviceTypeId,
|
|
638
|
+
serviceEligibilityId: serviceEligibilityId,
|
|
639
|
+
error: undefined,
|
|
640
|
+
}];
|
|
641
|
+
case 2:
|
|
642
|
+
err_4 = _a.sent();
|
|
643
|
+
console.error("Service eligibility check initiation failed for ".concat(serviceTypeId, ":"), err_4);
|
|
644
|
+
return [2 /*return*/, {
|
|
645
|
+
serviceTypeId: serviceTypeId,
|
|
646
|
+
serviceEligibilityId: null,
|
|
647
|
+
error: err_4 === null || err_4 === void 0 ? void 0 : err_4.message,
|
|
648
|
+
}];
|
|
649
|
+
case 3: return [2 /*return*/];
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
}); }))];
|
|
589
653
|
case 2:
|
|
590
|
-
|
|
591
|
-
serviceEligibilityId_1 = data === null || data === void 0 ? void 0 : data.id;
|
|
592
|
-
if (!serviceEligibilityId_1) {
|
|
593
|
-
throw new Error('No service eligibility ID returned');
|
|
594
|
-
}
|
|
654
|
+
initiatedChecks_1 = _b.sent();
|
|
595
655
|
setLoading(false);
|
|
596
656
|
setPolling(true);
|
|
597
|
-
|
|
598
|
-
var maxAttempts, attempts,
|
|
657
|
+
pollForAllResults = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
658
|
+
var maxAttempts, checkStatuses, attempts, pollAll;
|
|
599
659
|
return __generator(this, function (_a) {
|
|
600
660
|
maxAttempts = 60 // Poll for up to 60 attempts (2 minutes at 2s intervals)
|
|
601
661
|
;
|
|
662
|
+
checkStatuses = new Map(initiatedChecks_1.map(function (check) { return [
|
|
663
|
+
check.serviceTypeId,
|
|
664
|
+
{
|
|
665
|
+
completed: check.error !== undefined || check.serviceEligibilityId === null,
|
|
666
|
+
result: check.error ? { status: 'error', userIds: [], error: check.error } : null,
|
|
667
|
+
serviceEligibilityId: check.serviceEligibilityId,
|
|
668
|
+
}
|
|
669
|
+
]; }));
|
|
602
670
|
attempts = 0;
|
|
603
|
-
|
|
604
|
-
var
|
|
605
|
-
|
|
606
|
-
|
|
671
|
+
pollAll = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
672
|
+
var pollPromises, allCompleted, results, allUserIds, uniqueUserIds, aggregatedStatus;
|
|
673
|
+
var _a;
|
|
674
|
+
return __generator(this, function (_b) {
|
|
675
|
+
switch (_b.label) {
|
|
607
676
|
case 0:
|
|
608
677
|
if (attempts >= maxAttempts) {
|
|
609
678
|
setError('Eligibility check timed out. Please try again.');
|
|
@@ -611,52 +680,99 @@ export var BridgeEligibilityInput = function (_a) {
|
|
|
611
680
|
return [2 /*return*/];
|
|
612
681
|
}
|
|
613
682
|
attempts++;
|
|
614
|
-
|
|
683
|
+
pollPromises = initiatedChecks_1
|
|
684
|
+
.filter(function (check) {
|
|
685
|
+
var status = checkStatuses.get(check.serviceTypeId);
|
|
686
|
+
return check.serviceEligibilityId && status && !status.completed;
|
|
687
|
+
})
|
|
688
|
+
.map(function (check) { return __awaiter(void 0, void 0, void 0, function () {
|
|
689
|
+
var pollData, status_1, checkStatus, err_5, checkStatus;
|
|
690
|
+
return __generator(this, function (_a) {
|
|
691
|
+
switch (_a.label) {
|
|
692
|
+
case 0:
|
|
693
|
+
_a.trys.push([0, 2, , 3]);
|
|
694
|
+
return [4 /*yield*/, session.api.integrations.proxy_read({
|
|
695
|
+
id: check.serviceEligibilityId,
|
|
696
|
+
integration: BRIDGE_TITLE,
|
|
697
|
+
type: 'service-eligibility-poll',
|
|
698
|
+
})];
|
|
699
|
+
case 1:
|
|
700
|
+
pollData = (_a.sent()).data;
|
|
701
|
+
status_1 = pollData === null || pollData === void 0 ? void 0 : pollData.status;
|
|
702
|
+
// Check if we're in a terminal state
|
|
703
|
+
if (status_1 && status_1 !== 'PENDING') {
|
|
704
|
+
checkStatus = checkStatuses.get(check.serviceTypeId);
|
|
705
|
+
checkStatus.completed = true;
|
|
706
|
+
checkStatus.result = {
|
|
707
|
+
status: status_1 || 'unknown',
|
|
708
|
+
userIds: (pollData === null || pollData === void 0 ? void 0 : pollData.userIds) || [],
|
|
709
|
+
error: undefined,
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
return [3 /*break*/, 3];
|
|
713
|
+
case 2:
|
|
714
|
+
err_5 = _a.sent();
|
|
715
|
+
console.error("Service eligibility polling failed for ".concat(check.serviceTypeId, ":"), err_5);
|
|
716
|
+
checkStatus = checkStatuses.get(check.serviceTypeId);
|
|
717
|
+
checkStatus.completed = true;
|
|
718
|
+
checkStatus.result = {
|
|
719
|
+
status: 'error',
|
|
720
|
+
userIds: [],
|
|
721
|
+
error: err_5 === null || err_5 === void 0 ? void 0 : err_5.message,
|
|
722
|
+
};
|
|
723
|
+
return [3 /*break*/, 3];
|
|
724
|
+
case 3: return [2 /*return*/];
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
}); });
|
|
728
|
+
return [4 /*yield*/, Promise.all(pollPromises)
|
|
729
|
+
// Check if all checks are completed
|
|
730
|
+
];
|
|
615
731
|
case 1:
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
732
|
+
_b.sent();
|
|
733
|
+
allCompleted = Array.from(checkStatuses.values()).every(function (s) { return s.completed; });
|
|
734
|
+
if (allCompleted) {
|
|
735
|
+
results = Array.from(checkStatuses.entries()).map(function (_a) {
|
|
736
|
+
var _b, _d;
|
|
737
|
+
var serviceTypeId = _a[0], status = _a[1];
|
|
738
|
+
return ({
|
|
739
|
+
serviceTypeId: serviceTypeId,
|
|
740
|
+
status: ((_b = status.result) === null || _b === void 0 ? void 0 : _b.status) || 'unknown',
|
|
741
|
+
userIds: ((_d = status.result) === null || _d === void 0 ? void 0 : _d.userIds) || [],
|
|
742
|
+
});
|
|
743
|
+
});
|
|
744
|
+
allUserIds = results.flatMap(function (r) { return r.userIds; });
|
|
745
|
+
uniqueUserIds = Array.from(new Set(allUserIds));
|
|
746
|
+
aggregatedStatus = results.some(function (r) { return r.status === 'ELIGIBLE'; })
|
|
747
|
+
? 'ELIGIBLE'
|
|
748
|
+
: ((_a = results.find(function (r) { return r.status !== 'error'; })) === null || _a === void 0 ? void 0 : _a.status) || 'unknown';
|
|
749
|
+
// Store aggregated userIds in shared variable for Appointment Booking to use
|
|
750
|
+
setBridgeEligibilityUserIds(uniqueUserIds);
|
|
751
|
+
// Update the answer with aggregated results
|
|
630
752
|
onChange({
|
|
631
|
-
|
|
632
|
-
|
|
753
|
+
payerId: payerId,
|
|
754
|
+
status: aggregatedStatus,
|
|
755
|
+
userIds: uniqueUserIds,
|
|
633
756
|
}, field.id);
|
|
634
757
|
setPolling(false);
|
|
635
758
|
return [2 /*return*/];
|
|
636
759
|
}
|
|
637
|
-
// Still pending, poll again after delay
|
|
638
|
-
setTimeout(
|
|
639
|
-
return [
|
|
640
|
-
case 3:
|
|
641
|
-
err_3 = _a.sent();
|
|
642
|
-
setError((err_3 === null || err_3 === void 0 ? void 0 : err_3.message) || 'Failed to poll eligibility status');
|
|
643
|
-
console.error('Service eligibility polling failed:', err_3);
|
|
644
|
-
setPolling(false);
|
|
645
|
-
return [3 /*break*/, 4];
|
|
646
|
-
case 4: return [2 /*return*/];
|
|
760
|
+
// Still have pending checks, poll again after delay
|
|
761
|
+
setTimeout(pollAll, 2000); // Poll every 2 seconds
|
|
762
|
+
return [2 /*return*/];
|
|
647
763
|
}
|
|
648
764
|
});
|
|
649
765
|
}); };
|
|
650
|
-
|
|
766
|
+
pollAll();
|
|
651
767
|
return [2 /*return*/];
|
|
652
768
|
});
|
|
653
769
|
}); };
|
|
654
|
-
|
|
770
|
+
pollForAllResults();
|
|
655
771
|
return [3 /*break*/, 4];
|
|
656
772
|
case 3:
|
|
657
|
-
|
|
658
|
-
setError((
|
|
659
|
-
console.error('Service eligibility check failed:',
|
|
773
|
+
err_3 = _b.sent();
|
|
774
|
+
setError((err_3 === null || err_3 === void 0 ? void 0 : err_3.message) || 'Failed to check service eligibility');
|
|
775
|
+
console.error('Service eligibility check failed:', err_3);
|
|
660
776
|
setLoading(false);
|
|
661
777
|
setPolling(false);
|
|
662
778
|
return [3 /*break*/, 4];
|
|
@@ -669,6 +785,10 @@ export var BridgeEligibilityInput = function (_a) {
|
|
|
669
785
|
useEffect(function () {
|
|
670
786
|
if (!isEnduserSession)
|
|
671
787
|
return;
|
|
788
|
+
// If we already have a result and the payer hasn't changed, use the cached result
|
|
789
|
+
if ((value === null || value === void 0 ? void 0 : value.status) && (value === null || value === void 0 ? void 0 : value.payerId) === payerId) {
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
672
792
|
if (autoCheckRef.current)
|
|
673
793
|
return;
|
|
674
794
|
autoCheckRef.current = true;
|
|
@@ -678,7 +798,7 @@ export var BridgeEligibilityInput = function (_a) {
|
|
|
678
798
|
else {
|
|
679
799
|
checkProviderEligibility();
|
|
680
800
|
}
|
|
681
|
-
}, [isEnduserSession, eligibilityType, checkProviderEligibility, checkServiceEligibility]);
|
|
801
|
+
}, [isEnduserSession, eligibilityType, checkProviderEligibility, checkServiceEligibility, value, payerId]);
|
|
682
802
|
var errorComponent = useMemo(function () { return (_jsx(Grid, __assign({ container: true, spacing: 2, direction: "column", alignItems: "center", style: { padding: '20px 0' } }, { children: _jsx(Grid, __assign({ item: true }, { children: _jsx(Paper, __assign({ style: {
|
|
683
803
|
padding: 16,
|
|
684
804
|
backgroundColor: '#ffebee',
|
|
@@ -694,7 +814,7 @@ export var BridgeEligibilityInput = function (_a) {
|
|
|
694
814
|
} }, { children: _jsxs(Grid, __assign({ container: true, spacing: 2, direction: "column", alignItems: "center" }, { children: [_jsx(Grid, __assign({ item: true }, { children: isEligible ? (_jsx(CheckCircleOutline, { style: { fontSize: 48, color: '#4caf50' } })) : (_jsx(Typography, __assign({ variant: "h2", style: { color: '#ff9800' } }, { children: "\u26A0\uFE0F" }))) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ variant: "h6", align: "center" }, { children: isEligible
|
|
695
815
|
? "".concat(payerName || 'Your insurance provider', " is accepted!")
|
|
696
816
|
: 'Eligibility Status: ' + first_letter_capitalized(((value === null || value === void 0 ? void 0 : value.status) || 'Unknown').toLowerCase()) })) }))] })) })) })) })));
|
|
697
|
-
}, [value]);
|
|
817
|
+
}, [value, payerName]);
|
|
698
818
|
// Loading/polling state for enduser sessions
|
|
699
819
|
if (isEnduserSession) {
|
|
700
820
|
if (loading || polling) {
|
|
@@ -709,7 +829,7 @@ export var BridgeEligibilityInput = function (_a) {
|
|
|
709
829
|
return errorComponent;
|
|
710
830
|
}
|
|
711
831
|
// User/admin interface (non-enduser sessions)
|
|
712
|
-
return (_jsxs(Grid, __assign({ container: true, spacing: 2, direction: "column" }, { children: [_jsxs(Grid, __assign({ item: true }, { children: [_jsxs(Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["Eligibility Type: ", eligibilityType] })), _jsxs(Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["Service Type: ", ((_d = field.options) === null || _d === void 0 ? void 0 : _d.
|
|
832
|
+
return (_jsxs(Grid, __assign({ container: true, spacing: 2, direction: "column" }, { children: [_jsxs(Grid, __assign({ item: true }, { children: [_jsxs(Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["Eligibility Type: ", eligibilityType] })), _jsxs(Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["Service Type IDs: ", ((_e = (_d = field.options) === null || _d === void 0 ? void 0 : _d.bridgeServiceTypeIds) === null || _e === void 0 ? void 0 : _e.join(', ')) || 'Not configured'] })), state && _jsxs(Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["State: ", state] })), payerId && _jsxs(Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["Payer ID: ", payerId] })), memberId && _jsxs(Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["Member ID: ", memberId] }))] })), error && (_jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ variant: "body2", color: "error" }, { children: error })) }))), polling && (_jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ variant: "body2", color: "primary" }, { children: "Polling for results... (this may take 15-30 seconds)" })) }))), _jsxs(Grid, __assign({ item: true, container: true, spacing: 2 }, { children: [_jsx(Grid, __assign({ item: true }, { children: _jsx(LoadingButton, { variant: "outlined", onClick: checkProviderEligibility, submitText: "Check Provider Eligibility (Free)", submittingText: "Checking...", submitting: loading && !polling, disabled: !((_g = (_f = field.options) === null || _f === void 0 ? void 0 : _f.bridgeServiceTypeIds) === null || _g === void 0 ? void 0 : _g.length) || loading || polling }) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(LoadingButton, { variant: "outlined", onClick: checkServiceEligibility, submitText: "Check Service Eligibility (Paid)", submittingText: polling ? "Polling..." : "Initiating...", submitting: loading || polling, disabled: !((_j = (_h = field.options) === null || _h === void 0 ? void 0 : _h.bridgeServiceTypeIds) === null || _j === void 0 ? void 0 : _j.length) || loading || polling }) }))] })), value && (_jsxs(Grid, __assign({ item: true }, { children: [_jsx(Typography, __assign({ variant: "caption", color: "textSecondary" }, { children: "Current Answer:" })), _jsx("pre", __assign({ style: { fontSize: 11, whiteSpace: 'pre-wrap', wordBreak: 'break-word' } }, { children: JSON.stringify(value, null, 2) }))] })))] })));
|
|
713
833
|
};
|
|
714
834
|
var HourSelector = function (props) { return (_jsx(StringSelector, __assign({}, props, { options: Array(12).fill('').map(function (_, i) { return (i + 1) <= 9 ? "0".concat(i + 1) : (i + 1).toString(); }) }))); };
|
|
715
835
|
var MinuteSelector = function (props) { return (_jsx(StringSelector, __assign({}, props, { options: Array(60).fill('').map(function (_, i) { return i <= 9 ? "0".concat(i) : i.toString(); }) }))); };
|
|
@@ -2095,7 +2215,7 @@ export var AppointmentBookingInput = function (_a) {
|
|
|
2095
2215
|
var _s = useState(false), confirming = _s[0], setConfirming = _s[1];
|
|
2096
2216
|
var bookingPageId = (_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.bookingPageId;
|
|
2097
2217
|
var downloadICS = useCallback(function (event) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2098
|
-
var _a,
|
|
2218
|
+
var _a, err_6;
|
|
2099
2219
|
return __generator(this, function (_b) {
|
|
2100
2220
|
switch (_b.label) {
|
|
2101
2221
|
case 0:
|
|
@@ -2107,8 +2227,8 @@ export var AppointmentBookingInput = function (_a) {
|
|
|
2107
2227
|
{ name: "event.ics", dataIsURL: true, type: 'text/calendar' }]);
|
|
2108
2228
|
return [3 /*break*/, 3];
|
|
2109
2229
|
case 2:
|
|
2110
|
-
|
|
2111
|
-
console.error(
|
|
2230
|
+
err_6 = _b.sent();
|
|
2231
|
+
console.error(err_6);
|
|
2112
2232
|
return [3 /*break*/, 3];
|
|
2113
2233
|
case 3: return [2 /*return*/];
|
|
2114
2234
|
}
|