openchs-models 1.33.56 → 1.33.58
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/AttendanceRecord.js +21 -9
- package/dist/Schema.js +19 -1
- package/dist/Session.js +3 -3
- package/package.json +1 -1
package/dist/AttendanceRecord.js
CHANGED
|
@@ -36,11 +36,11 @@ class AttendanceRecord extends _BaseEntity.default {
|
|
|
36
36
|
set status(x) {
|
|
37
37
|
this.that.status = x;
|
|
38
38
|
}
|
|
39
|
-
get
|
|
40
|
-
return this.that.
|
|
39
|
+
get reasonConceptUUIDs() {
|
|
40
|
+
return this.that.reasonConceptUUIDs || [];
|
|
41
41
|
}
|
|
42
|
-
set
|
|
43
|
-
this.that.
|
|
42
|
+
set reasonConceptUUIDs(x) {
|
|
43
|
+
this.that.reasonConceptUUIDs = x || [];
|
|
44
44
|
}
|
|
45
45
|
get followUpEncounterUUID() {
|
|
46
46
|
return this.that.followUpEncounterUUID;
|
|
@@ -48,6 +48,12 @@ class AttendanceRecord extends _BaseEntity.default {
|
|
|
48
48
|
set followUpEncounterUUID(x) {
|
|
49
49
|
this.that.followUpEncounterUUID = x;
|
|
50
50
|
}
|
|
51
|
+
get needsFollowUp() {
|
|
52
|
+
return this.that.needsFollowUp;
|
|
53
|
+
}
|
|
54
|
+
set needsFollowUp(x) {
|
|
55
|
+
this.that.needsFollowUp = x;
|
|
56
|
+
}
|
|
51
57
|
get createdBy() {
|
|
52
58
|
return this.that.createdBy;
|
|
53
59
|
}
|
|
@@ -84,16 +90,18 @@ class AttendanceRecord extends _BaseEntity.default {
|
|
|
84
90
|
record.sessionUUID = resource.sessionUUID;
|
|
85
91
|
record.subjectUUID = resource.subjectUUID;
|
|
86
92
|
record.status = resource.status;
|
|
87
|
-
record.
|
|
93
|
+
record.reasonConceptUUIDs = Array.isArray(resource.reasonConceptUUIDs) ? resource.reasonConceptUUIDs : resource.reasonConceptUUID ? [resource.reasonConceptUUID] : [];
|
|
88
94
|
record.followUpEncounterUUID = resource.followUpEncounterUUID || null;
|
|
95
|
+
record.needsFollowUp = !!resource.needsFollowUp;
|
|
89
96
|
record.voided = !!resource.voided;
|
|
90
97
|
(0, _AuditUtil.mapAuditFields)(record, resource);
|
|
91
98
|
return record;
|
|
92
99
|
}
|
|
93
100
|
get toResource() {
|
|
94
101
|
const resource = _lodash.default.pick(this, ["uuid", "sessionUUID", "subjectUUID", "status", "voided"]);
|
|
95
|
-
resource.
|
|
102
|
+
resource.reasonConceptUUIDs = this.reasonConceptUUIDs || [];
|
|
96
103
|
resource.followUpEncounterUUID = this.followUpEncounterUUID || null;
|
|
104
|
+
resource.needsFollowUp = !!this.needsFollowUp;
|
|
97
105
|
return resource;
|
|
98
106
|
}
|
|
99
107
|
}
|
|
@@ -105,14 +113,18 @@ _defineProperty(AttendanceRecord, "schema", {
|
|
|
105
113
|
sessionUUID: "string",
|
|
106
114
|
subjectUUID: "string",
|
|
107
115
|
status: "string",
|
|
108
|
-
|
|
109
|
-
type: "string",
|
|
110
|
-
|
|
116
|
+
reasonConceptUUIDs: {
|
|
117
|
+
type: "string[]",
|
|
118
|
+
default: []
|
|
111
119
|
},
|
|
112
120
|
followUpEncounterUUID: {
|
|
113
121
|
type: "string",
|
|
114
122
|
optional: true
|
|
115
123
|
},
|
|
124
|
+
needsFollowUp: {
|
|
125
|
+
type: "bool",
|
|
126
|
+
default: false
|
|
127
|
+
},
|
|
116
128
|
voided: {
|
|
117
129
|
type: "bool",
|
|
118
130
|
default: false
|
package/dist/Schema.js
CHANGED
|
@@ -186,7 +186,7 @@ function createRealmConfig() {
|
|
|
186
186
|
return doCompact;
|
|
187
187
|
},
|
|
188
188
|
//order is important, should be arranged according to the dependency
|
|
189
|
-
schemaVersion:
|
|
189
|
+
schemaVersion: 215,
|
|
190
190
|
onMigration: function (oldDB, newDB) {
|
|
191
191
|
console.log("[AvniModels.Schema]", `Running migration with old schema version: ${oldDB.schemaVersion} and new schema version: ${newDB.schemaVersion}`);
|
|
192
192
|
if (oldDB.schemaVersion === VersionWithEmbeddedMigrationProblem) throw new Error(`Update from schema version ${VersionWithEmbeddedMigrationProblem} is not allowed. Please uninstall and install app.`);
|
|
@@ -828,6 +828,24 @@ function createRealmConfig() {
|
|
|
828
828
|
// AttendanceType) for the new MarkAttendance action. Existing rows
|
|
829
829
|
// remain null.
|
|
830
830
|
}
|
|
831
|
+
if (oldDB.schemaVersion < 214) {
|
|
832
|
+
// Backfill AttendanceRecord.needsFollowUp from existing follow-up
|
|
833
|
+
// linkage so historical follow-ups survive the first re-save under
|
|
834
|
+
// the new flag-based rule.
|
|
835
|
+
_lodash.default.forEach(newDB.objects(_SchemaNames.default.AttendanceRecord), rec => {
|
|
836
|
+
rec.needsFollowUp = !_lodash.default.isNil(rec.followUpEncounterUUID);
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
if (oldDB.schemaVersion < 215) {
|
|
840
|
+
// reasonConceptUUID (single, optional) -> reasonConceptUUIDs (string[]).
|
|
841
|
+
// A set reason becomes a one-element array; null becomes [].
|
|
842
|
+
const oldRecords = oldDB.objects(_SchemaNames.default.AttendanceRecord);
|
|
843
|
+
const newRecords = newDB.objects(_SchemaNames.default.AttendanceRecord);
|
|
844
|
+
for (let i = 0; i < oldRecords.length; i++) {
|
|
845
|
+
const reason = oldRecords[i].reasonConceptUUID;
|
|
846
|
+
newRecords[i].reasonConceptUUIDs = _lodash.default.isNil(reason) ? [] : [reason];
|
|
847
|
+
}
|
|
848
|
+
}
|
|
831
849
|
}
|
|
832
850
|
};
|
|
833
851
|
}
|
package/dist/Session.js
CHANGED
|
@@ -170,11 +170,11 @@ class Session extends _BaseEntity.default {
|
|
|
170
170
|
_lodash.default.forEach(attendanceRecords || [], record => {
|
|
171
171
|
if (!record) return;
|
|
172
172
|
if (record.status !== _AttendanceRecord.default.status.ABSENT) return;
|
|
173
|
-
if (!
|
|
173
|
+
if (!record.needsFollowUp) return;
|
|
174
174
|
// Re-mark path: an existing AttendanceRecord may already point at a
|
|
175
175
|
// previously-created follow-up encounter. Don't create a second one —
|
|
176
176
|
// leave the link in place; voidStaleFollowUps handles the inverse case
|
|
177
|
-
// (
|
|
177
|
+
// (needsFollowUp cleared while still Absent).
|
|
178
178
|
if (record.followUpEncounterUUID) return;
|
|
179
179
|
const student = studentLookup ? studentLookup(record.subjectUUID) : null;
|
|
180
180
|
if (!student) return;
|
|
@@ -221,7 +221,7 @@ class Session extends _BaseEntity.default {
|
|
|
221
221
|
_lodash.default.forOwn(prevByStudent, (prev, studentUUID) => {
|
|
222
222
|
if (!prev || !prev.followUpEncounterUUID) return;
|
|
223
223
|
const next = newByStudent[studentUUID];
|
|
224
|
-
const stillNeedsFollowUp = next && next.status === _AttendanceRecord.default.status.ABSENT &&
|
|
224
|
+
const stillNeedsFollowUp = next && next.status === _AttendanceRecord.default.status.ABSENT && next.needsFollowUp;
|
|
225
225
|
if (stillNeedsFollowUp) return;
|
|
226
226
|
const encounter = encounterLookup ? encounterLookup(prev.followUpEncounterUUID) : null;
|
|
227
227
|
if (!encounter) return;
|