@tellescope/react-components 1.234.1 → 1.235.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 (46) hide show
  1. package/lib/cjs/CMS/ContentViewer.d.ts.map +1 -1
  2. package/lib/cjs/CMS/ContentViewer.js +26 -22
  3. package/lib/cjs/CMS/ContentViewer.js.map +1 -1
  4. package/lib/cjs/Forms/forms.d.ts.map +1 -1
  5. package/lib/cjs/Forms/forms.js +37 -35
  6. package/lib/cjs/Forms/forms.js.map +1 -1
  7. package/lib/cjs/Forms/forms.v2.d.ts.map +1 -1
  8. package/lib/cjs/Forms/forms.v2.js +37 -35
  9. package/lib/cjs/Forms/forms.v2.js.map +1 -1
  10. package/lib/cjs/Forms/inputs.d.ts +17 -2
  11. package/lib/cjs/Forms/inputs.d.ts.map +1 -1
  12. package/lib/cjs/Forms/inputs.js +429 -37
  13. package/lib/cjs/Forms/inputs.js.map +1 -1
  14. package/lib/cjs/Forms/inputs.v2.d.ts +3 -2
  15. package/lib/cjs/Forms/inputs.v2.d.ts.map +1 -1
  16. package/lib/cjs/Forms/inputs.v2.js +21 -294
  17. package/lib/cjs/Forms/inputs.v2.js.map +1 -1
  18. package/lib/cjs/Forms/types.d.ts +4 -0
  19. package/lib/cjs/Forms/types.d.ts.map +1 -1
  20. package/lib/esm/CMS/ContentViewer.d.ts.map +1 -1
  21. package/lib/esm/CMS/ContentViewer.js +27 -23
  22. package/lib/esm/CMS/ContentViewer.js.map +1 -1
  23. package/lib/esm/Forms/forms.d.ts.map +1 -1
  24. package/lib/esm/Forms/forms.js +38 -36
  25. package/lib/esm/Forms/forms.js.map +1 -1
  26. package/lib/esm/Forms/forms.v2.d.ts.map +1 -1
  27. package/lib/esm/Forms/forms.v2.js +38 -36
  28. package/lib/esm/Forms/forms.v2.js.map +1 -1
  29. package/lib/esm/Forms/inputs.d.ts +17 -2
  30. package/lib/esm/Forms/inputs.d.ts.map +1 -1
  31. package/lib/esm/Forms/inputs.js +427 -38
  32. package/lib/esm/Forms/inputs.js.map +1 -1
  33. package/lib/esm/Forms/inputs.v2.d.ts +3 -2
  34. package/lib/esm/Forms/inputs.v2.d.ts.map +1 -1
  35. package/lib/esm/Forms/inputs.v2.js +16 -290
  36. package/lib/esm/Forms/inputs.v2.js.map +1 -1
  37. package/lib/esm/Forms/types.d.ts +4 -0
  38. package/lib/esm/Forms/types.d.ts.map +1 -1
  39. package/lib/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +44 -44
  41. package/src/CMS/ContentViewer.tsx +16 -2
  42. package/src/Forms/forms.tsx +13 -6
  43. package/src/Forms/forms.v2.tsx +9 -2
  44. package/src/Forms/inputs.tsx +563 -66
  45. package/src/Forms/inputs.v2.tsx +13 -594
  46. package/src/Forms/types.ts +4 -2
@@ -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.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 = 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.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"));
@@ -122,6 +122,16 @@ var react_stripe_js_1 = require("@stripe/react-stripe-js");
122
122
  var stripe_js_1 = require("@stripe/stripe-js");
123
123
  var icons_material_1 = require("@mui/icons-material");
124
124
  var wysiwyg_1 = require("./wysiwyg");
125
+ // Bridge Eligibility - shared variable for storing most recent eligibility userIds
126
+ var bridgeEligibilityResult = {
127
+ userIds: [],
128
+ };
129
+ var getBridgeEligibilityUserIds = function () { return bridgeEligibilityResult.userIds; };
130
+ exports.getBridgeEligibilityUserIds = getBridgeEligibilityUserIds;
131
+ var setBridgeEligibilityUserIds = function (userIds) {
132
+ bridgeEligibilityResult.userIds = userIds;
133
+ };
134
+ exports.setBridgeEligibilityUserIds = setBridgeEligibilityUserIds;
125
135
  // Debounce hook for search functionality
126
136
  var useDebounce = function (value, delay) {
127
137
  var _a = (0, react_1.useState)(value), debouncedValue = _a[0], setDebouncedValue = _a[1];
@@ -280,9 +290,15 @@ var TableInput = function (_a) {
280
290
  }), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, sx: { ml: 'auto', width: iconWidth } }, { children: (0, jsx_runtime_1.jsx)(__1.LabeledIconButton, { Icon: __1.CancelIcon, label: "Remove", onClick: function () { return handleRemove(i); }, disabled: !field.isOptional && value.length === 1 }) }))] }), i), (0, jsx_runtime_1.jsx)(material_1.Divider, { flexItem: true, sx: { my: 1 } })] })); }), (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ variant: "outlined", size: "small", onClick: handleNewRow, sx: { width: 200 } }, { children: "Add new entry" }))] })));
281
291
  };
282
292
  exports.TableInput = TableInput;
283
- var AutoFocusTextField = function (props) { return ((0, jsx_runtime_1.jsx)(material_1.TextField, __assign({ InputProps: exports.defaultInputProps }, props))); };
293
+ var AutoFocusTextField = function (props) {
294
+ var inputProps = props.inputProps, textFieldProps = __rest(props, ["inputProps"]);
295
+ return (0, jsx_runtime_1.jsx)(material_1.TextField, __assign({ InputProps: inputProps || exports.defaultInputProps }, textFieldProps));
296
+ };
284
297
  exports.AutoFocusTextField = AutoFocusTextField;
285
- var CustomDateStringInput = (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))); });
298
+ var CustomDateStringInput = (0, react_1.forwardRef)(function (props, ref) {
299
+ var inputProps = props.inputProps, textFieldProps = __rest(props, ["inputProps"]);
300
+ return ((0, jsx_runtime_1.jsx)(material_1.TextField, __assign({ InputProps: inputProps || exports.defaultInputProps, fullWidth: true, inputRef: ref }, textFieldProps)));
301
+ });
286
302
  var DateStringInput = function (_a) {
287
303
  var _b;
288
304
  var field = _a.field, value = _a.value, onChange = _a.onChange, props = __rest(_a, ["field", "value", "onChange"]);
@@ -370,7 +386,7 @@ var NumberInput = function (_a) {
370
386
  exports.NumberInput = NumberInput;
371
387
  var InsuranceInput = function (_a) {
372
388
  var _b, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
373
- var field = _a.field, onDatabaseSelect = _a.onDatabaseSelect, value = _a.value, onChange = _a.onChange, form = _a.form, responses = _a.responses, enduser = _a.enduser, props = __rest(_a, ["field", "onDatabaseSelect", "value", "onChange", "form", "responses", "enduser"]);
389
+ var field = _a.field, onDatabaseSelect = _a.onDatabaseSelect, value = _a.value, onChange = _a.onChange, form = _a.form, responses = _a.responses, enduser = _a.enduser, inputProps = _a.inputProps, props = __rest(_a, ["field", "onDatabaseSelect", "value", "onChange", "form", "responses", "enduser", "inputProps"]);
374
390
  var session = (0, __1.useResolvedSession)();
375
391
  var _t = (0, react_1.useState)([]), payers = _t[0], setPayers = _t[1];
376
392
  var _u = (0, react_1.useState)(''), query = _u[0], setQuery = _u[1];
@@ -389,11 +405,14 @@ var InsuranceInput = function (_a) {
389
405
  var _a, _b, _d;
390
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));
391
407
  }, [enduser === null || enduser === void 0 ? void 0 : enduser.state, addressQuestion]);
408
+ // load from database
392
409
  var loadRef = (0, react_1.useRef)(false); // so session changes don't cause
393
410
  (0, react_1.useEffect)(function () {
394
- var _a;
411
+ var _a, _b;
395
412
  if (((_a = field === null || field === void 0 ? void 0 : field.options) === null || _a === void 0 ? void 0 : _a.dataSource) === constants_1.CANVAS_TITLE)
396
413
  return; // instead, look-up while typing against Canvas Search API
414
+ if (((_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.dataSource) === constants_1.BRIDGE_TITLE)
415
+ return; // instead, look-up while typing against Bridge Search API
397
416
  if (loadRef.current)
398
417
  return;
399
418
  loadRef.current = true;
@@ -416,10 +435,11 @@ var InsuranceInput = function (_a) {
416
435
  })
417
436
  .catch(console.error);
418
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
419
439
  var searchRef = (0, react_1.useRef)(query);
420
440
  (0, react_1.useEffect)(function () {
421
- var _a;
422
- if (((_a = field === null || field === void 0 ? void 0 : field.options) === null || _a === void 0 ? void 0 : _a.dataSource) !== constants_1.CANVAS_TITLE) {
441
+ var _a, _b, _d, _e;
442
+ if (((_a = field === null || field === void 0 ? void 0 : field.options) === null || _a === void 0 ? void 0 : _a.dataSource) !== constants_1.CANVAS_TITLE && ((_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.dataSource) !== constants_1.BRIDGE_TITLE) {
423
443
  return;
424
444
  }
425
445
  if (!query)
@@ -427,24 +447,30 @@ var InsuranceInput = function (_a) {
427
447
  if (searchRef.current === query)
428
448
  return;
429
449
  searchRef.current = query;
430
- session.api.integrations.proxy_read({
431
- integration: constants_1.CANVAS_TITLE,
450
+ var integration = ((_d = field === null || field === void 0 ? void 0 : field.options) === null || _d === void 0 ? void 0 : _d.dataSource) === constants_1.CANVAS_TITLE ? constants_1.CANVAS_TITLE : constants_1.BRIDGE_TITLE;
451
+ var type = ((_e = field === null || field === void 0 ? void 0 : field.options) === null || _e === void 0 ? void 0 : _e.dataSource) === constants_1.CANVAS_TITLE ? 'organizations' : 'payers';
452
+ var t = setTimeout(function () { return (session.api.integrations.proxy_read({
453
+ integration: integration,
432
454
  query: query,
433
- type: 'organizations',
455
+ type: type,
434
456
  })
435
457
  .then(function (_a) {
436
458
  var data = _a.data;
437
459
  try {
438
- setPayers(data.map(function (d) { return ({
439
- id: d.resource.id,
440
- name: d.resource.name,
441
- }); }));
460
+ setPayers(data.map(function (d) {
461
+ var _a, _b;
462
+ return ({
463
+ id: ((_a = field === null || field === void 0 ? void 0 : field.options) === null || _a === void 0 ? void 0 : _a.dataSource) === constants_1.CANVAS_TITLE ? d.resource.id : d.id,
464
+ name: ((_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.dataSource) === constants_1.CANVAS_TITLE ? d.resource.name : d.name,
465
+ });
466
+ }));
442
467
  }
443
468
  catch (err) {
444
469
  console.error;
445
470
  }
446
471
  })
447
- .catch(console.error);
472
+ .catch(console.error)); }, 300);
473
+ return function () { clearTimeout(t); };
448
474
  }, [session, (_d = field === null || field === void 0 ? void 0 : field.options) === null || _d === void 0 ? void 0 : _d.dataSource, query]);
449
475
  return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, spacing: 2, sx: { mt: '0' } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12, sm: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.Autocomplete, { freeSolo: !((_e = field.options) === null || _e === void 0 ? void 0 : _e.requirePredefinedInsurer), options: payers.map(function (p) { return p.name; }), value: (value === null || value === void 0 ? void 0 : value.payerName) || '', onChange: function (e, v) {
450
476
  var _a, _b;
@@ -462,37 +488,395 @@ var InsuranceInput = function (_a) {
462
488
  if (databaseRecord) {
463
489
  onDatabaseSelect === null || onDatabaseSelect === void 0 ? void 0 : onDatabaseSelect([databaseRecord]);
464
490
  }
465
- onChange(__assign(__assign({}, value), { payerName: v || '', 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);
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);
466
493
  }, renderInput: function (params) {
467
- var _a;
468
- return ((0, jsx_runtime_1.jsx)(material_1.TextField, __assign({}, params, { InputProps: __assign(__assign({}, params.InputProps), { sx: 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 ? "Search insurer..." : "Insurer" })));
469
- } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12, sm: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { InputProps: exports.defaultInputProps, required: !field.isOptional, fullWidth: true, value: (_g = value === null || value === void 0 ? void 0 : value.memberId) !== null && _g !== void 0 ? _g : '', onChange: function (e) { return onChange(__assign(__assign({}, value), { memberId: e.target.value }), field.id); }, label: (0, __1.form_display_text_for_language)(form, "Member ID", ''), size: "small" }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12, sm: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { InputProps: exports.defaultInputProps, required: false, fullWidth: true, value: (_h = value === null || value === void 0 ? void 0 : value.planName) !== null && _h !== void 0 ? _h : '', onChange: function (e) { return onChange(__assign(__assign({}, value), { planName: e.target.value }), field.id); }, label: (0, __1.form_display_text_for_language)(form, "Plan Name", ''), size: "small" }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12, sm: 6 }, { children: (0, jsx_runtime_1.jsx)(exports.DateStringInput, { size: "small", label: "Plan Start Date", field: __assign(__assign({}, field), { isOptional: true }), value: (value === null || value === void 0 ? void 0 : value.startDate) || '', onChange: function (startDate) {
494
+ var _a, _b;
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" })));
496
+ } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12, sm: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { InputProps: inputProps || exports.defaultInputProps, required: !field.isOptional, fullWidth: true, value: (_g = value === null || value === void 0 ? void 0 : value.memberId) !== null && _g !== void 0 ? _g : '', onChange: function (e) { return onChange(__assign(__assign({}, value), { memberId: e.target.value }), field.id); }, label: (0, __1.form_display_text_for_language)(form, "Member ID", ''), size: "small" }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12, sm: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { InputProps: inputProps || exports.defaultInputProps, required: false, fullWidth: true, value: (_h = value === null || value === void 0 ? void 0 : value.planName) !== null && _h !== void 0 ? _h : '', onChange: function (e) { return onChange(__assign(__assign({}, value), { planName: e.target.value }), field.id); }, label: (0, __1.form_display_text_for_language)(form, "Plan Name", ''), size: "small" }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12, sm: 6 }, { children: (0, jsx_runtime_1.jsx)(exports.DateStringInput, { size: "small", label: "Plan Start Date", inputProps: inputProps, field: __assign(__assign({}, field), { isOptional: true }), value: (value === null || value === void 0 ? void 0 : value.startDate) || '', onChange: function (startDate) {
470
497
  return onChange(__assign(__assign({}, value), { startDate: startDate }), field.id);
471
498
  } }) })), ((_j = field.options) === null || _j === void 0 ? void 0 : _j.includeGroupNumber) &&
472
- (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { InputProps: exports.defaultInputProps, fullWidth: true, value: (_k = value === null || value === void 0 ? void 0 : value.groupNumber) !== null && _k !== void 0 ? _k : '', onChange: function (e) { return onChange(__assign(__assign({}, value), { groupNumber: e.target.value }), field.id); }, label: (0, __1.form_display_text_for_language)(form, "Group Number", ''), size: "small" }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(StringSelector, { size: "small", label: "Relationship to Policy Owner", options: ((((_l = field.options) === null || _l === void 0 ? void 0 : _l.billingProvider) === constants_1.CANVAS_TITLE || ((_m = field.options) === null || _m === void 0 ? void 0 : _m.dataSource) === constants_1.CANVAS_TITLE)
499
+ (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { InputProps: inputProps || exports.defaultInputProps, fullWidth: true, value: (_k = value === null || value === void 0 ? void 0 : value.groupNumber) !== null && _k !== void 0 ? _k : '', onChange: function (e) { return onChange(__assign(__assign({}, value), { groupNumber: e.target.value }), field.id); }, label: (0, __1.form_display_text_for_language)(form, "Group Number", ''), size: "small" }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(StringSelector, { size: "small", label: "Relationship to Policy Owner", inputProps: inputProps, options: ((((_l = field.options) === null || _l === void 0 ? void 0 : _l.billingProvider) === constants_1.CANVAS_TITLE || ((_m = field.options) === null || _m === void 0 ? void 0 : _m.dataSource) === constants_1.CANVAS_TITLE)
473
500
  ? constants_1.INSURANCE_RELATIONSHIPS_CANVAS
474
501
  : constants_1.INSURANCE_RELATIONSHIPS)
475
502
  .sort(function (x, y) { return x.localeCompare(y); }), value: (value === null || value === void 0 ? void 0 : value.relationship) || 'Self', onChange: function (relationship) {
476
503
  return onChange(__assign(__assign({}, value), { relationship: relationship || 'Self' }), field.id);
477
504
  } }) })), ((value === null || value === void 0 ? void 0 : value.relationship) || 'Self') !== 'Self' &&
478
- (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ sx: { fontWeight: 'bold' } }, { children: "Policy Owner Details" })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { label: "First Name", size: "small", InputProps: exports.defaultInputProps, fullWidth: true, value: ((_o = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _o === void 0 ? void 0 : _o.fname) || '', required: !field.isOptional, onChange: function (e) {
505
+ (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ sx: { fontWeight: 'bold' } }, { children: "Policy Owner Details" })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { label: "First Name", size: "small", InputProps: inputProps || exports.defaultInputProps, fullWidth: true, value: ((_o = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _o === void 0 ? void 0 : _o.fname) || '', required: !field.isOptional, onChange: function (e) {
479
506
  return onChange(__assign(__assign({}, value), { relationshipDetails: __assign(__assign({}, value === null || value === void 0 ? void 0 : value.relationshipDetails), { fname: e.target.value }) }), field.id);
480
- } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { label: "Last Name", size: "small", InputProps: exports.defaultInputProps, fullWidth: true, value: ((_p = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _p === void 0 ? void 0 : _p.lname) || '', required: !field.isOptional, onChange: function (e) {
507
+ } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { label: "Last Name", size: "small", InputProps: inputProps || exports.defaultInputProps, fullWidth: true, value: ((_p = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _p === void 0 ? void 0 : _p.lname) || '', required: !field.isOptional, onChange: function (e) {
481
508
  return onChange(__assign(__assign({}, value), { relationshipDetails: __assign(__assign({}, value === null || value === void 0 ? void 0 : value.relationshipDetails), { lname: e.target.value }) }), field.id);
482
- } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: (0, jsx_runtime_1.jsx)(StringSelector, { options: constants_1.TELLESCOPE_GENDERS, size: "small", label: "Gender", value: ((_q = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _q === void 0 ? void 0 : _q.gender) || '', required: !field.isOptional, onChange: function (v) {
509
+ } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: (0, jsx_runtime_1.jsx)(StringSelector, { options: constants_1.TELLESCOPE_GENDERS, size: "small", label: "Gender", inputProps: inputProps, value: ((_q = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _q === void 0 ? void 0 : _q.gender) || '', required: !field.isOptional, onChange: function (v) {
483
510
  return onChange(__assign(__assign({}, value), { relationshipDetails: __assign(__assign({}, value === null || value === void 0 ? void 0 : value.relationshipDetails), { gender: v }) }), field.id);
484
- } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: (0, jsx_runtime_1.jsx)(exports.DateStringInput, { size: "small", label: "Date of Birth", field: __assign(__assign({}, field), { isOptional: field.isOptional || ((_r = field.options) === null || _r === void 0 ? void 0 : _r.billingProvider) === 'Candid' }), value: ((_s = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _s === void 0 ? void 0 : _s.dateOfBirth) || '', onChange: function (dateOfBirth) {
511
+ } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: (0, jsx_runtime_1.jsx)(exports.DateStringInput, { size: "small", label: "Date of Birth", inputProps: inputProps, field: __assign(__assign({}, field), { isOptional: field.isOptional || ((_r = field.options) === null || _r === void 0 ? void 0 : _r.billingProvider) === 'Candid' }), value: ((_s = value === null || value === void 0 ? void 0 : value.relationshipDetails) === null || _s === void 0 ? void 0 : _s.dateOfBirth) || '', onChange: function (dateOfBirth) {
485
512
  return onChange(__assign(__assign({}, value), { relationshipDetails: __assign(__assign({}, value === null || value === void 0 ? void 0 : value.relationshipDetails), { dateOfBirth: dateOfBirth }) }), field.id);
486
513
  } }) }))] })] })));
487
514
  };
488
515
  exports.InsuranceInput = InsuranceInput;
489
516
  var StringSelector = function (_a) {
490
- var options = _a.options, value = _a.value, onChange = _a.onChange, required = _a.required, getDisplayValue = _a.getDisplayValue, props = __rest(_a, ["options", "value", "onChange", "required", "getDisplayValue"]);
491
- return ((0, jsx_runtime_1.jsxs)(material_1.FormControl, __assign({ fullWidth: true, size: props.size, required: required }, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: props.label }), (0, jsx_runtime_1.jsx)(material_1.Select, __assign({}, props, { value: value, onChange: function (e) { return onChange(e.target.value); }, fullWidth: true, sx: exports.defaultInputProps.sx }, { children: options.map(function (o, i) {
517
+ var options = _a.options, value = _a.value, onChange = _a.onChange, required = _a.required, getDisplayValue = _a.getDisplayValue, inputProps = _a.inputProps, props = __rest(_a, ["options", "value", "onChange", "required", "getDisplayValue", "inputProps"]);
518
+ return ((0, jsx_runtime_1.jsxs)(material_1.FormControl, __assign({ fullWidth: true, size: props.size, required: required }, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: props.label }), (0, jsx_runtime_1.jsx)(material_1.Select, __assign({}, props, { value: value, onChange: function (e) { return onChange(e.target.value); }, fullWidth: true, sx: (inputProps || exports.defaultInputProps).sx }, { children: options.map(function (o, i) {
492
519
  var _a;
493
520
  return ((0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: o }, { children: (_a = getDisplayValue === null || getDisplayValue === void 0 ? void 0 : getDisplayValue(o)) !== null && _a !== void 0 ? _a : o }), o || i));
494
521
  }) }))] })));
495
522
  };
523
+ var BridgeEligibilityInput = function (_a) {
524
+ var _b, _d, _e, _f, _g, _h, _j;
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"]);
526
+ var session = (0, __1.useResolvedSession)();
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];
530
+ // single-page form must require button-click to check, but 1-page-at-a-time enduser sessions should auto-check
531
+ var isEnduserSession = session.type === 'enduser';
532
+ var eligibilityType = ((_b = field.options) === null || _b === void 0 ? void 0 : _b.bridgeEligibilityType) || 'Soft';
533
+ // Extract payerId from Insurance question response
534
+ var _o = (0, react_1.useMemo)(function () {
535
+ var _a, _b, _d, _e;
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); });
537
+ if (((_a = insuranceResponse === null || insuranceResponse === void 0 ? void 0 : insuranceResponse.answer) === null || _a === void 0 ? void 0 : _a.type) === 'Insurance') {
538
+ return [
539
+ (_b = insuranceResponse.answer.value) === null || _b === void 0 ? void 0 : _b.payerId,
540
+ (_d = insuranceResponse.answer.value) === null || _d === void 0 ? void 0 : _d.memberId,
541
+ (_e = insuranceResponse.answer.value) === null || _e === void 0 ? void 0 : _e.payerName,
542
+ ];
543
+ }
544
+ // existing payer id is automatically resolved on the backend as default
545
+ return [];
546
+ }, [responses]), payerId = _o[0], memberId = _o[1], payerName = _o[2];
547
+ // Extract state from Address question or enduser
548
+ var state = (0, react_1.useMemo)(function () {
549
+ var _a, _b;
550
+ // Find Address field with state value
551
+ var addressResponse = 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) === 'Address' && ((_d = (_b = r.answer) === null || _b === void 0 ? void 0 : _b.value) === null || _d === void 0 ? void 0 : _d.state); });
552
+ if (((_a = addressResponse === null || addressResponse === void 0 ? void 0 : addressResponse.answer) === null || _a === void 0 ? void 0 : _a.type) === 'Address') {
553
+ return (_b = addressResponse.answer.value) === null || _b === void 0 ? void 0 : _b.state;
554
+ }
555
+ // enduser state is automatically resolved on the backend as default
556
+ }, [responses]);
557
+ // Soft eligibility check function - supports multiple service type IDs
558
+ var checkProviderEligibility = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
559
+ var serviceTypeIds, results, allUserIds, uniqueUserIds, aggregatedStatus, err_1;
560
+ var _a, _b;
561
+ return __generator(this, function (_d) {
562
+ switch (_d.label) {
563
+ case 0:
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');
567
+ return [2 /*return*/];
568
+ }
569
+ // payerId and state can be automatically resolved on the backend, if already saved on Enduser, so not required here
570
+ setLoading(true);
571
+ setError(undefined);
572
+ _d.label = 1;
573
+ case 1:
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
612
+ ];
613
+ case 2:
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
623
+ onChange({
624
+ payerId: payerId,
625
+ status: aggregatedStatus,
626
+ userIds: uniqueUserIds,
627
+ }, field.id);
628
+ return [3 /*break*/, 5];
629
+ case 3:
630
+ err_1 = _d.sent();
631
+ setError((err_1 === null || err_1 === void 0 ? void 0 : err_1.message) || 'Failed to check eligibility');
632
+ console.error('Provider eligibility check failed:', err_1);
633
+ return [3 /*break*/, 5];
634
+ case 4:
635
+ setLoading(false);
636
+ return [7 /*endfinally*/];
637
+ case 5: return [2 /*return*/];
638
+ }
639
+ });
640
+ }); }, [session, field, payerId, state, onChange, enduserId]);
641
+ // Hard eligibility check function with polling - supports multiple service type IDs
642
+ var checkServiceEligibility = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
643
+ var serviceTypeIds, initiatedChecks_1, pollForAllResults, err_3;
644
+ var _a;
645
+ return __generator(this, function (_b) {
646
+ switch (_b.label) {
647
+ case 0:
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');
651
+ return [2 /*return*/];
652
+ }
653
+ setLoading(true);
654
+ setError(undefined);
655
+ _b.label = 1;
656
+ case 1:
657
+ _b.trys.push([1, 3, , 4]);
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
+ }); }))];
698
+ case 2:
699
+ initiatedChecks_1 = _b.sent();
700
+ setLoading(false);
701
+ setPolling(true);
702
+ pollForAllResults = function () { return __awaiter(void 0, void 0, void 0, function () {
703
+ var maxAttempts, checkStatuses, attempts, pollAll;
704
+ return __generator(this, function (_a) {
705
+ maxAttempts = 60 // Poll for up to 60 attempts (2 minutes at 2s intervals)
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
+ ]; }));
715
+ attempts = 0;
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) {
721
+ case 0:
722
+ if (attempts >= maxAttempts) {
723
+ setError('Eligibility check timed out. Please try again.');
724
+ setPolling(false);
725
+ return [2 /*return*/];
726
+ }
727
+ attempts++;
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
+ ];
776
+ case 1:
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
797
+ onChange({
798
+ payerId: payerId,
799
+ status: aggregatedStatus,
800
+ userIds: uniqueUserIds,
801
+ }, field.id);
802
+ setPolling(false);
803
+ return [2 /*return*/];
804
+ }
805
+ // Still have pending checks, poll again after delay
806
+ setTimeout(pollAll, 2000); // Poll every 2 seconds
807
+ return [2 /*return*/];
808
+ }
809
+ });
810
+ }); };
811
+ pollAll();
812
+ return [2 /*return*/];
813
+ });
814
+ }); };
815
+ pollForAllResults();
816
+ return [3 /*break*/, 4];
817
+ case 3:
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);
821
+ setLoading(false);
822
+ setPolling(false);
823
+ return [3 /*break*/, 4];
824
+ case 4: return [2 /*return*/];
825
+ }
826
+ });
827
+ }); }, [session, field, payerId, memberId, state, onChange, enduserId]);
828
+ // Auto-check eligibility for enduser sessions
829
+ var autoCheckRef = (0, react_1.useRef)(false);
830
+ (0, react_1.useEffect)(function () {
831
+ if (!isEnduserSession)
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
+ }
837
+ if (autoCheckRef.current)
838
+ return;
839
+ autoCheckRef.current = true;
840
+ if (eligibilityType === 'Hard') {
841
+ checkServiceEligibility();
842
+ }
843
+ else {
844
+ checkProviderEligibility();
845
+ }
846
+ }, [isEnduserSession, eligibilityType, checkProviderEligibility, checkServiceEligibility, value, payerId]);
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: {
848
+ padding: 16,
849
+ backgroundColor: '#ffebee',
850
+ border: '2px solid #f44336'
851
+ } }, { 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: "\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", 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]);
852
+ 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]);
853
+ var resultsComponent = (0, react_1.useMemo)(function () {
854
+ var isEligible = (value === null || value === void 0 ? void 0 : value.status) === 'ELIGIBLE';
855
+ 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: {
856
+ padding: 16,
857
+ backgroundColor: isEligible ? '#e8f5e9' : '#fff3e0',
858
+ border: "2px solid ".concat(isEligible ? '#4caf50' : '#ff9800')
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
860
+ ? "".concat(payerName || 'Your insurance provider', " is accepted!")
861
+ : 'Eligibility Status: ' + (0, utilities_1.first_letter_capitalized)(((value === null || value === void 0 ? void 0 : value.status) || 'Unknown').toLowerCase()) })) }))] })) })) })) })));
862
+ }, [value, payerName]);
863
+ // Loading/polling state for enduser sessions
864
+ if (isEnduserSession) {
865
+ if (loading || polling) {
866
+ return checkingEligibilityComponent;
867
+ }
868
+ if (error) {
869
+ return errorComponent;
870
+ }
871
+ if (value === null || value === void 0 ? void 0 : value.status) {
872
+ return resultsComponent;
873
+ }
874
+ return errorComponent;
875
+ }
876
+ // User/admin interface (non-enduser sessions)
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) }))] })))] })));
878
+ };
879
+ exports.BridgeEligibilityInput = BridgeEligibilityInput;
496
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(); }) }))); };
497
881
  var MinuteSelector = function (props) { return ((0, jsx_runtime_1.jsx)(StringSelector, __assign({}, props, { options: Array(60).fill('').map(function (_, i) { return i <= 9 ? "0".concat(i) : i.toString(); }) }))); };
498
882
  var AmPmSelector = function (props) { return ((0, jsx_runtime_1.jsx)(StringSelector, __assign({}, props, { options: ['AM', 'PM'] }))); };
@@ -1886,17 +2270,17 @@ var RelatedContactsInput = function (_a) {
1886
2270
  };
1887
2271
  exports.RelatedContactsInput = RelatedContactsInput;
1888
2272
  var AppointmentBookingInput = function (_a) {
1889
- var _b, _d, _e, _f, _g, _h, _j, _k, _l;
2273
+ var _b, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1890
2274
  var formResponseId = _a.formResponseId, field = _a.field, value = _a.value, onChange = _a.onChange, form = _a.form, responses = _a.responses, goToPreviousField = _a.goToPreviousField, isPreviousDisabled = _a.isPreviousDisabled, enduserId = _a.enduserId, props = __rest(_a, ["formResponseId", "field", "value", "onChange", "form", "responses", "goToPreviousField", "isPreviousDisabled", "enduserId"]);
1891
2275
  var session = (0, __1.useResolvedSession)();
1892
- var _m = (0, react_1.useState)(), loaded = _m[0], setLoaded = _m[1];
1893
- var _o = (0, react_1.useState)(''), error = _o[0], setError = _o[1];
1894
- var _p = (0, react_1.useState)(false), acknowledgedWarning = _p[0], setAcknowledgedWarning = _p[1];
1895
- var _q = (0, react_1.useState)(450), height = _q[0], setHeight = _q[1];
1896
- var _r = (0, react_1.useState)(false), confirming = _r[0], setConfirming = _r[1];
2276
+ var _o = (0, react_1.useState)(), loaded = _o[0], setLoaded = _o[1];
2277
+ var _p = (0, react_1.useState)(''), error = _p[0], setError = _p[1];
2278
+ var _q = (0, react_1.useState)(false), acknowledgedWarning = _q[0], setAcknowledgedWarning = _q[1];
2279
+ var _r = (0, react_1.useState)(450), height = _r[0], setHeight = _r[1];
2280
+ var _s = (0, react_1.useState)(false), confirming = _s[0], setConfirming = _s[1];
1897
2281
  var bookingPageId = (_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.bookingPageId;
1898
2282
  var downloadICS = (0, react_1.useCallback)(function (event) { return __awaiter(void 0, void 0, void 0, function () {
1899
- var _a, err_1;
2283
+ var _a, err_6;
1900
2284
  return __generator(this, function (_b) {
1901
2285
  switch (_b.label) {
1902
2286
  case 0:
@@ -1908,8 +2292,8 @@ var AppointmentBookingInput = function (_a) {
1908
2292
  { name: "event.ics", dataIsURL: true, type: 'text/calendar' }]);
1909
2293
  return [3 /*break*/, 3];
1910
2294
  case 2:
1911
- err_1 = _b.sent();
1912
- console.error(err_1);
2295
+ err_6 = _b.sent();
2296
+ console.error(err_6);
1913
2297
  return [3 /*break*/, 3];
1914
2298
  case 3: return [2 /*return*/];
1915
2299
  }
@@ -2045,12 +2429,20 @@ var AppointmentBookingInput = function (_a) {
2045
2429
  })
2046
2430
  .join(','));
2047
2431
  }
2432
+ // Filter to Bridge eligibility userIds if option is enabled
2433
+ if ((_h = field.options) === null || _h === void 0 ? void 0 : _h.useBridgeEligibilityResult) {
2434
+ var bridgeUserIds = (0, exports.getBridgeEligibilityUserIds)();
2435
+ if (bridgeUserIds.length === 0) {
2436
+ return (0, jsx_runtime_1.jsx)(material_1.Typography, { children: "No eligible users found for booking" });
2437
+ }
2438
+ bookingURL += "&userIds=".concat(bridgeUserIds.join(','));
2439
+ }
2048
2440
  // need to use form?.id for internally-submitted forms because formResponseId isn't generated until initial submission or saved draft
2049
- if (((_h = field.options) === null || _h === void 0 ? void 0 : _h.holdAppointmentMinutes) && (formResponseId || (field === null || field === void 0 ? void 0 : field.id))) {
2441
+ if (((_j = field.options) === null || _j === void 0 ? void 0 : _j.holdAppointmentMinutes) && (formResponseId || (field === null || field === void 0 ? void 0 : field.id))) {
2050
2442
  bookingURL += "&formResponseId=".concat(formResponseId || (field === null || field === void 0 ? void 0 : field.id));
2051
2443
  bookingURL += "&holdAppointmentMinutes=".concat(field.options.holdAppointmentMinutes);
2052
2444
  }
2053
- return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, direction: "column", spacing: 1, sx: { mt: 1 } }, { children: [!!((_k = (_j = field.options) === null || _j === void 0 ? void 0 : _j.userFilterTags) === null || _k === void 0 ? void 0 : _k.length) && !((_l = field.options.userTags) === null || _l === void 0 ? void 0 : _l.length) && !(isPreviousDisabled === null || isPreviousDisabled === void 0 ? void 0 : isPreviousDisabled()) && !confirming &&
2445
+ return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, direction: "column", spacing: 1, sx: { mt: 1 } }, { children: [!!((_l = (_k = field.options) === null || _k === void 0 ? void 0 : _k.userFilterTags) === null || _l === void 0 ? void 0 : _l.length) && !((_m = field.options.userTags) === null || _m === void 0 ? void 0 : _m.length) && !(isPreviousDisabled === null || isPreviousDisabled === void 0 ? void 0 : isPreviousDisabled()) && !confirming &&
2054
2446
  (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, alignSelf: "flex-start" }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ variant: "outlined", onClick: goToPreviousField, sx: { height: 25, p: 0.5, px: 1 } }, { children: "Back" })) })), loaded.warningMessage &&
2055
2447
  (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ color: "error", sx: { fontSize: 20, fontWeight: 'bold' } }, { children: loaded.warningMessage })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (!loaded.warningMessage || acknowledgedWarning)
2056
2448
  ? ((0, jsx_runtime_1.jsx)("iframe", { title: "Appointment Booking Embed", src: bookingURL, style: { border: 'none', width: '100%', height: height } }))