@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
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
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
|
+
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 { feeSchedulePrograms as fspUtils } from '@unite-us/client-utils';
|
|
5
|
+
import { isEmpty } from 'lodash';
|
|
6
|
+
import moment from 'moment';
|
|
7
|
+
import { coreApi } from '../../api/config';
|
|
8
|
+
const shouldLoadDraftPaymentAuthorization = (referral, feeScheduleProgram) => referral.state === 'draft' && (feeScheduleProgram === null || feeScheduleProgram === void 0 ? void 0 : feeScheduleProgram.authorization_required);
|
|
9
|
+
const fetchCaseData = async caseId => {
|
|
10
|
+
var _caseResponse$data;
|
|
11
|
+
const caseResponse = await coreApi.findRecord('case', caseId);
|
|
12
|
+
return caseResponse === null || caseResponse === void 0 || (_caseResponse$data = caseResponse.data) === null || _caseResponse$data === void 0 ? void 0 : _caseResponse$data.data;
|
|
13
|
+
};
|
|
14
|
+
const fetchServiceAuthorizationData = async serviceAuthorizationId => {
|
|
15
|
+
var _serviceAuthorization;
|
|
16
|
+
const serviceAuthorizationResponse = await coreApi.findRecord('service_authorization', serviceAuthorizationId);
|
|
17
|
+
return serviceAuthorizationResponse === null || serviceAuthorizationResponse === void 0 || (_serviceAuthorization = serviceAuthorizationResponse.data) === null || _serviceAuthorization === void 0 ? void 0 : _serviceAuthorization.data;
|
|
18
|
+
};
|
|
19
|
+
const fetchClinicalModificationData = async clinicalModifications => {
|
|
20
|
+
var _clinicalModification;
|
|
21
|
+
const firstClinicalModification = clinicalModifications === null || clinicalModifications === void 0 ? void 0 : clinicalModifications[0];
|
|
22
|
+
if (!firstClinicalModification) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const clinicalModificationResponse = await coreApi.findRecord('clinical_modifications', firstClinicalModification.id);
|
|
26
|
+
return clinicalModificationResponse === null || clinicalModificationResponse === void 0 || (_clinicalModification = clinicalModificationResponse.data) === null || _clinicalModification === void 0 ? void 0 : _clinicalModification.data;
|
|
27
|
+
};
|
|
28
|
+
const buildAmountRequestedInitialValue = (serviceAuthorizationData, feeScheduleProgram) => {
|
|
29
|
+
const isUnitBased = !fspUtils.isCostPaymentType(feeScheduleProgram === null || feeScheduleProgram === void 0 ? void 0 : feeScheduleProgram.payment_type);
|
|
30
|
+
if (isUnitBased) {
|
|
31
|
+
return serviceAuthorizationData === null || serviceAuthorizationData === void 0 ? void 0 : serviceAuthorizationData.requested_unit_amount;
|
|
32
|
+
}
|
|
33
|
+
return (serviceAuthorizationData === null || serviceAuthorizationData === void 0 ? void 0 : serviceAuthorizationData.requested_cents) / 100;
|
|
34
|
+
};
|
|
35
|
+
const buildClinicalModificationValue = clinicalModificationData => {
|
|
36
|
+
if (isEmpty(clinicalModificationData)) {
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
value: clinicalModificationData.code,
|
|
41
|
+
id: clinicalModificationData.id
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
const buildPaymentAuthFormValues = _ref => {
|
|
45
|
+
let {
|
|
46
|
+
serviceAuthorizationData,
|
|
47
|
+
clinicalModificationData,
|
|
48
|
+
feeScheduleProgram
|
|
49
|
+
} = _ref;
|
|
50
|
+
return {
|
|
51
|
+
amount_requested: buildAmountRequestedInitialValue(serviceAuthorizationData, feeScheduleProgram),
|
|
52
|
+
service_end: moment(serviceAuthorizationData === null || serviceAuthorizationData === void 0 ? void 0 : serviceAuthorizationData.requested_ends_at).unix(),
|
|
53
|
+
service_start: moment(serviceAuthorizationData === null || serviceAuthorizationData === void 0 ? void 0 : serviceAuthorizationData.requested_starts_at).unix(),
|
|
54
|
+
icd10_code: buildClinicalModificationValue(clinicalModificationData)
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export const fetchDraftPaymentAuthorizationValues = async _ref2 => {
|
|
58
|
+
var _caseData$service_aut;
|
|
59
|
+
let {
|
|
60
|
+
caseId,
|
|
61
|
+
referralState,
|
|
62
|
+
paymentType,
|
|
63
|
+
authorizationRequired
|
|
64
|
+
} = _ref2;
|
|
65
|
+
if (!shouldLoadDraftPaymentAuthorization({
|
|
66
|
+
state: referralState
|
|
67
|
+
}, {
|
|
68
|
+
authorization_required: authorizationRequired
|
|
69
|
+
})) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
const caseData = await fetchCaseData(caseId);
|
|
73
|
+
const serviceAuthorizationData = await fetchServiceAuthorizationData(caseData === null || caseData === void 0 || (_caseData$service_aut = caseData.service_authorization) === null || _caseData$service_aut === void 0 ? void 0 : _caseData$service_aut.id);
|
|
74
|
+
const clinicalModificationData = await fetchClinicalModificationData(serviceAuthorizationData === null || serviceAuthorizationData === void 0 ? void 0 : serviceAuthorizationData.clinical_modifications);
|
|
75
|
+
return {
|
|
76
|
+
paymentAuthFormValues: buildPaymentAuthFormValues({
|
|
77
|
+
serviceAuthorizationData,
|
|
78
|
+
clinicalModificationData,
|
|
79
|
+
feeScheduleProgram: {
|
|
80
|
+
payment_type: paymentType
|
|
81
|
+
}
|
|
82
|
+
}),
|
|
83
|
+
serviceAuthorizationData
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
export const mergeDraftPaymentAuthorizationInitialValues = _ref3 => {
|
|
87
|
+
var _previousValues$case;
|
|
88
|
+
let {
|
|
89
|
+
previousValues,
|
|
90
|
+
paymentAuthFormValues,
|
|
91
|
+
serviceAuthorizationData,
|
|
92
|
+
crtb854ForwardingSuperset,
|
|
93
|
+
referralDescription
|
|
94
|
+
} = _ref3;
|
|
95
|
+
const initialValues = _objectSpread(_objectSpread({}, previousValues), {}, {
|
|
96
|
+
case: _objectSpread(_objectSpread({}, previousValues.case), {}, {
|
|
97
|
+
service_authorization: _objectSpread(_objectSpread({}, (_previousValues$case = previousValues.case) === null || _previousValues$case === void 0 ? void 0 : _previousValues$case.service_authorization), serviceAuthorizationData)
|
|
98
|
+
}),
|
|
99
|
+
paymentAuthForm: _objectSpread(_objectSpread({}, previousValues.paymentAuthForm), paymentAuthFormValues)
|
|
100
|
+
});
|
|
101
|
+
if (crtb854ForwardingSuperset && referralDescription) {
|
|
102
|
+
initialValues.description = referralDescription;
|
|
103
|
+
}
|
|
104
|
+
return initialValues;
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=referralBuilderFormDraftAuth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"referralBuilderFormDraftAuth.js","names":["feeSchedulePrograms","fspUtils","isEmpty","moment","coreApi","shouldLoadDraftPaymentAuthorization","referral","feeScheduleProgram","state","authorization_required","fetchCaseData","caseId","_caseResponse$data","caseResponse","findRecord","data","fetchServiceAuthorizationData","serviceAuthorizationId","_serviceAuthorization","serviceAuthorizationResponse","fetchClinicalModificationData","clinicalModifications","_clinicalModification","firstClinicalModification","clinicalModificationResponse","id","buildAmountRequestedInitialValue","serviceAuthorizationData","isUnitBased","isCostPaymentType","payment_type","requested_unit_amount","requested_cents","buildClinicalModificationValue","clinicalModificationData","value","code","buildPaymentAuthFormValues","_ref","amount_requested","service_end","requested_ends_at","unix","service_start","requested_starts_at","icd10_code","fetchDraftPaymentAuthorizationValues","_ref2","_caseData$service_aut","referralState","paymentType","authorizationRequired","caseData","service_authorization","clinical_modifications","paymentAuthFormValues","mergeDraftPaymentAuthorizationInitialValues","_ref3","_previousValues$case","previousValues","crtb854ForwardingSuperset","referralDescription","initialValues","_objectSpread","case","paymentAuthForm","description"],"sources":["../../../src/pages/builder/referralBuilderFormDraftAuth.js"],"sourcesContent":["import { feeSchedulePrograms as fspUtils } from '@unite-us/client-utils';\nimport { isEmpty } from 'lodash';\nimport moment from 'moment';\nimport { coreApi } from '../../api/config';\n\nconst shouldLoadDraftPaymentAuthorization = (referral, feeScheduleProgram) => (\n referral.state === 'draft' && feeScheduleProgram?.authorization_required\n);\n\nconst fetchCaseData = async (caseId) => {\n const caseResponse = await coreApi.findRecord('case', caseId);\n\n return caseResponse?.data?.data;\n};\n\nconst fetchServiceAuthorizationData = async (serviceAuthorizationId) => {\n const serviceAuthorizationResponse = await coreApi.findRecord(\n 'service_authorization',\n serviceAuthorizationId,\n );\n\n return serviceAuthorizationResponse?.data?.data;\n};\n\nconst fetchClinicalModificationData = async (clinicalModifications) => {\n const firstClinicalModification = clinicalModifications?.[0];\n\n if (!firstClinicalModification) {\n return null;\n }\n\n const clinicalModificationResponse = await coreApi.findRecord(\n 'clinical_modifications',\n firstClinicalModification.id,\n );\n\n return clinicalModificationResponse?.data?.data;\n};\n\nconst buildAmountRequestedInitialValue = (\n serviceAuthorizationData,\n feeScheduleProgram,\n) => {\n const isUnitBased = !fspUtils.isCostPaymentType(\n feeScheduleProgram?.payment_type,\n );\n\n if (isUnitBased) {\n return serviceAuthorizationData?.requested_unit_amount;\n }\n\n return serviceAuthorizationData?.requested_cents / 100;\n};\n\nconst buildClinicalModificationValue = (clinicalModificationData) => {\n if (isEmpty(clinicalModificationData)) {\n return {};\n }\n\n return {\n value: clinicalModificationData.code,\n id: clinicalModificationData.id,\n };\n};\n\nconst buildPaymentAuthFormValues = ({\n serviceAuthorizationData,\n clinicalModificationData,\n feeScheduleProgram,\n}) => ({\n amount_requested: buildAmountRequestedInitialValue(\n serviceAuthorizationData,\n feeScheduleProgram,\n ),\n service_end: moment(serviceAuthorizationData?.requested_ends_at).unix(),\n service_start: moment(serviceAuthorizationData?.requested_starts_at).unix(),\n icd10_code: buildClinicalModificationValue(clinicalModificationData),\n});\n\nexport const fetchDraftPaymentAuthorizationValues = async ({\n caseId,\n referralState,\n paymentType,\n authorizationRequired,\n}) => {\n if (!shouldLoadDraftPaymentAuthorization(\n { state: referralState },\n { authorization_required: authorizationRequired },\n )) {\n return null;\n }\n\n const caseData = await fetchCaseData(caseId);\n const serviceAuthorizationData = await fetchServiceAuthorizationData(\n caseData?.service_authorization?.id,\n );\n const clinicalModificationData = await fetchClinicalModificationData(\n serviceAuthorizationData?.clinical_modifications,\n );\n\n return {\n paymentAuthFormValues: buildPaymentAuthFormValues({\n serviceAuthorizationData,\n clinicalModificationData,\n feeScheduleProgram: { payment_type: paymentType },\n }),\n serviceAuthorizationData,\n };\n};\n\nexport const mergeDraftPaymentAuthorizationInitialValues = ({\n previousValues,\n paymentAuthFormValues,\n serviceAuthorizationData,\n crtb854ForwardingSuperset,\n referralDescription,\n}) => {\n const initialValues = {\n ...previousValues,\n case: {\n ...previousValues.case,\n service_authorization: {\n ...previousValues.case?.service_authorization,\n ...serviceAuthorizationData,\n },\n },\n paymentAuthForm: {\n ...previousValues.paymentAuthForm,\n ...paymentAuthFormValues,\n },\n };\n\n if (crtb854ForwardingSuperset && referralDescription) {\n initialValues.description = referralDescription;\n }\n\n return initialValues;\n};\n"],"mappings":";;;AAAA,SAASA,mBAAmB,IAAIC,QAAQ,QAAQ,wBAAwB;AACxE,SAASC,OAAO,QAAQ,QAAQ;AAChC,OAAOC,MAAM,MAAM,QAAQ;AAC3B,SAASC,OAAO,QAAQ,kBAAkB;AAE1C,MAAMC,mCAAmC,GAAGA,CAACC,QAAQ,EAAEC,kBAAkB,KACvED,QAAQ,CAACE,KAAK,KAAK,OAAO,KAAID,kBAAkB,aAAlBA,kBAAkB,uBAAlBA,kBAAkB,CAAEE,sBAAsB,CACzE;AAED,MAAMC,aAAa,GAAG,MAAOC,MAAM,IAAK;EAAA,IAAAC,kBAAA;EACtC,MAAMC,YAAY,GAAG,MAAMT,OAAO,CAACU,UAAU,CAAC,MAAM,EAAEH,MAAM,CAAC;EAE7D,OAAOE,YAAY,aAAZA,YAAY,gBAAAD,kBAAA,GAAZC,YAAY,CAAEE,IAAI,cAAAH,kBAAA,uBAAlBA,kBAAA,CAAoBG,IAAI;AACjC,CAAC;AAED,MAAMC,6BAA6B,GAAG,MAAOC,sBAAsB,IAAK;EAAA,IAAAC,qBAAA;EACtE,MAAMC,4BAA4B,GAAG,MAAMf,OAAO,CAACU,UAAU,CAC3D,uBAAuB,EACvBG,sBACF,CAAC;EAED,OAAOE,4BAA4B,aAA5BA,4BAA4B,gBAAAD,qBAAA,GAA5BC,4BAA4B,CAAEJ,IAAI,cAAAG,qBAAA,uBAAlCA,qBAAA,CAAoCH,IAAI;AACjD,CAAC;AAED,MAAMK,6BAA6B,GAAG,MAAOC,qBAAqB,IAAK;EAAA,IAAAC,qBAAA;EACrE,MAAMC,yBAAyB,GAAGF,qBAAqB,aAArBA,qBAAqB,uBAArBA,qBAAqB,CAAG,CAAC,CAAC;EAE5D,IAAI,CAACE,yBAAyB,EAAE;IAC9B,OAAO,IA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,aAAA,CAAAA,aAAA,KACCJ,cAAc,CAACK,IAAI;MACtBX,qBAAqB,EAAAU,aAAA,CAAAA,aAAA,MAAAL,oBAAA,GAChBC,cAAc,CAACK,IAAI,cAAAN,oBAAA,uBAAnBA,oBAAA,CAAqBL,qBAAqB,GAC1C1B,wBAAwB;IAC5B,EACF;IACDsC,eAAe,EAAAF,aAAA,CAAAA,aAAA,KACVJ,cAAc,CAACM,eAAe,GAC9BV,qBAAqB;EACzB,EACF;EAED,IAAIK,yBAAyB,IAAIC,mBAAmB,EAAE;IACpDC,aAAa,CAACI,WAAW,GAAGL,mBAAmB;EACjD;EAEA,OAAOC,aAAa;AACtB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
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
|
+
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 { isEmpty, uniqBy, upperFirst } from 'lodash';
|
|
5
|
+
import moment from 'moment';
|
|
6
|
+
import { referralIsFunded, referralIsGrouped, referralIsOON } from './utils';
|
|
7
|
+
export const buildReferralTitle = (referral, index) => {
|
|
8
|
+
var _referral$service;
|
|
9
|
+
const serviceName = referral === null || referral === void 0 || (_referral$service = referral.service) === null || _referral$service === void 0 ? void 0 : _referral$service.name;
|
|
10
|
+
const grouped = referralIsGrouped(referral) ? 'Grouped' : null;
|
|
11
|
+
const offPlatform = referralIsOON(referral) ? 'Off-Platform' : null;
|
|
12
|
+
const funded = referralIsFunded(referral) ? 'Funded' : null;
|
|
13
|
+
const status = [grouped, offPlatform, funded].filter(Boolean).join(', ');
|
|
14
|
+
return "Referral ".concat(index + 1, ": ").concat(serviceName).concat(status ? ", ".concat(status) : '');
|
|
15
|
+
};
|
|
16
|
+
export const buildProgramMenus = function () {
|
|
17
|
+
let programs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
18
|
+
return programs.map(program => ({
|
|
19
|
+
id: program.id,
|
|
20
|
+
menuIsOpen: false
|
|
21
|
+
}));
|
|
22
|
+
};
|
|
23
|
+
export const toggleProgramMenus = (programMenus, id) => programMenus.map(programMenu => programMenu.id === id ? _objectSpread(_objectSpread({}, programMenu), {}, {
|
|
24
|
+
menuIsOpen: !programMenu.menuIsOpen
|
|
25
|
+
}) : _objectSpread(_objectSpread({}, programMenu), {}, {
|
|
26
|
+
menuIsOpen: false
|
|
27
|
+
}));
|
|
28
|
+
export const mergePrimaryWorkerOptions = _ref => {
|
|
29
|
+
let {
|
|
30
|
+
currentPrimaryWorkers,
|
|
31
|
+
fetchedPrimaryWorkers,
|
|
32
|
+
primaryWorker,
|
|
33
|
+
query
|
|
34
|
+
} = _ref;
|
|
35
|
+
if (!isEmpty(query)) {
|
|
36
|
+
return fetchedPrimaryWorkers;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// if the query is empty, keep the queried employees and the current primary worker in select field's options array
|
|
40
|
+
return uniqBy([...currentPrimaryWorkers, ...fetchedPrimaryWorkers, primaryWorker].filter(Boolean), 'id');
|
|
41
|
+
};
|
|
42
|
+
export const mapClientNeeds = clientNeedsData => {
|
|
43
|
+
var _clientNeedsData$data, _clientNeedsData$data2;
|
|
44
|
+
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 => ({
|
|
45
|
+
label: upperFirst(condition === null || condition === void 0 ? void 0 : condition.name),
|
|
46
|
+
value: condition === null || condition === void 0 ? void 0 : condition.id
|
|
47
|
+
}))) !== null && _clientNeedsData$data !== void 0 ? _clientNeedsData$data : [];
|
|
48
|
+
};
|
|
49
|
+
export const getSelectedClientNeeds = (clientNeeds, caseData) => clientNeeds.filter(clientNeed => {
|
|
50
|
+
var _caseData$person_cond;
|
|
51
|
+
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);
|
|
52
|
+
});
|
|
53
|
+
export const buildInitialValues = _ref2 => {
|
|
54
|
+
let {
|
|
55
|
+
referral,
|
|
56
|
+
isOON,
|
|
57
|
+
primaryWorkers,
|
|
58
|
+
currentEmployeeId,
|
|
59
|
+
crtb854ForwardingSuperset,
|
|
60
|
+
referralDescription
|
|
61
|
+
} = _ref2;
|
|
62
|
+
const initialValues = _objectSpread({}, referral);
|
|
63
|
+
if (referral.primaryWorker == null && isOON) {
|
|
64
|
+
initialValues.primaryWorker = primaryWorkers.find(worker => worker.id === currentEmployeeId);
|
|
65
|
+
}
|
|
66
|
+
if (crtb854ForwardingSuperset && referralDescription) {
|
|
67
|
+
initialValues.referralDescription = referralDescription;
|
|
68
|
+
}
|
|
69
|
+
return initialValues;
|
|
70
|
+
};
|
|
71
|
+
export const createOpenDateValidator = today => date => {
|
|
72
|
+
try {
|
|
73
|
+
const openDate = new Date(parseInt(date, 10) * 1000);
|
|
74
|
+
const maxDate = new Date(parseInt(today, 10) * 1000);
|
|
75
|
+
const minDate = new Date(moment().subtract(1, 'year').unix() * 1000);
|
|
76
|
+
return !(Number.isNaN(openDate.getTime()) || openDate.getTime() < minDate || openDate.getTime() > maxDate);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.error('Error validating open date', error);
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=referralBuilderFormUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"referralBuilderFormUtils.js","names":["isEmpty","uniqBy","upperFirst","moment","referralIsFunded","referralIsGrouped","referralIsOON","buildReferralTitle","referral","index","_referral$service","serviceName","service","name","grouped","offPlatform","funded","status","filter","Boolean","join","concat","buildProgramMenus","programs","arguments","length","undefined","map","program","id","menuIsOpen","toggleProgramMenus","programMenus","programMenu","_objectSpread","mergePrimaryWorkerOptions","_ref","currentPrimaryWorkers","fetchedPrimaryWorkers","primaryWorker","query","mapClientNeeds","clientNeedsData","_clientNeedsData$data","_clientNeedsData$data2","data","condition","label","value","getSelectedClientNeeds","clientNeeds","caseData","clientNeed","_caseData$person_cond","person_condition_ids","includes","buildInitialValues","_ref2","isOON","primaryWorkers","currentEmployeeId","crtb854ForwardingSuperset","referralDescription","initialValues","find","worker","createOpenDateValidator","today","date","openDate","Date","parseInt","maxDate","minDate","subtract","unix","Number","isNaN","getTime","error","console"],"sources":["../../../src/pages/builder/referralBuilderFormUtils.js"],"sourcesContent":["import { isEmpty, uniqBy, upperFirst } from 'lodash';\nimport moment from 'moment';\nimport {\n referralIsFunded,\n referralIsGrouped,\n referralIsOON,\n} from './utils';\n\nexport const buildReferralTitle = (referral, index) => {\n const serviceName = referral?.service?.name;\n const grouped = referralIsGrouped(referral) ? 'Grouped' : null;\n const offPlatform = referralIsOON(referral) ? 'Off-Platform' : null;\n const funded = referralIsFunded(referral) ? 'Funded' : null;\n const status = [grouped, offPlatform, funded].filter(Boolean).join(', ');\n\n return `Referral ${index + 1}: ${serviceName}${status ? `, ${status}` : ''}`;\n};\n\nexport const buildProgramMenus = (programs = []) => (\n programs.map((program) => ({ id: program.id, menuIsOpen: false }))\n);\n\nexport const toggleProgramMenus = (programMenus, id) => (\n programMenus.map((programMenu) => (\n programMenu.id === id ?\n { ...programMenu, menuIsOpen: !programMenu.menuIsOpen } :\n { ...programMenu, menuIsOpen: false }\n ))\n);\n\nexport const mergePrimaryWorkerOptions = ({\n currentPrimaryWorkers,\n fetchedPrimaryWorkers,\n primaryWorker,\n query,\n}) => {\n if (!isEmpty(query)) {\n return fetchedPrimaryWorkers;\n }\n\n // if the query is empty, keep the queried employees and the current primary worker in select field's options array\n return uniqBy(\n [...currentPrimaryWorkers, ...fetchedPrimaryWorkers, primaryWorker].filter(Boolean),\n 'id',\n );\n};\n\nexport const mapClientNeeds = (clientNeedsData) => (\n clientNeedsData?.data?.data?.map((condition) => ({\n label: upperFirst(condition?.name),\n value: condition?.id,\n })) ?? []\n);\n\nexport const getSelectedClientNeeds = (clientNeeds, caseData) => (\n clientNeeds.filter((clientNeed) => (\n caseData?.person_condition_ids?.includes(clientNeed.value)\n ))\n);\n\nexport const buildInitialValues = ({\n referral,\n isOON,\n primaryWorkers,\n currentEmployeeId,\n crtb854ForwardingSuperset,\n referralDescription,\n}) => {\n const initialValues = {\n ...referral,\n };\n\n if (referral.primaryWorker == null && isOON) {\n initialValues.primaryWorker = primaryWorkers.find(\n (worker) => worker.id === currentEmployeeId,\n );\n }\n\n if (crtb854ForwardingSuperset && referralDescription) {\n initialValues.referralDescription = referralDescription;\n }\n\n return initialValues;\n};\n\nexport const createOpenDateValidator = (today) => (date) => {\n try {\n const openDate = new Date(parseInt(date, 10) * 1000);\n const maxDate = new Date(parseInt(today, 10) * 1000);\n const minDate = new Date(moment().subtract(1, 'year').unix() * 1000);\n\n return !(\n Number.isNaN(openDate.getTime()) ||\n openDate.getTime() < minDate ||\n openDate.getTime() > maxDate\n );\n } catch (error) {\n console.error('Error validating open date', error);\n return false;\n }\n};\n"],"mappings":";;;AAAA,SAASA,OAAO,EAAEC,MAAM,EAAEC,UAAU,QAAQ,QAAQ;AACpD,OAAOC,MAAM,MAAM,QAAQ;AAC3B,SACEC,gBAAgB,EAChBC,iBAAiB,EAC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C,OAAOO,KAAK,EAAE;IACdC,OAAO,CAACD,KAAK,CAAC,4BAA4B,EAAEA,KAAK,CAAC;IAClD,OAAO,KAAK;EACd;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
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
|
+
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 { feeSchedulePrograms as fspUtils } from '@unite-us/client-utils';
|
|
5
|
+
import validateCostAmount from '../../utils/validateCostAmount';
|
|
6
|
+
import validateUnitAmount from '../../utils/validateUnitAmount';
|
|
7
|
+
const descriptionIsMissing = values => {
|
|
8
|
+
if (!values.description) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
return values.description.trim() === '';
|
|
12
|
+
};
|
|
13
|
+
const clientNeedsAreMissing = values => {
|
|
14
|
+
if (!(values !== null && values !== void 0 && values.client_need)) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return values.client_need.length === 0;
|
|
18
|
+
};
|
|
19
|
+
const validateBasicFields = (values, showClientNeeds, showNetworkSelect) => {
|
|
20
|
+
const errors = {};
|
|
21
|
+
if (descriptionIsMissing(values)) {
|
|
22
|
+
errors.description = 'Required';
|
|
23
|
+
}
|
|
24
|
+
if (showClientNeeds && clientNeedsAreMissing(values)) {
|
|
25
|
+
errors.client_need = 'Required';
|
|
26
|
+
}
|
|
27
|
+
if (showNetworkSelect && !values.network) {
|
|
28
|
+
errors.network = 'Required';
|
|
29
|
+
}
|
|
30
|
+
return errors;
|
|
31
|
+
};
|
|
32
|
+
const validateOpenedDate = (values, validateOpenDate) => {
|
|
33
|
+
if (!values.opened_date) {
|
|
34
|
+
return 'Required';
|
|
35
|
+
}
|
|
36
|
+
if (!validateOpenDate(values.opened_date)) {
|
|
37
|
+
return 'Invalid date';
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
40
|
+
};
|
|
41
|
+
const validateOONFields = (values, isOON, validateOpenDate) => {
|
|
42
|
+
const errors = {};
|
|
43
|
+
if (isOON) {
|
|
44
|
+
errors.opened_date = validateOpenedDate(values, validateOpenDate);
|
|
45
|
+
if (!values.primaryWorker) {
|
|
46
|
+
errors.primaryWorker = 'Required';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return errors;
|
|
50
|
+
};
|
|
51
|
+
const getAmountRequestedError = (amountRequested, feeScheduleProgram) => {
|
|
52
|
+
const isCostBased = fspUtils.isCostPaymentType(feeScheduleProgram.payment_type);
|
|
53
|
+
if (isCostBased) {
|
|
54
|
+
return validateCostAmount(amountRequested);
|
|
55
|
+
}
|
|
56
|
+
return validateUnitAmount(amountRequested);
|
|
57
|
+
};
|
|
58
|
+
const getServiceEndError = paymentAuthForm => {
|
|
59
|
+
if (paymentAuthForm !== null && paymentAuthForm !== void 0 && paymentAuthForm.service_end) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
return 'Required';
|
|
63
|
+
};
|
|
64
|
+
const getIcd10CodeError = (paymentAuthForm, feeScheduleProgram) => {
|
|
65
|
+
var _paymentAuthForm$icd;
|
|
66
|
+
if (!feeScheduleProgram.cm_code_required_on_authorization) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
if (paymentAuthForm !== null && paymentAuthForm !== void 0 && (_paymentAuthForm$icd = paymentAuthForm.icd10_code) !== null && _paymentAuthForm$icd !== void 0 && _paymentAuthForm$icd.value) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
return 'Required';
|
|
73
|
+
};
|
|
74
|
+
const validatePaymentAuth = (values, feeScheduleProgram) => {
|
|
75
|
+
if (!(feeScheduleProgram !== null && feeScheduleProgram !== void 0 && feeScheduleProgram.authorization_required)) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
const paymentAuthForm = values === null || values === void 0 ? void 0 : values.paymentAuthForm;
|
|
79
|
+
return {
|
|
80
|
+
amount_requested: getAmountRequestedError(paymentAuthForm === null || paymentAuthForm === void 0 ? void 0 : paymentAuthForm.amount_requested, feeScheduleProgram),
|
|
81
|
+
service_end: getServiceEndError(paymentAuthForm),
|
|
82
|
+
icd10_code: getIcd10CodeError(paymentAuthForm, feeScheduleProgram)
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
const buildFieldErrors = errors => {
|
|
86
|
+
var _errors$paymentAuthFo, _errors$paymentAuthFo2, _errors$paymentAuthFo3;
|
|
87
|
+
return {
|
|
88
|
+
description: !!errors.description,
|
|
89
|
+
opened_date: !!errors.opened_date,
|
|
90
|
+
client_need: !!errors.client_need,
|
|
91
|
+
primary_worker: !!errors.primaryWorker,
|
|
92
|
+
network: !!errors.network,
|
|
93
|
+
service_end: !!(errors !== null && errors !== void 0 && (_errors$paymentAuthFo = errors.paymentAuthForm) !== null && _errors$paymentAuthFo !== void 0 && _errors$paymentAuthFo.service_end),
|
|
94
|
+
amount_requested: !!(errors !== null && errors !== void 0 && (_errors$paymentAuthFo2 = errors.paymentAuthForm) !== null && _errors$paymentAuthFo2 !== void 0 && _errors$paymentAuthFo2.amount_requested),
|
|
95
|
+
icd10_code: !!(errors !== null && errors !== void 0 && (_errors$paymentAuthFo3 = errors.paymentAuthForm) !== null && _errors$paymentAuthFo3 !== void 0 && _errors$paymentAuthFo3.icd10_code)
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
export const validateReferralBuilderForm = _ref => {
|
|
99
|
+
let {
|
|
100
|
+
values,
|
|
101
|
+
isOON,
|
|
102
|
+
showClientNeeds,
|
|
103
|
+
showNetworkSelect,
|
|
104
|
+
feeScheduleProgram,
|
|
105
|
+
validateOpenDate,
|
|
106
|
+
setReferralErrors,
|
|
107
|
+
index
|
|
108
|
+
} = _ref;
|
|
109
|
+
const errors = _objectSpread(_objectSpread({}, validateBasicFields(values, showClientNeeds, showNetworkSelect)), validateOONFields(values, isOON, validateOpenDate));
|
|
110
|
+
errors.paymentAuthForm = validatePaymentAuth(values, feeScheduleProgram);
|
|
111
|
+
setReferralErrors(index, buildFieldErrors(errors));
|
|
112
|
+
return errors;
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=referralBuilderFormValidation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"referralBuilderFormValidation.js","names":["feeSchedulePrograms","fspUtils","validateCostAmount","validateUnitAmount","descriptionIsMissing","values","description","trim","clientNeedsAreMissing","client_need","length","validateBasicFields","showClientNeeds","showNetworkSelect","errors","network","validateOpenedDate","validateOpenDate","opened_date","undefined","validateOONFields","isOON","primaryWorker","getAmountRequestedError","amountRequested","feeScheduleProgram","isCostBased","isCostPaymentType","payment_type","getServiceEndError","paymentAuthForm","service_end","getIcd10CodeError","_paymentAuthForm$icd","cm_code_required_on_authorization","icd10_code","value","validatePaymentAuth","authorization_required","amount_requested","buildFieldErrors","_errors$paymentAuthFo","_errors$paymentAuthFo2","_errors$paymentAuthFo3","primary_worker","validateReferralBuilderForm","_ref","setReferralErrors","index","_objectSpread"],"sources":["../../../src/pages/builder/referralBuilderFormValidation.js"],"sourcesContent":["import { feeSchedulePrograms as fspUtils } from '@unite-us/client-utils';\nimport validateCostAmount from '../../utils/validateCostAmount';\nimport validateUnitAmount from '../../utils/validateUnitAmount';\n\nconst descriptionIsMissing = (values) => {\n if (!values.description) {\n return true;\n }\n\n return values.description.trim() === '';\n};\n\nconst clientNeedsAreMissing = (values) => {\n if (!values?.client_need) {\n return true;\n }\n\n return values.client_need.length === 0;\n};\n\nconst validateBasicFields = (values, showClientNeeds, showNetworkSelect) => {\n const errors = {};\n\n if (descriptionIsMissing(values)) {\n errors.description = 'Required';\n }\n\n if (showClientNeeds && clientNeedsAreMissing(values)) {\n errors.client_need = 'Required';\n }\n\n if (showNetworkSelect && !values.network) {\n errors.network = 'Required';\n }\n\n return errors;\n};\n\nconst validateOpenedDate = (values, validateOpenDate) => {\n if (!values.opened_date) {\n return 'Required';\n }\n\n if (!validateOpenDate(values.opened_date)) {\n return 'Invalid date';\n }\n\n return undefined;\n};\n\nconst validateOONFields = (values, isOON, validateOpenDate) => {\n const errors = {};\n\n if (isOON) {\n errors.opened_date = validateOpenedDate(values, validateOpenDate);\n\n if (!values.primaryWorker) {\n errors.primaryWorker = 'Required';\n }\n }\n\n return errors;\n};\n\nconst getAmountRequestedError = (amountRequested, feeScheduleProgram) => {\n const isCostBased = fspUtils.isCostPaymentType(\n feeScheduleProgram.payment_type,\n );\n\n if (isCostBased) {\n return validateCostAmount(amountRequested);\n }\n\n return validateUnitAmount(amountRequested);\n};\n\nconst getServiceEndError = (paymentAuthForm) => {\n if (paymentAuthForm?.service_end) {\n return undefined;\n }\n\n return 'Required';\n};\n\nconst getIcd10CodeError = (paymentAuthForm, feeScheduleProgram) => {\n if (!feeScheduleProgram.cm_code_required_on_authorization) {\n return undefined;\n }\n\n if (paymentAuthForm?.icd10_code?.value) {\n return undefined;\n }\n\n return 'Required';\n};\n\nconst validatePaymentAuth = (values, feeScheduleProgram) => {\n if (!feeScheduleProgram?.authorization_required) {\n return undefined;\n }\n\n const paymentAuthForm = values?.paymentAuthForm;\n\n return {\n amount_requested: getAmountRequestedError(\n paymentAuthForm?.amount_requested,\n feeScheduleProgram,\n ),\n service_end: getServiceEndError(paymentAuthForm),\n icd10_code: getIcd10CodeError(paymentAuthForm, feeScheduleProgram),\n };\n};\n\nconst buildFieldErrors = (errors) => ({\n description: !!errors.description,\n opened_date: !!errors.opened_date,\n client_need: !!errors.client_need,\n primary_worker: !!errors.primaryWorker,\n network: !!errors.network,\n service_end: !!errors?.paymentAuthForm?.service_end,\n amount_requested: !!errors?.paymentAuthForm?.amount_requested,\n icd10_code: !!errors?.paymentAuthForm?.icd10_code,\n});\n\nexport const validateReferralBuilderForm = ({\n values,\n isOON,\n showClientNeeds,\n showNetworkSelect,\n feeScheduleProgram,\n validateOpenDate,\n setReferralErrors,\n index,\n}) => {\n const errors = {\n ...validateBasicFields(values, showClientNeeds, showNetworkSelect),\n ...validateOONFields(values, isOON, validateOpenDate),\n };\n\n errors.paymentAuthForm = validatePaymentAuth(values, feeScheduleProgram);\n\n setReferralErrors(index, buildFieldErrors(errors));\n\n return errors;\n};\n"],"mappings":";;;AAAA,SAASA,mBAAmB,IAAIC,QAAQ,QAAQ,wBAAwB;AACxE,OAAOC,kBAAkB,MAAM,gCAAgC;AAC/D,OAAOC,kBAAkB,MAAM,gCAAgC;AAE/D,MAAMC,oBAAoB,GAAIC,MAAM,IAAK;EACvC,IAAI,CAACA,MAAM,CAACC,WAAW,EAAE;IACvB,OAAO,IAAI;EACb;EAEA,OAAOD,MAAM,CAACC,WAAW,CAACC,IAAI,CAAC,CAAC,KAAK,EAAE;AACzC,CAAC;AAED,MAAMC,qBAAqB,GAAIH,MAAM,IAAK;EACxC,IAAI,EAACA,MAAM,aAANA,MAAM,eAANA,MAAM,CAAEI,WAAW,GAAE;IACxB,OAAO,IAAI;EACb;EAEA,OAAOJ,MAAM,CAACI,WAAW,CAACC,MAAM,KAAK,CAAC;AACxC,CAAC;AAED,MAAMC,mBAAmB,GAAGA,CAACN,MAAM,EAAEO,eAAe,EAAEC,iBAAiB,KAAK;EAC1E,MAAMC,MAAM,GAAG,CAAC,CAAC;EAEjB,IAAIV,oBAAoB,CAACC,MAAM,CAAC,EAAE;IAChCS,MAAM,CAACR,WAAW,GAAG,UAAU;EACjC;EAEA,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