@unite-us/app-create-referral 0.15.116 → 0.15.117
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/pages/builder/ReferralBuilderForm.js +96 -357
- package/dist/pages/builder/ReferralBuilderForm.js.map +1 -1
- package/dist/pages/builder/ReferralBuilderFormContent.js +404 -0
- package/dist/pages/builder/ReferralBuilderFormContent.js.map +1 -0
- package/dist/pages/builder/referralBuilderFormDraftAuth.js +106 -0
- package/dist/pages/builder/referralBuilderFormDraftAuth.js.map +1 -0
- package/dist/pages/builder/referralBuilderFormUtils.js +82 -0
- package/dist/pages/builder/referralBuilderFormUtils.js.map +1 -0
- package/dist/pages/builder/referralBuilderFormValidation.js +114 -0
- package/dist/pages/builder/referralBuilderFormValidation.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,112 +1,24 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
import React, { useCallback, useEffect,
|
|
4
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
5
5
|
import { PropTypes } from 'prop-types';
|
|
6
|
-
import { Form,
|
|
7
|
-
import { get, isEmpty
|
|
8
|
-
import { DateField, TextField, SelectField } from '@unite-us/app-components';
|
|
9
|
-
import validateCostAmount from '../../utils/validateCostAmount';
|
|
10
|
-
import validateUnitAmount from '../../utils/validateUnitAmount';
|
|
11
|
-
import InfoPanel from '@unite-us/client-utils/dist/InfoPanel/InfoPanel';
|
|
12
|
-
import { isRequired } from '@unite-us/client-utils/dist/utils/validations/validations';
|
|
13
|
-
import { feeSchedulePrograms as fspUtils } from '@unite-us/client-utils';
|
|
6
|
+
import { Form, FormSpy } from 'react-final-form';
|
|
7
|
+
import { get, isEmpty } from 'lodash';
|
|
14
8
|
import moment from 'moment';
|
|
15
|
-
import {
|
|
16
|
-
import { REFERRAL_PII_PHI_DESCRIPTION } from './constants';
|
|
17
|
-
import AuthorizationSubform from './AuthorizationSubform';
|
|
18
|
-
import ReferralProgramCard from './ReferralProgramCard';
|
|
19
|
-
import { FileUpload } from '../../common/form/FileUploadV2/FileUpload';
|
|
20
|
-
import { isUnlistedReferral, programIsOffPlatform, referralIsOON, referralIsGrouped, shouldShowNetworkSelect, filterNetworks, referralIsFunded } from './utils';
|
|
9
|
+
import { isUnlistedReferral, referralIsOON, shouldShowNetworkSelect, filterNetworks } from './utils';
|
|
21
10
|
import fetchPrimaryWorkers from '../../actions/Referral/fetchPrimaryWorkers';
|
|
22
11
|
import { useDebounce } from '../../utils/useDebounce';
|
|
23
12
|
import { useFeatureFlag } from '../../utils/useFeatureFlag';
|
|
24
|
-
import { cannotMoveToReferralReasons } from '../../actions/Referral/cannotMoveToReferralReasons';
|
|
25
|
-
import ContactDocumentsSelector from '../../common/form/DocumentUploader/components/ContactDocumentsSelector';
|
|
26
13
|
import { useFind } from '../../api/ApiHooks';
|
|
27
14
|
import './ReferralBuilderForm.scss';
|
|
28
|
-
import
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (showNetworkSelect && !values.network) errors.network = "Required";
|
|
36
|
-
return errors;
|
|
37
|
-
};
|
|
38
|
-
const validateOONFields = (values, isOON, validateOpenDate) => {
|
|
39
|
-
const errors = {};
|
|
40
|
-
if (isOON) {
|
|
41
|
-
if (!values.opened_date) {
|
|
42
|
-
errors.opened_date = "Required";
|
|
43
|
-
} else if (!validateOpenDate(values.opened_date)) {
|
|
44
|
-
errors.opened_date = "Invalid date";
|
|
45
|
-
}
|
|
46
|
-
if (!values.primaryWorker) errors.primaryWorker = "Required";
|
|
47
|
-
}
|
|
48
|
-
return errors;
|
|
49
|
-
};
|
|
50
|
-
const validatePaymentAuth = _ref => {
|
|
51
|
-
var _paymentAuthForm$icd;
|
|
52
|
-
let {
|
|
53
|
-
values,
|
|
54
|
-
feeScheduleProgram,
|
|
55
|
-
validateCostAmount,
|
|
56
|
-
validateUnitAmount,
|
|
57
|
-
fspUtils
|
|
58
|
-
} = _ref;
|
|
59
|
-
if (!(feeScheduleProgram !== null && feeScheduleProgram !== void 0 && feeScheduleProgram.authorization_required)) return undefined;
|
|
60
|
-
const paymentAuthForm = values === null || values === void 0 ? void 0 : values.paymentAuthForm;
|
|
61
|
-
const amountRequested = paymentAuthForm === null || paymentAuthForm === void 0 ? void 0 : paymentAuthForm.amount_requested;
|
|
62
|
-
const serviceEnd = paymentAuthForm === null || paymentAuthForm === void 0 ? void 0 : paymentAuthForm.service_end;
|
|
63
|
-
const icd10Code = paymentAuthForm === null || paymentAuthForm === void 0 || (_paymentAuthForm$icd = paymentAuthForm.icd10_code) === null || _paymentAuthForm$icd === void 0 ? void 0 : _paymentAuthForm$icd.value;
|
|
64
|
-
const isCostBased = fspUtils.isCostPaymentType(feeScheduleProgram.payment_type);
|
|
65
|
-
const cmCodeRequired = feeScheduleProgram.cm_code_required_on_authorization;
|
|
66
|
-
return {
|
|
67
|
-
amount_requested: isCostBased ? validateCostAmount(amountRequested) : validateUnitAmount(amountRequested),
|
|
68
|
-
service_end: serviceEnd ? undefined : 'Required',
|
|
69
|
-
icd10_code: icd10Code || !cmCodeRequired ? undefined : 'Required'
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
const validateForm = params => {
|
|
73
|
-
var _errors$paymentAuthFo, _errors$paymentAuthFo2, _errors$paymentAuthFo3;
|
|
74
|
-
const {
|
|
75
|
-
values,
|
|
76
|
-
isOON,
|
|
77
|
-
showClientNeeds,
|
|
78
|
-
showNetworkSelect,
|
|
79
|
-
feeScheduleProgram,
|
|
80
|
-
validateOpenDate,
|
|
81
|
-
validateCostAmount,
|
|
82
|
-
validateUnitAmount,
|
|
83
|
-
fspUtils,
|
|
84
|
-
setReferralErrors,
|
|
85
|
-
index
|
|
86
|
-
} = params;
|
|
87
|
-
const errors = _objectSpread(_objectSpread({}, validateBasicFields(values, showClientNeeds, showNetworkSelect)), validateOONFields(values, isOON, validateOpenDate));
|
|
88
|
-
errors.paymentAuthForm = validatePaymentAuth({
|
|
89
|
-
values,
|
|
90
|
-
feeScheduleProgram,
|
|
91
|
-
validateCostAmount,
|
|
92
|
-
validateUnitAmount,
|
|
93
|
-
fspUtils
|
|
94
|
-
});
|
|
95
|
-
const fieldErrors = {
|
|
96
|
-
description: !!errors.description,
|
|
97
|
-
opened_date: !!errors.opened_date,
|
|
98
|
-
client_need: !!errors.client_need,
|
|
99
|
-
primary_worker: !!errors.primaryWorker,
|
|
100
|
-
network: !!errors.network,
|
|
101
|
-
service_end: !!(errors !== null && errors !== void 0 && (_errors$paymentAuthFo = errors.paymentAuthForm) !== null && _errors$paymentAuthFo !== void 0 && _errors$paymentAuthFo.service_end),
|
|
102
|
-
amount_requested: !!(errors !== null && errors !== void 0 && (_errors$paymentAuthFo2 = errors.paymentAuthForm) !== null && _errors$paymentAuthFo2 !== void 0 && _errors$paymentAuthFo2.amount_requested),
|
|
103
|
-
icd10_code: !!(errors !== null && errors !== void 0 && (_errors$paymentAuthFo3 = errors.paymentAuthForm) !== null && _errors$paymentAuthFo3 !== void 0 && _errors$paymentAuthFo3.icd10_code)
|
|
104
|
-
};
|
|
105
|
-
setReferralErrors(index, fieldErrors);
|
|
106
|
-
return errors;
|
|
107
|
-
};
|
|
108
|
-
export function ReferralBuilderForm(_ref2) {
|
|
109
|
-
var _referral$case2;
|
|
15
|
+
import ReferralBuilderFormContent from './ReferralBuilderFormContent';
|
|
16
|
+
import { buildInitialValues, buildProgramMenus, buildReferralTitle, createOpenDateValidator, getSelectedClientNeeds, mapClientNeeds, mergePrimaryWorkerOptions, toggleProgramMenus } from './referralBuilderFormUtils';
|
|
17
|
+
import { fetchDraftPaymentAuthorizationValues, mergeDraftPaymentAuthorizationInitialValues } from './referralBuilderFormDraftAuth';
|
|
18
|
+
import { validateReferralBuilderForm } from './referralBuilderFormValidation';
|
|
19
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
|
+
export function ReferralBuilderForm(_ref) {
|
|
21
|
+
var _referral$case;
|
|
110
22
|
let {
|
|
111
23
|
currentEmployee,
|
|
112
24
|
currentProvider,
|
|
@@ -129,15 +41,14 @@ export function ReferralBuilderForm(_ref2) {
|
|
|
129
41
|
referralSubtitle,
|
|
130
42
|
caseData,
|
|
131
43
|
personId
|
|
132
|
-
} =
|
|
44
|
+
} = _ref;
|
|
133
45
|
const {
|
|
134
|
-
service,
|
|
135
46
|
programs,
|
|
136
47
|
primaryWorker,
|
|
137
48
|
attachments,
|
|
138
49
|
attachableDocuments
|
|
139
50
|
} = referral;
|
|
140
|
-
const [moveReferralMenus, setMoveReferralMenus] = useState(
|
|
51
|
+
const [moveReferralMenus, setMoveReferralMenus] = useState([]);
|
|
141
52
|
const [uploadedFiles, setUploadedFiles] = useState(attachments);
|
|
142
53
|
const [primaryWorkers, setPrimaryWorkers] = useState(primaryWorker ? [primaryWorker] : []);
|
|
143
54
|
const [initialValues, setInitialValues] = useState(referral);
|
|
@@ -149,9 +60,7 @@ export function ReferralBuilderForm(_ref2) {
|
|
|
149
60
|
filesTooBigAndWrongType: []
|
|
150
61
|
});
|
|
151
62
|
const isOON = referralIsOON(referral);
|
|
152
|
-
const
|
|
153
|
-
const isFunded = referralIsFunded(referral);
|
|
154
|
-
const referralTitle = "Referral ".concat(index + 1, ": ").concat(service === null || service === void 0 ? void 0 : service.name).concat(isGrouped ? ', Grouped' : '').concat(isOON ? ', Off-Platform' : '').concat(isFunded ? ', Funded' : '');
|
|
63
|
+
const referralTitle = buildReferralTitle(referral, index);
|
|
155
64
|
const crtb854ForwardingSuperset = useFeatureFlag('crtb854ForwardingSuperset', false);
|
|
156
65
|
const featureFlagCMultiplelientNeeds = useFeatureFlag('crtb2130MultipleClientNeeds', false);
|
|
157
66
|
const newLanguageDashboard = useFeatureFlag('crtb2182ClarifyReferralLanguage', false);
|
|
@@ -160,17 +69,9 @@ export function ReferralBuilderForm(_ref2) {
|
|
|
160
69
|
// If all the programs in the referral are unlisted, show the user provider networks
|
|
161
70
|
const networks = isUnlistedReferral(referral) ? networksUnlistedProgram : filterNetworks(referral);
|
|
162
71
|
const showNetworkSelect = shouldShowNetworkSelect(networks, programs);
|
|
163
|
-
const onProgramClick = id => {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
p.menuIsOpen = !p.menuIsOpen;
|
|
167
|
-
} else {
|
|
168
|
-
p.menuIsOpen = false;
|
|
169
|
-
}
|
|
170
|
-
return p;
|
|
171
|
-
});
|
|
172
|
-
setMoveReferralMenus(programMenus);
|
|
173
|
-
};
|
|
72
|
+
const onProgramClick = useCallback(id => {
|
|
73
|
+
setMoveReferralMenus(currentMenus => toggleProgramMenus(currentMenus, id));
|
|
74
|
+
}, []);
|
|
174
75
|
const getPrimaryWorkers = useCallback(async () => {
|
|
175
76
|
const {
|
|
176
77
|
primary_workers
|
|
@@ -179,62 +80,43 @@ export function ReferralBuilderForm(_ref2) {
|
|
|
179
80
|
currentEmployee,
|
|
180
81
|
query: debouncedQuery
|
|
181
82
|
});
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
83
|
+
setPrimaryWorkers(currentPrimaryWorkers => mergePrimaryWorkerOptions({
|
|
84
|
+
currentPrimaryWorkers,
|
|
85
|
+
fetchedPrimaryWorkers: primary_workers,
|
|
86
|
+
primaryWorker,
|
|
87
|
+
query: debouncedQuery
|
|
88
|
+
}));
|
|
89
|
+
}, [currentEmployee, debouncedQuery, primaryWorker, referral.sendingProvider.id]);
|
|
186
90
|
const feeScheduleProgram = get(programs, '[0].fee_schedule_program');
|
|
91
|
+
const referralCaseId = (_referral$case = referral.case) === null || _referral$case === void 0 ? void 0 : _referral$case.id;
|
|
92
|
+
const referralState = referral.state;
|
|
93
|
+
const feeSchedulePaymentType = feeScheduleProgram === null || feeScheduleProgram === void 0 ? void 0 : feeScheduleProgram.payment_type;
|
|
94
|
+
const authorizationRequired = feeScheduleProgram === null || feeScheduleProgram === void 0 ? void 0 : feeScheduleProgram.authorization_required;
|
|
187
95
|
const initializePaymentFormValues = useCallback(async () => {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
if (clinicalModifications && clinicalModifications.length > 0) {
|
|
197
|
-
var _clinicalModification;
|
|
198
|
-
const clinicalModification = await coreApi.findRecord('clinical_modifications', clinicalModifications[0].id);
|
|
199
|
-
clinicalModificationData = clinicalModification === null || clinicalModification === void 0 || (_clinicalModification = clinicalModification.data) === null || _clinicalModification === void 0 ? void 0 : _clinicalModification.data;
|
|
200
|
-
}
|
|
201
|
-
const isUnitBased = !fspUtils.isCostPaymentType(feeScheduleProgram === null || feeScheduleProgram === void 0 ? void 0 : feeScheduleProgram.payment_type);
|
|
202
|
-
const amountRequestedInitialValue = isUnitBased ? kaseServiceAuthorizationData === null || kaseServiceAuthorizationData === void 0 ? void 0 : kaseServiceAuthorizationData.requested_unit_amount : (kaseServiceAuthorizationData === null || kaseServiceAuthorizationData === void 0 ? void 0 : kaseServiceAuthorizationData.requested_cents) / 100;
|
|
203
|
-
const paymentAuthFormValues = {
|
|
204
|
-
amount_requested: amountRequestedInitialValue,
|
|
205
|
-
service_end: moment(kaseServiceAuthorizationData === null || kaseServiceAuthorizationData === void 0 ? void 0 : kaseServiceAuthorizationData.requested_ends_at).unix(),
|
|
206
|
-
service_start: moment(kaseServiceAuthorizationData === null || kaseServiceAuthorizationData === void 0 ? void 0 : kaseServiceAuthorizationData.requested_starts_at).unix(),
|
|
207
|
-
icd10_code: !isEmpty(clinicalModificationData) ? {
|
|
208
|
-
value: clinicalModificationData.code,
|
|
209
|
-
id: clinicalModificationData.id
|
|
210
|
-
} : {}
|
|
211
|
-
};
|
|
212
|
-
setInitialValues(previousValues => {
|
|
213
|
-
var _previousValues$case;
|
|
214
|
-
const initialValues = _objectSpread(_objectSpread({}, previousValues), {}, {
|
|
215
|
-
case: _objectSpread(_objectSpread({}, previousValues.case), {}, {
|
|
216
|
-
service_authorization: _objectSpread(_objectSpread({}, (_previousValues$case = previousValues.case) === null || _previousValues$case === void 0 ? void 0 : _previousValues$case.service_authorization), kaseServiceAuthorizationData)
|
|
217
|
-
}),
|
|
218
|
-
paymentAuthForm: _objectSpread(_objectSpread({}, previousValues.paymentAuthForm), paymentAuthFormValues)
|
|
219
|
-
});
|
|
220
|
-
if (crtb854ForwardingSuperset && referralDescription) {
|
|
221
|
-
initialValues.description = referralDescription;
|
|
222
|
-
}
|
|
223
|
-
return initialValues;
|
|
224
|
-
});
|
|
96
|
+
const draftPaymentAuthorizationValues = await fetchDraftPaymentAuthorizationValues({
|
|
97
|
+
caseId: referralCaseId,
|
|
98
|
+
referralState,
|
|
99
|
+
paymentType: feeSchedulePaymentType,
|
|
100
|
+
authorizationRequired
|
|
101
|
+
});
|
|
102
|
+
if (!draftPaymentAuthorizationValues) {
|
|
103
|
+
return;
|
|
225
104
|
}
|
|
226
|
-
|
|
105
|
+
setInitialValues(previousValues => mergeDraftPaymentAuthorizationInitialValues({
|
|
106
|
+
previousValues,
|
|
107
|
+
paymentAuthFormValues: draftPaymentAuthorizationValues.paymentAuthFormValues,
|
|
108
|
+
serviceAuthorizationData: draftPaymentAuthorizationValues.serviceAuthorizationData,
|
|
109
|
+
crtb854ForwardingSuperset,
|
|
110
|
+
referralDescription
|
|
111
|
+
}));
|
|
112
|
+
}, [authorizationRequired, crtb854ForwardingSuperset, feeSchedulePaymentType, referralCaseId, referralDescription, referralState]);
|
|
227
113
|
useEffect(() => {
|
|
228
114
|
if (isOON) {
|
|
229
115
|
getPrimaryWorkers();
|
|
230
116
|
}
|
|
231
117
|
}, [getPrimaryWorkers, isOON]);
|
|
232
118
|
useEffect(() => {
|
|
233
|
-
|
|
234
|
-
id: p.id,
|
|
235
|
-
menuIsOpen: false
|
|
236
|
-
}));
|
|
237
|
-
setMoveReferralMenus(programMenus);
|
|
119
|
+
setMoveReferralMenus(buildProgramMenus(programs));
|
|
238
120
|
}, [programs]);
|
|
239
121
|
const {
|
|
240
122
|
data: clientNeedsData
|
|
@@ -245,64 +127,45 @@ export function ReferralBuilderForm(_ref2) {
|
|
|
245
127
|
placeholderData: undefined
|
|
246
128
|
}
|
|
247
129
|
});
|
|
248
|
-
const clientNeeds = useMemo(() =>
|
|
249
|
-
|
|
250
|
-
return (_clientNeedsData$data = clientNeedsData === null || clientNeedsData === void 0 || (_clientNeedsData$data2 = clientNeedsData.data) === null || _clientNeedsData$data2 === void 0 || (_clientNeedsData$data2 = _clientNeedsData$data2.data) === null || _clientNeedsData$data2 === void 0 ? void 0 : _clientNeedsData$data2.map(condition => ({
|
|
251
|
-
label: upperFirst(condition === null || condition === void 0 ? void 0 : condition.name),
|
|
252
|
-
value: condition === null || condition === void 0 ? void 0 : condition.id
|
|
253
|
-
}))) !== null && _clientNeedsData$data !== void 0 ? _clientNeedsData$data : [];
|
|
254
|
-
}, [clientNeedsData]);
|
|
255
|
-
const selectedClientNeeds = useMemo(() => clientNeeds.filter(clientNeed => {
|
|
256
|
-
var _caseData$person_cond;
|
|
257
|
-
return caseData === null || caseData === void 0 || (_caseData$person_cond = caseData.person_condition_ids) === null || _caseData$person_cond === void 0 ? void 0 : _caseData$person_cond.includes(clientNeed.value);
|
|
258
|
-
}), [clientNeeds, caseData === null || caseData === void 0 ? void 0 : caseData.person_condition_ids]);
|
|
130
|
+
const clientNeeds = useMemo(() => mapClientNeeds(clientNeedsData), [clientNeedsData]);
|
|
131
|
+
const selectedClientNeeds = useMemo(() => getSelectedClientNeeds(clientNeeds, caseData), [caseData, clientNeeds]);
|
|
259
132
|
useEffect(() => {
|
|
260
133
|
if (selectedClientNeeds.length > 0 && !referral.client_need) {
|
|
261
134
|
setInitialValues(prev => _objectSpread(_objectSpread({}, prev), {}, {
|
|
262
135
|
client_need: selectedClientNeeds.map(need => need.value)
|
|
263
136
|
}));
|
|
264
137
|
}
|
|
265
|
-
}, [selectedClientNeeds]);
|
|
138
|
+
}, [referral.client_need, selectedClientNeeds]);
|
|
266
139
|
useEffect(() => {
|
|
267
|
-
setInitialValues(
|
|
268
|
-
|
|
269
|
-
|
|
140
|
+
setInitialValues(buildInitialValues({
|
|
141
|
+
referral,
|
|
142
|
+
isOON,
|
|
143
|
+
primaryWorkers,
|
|
144
|
+
currentEmployeeId: currentEmployee.id,
|
|
145
|
+
crtb854ForwardingSuperset,
|
|
270
146
|
referralDescription
|
|
271
|
-
}
|
|
272
|
-
}, [
|
|
147
|
+
}));
|
|
148
|
+
}, [crtb854ForwardingSuperset, currentEmployee.id, isOON, primaryWorkers, referral, referralDescription]);
|
|
273
149
|
useEffect(() => {
|
|
274
150
|
if (!isEmpty(uploadedFiles)) {
|
|
275
151
|
updateAttachments(uploadedFiles);
|
|
276
152
|
}
|
|
277
|
-
}, [uploadedFiles]);
|
|
153
|
+
}, [updateAttachments, uploadedFiles]);
|
|
278
154
|
useEffect(() => {
|
|
279
155
|
initializePaymentFormValues();
|
|
280
156
|
}, [initializePaymentFormValues]);
|
|
281
157
|
const showClientNeeds = featureFlagCMultiplelientNeeds && !isEmpty(clientNeeds);
|
|
282
|
-
const validateOpenDate =
|
|
283
|
-
try {
|
|
284
|
-
const openDate = new Date(parseInt(date) * 1000);
|
|
285
|
-
const maxDate = new Date(parseInt(today) * 1000);
|
|
286
|
-
const minDate = new Date(moment().subtract(1, 'year').unix() * 1000);
|
|
287
|
-
return isNaN(openDate.getTime()) || openDate.getTime() < minDate || openDate.getTime() > maxDate ? false : true;
|
|
288
|
-
} catch (error) {
|
|
289
|
-
console.error('Error validating open date', error);
|
|
290
|
-
return false;
|
|
291
|
-
}
|
|
292
|
-
};
|
|
158
|
+
const validateOpenDate = useMemo(() => createOpenDateValidator(today), [today]);
|
|
293
159
|
return /*#__PURE__*/_jsx(Form, {
|
|
294
160
|
initialValues: initialValues,
|
|
295
161
|
onSubmit: () => {},
|
|
296
|
-
validate: values =>
|
|
162
|
+
validate: values => validateReferralBuilderForm({
|
|
297
163
|
values,
|
|
298
164
|
isOON,
|
|
299
165
|
showClientNeeds,
|
|
300
166
|
showNetworkSelect,
|
|
301
167
|
feeScheduleProgram,
|
|
302
168
|
validateOpenDate,
|
|
303
|
-
validateCostAmount,
|
|
304
|
-
validateUnitAmount,
|
|
305
|
-
fspUtils,
|
|
306
169
|
setReferralErrors,
|
|
307
170
|
index
|
|
308
171
|
}),
|
|
@@ -315,11 +178,11 @@ export function ReferralBuilderForm(_ref2) {
|
|
|
315
178
|
}
|
|
316
179
|
}
|
|
317
180
|
},
|
|
318
|
-
render:
|
|
181
|
+
render: _ref2 => {
|
|
319
182
|
let {
|
|
320
183
|
form,
|
|
321
184
|
values
|
|
322
|
-
} =
|
|
185
|
+
} = _ref2;
|
|
323
186
|
onSetForm && onSetForm(form);
|
|
324
187
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
325
188
|
children: [/*#__PURE__*/_jsx(FormSpy, {
|
|
@@ -327,165 +190,41 @@ export function ReferralBuilderForm(_ref2) {
|
|
|
327
190
|
values: true
|
|
328
191
|
},
|
|
329
192
|
onChange: onChange
|
|
330
|
-
}), /*#__PURE__*/
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
onClick: onProgramClick,
|
|
366
|
-
isOON: programIsOffPlatform(program),
|
|
367
|
-
menuIsOpen: menuIsOpen,
|
|
368
|
-
unselected: unselected,
|
|
369
|
-
referral: referral,
|
|
370
|
-
removeProgram: removeProgram,
|
|
371
|
-
moveToNewReferral: moveToNewReferral,
|
|
372
|
-
moveToExistingReferral: moveToExistingReferral,
|
|
373
|
-
cannotMoveReasons: cannotMoveReasons
|
|
374
|
-
}, "referral-program-".concat(program === null || program === void 0 ? void 0 : program.id, "-card"));
|
|
375
|
-
}), /*#__PURE__*/_jsxs("p", {
|
|
376
|
-
className: "text-center text-dark-grey my-10",
|
|
377
|
-
children: ["Click on the three-dot icon to edit referral groupings.", hasDraftReferral ? /*#__PURE__*/_jsxs("div", {
|
|
378
|
-
children: ["To add more programs, go to the ", /*#__PURE__*/_jsx("a", {
|
|
379
|
-
onClick: navigateToAddResources,
|
|
380
|
-
children: "Add Resources"
|
|
381
|
-
}), " page."]
|
|
382
|
-
}) : null]
|
|
383
|
-
}), showNetworkSelect && /*#__PURE__*/_jsx("div", {
|
|
384
|
-
className: "mb-10",
|
|
385
|
-
children: /*#__PURE__*/_jsx(Field, {
|
|
386
|
-
name: "network",
|
|
387
|
-
required: true,
|
|
388
|
-
children: params => /*#__PURE__*/_jsx(SelectField, _objectSpread({
|
|
389
|
-
required: true,
|
|
390
|
-
id: "network-selection",
|
|
391
|
-
label: "Network Selection",
|
|
392
|
-
placeholder: "Choose one...",
|
|
393
|
-
options: networks,
|
|
394
|
-
labelKey: "name",
|
|
395
|
-
valueKey: "id",
|
|
396
|
-
validations: isRequired
|
|
397
|
-
}, params))
|
|
398
|
-
}, "referral-".concat(index, "-network"))
|
|
399
|
-
}), (feeScheduleProgram === null || feeScheduleProgram === void 0 ? void 0 : feeScheduleProgram.authorization_required) && /*#__PURE__*/_jsx(AuthorizationSubform, {
|
|
400
|
-
feeScheduleProgram: feeScheduleProgram,
|
|
401
|
-
formValues: values,
|
|
402
|
-
setReferralErrors: errors => setReferralErrors(index, errors)
|
|
403
|
-
}), newLanguageDashboard && isOON && /*#__PURE__*/_jsx("h5", {
|
|
404
|
-
className: "mb-2",
|
|
405
|
-
children: "CASE INFORMATION"
|
|
406
|
-
}), newLanguageDashboard && isOON && /*#__PURE__*/_jsx("div", {
|
|
407
|
-
className: "bg-alert-yellow border border-solid border-canary-yellow rounded p-3 mb-5",
|
|
408
|
-
children: /*#__PURE__*/_jsx("p", {
|
|
409
|
-
className: "text-brand-blue",
|
|
410
|
-
children: "These programs aren't accepting referrals in Unite Us. We'll create an off-platform case where you can document communication with or services provided by the program."
|
|
411
|
-
})
|
|
412
|
-
}), /*#__PURE__*/_jsx(Field, {
|
|
413
|
-
name: "description",
|
|
414
|
-
required: true,
|
|
415
|
-
children: params => /*#__PURE__*/_jsx(TextField, _objectSpread({
|
|
416
|
-
afterLabelContent: /*#__PURE__*/_jsx(InfoPanel, {
|
|
417
|
-
className: "mb-4 mt-2",
|
|
418
|
-
message: REFERRAL_PII_PHI_DESCRIPTION
|
|
419
|
-
}),
|
|
420
|
-
id: "referral-description",
|
|
421
|
-
label: newLanguageDashboard ? "Description" : "Referral Description",
|
|
422
|
-
placeholder: newLanguageDashboard ? "E.g. Client needs food assistance. These programs are off-platform and need to be contacted in order to facilitate the referral." : "Describe your client's current situation and reason for referral.",
|
|
423
|
-
rows: 3,
|
|
424
|
-
inline: false,
|
|
425
|
-
validations: isRequired,
|
|
426
|
-
required: true,
|
|
427
|
-
style: source === 'emr' && get(params, 'meta.touched') && !get(params, 'meta.valid') ? {
|
|
428
|
-
text: {
|
|
429
|
-
'border-color': 'red'
|
|
430
|
-
}
|
|
431
|
-
} : {}
|
|
432
|
-
}, params))
|
|
433
|
-
}, "referral-".concat(index, "-description")), isOON && /*#__PURE__*/_jsx(Field, {
|
|
434
|
-
name: "opened_date",
|
|
435
|
-
required: true,
|
|
436
|
-
children: params => /*#__PURE__*/_jsx(DateField, _objectSpread({
|
|
437
|
-
required: true,
|
|
438
|
-
id: "opened-date",
|
|
439
|
-
label: newLanguageDashboard ? "Case open date" : "Open date",
|
|
440
|
-
validations: validateOpenDate(params.input.value),
|
|
441
|
-
minDate: moment().subtract(1, 'year').unix(),
|
|
442
|
-
maxDate: today,
|
|
443
|
-
style: source === 'emr' && get(params, 'meta.touched') && !get(params, 'meta.valid') ? {
|
|
444
|
-
text: {
|
|
445
|
-
'border-color': 'red'
|
|
446
|
-
}
|
|
447
|
-
} : {}
|
|
448
|
-
}, params))
|
|
449
|
-
}, "opened-".concat(index, "-date")), isOON && /*#__PURE__*/_jsx(Field, {
|
|
450
|
-
name: "primaryWorker",
|
|
451
|
-
required: true,
|
|
452
|
-
children: params => /*#__PURE__*/_jsx(SelectField, _objectSpread({
|
|
453
|
-
required: true,
|
|
454
|
-
id: "primary-worker",
|
|
455
|
-
label: "Primary Worker",
|
|
456
|
-
placeholder: "Choose one...",
|
|
457
|
-
loadOptions: search => setQuery(search),
|
|
458
|
-
options: primaryWorkers,
|
|
459
|
-
labelKey: "full_name",
|
|
460
|
-
valueKey: "id",
|
|
461
|
-
validations: isRequired
|
|
462
|
-
}, params))
|
|
463
|
-
}, "referral-".concat(index, "-primary-worker")), showClientNeeds && /*#__PURE__*/_jsxs(_Fragment, {
|
|
464
|
-
children: [/*#__PURE__*/_jsx("p", {
|
|
465
|
-
className: "mb-4 mt-2 text-dark-blue",
|
|
466
|
-
children: "Select the identified need from the client\u2019s screening or assessment that relates to this referral."
|
|
467
|
-
}), /*#__PURE__*/_jsx(Field, {
|
|
468
|
-
name: "client_need",
|
|
469
|
-
required: true,
|
|
470
|
-
children: params => /*#__PURE__*/_jsx(ReferralClientNeedsField, {
|
|
471
|
-
params: params,
|
|
472
|
-
clientNeeds: clientNeeds
|
|
473
|
-
})
|
|
474
|
-
}, "associated-".concat(index, "-need"))]
|
|
475
|
-
}), attachableDocuments && /*#__PURE__*/_jsxs("div", {
|
|
476
|
-
className: "upload-documents",
|
|
477
|
-
children: [/*#__PURE__*/_jsx("h5", {
|
|
478
|
-
children: "Documents"
|
|
479
|
-
}), /*#__PURE__*/_jsx(ContactDocumentsSelector, {
|
|
480
|
-
documentFields: attachableDocuments
|
|
481
|
-
})]
|
|
482
|
-
}), /*#__PURE__*/_jsx(FileUpload, {
|
|
483
|
-
rejectedFiles: rejectedFiles,
|
|
484
|
-
setRejectedFiles: setRejectedFiles,
|
|
485
|
-
setUploadedFiles: setUploadedFiles,
|
|
486
|
-
uploadedFiles: attachments || []
|
|
487
|
-
})]
|
|
488
|
-
})]
|
|
193
|
+
}), /*#__PURE__*/_jsx(ReferralBuilderFormContent, {
|
|
194
|
+
referralTitle: referralTitle,
|
|
195
|
+
referralSubtitle: referralSubtitle,
|
|
196
|
+
newLanguageDashboard: newLanguageDashboard,
|
|
197
|
+
isOON: isOON,
|
|
198
|
+
programs: programs,
|
|
199
|
+
moveReferralMenus: moveReferralMenus,
|
|
200
|
+
onProgramClick: onProgramClick,
|
|
201
|
+
unselected: unselected,
|
|
202
|
+
referral: referral,
|
|
203
|
+
referrals: referrals,
|
|
204
|
+
currentProvider: currentProvider,
|
|
205
|
+
removeProgram: removeProgram,
|
|
206
|
+
moveToNewReferral: moveToNewReferral,
|
|
207
|
+
moveToExistingReferral: moveToExistingReferral,
|
|
208
|
+
hasDraftReferral: hasDraftReferral,
|
|
209
|
+
navigateToAddResources: navigateToAddResources,
|
|
210
|
+
showNetworkSelect: showNetworkSelect,
|
|
211
|
+
index: index,
|
|
212
|
+
networks: networks,
|
|
213
|
+
feeScheduleProgram: feeScheduleProgram,
|
|
214
|
+
formValues: values,
|
|
215
|
+
setReferralErrors: setReferralErrors,
|
|
216
|
+
source: source,
|
|
217
|
+
validateOpenDate: validateOpenDate,
|
|
218
|
+
today: today,
|
|
219
|
+
setQuery: setQuery,
|
|
220
|
+
primaryWorkers: primaryWorkers,
|
|
221
|
+
showClientNeeds: showClientNeeds,
|
|
222
|
+
clientNeeds: clientNeeds,
|
|
223
|
+
attachableDocuments: attachableDocuments,
|
|
224
|
+
rejectedFiles: rejectedFiles,
|
|
225
|
+
setRejectedFiles: setRejectedFiles,
|
|
226
|
+
setUploadedFiles: setUploadedFiles,
|
|
227
|
+
attachments: attachments
|
|
489
228
|
})]
|
|
490
229
|
});
|
|
491
230
|
}
|