openchs-models 1.30.30 → 1.30.32

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.
@@ -167,7 +167,9 @@ const refData = (clazz, {
167
167
  translated,
168
168
  parent,
169
169
  syncWeight,
170
- resUrl
170
+ resUrl,
171
+ syncPushRequired = true,
172
+ syncPullRequired = true
171
173
  } = {}) => ({
172
174
  schemaName: clazz.schema.name,
173
175
  entityName: clazz.schema.name,
@@ -178,7 +180,9 @@ const refData = (clazz, {
178
180
  resourceSearchFilterURL: filter,
179
181
  parent: parent,
180
182
  syncWeight: syncWeight,
181
- resourceUrl: resUrl
183
+ resourceUrl: resUrl,
184
+ syncPushRequired,
185
+ syncPullRequired
182
186
  });
183
187
 
184
188
  const refDataNameTranslated = (clazz, attrs = {}) => refData(clazz, _objectSpread({}, attrs, {
@@ -198,7 +202,9 @@ const txData = (clazz, {
198
202
  queryParam,
199
203
  hasMoreThanOneAssociation,
200
204
  apiQueryParams,
201
- apiQueryParamKey
205
+ apiQueryParamKey,
206
+ syncPushRequired = true,
207
+ syncPullRequired = true
202
208
  } = {}) => ({
203
209
  schemaName: clazz.schema.name,
204
210
  entityName: entityName || clazz.schema.name,
@@ -216,7 +222,9 @@ const txData = (clazz, {
216
222
  queryParam,
217
223
  hasMoreThanOneAssociation: !!hasMoreThanOneAssociation,
218
224
  apiQueryParams,
219
- apiQueryParamKey
225
+ apiQueryParamKey,
226
+ syncPushRequired,
227
+ syncPullRequired
220
228
  });
221
229
 
222
230
  const checklistDetail = refData(_ChecklistDetail.default, {
@@ -378,11 +386,13 @@ const groupSubject = txData(_GroupSubject.default, {
378
386
  const videoTelemetric = txData(_VideoTelemetric.default, {
379
387
  res: "videotelemetric",
380
388
  parent: video,
381
- syncWeight: 0
389
+ syncWeight: 0,
390
+ syncPullRequired: false
382
391
  });
383
392
  const syncTelemetry = txData(_SyncTelemetry.default, {
384
393
  resUrl: "syncTelemetry",
385
- syncWeight: 1
394
+ syncWeight: 1,
395
+ syncPullRequired: false
386
396
  });
387
397
  const userInfo = txData(_UserInfo.default, {
388
398
  resUrl: "me",
@@ -394,7 +404,8 @@ const identifierAssignment = txData(_IdentifierAssignment.default, {
394
404
  });
395
405
  const ruleFailureTelemetry = txData(_RuleFailureTelemetry.default, {
396
406
  resUrl: "ruleFailureTelemetry",
397
- syncWeight: 0
407
+ syncWeight: 0,
408
+ syncPullRequired: false
398
409
  });
399
410
  const groups = refData(_Groups.default, {
400
411
  res: "groups",
@@ -471,7 +482,8 @@ const subjectEntityApprovalStatus = txData(_EntityApprovalStatus.default, {
471
482
  privilegeEntity: _Privilege.default.privilegeEntityType.subject,
472
483
  privilegeName: _Privilege.default.privilegeName.viewSubject,
473
484
  parent: individual,
474
- syncWeight: 2
485
+ syncWeight: 2,
486
+ syncPushRequired: false
475
487
  });
476
488
  const encounterEntityApprovalStatus = txData(_EntityApprovalStatus.default, {
477
489
  res: "entityApprovalStatus",
@@ -485,7 +497,8 @@ const encounterEntityApprovalStatus = txData(_EntityApprovalStatus.default, {
485
497
  privilegeEntity: _Privilege.default.privilegeEntityType.encounter,
486
498
  privilegeName: _Privilege.default.privilegeName.viewVisit,
487
499
  parent: encounter,
488
- syncWeight: 2
500
+ syncWeight: 2,
501
+ syncPushRequired: false
489
502
  });
490
503
  const programEncounterEntityApprovalStatus = txData(_EntityApprovalStatus.default, {
491
504
  res: "entityApprovalStatus",
@@ -499,7 +512,8 @@ const programEncounterEntityApprovalStatus = txData(_EntityApprovalStatus.defaul
499
512
  privilegeEntity: _Privilege.default.privilegeEntityType.encounter,
500
513
  privilegeName: _Privilege.default.privilegeName.viewVisit,
501
514
  parent: programEncounter,
502
- syncWeight: 2
515
+ syncWeight: 2,
516
+ syncPushRequired: false
503
517
  });
504
518
  const programEnrolmentEntityApprovalStatus = txData(_EntityApprovalStatus.default, {
505
519
  res: "entityApprovalStatus",
@@ -513,7 +527,8 @@ const programEnrolmentEntityApprovalStatus = txData(_EntityApprovalStatus.defaul
513
527
  privilegeEntity: _Privilege.default.privilegeEntityType.enrolment,
514
528
  privilegeName: _Privilege.default.privilegeName.viewEnrolmentDetails,
515
529
  parent: programEnrolment,
516
- syncWeight: 2
530
+ syncWeight: 2,
531
+ syncPushRequired: false
517
532
  });
518
533
  const checklistItemEntityApprovalStatus = txData(_EntityApprovalStatus.default, {
519
534
  res: "entityApprovalStatus",
@@ -527,11 +542,13 @@ const checklistItemEntityApprovalStatus = txData(_EntityApprovalStatus.default,
527
542
  privilegeEntity: _Privilege.default.privilegeEntityType.checklist,
528
543
  privilegeName: _Privilege.default.privilegeName.viewChecklist,
529
544
  parent: checklistItem,
530
- syncWeight: 2
545
+ syncWeight: 2,
546
+ syncPushRequired: false
531
547
  });
532
548
  const entityApprovalStatus = txData(_EntityApprovalStatus.default, {
533
549
  res: 'entityApprovalStatus',
534
- syncWeight: 1
550
+ syncWeight: 1,
551
+ syncPullRequired: false
535
552
  });
536
553
  const news = txData(_News.default, {
537
554
  syncWeight: 0
@@ -624,6 +641,10 @@ class EntityMetaData {
624
641
  return _lodash.default.find(EntityMetaData.model(), entityMetadata => entityMetadata.entityName === entityName);
625
642
  }
626
643
 
644
+ static getEntitiesToBePulled() {
645
+ return _lodash.default.filter(EntityMetaData.model(), entityMetadata => entityMetadata.syncPullRequired);
646
+ }
647
+
627
648
  }
628
649
 
629
650
  var _default = EntityMetaData;
@@ -410,9 +410,21 @@ class Individual extends _BaseEntity.default {
410
410
  return _AgeUtil.default.getDisplayAge(this.dateOfBirth, i18n);
411
411
  }
412
412
 
413
+ getAgeInYears(asOnDate = (0, _moment.default)(), precise = false) {
414
+ return _AgeUtil.default.getAgeInYears(this.dateOfBirth, asOnDate, precise);
415
+ }
416
+
417
+ getAgeInMonths(asOnDate = (0, _moment.default)(), precise = false) {
418
+ return _AgeUtil.default.getAgeInMonths(this.dateOfBirth, asOnDate, precise);
419
+ }
420
+
421
+ getAgeInWeeks(asOnDate = (0, _moment.default)(), precise = false) {
422
+ return _AgeUtil.default.getAgeInWeeks(this.dateOfBirth, asOnDate, precise);
423
+ }
424
+
413
425
  getAge(asOnDate = (0, _moment.default)()) {
414
- if (_AgeUtil.default.getAgeInYears(this.dateOfBirth, asOnDate) > 0) return _Duration.default.inYear(_AgeUtil.default.getAgeInYears(this.dateOfBirth));
415
- if (_AgeUtil.default.getAgeInMonths(this.dateOfBirth, asOnDate) > 0) return _Duration.default.inMonth(asOnDate.diff(this.dateOfBirth, "months"));
426
+ if (this.getAgeInYears(asOnDate) > 0) return _Duration.default.inYear(this.getAgeInYears());
427
+ if (this.getAgeInMonths(asOnDate) > 0) return _Duration.default.inMonth(asOnDate.diff(this.dateOfBirth, "months"));
416
428
  return _Duration.default.inYear(0);
417
429
  }
418
430
 
@@ -455,7 +467,7 @@ class Individual extends _BaseEntity.default {
455
467
  return _ValidationResult.default.failure(Individual.validationKeys.DOB, "emptyValidationMessage");
456
468
  } else if (!(0, _moment.default)(this.dateOfBirth).isValid()) {
457
469
  return _ValidationResult.default.failure(Individual.validationKeys.DOB, "invalidDateFormat");
458
- } else if (_AgeUtil.default.getAgeInYears(this.dateOfBirth) > 120) {
470
+ } else if (this.getAgeInYears() > 120) {
459
471
  return _ValidationResult.default.failure(Individual.validationKeys.DOB, "ageTooHigh");
460
472
  } else if (this.isRegistrationBeforeDateOfBirth) {
461
473
  return _ValidationResult.default.failure(Individual.validationKeys.DOB, "registrationBeforeDateOfBirth");
package/dist/Schema.js CHANGED
@@ -200,7 +200,7 @@ const entities = [_DashboardFilter.default, _LocaleMapping.default, _Settings.de
200
200
  function createRealmConfig() {
201
201
  return {
202
202
  //order is important, should be arranged according to the dependency
203
- schemaVersion: 177,
203
+ schemaVersion: 178,
204
204
  migration: function (oldDB, newDB) {
205
205
  console.log("[AvniModels.Schema]", `Running migration with old schema version: ${oldDB.schemaVersion} and new schema version: ${newDB.schemaVersion}`);
206
206
 
@@ -761,6 +761,12 @@ function createRealmConfig() {
761
761
  }
762
762
  });
763
763
  }
764
+
765
+ if (oldDB.schemaVersion < 178) {
766
+ const pushOnlyEntities = oldDB.objects(_EntitySyncStatus.default.schema.name).filtered("entityName = 'EntityApprovalStatus' OR entityName = 'SyncTelemetry' OR entityName = 'VideoTelemetric' OR entityName = 'RuleFailureTelemetry'");
767
+
768
+ _lodash.default.forEach(pushOnlyEntities, pushOnlyEntity => newDB.delete(pushOnlyEntity));
769
+ }
764
770
  }
765
771
  };
766
772
  }
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.30.30",
4
+ "version": "1.30.32",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",