openchs-models 1.33.67 → 1.33.69

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.
@@ -419,8 +419,12 @@ class ObservationsHolder {
419
419
  // Handle multiple coded values
420
420
  else if (valueWrapper.isMultipleCoded) {
421
421
  const answers = valueWrapper.getValue();
422
- if (_lodash.default.includes(answers, oldValue)) {
423
- const newAnswers = _lodash.default.map(answers, answer => answer === oldValue ? newValue : answer);
422
+ const oldValueIndex = _lodash.default.indexOf(answers, oldValue);
423
+ if (oldValueIndex >= 0) {
424
+ // Duplicate occurrences are not meaningful for media values — collapse them
425
+ // into the single replaced entry.
426
+ const newAnswers = _lodash.default.reject(answers, answer => answer === oldValue);
427
+ newAnswers.splice(oldValueIndex, 0, newValue);
424
428
  observation.valueJSON = new _MultipleCodedValues.default(newAnswers, valueWrapper.answerSource);
425
429
  return true;
426
430
  }
package/dist/Schema.js CHANGED
@@ -828,17 +828,20 @@ function createRealmConfig() {
828
828
  // AttendanceType) for the new MarkAttendance action. Existing rows
829
829
  // remain null.
830
830
  }
831
- if (oldDB.schemaVersion < 214) {
831
+ if (oldDB.schemaVersion >= 212 && oldDB.schemaVersion < 214) {
832
832
  // Backfill AttendanceRecord.needsFollowUp from existing follow-up
833
833
  // linkage so historical follow-ups survive the first re-save under
834
- // the new flag-based rule.
834
+ // the new flag-based rule. Skipped when upgrading from < 212, where
835
+ // AttendanceRecord did not exist yet (no rows to backfill).
835
836
  _lodash.default.forEach(newDB.objects(_SchemaNames.default.AttendanceRecord), rec => {
836
837
  rec.needsFollowUp = !_lodash.default.isNil(rec.followUpEncounterUUID);
837
838
  });
838
839
  }
839
- if (oldDB.schemaVersion < 215) {
840
+ if (oldDB.schemaVersion >= 212 && oldDB.schemaVersion < 215) {
840
841
  // reasonConceptUUID (single, optional) -> reasonConceptUUIDs (string[]).
841
842
  // A set reason becomes a one-element array; null becomes [].
843
+ // Guarded to >= 212: reading oldDB.objects(AttendanceRecord) when the
844
+ // old schema predates the type throws "not found in schema".
842
845
  const oldRecords = oldDB.objects(_SchemaNames.default.AttendanceRecord);
843
846
  const newRecords = newDB.objects(_SchemaNames.default.AttendanceRecord);
844
847
  for (let i = 0; i < oldRecords.length; i++) {
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.67",
4
+ "version": "1.33.69",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",