openchs-models 1.31.6 → 1.31.8
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 +1 -1
- package/dist/Checklist.js +0 -6
- package/dist/ChecklistItem.js +0 -4
- package/dist/Encounter.js +0 -4
- package/dist/EntityApprovalStatus.js +0 -27
- package/dist/Individual.js +5 -24
- package/dist/ProgramEncounter.js +0 -4
- package/dist/ProgramEnrolment.js +0 -12
- package/dist/RuleFailureTelemetry.js +16 -4
- package/dist/StandardReportCardType.js +0 -11
- package/dist/application/FormMapping.js +52 -0
- package/dist/draft/DraftEncounter.js +2 -2
- package/dist/draft/DraftSubject.js +1 -1
- package/dist/framework/RealmResultsProxy.js +1 -3
- package/package.json +1 -1
package/Makefile
CHANGED
package/dist/Checklist.js
CHANGED
|
@@ -21,8 +21,6 @@ var _ChecklistDetail = _interopRequireDefault(require("./ChecklistDetail"));
|
|
|
21
21
|
|
|
22
22
|
var _SchemaNames = _interopRequireDefault(require("./SchemaNames"));
|
|
23
23
|
|
|
24
|
-
var _EntityApprovalStatus = _interopRequireDefault(require("./EntityApprovalStatus"));
|
|
25
|
-
|
|
26
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
25
|
|
|
28
26
|
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; }
|
|
@@ -128,10 +126,6 @@ class Checklist extends _BaseEntity.default {
|
|
|
128
126
|
}`;
|
|
129
127
|
}
|
|
130
128
|
|
|
131
|
-
addApprovalDescendantsWithLatestStatus(approvalStatus_status, list) {
|
|
132
|
-
_EntityApprovalStatus.default.addMatchingApprovalStatusEntity(this.items, approvalStatus_status, "baseDate", list);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
129
|
}
|
|
136
130
|
|
|
137
131
|
_defineProperty(Checklist, "schema", {
|
package/dist/ChecklistItem.js
CHANGED
|
@@ -305,10 +305,6 @@ class ChecklistItem extends _BaseEntity.default {
|
|
|
305
305
|
this.that.latestEntityApprovalStatus = this.fromObject(entityApprovalStatus);
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
-
getSchemaName() {
|
|
309
|
-
return _SchemaNames.default.ChecklistItem;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
308
|
}
|
|
313
309
|
|
|
314
310
|
_defineProperty(ChecklistItem, "schema", {
|
package/dist/Encounter.js
CHANGED
|
@@ -22,17 +22,6 @@ 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, 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
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
25
|
static getApprovalEntitiesSchema() {
|
|
37
26
|
return [_SchemaNames.default.Individual, _SchemaNames.default.ProgramEncounter, _SchemaNames.default.Encounter, _SchemaNames.default.ProgramEnrolment, _SchemaNames.default.ChecklistItem];
|
|
38
27
|
}
|
|
@@ -152,22 +141,6 @@ class EntityApprovalStatus extends _BaseEntity.default {
|
|
|
152
141
|
}];
|
|
153
142
|
}
|
|
154
143
|
|
|
155
|
-
hasStatus(status) {
|
|
156
|
-
return this.approvalStatus.status === status;
|
|
157
|
-
}
|
|
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
|
-
|
|
171
144
|
}
|
|
172
145
|
|
|
173
146
|
_defineProperty(EntityApprovalStatus, "schema", {
|
package/dist/Individual.js
CHANGED
|
@@ -232,7 +232,7 @@ class Individual extends _BaseEntity.default {
|
|
|
232
232
|
const individual = new Individual();
|
|
233
233
|
individual.uuid = _General.default.randomUUID();
|
|
234
234
|
individual.subjectType = _SubjectType.default.create("");
|
|
235
|
-
individual.registrationDate =
|
|
235
|
+
individual.registrationDate = new Date();
|
|
236
236
|
individual.gender = _Gender.default.create("");
|
|
237
237
|
individual.observations = [];
|
|
238
238
|
individual.encounters = [];
|
|
@@ -330,7 +330,7 @@ class Individual extends _BaseEntity.default {
|
|
|
330
330
|
}
|
|
331
331
|
|
|
332
332
|
static associateRelationship(child, childEntityClass, childResource, entityService) {
|
|
333
|
-
|
|
333
|
+
var individual = _BaseEntity.default.getParentEntity(entityService, childEntityClass, childResource, "individualAUUID", Individual.schema.name);
|
|
334
334
|
|
|
335
335
|
individual = _General.default.pick(individual, ["uuid"], ["enrolments", "encounters", "relationships", "groupSubjects", "comments", "groups"]);
|
|
336
336
|
|
|
@@ -351,7 +351,7 @@ class Individual extends _BaseEntity.default {
|
|
|
351
351
|
|
|
352
352
|
|
|
353
353
|
try {
|
|
354
|
-
|
|
354
|
+
var memberSubject = getParentByUUID("memberSubjectUUID");
|
|
355
355
|
memberSubject = copyFieldsForSubject(memberSubject);
|
|
356
356
|
|
|
357
357
|
_BaseEntity.default.addNewChild(child, memberSubject.groups);
|
|
@@ -453,12 +453,12 @@ class Individual extends _BaseEntity.default {
|
|
|
453
453
|
}
|
|
454
454
|
|
|
455
455
|
setDateOfBirth(date) {
|
|
456
|
-
this.dateOfBirth =
|
|
456
|
+
this.dateOfBirth = date;
|
|
457
457
|
this.dateOfBirthVerified = true;
|
|
458
458
|
}
|
|
459
459
|
|
|
460
460
|
setAge(age, isInYears) {
|
|
461
|
-
this.dateOfBirth = (0, _moment.default)().subtract(age, isInYears ? "years" : "months").
|
|
461
|
+
this.dateOfBirth = (0, _moment.default)().subtract(age, isInYears ? "years" : "months").toDate();
|
|
462
462
|
this.dateOfBirthVerified = false;
|
|
463
463
|
}
|
|
464
464
|
|
|
@@ -971,21 +971,6 @@ class Individual extends _BaseEntity.default {
|
|
|
971
971
|
this.that.latestEntityApprovalStatus = this.fromObject(entityApprovalStatus);
|
|
972
972
|
}
|
|
973
973
|
|
|
974
|
-
getMemberEntitiesWithLatestStatus(approvalStatus_status) {
|
|
975
|
-
let descendants = [];
|
|
976
|
-
if (!_lodash.default.isNil(this.latestEntityApprovalStatus) && this.latestEntityApprovalStatus.hasStatus(approvalStatus_status)) descendants.push(this);
|
|
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
|
-
|
|
982
|
-
this.nonVoidedEnrolments().forEach(enrolment => {
|
|
983
|
-
const latestEntity = enrolment.addApprovalDescendantsWithLatestStatus(approvalStatus_status, descendants);
|
|
984
|
-
if (!_lodash.default.isNil(latestEntity)) descendants.push(latestEntity);
|
|
985
|
-
});
|
|
986
|
-
return descendants;
|
|
987
|
-
}
|
|
988
|
-
|
|
989
974
|
toJSON() {
|
|
990
975
|
return {
|
|
991
976
|
uuid: this.uuid,
|
|
@@ -1011,10 +996,6 @@ class Individual extends _BaseEntity.default {
|
|
|
1011
996
|
};
|
|
1012
997
|
}
|
|
1013
998
|
|
|
1014
|
-
getSchemaName() {
|
|
1015
|
-
return _SchemaNames.default.Individual;
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
999
|
}
|
|
1019
1000
|
|
|
1020
1001
|
_defineProperty(Individual, "schema", {
|
package/dist/ProgramEncounter.js
CHANGED
|
@@ -145,10 +145,6 @@ class ProgramEncounter extends _AbstractEncounter.default {
|
|
|
145
145
|
this.that.latestEntityApprovalStatus = this.fromObject(entityApprovalStatus);
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
getSchemaName() {
|
|
149
|
-
return _SchemaNames.default.ProgramEncounter;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
148
|
}
|
|
153
149
|
|
|
154
150
|
_defineProperty(ProgramEncounter, "fieldKeys", {
|
package/dist/ProgramEnrolment.js
CHANGED
|
@@ -591,14 +591,6 @@ class ProgramEnrolment extends _BaseEntity.default {
|
|
|
591
591
|
this.that.latestEntityApprovalStatus = this.fromObject(entityApprovalStatus);
|
|
592
592
|
}
|
|
593
593
|
|
|
594
|
-
addApprovalDescendantsWithLatestStatus(approvalStatus_status, list) {
|
|
595
|
-
_EntityApprovalStatus.default.addMatchingApprovalStatusEntity(this.nonVoidedEncounters(), approvalStatus_status, "encounterDateTime", list, "encounterType.uuid");
|
|
596
|
-
|
|
597
|
-
this.checklists.filter(x => !x.voided).forEach(x => {
|
|
598
|
-
x.addApprovalDescendantsWithLatestStatus(approvalStatus_status, list);
|
|
599
|
-
});
|
|
600
|
-
}
|
|
601
|
-
|
|
602
594
|
toJSON() {
|
|
603
595
|
return {
|
|
604
596
|
uuid: this.uuid,
|
|
@@ -619,10 +611,6 @@ class ProgramEnrolment extends _BaseEntity.default {
|
|
|
619
611
|
};
|
|
620
612
|
}
|
|
621
613
|
|
|
622
|
-
getSchemaName() {
|
|
623
|
-
return _SchemaNames.default.ProgramEnrolment;
|
|
624
|
-
}
|
|
625
|
-
|
|
626
614
|
}
|
|
627
615
|
|
|
628
616
|
_defineProperty(ProgramEnrolment, "schema", {
|
|
@@ -172,10 +172,22 @@ _defineProperty(RuleFailureTelemetry, "schema", {
|
|
|
172
172
|
default: false
|
|
173
173
|
},
|
|
174
174
|
errorDateTime: "date",
|
|
175
|
-
sourceType:
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
175
|
+
sourceType: {
|
|
176
|
+
type: "string",
|
|
177
|
+
optional: true
|
|
178
|
+
},
|
|
179
|
+
sourceId: {
|
|
180
|
+
type: "string",
|
|
181
|
+
optional: true
|
|
182
|
+
},
|
|
183
|
+
entityType: {
|
|
184
|
+
type: "string",
|
|
185
|
+
optional: true
|
|
186
|
+
},
|
|
187
|
+
entityId: {
|
|
188
|
+
type: "string",
|
|
189
|
+
optional: true
|
|
190
|
+
},
|
|
179
191
|
appType: "string"
|
|
180
192
|
}
|
|
181
193
|
});
|
|
@@ -11,8 +11,6 @@ var _General = _interopRequireDefault(require("./utility/General"));
|
|
|
11
11
|
|
|
12
12
|
var _TaskType = _interopRequireDefault(require("./task/TaskType"));
|
|
13
13
|
|
|
14
|
-
var _ApprovalStatus = _interopRequireDefault(require("./ApprovalStatus"));
|
|
15
|
-
|
|
16
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
15
|
|
|
18
16
|
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; }
|
|
@@ -112,10 +110,6 @@ class StandardReportCardType extends _BaseEntity.default {
|
|
|
112
110
|
return _.includes(this.defaultTypes(), this.name);
|
|
113
111
|
}
|
|
114
112
|
|
|
115
|
-
getApprovalStatusForType() {
|
|
116
|
-
return typeToStatusMap[this.name];
|
|
117
|
-
}
|
|
118
|
-
|
|
119
113
|
}
|
|
120
114
|
|
|
121
115
|
_defineProperty(StandardReportCardType, "schema", {
|
|
@@ -151,10 +145,5 @@ _defineProperty(StandardReportCardType, "type", {
|
|
|
151
145
|
DueChecklist: "Due checklist"
|
|
152
146
|
});
|
|
153
147
|
|
|
154
|
-
const typeToStatusMap = {
|
|
155
|
-
[StandardReportCardType.type.PendingApproval]: _ApprovalStatus.default.statuses.Pending,
|
|
156
|
-
[StandardReportCardType.type.Approved]: _ApprovalStatus.default.statuses.Approved,
|
|
157
|
-
[StandardReportCardType.type.Rejected]: _ApprovalStatus.default.statuses.Rejected
|
|
158
|
-
};
|
|
159
148
|
var _default = StandardReportCardType;
|
|
160
149
|
exports.default = _default;
|
|
@@ -100,6 +100,58 @@ class FormMapping extends _BaseEntity.default {
|
|
|
100
100
|
return formMapping;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
getSchemaAndFilterQuery() {
|
|
104
|
+
switch (this.form.formType) {
|
|
105
|
+
case _Form.default.formTypes.IndividualProfile:
|
|
106
|
+
return {
|
|
107
|
+
schema: "Individual",
|
|
108
|
+
filterQuery: `subjectType.uuid = '${this.subjectType.uuid}'`
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
case _Form.default.formTypes.IndividualEncounterCancellation:
|
|
112
|
+
return {
|
|
113
|
+
schema: "Encounter",
|
|
114
|
+
filterQuery: `individual.subjectType.uuid = '${this.subjectType.uuid}' and encounterType.uuid = '${this.observationsTypeEntityUUID}' and cancelDateTime <> null`
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
case _Form.default.formTypes.Encounter:
|
|
118
|
+
return {
|
|
119
|
+
schema: "Encounter",
|
|
120
|
+
filterQuery: `individual.subjectType.uuid = '${this.subjectType.uuid}' and encounterType.uuid = '${this.observationsTypeEntityUUID}' and cancelDateTime = null`
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
case _Form.default.formTypes.ProgramEnrolment:
|
|
124
|
+
return {
|
|
125
|
+
schema: "ProgramEnrolment",
|
|
126
|
+
filterQuery: `individual.subjectType.uuid = '${this.subjectType.uuid}' and program.uuid = '${this.entityUUID}' and programExitDateTime = null`
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
case _Form.default.formTypes.ProgramExit:
|
|
130
|
+
return {
|
|
131
|
+
schema: "ProgramEnrolment",
|
|
132
|
+
filterQuery: `individual.subjectType.uuid = '${this.subjectType.uuid}' and program.uuid = '${this.entityUUID}' and programExitDateTime <> null`
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
case _Form.default.formTypes.ProgramEncounter:
|
|
136
|
+
return {
|
|
137
|
+
schema: "ProgramEncounter",
|
|
138
|
+
filterQuery: `programEnrolment.individual.subjectType.uuid = '${this.subjectType.uuid}' and programEnrolment.program.uuid = '${this.entityUUID}' and encounterType.uuid = '${this.observationsTypeEntityUUID}' and cancelDateTime = null`
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
case _Form.default.formTypes.ProgramEncounterCancellation:
|
|
142
|
+
return {
|
|
143
|
+
schema: "ProgramEncounter",
|
|
144
|
+
filterQuery: `programEnrolment.individual.subjectType.uuid = '${this.subjectType.uuid}' and programEnrolment.program.uuid = '${this.entityUUID}' and encounterType.uuid = '${this.observationsTypeEntityUUID}' and cancelDateTime <> null`
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
case _Form.default.formTypes.ChecklistItem:
|
|
148
|
+
return {
|
|
149
|
+
schema: "ChecklistItem",
|
|
150
|
+
filterQuery: ''
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
103
155
|
getEntityNameAndEntityTypeUUID() {
|
|
104
156
|
const formTypes = _Form.default.formTypes;
|
|
105
157
|
|
|
@@ -124,13 +124,13 @@ class DraftEncounter extends _BaseEntity.default {
|
|
|
124
124
|
draftEncounter.encounterType = encounter.encounterType;
|
|
125
125
|
draftEncounter.encounterDateTime = encounter.encounterDateTime;
|
|
126
126
|
draftEncounter.individual = encounter.individual;
|
|
127
|
-
draftEncounter.observations =
|
|
127
|
+
draftEncounter.observations = encounter.observations;
|
|
128
128
|
draftEncounter.encounterLocation = encounter.encounterLocation;
|
|
129
129
|
draftEncounter.name = encounter.name;
|
|
130
130
|
draftEncounter.earliestVisitDateTime = encounter.earliestVisitDateTime;
|
|
131
131
|
draftEncounter.maxVisitDateTime = encounter.maxVisitDateTime;
|
|
132
132
|
draftEncounter.cancelDateTime = encounter.cancelDateTime;
|
|
133
|
-
draftEncounter.cancelObservations =
|
|
133
|
+
draftEncounter.cancelObservations = encounter.cancelObservations;
|
|
134
134
|
draftEncounter.cancelLocation = encounter.cancelLocation;
|
|
135
135
|
draftEncounter.voided = encounter.voided;
|
|
136
136
|
draftEncounter.registrationLocation = encounter.registrationLocation;
|
|
@@ -148,7 +148,7 @@ class DraftSubject extends _BaseEntity.default {
|
|
|
148
148
|
draftSubject.dateOfBirthVerified = subject.dateOfBirthVerified;
|
|
149
149
|
draftSubject.gender = subject.gender;
|
|
150
150
|
draftSubject.lowestAddressLevel = subject.lowestAddressLevel;
|
|
151
|
-
draftSubject.observations =
|
|
151
|
+
draftSubject.observations = subject.observations;
|
|
152
152
|
draftSubject.registrationLocation = subject.registrationLocation;
|
|
153
153
|
draftSubject.totalMembers = _.isEmpty(totalMembers) ? null : totalMembers;
|
|
154
154
|
draftSubject.updatedOn = new Date();
|
|
@@ -60,9 +60,7 @@ class RealmResultsProxy {
|
|
|
60
60
|
|
|
61
61
|
filtered(query, ...args) {
|
|
62
62
|
if (this.logQueries) console.log(this.entityClass, query, ...args);
|
|
63
|
-
|
|
64
|
-
realmResultsProxy.setLogQueries(this.logQueries);
|
|
65
|
-
return realmResultsProxy;
|
|
63
|
+
return RealmResultsProxy.create(this.realmCollection.filtered(query, ...args), this.entityClass);
|
|
66
64
|
}
|
|
67
65
|
|
|
68
66
|
getAt(index) {
|