openchs-models 1.18.0 → 1.18.1
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.
|
@@ -52,6 +52,17 @@ class ObservationsHolder {
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
findQuestionGroupObservation(concept, parentFormElement, questionGroupIndex) {
|
|
56
|
+
const observations = this.findObservation(parentFormElement.concept);
|
|
57
|
+
const groupObservations = observations && observations.getValueWrapper();
|
|
58
|
+
|
|
59
|
+
if (parentFormElement.repeatable) {
|
|
60
|
+
return groupObservations && groupObservations.getGroupObservationAtIndex(questionGroupIndex).getObservation(concept);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return groupObservations && groupObservations.getObservation(concept);
|
|
64
|
+
}
|
|
65
|
+
|
|
55
66
|
getObservation(concept) {
|
|
56
67
|
return this.findObservation(concept);
|
|
57
68
|
}
|
|
@@ -344,11 +355,11 @@ class ObservationsHolder {
|
|
|
344
355
|
return observation;
|
|
345
356
|
}
|
|
346
357
|
|
|
347
|
-
updateGroupQuestion(parentFormElement, childFormElement, value) {
|
|
358
|
+
updateGroupQuestion(parentFormElement, childFormElement, value, verified = false, skipVerification = false) {
|
|
348
359
|
const parentConcept = parentFormElement.concept;
|
|
349
360
|
const parentObservation = this.getObservation(parentConcept);
|
|
350
361
|
const childObservations = _lodash.default.isEmpty(parentObservation) ? new _QuestionGroup.default() : parentObservation.getValueWrapper();
|
|
351
|
-
this.updateChildObservations(childFormElement, childObservations, value);
|
|
362
|
+
this.updateChildObservations(childFormElement, childObservations, value, verified, skipVerification);
|
|
352
363
|
|
|
353
364
|
this._removeExistingObs(parentConcept);
|
|
354
365
|
|
|
@@ -357,10 +368,10 @@ class ObservationsHolder {
|
|
|
357
368
|
}
|
|
358
369
|
}
|
|
359
370
|
|
|
360
|
-
updateChildObservations(childFormElement, childObservations, value) {
|
|
371
|
+
updateChildObservations(childFormElement, childObservations, value, verified = false, skipVerification = false) {
|
|
361
372
|
const childConcept = childFormElement.concept;
|
|
362
373
|
|
|
363
|
-
if (childConcept.isPrimitive()
|
|
374
|
+
if (childConcept.isPrimitive()) {
|
|
364
375
|
childObservations.removeExistingObs(childConcept);
|
|
365
376
|
|
|
366
377
|
if (!_lodash.default.isEmpty(_lodash.default.toString(value))) {
|
|
@@ -385,9 +396,29 @@ class ObservationsHolder {
|
|
|
385
396
|
}
|
|
386
397
|
}
|
|
387
398
|
}
|
|
399
|
+
|
|
400
|
+
if (childFormElement.getType() === _Concept.default.dataType.Duration && !(0, _lodash.isNil)(childFormElement.durationOptions)) {
|
|
401
|
+
childObservations.removeExistingObs(childConcept);
|
|
402
|
+
|
|
403
|
+
if (!_lodash.default.isEmpty(value) && !_lodash.default.isEmpty(value.durations)) {
|
|
404
|
+
const observation = _Observation.default.create(childFormElement.concept, _CompositeDuration.default.fromObs(value));
|
|
405
|
+
|
|
406
|
+
childObservations.addObservation(observation);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
if (childFormElement.getType() === _Concept.default.dataType.PhoneNumber) {
|
|
411
|
+
childObservations.removeExistingObs(childConcept);
|
|
412
|
+
|
|
413
|
+
if (!_lodash.default.isEmpty(value)) {
|
|
414
|
+
const observation = _Observation.default.create(childFormElement.concept, new _PhoneNumber.default(value, verified, skipVerification));
|
|
415
|
+
|
|
416
|
+
childObservations.addObservation(observation);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
388
419
|
}
|
|
389
420
|
|
|
390
|
-
updateRepeatableGroupQuestion(index, parentFormElement, childFormElement, value, action) {
|
|
421
|
+
updateRepeatableGroupQuestion(index, parentFormElement, childFormElement, value, action, verified = false, skipVerification = false) {
|
|
391
422
|
const parentConcept = parentFormElement.concept;
|
|
392
423
|
const observations = this.getObservation(parentConcept);
|
|
393
424
|
const repeatableObservations = _lodash.default.isEmpty(observations) ? new _RepeatableQuestionGroup.default() : observations.getValueWrapper();
|
|
@@ -401,7 +432,7 @@ class ObservationsHolder {
|
|
|
401
432
|
}
|
|
402
433
|
|
|
403
434
|
const childObservations = repeatableObservations.getGroupObservationAtIndex(index);
|
|
404
|
-
this.updateChildObservations(childFormElement, childObservations, value);
|
|
435
|
+
this.updateChildObservations(childFormElement, childObservations, value, verified, skipVerification);
|
|
405
436
|
repeatableObservations.updateGroupObservationsAtIndex(childObservations, index);
|
|
406
437
|
|
|
407
438
|
this._removeExistingObs(parentConcept);
|
package/dist/PhoneNumber.js
CHANGED
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _lodash = require("lodash");
|
|
9
|
+
|
|
8
10
|
class PhoneNumber {
|
|
9
11
|
constructor(phoneNumber, verified = false, skipVerification = false) {
|
|
10
12
|
this.phoneNumber = phoneNumber;
|
|
@@ -20,7 +22,7 @@ class PhoneNumber {
|
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
static fromObs(obs) {
|
|
23
|
-
return new PhoneNumber(obs.phoneNumber, obs.verified, obs.skipVerification);
|
|
25
|
+
return (0, _lodash.get)(obs, 'phoneNumber', null) ? new PhoneNumber(obs.phoneNumber, obs.verified, obs.skipVerification) : null;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
getValue() {
|
|
@@ -51,7 +51,8 @@ class QuestionGroup {
|
|
|
51
51
|
const observation = new _Observation.default();
|
|
52
52
|
observation.concept = QuestionGroup.constructConceptModel(concept);
|
|
53
53
|
const value = valueJSON.answer || valueJSON.value;
|
|
54
|
-
|
|
54
|
+
const valueToPass = _lodash.default.includes([_Concept.default.dataType.Duration, _Concept.default.dataType.PhoneNumber, _Concept.default.dataType.Id], concept.datatype) ? valueJSON : value;
|
|
55
|
+
observation.valueJSON = observation.concept.getValueWrapperFor(valueToPass);
|
|
55
56
|
return observation;
|
|
56
57
|
});
|
|
57
58
|
|