@icure/be-fhc-api 0.4.37 → 0.4.38
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/package.json +1 -1
- package/x-api/message-x-api.js +29 -23
package/package.json
CHANGED
package/x-api/message-x-api.js
CHANGED
|
@@ -197,35 +197,41 @@ class MessageXApi {
|
|
|
197
197
|
ssins: ssins
|
|
198
198
|
})
|
|
199
199
|
}))
|
|
200
|
-
.then((pats) => Promise.
|
|
200
|
+
.then((pats) => Promise.all((pats.rows || []).map(p => {
|
|
201
201
|
const actions = _.sortBy(patsDmgs[p.ssin], a => moment(a.date, "DD/MM/YYYY").format("YYYYMMDD"));
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
p.patientHealthCareParties.find(phcp => phcp.healthcarePartyId === user.healthcarePartyId);
|
|
205
|
-
if (!phcp) {
|
|
206
|
-
p.patientHealthCareParties.push((phcp = new api_1.PatientHealthCareParty({
|
|
207
|
-
healthcarePartyId: user.healthcarePartyId,
|
|
208
|
-
referralPeriods: []
|
|
209
|
-
})));
|
|
210
|
-
}
|
|
202
|
+
let phcp = ((p.patientHealthCareParties || (p.patientHealthCareParties = [])) &&
|
|
203
|
+
p.patientHealthCareParties.find(phcp => phcp.healthcarePartyId === user.healthcarePartyId)) || new api_1.PatientHealthCareParty({ healthcarePartyId: user.healthcarePartyId, referralPeriods: [] });
|
|
211
204
|
if (!phcp.referralPeriods) {
|
|
212
205
|
phcp.referralPeriods = [];
|
|
213
206
|
}
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
207
|
+
const referralPeriods = phcp.referralPeriods;
|
|
208
|
+
actions.map(action => {
|
|
209
|
+
const actionDate = Number(moment((action === null || action === void 0 ? void 0 : action.date) || "", "DD/MM/YYYY").format("YYYYMMDD"));
|
|
210
|
+
if (action) {
|
|
211
|
+
if (action.closure) {
|
|
212
|
+
const rp = referralPeriods.find(per => (!per.endDate || per.endDate > actionDate) && ((per === null || per === void 0 ? void 0 : per.startDate) || 0) < actionDate);
|
|
213
|
+
if (rp) {
|
|
214
|
+
rp.comment = (rp.comment + ' ' || '') + (rp.endDate ? "Correction End Date. " : "") + `Transferred to ${action.newHcp}`;
|
|
215
|
+
rp.endDate = actionDate;
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
referralPeriods.push(new api_1.ReferralPeriod({ startDate: Number(moment().format("YYYYMMDD")), endDate: actionDate, comment: `No start Date Info. Transferred to ${action.newHcp}` }));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
const rp = referralPeriods.find(per => (!per.endDate || per.endDate > actionDate) && ((per === null || per === void 0 ? void 0 : per.startDate) || 0) < actionDate);
|
|
223
|
+
if (rp) {
|
|
224
|
+
rp.startDate = actionDate < (rp.startDate || 0) ? actionDate : rp.startDate;
|
|
225
|
+
rp.comment = (rp.comment + ' ' || '') + 'Correction Start Date.';
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
referralPeriods.push(new api_1.ReferralPeriod({ startDate: actionDate, comment: `New Referral to ${action.newHcp}` }));
|
|
229
|
+
}
|
|
226
230
|
}
|
|
227
231
|
}
|
|
228
|
-
}
|
|
232
|
+
});
|
|
233
|
+
phcp.referralPeriods = referralPeriods.sort((a, b) => (a.startDate || 0) - (b.startDate || 0));
|
|
234
|
+
phcp.referral = !Boolean(referralPeriods[referralPeriods.length - 1].endDate);
|
|
229
235
|
return p;
|
|
230
236
|
}))))
|
|
231
237
|
.then(pats => this.patientApi.bulkUpdatePatients(pats || []).catch(() => {
|