openchs-models 1.30.96 → 1.30.99

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/Makefile CHANGED
@@ -13,7 +13,7 @@ build:
13
13
 
14
14
  release: get-current-version
15
15
  @echo "\033[0m"
16
- yarn version
16
+ @yarn version
17
17
  @echo " Now please run \nmake publish"
18
18
 
19
19
  publish:
package/dist/Checklist.js CHANGED
@@ -128,8 +128,8 @@ class Checklist extends _BaseEntity.default {
128
128
  }`;
129
129
  }
130
130
 
131
- getApprovalDescendantsWithLatestStatus(approvalStatus_status) {
132
- return _EntityApprovalStatus.default.getMatchingApprovalStatusEntity(this.items, approvalStatus_status);
131
+ addApprovalDescendantsWithLatestStatus(approvalStatus_status, list) {
132
+ _EntityApprovalStatus.default.addMatchingApprovalStatusEntity(this.items, approvalStatus_status, "baseDate", list);
133
133
  }
134
134
 
135
135
  }
@@ -22,8 +22,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
22
22
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23
23
 
24
24
  class EntityApprovalStatus extends _BaseEntity.default {
25
- static getMatchingApprovalStatusEntity(entities, approvalStatus_status) {
26
- return entities.filter(x => !_lodash.default.isNil(x.latestEntityApprovalStatus) && x.latestEntityApprovalStatus.hasStatus(approvalStatus_status));
25
+ static getMatchingApprovalStatusEntity(entities, approvalStatus_status, latestFieldPath) {
26
+ return _lodash.default.max(entities.filter(x => !_lodash.default.isNil(x.latestEntityApprovalStatus) && x.latestEntityApprovalStatus.hasStatus(approvalStatus_status)), y => _lodash.default.get(y, latestFieldPath));
27
+ }
28
+
29
+ static addMatchingApprovalStatusEntity(entities, approvalStatus_status, latestFieldPath, list, groupingByPath) {
30
+ Object.values(_lodash.default.groupBy(entities, x => _lodash.default.get(x, groupingByPath))).forEach(y => {
31
+ const latestEntity = EntityApprovalStatus.getMatchingApprovalStatusEntity(y, approvalStatus_status, latestFieldPath);
32
+ if (!_lodash.default.isNil(latestEntity)) list.push(latestEntity);
33
+ });
27
34
  }
28
35
 
29
36
  static getApprovalEntitiesSchema() {
@@ -149,6 +156,18 @@ class EntityApprovalStatus extends _BaseEntity.default {
149
156
  return this.approvalStatus.status === status;
150
157
  }
151
158
 
159
+ get isRejected() {
160
+ return this.approvalStatus.isRejected;
161
+ }
162
+
163
+ get isApproved() {
164
+ return this.approvalStatus.isApproved;
165
+ }
166
+
167
+ get isPending() {
168
+ return this.approvalStatus.isPending;
169
+ }
170
+
152
171
  }
153
172
 
154
173
  _defineProperty(EntityApprovalStatus, "schema", {
@@ -974,10 +974,14 @@ class Individual extends _BaseEntity.default {
974
974
  getMemberEntitiesWithLatestStatus(approvalStatus_status) {
975
975
  let descendants = [];
976
976
  if (!_lodash.default.isNil(this.latestEntityApprovalStatus) && this.latestEntityApprovalStatus.hasStatus(approvalStatus_status)) descendants.push(this);
977
- descendants = descendants.concat(_EntityApprovalStatus.default.getMatchingApprovalStatusEntity(this.nonVoidedEncounters(), approvalStatus_status));
978
- descendants = descendants.concat(_EntityApprovalStatus.default.getMatchingApprovalStatusEntity(this.nonVoidedEnrolments(), approvalStatus_status));
977
+
978
+ _EntityApprovalStatus.default.addMatchingApprovalStatusEntity(this.nonVoidedEncounters(), approvalStatus_status, "encounterDateTime", descendants, "encounterType.uuid");
979
+
980
+ _EntityApprovalStatus.default.addMatchingApprovalStatusEntity(this.nonVoidedEnrolments(), approvalStatus_status, "enrolmentDateTime", descendants, "program.uuid");
981
+
979
982
  this.nonVoidedEnrolments().forEach(enrolment => {
980
- descendants = descendants.concat(enrolment.getApprovalDescendantsWithLatestStatus(approvalStatus_status));
983
+ const latestEntity = enrolment.addApprovalDescendantsWithLatestStatus(approvalStatus_status, descendants);
984
+ if (!_lodash.default.isNil(latestEntity)) descendants.push(latestEntity);
981
985
  });
982
986
  return descendants;
983
987
  }
@@ -591,13 +591,12 @@ class ProgramEnrolment extends _BaseEntity.default {
591
591
  this.that.latestEntityApprovalStatus = this.fromObject(entityApprovalStatus);
592
592
  }
593
593
 
594
- getApprovalDescendantsWithLatestStatus(approvalStatus_status) {
595
- let descendants = _EntityApprovalStatus.default.getMatchingApprovalStatusEntity(this.nonVoidedEncounters(), approvalStatus_status);
594
+ addApprovalDescendantsWithLatestStatus(approvalStatus_status, list) {
595
+ _EntityApprovalStatus.default.addMatchingApprovalStatusEntity(this.nonVoidedEncounters(), approvalStatus_status, "encounterDateTime", list, "encounterType.uuid");
596
596
 
597
597
  this.checklists.filter(x => !x.voided).forEach(x => {
598
- descendants = descendants.concat(x.getApprovalDescendantsWithLatestStatus(approvalStatus_status));
598
+ x.addApprovalDescendantsWithLatestStatus(approvalStatus_status, list);
599
599
  });
600
- return descendants;
601
600
  }
602
601
 
603
602
  toJSON() {
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.96",
4
+ "version": "1.30.99",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",