openchs-models 1.17.4 → 1.18.2
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/EntityMetaData.js +7 -1
- package/dist/ObservationsHolder.js +38 -7
- package/dist/PhoneNumber.js +3 -1
- package/dist/ResetSync.js +75 -0
- package/dist/Schema.js +4 -2
- package/dist/index.js +8 -0
- package/dist/observation/QuestionGroup.js +2 -1
- package/package.json +1 -1
package/dist/EntityMetaData.js
CHANGED
|
@@ -125,6 +125,8 @@ var _Extension = _interopRequireDefault(require("./Extension"));
|
|
|
125
125
|
|
|
126
126
|
var _SubjectMigration = _interopRequireDefault(require("./SubjectMigration"));
|
|
127
127
|
|
|
128
|
+
var _ResetSync = _interopRequireDefault(require("./ResetSync"));
|
|
129
|
+
|
|
128
130
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
129
131
|
|
|
130
132
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -280,6 +282,10 @@ const subjectMigration = txData(_SubjectMigration.default, {
|
|
|
280
282
|
privilegeEntity: _Privilege.default.privilegeEntityType.subject,
|
|
281
283
|
privilegeName: _Privilege.default.privilegeName.viewSubject
|
|
282
284
|
});
|
|
285
|
+
const resetSync = txData(_ResetSync.default, {
|
|
286
|
+
res: "resetSyncs",
|
|
287
|
+
syncWeight: 0
|
|
288
|
+
});
|
|
283
289
|
const addressLevel = refDataNameTranslated(_AddressLevel.default, {
|
|
284
290
|
res: "locations",
|
|
285
291
|
syncWeight: 4
|
|
@@ -443,7 +449,7 @@ const commentThread = txData(_CommentThread.default, {
|
|
|
443
449
|
class EntityMetaData {
|
|
444
450
|
//order is important. last entity in each (tx and ref) with be executed first. parent should be synced before the child.
|
|
445
451
|
static model() {
|
|
446
|
-
return [groupDashboard, approvalStatus, dashboardSectionCardMapping, dashboardSection, dashboard, reportCard, standardReportCardType, locationHierarchy, video, checklistItemDetail, checklistDetail, rule, ruleDependency, individualRelationshipType, individualRelationGenderMapping, individualRelation, programConfig, formMapping, formElement, formElementGroup, form, identifierSource, organisationConfig, platformTranslation, translation, locationMapping, addressLevel, encounterType, program, programOutcome, gender, groupRole, subjectType, conceptAnswer, concept, myGroups, groupPrivileges, groups, privilege, subjectMigration, news, videoTelemetric, groupSubject, comment, commentThread, entityApprovalStatus, individualRelationship, checklistItem, checklist, encounter, identifierAssignment, programEncounter, programEnrolment, individual, extension, userInfo, syncTelemetry, ruleFailureTelemetry];
|
|
452
|
+
return [groupDashboard, approvalStatus, dashboardSectionCardMapping, dashboardSection, dashboard, reportCard, standardReportCardType, locationHierarchy, video, checklistItemDetail, checklistDetail, rule, ruleDependency, individualRelationshipType, individualRelationGenderMapping, individualRelation, programConfig, formMapping, formElement, formElementGroup, form, identifierSource, organisationConfig, platformTranslation, translation, locationMapping, addressLevel, encounterType, program, programOutcome, gender, groupRole, subjectType, conceptAnswer, concept, myGroups, groupPrivileges, groups, privilege, resetSync, subjectMigration, news, videoTelemetric, groupSubject, comment, commentThread, entityApprovalStatus, individualRelationship, checklistItem, checklist, encounter, identifierAssignment, programEncounter, programEnrolment, individual, extension, userInfo, syncTelemetry, ruleFailureTelemetry];
|
|
447
453
|
}
|
|
448
454
|
|
|
449
455
|
static entitiesLoadedFromServer() {
|
|
@@ -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
|
}
|
|
@@ -163,7 +174,7 @@ class ObservationsHolder {
|
|
|
163
174
|
_lodash.default.forEach(childFormElements, cfe => {
|
|
164
175
|
_lodash.default.range(size).forEach(questionGroupIndex => {
|
|
165
176
|
const newFormElement = cfe.clone();
|
|
166
|
-
newFormElement.questionGroupIndex =
|
|
177
|
+
newFormElement.questionGroupIndex = questionGroupIndex;
|
|
167
178
|
formElementsIncludingRepeatableElements.push(newFormElement);
|
|
168
179
|
});
|
|
169
180
|
});
|
|
@@ -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() {
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _BaseEntity = _interopRequireDefault(require("./BaseEntity"));
|
|
9
|
+
|
|
10
|
+
var _ResourceUtil = _interopRequireDefault(require("./utility/ResourceUtil"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
|
|
16
|
+
class ResetSync extends _BaseEntity.default {
|
|
17
|
+
constructor(...args) {
|
|
18
|
+
super(...args);
|
|
19
|
+
|
|
20
|
+
_defineProperty(this, "uuid", void 0);
|
|
21
|
+
|
|
22
|
+
_defineProperty(this, "subjectTypeUUID", void 0);
|
|
23
|
+
|
|
24
|
+
_defineProperty(this, "hasMigrated", void 0);
|
|
25
|
+
|
|
26
|
+
_defineProperty(this, "voided", void 0);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static fromResource(resource) {
|
|
30
|
+
const resetSync = new ResetSync();
|
|
31
|
+
resetSync.uuid = resource.uuid;
|
|
32
|
+
resetSync.voided = resource.voided;
|
|
33
|
+
resetSync.subjectTypeUUID = _ResourceUtil.default.getUUIDFor(resource, 'subjectTypeUUID');
|
|
34
|
+
return resetSync;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
updatedHasMigrated() {
|
|
38
|
+
const resetSync = this.clone();
|
|
39
|
+
resetSync.hasMigrated = true;
|
|
40
|
+
return resetSync;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
clone() {
|
|
44
|
+
const resetSync = new ResetSync();
|
|
45
|
+
resetSync.uuid = this.uuid;
|
|
46
|
+
resetSync.subjectTypeUUID = this.subjectTypeUUID;
|
|
47
|
+
resetSync.hasMigrated = this.hasMigrated;
|
|
48
|
+
resetSync.voided = this.voided;
|
|
49
|
+
return resetSync;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
_defineProperty(ResetSync, "schema", {
|
|
55
|
+
name: 'ResetSync',
|
|
56
|
+
primaryKey: 'uuid',
|
|
57
|
+
properties: {
|
|
58
|
+
uuid: 'string',
|
|
59
|
+
subjectTypeUUID: {
|
|
60
|
+
type: 'string',
|
|
61
|
+
optional: true
|
|
62
|
+
},
|
|
63
|
+
hasMigrated: {
|
|
64
|
+
type: 'bool',
|
|
65
|
+
default: false
|
|
66
|
+
},
|
|
67
|
+
voided: {
|
|
68
|
+
type: "bool",
|
|
69
|
+
default: false
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
var _default = ResetSync;
|
|
75
|
+
exports.default = _default;
|
package/dist/Schema.js
CHANGED
|
@@ -159,6 +159,8 @@ var _Extension = _interopRequireDefault(require("./Extension"));
|
|
|
159
159
|
|
|
160
160
|
var _SubjectMigration = _interopRequireDefault(require("./SubjectMigration"));
|
|
161
161
|
|
|
162
|
+
var _ResetSync = _interopRequireDefault(require("./ResetSync"));
|
|
163
|
+
|
|
162
164
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
163
165
|
|
|
164
166
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -167,8 +169,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
167
169
|
|
|
168
170
|
var _default = {
|
|
169
171
|
//order is important, should be arranged according to the dependency
|
|
170
|
-
schema: [_LocaleMapping.default, _Settings.default, _Concept.ConceptAnswer, _Concept.default, _EncounterType.default, _Gender.default, _UserDefinedIndividualProperty.default, _AddressLevel.LocationMapping, _AddressLevel.default, _KeyValue.default, _Form.default, _FormMapping.default, _FormElementGroup.default, _FormElement.default, _SubjectType.default, _Individual.default, _ProgramOutcome.default, _Program.default, _ProgramEnrolment.default, _Observation.default, _ProgramEncounter.default, _Encounter.default, _EntitySyncStatus.default, _EntityQueue.default, _ConfigFile.default, _Checklist.default, _ChecklistItem.default, _Format.default, _UserInfo.default, _StringKeyNumericValue.default, _VisitScheduleInterval.default, _VisitScheduleConfig.default, _ProgramConfig.default, _Family.default, _IndividualRelation.default, _IndividualRelationGenderMapping.default, _IndividualRelationshipType.default, _IndividualRelationship.default, _RuleDependency.default, _Rule.default, _ChecklistItemStatus.default, _ChecklistDetail.default, _ChecklistItemDetail.default, _VideoTelemetric.default, _Video.default, _MediaQueue.default, _Point.default, _SyncTelemetry.default, _IdentifierSource.default, _IdentifierAssignment.default, _RuleFailureTelemetry.default, _BeneficiaryModePin.default, _OrganisationConfig.default, _PlatformTranslation.default, _Translation.default, _Groups.default, _MyGroups.default, _GroupPrivileges.default, _Privilege.default, _GroupRole.default, _GroupSubject.default, _DashboardCache.default, _LocationHierarchy.default, _ReportCard.default, _Dashboard.default, _DashboardSectionCardMapping.default, _DraftSubject.default, _StandardReportCardType.default, _ApprovalStatus.default, _EntityApprovalStatus.default, _GroupDashboard.default, _DashboardSection.default, _News.default, _Comment.default, _CommentThread.default, _Extension.default, _SubjectMigration.default],
|
|
171
|
-
schemaVersion:
|
|
172
|
+
schema: [_LocaleMapping.default, _Settings.default, _Concept.ConceptAnswer, _Concept.default, _EncounterType.default, _Gender.default, _UserDefinedIndividualProperty.default, _AddressLevel.LocationMapping, _AddressLevel.default, _KeyValue.default, _Form.default, _FormMapping.default, _FormElementGroup.default, _FormElement.default, _SubjectType.default, _Individual.default, _ProgramOutcome.default, _Program.default, _ProgramEnrolment.default, _Observation.default, _ProgramEncounter.default, _Encounter.default, _EntitySyncStatus.default, _EntityQueue.default, _ConfigFile.default, _Checklist.default, _ChecklistItem.default, _Format.default, _UserInfo.default, _StringKeyNumericValue.default, _VisitScheduleInterval.default, _VisitScheduleConfig.default, _ProgramConfig.default, _Family.default, _IndividualRelation.default, _IndividualRelationGenderMapping.default, _IndividualRelationshipType.default, _IndividualRelationship.default, _RuleDependency.default, _Rule.default, _ChecklistItemStatus.default, _ChecklistDetail.default, _ChecklistItemDetail.default, _VideoTelemetric.default, _Video.default, _MediaQueue.default, _Point.default, _SyncTelemetry.default, _IdentifierSource.default, _IdentifierAssignment.default, _RuleFailureTelemetry.default, _BeneficiaryModePin.default, _OrganisationConfig.default, _PlatformTranslation.default, _Translation.default, _Groups.default, _MyGroups.default, _GroupPrivileges.default, _Privilege.default, _GroupRole.default, _GroupSubject.default, _DashboardCache.default, _LocationHierarchy.default, _ReportCard.default, _Dashboard.default, _DashboardSectionCardMapping.default, _DraftSubject.default, _StandardReportCardType.default, _ApprovalStatus.default, _EntityApprovalStatus.default, _GroupDashboard.default, _DashboardSection.default, _News.default, _Comment.default, _CommentThread.default, _Extension.default, _SubjectMigration.default, _ResetSync.default],
|
|
173
|
+
schemaVersion: 154,
|
|
172
174
|
migration: function (oldDB, newDB) {
|
|
173
175
|
if (oldDB.schemaVersion < 10) {
|
|
174
176
|
var oldObjects = oldDB.objects("DecisionConfig");
|
package/dist/index.js
CHANGED
|
@@ -657,6 +657,12 @@ Object.defineProperty(exports, "RepeatableQuestionGroup", {
|
|
|
657
657
|
return _RepeatableQuestionGroup.default;
|
|
658
658
|
}
|
|
659
659
|
});
|
|
660
|
+
Object.defineProperty(exports, "ResetSync", {
|
|
661
|
+
enumerable: true,
|
|
662
|
+
get: function () {
|
|
663
|
+
return _ResetSync.default;
|
|
664
|
+
}
|
|
665
|
+
});
|
|
660
666
|
|
|
661
667
|
var _AbstractEncounter = _interopRequireDefault(require("./AbstractEncounter"));
|
|
662
668
|
|
|
@@ -874,6 +880,8 @@ var _QuestionGroup = _interopRequireDefault(require("./observation/QuestionGroup
|
|
|
874
880
|
|
|
875
881
|
var _RepeatableQuestionGroup = _interopRequireDefault(require("./observation/RepeatableQuestionGroup"));
|
|
876
882
|
|
|
883
|
+
var _ResetSync = _interopRequireDefault(require("./ResetSync"));
|
|
884
|
+
|
|
877
885
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
878
886
|
|
|
879
887
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -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
|
|