@usebridge/sdk-react 0.3.0 → 0.4.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.
- package/dist/index.cjs +29 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +34 -24
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1965,7 +1965,7 @@ var import_sdk_core9 = require("@usebridge/sdk-core");
|
|
|
1965
1965
|
// src/eligibility-input/use-eligibility-input-field.ts
|
|
1966
1966
|
var import_react13 = require("react");
|
|
1967
1967
|
var import_sdk_core8 = require("@usebridge/sdk-core");
|
|
1968
|
-
function useEligibilityInputField(field) {
|
|
1968
|
+
function useEligibilityInputField(field, defaultValue) {
|
|
1969
1969
|
const input = useEligibilityInput();
|
|
1970
1970
|
const inputField = input[field];
|
|
1971
1971
|
const { requirePatient } = input;
|
|
@@ -2028,16 +2028,23 @@ function useEligibilityInputField(field) {
|
|
|
2028
2028
|
default:
|
|
2029
2029
|
throw new Error(`Unknown field: ${field}`);
|
|
2030
2030
|
}
|
|
2031
|
+
const setValue = set;
|
|
2032
|
+
const hasSetDefaultValue = (0, import_react13.useRef)(false);
|
|
2033
|
+
(0, import_react13.useLayoutEffect)(() => {
|
|
2034
|
+
if (hasSetDefaultValue.current) return;
|
|
2035
|
+
if (defaultValue) setValue(defaultValue);
|
|
2036
|
+
hasSetDefaultValue.current = true;
|
|
2037
|
+
}, [setValue, defaultValue]);
|
|
2031
2038
|
return (0, import_react13.useMemo)(
|
|
2032
2039
|
() => ({
|
|
2033
2040
|
value,
|
|
2034
|
-
setValue
|
|
2041
|
+
setValue,
|
|
2035
2042
|
isVisible,
|
|
2036
2043
|
isValid,
|
|
2037
2044
|
isRequired,
|
|
2038
2045
|
isDisabled
|
|
2039
2046
|
}),
|
|
2040
|
-
[value,
|
|
2047
|
+
[value, setValue, isVisible, isValid, isRequired, isDisabled]
|
|
2041
2048
|
);
|
|
2042
2049
|
}
|
|
2043
2050
|
|
|
@@ -2057,30 +2064,33 @@ function useEligibilityInputIsValid() {
|
|
|
2057
2064
|
// src/hard-eligibility/use-hard-eligibility-submit.ts
|
|
2058
2065
|
function useHardEligibilitySubmit() {
|
|
2059
2066
|
const session = useHardEligibilitySession();
|
|
2060
|
-
const {
|
|
2061
|
-
const { isVisible: isMemberIdVisible, isRequired: isMemberIdRequired } = useEligibilityInputField("memberId");
|
|
2067
|
+
const { state, payer, firstName, lastName, dateOfBirth, memberId } = useEligibilityInput();
|
|
2062
2068
|
const { status } = useHardEligibilityState();
|
|
2063
|
-
const
|
|
2069
|
+
const usesExistingPolicy = session.usesExistingPolicy;
|
|
2070
|
+
const inputIsValid = usesExistingPolicy ? Boolean(state.value) : useEligibilityInputIsValid();
|
|
2064
2071
|
const isDisabled = !inputIsValid || !import_sdk_core9.HardEligibility.canSubmit(status);
|
|
2065
2072
|
const submit = (0, import_react14.useCallback)(
|
|
2066
2073
|
({ clinicalInfo } = {}) => {
|
|
2067
|
-
if (!payer.value) throw new Error("Payer is required");
|
|
2068
2074
|
if (!state.value) throw new Error("State is required");
|
|
2069
|
-
|
|
2070
|
-
if (!lastName.value) throw new Error("Last name is required");
|
|
2071
|
-
if (!dateOfBirth.value) throw new Error("Date of birth is required");
|
|
2072
|
-
if (isMemberIdRequired && !memberId.value) throw new Error("Member ID is required");
|
|
2073
|
-
return session.submit({
|
|
2074
|
-
payerId: payer.value.id,
|
|
2075
|
+
const submitArgs = {
|
|
2075
2076
|
state: state.value,
|
|
2076
|
-
firstName: firstName.value,
|
|
2077
|
-
lastName: lastName.value,
|
|
2078
|
-
memberId: isMemberIdVisible ? memberId.value : void 0,
|
|
2079
|
-
dateOfBirth: (0, import_sdk_core9.dateToDateObject)(dateOfBirth.value),
|
|
2080
2077
|
clinicalInfo
|
|
2081
|
-
}
|
|
2078
|
+
};
|
|
2079
|
+
if (!session.usesExistingPolicy) {
|
|
2080
|
+
if (!payer.value || !firstName.value || !lastName.value || !dateOfBirth.value) {
|
|
2081
|
+
throw new Error("Patient information is required");
|
|
2082
|
+
}
|
|
2083
|
+
submitArgs.patient = {
|
|
2084
|
+
payerId: payer.value.id,
|
|
2085
|
+
firstName: firstName.value.trim(),
|
|
2086
|
+
lastName: lastName.value.trim(),
|
|
2087
|
+
dateOfBirth: (0, import_sdk_core9.dateToDateObject)(dateOfBirth.value),
|
|
2088
|
+
memberId: memberId.value?.trim() || void 0
|
|
2089
|
+
};
|
|
2090
|
+
}
|
|
2091
|
+
return session.submit(submitArgs);
|
|
2082
2092
|
},
|
|
2083
|
-
[session,
|
|
2093
|
+
[session, state, payer, firstName, lastName, dateOfBirth, memberId]
|
|
2084
2094
|
);
|
|
2085
2095
|
return (0, import_react14.useMemo)(() => ({ isDisabled, submit }), [isDisabled, submit]);
|
|
2086
2096
|
}
|