openchs-models 1.32.38 → 1.32.40

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/Concept.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.MediaType = exports.default = void 0;
7
7
 
8
8
  var _BaseEntity = _interopRequireDefault(require("./BaseEntity"));
9
9
 
@@ -84,6 +84,22 @@ class Concept extends _BaseEntity.default {
84
84
  this.that.unit = x;
85
85
  }
86
86
 
87
+ get mediaUrl() {
88
+ return this.that.mediaUrl;
89
+ }
90
+
91
+ set mediaUrl(x) {
92
+ this.that.mediaUrl = x;
93
+ }
94
+
95
+ get mediaType() {
96
+ return this.that.mediaType;
97
+ }
98
+
99
+ set mediaType(x) {
100
+ this.that.mediaType = x;
101
+ }
102
+
87
103
  get name() {
88
104
  return this.that.name;
89
105
  }
@@ -129,6 +145,8 @@ class Concept extends _BaseEntity.default {
129
145
  concept.voided = conceptResource.voided || false; //This change should be independently deployable irrespective of server
130
146
 
131
147
  concept.keyValues = _lodash.default.map(conceptResource.keyValues, _KeyValue.default.fromResource);
148
+ concept.mediaUrl = conceptResource.mediaUrl;
149
+ concept.mediaType = conceptResource.mediaType;
132
150
  return concept;
133
151
  }
134
152
 
@@ -271,7 +289,7 @@ class Concept extends _BaseEntity.default {
271
289
  }
272
290
 
273
291
  isMediaSelectConcept() {
274
- return _lodash.default.includes([Concept.dataType.Image, Concept.dataType.Video, Concept.dataType.File], this.datatype);
292
+ return _lodash.default.includes([Concept.dataType.Image, Concept.dataType.ImageV2, Concept.dataType.Video, Concept.dataType.File], this.datatype);
275
293
  }
276
294
 
277
295
  isSelectConcept() {
@@ -333,6 +351,26 @@ class Concept extends _BaseEntity.default {
333
351
  return keyValue === _KeyValue.default.ContactYesValue;
334
352
  }
335
353
 
354
+ isMediaTypeImage() {
355
+ return this.mediaType === MediaType.Image;
356
+ }
357
+
358
+ hasMediaType() {
359
+ return !_lodash.default.isNil(this.mediaType);
360
+ }
361
+
362
+ hasMediaUrl() {
363
+ return !_lodash.default.isNil(this.mediaUrl) && this.mediaUrl !== '';
364
+ }
365
+
366
+ hasAnswersWithMedia() {
367
+ return _lodash.default.some(this.answers, answer => answer.concept.hasMediaUrl() || answer.concept.hasMediaType());
368
+ }
369
+
370
+ hasMedia() {
371
+ return this.hasMediaUrl() || this.hasMediaType() || this.hasAnswersWithMedia();
372
+ }
373
+
336
374
  }
337
375
 
338
376
  exports.default = Concept;
@@ -380,6 +418,14 @@ _defineProperty(Concept, "schema", {
380
418
  voided: {
381
419
  type: "bool",
382
420
  default: false
421
+ },
422
+ mediaUrl: {
423
+ type: "string",
424
+ optional: true
425
+ },
426
+ mediaType: {
427
+ type: "string",
428
+ optional: true
383
429
  }
384
430
  }
385
431
  });
@@ -428,4 +474,9 @@ _defineProperty(Concept, "dataType", {
428
474
 
429
475
  });
430
476
 
431
- _defineProperty(Concept, "merge", () => _BaseEntity.default.mergeOn("answers"));
477
+ _defineProperty(Concept, "merge", () => _BaseEntity.default.mergeOn("answers"));
478
+
479
+ const MediaType = {
480
+ Image: "Image"
481
+ };
482
+ exports.MediaType = MediaType;
package/dist/Schema.js CHANGED
@@ -283,7 +283,7 @@ function createRealmConfig() {
283
283
  return doCompact;
284
284
  },
285
285
  //order is important, should be arranged according to the dependency
286
- schemaVersion: 199,
286
+ schemaVersion: 200,
287
287
  onMigration: function (oldDB, newDB) {
288
288
  console.log("[AvniModels.Schema]", `Running migration with old schema version: ${oldDB.schemaVersion} and new schema version: ${newDB.schemaVersion}`);
289
289
  if (oldDB.schemaVersion === VersionWithEmbeddedMigrationProblem) throw new Error(`Update from schema version ${VersionWithEmbeddedMigrationProblem} is not allowed. Please uninstall and install app.`);
@@ -971,6 +971,13 @@ function createRealmConfig() {
971
971
  program.showGrowthChart = _lodash.default.toLower(program.name) === "child";
972
972
  });
973
973
  }
974
+
975
+ if (oldDB.schemaVersion < 200) {
976
+ _lodash.default.forEach(newDB.objects("Concept"), concept => {
977
+ concept.mediaType = null;
978
+ concept.mediaUrl = null;
979
+ });
980
+ }
974
981
  }
975
982
  };
976
983
  }
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.32.38",
4
+ "version": "1.32.40",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",