openchs-models 1.9.2 → 1.10.0
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/AbstractEncounter.js +12 -12
- package/dist/ChecklistItem.js +2 -2
- package/dist/Concept.js +6 -2
- package/dist/Family.js +4 -4
- package/dist/Individual.js +18 -18
- package/dist/ProgramEncounter.js +6 -6
- package/dist/ProgramEnrolment.js +46 -44
- package/dist/application/Form.js +47 -0
- package/dist/application/FormElement.js +5 -1
- package/package.json +1 -1
|
@@ -113,30 +113,30 @@ class AbstractEncounter extends _BaseEntity.default {
|
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
findObservation(
|
|
116
|
+
findObservation(conceptNameOrUuid) {
|
|
117
117
|
return _lodash.default.find(this.observations, observation => {
|
|
118
|
-
return observation.concept.name ===
|
|
118
|
+
return observation.concept.name === conceptNameOrUuid || observation.concept.uuid === conceptNameOrUuid;
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
findCancelEncounterObservation(
|
|
122
|
+
findCancelEncounterObservation(conceptNameOrUuid) {
|
|
123
123
|
return _lodash.default.find(this.cancelObservations, observation => {
|
|
124
|
-
return observation.concept.name ===
|
|
124
|
+
return observation.concept.name === conceptNameOrUuid || observation.concept.uuid === conceptNameOrUuid;
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
findCancelEncounterObservationReadableValue(
|
|
129
|
-
const observationForConcept = this.findCancelEncounterObservation(
|
|
128
|
+
findCancelEncounterObservationReadableValue(conceptNameOrUuid) {
|
|
129
|
+
const observationForConcept = this.findCancelEncounterObservation(conceptNameOrUuid);
|
|
130
130
|
return _lodash.default.isEmpty(observationForConcept) ? observationForConcept : observationForConcept.getReadableValue();
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
getObservationValue(
|
|
134
|
-
const observationForConcept = this.findObservation(
|
|
133
|
+
getObservationValue(conceptNameOrUuid) {
|
|
134
|
+
const observationForConcept = this.findObservation(conceptNameOrUuid);
|
|
135
135
|
return _lodash.default.isEmpty(observationForConcept) ? observationForConcept : observationForConcept.getValue();
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
getObservationReadableValue(
|
|
139
|
-
const observationForConcept = this.findObservation(
|
|
138
|
+
getObservationReadableValue(conceptNameOrUuid) {
|
|
139
|
+
const observationForConcept = this.findObservation(conceptNameOrUuid);
|
|
140
140
|
return _lodash.default.isEmpty(observationForConcept) ? observationForConcept : observationForConcept.getReadableValue();
|
|
141
141
|
}
|
|
142
142
|
|
|
@@ -171,8 +171,8 @@ class AbstractEncounter extends _BaseEntity.default {
|
|
|
171
171
|
return _lodash.default.isNil(this.encounterDateTime) && _lodash.default.isNil(this.cancelDateTime);
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
hasObservation(
|
|
175
|
-
return !_lodash.default.isNil(this.getObservationValue(
|
|
174
|
+
hasObservation(conceptNameOrUuid) {
|
|
175
|
+
return !_lodash.default.isNil(this.getObservationValue(conceptNameOrUuid));
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
findMediaObservations() {
|
package/dist/ChecklistItem.js
CHANGED
|
@@ -208,9 +208,9 @@ class ChecklistItem {
|
|
|
208
208
|
return `ChecklistItem{uuid=${this.uuid}}`;
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
findObservation(
|
|
211
|
+
findObservation(conceptNameOrUuid) {
|
|
212
212
|
return _lodash.default.find(this.observations, observation => {
|
|
213
|
-
return observation.concept.name ===
|
|
213
|
+
return observation.concept.name === conceptNameOrUuid || observation.concept.uuid === conceptNameOrUuid;
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
216
|
|
package/dist/Concept.js
CHANGED
|
@@ -182,8 +182,8 @@ class Concept {
|
|
|
182
182
|
return conceptAnswer;
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
getPossibleAnswerConcept(
|
|
186
|
-
return _lodash.default.find(this.answers, conceptAnswer => conceptAnswer.concept.name ===
|
|
185
|
+
getPossibleAnswerConcept(nameOrUuid) {
|
|
186
|
+
return _lodash.default.find(this.answers, conceptAnswer => conceptAnswer.concept.name === nameOrUuid || conceptAnswer.concept.uuid === nameOrUuid);
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
getValueWrapperFor(obsValue) {
|
|
@@ -240,6 +240,10 @@ class Concept {
|
|
|
240
240
|
return _lodash.default.find(this.getAnswers(), answer => answer.concept.name === answerName);
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
+
getAnswerWithConceptUuid(answerConceptUuid) {
|
|
244
|
+
return _lodash.default.find(this.getAnswers(), answer => answer.concept.uuid === answerConceptUuid);
|
|
245
|
+
}
|
|
246
|
+
|
|
243
247
|
get translatedFieldValue() {
|
|
244
248
|
return this.name;
|
|
245
249
|
}
|
package/dist/Family.js
CHANGED
|
@@ -131,14 +131,14 @@ class Family extends _BaseEntity.default {
|
|
|
131
131
|
return family;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
findObservation(
|
|
134
|
+
findObservation(conceptNameOrUuid) {
|
|
135
135
|
return _lodash.default.find(this.observations, observation => {
|
|
136
|
-
return observation.concept.name ===
|
|
136
|
+
return observation.concept.name === conceptNameOrUuid || observation.concept.uuid === conceptNameOrUuid;
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
getObservationValue(
|
|
141
|
-
const observationForConcept = this.findObservation(
|
|
140
|
+
getObservationValue(conceptNameOrUuid) {
|
|
141
|
+
const observationForConcept = this.findObservation(conceptNameOrUuid);
|
|
142
142
|
return _lodash.default.isEmpty(observationForConcept) ? observationForConcept : observationForConcept.getValue();
|
|
143
143
|
}
|
|
144
144
|
|
package/dist/Individual.js
CHANGED
|
@@ -146,12 +146,12 @@ class Individual extends _BaseEntity.default {
|
|
|
146
146
|
return resource;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
findObservationAcrossAllEnrolments(
|
|
150
|
-
return this.nonVoidedEnrolments().find(enrolment => enrolment.findLatestObservationInEntireEnrolment(
|
|
149
|
+
findObservationAcrossAllEnrolments(conceptNameOrUuid) {
|
|
150
|
+
return this.nonVoidedEnrolments().find(enrolment => enrolment.findLatestObservationInEntireEnrolment(conceptNameOrUuid) !== undefined);
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
observationExistsAcrossAllEnrolments(
|
|
154
|
-
return this.nonVoidedEnrolments().find(enrolment => enrolment.findLatestObservationInEntireEnrolment(
|
|
153
|
+
observationExistsAcrossAllEnrolments(conceptNameOrUuid) {
|
|
154
|
+
return this.nonVoidedEnrolments().find(enrolment => enrolment.findLatestObservationInEntireEnrolment(conceptNameOrUuid) !== undefined);
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
static newInstance(uuid, firstName, lastName, dateOfBirth, dateOfBirthVerified, gender, lowestAddressLevel, subjectType) {
|
|
@@ -544,14 +544,14 @@ class Individual extends _BaseEntity.default {
|
|
|
544
544
|
}
|
|
545
545
|
}
|
|
546
546
|
|
|
547
|
-
findObservation(
|
|
547
|
+
findObservation(conceptNameOrUuid) {
|
|
548
548
|
return _lodash.default.find(this.observations, observation => {
|
|
549
|
-
return observation.concept.name ===
|
|
549
|
+
return observation.concept.name === conceptNameOrUuid || observation.concept.uuid === conceptNameOrUuid;
|
|
550
550
|
});
|
|
551
551
|
}
|
|
552
552
|
|
|
553
|
-
getObservationValue(
|
|
554
|
-
const observationForConcept = this.findObservation(
|
|
553
|
+
getObservationValue(conceptNameOrUuid) {
|
|
554
|
+
const observationForConcept = this.findObservation(conceptNameOrUuid);
|
|
555
555
|
return _lodash.default.isEmpty(observationForConcept) ? observationForConcept : observationForConcept.getValue();
|
|
556
556
|
}
|
|
557
557
|
|
|
@@ -681,13 +681,13 @@ class Individual extends _BaseEntity.default {
|
|
|
681
681
|
return _lodash.default.chain(this.getEncounters(false)).filter(enc => enc.encounterDateTime).filter(enc => enc.encounterDateTime < currentEncounter.encounterDateTime).filter(enc => encounterTypes.some(encounterType => encounterType === enc.encounterType.name)).nth(n).value();
|
|
682
682
|
}
|
|
683
683
|
|
|
684
|
-
_findObservationWithDateFromAllEncounters(
|
|
684
|
+
_findObservationWithDateFromAllEncounters(conceptNameOrUuid, encounters) {
|
|
685
685
|
let observation;
|
|
686
686
|
let encounter;
|
|
687
687
|
|
|
688
688
|
for (let i = 0; i < encounters.length; i++) {
|
|
689
689
|
encounter = encounters[i];
|
|
690
|
-
observation = encounters[i].findObservation(
|
|
690
|
+
observation = encounters[i].findObservation(conceptNameOrUuid);
|
|
691
691
|
if (!_lodash.default.isNil(observation)) return {
|
|
692
692
|
observation: observation,
|
|
693
693
|
date: encounter.encounterDateTime
|
|
@@ -697,22 +697,22 @@ class Individual extends _BaseEntity.default {
|
|
|
697
697
|
return {};
|
|
698
698
|
}
|
|
699
699
|
|
|
700
|
-
_findObservationFromAllEncounters(
|
|
701
|
-
return this._findObservationWithDateFromAllEncounters(
|
|
700
|
+
_findObservationFromAllEncounters(conceptNameOrUuid, encounters) {
|
|
701
|
+
return this._findObservationWithDateFromAllEncounters(conceptNameOrUuid, encounters).observation;
|
|
702
702
|
}
|
|
703
703
|
|
|
704
|
-
findLatestObservationFromPreviousEncounters(
|
|
704
|
+
findLatestObservationFromPreviousEncounters(conceptNameOrUuid, currentEncounter) {
|
|
705
705
|
const encounters = _lodash.default.chain(this.getEncounters(false)).filter(enc => enc.encounterDateTime).filter(enc => enc.encounterDateTime < currentEncounter.encounterDateTime).value();
|
|
706
706
|
|
|
707
|
-
return this._findObservationFromAllEncounters(
|
|
707
|
+
return this._findObservationFromAllEncounters(conceptNameOrUuid, encounters);
|
|
708
708
|
}
|
|
709
709
|
|
|
710
|
-
findLatestObservationFromEncounters(
|
|
710
|
+
findLatestObservationFromEncounters(conceptNameOrUuid, currentEncounter) {
|
|
711
711
|
const previousEncounters = _lodash.default.chain(this.getEncounters(false)).filter(enc => enc.encounterDateTime).filter(enc => currentEncounter ? enc.encounterDateTime < currentEncounter.encounterDateTime : true).value();
|
|
712
712
|
|
|
713
713
|
const encounters = _lodash.default.chain(currentEncounter).concat(previousEncounters).compact().value();
|
|
714
714
|
|
|
715
|
-
return this._findObservationFromAllEncounters(
|
|
715
|
+
return this._findObservationFromAllEncounters(conceptNameOrUuid, encounters);
|
|
716
716
|
}
|
|
717
717
|
|
|
718
718
|
scheduledEncountersOfType(encounterTypeName) {
|
|
@@ -746,8 +746,8 @@ class Individual extends _BaseEntity.default {
|
|
|
746
746
|
}
|
|
747
747
|
}
|
|
748
748
|
|
|
749
|
-
getObservationReadableValue(
|
|
750
|
-
const observationForConcept = this.findObservation(
|
|
749
|
+
getObservationReadableValue(conceptNameOrUuid) {
|
|
750
|
+
const observationForConcept = this.findObservation(conceptNameOrUuid);
|
|
751
751
|
return _lodash.default.isEmpty(observationForConcept) ? observationForConcept : observationForConcept.getReadableValue();
|
|
752
752
|
}
|
|
753
753
|
|
package/dist/ProgramEncounter.js
CHANGED
|
@@ -68,16 +68,16 @@ class ProgramEncounter extends _AbstractEncounter.default {
|
|
|
68
68
|
return "ProgramEncounter";
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
findObservationInEntireEnrolment(
|
|
72
|
-
return this.programEnrolment.findObservationInEntireEnrolment(
|
|
71
|
+
findObservationInEntireEnrolment(conceptNameOrUuid) {
|
|
72
|
+
return this.programEnrolment.findObservationInEntireEnrolment(conceptNameOrUuid);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
findLatestObservationInEntireEnrolment(
|
|
76
|
-
return this.programEnrolment.findLatestObservationInEntireEnrolment(
|
|
75
|
+
findLatestObservationInEntireEnrolment(conceptNameOrUuid, currentEncounter) {
|
|
76
|
+
return this.programEnrolment.findLatestObservationInEntireEnrolment(conceptNameOrUuid, currentEncounter);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
observationExistsInEntireEnrolment(
|
|
80
|
-
return !_lodash.default.isNil(this.programEnrolment.findObservationInEntireEnrolment(
|
|
79
|
+
observationExistsInEntireEnrolment(conceptNameOrUuid) {
|
|
80
|
+
return !_lodash.default.isNil(this.programEnrolment.findObservationInEntireEnrolment(conceptNameOrUuid));
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
get individual() {
|
package/dist/ProgramEnrolment.js
CHANGED
|
@@ -181,11 +181,11 @@ class ProgramEnrolment extends _BaseEntity.default {
|
|
|
181
181
|
return _lodash.default.chain(this.nonVoidedEncounters()).filter(encounter => _lodash.default.isEmpty(encounterTypeNames) ? encounter : _lodash.default.some(encounterTypeNames, name => name === _lodash.default.get(encounter, "encounterType.name"))).filter(encounter => encounter.encounterDateTime).maxBy(encounter => encounter.encounterDateTime).value();
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
getObservationsForConceptName(
|
|
184
|
+
getObservationsForConceptName(conceptNameOrUuid) {
|
|
185
185
|
return _lodash.default.chain(this.getEncounters(true)).map(encounter => {
|
|
186
186
|
return {
|
|
187
187
|
encounterDateTime: encounter.encounterDateTime,
|
|
188
|
-
obs: encounter.findObservation(
|
|
188
|
+
obs: encounter.findObservation(conceptNameOrUuid)
|
|
189
189
|
};
|
|
190
190
|
}).filter(observation => observation.obs).map(observation => {
|
|
191
191
|
return {
|
|
@@ -227,14 +227,14 @@ class ProgramEnrolment extends _BaseEntity.default {
|
|
|
227
227
|
return _lodash.default.uniqBy(_lodash.default.map(this.encounters, enc => enc.encounterType), "uuid");
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
findObservationValueInEntireEnrolment(
|
|
230
|
+
findObservationValueInEntireEnrolment(conceptNameOrUuid, checkInEnrolment) {
|
|
231
231
|
let encounters = _lodash.default.reverse(this.getEncounters(true));
|
|
232
232
|
|
|
233
|
-
let observationWithDate = this._findObservationWithDateFromEntireEnrolment(
|
|
233
|
+
let observationWithDate = this._findObservationWithDateFromEntireEnrolment(conceptNameOrUuid, encounters, checkInEnrolment);
|
|
234
234
|
|
|
235
235
|
if (_lodash.default.isNil(observationWithDate.observation)) {
|
|
236
236
|
observationWithDate = {
|
|
237
|
-
observation: this.findObservation(
|
|
237
|
+
observation: this.findObservation(conceptNameOrUuid),
|
|
238
238
|
date: this.enrolmentDateTime
|
|
239
239
|
};
|
|
240
240
|
}
|
|
@@ -245,55 +245,55 @@ class ProgramEnrolment extends _BaseEntity.default {
|
|
|
245
245
|
};
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
findObservationInEntireEnrolment(
|
|
248
|
+
findObservationInEntireEnrolment(conceptNameOrUuid, currentEncounter, latest = false) {
|
|
249
249
|
let encounters = _lodash.default.chain(this.getEncounters()).filter(enc => currentEncounter ? enc.uuid !== currentEncounter.uuid : true).concat(currentEncounter).compact().sortBy(enc => enc.encounterDateTime).value();
|
|
250
250
|
|
|
251
251
|
encounters = latest ? _lodash.default.reverse(encounters) : encounters;
|
|
252
|
-
return this._findObservationFromEntireEnrolment(
|
|
252
|
+
return this._findObservationFromEntireEnrolment(conceptNameOrUuid, encounters, true);
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
observationExistsInEntireEnrolment(
|
|
256
|
-
return !_lodash.default.isEmpty(this.findObservationInEntireEnrolment(
|
|
255
|
+
observationExistsInEntireEnrolment(conceptNameOrUuid, currentEncounter) {
|
|
256
|
+
return !_lodash.default.isEmpty(this.findObservationInEntireEnrolment(conceptNameOrUuid, currentEncounter));
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
findLatestObservationInEntireEnrolment(
|
|
260
|
-
return this.findObservationInEntireEnrolment(
|
|
259
|
+
findLatestObservationInEntireEnrolment(conceptNameOrUuid, currentEncounter) {
|
|
260
|
+
return this.findObservationInEntireEnrolment(conceptNameOrUuid, currentEncounter, true);
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
findLatestObservationFromEncounters(
|
|
263
|
+
findLatestObservationFromEncounters(conceptNameOrUuid, currentEncounter, checkInEnrolment = false) {
|
|
264
264
|
const encountersFromEnrolment = _lodash.default.chain(this.getEncounters()).filter(enc => enc.encounterDateTime).filter(enc => currentEncounter ? enc.encounterDateTime < currentEncounter.encounterDateTime : true).value();
|
|
265
265
|
|
|
266
266
|
const encounters = _lodash.default.chain(currentEncounter).concat(encountersFromEnrolment).compact().value();
|
|
267
267
|
|
|
268
|
-
return this._findObservationFromEntireEnrolment(
|
|
268
|
+
return this._findObservationFromEntireEnrolment(conceptNameOrUuid, encounters, checkInEnrolment);
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
findLatestObservationFromPreviousEncounters(
|
|
271
|
+
findLatestObservationFromPreviousEncounters(conceptNameOrUuid, currentEncounter) {
|
|
272
272
|
const encounters = _lodash.default.chain(this.getEncounters()).filter(enc => enc.encounterDateTime).filter(enc => enc.encounterDateTime < currentEncounter.encounterDateTime).value();
|
|
273
273
|
|
|
274
|
-
return this._findObservationFromEntireEnrolment(
|
|
274
|
+
return this._findObservationFromEntireEnrolment(conceptNameOrUuid, encounters, false);
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
findLatestPreviousEncounterWithValueForConcept(currentEncounter,
|
|
277
|
+
findLatestPreviousEncounterWithValueForConcept(currentEncounter, conceptNameOrUuid, valueConceptName) {
|
|
278
278
|
const encounters = _lodash.default.chain(this.getEncounters()).filter(enc => enc.encounterDateTime).filter(enc => enc.encounterDateTime < currentEncounter.encounterDateTime).value();
|
|
279
279
|
|
|
280
280
|
for (let i = 0; i < encounters.length; i++) {
|
|
281
|
-
if (this._encounterContainsAnswerConceptName(encounters[i],
|
|
281
|
+
if (this._encounterContainsAnswerConceptName(encounters[i], conceptNameOrUuid, valueConceptName)) return encounters[i];
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
return null;
|
|
285
285
|
}
|
|
286
286
|
|
|
287
|
-
_encounterHasObsForConcept(encounter,
|
|
288
|
-
const observation = encounter.getObservationValue(
|
|
287
|
+
_encounterHasObsForConcept(encounter, conceptNameOrUuid) {
|
|
288
|
+
const observation = encounter.getObservationValue(conceptNameOrUuid);
|
|
289
289
|
return !_lodash.default.isNil(observation);
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
findLatestPreviousEncounterWithObservationForConcept(currentEncounter,
|
|
292
|
+
findLatestPreviousEncounterWithObservationForConcept(currentEncounter, conceptNameOrUuid) {
|
|
293
293
|
const encounters = _lodash.default.chain(this.getEncounters()).filter(enc => enc.encounterDateTime).filter(enc => enc.encounterDateTime < currentEncounter.encounterDateTime).value();
|
|
294
294
|
|
|
295
295
|
for (let i = 0; i < encounters.length; i++) {
|
|
296
|
-
if (this._encounterHasObsForConcept(encounters[i],
|
|
296
|
+
if (this._encounterHasObsForConcept(encounters[i], conceptNameOrUuid)) return encounters[i];
|
|
297
297
|
}
|
|
298
298
|
|
|
299
299
|
return null;
|
|
@@ -307,28 +307,28 @@ class ProgramEnrolment extends _BaseEntity.default {
|
|
|
307
307
|
return _lodash.default.chain(this.getEncounters()).filter(enc => enc.encounterDateTime).filter(enc => enc.encounterDateTime < currentEncounter.encounterDateTime).filter(enc => encounterTypes.some(encounterType => encounterType === enc.encounterType.name)).nth(n).value();
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
-
_encounterContainsAnswerConceptName(encounter,
|
|
311
|
-
let observation = encounter.findObservation(
|
|
310
|
+
_encounterContainsAnswerConceptName(encounter, conceptNameOrUuid, valueConceptName) {
|
|
311
|
+
let observation = encounter.findObservation(conceptNameOrUuid);
|
|
312
312
|
return !_lodash.default.isNil(observation) && this._containsAnswerConceptName(valueConceptName, observation);
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
-
_containsAnswerConceptName(
|
|
316
|
-
const answerConcept = observation.concept.getPossibleAnswerConcept(
|
|
315
|
+
_containsAnswerConceptName(conceptNameOrUuid, observation) {
|
|
316
|
+
const answerConcept = observation.concept.getPossibleAnswerConcept(conceptNameOrUuid);
|
|
317
317
|
const answerUuid = answerConcept && answerConcept.concept.uuid;
|
|
318
318
|
return observation.getValueWrapper().hasValue(answerUuid);
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
-
_findObservationFromEntireEnrolment(
|
|
322
|
-
return this._findObservationWithDateFromEntireEnrolment(
|
|
321
|
+
_findObservationFromEntireEnrolment(conceptNameOrUuid, encounters, checkInEnrolment = true) {
|
|
322
|
+
return this._findObservationWithDateFromEntireEnrolment(conceptNameOrUuid, encounters, checkInEnrolment).observation;
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
-
_findObservationWithDateFromEntireEnrolment(
|
|
325
|
+
_findObservationWithDateFromEntireEnrolment(conceptNameOrUuid, encounters, checkInEnrolment = true) {
|
|
326
326
|
let observation;
|
|
327
327
|
let encounter;
|
|
328
328
|
|
|
329
329
|
for (let i = 0; i < encounters.length; i++) {
|
|
330
330
|
encounter = encounters[i];
|
|
331
|
-
observation = encounters[i].findObservation(
|
|
331
|
+
observation = encounters[i].findObservation(conceptNameOrUuid);
|
|
332
332
|
if (!_lodash.default.isNil(observation)) return {
|
|
333
333
|
observation: observation,
|
|
334
334
|
date: encounter.encounterDateTime
|
|
@@ -336,23 +336,25 @@ class ProgramEnrolment extends _BaseEntity.default {
|
|
|
336
336
|
}
|
|
337
337
|
|
|
338
338
|
if (checkInEnrolment) return {
|
|
339
|
-
observation: this.findObservation(
|
|
339
|
+
observation: this.findObservation(conceptNameOrUuid),
|
|
340
340
|
date: this.enrolmentDateTime
|
|
341
341
|
};
|
|
342
342
|
return {};
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
-
getObservationReadableValueInEntireEnrolment(
|
|
346
|
-
let obs = this.findObservationInEntireEnrolment(
|
|
345
|
+
getObservationReadableValueInEntireEnrolment(conceptNameOrUuid, programEncounter) {
|
|
346
|
+
let obs = this.findObservationInEntireEnrolment(conceptNameOrUuid, programEncounter);
|
|
347
347
|
return obs ? obs.getReadableValue() : undefined;
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
findObservation(
|
|
351
|
-
return _lodash.default.find(this.observations, observation =>
|
|
350
|
+
findObservation(conceptNameOrUuid) {
|
|
351
|
+
return _lodash.default.find(this.observations, observation => {
|
|
352
|
+
return observation.concept.name === conceptNameOrUuid || observation.concept.uuid === conceptNameOrUuid;
|
|
353
|
+
});
|
|
352
354
|
}
|
|
353
355
|
|
|
354
|
-
findExitObservation(
|
|
355
|
-
return _lodash.default.find(this.programExitObservations, observation => observation.concept.name ===
|
|
356
|
+
findExitObservation(conceptNameOrUuid) {
|
|
357
|
+
return _lodash.default.find(this.programExitObservations, observation => observation.concept.name === conceptNameOrUuid || observation.concept.uuid === conceptNameOrUuid);
|
|
356
358
|
}
|
|
357
359
|
|
|
358
360
|
addChecklist(checklist) {
|
|
@@ -415,24 +417,24 @@ class ProgramEnrolment extends _BaseEntity.default {
|
|
|
415
417
|
return encounterTypeNames.some(it => this.hasEncounterOfType(it));
|
|
416
418
|
}
|
|
417
419
|
|
|
418
|
-
hasEncounterWithObservationValueAfterDate(encounterTypeName, afterDate,
|
|
419
|
-
const obsAfterDate = (0, _lodash.default)(this.getEncounters()).filter(en => (0, _moment.default)(en.encounterDateTime).isAfter(afterDate)).filter(en => en.encounterType.name === encounterTypeName).find(en => en.getObservationReadableValue(
|
|
420
|
+
hasEncounterWithObservationValueAfterDate(encounterTypeName, afterDate, conceptNameOrUuid, value) {
|
|
421
|
+
const obsAfterDate = (0, _lodash.default)(this.getEncounters()).filter(en => (0, _moment.default)(en.encounterDateTime).isAfter(afterDate)).filter(en => en.encounterType.name === encounterTypeName).find(en => en.getObservationReadableValue(conceptNameOrUuid) === value);
|
|
420
422
|
return !_lodash.default.isNil(obsAfterDate);
|
|
421
423
|
} //get has been taken by the prototype
|
|
422
424
|
|
|
423
425
|
|
|
424
|
-
getObservationValue(
|
|
425
|
-
const observationValue = this.findObservation(
|
|
426
|
+
getObservationValue(conceptNameOrUuid) {
|
|
427
|
+
const observationValue = this.findObservation(conceptNameOrUuid);
|
|
426
428
|
return _lodash.default.isEmpty(observationValue) ? undefined : observationValue.getValue();
|
|
427
429
|
}
|
|
428
430
|
|
|
429
|
-
getObservationReadableValue(
|
|
430
|
-
const observationValue = this.findObservation(
|
|
431
|
+
getObservationReadableValue(conceptNameOrUuid) {
|
|
432
|
+
const observationValue = this.findObservation(conceptNameOrUuid);
|
|
431
433
|
return _lodash.default.isNil(observationValue) ? undefined : observationValue.getReadableValue();
|
|
432
434
|
}
|
|
433
435
|
|
|
434
|
-
hasObservation(
|
|
435
|
-
return !_lodash.default.isNil(this.getObservationValue(
|
|
436
|
+
hasObservation(conceptNameOrUuid) {
|
|
437
|
+
return !_lodash.default.isNil(this.getObservationValue(conceptNameOrUuid));
|
|
436
438
|
}
|
|
437
439
|
|
|
438
440
|
findMediaObservations() {
|
package/dist/application/Form.js
CHANGED
|
@@ -143,6 +143,53 @@ class Form {
|
|
|
143
143
|
return orderedObservations.concat(extraObs);
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
sectionWiseOrderedObservations(observations) {
|
|
147
|
+
const sections = [];
|
|
148
|
+
const allObservations = [];
|
|
149
|
+
|
|
150
|
+
const orderedFEG = _lodash.default.sortBy(this.formElementGroups, ({
|
|
151
|
+
displayOrder
|
|
152
|
+
}) => displayOrder);
|
|
153
|
+
|
|
154
|
+
_lodash.default.forEach(orderedFEG, feg => {
|
|
155
|
+
const conceptOrdering = _lodash.default.sortBy(feg.getFormElements(), fe => fe.displayOrder).map(fe => fe.concept);
|
|
156
|
+
|
|
157
|
+
const fegObs = [];
|
|
158
|
+
|
|
159
|
+
_lodash.default.forEach(conceptOrdering, concept => {
|
|
160
|
+
const foundObs = observations.find(obs => obs.concept.uuid === concept.uuid);
|
|
161
|
+
if (!_lodash.default.isNil(foundObs)) fegObs.push(foundObs);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
if (!_lodash.default.isEmpty(fegObs)) {
|
|
165
|
+
sections.push({
|
|
166
|
+
groupName: feg.name,
|
|
167
|
+
groupUUID: feg.uuid,
|
|
168
|
+
observations: fegObs
|
|
169
|
+
});
|
|
170
|
+
allObservations.push(...fegObs);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
const decisionObs = observations.filter(obs => _lodash.default.isNil(allObservations.find(oobs => oobs.concept.uuid === obs.concept.uuid)));
|
|
175
|
+
if (!_lodash.default.isEmpty(decisionObs)) sections.push({
|
|
176
|
+
groupName: 'decisions',
|
|
177
|
+
groupUUID: null,
|
|
178
|
+
observations: decisionObs
|
|
179
|
+
});
|
|
180
|
+
return sections;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
getFormElementGroupOrder(groupUUID) {
|
|
184
|
+
const orderedFEG = _lodash.default.sortBy(this.nonVoidedFormElementGroups(), ({
|
|
185
|
+
displayOrder
|
|
186
|
+
}) => displayOrder);
|
|
187
|
+
|
|
188
|
+
return _lodash.default.findIndex(orderedFEG, ({
|
|
189
|
+
uuid
|
|
190
|
+
}) => uuid === groupUUID) + 1;
|
|
191
|
+
}
|
|
192
|
+
|
|
146
193
|
}
|
|
147
194
|
|
|
148
195
|
_defineProperty(Form, "schema", {
|
|
@@ -155,6 +155,10 @@ class FormElement {
|
|
|
155
155
|
return _lodash.default.find(this.concept.getAnswers(), answer => answer.concept.name === conceptName);
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
getAnswerWithConceptUuid(conceptUuid) {
|
|
159
|
+
return _lodash.default.find(this.concept.getAnswers(), answer => answer.concept.uuid === conceptUuid);
|
|
160
|
+
}
|
|
161
|
+
|
|
158
162
|
getRawAnswers() {
|
|
159
163
|
return this.concept.getAnswers();
|
|
160
164
|
}
|
|
@@ -291,7 +295,7 @@ _defineProperty(FormElement, "keys", {
|
|
|
291
295
|
allowedTypes: "allowedTypes",
|
|
292
296
|
allowedMaxSize: "allowedMaxSize",
|
|
293
297
|
displayAllGroupMembers: "displayAllGroupMembers",
|
|
294
|
-
|
|
298
|
+
searchOptions: "searchOptions"
|
|
295
299
|
});
|
|
296
300
|
|
|
297
301
|
_defineProperty(FormElement, "values", {
|