openchs-models 1.11.2 → 1.11.3
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.
|
@@ -113,12 +113,19 @@ class AbstractEncounter extends _BaseEntity.default {
|
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
findObservation(conceptNameOrUuid) {
|
|
117
|
-
|
|
116
|
+
findObservation(conceptNameOrUuid, parentConceptNameOrUuid) {
|
|
117
|
+
const observations = _lodash.default.isNil(parentConceptNameOrUuid) ? this.observations : this.findGroupedObservation(parentConceptNameOrUuid);
|
|
118
|
+
return _lodash.default.find(observations, observation => {
|
|
118
119
|
return observation.concept.name === conceptNameOrUuid || observation.concept.uuid === conceptNameOrUuid;
|
|
119
120
|
});
|
|
120
121
|
}
|
|
121
122
|
|
|
123
|
+
findGroupedObservation(parentConceptNameOrUuid) {
|
|
124
|
+
const groupedObservations = _lodash.default.find(this.observations, observation => observation.concept.name === parentConceptNameOrUuid || observation.concept.uuid === parentConceptNameOrUuid);
|
|
125
|
+
|
|
126
|
+
return _lodash.default.isEmpty(groupedObservations) ? [] : groupedObservations.getValue();
|
|
127
|
+
}
|
|
128
|
+
|
|
122
129
|
findCancelEncounterObservation(conceptNameOrUuid) {
|
|
123
130
|
return _lodash.default.find(this.cancelObservations, observation => {
|
|
124
131
|
return observation.concept.name === conceptNameOrUuid || observation.concept.uuid === conceptNameOrUuid;
|
|
@@ -130,13 +137,13 @@ class AbstractEncounter extends _BaseEntity.default {
|
|
|
130
137
|
return _lodash.default.isEmpty(observationForConcept) ? observationForConcept : observationForConcept.getReadableValue();
|
|
131
138
|
}
|
|
132
139
|
|
|
133
|
-
getObservationValue(conceptNameOrUuid) {
|
|
134
|
-
const observationForConcept = this.findObservation(conceptNameOrUuid);
|
|
140
|
+
getObservationValue(conceptNameOrUuid, parentConceptNameOrUuid) {
|
|
141
|
+
const observationForConcept = this.findObservation(conceptNameOrUuid, parentConceptNameOrUuid);
|
|
135
142
|
return _lodash.default.isEmpty(observationForConcept) ? observationForConcept : observationForConcept.getValue();
|
|
136
143
|
}
|
|
137
144
|
|
|
138
|
-
getObservationReadableValue(conceptNameOrUuid) {
|
|
139
|
-
const observationForConcept = this.findObservation(conceptNameOrUuid);
|
|
145
|
+
getObservationReadableValue(conceptNameOrUuid, parentConceptNameOrUuid) {
|
|
146
|
+
const observationForConcept = this.findObservation(conceptNameOrUuid, parentConceptNameOrUuid);
|
|
140
147
|
return _lodash.default.isEmpty(observationForConcept) ? observationForConcept : observationForConcept.getReadableValue();
|
|
141
148
|
}
|
|
142
149
|
|
package/dist/Individual.js
CHANGED
|
@@ -288,7 +288,7 @@ class Individual extends _BaseEntity.default {
|
|
|
288
288
|
|
|
289
289
|
get nameStringWithUniqueAttribute() {
|
|
290
290
|
if (this.subjectType.name === 'Farmer') {
|
|
291
|
-
const mobileNumber = this.getObservationReadableValue('Mobile Number');
|
|
291
|
+
const mobileNumber = this.getObservationReadableValue('Mobile Number', null);
|
|
292
292
|
const numberToDisplay = mobileNumber ? `(${mobileNumber})` : '';
|
|
293
293
|
return `${this.nameString} ${numberToDisplay}`;
|
|
294
294
|
} else {
|
|
@@ -544,14 +544,21 @@ class Individual extends _BaseEntity.default {
|
|
|
544
544
|
}
|
|
545
545
|
}
|
|
546
546
|
|
|
547
|
-
findObservation(conceptNameOrUuid) {
|
|
548
|
-
|
|
547
|
+
findObservation(conceptNameOrUuid, parentConceptNameOrUuid) {
|
|
548
|
+
const observations = _lodash.default.isNil(parentConceptNameOrUuid) ? this.observations : this.findGroupedObservation(parentConceptNameOrUuid);
|
|
549
|
+
return _lodash.default.find(observations, observation => {
|
|
549
550
|
return observation.concept.name === conceptNameOrUuid || observation.concept.uuid === conceptNameOrUuid;
|
|
550
551
|
});
|
|
551
552
|
}
|
|
552
553
|
|
|
553
|
-
|
|
554
|
-
const
|
|
554
|
+
findGroupedObservation(parentConceptNameOrUuid) {
|
|
555
|
+
const groupedObservations = _lodash.default.find(this.observations, observation => observation.concept.name === parentConceptNameOrUuid || observation.concept.uuid === parentConceptNameOrUuid);
|
|
556
|
+
|
|
557
|
+
return _lodash.default.isEmpty(groupedObservations) ? [] : groupedObservations.getValue();
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
getObservationValue(conceptNameOrUuid, parentConceptNameOrUuid) {
|
|
561
|
+
const observationForConcept = this.findObservation(conceptNameOrUuid, parentConceptNameOrUuid);
|
|
555
562
|
return _lodash.default.isEmpty(observationForConcept) ? observationForConcept : observationForConcept.getValue();
|
|
556
563
|
}
|
|
557
564
|
|
|
@@ -751,8 +758,8 @@ class Individual extends _BaseEntity.default {
|
|
|
751
758
|
}
|
|
752
759
|
}
|
|
753
760
|
|
|
754
|
-
getObservationReadableValue(conceptNameOrUuid) {
|
|
755
|
-
const observationForConcept = this.findObservation(conceptNameOrUuid);
|
|
761
|
+
getObservationReadableValue(conceptNameOrUuid, parentConceptNameOrUuid) {
|
|
762
|
+
const observationForConcept = this.findObservation(conceptNameOrUuid, parentConceptNameOrUuid);
|
|
756
763
|
return _lodash.default.isEmpty(observationForConcept) ? observationForConcept : observationForConcept.getReadableValue();
|
|
757
764
|
}
|
|
758
765
|
|
|
@@ -151,7 +151,20 @@ class ObservationsHolder {
|
|
|
151
151
|
this.removeNonApplicableAnswers(fe, fe.isSingleSelect());
|
|
152
152
|
}
|
|
153
153
|
});
|
|
154
|
-
return _lodash.default.flatten(inApplicableFormElements.map(fe =>
|
|
154
|
+
return _lodash.default.flatten(inApplicableFormElements.map(fe => this._removeObs(fe, allFormElements)));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
_removeObs(formElement, allFormElements) {
|
|
158
|
+
if (formElement.isQuestionGroup()) {
|
|
159
|
+
const parentFormElement = _lodash.default.find(allFormElements, ({
|
|
160
|
+
uuid
|
|
161
|
+
}) => formElement.groupUuid === uuid);
|
|
162
|
+
|
|
163
|
+
const parentObservation = this.getObservation(parentFormElement.concept);
|
|
164
|
+
return _lodash.default.isNil(parentObservation) ? [] : parentObservation.getValueWrapper().removeExistingObs(formElement.concept);
|
|
165
|
+
} else {
|
|
166
|
+
return _lodash.default.remove(this.observations, obs => obs.concept.uuid === formElement.concept.uuid);
|
|
167
|
+
}
|
|
155
168
|
}
|
|
156
169
|
|
|
157
170
|
removeNonApplicableAnswers(fe, isSingleSelect) {
|
|
@@ -180,7 +193,16 @@ class ObservationsHolder {
|
|
|
180
193
|
|
|
181
194
|
if (!_lodash.default.isNil(value)) {
|
|
182
195
|
const concept = fe.concept;
|
|
183
|
-
|
|
196
|
+
|
|
197
|
+
if (fe.isQuestionGroup()) {
|
|
198
|
+
const parentFormElement = _lodash.default.find(applicableFormElements, ({
|
|
199
|
+
uuid
|
|
200
|
+
}) => fe.groupUuid === uuid);
|
|
201
|
+
|
|
202
|
+
this.updateGroupQuestion(_lodash.default.get(parentFormElement, 'concept'), concept, value, fe);
|
|
203
|
+
} else {
|
|
204
|
+
concept.isCodedConcept() ? this.addOrUpdateCodedObs(concept, value, fe.isSingleSelect()) : this.addOrUpdatePrimitiveObs(concept, value);
|
|
205
|
+
}
|
|
184
206
|
}
|
|
185
207
|
});
|
|
186
208
|
}
|
package/dist/ProgramEnrolment.js
CHANGED
|
@@ -245,11 +245,11 @@ class ProgramEnrolment extends _BaseEntity.default {
|
|
|
245
245
|
};
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
findObservationInEntireEnrolment(conceptNameOrUuid, currentEncounter, latest = false) {
|
|
248
|
+
findObservationInEntireEnrolment(conceptNameOrUuid, currentEncounter, latest = false, parentConceptNameOrUuid) {
|
|
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(conceptNameOrUuid, encounters, true);
|
|
252
|
+
return this._findObservationFromEntireEnrolment(conceptNameOrUuid, encounters, true, parentConceptNameOrUuid);
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
observationExistsInEntireEnrolment(conceptNameOrUuid, currentEncounter) {
|
|
@@ -268,10 +268,10 @@ class ProgramEnrolment extends _BaseEntity.default {
|
|
|
268
268
|
return this._findObservationFromEntireEnrolment(conceptNameOrUuid, encounters, checkInEnrolment);
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
findLatestObservationFromPreviousEncounters(conceptNameOrUuid, currentEncounter) {
|
|
271
|
+
findLatestObservationFromPreviousEncounters(conceptNameOrUuid, currentEncounter, parentConceptNameOrUuid) {
|
|
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(conceptNameOrUuid, encounters, false);
|
|
274
|
+
return this._findObservationFromEntireEnrolment(conceptNameOrUuid, encounters, false, parentConceptNameOrUuid);
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
findLatestPreviousEncounterWithValueForConcept(currentEncounter, conceptNameOrUuid, valueConceptName) {
|
|
@@ -284,24 +284,24 @@ class ProgramEnrolment extends _BaseEntity.default {
|
|
|
284
284
|
return null;
|
|
285
285
|
}
|
|
286
286
|
|
|
287
|
-
_encounterHasObsForConcept(encounter, conceptNameOrUuid) {
|
|
288
|
-
const observation = encounter.getObservationValue(conceptNameOrUuid);
|
|
287
|
+
_encounterHasObsForConcept(encounter, conceptNameOrUuid, parentConceptNameOrUuid) {
|
|
288
|
+
const observation = encounter.getObservationValue(conceptNameOrUuid, parentConceptNameOrUuid);
|
|
289
289
|
return !_lodash.default.isNil(observation);
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
findLatestPreviousEncounterWithObservationForConcept(currentEncounter, conceptNameOrUuid) {
|
|
292
|
+
findLatestPreviousEncounterWithObservationForConcept(currentEncounter, conceptNameOrUuid, parentConceptNameOrUuid) {
|
|
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], conceptNameOrUuid)) return encounters[i];
|
|
296
|
+
if (this._encounterHasObsForConcept(encounters[i], conceptNameOrUuid, parentConceptNameOrUuid)) return encounters[i];
|
|
297
297
|
}
|
|
298
298
|
|
|
299
299
|
return null;
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
-
findObservationInLastEncounter(conceptNameOrUuid, currentEncounter) {
|
|
302
|
+
findObservationInLastEncounter(conceptNameOrUuid, currentEncounter, parentConceptNameOrUuid) {
|
|
303
303
|
const lastEncounter = this.findLastEncounterOfType(currentEncounter, _lodash.default.get(currentEncounter, 'encounterType'));
|
|
304
|
-
return lastEncounter ? lastEncounter.findObservation(conceptNameOrUuid) : null;
|
|
304
|
+
return lastEncounter ? lastEncounter.findObservation(conceptNameOrUuid, parentConceptNameOrUuid) : null;
|
|
305
305
|
}
|
|
306
306
|
|
|
307
307
|
findLastEncounterOfType(currentEncounter, encounterTypes = []) {
|
|
@@ -323,17 +323,17 @@ class ProgramEnrolment extends _BaseEntity.default {
|
|
|
323
323
|
return observation.getValueWrapper().hasValue(answerUuid);
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
-
_findObservationFromEntireEnrolment(conceptNameOrUuid, encounters, checkInEnrolment = true) {
|
|
327
|
-
return this._findObservationWithDateFromEntireEnrolment(conceptNameOrUuid, encounters, checkInEnrolment).observation;
|
|
326
|
+
_findObservationFromEntireEnrolment(conceptNameOrUuid, encounters, checkInEnrolment = true, parentConceptNameOrUuid) {
|
|
327
|
+
return this._findObservationWithDateFromEntireEnrolment(conceptNameOrUuid, encounters, checkInEnrolment, parentConceptNameOrUuid).observation;
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
_findObservationWithDateFromEntireEnrolment(conceptNameOrUuid, encounters, checkInEnrolment = true) {
|
|
330
|
+
_findObservationWithDateFromEntireEnrolment(conceptNameOrUuid, encounters, checkInEnrolment = true, parentConceptNameOrUuid) {
|
|
331
331
|
let observation;
|
|
332
332
|
let encounter;
|
|
333
333
|
|
|
334
334
|
for (let i = 0; i < encounters.length; i++) {
|
|
335
335
|
encounter = encounters[i];
|
|
336
|
-
observation = encounters[i].findObservation(conceptNameOrUuid);
|
|
336
|
+
observation = encounters[i].findObservation(conceptNameOrUuid, parentConceptNameOrUuid);
|
|
337
337
|
if (!_lodash.default.isNil(observation)) return {
|
|
338
338
|
observation: observation,
|
|
339
339
|
date: encounter.encounterDateTime
|
|
@@ -341,7 +341,7 @@ class ProgramEnrolment extends _BaseEntity.default {
|
|
|
341
341
|
}
|
|
342
342
|
|
|
343
343
|
if (checkInEnrolment) return {
|
|
344
|
-
observation: this.findObservation(conceptNameOrUuid),
|
|
344
|
+
observation: this.findObservation(conceptNameOrUuid, parentConceptNameOrUuid),
|
|
345
345
|
date: this.enrolmentDateTime
|
|
346
346
|
};
|
|
347
347
|
return {};
|
|
@@ -352,12 +352,19 @@ class ProgramEnrolment extends _BaseEntity.default {
|
|
|
352
352
|
return obs ? obs.getReadableValue() : undefined;
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
-
findObservation(conceptNameOrUuid) {
|
|
356
|
-
|
|
355
|
+
findObservation(conceptNameOrUuid, parentConceptNameOrUuid) {
|
|
356
|
+
const observations = _lodash.default.isNil(parentConceptNameOrUuid) ? this.observations : this.findGroupedObservation(parentConceptNameOrUuid);
|
|
357
|
+
return _lodash.default.find(observations, observation => {
|
|
357
358
|
return observation.concept.name === conceptNameOrUuid || observation.concept.uuid === conceptNameOrUuid;
|
|
358
359
|
});
|
|
359
360
|
}
|
|
360
361
|
|
|
362
|
+
findGroupedObservation(parentConceptNameOrUuid) {
|
|
363
|
+
const groupedObservations = _lodash.default.find(this.observations, observation => observation.concept.name === parentConceptNameOrUuid || observation.concept.uuid === parentConceptNameOrUuid);
|
|
364
|
+
|
|
365
|
+
return _lodash.default.isEmpty(groupedObservations) ? [] : groupedObservations.getValue();
|
|
366
|
+
}
|
|
367
|
+
|
|
361
368
|
findExitObservation(conceptNameOrUuid) {
|
|
362
369
|
return _lodash.default.find(this.programExitObservations, observation => observation.concept.name === conceptNameOrUuid || observation.concept.uuid === conceptNameOrUuid);
|
|
363
370
|
}
|
|
@@ -428,13 +435,13 @@ class ProgramEnrolment extends _BaseEntity.default {
|
|
|
428
435
|
} //get has been taken by the prototype
|
|
429
436
|
|
|
430
437
|
|
|
431
|
-
getObservationValue(conceptNameOrUuid) {
|
|
432
|
-
const observationValue = this.findObservation(conceptNameOrUuid);
|
|
438
|
+
getObservationValue(conceptNameOrUuid, parentConceptNameOrUuid) {
|
|
439
|
+
const observationValue = this.findObservation(conceptNameOrUuid, parentConceptNameOrUuid);
|
|
433
440
|
return _lodash.default.isEmpty(observationValue) ? undefined : observationValue.getValue();
|
|
434
441
|
}
|
|
435
442
|
|
|
436
|
-
getObservationReadableValue(conceptNameOrUuid) {
|
|
437
|
-
const observationValue = this.findObservation(conceptNameOrUuid);
|
|
443
|
+
getObservationReadableValue(conceptNameOrUuid, parentConceptNameOrUuid) {
|
|
444
|
+
const observationValue = this.findObservation(conceptNameOrUuid, parentConceptNameOrUuid);
|
|
438
445
|
return _lodash.default.isNil(observationValue) ? undefined : observationValue.getReadableValue();
|
|
439
446
|
}
|
|
440
447
|
|
|
@@ -81,7 +81,7 @@ class QuestionGroup {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
removeExistingObs(concept) {
|
|
84
|
-
_lodash.default.remove(this.groupObservations, obs => obs.concept.uuid === concept.uuid);
|
|
84
|
+
return _lodash.default.remove(this.groupObservations, obs => obs.concept.uuid === concept.uuid);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
getValueForConcept(concept) {
|