@tellescope/react-components 1.237.6 → 1.239.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.
- package/lib/cjs/Forms/forms.d.ts.map +1 -1
- package/lib/cjs/Forms/forms.js +29 -27
- package/lib/cjs/Forms/forms.js.map +1 -1
- package/lib/cjs/Forms/forms.v2.d.ts.map +1 -1
- package/lib/cjs/Forms/forms.v2.js +29 -27
- package/lib/cjs/Forms/forms.v2.js.map +1 -1
- package/lib/cjs/Forms/hooks.d.ts +25 -1
- package/lib/cjs/Forms/hooks.d.ts.map +1 -1
- package/lib/cjs/Forms/hooks.js +40 -2
- package/lib/cjs/Forms/hooks.js.map +1 -1
- package/lib/cjs/Forms/inputs.d.ts +6 -2
- package/lib/cjs/Forms/inputs.d.ts.map +1 -1
- package/lib/cjs/Forms/inputs.js +138 -23
- package/lib/cjs/Forms/inputs.js.map +1 -1
- package/lib/cjs/Forms/inputs.v2.d.ts +2 -1
- package/lib/cjs/Forms/inputs.v2.d.ts.map +1 -1
- package/lib/cjs/Forms/inputs.v2.js +26 -9
- package/lib/cjs/Forms/inputs.v2.js.map +1 -1
- package/lib/cjs/Forms/localization.d.ts.map +1 -1
- package/lib/cjs/Forms/localization.js +7 -0
- package/lib/cjs/Forms/localization.js.map +1 -1
- package/lib/cjs/inputs_shared.d.ts +6 -2
- package/lib/cjs/inputs_shared.d.ts.map +1 -1
- package/lib/cjs/inputs_shared.js +4 -3
- package/lib/cjs/inputs_shared.js.map +1 -1
- package/lib/esm/Forms/forms.d.ts.map +1 -1
- package/lib/esm/Forms/forms.js +30 -28
- package/lib/esm/Forms/forms.js.map +1 -1
- package/lib/esm/Forms/forms.v2.d.ts.map +1 -1
- package/lib/esm/Forms/forms.v2.js +30 -28
- package/lib/esm/Forms/forms.v2.js.map +1 -1
- package/lib/esm/Forms/hooks.d.ts +25 -1
- package/lib/esm/Forms/hooks.d.ts.map +1 -1
- package/lib/esm/Forms/hooks.js +38 -1
- package/lib/esm/Forms/hooks.js.map +1 -1
- package/lib/esm/Forms/inputs.d.ts +6 -2
- package/lib/esm/Forms/inputs.d.ts.map +1 -1
- package/lib/esm/Forms/inputs.js +136 -22
- package/lib/esm/Forms/inputs.js.map +1 -1
- package/lib/esm/Forms/inputs.v2.d.ts +2 -1
- package/lib/esm/Forms/inputs.v2.d.ts.map +1 -1
- package/lib/esm/Forms/inputs.v2.js +25 -9
- package/lib/esm/Forms/inputs.v2.js.map +1 -1
- package/lib/esm/Forms/localization.d.ts.map +1 -1
- package/lib/esm/Forms/localization.js +7 -0
- package/lib/esm/Forms/localization.js.map +1 -1
- package/lib/esm/inputs_shared.d.ts +6 -2
- package/lib/esm/inputs_shared.d.ts.map +1 -1
- package/lib/esm/inputs_shared.js +4 -3
- package/lib/esm/inputs_shared.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/Forms/forms.tsx +9 -2
- package/src/Forms/forms.v2.tsx +9 -2
- package/src/Forms/hooks.tsx +57 -2
- package/src/Forms/inputs.tsx +246 -17
- package/src/Forms/inputs.v2.tsx +29 -11
- package/src/Forms/localization.ts +8 -0
- package/src/inputs_shared.tsx +6 -5
package/lib/cjs/Forms/inputs.js
CHANGED
|
@@ -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.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.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,7 @@ 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
|
+
var hooks_1 = require("./hooks");
|
|
125
126
|
// Bridge Eligibility - shared variable for storing most recent eligibility userIds
|
|
126
127
|
var bridgeEligibilityResult = {
|
|
127
128
|
userIds: [],
|
|
@@ -877,6 +878,92 @@ var BridgeEligibilityInput = function (_a) {
|
|
|
877
878
|
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) }))] })))] })));
|
|
878
879
|
};
|
|
879
880
|
exports.BridgeEligibilityInput = BridgeEligibilityInput;
|
|
881
|
+
var PharmacySearchInput = function (_a) {
|
|
882
|
+
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
|
+
var value = rawValue;
|
|
884
|
+
var session = (0, __1.useResolvedSession)();
|
|
885
|
+
// Get initial ZIP code from responses or enduser data
|
|
886
|
+
var getInitialZipCode = function () {
|
|
887
|
+
var _a;
|
|
888
|
+
// Check Address field responses first
|
|
889
|
+
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.zipCode); });
|
|
890
|
+
if (((_a = addressResponse === null || addressResponse === void 0 ? void 0 : addressResponse.answer) === null || _a === void 0 ? void 0 : _a.type) === 'Address') {
|
|
891
|
+
var addressValue = addressResponse.answer.value;
|
|
892
|
+
if (addressValue === null || addressValue === void 0 ? void 0 : addressValue.zipCode) {
|
|
893
|
+
return addressValue.zipCode;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
// Fall back to enduser.zipCode
|
|
897
|
+
return (enduser === null || enduser === void 0 ? void 0 : enduser.zipCode) || '';
|
|
898
|
+
};
|
|
899
|
+
var _b = (0, react_1.useState)(getInitialZipCode()), zipCode = _b[0], setZipCode = _b[1];
|
|
900
|
+
var _d = (0, react_1.useState)(false), loading = _d[0], setLoading = _d[1];
|
|
901
|
+
var _e = (0, react_1.useState)(), error = _e[0], setError = _e[1];
|
|
902
|
+
var _f = (0, react_1.useState)([]), pharmacies = _f[0], setPharmacies = _f[1];
|
|
903
|
+
var _g = (0, react_1.useState)(false), hasSearched = _g[0], setHasSearched = _g[1];
|
|
904
|
+
var searchPharmacies = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
905
|
+
var data, err_6;
|
|
906
|
+
return __generator(this, function (_a) {
|
|
907
|
+
switch (_a.label) {
|
|
908
|
+
case 0:
|
|
909
|
+
if (!zipCode || zipCode.length !== 5) {
|
|
910
|
+
setError((0, __1.form_display_text_for_language)(form, 'Please enter a valid 5-digit ZIP code'));
|
|
911
|
+
return [2 /*return*/];
|
|
912
|
+
}
|
|
913
|
+
setLoading(true);
|
|
914
|
+
setError(undefined);
|
|
915
|
+
setHasSearched(true);
|
|
916
|
+
_a.label = 1;
|
|
917
|
+
case 1:
|
|
918
|
+
_a.trys.push([1, 3, 4, 5]);
|
|
919
|
+
return [4 /*yield*/, session.api.integrations.proxy_read({
|
|
920
|
+
integration: 'ScriptSure',
|
|
921
|
+
type: 'pharmacy-search',
|
|
922
|
+
query: JSON.stringify({ zipCode: zipCode }),
|
|
923
|
+
})];
|
|
924
|
+
case 2:
|
|
925
|
+
data = (_a.sent()).data;
|
|
926
|
+
setPharmacies(data || []);
|
|
927
|
+
if (!(data === null || data === void 0 ? void 0 : data.length)) {
|
|
928
|
+
setError((0, __1.form_display_text_for_language)(form, 'No pharmacies found for this ZIP code'));
|
|
929
|
+
}
|
|
930
|
+
return [3 /*break*/, 5];
|
|
931
|
+
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'));
|
|
934
|
+
setPharmacies([]);
|
|
935
|
+
return [3 /*break*/, 5];
|
|
936
|
+
case 4:
|
|
937
|
+
setLoading(false);
|
|
938
|
+
return [7 /*endfinally*/];
|
|
939
|
+
case 5: return [2 /*return*/];
|
|
940
|
+
}
|
|
941
|
+
});
|
|
942
|
+
}); }, [session, zipCode, form]);
|
|
943
|
+
var handleSelectPharmacy = function (pharmacy) {
|
|
944
|
+
onChange({
|
|
945
|
+
npi: pharmacy.npi,
|
|
946
|
+
ncpdpId: pharmacy.ncpdpId,
|
|
947
|
+
businessName: pharmacy.businessName,
|
|
948
|
+
primaryTelephone: pharmacy.primaryTelephone || '',
|
|
949
|
+
addressLine1: pharmacy.addressLine1,
|
|
950
|
+
city: pharmacy.city,
|
|
951
|
+
stateProvince: pharmacy.stateProvince,
|
|
952
|
+
postalCode: pharmacy.postalCode,
|
|
953
|
+
}, field.id);
|
|
954
|
+
};
|
|
955
|
+
var formatPharmacyAddress = function (p) {
|
|
956
|
+
var parts = [p.addressLine1, p.city, p.stateProvince, p.postalCode].filter(Boolean);
|
|
957
|
+
return parts.join(', ');
|
|
958
|
+
};
|
|
959
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, direction: "column", spacing: 2 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, spacing: 2, alignItems: "flex-end" }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 8, sm: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, size: "small", label: (0, __1.form_display_text_for_language)(form, "ZIP Code"), value: zipCode, onChange: function (e) { return setZipCode(e.target.value.replace(/\D/g, '').slice(0, 5)); }, InputProps: exports.defaultInputProps, placeholder: "12345", required: !field.isOptional }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 4, sm: 6 }, { children: (0, jsx_runtime_1.jsx)(__1.LoadingButton, { variant: "contained", onClick: searchPharmacies, submitText: (0, __1.form_display_text_for_language)(form, "Search"), submittingText: (0, __1.form_display_text_for_language)(form, "Searching..."), submitting: loading, disabled: zipCode.length !== 5 || loading, style: { width: '100%', marginTop: 0 } }) }))] })) })), error && ((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: 14 } }, { children: error })) }))), value && ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Paper, __assign({ elevation: 2, sx: { p: 2, backgroundColor: '#e8f5e9' } }, { children: (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, alignItems: "center", justifyContent: "space-between" }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ item: true, xs: true }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "subtitle1", fontWeight: "bold" }, { children: [(0, jsx_runtime_1.jsx)(icons_material_1.CheckCircleOutline, { sx: { color: 'success.main', mr: 1, verticalAlign: 'middle' } }), value.businessName] })), (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "text.secondary" }, { children: formatPharmacyAddress(value) })), value.primaryTelephone && ((0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "text.secondary" }, { children: value.primaryTelephone })))] })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ onClick: function () { return onChange(undefined, field.id); }, size: "small" }, { children: (0, jsx_runtime_1.jsx)(__1.CancelIcon, {}) })) }))] })) })) }))), !value && hasSearched && pharmacies.length > 0 && ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ item: true }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "subtitle2", sx: { mb: 1 } }, { children: [pharmacies.length, " ", (0, __1.form_display_text_for_language)(form, pharmacies.length === 1 ? 'pharmacy found' : 'pharmacies found')] })), (0, jsx_runtime_1.jsx)(material_1.Box, __assign({ sx: { maxHeight: 300, overflow: 'auto' } }, { children: pharmacies.map(function (pharmacy, index) { return ((0, jsx_runtime_1.jsxs)(material_1.Paper, __assign({ elevation: 1, sx: {
|
|
960
|
+
p: 1.5,
|
|
961
|
+
mb: 1,
|
|
962
|
+
cursor: 'pointer',
|
|
963
|
+
'&:hover': { backgroundColor: '#f5f5f5' },
|
|
964
|
+
}, onClick: function () { return handleSelectPharmacy(pharmacy); } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "subtitle2", fontWeight: "medium" }, { children: pharmacy.businessName })), (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "text.secondary" }, { children: formatPharmacyAddress(pharmacy) })), pharmacy.primaryTelephone && ((0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "caption", color: "text.secondary" }, { children: pharmacy.primaryTelephone })))] }), "".concat(pharmacy.ncpdpId, "-").concat(index))); }) }))] }))), loading && ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(LinearProgress_1.default, {}) })))] })));
|
|
965
|
+
};
|
|
966
|
+
exports.PharmacySearchInput = PharmacySearchInput;
|
|
880
967
|
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(); }) }))); };
|
|
881
968
|
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(); }) }))); };
|
|
882
969
|
var AmPmSelector = function (props) { return ((0, jsx_runtime_1.jsx)(StringSelector, __assign({}, props, { options: ['AM', 'PM'] }))); };
|
|
@@ -1183,13 +1270,24 @@ var multipleChoiceItemSx = {
|
|
|
1183
1270
|
};
|
|
1184
1271
|
var MultipleChoiceInput = function (_a) {
|
|
1185
1272
|
var _b;
|
|
1186
|
-
var field = _a.field, form = _a.form, _value = _a.value, onChange = _a.onChange;
|
|
1273
|
+
var field = _a.field, form = _a.form, _value = _a.value, onChange = _a.onChange, responses = _a.responses, enduser = _a.enduser;
|
|
1187
1274
|
var value = typeof _value === 'string' ? [_value] : _value; // if loading existingResponses, allows them to be a string
|
|
1188
1275
|
var _d = field.options, choices = _d.choices, radio = _d.radio, other = _d.other, optionDetails = _d.optionDetails;
|
|
1189
1276
|
var _e = (0, react_1.useState)({}), expandedDescriptions = _e[0], setExpandedDescriptions = _e[1];
|
|
1190
1277
|
// current other string
|
|
1191
1278
|
var enteringOtherStringRef = react_1.default.useRef(''); // if typing otherString as prefix of a checkbox value, don't auto-select
|
|
1192
1279
|
var otherString = (_b = value === null || value === void 0 ? void 0 : value.find(function (v) { var _a; return v === enteringOtherStringRef.current || !((_a = (choices !== null && choices !== void 0 ? choices : [])) === null || _a === void 0 ? void 0 : _a.find(function (c) { return c === v; })); })) !== null && _b !== void 0 ? _b : '';
|
|
1280
|
+
// Conditional visibility for choices
|
|
1281
|
+
var _f = (0, hooks_1.useConditionalChoices)({
|
|
1282
|
+
choices: choices,
|
|
1283
|
+
optionDetails: optionDetails,
|
|
1284
|
+
responses: responses,
|
|
1285
|
+
enduser: enduser,
|
|
1286
|
+
form: form,
|
|
1287
|
+
onChange: onChange,
|
|
1288
|
+
fieldId: field.id,
|
|
1289
|
+
otherString: otherString,
|
|
1290
|
+
}), visibleChoices = _f.visibleChoices, handleChange = _f.handleChange;
|
|
1193
1291
|
var getDescriptionForChoice = (0, react_1.useCallback)(function (choice) {
|
|
1194
1292
|
var _a;
|
|
1195
1293
|
return (_a = optionDetails === null || optionDetails === void 0 ? void 0 : optionDetails.find(function (detail) { return detail.option === choice; })) === null || _a === void 0 ? void 0 : _a.description;
|
|
@@ -1201,11 +1299,11 @@ var MultipleChoiceInput = function (_a) {
|
|
|
1201
1299
|
});
|
|
1202
1300
|
}, []);
|
|
1203
1301
|
return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, alignItems: "center" }, { children: [radio
|
|
1204
|
-
? ((0, jsx_runtime_1.jsxs)(material_1.FormControl, __assign({ fullWidth: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.FormLabel, __assign({ id: "radio-group-".concat(field.id, "-label") }, { children: (0, __1.form_display_text_for_language)(form, "Select One") })), (0, jsx_runtime_1.jsx)(material_1.RadioGroup, __assign({ "aria-labelledby": "radio-group-".concat(field.id, "-label"), defaultValue: "female", name: "radio-group-".concat(field.id) }, { children:
|
|
1302
|
+
? ((0, jsx_runtime_1.jsxs)(material_1.FormControl, __assign({ fullWidth: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.FormLabel, __assign({ id: "radio-group-".concat(field.id, "-label") }, { children: (0, __1.form_display_text_for_language)(form, "Select One") })), (0, jsx_runtime_1.jsx)(material_1.RadioGroup, __assign({ "aria-labelledby": "radio-group-".concat(field.id, "-label"), defaultValue: "female", name: "radio-group-".concat(field.id) }, { children: visibleChoices.map(function (c, i) {
|
|
1205
1303
|
var description = getDescriptionForChoice(c);
|
|
1206
1304
|
var hasDescription = !!description;
|
|
1207
1305
|
var isExpanded = expandedDescriptions[i];
|
|
1208
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: { width: '100%' } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, __assign({ sx: { display: 'flex', alignItems: 'center', width: '100%' } }, { children: (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { sx: __assign(__assign({}, multipleChoiceItemSx), { flex: 1, marginLeft: '0px' }), checked: !!(value === null || value === void 0 ? void 0 : value.includes(c)) && c !== otherString, control: (0, jsx_runtime_1.jsx)(material_1.Radio, { onClick: function () { return
|
|
1306
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: { width: '100%' } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, __assign({ sx: { display: 'flex', alignItems: 'center', width: '100%' } }, { children: (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { sx: __assign(__assign({}, multipleChoiceItemSx), { flex: 1, marginLeft: '0px' }), checked: !!(value === null || value === void 0 ? void 0 : value.includes(c)) && c !== otherString, control: (0, jsx_runtime_1.jsx)(material_1.Radio, { onClick: function () { return handleChange((value === null || value === void 0 ? void 0 : value.includes(c)) ? [] : [c], field.id); } }), label: (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: { display: 'flex', alignItems: 'center', width: '100%' } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ component: "span", sx: { flex: 1 } }, { children: c })), hasDescription && ((0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ size: "small", onClick: function (e) {
|
|
1209
1307
|
e.stopPropagation();
|
|
1210
1308
|
toggleDescription(i);
|
|
1211
1309
|
}, sx: {
|
|
@@ -1213,7 +1311,7 @@ var MultipleChoiceInput = function (_a) {
|
|
|
1213
1311
|
transition: 'transform 0.2s',
|
|
1214
1312
|
ml: 1
|
|
1215
1313
|
} }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.ExpandMore, { fontSize: "small" }) })))] })) }) })), hasDescription && ((0, jsx_runtime_1.jsx)(material_1.Collapse, __assign({ in: isExpanded }, { children: (0, jsx_runtime_1.jsx)(material_1.Box, __assign({ sx: { pl: '42px', pr: 2, pb: 1 } }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "text.secondary" }, { children: description })) })) })))] }), i));
|
|
1216
|
-
}) }))] }))) : (
|
|
1314
|
+
}) }))] }))) : (visibleChoices.map(function (c, i) {
|
|
1217
1315
|
var description = getDescriptionForChoice(c);
|
|
1218
1316
|
var hasDescription = !!description;
|
|
1219
1317
|
var isExpanded = expandedDescriptions[i];
|
|
@@ -1223,7 +1321,7 @@ var MultipleChoiceInput = function (_a) {
|
|
|
1223
1321
|
if (e.target.closest('.expand-button')) {
|
|
1224
1322
|
return;
|
|
1225
1323
|
}
|
|
1226
|
-
|
|
1324
|
+
handleChange(((value === null || value === void 0 ? void 0 : value.includes(c))
|
|
1227
1325
|
? ((radio || ((_b = (_a = field.options) === null || _a === void 0 ? void 0 : _a.radioChoices) === null || _b === void 0 ? void 0 : _b.includes(c)))
|
|
1228
1326
|
? []
|
|
1229
1327
|
: value.filter(function (v) { return v !== c; }))
|
|
@@ -1244,13 +1342,13 @@ var MultipleChoiceInput = function (_a) {
|
|
|
1244
1342
|
// onClick={() => !otherChecked && handleOtherChecked()} // allow click to enable when disabled
|
|
1245
1343
|
onChange: function (e) {
|
|
1246
1344
|
enteringOtherStringRef.current = e.target.value;
|
|
1247
|
-
|
|
1345
|
+
handleChange((radio
|
|
1248
1346
|
? (e.target.value.trim()
|
|
1249
1347
|
? [e.target.value]
|
|
1250
1348
|
: [])
|
|
1251
1349
|
: (e.target.value.trim()
|
|
1252
1350
|
// remove existing other string (if exists) and append new one
|
|
1253
|
-
? __spreadArray(__spreadArray([], (value !== null && value !== void 0 ? value : []).filter(function (v) { return v !== otherString; }), true), [e.target.value], false) : value
|
|
1351
|
+
? __spreadArray(__spreadArray([], (value !== null && value !== void 0 ? value : []).filter(function (v) { return v !== otherString; }), true), [e.target.value], false) : (value !== null && value !== void 0 ? value : []).filter(function (v) { return v !== otherString; }))), field.id);
|
|
1254
1352
|
} }) }))] })));
|
|
1255
1353
|
};
|
|
1256
1354
|
exports.MultipleChoiceInput = MultipleChoiceInput;
|
|
@@ -1705,6 +1803,7 @@ var DatabaseSelectInput = function (_a) {
|
|
|
1705
1803
|
var AddToDatabase = _a.AddToDatabase, field = _a.field, _value = _a.value, onChange = _a.onChange, onDatabaseSelect = _a.onDatabaseSelect, responses = _a.responses, size = _a.size, disabled = _a.disabled, enduser = _a.enduser, inputProps = _a.inputProps;
|
|
1706
1804
|
var _l = (0, react_1.useState)(''), typing = _l[0], setTyping = _l[1];
|
|
1707
1805
|
var _m = (0, react_1.useState)(false), open = _m[0], setOpen = _m[1];
|
|
1806
|
+
var selectedRecordsCache = (0, react_1.useRef)(new Map());
|
|
1708
1807
|
var _o = useDatabaseChoices({
|
|
1709
1808
|
databaseId: (_b = field.options) === null || _b === void 0 ? void 0 : _b.databaseId,
|
|
1710
1809
|
field: field,
|
|
@@ -1712,15 +1811,31 @@ var DatabaseSelectInput = function (_a) {
|
|
|
1712
1811
|
searchQuery: typing,
|
|
1713
1812
|
}), addChoice = _o.addChoice, choices = _o.choices, doneLoading = _o.doneLoading, isSearching = _o.isSearching, minSearchChars = _o.minSearchChars;
|
|
1714
1813
|
var value = react_1.default.useMemo(function () {
|
|
1715
|
-
var _a, _b;
|
|
1716
1814
|
try {
|
|
1717
|
-
// if the value is a string (some single answer that was
|
|
1815
|
+
// if the value is a string (some single answer that was saved), make sure we coerce to array
|
|
1718
1816
|
var __value = typeof _value === 'string' ? [_value] : _value;
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1817
|
+
var result = [];
|
|
1818
|
+
var _loop_2 = function (v) {
|
|
1819
|
+
var recordId = typeof v === 'string' ? v : v.recordId;
|
|
1820
|
+
// First try to find in current choices
|
|
1821
|
+
var found = choices.find(function (c) {
|
|
1822
|
+
return c.id === recordId || (typeof v === 'string' && label_for_database_record(field, c) === v);
|
|
1722
1823
|
});
|
|
1723
|
-
|
|
1824
|
+
if (found) {
|
|
1825
|
+
// Update cache with found record
|
|
1826
|
+
selectedRecordsCache.current.set(found.id, found);
|
|
1827
|
+
result.push(found);
|
|
1828
|
+
}
|
|
1829
|
+
else if (recordId && selectedRecordsCache.current.has(recordId)) {
|
|
1830
|
+
// Use cached record if not in current choices (e.g., during search)
|
|
1831
|
+
result.push(selectedRecordsCache.current.get(recordId));
|
|
1832
|
+
}
|
|
1833
|
+
};
|
|
1834
|
+
for (var _a = 0, _b = (__value !== null && __value !== void 0 ? __value : []); _a < _b.length; _a++) {
|
|
1835
|
+
var v = _b[_a];
|
|
1836
|
+
_loop_2(v);
|
|
1837
|
+
}
|
|
1838
|
+
return result;
|
|
1724
1839
|
}
|
|
1725
1840
|
catch (err) {
|
|
1726
1841
|
console.error('Error resolving database answers for _value', err);
|
|
@@ -2280,7 +2395,7 @@ var AppointmentBookingInput = function (_a) {
|
|
|
2280
2395
|
var _s = (0, react_1.useState)(false), confirming = _s[0], setConfirming = _s[1];
|
|
2281
2396
|
var bookingPageId = (_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.bookingPageId;
|
|
2282
2397
|
var downloadICS = (0, react_1.useCallback)(function (event) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2283
|
-
var _a,
|
|
2398
|
+
var _a, err_7;
|
|
2284
2399
|
return __generator(this, function (_b) {
|
|
2285
2400
|
switch (_b.label) {
|
|
2286
2401
|
case 0:
|
|
@@ -2292,8 +2407,8 @@ var AppointmentBookingInput = function (_a) {
|
|
|
2292
2407
|
{ name: "event.ics", dataIsURL: true, type: 'text/calendar' }]);
|
|
2293
2408
|
return [3 /*break*/, 3];
|
|
2294
2409
|
case 2:
|
|
2295
|
-
|
|
2296
|
-
console.error(
|
|
2410
|
+
err_7 = _b.sent();
|
|
2411
|
+
console.error(err_7);
|
|
2297
2412
|
return [3 /*break*/, 3];
|
|
2298
2413
|
case 3: return [2 /*return*/];
|
|
2299
2414
|
}
|
|
@@ -2674,7 +2789,7 @@ var AllergiesInput = function (_a) {
|
|
|
2674
2789
|
.flatMap(function (v) { var _a, _b; return ((_b = (_a = v === null || v === void 0 ? void 0 : v.resource) === null || _a === void 0 ? void 0 : _a.code) === null || _b === void 0 ? void 0 : _b.coding) || []; })
|
|
2675
2790
|
.filter(function (v) { return v.system.includes('fdbhealth'); })
|
|
2676
2791
|
.map(function (v) { return ({ code: v.code, display: v.display, system: v.system }); }));
|
|
2677
|
-
var
|
|
2792
|
+
var _loop_3 = function (v) {
|
|
2678
2793
|
if (deduped.find(function (d) { return d.display === v.display; })) {
|
|
2679
2794
|
return "continue";
|
|
2680
2795
|
}
|
|
@@ -2682,7 +2797,7 @@ var AllergiesInput = function (_a) {
|
|
|
2682
2797
|
};
|
|
2683
2798
|
for (var _a = 0, totalResults_1 = totalResults; _a < totalResults_1.length; _a++) {
|
|
2684
2799
|
var v = totalResults_1[_a];
|
|
2685
|
-
|
|
2800
|
+
_loop_3(v);
|
|
2686
2801
|
}
|
|
2687
2802
|
setResults(deduped);
|
|
2688
2803
|
});
|
|
@@ -2691,7 +2806,7 @@ var AllergiesInput = function (_a) {
|
|
|
2691
2806
|
session.api.allergy_codes.getSome({ search: { query: query } })
|
|
2692
2807
|
.then(function (results) {
|
|
2693
2808
|
var deduped = [];
|
|
2694
|
-
var
|
|
2809
|
+
var _loop_4 = function (v) {
|
|
2695
2810
|
if (deduped.find(function (d) { return d.display === v.display; })) {
|
|
2696
2811
|
return "continue";
|
|
2697
2812
|
}
|
|
@@ -2699,7 +2814,7 @@ var AllergiesInput = function (_a) {
|
|
|
2699
2814
|
};
|
|
2700
2815
|
for (var _a = 0, results_1 = results; _a < results_1.length; _a++) {
|
|
2701
2816
|
var v = results_1[_a];
|
|
2702
|
-
|
|
2817
|
+
_loop_4(v);
|
|
2703
2818
|
}
|
|
2704
2819
|
setResults(deduped);
|
|
2705
2820
|
});
|
|
@@ -2735,7 +2850,7 @@ var ConditionsInput = function (_a) {
|
|
|
2735
2850
|
session.api.diagnosis_codes.getSome({ search: { query: query } })
|
|
2736
2851
|
.then(function (codes) {
|
|
2737
2852
|
var deduped = [];
|
|
2738
|
-
var
|
|
2853
|
+
var _loop_5 = function (v) {
|
|
2739
2854
|
if (deduped.find(function (d) { return d.display === v.display; })) {
|
|
2740
2855
|
return "continue";
|
|
2741
2856
|
}
|
|
@@ -2743,7 +2858,7 @@ var ConditionsInput = function (_a) {
|
|
|
2743
2858
|
};
|
|
2744
2859
|
for (var _a = 0, codes_1 = codes; _a < codes_1.length; _a++) {
|
|
2745
2860
|
var v = codes_1[_a];
|
|
2746
|
-
|
|
2861
|
+
_loop_5(v);
|
|
2747
2862
|
}
|
|
2748
2863
|
setResults(deduped);
|
|
2749
2864
|
});
|