@tellescope/react-components 1.243.1 → 1.244.1

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 (65) 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/Forms/forms.d.ts +1 -0
  30. package/lib/esm/Forms/forms.d.ts.map +1 -1
  31. package/lib/esm/Forms/forms.js +40 -38
  32. package/lib/esm/Forms/forms.js.map +1 -1
  33. package/lib/esm/Forms/forms.v2.d.ts +1 -0
  34. package/lib/esm/Forms/forms.v2.d.ts.map +1 -1
  35. package/lib/esm/Forms/forms.v2.js +48 -41
  36. package/lib/esm/Forms/forms.v2.js.map +1 -1
  37. package/lib/esm/Forms/hooks.d.ts +1 -0
  38. package/lib/esm/Forms/hooks.d.ts.map +1 -1
  39. package/lib/esm/Forms/hooks.js +70 -28
  40. package/lib/esm/Forms/hooks.js.map +1 -1
  41. package/lib/esm/Forms/inputs.d.ts +5 -0
  42. package/lib/esm/Forms/inputs.d.ts.map +1 -1
  43. package/lib/esm/Forms/inputs.js +202 -13
  44. package/lib/esm/Forms/inputs.js.map +1 -1
  45. package/lib/esm/Forms/inputs.v2.d.ts +1 -0
  46. package/lib/esm/Forms/inputs.v2.d.ts.map +1 -1
  47. package/lib/esm/Forms/inputs.v2.js +16 -7
  48. package/lib/esm/Forms/inputs.v2.js.map +1 -1
  49. package/lib/esm/forms.d.ts +2 -1
  50. package/lib/esm/forms.d.ts.map +1 -1
  51. package/lib/esm/forms.js +2 -2
  52. package/lib/esm/forms.js.map +1 -1
  53. package/lib/esm/inputs_shared.d.ts +1 -0
  54. package/lib/esm/inputs_shared.d.ts.map +1 -1
  55. package/lib/esm/inputs_shared.js +28 -4
  56. package/lib/esm/inputs_shared.js.map +1 -1
  57. package/lib/tsconfig.tsbuildinfo +1 -1
  58. package/package.json +9 -9
  59. package/src/Forms/forms.tsx +10 -2
  60. package/src/Forms/forms.v2.tsx +29 -3
  61. package/src/Forms/hooks.tsx +46 -1
  62. package/src/Forms/inputs.tsx +304 -6
  63. package/src/Forms/inputs.v2.tsx +19 -4
  64. package/src/forms.tsx +3 -1
  65. package/src/inputs_shared.tsx +39 -5
@@ -74,7 +74,7 @@ import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState }
74
74
  import axios from "axios";
75
75
  import { Autocomplete, Box, Button, Checkbox, Chip, CircularProgress, Collapse, Divider, FormControl, FormControlLabel, FormLabel, Grid, IconButton as MuiIconButton, InputLabel, MenuItem, Paper, Radio, RadioGroup, Select, TextField, Typography } from "@mui/material";
76
76
  import { useDropzone } from "react-dropzone";
77
- import { CANVAS_TITLE, BRIDGE_TITLE, EMOTII_TITLE, INSURANCE_RELATIONSHIPS, INSURANCE_RELATIONSHIPS_CANVAS, PRIMARY_HEX, RELATIONSHIP_TYPES, TELLESCOPE_GENDERS } from "@tellescope/constants";
77
+ import { CANVAS_TITLE, BRIDGE_TITLE, CANDID_TITLE, EMOTII_TITLE, INSURANCE_RELATIONSHIPS, INSURANCE_RELATIONSHIPS_CANVAS, PRIMARY_HEX, RELATIONSHIP_TYPES, TELLESCOPE_GENDERS } from "@tellescope/constants";
78
78
  import { MM_DD_YYYY_to_YYYY_MM_DD, capture_is_supported, downloadFile, emit_gtm_event, first_letter_capitalized, form_response_value_to_string, format_stripe_subscription_interval, getLocalTimezone, getPublicFileURL, mm_dd_yyyy, object_is_empty, replace_enduser_template_values, responses_satisfy_conditions, truncate_string, update_local_storage, user_display_name } from "@tellescope/utilities";
79
79
  import { TIMEZONES_USA } from "@tellescope/types-models";
80
80
  import { VALID_STATES, emailValidator, phoneValidator } from "@tellescope/validation";
@@ -93,7 +93,7 @@ import { Elements, PaymentElement, useStripe, useElements, EmbeddedCheckout, Emb
93
93
  import { loadStripe } from '@stripe/stripe-js';
94
94
  import { CheckCircleOutline, Delete, Edit, ExpandMore } from "@mui/icons-material";
95
95
  import { WYSIWYG } from "./wysiwyg";
96
- import { useConditionalChoices } from "./hooks";
96
+ import { dateFromOffsetMs, useConditionalChoices } from "./hooks";
97
97
  // Bridge Eligibility - shared variable for storing most recent eligibility userIds
98
98
  var bridgeEligibilityResult = {
99
99
  userIds: [],
@@ -195,12 +195,15 @@ export var RankingInput = function (_a) {
195
195
  };
196
196
  var CustomDateInput = forwardRef(function (props, ref) { return (_jsx(TextField, __assign({ InputProps: defaultInputProps, fullWidth: true, inputRef: ref }, props))); });
197
197
  export var DateInput = function (_a) {
198
- 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"]);
198
+ var _b, _d;
199
+ 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"]);
199
200
  var inputRef = useRef(null);
201
+ var minDate = ((_b = field.options) === null || _b === void 0 ? void 0 : _b.minDateOffsetMs) !== undefined ? dateFromOffsetMs(field.options.minDateOffsetMs) : undefined;
202
+ var maxDate = ((_d = field.options) === null || _d === void 0 ? void 0 : _d.maxDateOffsetMs) !== undefined ? dateFromOffsetMs(field.options.maxDateOffsetMs) : undefined;
200
203
  return (_jsx(DatePicker // wrap in item to prevent movement on focused
201
204
  , { 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: _jsx(CustomDateInput, __assign({ inputRef: inputRef }, props)),
202
205
  // className={css`width: 100%;`}
203
- className: css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["", ""], ["", ""])), datepickerCSS) }));
206
+ className: css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["", ""], ["", ""])), datepickerCSS), minDate: minDate, maxDate: maxDate }));
204
207
  };
205
208
  export var TableInput = function (_a) {
206
209
  var _b;
@@ -263,16 +266,18 @@ var CustomDateStringInput = forwardRef(function (props, ref) {
263
266
  return (_jsx(TextField, __assign({ InputProps: inputProps || defaultInputProps, fullWidth: true, inputRef: ref }, textFieldProps)));
264
267
  });
265
268
  export var DateStringInput = function (_a) {
266
- var _b;
269
+ var _b, _d, _e;
267
270
  var field = _a.field, value = _a.value, onChange = _a.onChange, form = _a.form, props = __rest(_a, ["field", "value", "onChange", "form"]);
268
271
  var inputRef = useRef(null);
272
+ var minDate = ((_b = field.options) === null || _b === void 0 ? void 0 : _b.minDateOffsetMs) !== undefined ? dateFromOffsetMs(field.options.minDateOffsetMs) : undefined;
273
+ var maxDate = ((_d = field.options) === null || _d === void 0 ? void 0 : _d.maxDateOffsetMs) !== undefined ? dateFromOffsetMs(field.options.maxDateOffsetMs) : undefined;
269
274
  // if (value && isDateString(value)) {
270
275
  // console.log(value, new Date(
271
276
  // new Date(MM_DD_YYYY_to_YYYY_MM_DD(value)).getTime()
272
277
  // + (new Date().getTimezoneOffset() * 60 * 1000)
273
278
  // ))
274
279
  // }
275
- return (((_b = field.options) === null || _b === void 0 ? void 0 : _b.useDatePicker)
280
+ return (((_e = field.options) === null || _e === void 0 ? void 0 : _e.useDatePicker)
276
281
  ? (_jsx(DatePicker // wrap in item to prevent movement on focused
277
282
  , { selected: (value && isDateString(value))
278
283
  ? new Date(new Date(MM_DD_YYYY_to_YYYY_MM_DD(value)).getTime()
@@ -280,7 +285,7 @@ export var DateStringInput = function (_a) {
280
285
  )
281
286
  : undefined, onChange: function (d) { return onChange === null || onChange === void 0 ? void 0 : onChange(mm_dd_yyyy(d), field.id); }, showTimeSelect: false, required: !field.isOptional, autoComplete: "off", dateFormat: "MM-dd-yyyy", customInput: _jsx(CustomDateStringInput, __assign({ inputRef: inputRef }, props, { label: (!field.title && field.placeholder) ? field.placeholder : props.label })),
282
287
  // className={css`width: 100%;`}
283
- className: css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["", ""], ["", ""])), datepickerCSS) }))
288
+ className: css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["", ""], ["", ""])), datepickerCSS), minDate: minDate, maxDate: maxDate }))
284
289
  : (_jsx(AutoFocusTextField, __assign({}, props, { required: !field.isOptional, fullWidth: true, placeholder: form_display_text_for_language(form, "MM-DD-YYYY"), value: value, label: (!field.title && field.placeholder) ? field.placeholder : props.label, onChange: function (e) {
285
290
  var v = e.target.value || '';
286
291
  onChange((v.length === 2 && /\d{2}/.test(v) && (value === null || value === void 0 ? void 0 : value.length) !== 3 // allow deletion
@@ -832,6 +837,190 @@ export var BridgeEligibilityInput = function (_a) {
832
837
  // User/admin interface (non-enduser sessions)
833
838
  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: form_display_text_for_language(form, "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: form_display_text_for_language(form, "Check Provider Eligibility (Free)"), submittingText: 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 }) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(LoadingButton, { variant: "outlined", onClick: checkServiceEligibility, submitText: form_display_text_for_language(form, "Check Service Eligibility (Paid)"), submittingText: polling ? form_display_text_for_language(form, "Polling...") : 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 && (_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) }))] })))] })));
834
839
  };
840
+ export var CandidEligibilityInput = function (_a) {
841
+ var _b, _d;
842
+ 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"]);
843
+ var session = useResolvedSession();
844
+ var _e = useState(false), loading = _e[0], setLoading = _e[1];
845
+ var _f = useState(false), polling = _f[0], setPolling = _f[1];
846
+ var _g = useState(), error = _g[0], setError = _g[1];
847
+ var isEnduserSession = session.type === 'enduser';
848
+ var pollTimeoutRef = useRef();
849
+ // Clean up polling timeout on unmount
850
+ useEffect(function () {
851
+ return function () {
852
+ if (pollTimeoutRef.current)
853
+ clearTimeout(pollTimeoutRef.current);
854
+ };
855
+ }, []);
856
+ // Extract payerId from Insurance question response
857
+ var _h = useMemo(function () {
858
+ var _a, _b, _d, _e;
859
+ 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); });
860
+ if (((_a = insuranceResponse === null || insuranceResponse === void 0 ? void 0 : insuranceResponse.answer) === null || _a === void 0 ? void 0 : _a.type) === 'Insurance') {
861
+ return [
862
+ (_b = insuranceResponse.answer.value) === null || _b === void 0 ? void 0 : _b.payerId,
863
+ (_d = insuranceResponse.answer.value) === null || _d === void 0 ? void 0 : _d.memberId,
864
+ (_e = insuranceResponse.answer.value) === null || _e === void 0 ? void 0 : _e.payerName,
865
+ ];
866
+ }
867
+ return [];
868
+ }, [responses]), payerId = _h[0], memberId = _h[1], payerName = _h[2];
869
+ var checkEligibility = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
870
+ var data, coverageId_1, checkId_1, initialStatus, maxAttempts_1, attempts_1, pollForResult_1, err_6;
871
+ var _a, _b;
872
+ return __generator(this, function (_d) {
873
+ switch (_d.label) {
874
+ case 0:
875
+ setLoading(true);
876
+ setError(undefined);
877
+ _d.label = 1;
878
+ case 1:
879
+ _d.trys.push([1, 3, , 4]);
880
+ return [4 /*yield*/, session.api.integrations.proxy_read({
881
+ id: enduserId,
882
+ integration: CANDID_TITLE,
883
+ type: 'candid-eligibility',
884
+ query: JSON.stringify({
885
+ serviceCode: (_a = field.options) === null || _a === void 0 ? void 0 : _a.candidServiceCode,
886
+ npi: (_b = field.options) === null || _b === void 0 ? void 0 : _b.candidNPI,
887
+ payerId: payerId,
888
+ memberId: memberId,
889
+ payerName: payerName,
890
+ }),
891
+ })];
892
+ case 2:
893
+ data = (_d.sent()).data;
894
+ coverageId_1 = data === null || data === void 0 ? void 0 : data.coverageId;
895
+ checkId_1 = data === null || data === void 0 ? void 0 : data.checkId;
896
+ initialStatus = data === null || data === void 0 ? void 0 : data.status;
897
+ if (!coverageId_1 || !checkId_1) {
898
+ throw new Error('No coverage ID or check ID returned from eligibility check');
899
+ }
900
+ // If already completed, update answer immediately
901
+ if (initialStatus === 'COMPLETED' || initialStatus === 'FAILED' || initialStatus === 'UNKNOWN') {
902
+ onChange({
903
+ payerId: payerId,
904
+ status: initialStatus,
905
+ coverageId: coverageId_1,
906
+ }, field.id);
907
+ setLoading(false);
908
+ return [2 /*return*/];
909
+ }
910
+ // Step 2: Poll for results
911
+ setLoading(false);
912
+ setPolling(true);
913
+ maxAttempts_1 = 60 // 2 minutes at 2s intervals
914
+ ;
915
+ attempts_1 = 0;
916
+ pollForResult_1 = function () { return __awaiter(void 0, void 0, void 0, function () {
917
+ var pollData, status_2, err_7;
918
+ return __generator(this, function (_a) {
919
+ switch (_a.label) {
920
+ case 0:
921
+ if (attempts_1 >= maxAttempts_1) {
922
+ setError('Eligibility check timed out. Please try again.');
923
+ setPolling(false);
924
+ return [2 /*return*/];
925
+ }
926
+ attempts_1++;
927
+ _a.label = 1;
928
+ case 1:
929
+ _a.trys.push([1, 3, , 4]);
930
+ return [4 /*yield*/, session.api.integrations.proxy_read({
931
+ id: coverageId_1,
932
+ integration: CANDID_TITLE,
933
+ type: 'candid-eligibility-poll',
934
+ query: JSON.stringify({ checkId: checkId_1 }),
935
+ })];
936
+ case 2:
937
+ pollData = (_a.sent()).data;
938
+ status_2 = pollData === null || pollData === void 0 ? void 0 : pollData.status;
939
+ // Terminal statuses: COMPLETED, FAILED, or UNKNOWN (Candid returns UNKNOWN when eligibility cannot be determined)
940
+ if (status_2 === 'COMPLETED' || status_2 === 'FAILED' || status_2 === 'UNKNOWN') {
941
+ onChange({
942
+ payerId: payerId,
943
+ status: status_2,
944
+ coverageId: coverageId_1,
945
+ benefits: pollData === null || pollData === void 0 ? void 0 : pollData.benefits,
946
+ }, field.id);
947
+ setPolling(false);
948
+ return [2 /*return*/];
949
+ }
950
+ // Still pending, poll again
951
+ pollTimeoutRef.current = setTimeout(pollForResult_1, 2000);
952
+ return [3 /*break*/, 4];
953
+ case 3:
954
+ err_7 = _a.sent();
955
+ setError((err_7 === null || err_7 === void 0 ? void 0 : err_7.message) || 'Failed to check eligibility status');
956
+ setPolling(false);
957
+ return [3 /*break*/, 4];
958
+ case 4: return [2 /*return*/];
959
+ }
960
+ });
961
+ }); };
962
+ pollForResult_1();
963
+ return [3 /*break*/, 4];
964
+ case 3:
965
+ err_6 = _d.sent();
966
+ setError((err_6 === null || err_6 === void 0 ? void 0 : err_6.message) || 'Failed to check eligibility');
967
+ console.error('Candid eligibility check failed:', err_6);
968
+ setLoading(false);
969
+ setPolling(false);
970
+ return [3 /*break*/, 4];
971
+ case 4: return [2 /*return*/];
972
+ }
973
+ });
974
+ }); }, [session, field, payerId, memberId, payerName, onChange, enduserId]);
975
+ // Auto-check eligibility for enduser sessions
976
+ var autoCheckRef = useRef(false);
977
+ useEffect(function () {
978
+ if (!isEnduserSession)
979
+ return;
980
+ // If we already have a result and the payer hasn't changed, use the cached result
981
+ if ((value === null || value === void 0 ? void 0 : value.status) && (value === null || value === void 0 ? void 0 : value.payerId) === payerId) {
982
+ return;
983
+ }
984
+ if (autoCheckRef.current)
985
+ return;
986
+ autoCheckRef.current = true;
987
+ checkEligibility();
988
+ }, [isEnduserSession, checkEligibility, value, payerId]);
989
+ 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: {
990
+ padding: 16,
991
+ backgroundColor: '#ffebee',
992
+ border: '2px solid #f44336'
993
+ } }, { children: _jsxs(Grid, __assign({ container: true, spacing: 2, direction: "column", alignItems: "center" }, { children: [_jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ variant: "h2", style: { color: '#f44336' } }, { children: "!" })) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ variant: "h6", align: "center", color: "error" }, { children: "Unable to Check Eligibility" })) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ variant: "body2", align: "center", style: { color: '#d32f2f' } }, { children: error })) }))] })) })) })) }))); }, [error]);
994
+ var checkingEligibilityComponent = useMemo(function () { return (_jsxs(Grid, __assign({ container: true, spacing: 2, direction: "column", alignItems: "center", style: { padding: '20px 0' } }, { children: [_jsx(Grid, __assign({ item: true }, { children: _jsx(CircularProgress, { size: 40 }) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ variant: "body1" }, { children: polling ? 'Verifying eligibility with insurance...' : 'Checking eligibility...' })) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: polling ? 'This usually takes 15-30 seconds' : 'This may take a few moments' })) }))] }))); }, [polling]);
995
+ var resultsComponent = useMemo(function () {
996
+ var isCompleted = (value === null || value === void 0 ? void 0 : value.status) === 'COMPLETED';
997
+ var isFailed = (value === null || value === void 0 ? void 0 : value.status) === 'FAILED';
998
+ return (_jsx(Grid, __assign({ container: true, spacing: 2, direction: "column" }, { children: _jsx(Grid, __assign({ item: true }, { children: _jsx(Paper, __assign({ style: {
999
+ padding: 16,
1000
+ backgroundColor: isCompleted ? '#e8f5e9' : '#ffebee',
1001
+ border: "2px solid ".concat(isCompleted ? '#4caf50' : '#f44336')
1002
+ } }, { children: _jsxs(Grid, __assign({ container: true, spacing: 2, direction: "column", alignItems: "center" }, { children: [_jsx(Grid, __assign({ item: true }, { children: isCompleted ? (_jsx(CheckCircleOutline, { style: { fontSize: 48, color: '#4caf50' } })) : (_jsx(Typography, __assign({ variant: "h2", style: { color: '#f44336' } }, { children: "!" }))) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ variant: "h6", align: "center" }, { children: isCompleted
1003
+ ? "".concat(payerName || 'Insurance', " eligibility verified")
1004
+ : isFailed
1005
+ ? 'Eligibility check failed'
1006
+ : 'Eligibility Status: ' + first_letter_capitalized(((value === null || value === void 0 ? void 0 : value.status) || 'Unknown').toLowerCase()) })) }))] })) })) })) })));
1007
+ }, [value, payerName]);
1008
+ // Loading/polling state for enduser sessions
1009
+ if (isEnduserSession) {
1010
+ if (loading || polling) {
1011
+ return checkingEligibilityComponent;
1012
+ }
1013
+ if (error) {
1014
+ return errorComponent;
1015
+ }
1016
+ if (value === null || value === void 0 ? void 0 : value.status) {
1017
+ return resultsComponent;
1018
+ }
1019
+ return errorComponent;
1020
+ }
1021
+ // User/admin interface (non-enduser sessions)
1022
+ 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: ["Service Code: ", ((_b = field.options) === null || _b === void 0 ? void 0 : _b.candidServiceCode) || 'Not configured'] })), _jsxs(Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: ["Provider NPI: ", ((_d = field.options) === null || _d === void 0 ? void 0 : _d.candidNPI) || 'Not configured'] })), 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: form_display_text_for_language(form, "Polling for results... (this may take 15-30 seconds)") })) }))), _jsx(Grid, __assign({ item: true, container: true, spacing: 2 }, { children: _jsx(Grid, __assign({ item: true }, { children: _jsx(LoadingButton, { variant: "outlined", onClick: checkEligibility, submitText: form_display_text_for_language(form, "Check Eligibility"), submittingText: polling ? form_display_text_for_language(form, "Polling...") : form_display_text_for_language(form, "Checking..."), submitting: loading || polling, disabled: 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) }))] })))] })));
1023
+ };
835
1024
  export var PharmacySearchInput = function (_a) {
836
1025
  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"]);
837
1026
  var value = rawValue;
@@ -856,7 +1045,7 @@ export var PharmacySearchInput = function (_a) {
856
1045
  var _f = useState([]), pharmacies = _f[0], setPharmacies = _f[1];
857
1046
  var _g = useState(false), hasSearched = _g[0], setHasSearched = _g[1];
858
1047
  var searchPharmacies = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
859
- var data, err_6;
1048
+ var data, err_8;
860
1049
  return __generator(this, function (_a) {
861
1050
  switch (_a.label) {
862
1051
  case 0:
@@ -883,8 +1072,8 @@ export var PharmacySearchInput = function (_a) {
883
1072
  }
884
1073
  return [3 /*break*/, 5];
885
1074
  case 3:
886
- err_6 = _a.sent();
887
- setError((err_6 === null || err_6 === void 0 ? void 0 : err_6.message) || form_display_text_for_language(form, 'Failed to search pharmacies'));
1075
+ err_8 = _a.sent();
1076
+ setError((err_8 === null || err_8 === void 0 ? void 0 : err_8.message) || form_display_text_for_language(form, 'Failed to search pharmacies'));
888
1077
  setPharmacies([]);
889
1078
  return [3 /*break*/, 5];
890
1079
  case 4:
@@ -2329,7 +2518,7 @@ export var AppointmentBookingInput = function (_a) {
2329
2518
  var _s = useState(false), confirming = _s[0], setConfirming = _s[1];
2330
2519
  var bookingPageId = (_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.bookingPageId;
2331
2520
  var downloadICS = useCallback(function (event) { return __awaiter(void 0, void 0, void 0, function () {
2332
- var _a, err_7;
2521
+ var _a, err_9;
2333
2522
  return __generator(this, function (_b) {
2334
2523
  switch (_b.label) {
2335
2524
  case 0:
@@ -2341,8 +2530,8 @@ export var AppointmentBookingInput = function (_a) {
2341
2530
  { name: "event.ics", dataIsURL: true, type: 'text/calendar' }]);
2342
2531
  return [3 /*break*/, 3];
2343
2532
  case 2:
2344
- err_7 = _b.sent();
2345
- console.error(err_7);
2533
+ err_9 = _b.sent();
2534
+ console.error(err_9);
2346
2535
  return [3 /*break*/, 3];
2347
2536
  case 3: return [2 /*return*/];
2348
2537
  }