@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/cjs/Forms/inputs.js
CHANGED
|
@@ -405,6 +405,7 @@ var InsuranceInput = function (_a) {
|
|
|
405
405
|
var _a, _b, _d;
|
|
406
406
|
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));
|
|
407
407
|
}, [enduser === null || enduser === void 0 ? void 0 : enduser.state, addressQuestion]);
|
|
408
|
+
// load from database
|
|
408
409
|
var loadRef = (0, react_1.useRef)(false); // so session changes don't cause
|
|
409
410
|
(0, react_1.useEffect)(function () {
|
|
410
411
|
var _a, _b;
|
|
@@ -434,6 +435,7 @@ var InsuranceInput = function (_a) {
|
|
|
434
435
|
})
|
|
435
436
|
.catch(console.error);
|
|
436
437
|
}, [session, state, (_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.dataSource]);
|
|
438
|
+
// load from 3rd-party on search only
|
|
437
439
|
var searchRef = (0, react_1.useRef)(query);
|
|
438
440
|
(0, react_1.useEffect)(function () {
|
|
439
441
|
var _a, _b, _d, _e;
|
|
@@ -486,7 +488,8 @@ var InsuranceInput = function (_a) {
|
|
|
486
488
|
if (databaseRecord) {
|
|
487
489
|
onDatabaseSelect === null || onDatabaseSelect === void 0 ? void 0 : onDatabaseSelect([databaseRecord]);
|
|
488
490
|
}
|
|
489
|
-
|
|
491
|
+
// don't lose existing payerId on back-and-forth navigation
|
|
492
|
+
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);
|
|
490
493
|
}, renderInput: function (params) {
|
|
491
494
|
var _a, _b;
|
|
492
495
|
return ((0, jsx_runtime_1.jsx)(material_1.TextField, __assign({}, params, { InputProps: __assign(__assign({}, params.InputProps), { sx: (inputProps || exports.defaultInputProps).sx }), required: !field.isOptional, size: "small", label: "Insurer", placeholder: (((_a = field.options) === null || _a === void 0 ? void 0 : _a.dataSource) === constants_1.CANVAS_TITLE || ((_b = field.options) === null || _b === void 0 ? void 0 : _b.dataSource) === constants_1.BRIDGE_TITLE) ? "Search insurer..." : "Insurer" })));
|
|
@@ -518,17 +521,17 @@ var StringSelector = function (_a) {
|
|
|
518
521
|
}) }))] })));
|
|
519
522
|
};
|
|
520
523
|
var BridgeEligibilityInput = function (_a) {
|
|
521
|
-
var _b, _d, _e, _f;
|
|
524
|
+
var _b, _d, _e, _f, _g, _h, _j;
|
|
522
525
|
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"]);
|
|
523
526
|
var session = (0, __1.useResolvedSession)();
|
|
524
|
-
var
|
|
525
|
-
var
|
|
526
|
-
var
|
|
527
|
+
var _k = (0, react_1.useState)(false), loading = _k[0], setLoading = _k[1];
|
|
528
|
+
var _l = (0, react_1.useState)(false), polling = _l[0], setPolling = _l[1];
|
|
529
|
+
var _m = (0, react_1.useState)(), error = _m[0], setError = _m[1];
|
|
527
530
|
// single-page form must require button-click to check, but 1-page-at-a-time enduser sessions should auto-check
|
|
528
531
|
var isEnduserSession = session.type === 'enduser';
|
|
529
532
|
var eligibilityType = ((_b = field.options) === null || _b === void 0 ? void 0 : _b.bridgeEligibilityType) || 'Soft';
|
|
530
533
|
// Extract payerId from Insurance question response
|
|
531
|
-
var
|
|
534
|
+
var _o = (0, react_1.useMemo)(function () {
|
|
532
535
|
var _a, _b, _d, _e;
|
|
533
536
|
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); });
|
|
534
537
|
if (((_a = insuranceResponse === null || insuranceResponse === void 0 ? void 0 : insuranceResponse.answer) === null || _a === void 0 ? void 0 : _a.type) === 'Insurance') {
|
|
@@ -540,7 +543,7 @@ var BridgeEligibilityInput = function (_a) {
|
|
|
540
543
|
}
|
|
541
544
|
// existing payer id is automatically resolved on the backend as default
|
|
542
545
|
return [];
|
|
543
|
-
}, [responses]), payerId =
|
|
546
|
+
}, [responses]), payerId = _o[0], memberId = _o[1], payerName = _o[2];
|
|
544
547
|
// Extract state from Address question or enduser
|
|
545
548
|
var state = (0, react_1.useMemo)(function () {
|
|
546
549
|
var _a, _b;
|
|
@@ -551,48 +554,80 @@ var BridgeEligibilityInput = function (_a) {
|
|
|
551
554
|
}
|
|
552
555
|
// enduser state is automatically resolved on the backend as default
|
|
553
556
|
}, [responses]);
|
|
554
|
-
// Soft eligibility check function
|
|
557
|
+
// Soft eligibility check function - supports multiple service type IDs
|
|
555
558
|
var checkProviderEligibility = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
556
|
-
var
|
|
557
|
-
var _a;
|
|
558
|
-
return __generator(this, function (
|
|
559
|
-
switch (
|
|
559
|
+
var serviceTypeIds, results, allUserIds, uniqueUserIds, aggregatedStatus, err_1;
|
|
560
|
+
var _a, _b;
|
|
561
|
+
return __generator(this, function (_d) {
|
|
562
|
+
switch (_d.label) {
|
|
560
563
|
case 0:
|
|
561
|
-
|
|
562
|
-
if (!
|
|
563
|
-
setError('Bridge Service Type
|
|
564
|
+
serviceTypeIds = (_a = field.options) === null || _a === void 0 ? void 0 : _a.bridgeServiceTypeIds;
|
|
565
|
+
if (!serviceTypeIds || serviceTypeIds.length === 0) {
|
|
566
|
+
setError('Bridge Service Type IDs not configured');
|
|
564
567
|
return [2 /*return*/];
|
|
565
568
|
}
|
|
566
569
|
// payerId and state can be automatically resolved on the backend, if already saved on Enduser, so not required here
|
|
567
570
|
setLoading(true);
|
|
568
571
|
setError(undefined);
|
|
569
|
-
|
|
572
|
+
_d.label = 1;
|
|
570
573
|
case 1:
|
|
571
|
-
|
|
572
|
-
return [4 /*yield*/,
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
574
|
+
_d.trys.push([1, 3, 4, 5]);
|
|
575
|
+
return [4 /*yield*/, Promise.all(serviceTypeIds.map(function (serviceTypeId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
576
|
+
var data, err_2;
|
|
577
|
+
return __generator(this, function (_a) {
|
|
578
|
+
switch (_a.label) {
|
|
579
|
+
case 0:
|
|
580
|
+
_a.trys.push([0, 2, , 3]);
|
|
581
|
+
return [4 /*yield*/, session.api.integrations.proxy_read({
|
|
582
|
+
id: enduserId,
|
|
583
|
+
integration: constants_1.BRIDGE_TITLE,
|
|
584
|
+
type: 'provider-eligibility',
|
|
585
|
+
query: JSON.stringify({
|
|
586
|
+
serviceTypeId: serviceTypeId,
|
|
587
|
+
payerId: payerId,
|
|
588
|
+
state: state,
|
|
589
|
+
}),
|
|
590
|
+
})];
|
|
591
|
+
case 1:
|
|
592
|
+
data = (_a.sent()).data;
|
|
593
|
+
return [2 /*return*/, {
|
|
594
|
+
serviceTypeId: serviceTypeId,
|
|
595
|
+
status: (data === null || data === void 0 ? void 0 : data.status) || 'unknown',
|
|
596
|
+
userIds: (data === null || data === void 0 ? void 0 : data.userIds) || [],
|
|
597
|
+
}];
|
|
598
|
+
case 2:
|
|
599
|
+
err_2 = _a.sent();
|
|
600
|
+
console.error("Provider eligibility check failed for ".concat(serviceTypeId, ":"), err_2);
|
|
601
|
+
return [2 /*return*/, {
|
|
602
|
+
serviceTypeId: serviceTypeId,
|
|
603
|
+
status: 'error',
|
|
604
|
+
userIds: [],
|
|
605
|
+
error: err_2 === null || err_2 === void 0 ? void 0 : err_2.message,
|
|
606
|
+
}];
|
|
607
|
+
case 3: return [2 /*return*/];
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
}); }))
|
|
611
|
+
// Aggregate results - union of userIds across all service types
|
|
583
612
|
];
|
|
584
613
|
case 2:
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
614
|
+
results = _d.sent();
|
|
615
|
+
allUserIds = results.flatMap(function (r) { return r.userIds; });
|
|
616
|
+
uniqueUserIds = Array.from(new Set(allUserIds));
|
|
617
|
+
aggregatedStatus = results.some(function (r) { return r.status === 'ELIGIBLE'; })
|
|
618
|
+
? 'ELIGIBLE'
|
|
619
|
+
: ((_b = results.find(function (r) { return r.status !== 'error'; })) === null || _b === void 0 ? void 0 : _b.status) || 'unknown';
|
|
620
|
+
// Store aggregated userIds in shared variable for Appointment Booking to use
|
|
621
|
+
(0, exports.setBridgeEligibilityUserIds)(uniqueUserIds);
|
|
622
|
+
// Update the answer with aggregated results
|
|
589
623
|
onChange({
|
|
590
|
-
|
|
591
|
-
|
|
624
|
+
payerId: payerId,
|
|
625
|
+
status: aggregatedStatus,
|
|
626
|
+
userIds: uniqueUserIds,
|
|
592
627
|
}, field.id);
|
|
593
628
|
return [3 /*break*/, 5];
|
|
594
629
|
case 3:
|
|
595
|
-
err_1 =
|
|
630
|
+
err_1 = _d.sent();
|
|
596
631
|
setError((err_1 === null || err_1 === void 0 ? void 0 : err_1.message) || 'Failed to check eligibility');
|
|
597
632
|
console.error('Provider eligibility check failed:', err_1);
|
|
598
633
|
return [3 /*break*/, 5];
|
|
@@ -603,16 +638,16 @@ var BridgeEligibilityInput = function (_a) {
|
|
|
603
638
|
}
|
|
604
639
|
});
|
|
605
640
|
}); }, [session, field, payerId, state, onChange, enduserId]);
|
|
606
|
-
// Hard eligibility check function with polling
|
|
641
|
+
// Hard eligibility check function with polling - supports multiple service type IDs
|
|
607
642
|
var checkServiceEligibility = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
608
|
-
var
|
|
643
|
+
var serviceTypeIds, initiatedChecks_1, pollForAllResults, err_3;
|
|
609
644
|
var _a;
|
|
610
645
|
return __generator(this, function (_b) {
|
|
611
646
|
switch (_b.label) {
|
|
612
647
|
case 0:
|
|
613
|
-
|
|
614
|
-
if (!
|
|
615
|
-
setError('Bridge Service Type
|
|
648
|
+
serviceTypeIds = (_a = field.options) === null || _a === void 0 ? void 0 : _a.bridgeServiceTypeIds;
|
|
649
|
+
if (!serviceTypeIds || serviceTypeIds.length === 0) {
|
|
650
|
+
setError('Bridge Service Type IDs not configured');
|
|
616
651
|
return [2 /*return*/];
|
|
617
652
|
}
|
|
618
653
|
setLoading(true);
|
|
@@ -620,35 +655,69 @@ var BridgeEligibilityInput = function (_a) {
|
|
|
620
655
|
_b.label = 1;
|
|
621
656
|
case 1:
|
|
622
657
|
_b.trys.push([1, 3, , 4]);
|
|
623
|
-
return [4 /*yield*/,
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
658
|
+
return [4 /*yield*/, Promise.all(serviceTypeIds.map(function (serviceTypeId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
659
|
+
var data, serviceEligibilityId, err_4;
|
|
660
|
+
return __generator(this, function (_a) {
|
|
661
|
+
switch (_a.label) {
|
|
662
|
+
case 0:
|
|
663
|
+
_a.trys.push([0, 2, , 3]);
|
|
664
|
+
return [4 /*yield*/, session.api.integrations.proxy_read({
|
|
665
|
+
id: enduserId,
|
|
666
|
+
integration: constants_1.BRIDGE_TITLE,
|
|
667
|
+
type: 'service-eligibility',
|
|
668
|
+
query: JSON.stringify({
|
|
669
|
+
serviceTypeId: serviceTypeId,
|
|
670
|
+
payerId: payerId,
|
|
671
|
+
memberId: memberId,
|
|
672
|
+
state: state,
|
|
673
|
+
}),
|
|
674
|
+
})];
|
|
675
|
+
case 1:
|
|
676
|
+
data = (_a.sent()).data;
|
|
677
|
+
serviceEligibilityId = data === null || data === void 0 ? void 0 : data.id;
|
|
678
|
+
if (!serviceEligibilityId) {
|
|
679
|
+
throw new Error('No service eligibility ID returned');
|
|
680
|
+
}
|
|
681
|
+
return [2 /*return*/, {
|
|
682
|
+
serviceTypeId: serviceTypeId,
|
|
683
|
+
serviceEligibilityId: serviceEligibilityId,
|
|
684
|
+
error: undefined,
|
|
685
|
+
}];
|
|
686
|
+
case 2:
|
|
687
|
+
err_4 = _a.sent();
|
|
688
|
+
console.error("Service eligibility check initiation failed for ".concat(serviceTypeId, ":"), err_4);
|
|
689
|
+
return [2 /*return*/, {
|
|
690
|
+
serviceTypeId: serviceTypeId,
|
|
691
|
+
serviceEligibilityId: null,
|
|
692
|
+
error: err_4 === null || err_4 === void 0 ? void 0 : err_4.message,
|
|
693
|
+
}];
|
|
694
|
+
case 3: return [2 /*return*/];
|
|
695
|
+
}
|
|
696
|
+
});
|
|
697
|
+
}); }))];
|
|
634
698
|
case 2:
|
|
635
|
-
|
|
636
|
-
serviceEligibilityId_1 = data === null || data === void 0 ? void 0 : data.id;
|
|
637
|
-
if (!serviceEligibilityId_1) {
|
|
638
|
-
throw new Error('No service eligibility ID returned');
|
|
639
|
-
}
|
|
699
|
+
initiatedChecks_1 = _b.sent();
|
|
640
700
|
setLoading(false);
|
|
641
701
|
setPolling(true);
|
|
642
|
-
|
|
643
|
-
var maxAttempts, attempts,
|
|
702
|
+
pollForAllResults = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
703
|
+
var maxAttempts, checkStatuses, attempts, pollAll;
|
|
644
704
|
return __generator(this, function (_a) {
|
|
645
705
|
maxAttempts = 60 // Poll for up to 60 attempts (2 minutes at 2s intervals)
|
|
646
706
|
;
|
|
707
|
+
checkStatuses = new Map(initiatedChecks_1.map(function (check) { return [
|
|
708
|
+
check.serviceTypeId,
|
|
709
|
+
{
|
|
710
|
+
completed: check.error !== undefined || check.serviceEligibilityId === null,
|
|
711
|
+
result: check.error ? { status: 'error', userIds: [], error: check.error } : null,
|
|
712
|
+
serviceEligibilityId: check.serviceEligibilityId,
|
|
713
|
+
}
|
|
714
|
+
]; }));
|
|
647
715
|
attempts = 0;
|
|
648
|
-
|
|
649
|
-
var
|
|
650
|
-
|
|
651
|
-
|
|
716
|
+
pollAll = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
717
|
+
var pollPromises, allCompleted, results, allUserIds, uniqueUserIds, aggregatedStatus;
|
|
718
|
+
var _a;
|
|
719
|
+
return __generator(this, function (_b) {
|
|
720
|
+
switch (_b.label) {
|
|
652
721
|
case 0:
|
|
653
722
|
if (attempts >= maxAttempts) {
|
|
654
723
|
setError('Eligibility check timed out. Please try again.');
|
|
@@ -656,52 +725,99 @@ var BridgeEligibilityInput = function (_a) {
|
|
|
656
725
|
return [2 /*return*/];
|
|
657
726
|
}
|
|
658
727
|
attempts++;
|
|
659
|
-
|
|
728
|
+
pollPromises = initiatedChecks_1
|
|
729
|
+
.filter(function (check) {
|
|
730
|
+
var status = checkStatuses.get(check.serviceTypeId);
|
|
731
|
+
return check.serviceEligibilityId && status && !status.completed;
|
|
732
|
+
})
|
|
733
|
+
.map(function (check) { return __awaiter(void 0, void 0, void 0, function () {
|
|
734
|
+
var pollData, status_1, checkStatus, err_5, checkStatus;
|
|
735
|
+
return __generator(this, function (_a) {
|
|
736
|
+
switch (_a.label) {
|
|
737
|
+
case 0:
|
|
738
|
+
_a.trys.push([0, 2, , 3]);
|
|
739
|
+
return [4 /*yield*/, session.api.integrations.proxy_read({
|
|
740
|
+
id: check.serviceEligibilityId,
|
|
741
|
+
integration: constants_1.BRIDGE_TITLE,
|
|
742
|
+
type: 'service-eligibility-poll',
|
|
743
|
+
})];
|
|
744
|
+
case 1:
|
|
745
|
+
pollData = (_a.sent()).data;
|
|
746
|
+
status_1 = pollData === null || pollData === void 0 ? void 0 : pollData.status;
|
|
747
|
+
// Check if we're in a terminal state
|
|
748
|
+
if (status_1 && status_1 !== 'PENDING') {
|
|
749
|
+
checkStatus = checkStatuses.get(check.serviceTypeId);
|
|
750
|
+
checkStatus.completed = true;
|
|
751
|
+
checkStatus.result = {
|
|
752
|
+
status: status_1 || 'unknown',
|
|
753
|
+
userIds: (pollData === null || pollData === void 0 ? void 0 : pollData.userIds) || [],
|
|
754
|
+
error: undefined,
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
return [3 /*break*/, 3];
|
|
758
|
+
case 2:
|
|
759
|
+
err_5 = _a.sent();
|
|
760
|
+
console.error("Service eligibility polling failed for ".concat(check.serviceTypeId, ":"), err_5);
|
|
761
|
+
checkStatus = checkStatuses.get(check.serviceTypeId);
|
|
762
|
+
checkStatus.completed = true;
|
|
763
|
+
checkStatus.result = {
|
|
764
|
+
status: 'error',
|
|
765
|
+
userIds: [],
|
|
766
|
+
error: err_5 === null || err_5 === void 0 ? void 0 : err_5.message,
|
|
767
|
+
};
|
|
768
|
+
return [3 /*break*/, 3];
|
|
769
|
+
case 3: return [2 /*return*/];
|
|
770
|
+
}
|
|
771
|
+
});
|
|
772
|
+
}); });
|
|
773
|
+
return [4 /*yield*/, Promise.all(pollPromises)
|
|
774
|
+
// Check if all checks are completed
|
|
775
|
+
];
|
|
660
776
|
case 1:
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
(
|
|
674
|
-
|
|
777
|
+
_b.sent();
|
|
778
|
+
allCompleted = Array.from(checkStatuses.values()).every(function (s) { return s.completed; });
|
|
779
|
+
if (allCompleted) {
|
|
780
|
+
results = Array.from(checkStatuses.entries()).map(function (_a) {
|
|
781
|
+
var _b, _d;
|
|
782
|
+
var serviceTypeId = _a[0], status = _a[1];
|
|
783
|
+
return ({
|
|
784
|
+
serviceTypeId: serviceTypeId,
|
|
785
|
+
status: ((_b = status.result) === null || _b === void 0 ? void 0 : _b.status) || 'unknown',
|
|
786
|
+
userIds: ((_d = status.result) === null || _d === void 0 ? void 0 : _d.userIds) || [],
|
|
787
|
+
});
|
|
788
|
+
});
|
|
789
|
+
allUserIds = results.flatMap(function (r) { return r.userIds; });
|
|
790
|
+
uniqueUserIds = Array.from(new Set(allUserIds));
|
|
791
|
+
aggregatedStatus = results.some(function (r) { return r.status === 'ELIGIBLE'; })
|
|
792
|
+
? 'ELIGIBLE'
|
|
793
|
+
: ((_a = results.find(function (r) { return r.status !== 'error'; })) === null || _a === void 0 ? void 0 : _a.status) || 'unknown';
|
|
794
|
+
// Store aggregated userIds in shared variable for Appointment Booking to use
|
|
795
|
+
(0, exports.setBridgeEligibilityUserIds)(uniqueUserIds);
|
|
796
|
+
// Update the answer with aggregated results
|
|
675
797
|
onChange({
|
|
676
|
-
|
|
677
|
-
|
|
798
|
+
payerId: payerId,
|
|
799
|
+
status: aggregatedStatus,
|
|
800
|
+
userIds: uniqueUserIds,
|
|
678
801
|
}, field.id);
|
|
679
802
|
setPolling(false);
|
|
680
803
|
return [2 /*return*/];
|
|
681
804
|
}
|
|
682
|
-
// Still pending, poll again after delay
|
|
683
|
-
setTimeout(
|
|
684
|
-
return [
|
|
685
|
-
case 3:
|
|
686
|
-
err_3 = _a.sent();
|
|
687
|
-
setError((err_3 === null || err_3 === void 0 ? void 0 : err_3.message) || 'Failed to poll eligibility status');
|
|
688
|
-
console.error('Service eligibility polling failed:', err_3);
|
|
689
|
-
setPolling(false);
|
|
690
|
-
return [3 /*break*/, 4];
|
|
691
|
-
case 4: return [2 /*return*/];
|
|
805
|
+
// Still have pending checks, poll again after delay
|
|
806
|
+
setTimeout(pollAll, 2000); // Poll every 2 seconds
|
|
807
|
+
return [2 /*return*/];
|
|
692
808
|
}
|
|
693
809
|
});
|
|
694
810
|
}); };
|
|
695
|
-
|
|
811
|
+
pollAll();
|
|
696
812
|
return [2 /*return*/];
|
|
697
813
|
});
|
|
698
814
|
}); };
|
|
699
|
-
|
|
815
|
+
pollForAllResults();
|
|
700
816
|
return [3 /*break*/, 4];
|
|
701
817
|
case 3:
|
|
702
|
-
|
|
703
|
-
setError((
|
|
704
|
-
console.error('Service eligibility check failed:',
|
|
818
|
+
err_3 = _b.sent();
|
|
819
|
+
setError((err_3 === null || err_3 === void 0 ? void 0 : err_3.message) || 'Failed to check service eligibility');
|
|
820
|
+
console.error('Service eligibility check failed:', err_3);
|
|
705
821
|
setLoading(false);
|
|
706
822
|
setPolling(false);
|
|
707
823
|
return [3 /*break*/, 4];
|
|
@@ -714,6 +830,10 @@ var BridgeEligibilityInput = function (_a) {
|
|
|
714
830
|
(0, react_1.useEffect)(function () {
|
|
715
831
|
if (!isEnduserSession)
|
|
716
832
|
return;
|
|
833
|
+
// If we already have a result and the payer hasn't changed, use the cached result
|
|
834
|
+
if ((value === null || value === void 0 ? void 0 : value.status) && (value === null || value === void 0 ? void 0 : value.payerId) === payerId) {
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
717
837
|
if (autoCheckRef.current)
|
|
718
838
|
return;
|
|
719
839
|
autoCheckRef.current = true;
|
|
@@ -723,7 +843,7 @@ var BridgeEligibilityInput = function (_a) {
|
|
|
723
843
|
else {
|
|
724
844
|
checkProviderEligibility();
|
|
725
845
|
}
|
|
726
|
-
}, [isEnduserSession, eligibilityType, checkProviderEligibility, checkServiceEligibility]);
|
|
846
|
+
}, [isEnduserSession, eligibilityType, checkProviderEligibility, checkServiceEligibility, value, payerId]);
|
|
727
847
|
var errorComponent = (0, react_1.useMemo)(function () { return ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ container: true, spacing: 2, direction: "column", alignItems: "center", style: { padding: '20px 0' } }, { children: (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Paper, __assign({ style: {
|
|
728
848
|
padding: 16,
|
|
729
849
|
backgroundColor: '#ffebee',
|
|
@@ -739,7 +859,7 @@ var BridgeEligibilityInput = function (_a) {
|
|
|
739
859
|
} }, { children: (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, spacing: 2, direction: "column", alignItems: "center" }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: isEligible ? ((0, jsx_runtime_1.jsx)(icons_material_1.CheckCircleOutline, { style: { fontSize: 48, color: '#4caf50' } })) : ((0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "h2", style: { color: '#ff9800' } }, { children: "\u26A0\uFE0F" }))) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "h6", align: "center" }, { children: isEligible
|
|
740
860
|
? "".concat(payerName || 'Your insurance provider', " is accepted!")
|
|
741
861
|
: 'Eligibility Status: ' + (0, utilities_1.first_letter_capitalized)(((value === null || value === void 0 ? void 0 : value.status) || 'Unknown').toLowerCase()) })) }))] })) })) })) })));
|
|
742
|
-
}, [value]);
|
|
862
|
+
}, [value, payerName]);
|
|
743
863
|
// Loading/polling state for enduser sessions
|
|
744
864
|
if (isEnduserSession) {
|
|
745
865
|
if (loading || polling) {
|
|
@@ -754,7 +874,7 @@ var BridgeEligibilityInput = function (_a) {
|
|
|
754
874
|
return errorComponent;
|
|
755
875
|
}
|
|
756
876
|
// User/admin interface (non-enduser sessions)
|
|
757
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, spacing: 2, direction: "column" }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ item: true }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["Eligibility Type: ", eligibilityType] })), (0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["Service Type: ", ((_d = field.options) === null || _d === void 0 ? void 0 : _d.
|
|
877
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, spacing: 2, direction: "column" }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ item: true }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["Eligibility Type: ", eligibilityType] })), (0, jsx_runtime_1.jsxs)(material_1.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 && (0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["State: ", state] })), payerId && (0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["Payer ID: ", payerId] })), memberId && (0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["Member ID: ", memberId] }))] })), error && ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "error" }, { children: error })) }))), polling && ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "primary" }, { children: "Polling for results... (this may take 15-30 seconds)" })) }))), (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ item: true, container: true, spacing: 2 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(__1.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 }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(__1.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 && ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ item: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "caption", color: "textSecondary" }, { children: "Current Answer:" })), (0, jsx_runtime_1.jsx)("pre", __assign({ style: { fontSize: 11, whiteSpace: 'pre-wrap', wordBreak: 'break-word' } }, { children: JSON.stringify(value, null, 2) }))] })))] })));
|
|
758
878
|
};
|
|
759
879
|
exports.BridgeEligibilityInput = BridgeEligibilityInput;
|
|
760
880
|
var HourSelector = function (props) { return ((0, jsx_runtime_1.jsx)(StringSelector, __assign({}, props, { options: Array(12).fill('').map(function (_, i) { return (i + 1) <= 9 ? "0".concat(i + 1) : (i + 1).toString(); }) }))); };
|
|
@@ -2160,7 +2280,7 @@ var AppointmentBookingInput = function (_a) {
|
|
|
2160
2280
|
var _s = (0, react_1.useState)(false), confirming = _s[0], setConfirming = _s[1];
|
|
2161
2281
|
var bookingPageId = (_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.bookingPageId;
|
|
2162
2282
|
var downloadICS = (0, react_1.useCallback)(function (event) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2163
|
-
var _a,
|
|
2283
|
+
var _a, err_6;
|
|
2164
2284
|
return __generator(this, function (_b) {
|
|
2165
2285
|
switch (_b.label) {
|
|
2166
2286
|
case 0:
|
|
@@ -2172,8 +2292,8 @@ var AppointmentBookingInput = function (_a) {
|
|
|
2172
2292
|
{ name: "event.ics", dataIsURL: true, type: 'text/calendar' }]);
|
|
2173
2293
|
return [3 /*break*/, 3];
|
|
2174
2294
|
case 2:
|
|
2175
|
-
|
|
2176
|
-
console.error(
|
|
2295
|
+
err_6 = _b.sent();
|
|
2296
|
+
console.error(err_6);
|
|
2177
2297
|
return [3 /*break*/, 3];
|
|
2178
2298
|
case 3: return [2 /*return*/];
|
|
2179
2299
|
}
|