@tellescope/react-components 1.243.0 → 1.244.0

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.
Files changed (78) hide show
  1. package/lib/cjs/Forms/forms.d.ts +1 -0
  2. package/lib/cjs/Forms/forms.d.ts.map +1 -1
  3. package/lib/cjs/Forms/forms.js +39 -37
  4. package/lib/cjs/Forms/forms.js.map +1 -1
  5. package/lib/cjs/Forms/forms.v2.d.ts +1 -0
  6. package/lib/cjs/Forms/forms.v2.d.ts.map +1 -1
  7. package/lib/cjs/Forms/forms.v2.js +47 -40
  8. package/lib/cjs/Forms/forms.v2.js.map +1 -1
  9. package/lib/cjs/Forms/hooks.d.ts +1 -0
  10. package/lib/cjs/Forms/hooks.d.ts.map +1 -1
  11. package/lib/cjs/Forms/hooks.js +71 -28
  12. package/lib/cjs/Forms/hooks.js.map +1 -1
  13. package/lib/cjs/Forms/inputs.d.ts +5 -0
  14. package/lib/cjs/Forms/inputs.d.ts.map +1 -1
  15. package/lib/cjs/Forms/inputs.js +202 -12
  16. package/lib/cjs/Forms/inputs.js.map +1 -1
  17. package/lib/cjs/Forms/inputs.v2.d.ts +1 -0
  18. package/lib/cjs/Forms/inputs.v2.d.ts.map +1 -1
  19. package/lib/cjs/Forms/inputs.v2.js +16 -6
  20. package/lib/cjs/Forms/inputs.v2.js.map +1 -1
  21. package/lib/cjs/forms.d.ts +2 -1
  22. package/lib/cjs/forms.d.ts.map +1 -1
  23. package/lib/cjs/forms.js +2 -2
  24. package/lib/cjs/forms.js.map +1 -1
  25. package/lib/cjs/inputs_shared.d.ts +1 -0
  26. package/lib/cjs/inputs_shared.d.ts.map +1 -1
  27. package/lib/cjs/inputs_shared.js +27 -3
  28. package/lib/cjs/inputs_shared.js.map +1 -1
  29. package/lib/esm/CMS/components.d.ts +0 -1
  30. package/lib/esm/CMS/components.d.ts.map +1 -1
  31. package/lib/esm/Forms/form_responses.d.ts +0 -1
  32. package/lib/esm/Forms/form_responses.d.ts.map +1 -1
  33. package/lib/esm/Forms/forms.d.ts +4 -3
  34. package/lib/esm/Forms/forms.d.ts.map +1 -1
  35. package/lib/esm/Forms/forms.js +40 -38
  36. package/lib/esm/Forms/forms.js.map +1 -1
  37. package/lib/esm/Forms/forms.v2.d.ts +4 -3
  38. package/lib/esm/Forms/forms.v2.d.ts.map +1 -1
  39. package/lib/esm/Forms/forms.v2.js +48 -41
  40. package/lib/esm/Forms/forms.v2.js.map +1 -1
  41. package/lib/esm/Forms/hooks.d.ts +3 -2
  42. package/lib/esm/Forms/hooks.d.ts.map +1 -1
  43. package/lib/esm/Forms/hooks.js +70 -28
  44. package/lib/esm/Forms/hooks.js.map +1 -1
  45. package/lib/esm/Forms/inputs.d.ts +8 -3
  46. package/lib/esm/Forms/inputs.d.ts.map +1 -1
  47. package/lib/esm/Forms/inputs.js +202 -13
  48. package/lib/esm/Forms/inputs.js.map +1 -1
  49. package/lib/esm/Forms/inputs.native.d.ts +0 -1
  50. package/lib/esm/Forms/inputs.native.d.ts.map +1 -1
  51. package/lib/esm/Forms/inputs.v2.d.ts +2 -1
  52. package/lib/esm/Forms/inputs.v2.d.ts.map +1 -1
  53. package/lib/esm/Forms/inputs.v2.js +16 -7
  54. package/lib/esm/Forms/inputs.v2.js.map +1 -1
  55. package/lib/esm/controls.d.ts +2 -2
  56. package/lib/esm/forms.d.ts +2 -1
  57. package/lib/esm/forms.d.ts.map +1 -1
  58. package/lib/esm/forms.js +2 -2
  59. package/lib/esm/forms.js.map +1 -1
  60. package/lib/esm/inputs.d.ts +1 -1
  61. package/lib/esm/inputs.native.d.ts +0 -1
  62. package/lib/esm/inputs.native.d.ts.map +1 -1
  63. package/lib/esm/inputs_shared.d.ts +1 -0
  64. package/lib/esm/inputs_shared.d.ts.map +1 -1
  65. package/lib/esm/inputs_shared.js +28 -4
  66. package/lib/esm/inputs_shared.js.map +1 -1
  67. package/lib/esm/state.d.ts +347 -347
  68. package/lib/esm/theme.native.d.ts +0 -1
  69. package/lib/esm/theme.native.d.ts.map +1 -1
  70. package/lib/tsconfig.tsbuildinfo +1 -1
  71. package/package.json +9 -9
  72. package/src/Forms/forms.tsx +10 -2
  73. package/src/Forms/forms.v2.tsx +29 -3
  74. package/src/Forms/hooks.tsx +46 -1
  75. package/src/Forms/inputs.tsx +304 -6
  76. package/src/Forms/inputs.v2.tsx +19 -4
  77. package/src/forms.tsx +3 -1
  78. package/src/inputs_shared.tsx +39 -5
@@ -97,7 +97,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
97
97
  return (mod && mod.__esModule) ? mod : { "default": mod };
98
98
  };
99
99
  Object.defineProperty(exports, "__esModule", { value: true });
100
- exports.ChargeebeeInput = exports.RichTextInput = exports.ConditionsInput = exports.AllergiesInput = exports.EmotiiInput = exports.HiddenValueInput = exports.RedirectInput = exports.include_current_url_parameters_if_templated = exports.HeightInput = exports.AppointmentBookingInput = exports.RelatedContactsInput = exports.contact_is_valid = exports.BelugaPatientPreferenceInput = exports.MedicationsInput = exports.CanvasMedicationsInput = exports.DatabaseSelectInput = exports.DropdownInput = exports.Progress = exports.StripeInput = exports.MultipleChoiceInput = exports.FilesInput = exports.safe_create_url = exports.FileInput = exports.convertHEIC = exports.SignatureInput = exports.ESignatureTerms = exports.AddressInput = exports.TimezoneInput = exports.TimeInput = exports.PharmacySearchInput = exports.BridgeEligibilityInput = exports.InsuranceInput = exports.NumberInput = exports.EmailInput = exports.PhoneInput = exports.StringLongInput = exports.StringInput = exports.DateStringInput = exports.AutoFocusTextField = exports.TableInput = exports.DateInput = exports.RankingInput = exports.RatingInput = exports.PdfViewer = exports.defaultButtonStyles = exports.defaultInputProps = exports.LanguageSelect = exports.setBridgeEligibilityUserIds = exports.getBridgeEligibilityUserIds = void 0;
100
+ exports.ChargeebeeInput = exports.RichTextInput = exports.ConditionsInput = exports.AllergiesInput = exports.EmotiiInput = exports.HiddenValueInput = exports.RedirectInput = exports.include_current_url_parameters_if_templated = exports.HeightInput = exports.AppointmentBookingInput = exports.RelatedContactsInput = exports.contact_is_valid = exports.BelugaPatientPreferenceInput = exports.MedicationsInput = exports.CanvasMedicationsInput = exports.DatabaseSelectInput = exports.DropdownInput = exports.Progress = exports.StripeInput = exports.MultipleChoiceInput = exports.FilesInput = exports.safe_create_url = exports.FileInput = exports.convertHEIC = exports.SignatureInput = exports.ESignatureTerms = exports.AddressInput = exports.TimezoneInput = exports.TimeInput = exports.PharmacySearchInput = exports.CandidEligibilityInput = exports.BridgeEligibilityInput = exports.InsuranceInput = exports.NumberInput = exports.EmailInput = exports.PhoneInput = exports.StringLongInput = exports.StringInput = exports.DateStringInput = exports.AutoFocusTextField = exports.TableInput = exports.DateInput = exports.RankingInput = exports.RatingInput = exports.PdfViewer = exports.defaultButtonStyles = exports.defaultInputProps = exports.LanguageSelect = exports.setBridgeEligibilityUserIds = exports.getBridgeEligibilityUserIds = void 0;
101
101
  var jsx_runtime_1 = require("react/jsx-runtime");
102
102
  var react_1 = __importStar(require("react"));
103
103
  var axios_1 = __importDefault(require("axios"));
@@ -230,12 +230,15 @@ var RankingInput = function (_a) {
230
230
  exports.RankingInput = RankingInput;
231
231
  var CustomDateInput = (0, react_1.forwardRef)(function (props, ref) { return ((0, jsx_runtime_1.jsx)(material_1.TextField, __assign({ InputProps: exports.defaultInputProps, fullWidth: true, inputRef: ref }, props))); });
232
232
  var DateInput = function (_a) {
233
- var field = _a.field, value = _a.value, onChange = _a.onChange, _b = _a.placement, placement = _b === void 0 ? 'top' : _b, props = __rest(_a, ["field", "value", "onChange", "placement"]);
233
+ var _b, _d;
234
+ var field = _a.field, value = _a.value, onChange = _a.onChange, _e = _a.placement, placement = _e === void 0 ? 'top' : _e, props = __rest(_a, ["field", "value", "onChange", "placement"]);
234
235
  var inputRef = (0, react_1.useRef)(null);
236
+ var minDate = ((_b = field.options) === null || _b === void 0 ? void 0 : _b.minDateOffsetMs) !== undefined ? (0, hooks_1.dateFromOffsetMs)(field.options.minDateOffsetMs) : undefined;
237
+ var maxDate = ((_d = field.options) === null || _d === void 0 ? void 0 : _d.maxDateOffsetMs) !== undefined ? (0, hooks_1.dateFromOffsetMs)(field.options.maxDateOffsetMs) : undefined;
235
238
  return ((0, jsx_runtime_1.jsx)(react_datepicker_1.default // wrap in item to prevent movement on focused
236
239
  , { selected: value, onChange: function (d) { return onChange === null || onChange === void 0 ? void 0 : onChange(d, field.id); }, showTimeSelect: true, required: !field.isOptional, dateFormat: "Pp", autoComplete: "off", timeIntervals: 15, popperPlacement: placement, customInput: (0, jsx_runtime_1.jsx)(CustomDateInput, __assign({ inputRef: inputRef }, props)),
237
240
  // className={css`width: 100%;`}
238
- className: (0, css_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["", ""], ["", ""])), react_datepicker_2.datepickerCSS) }));
241
+ className: (0, css_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["", ""], ["", ""])), react_datepicker_2.datepickerCSS), minDate: minDate, maxDate: maxDate }));
239
242
  };
240
243
  exports.DateInput = DateInput;
241
244
  var TableInput = function (_a) {
@@ -301,16 +304,18 @@ var CustomDateStringInput = (0, react_1.forwardRef)(function (props, ref) {
301
304
  return ((0, jsx_runtime_1.jsx)(material_1.TextField, __assign({ InputProps: inputProps || exports.defaultInputProps, fullWidth: true, inputRef: ref }, textFieldProps)));
302
305
  });
303
306
  var DateStringInput = function (_a) {
304
- var _b;
307
+ var _b, _d, _e;
305
308
  var field = _a.field, value = _a.value, onChange = _a.onChange, form = _a.form, props = __rest(_a, ["field", "value", "onChange", "form"]);
306
309
  var inputRef = (0, react_1.useRef)(null);
310
+ var minDate = ((_b = field.options) === null || _b === void 0 ? void 0 : _b.minDateOffsetMs) !== undefined ? (0, hooks_1.dateFromOffsetMs)(field.options.minDateOffsetMs) : undefined;
311
+ var maxDate = ((_d = field.options) === null || _d === void 0 ? void 0 : _d.maxDateOffsetMs) !== undefined ? (0, hooks_1.dateFromOffsetMs)(field.options.maxDateOffsetMs) : undefined;
307
312
  // if (value && isDateString(value)) {
308
313
  // console.log(value, new Date(
309
314
  // new Date(MM_DD_YYYY_to_YYYY_MM_DD(value)).getTime()
310
315
  // + (new Date().getTimezoneOffset() * 60 * 1000)
311
316
  // ))
312
317
  // }
313
- return (((_b = field.options) === null || _b === void 0 ? void 0 : _b.useDatePicker)
318
+ return (((_e = field.options) === null || _e === void 0 ? void 0 : _e.useDatePicker)
314
319
  ? ((0, jsx_runtime_1.jsx)(react_datepicker_1.default // wrap in item to prevent movement on focused
315
320
  , { selected: (value && (0, __1.isDateString)(value))
316
321
  ? new Date(new Date((0, utilities_1.MM_DD_YYYY_to_YYYY_MM_DD)(value)).getTime()
@@ -318,7 +323,7 @@ var DateStringInput = function (_a) {
318
323
  )
319
324
  : undefined, onChange: function (d) { return onChange === null || onChange === void 0 ? void 0 : onChange((0, utilities_1.mm_dd_yyyy)(d), field.id); }, showTimeSelect: false, required: !field.isOptional, autoComplete: "off", dateFormat: "MM-dd-yyyy", customInput: (0, jsx_runtime_1.jsx)(CustomDateStringInput, __assign({ inputRef: inputRef }, props, { label: (!field.title && field.placeholder) ? field.placeholder : props.label })),
320
325
  // className={css`width: 100%;`}
321
- className: (0, css_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["", ""], ["", ""])), react_datepicker_2.datepickerCSS) }))
326
+ className: (0, css_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["", ""], ["", ""])), react_datepicker_2.datepickerCSS), minDate: minDate, maxDate: maxDate }))
322
327
  : ((0, jsx_runtime_1.jsx)(exports.AutoFocusTextField, __assign({}, props, { required: !field.isOptional, fullWidth: true, placeholder: (0, __1.form_display_text_for_language)(form, "MM-DD-YYYY"), value: value, label: (!field.title && field.placeholder) ? field.placeholder : props.label, onChange: function (e) {
323
328
  var v = e.target.value || '';
324
329
  onChange((v.length === 2 && /\d{2}/.test(v) && (value === null || value === void 0 ? void 0 : value.length) !== 3 // allow deletion
@@ -878,6 +883,191 @@ var BridgeEligibilityInput = function (_a) {
878
883
  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: (0, __1.form_display_text_for_language)(form, "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: (0, __1.form_display_text_for_language)(form, "Check Provider Eligibility (Free)"), submittingText: (0, __1.form_display_text_for_language)(form, "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: (0, __1.form_display_text_for_language)(form, "Check Service Eligibility (Paid)"), submittingText: polling ? (0, __1.form_display_text_for_language)(form, "Polling...") : (0, __1.form_display_text_for_language)(form, "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) }))] })))] })));
879
884
  };
880
885
  exports.BridgeEligibilityInput = BridgeEligibilityInput;
886
+ var CandidEligibilityInput = function (_a) {
887
+ var _b, _d;
888
+ var field = _a.field, value = _a.value, onChange = _a.onChange, responses = _a.responses, enduser = _a.enduser, inputProps = _a.inputProps, enduserId = _a.enduserId, form = _a.form, props = __rest(_a, ["field", "value", "onChange", "responses", "enduser", "inputProps", "enduserId", "form"]);
889
+ var session = (0, __1.useResolvedSession)();
890
+ var _e = (0, react_1.useState)(false), loading = _e[0], setLoading = _e[1];
891
+ var _f = (0, react_1.useState)(false), polling = _f[0], setPolling = _f[1];
892
+ var _g = (0, react_1.useState)(), error = _g[0], setError = _g[1];
893
+ var isEnduserSession = session.type === 'enduser';
894
+ var pollTimeoutRef = (0, react_1.useRef)();
895
+ // Clean up polling timeout on unmount
896
+ (0, react_1.useEffect)(function () {
897
+ return function () {
898
+ if (pollTimeoutRef.current)
899
+ clearTimeout(pollTimeoutRef.current);
900
+ };
901
+ }, []);
902
+ // Extract payerId from Insurance question response
903
+ var _h = (0, react_1.useMemo)(function () {
904
+ var _a, _b, _d, _e;
905
+ 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); });
906
+ if (((_a = insuranceResponse === null || insuranceResponse === void 0 ? void 0 : insuranceResponse.answer) === null || _a === void 0 ? void 0 : _a.type) === 'Insurance') {
907
+ return [
908
+ (_b = insuranceResponse.answer.value) === null || _b === void 0 ? void 0 : _b.payerId,
909
+ (_d = insuranceResponse.answer.value) === null || _d === void 0 ? void 0 : _d.memberId,
910
+ (_e = insuranceResponse.answer.value) === null || _e === void 0 ? void 0 : _e.payerName,
911
+ ];
912
+ }
913
+ return [];
914
+ }, [responses]), payerId = _h[0], memberId = _h[1], payerName = _h[2];
915
+ var checkEligibility = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
916
+ var data, coverageId_1, checkId_1, initialStatus, maxAttempts_1, attempts_1, pollForResult_1, err_6;
917
+ var _a, _b;
918
+ return __generator(this, function (_d) {
919
+ switch (_d.label) {
920
+ case 0:
921
+ setLoading(true);
922
+ setError(undefined);
923
+ _d.label = 1;
924
+ case 1:
925
+ _d.trys.push([1, 3, , 4]);
926
+ return [4 /*yield*/, session.api.integrations.proxy_read({
927
+ id: enduserId,
928
+ integration: constants_1.CANDID_TITLE,
929
+ type: 'candid-eligibility',
930
+ query: JSON.stringify({
931
+ serviceCode: (_a = field.options) === null || _a === void 0 ? void 0 : _a.candidServiceCode,
932
+ npi: (_b = field.options) === null || _b === void 0 ? void 0 : _b.candidNPI,
933
+ payerId: payerId,
934
+ memberId: memberId,
935
+ payerName: payerName,
936
+ }),
937
+ })];
938
+ case 2:
939
+ data = (_d.sent()).data;
940
+ coverageId_1 = data === null || data === void 0 ? void 0 : data.coverageId;
941
+ checkId_1 = data === null || data === void 0 ? void 0 : data.checkId;
942
+ initialStatus = data === null || data === void 0 ? void 0 : data.status;
943
+ if (!coverageId_1 || !checkId_1) {
944
+ throw new Error('No coverage ID or check ID returned from eligibility check');
945
+ }
946
+ // If already completed, update answer immediately
947
+ if (initialStatus === 'COMPLETED' || initialStatus === 'FAILED' || initialStatus === 'UNKNOWN') {
948
+ onChange({
949
+ payerId: payerId,
950
+ status: initialStatus,
951
+ coverageId: coverageId_1,
952
+ }, field.id);
953
+ setLoading(false);
954
+ return [2 /*return*/];
955
+ }
956
+ // Step 2: Poll for results
957
+ setLoading(false);
958
+ setPolling(true);
959
+ maxAttempts_1 = 60 // 2 minutes at 2s intervals
960
+ ;
961
+ attempts_1 = 0;
962
+ pollForResult_1 = function () { return __awaiter(void 0, void 0, void 0, function () {
963
+ var pollData, status_2, err_7;
964
+ return __generator(this, function (_a) {
965
+ switch (_a.label) {
966
+ case 0:
967
+ if (attempts_1 >= maxAttempts_1) {
968
+ setError('Eligibility check timed out. Please try again.');
969
+ setPolling(false);
970
+ return [2 /*return*/];
971
+ }
972
+ attempts_1++;
973
+ _a.label = 1;
974
+ case 1:
975
+ _a.trys.push([1, 3, , 4]);
976
+ return [4 /*yield*/, session.api.integrations.proxy_read({
977
+ id: coverageId_1,
978
+ integration: constants_1.CANDID_TITLE,
979
+ type: 'candid-eligibility-poll',
980
+ query: JSON.stringify({ checkId: checkId_1 }),
981
+ })];
982
+ case 2:
983
+ pollData = (_a.sent()).data;
984
+ status_2 = pollData === null || pollData === void 0 ? void 0 : pollData.status;
985
+ // Terminal statuses: COMPLETED, FAILED, or UNKNOWN (Candid returns UNKNOWN when eligibility cannot be determined)
986
+ if (status_2 === 'COMPLETED' || status_2 === 'FAILED' || status_2 === 'UNKNOWN') {
987
+ onChange({
988
+ payerId: payerId,
989
+ status: status_2,
990
+ coverageId: coverageId_1,
991
+ benefits: pollData === null || pollData === void 0 ? void 0 : pollData.benefits,
992
+ }, field.id);
993
+ setPolling(false);
994
+ return [2 /*return*/];
995
+ }
996
+ // Still pending, poll again
997
+ pollTimeoutRef.current = setTimeout(pollForResult_1, 2000);
998
+ return [3 /*break*/, 4];
999
+ case 3:
1000
+ err_7 = _a.sent();
1001
+ setError((err_7 === null || err_7 === void 0 ? void 0 : err_7.message) || 'Failed to check eligibility status');
1002
+ setPolling(false);
1003
+ return [3 /*break*/, 4];
1004
+ case 4: return [2 /*return*/];
1005
+ }
1006
+ });
1007
+ }); };
1008
+ pollForResult_1();
1009
+ return [3 /*break*/, 4];
1010
+ case 3:
1011
+ err_6 = _d.sent();
1012
+ setError((err_6 === null || err_6 === void 0 ? void 0 : err_6.message) || 'Failed to check eligibility');
1013
+ console.error('Candid eligibility check failed:', err_6);
1014
+ setLoading(false);
1015
+ setPolling(false);
1016
+ return [3 /*break*/, 4];
1017
+ case 4: return [2 /*return*/];
1018
+ }
1019
+ });
1020
+ }); }, [session, field, payerId, memberId, payerName, onChange, enduserId]);
1021
+ // Auto-check eligibility for enduser sessions
1022
+ var autoCheckRef = (0, react_1.useRef)(false);
1023
+ (0, react_1.useEffect)(function () {
1024
+ if (!isEnduserSession)
1025
+ return;
1026
+ // If we already have a result and the payer hasn't changed, use the cached result
1027
+ if ((value === null || value === void 0 ? void 0 : value.status) && (value === null || value === void 0 ? void 0 : value.payerId) === payerId) {
1028
+ return;
1029
+ }
1030
+ if (autoCheckRef.current)
1031
+ return;
1032
+ autoCheckRef.current = true;
1033
+ checkEligibility();
1034
+ }, [isEnduserSession, checkEligibility, value, payerId]);
1035
+ 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: {
1036
+ padding: 16,
1037
+ backgroundColor: '#ffebee',
1038
+ border: '2px solid #f44336'
1039
+ } }, { 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: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "h2", style: { color: '#f44336' } }, { children: "!" })) })), (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", color: "error" }, { children: "Unable to Check Eligibility" })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", align: "center", style: { color: '#d32f2f' } }, { children: error })) }))] })) })) })) }))); }, [error]);
1040
+ var checkingEligibilityComponent = (0, react_1.useMemo)(function () { return ((0, jsx_runtime_1.jsxs)(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.CircularProgress, { size: 40 }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body1" }, { children: polling ? 'Verifying eligibility with insurance...' : 'Checking eligibility...' })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: polling ? 'This usually takes 15-30 seconds' : 'This may take a few moments' })) }))] }))); }, [polling]);
1041
+ var resultsComponent = (0, react_1.useMemo)(function () {
1042
+ var isCompleted = (value === null || value === void 0 ? void 0 : value.status) === 'COMPLETED';
1043
+ var isFailed = (value === null || value === void 0 ? void 0 : value.status) === 'FAILED';
1044
+ return ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ container: true, spacing: 2, direction: "column" }, { children: (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Paper, __assign({ style: {
1045
+ padding: 16,
1046
+ backgroundColor: isCompleted ? '#e8f5e9' : '#ffebee',
1047
+ border: "2px solid ".concat(isCompleted ? '#4caf50' : '#f44336')
1048
+ } }, { 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: isCompleted ? ((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: '#f44336' } }, { children: "!" }))) })), (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: isCompleted
1049
+ ? "".concat(payerName || 'Insurance', " eligibility verified")
1050
+ : isFailed
1051
+ ? 'Eligibility check failed'
1052
+ : 'Eligibility Status: ' + (0, utilities_1.first_letter_capitalized)(((value === null || value === void 0 ? void 0 : value.status) || 'Unknown').toLowerCase()) })) }))] })) })) })) })));
1053
+ }, [value, payerName]);
1054
+ // Loading/polling state for enduser sessions
1055
+ if (isEnduserSession) {
1056
+ if (loading || polling) {
1057
+ return checkingEligibilityComponent;
1058
+ }
1059
+ if (error) {
1060
+ return errorComponent;
1061
+ }
1062
+ if (value === null || value === void 0 ? void 0 : value.status) {
1063
+ return resultsComponent;
1064
+ }
1065
+ return errorComponent;
1066
+ }
1067
+ // User/admin interface (non-enduser sessions)
1068
+ 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: ["Service Code: ", ((_b = field.options) === null || _b === void 0 ? void 0 : _b.candidServiceCode) || 'Not configured'] })), (0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["Provider NPI: ", ((_d = field.options) === null || _d === void 0 ? void 0 : _d.candidNPI) || 'Not configured'] })), 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: (0, __1.form_display_text_for_language)(form, "Polling for results... (this may take 15-30 seconds)") })) }))), (0, jsx_runtime_1.jsx)(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: checkEligibility, submitText: (0, __1.form_display_text_for_language)(form, "Check Eligibility"), submittingText: polling ? (0, __1.form_display_text_for_language)(form, "Polling...") : (0, __1.form_display_text_for_language)(form, "Checking..."), submitting: loading || polling, disabled: 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) }))] })))] })));
1069
+ };
1070
+ exports.CandidEligibilityInput = CandidEligibilityInput;
881
1071
  var PharmacySearchInput = function (_a) {
882
1072
  var field = _a.field, rawValue = _a.value, onChange = _a.onChange, responses = _a.responses, enduser = _a.enduser, form = _a.form, props = __rest(_a, ["field", "value", "onChange", "responses", "enduser", "form"]);
883
1073
  var value = rawValue;
@@ -902,7 +1092,7 @@ var PharmacySearchInput = function (_a) {
902
1092
  var _f = (0, react_1.useState)([]), pharmacies = _f[0], setPharmacies = _f[1];
903
1093
  var _g = (0, react_1.useState)(false), hasSearched = _g[0], setHasSearched = _g[1];
904
1094
  var searchPharmacies = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
905
- var data, err_6;
1095
+ var data, err_8;
906
1096
  return __generator(this, function (_a) {
907
1097
  switch (_a.label) {
908
1098
  case 0:
@@ -929,8 +1119,8 @@ var PharmacySearchInput = function (_a) {
929
1119
  }
930
1120
  return [3 /*break*/, 5];
931
1121
  case 3:
932
- err_6 = _a.sent();
933
- setError((err_6 === null || err_6 === void 0 ? void 0 : err_6.message) || (0, __1.form_display_text_for_language)(form, 'Failed to search pharmacies'));
1122
+ err_8 = _a.sent();
1123
+ setError((err_8 === null || err_8 === void 0 ? void 0 : err_8.message) || (0, __1.form_display_text_for_language)(form, 'Failed to search pharmacies'));
934
1124
  setPharmacies([]);
935
1125
  return [3 /*break*/, 5];
936
1126
  case 4:
@@ -2395,7 +2585,7 @@ var AppointmentBookingInput = function (_a) {
2395
2585
  var _s = (0, react_1.useState)(false), confirming = _s[0], setConfirming = _s[1];
2396
2586
  var bookingPageId = (_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.bookingPageId;
2397
2587
  var downloadICS = (0, react_1.useCallback)(function (event) { return __awaiter(void 0, void 0, void 0, function () {
2398
- var _a, err_7;
2588
+ var _a, err_9;
2399
2589
  return __generator(this, function (_b) {
2400
2590
  switch (_b.label) {
2401
2591
  case 0:
@@ -2407,8 +2597,8 @@ var AppointmentBookingInput = function (_a) {
2407
2597
  { name: "event.ics", dataIsURL: true, type: 'text/calendar' }]);
2408
2598
  return [3 /*break*/, 3];
2409
2599
  case 2:
2410
- err_7 = _b.sent();
2411
- console.error(err_7);
2600
+ err_9 = _b.sent();
2601
+ console.error(err_9);
2412
2602
  return [3 /*break*/, 3];
2413
2603
  case 3: return [2 /*return*/];
2414
2604
  }