openchs-models 1.33.54 → 1.33.56
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/Session.js +10 -4
- package/package.json +1 -1
package/dist/Session.js
CHANGED
|
@@ -163,13 +163,19 @@ class Session extends _BaseEntity.default {
|
|
|
163
163
|
const followUpEncounterTypeUUID = attendanceType.getFollowUpEncounterTypeUUID();
|
|
164
164
|
if (!followUpEncounterTypeUUID) return [];
|
|
165
165
|
if (!encounterType) return [];
|
|
166
|
-
const
|
|
167
|
-
const
|
|
166
|
+
const base = (0, _moment.default)(this.scheduledDate).startOf("day");
|
|
167
|
+
const earliestVisit = base.clone().toDate();
|
|
168
|
+
const maxVisit = base.clone().add(2, "days").toDate();
|
|
168
169
|
const created = [];
|
|
169
170
|
_lodash.default.forEach(attendanceRecords || [], record => {
|
|
170
171
|
if (!record) return;
|
|
171
172
|
if (record.status !== _AttendanceRecord.default.status.ABSENT) return;
|
|
172
173
|
if (!_lodash.default.isNil(record.reasonConceptUUID)) return;
|
|
174
|
+
// Re-mark path: an existing AttendanceRecord may already point at a
|
|
175
|
+
// previously-created follow-up encounter. Don't create a second one —
|
|
176
|
+
// leave the link in place; voidStaleFollowUps handles the inverse case
|
|
177
|
+
// (student transitioned out of "absent-no-reason").
|
|
178
|
+
if (record.followUpEncounterUUID) return;
|
|
173
179
|
const student = studentLookup ? studentLookup(record.subjectUUID) : null;
|
|
174
180
|
if (!student) return;
|
|
175
181
|
let encounter;
|
|
@@ -180,7 +186,7 @@ class Session extends _BaseEntity.default {
|
|
|
180
186
|
encounter.uuid = _General.default.randomUUID();
|
|
181
187
|
encounter.encounterType = encounterType;
|
|
182
188
|
encounter.programEnrolment = enrolment;
|
|
183
|
-
encounter.earliestVisitDateTime =
|
|
189
|
+
encounter.earliestVisitDateTime = earliestVisit;
|
|
184
190
|
encounter.maxVisitDateTime = maxVisit;
|
|
185
191
|
encounter.observations = [];
|
|
186
192
|
encounter.cancelObservations = [];
|
|
@@ -190,7 +196,7 @@ class Session extends _BaseEntity.default {
|
|
|
190
196
|
encounter.uuid = _General.default.randomUUID();
|
|
191
197
|
encounter.encounterType = encounterType;
|
|
192
198
|
encounter.individual = student;
|
|
193
|
-
encounter.earliestVisitDateTime =
|
|
199
|
+
encounter.earliestVisitDateTime = earliestVisit;
|
|
194
200
|
encounter.maxVisitDateTime = maxVisit;
|
|
195
201
|
encounter.observations = [];
|
|
196
202
|
encounter.cancelObservations = [];
|