openchs-models 1.33.56 → 1.33.57

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.
@@ -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
  }
@@ -86,6 +92,7 @@ class AttendanceRecord extends _BaseEntity.default {
86
92
  record.status = resource.status;
87
93
  record.reasonConceptUUID = resource.reasonConceptUUID || null;
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;
@@ -94,6 +101,7 @@ class AttendanceRecord extends _BaseEntity.default {
94
101
  const resource = _lodash.default.pick(this, ["uuid", "sessionUUID", "subjectUUID", "status", "voided"]);
95
102
  resource.reasonConceptUUID = this.reasonConceptUUID || null;
96
103
  resource.followUpEncounterUUID = this.followUpEncounterUUID || null;
104
+ resource.needsFollowUp = !!this.needsFollowUp;
97
105
  return resource;
98
106
  }
99
107
  }
@@ -113,6 +121,10 @@ _defineProperty(AttendanceRecord, "schema", {
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: 213,
189
+ schemaVersion: 214,
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,14 @@ 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
+ }
831
839
  }
832
840
  };
833
841
  }
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 (!_lodash.default.isNil(record.reasonConceptUUID)) return;
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
- // (student transitioned out of "absent-no-reason").
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 && _lodash.default.isNil(next.reasonConceptUUID);
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;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "openchs-models",
3
3
  "description": "OpenCHS data model to be used by front end clients",
4
- "version": "1.33.56",
4
+ "version": "1.33.57",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",