openchs-models 1.11.4 → 1.12.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/Schema.js CHANGED
@@ -168,7 +168,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
168
168
  var _default = {
169
169
  //order is important, should be arranged according to the dependency
170
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: 149,
171
+ schemaVersion: 150,
172
172
  migration: function (oldDB, newDB) {
173
173
  if (oldDB.schemaVersion < 10) {
174
174
  var oldObjects = oldDB.objects("DecisionConfig");
@@ -27,15 +27,30 @@ class SubjectMigration extends _BaseEntity.default {
27
27
 
28
28
  _defineProperty(this, "newAddressLevelUUID", void 0);
29
29
 
30
+ _defineProperty(this, "oldSyncConcept1Value", void 0);
31
+
32
+ _defineProperty(this, "newSyncConcept1Value", void 0);
33
+
34
+ _defineProperty(this, "oldSyncConcept2Value", void 0);
35
+
36
+ _defineProperty(this, "newSyncConcept2Value", void 0);
37
+
38
+ _defineProperty(this, "subjectTypeUUID", void 0);
39
+
30
40
  _defineProperty(this, "hasMigrated", void 0);
31
41
  }
32
42
 
33
- static create(subjectUUID, oldAddressLevelUUID, newAddressLevelUUID) {
43
+ static create(subjectUUID, oldAddressLevelUUID, newAddressLevelUUID, oldSyncConcept1Value, newSyncConcept1Value, oldSyncConcept2Value, newSyncConcept2Value, subjectTypeUUID) {
34
44
  let subjectMigration = new SubjectMigration();
35
45
  subjectMigration.uuid = _General.default.randomUUID();
36
46
  subjectMigration.subjectUUID = subjectUUID;
37
47
  subjectMigration.oldAddressLevelUUID = oldAddressLevelUUID;
38
48
  subjectMigration.newAddressLevelUUID = newAddressLevelUUID;
49
+ subjectMigration.oldSyncConcept1Value = oldSyncConcept1Value;
50
+ subjectMigration.newSyncConcept1Value = newSyncConcept1Value;
51
+ subjectMigration.oldSyncConcept2Value = oldSyncConcept2Value;
52
+ subjectMigration.newSyncConcept2Value = newSyncConcept2Value;
53
+ subjectMigration.subjectTypeUUID = subjectTypeUUID;
39
54
  return subjectMigration;
40
55
  }
41
56
 
@@ -45,6 +60,11 @@ class SubjectMigration extends _BaseEntity.default {
45
60
  subjectMigration.subjectUUID = _ResourceUtil.default.getUUIDFor(resource, 'individualUUID');
46
61
  subjectMigration.oldAddressLevelUUID = _ResourceUtil.default.getUUIDFor(resource, 'oldAddressLevelUUID');
47
62
  subjectMigration.newAddressLevelUUID = _ResourceUtil.default.getUUIDFor(resource, 'newAddressLevelUUID');
63
+ subjectMigration.subjectTypeUUID = _ResourceUtil.default.getUUIDFor(resource, 'subjectTypeUUID');
64
+ subjectMigration.oldSyncConcept1Value = resource.oldSyncConcept1Value;
65
+ subjectMigration.newSyncConcept1Value = resource.newSyncConcept1Value;
66
+ subjectMigration.oldSyncConcept2Value = resource.oldSyncConcept2Value;
67
+ subjectMigration.newSyncConcept2Value = resource.newSyncConcept2Value;
48
68
  return subjectMigration;
49
69
  }
50
70
 
@@ -54,6 +74,11 @@ class SubjectMigration extends _BaseEntity.default {
54
74
  cloned.subjectUUID = this.subjectUUID;
55
75
  cloned.oldAddressLevelUUID = this.oldAddressLevelUUID;
56
76
  cloned.newAddressLevelUUID = this.newAddressLevelUUID;
77
+ cloned.oldSyncConcept1Value = this.oldSyncConcept1Value;
78
+ cloned.newSyncConcept1Value = this.newSyncConcept1Value;
79
+ cloned.oldSyncConcept2Value = this.oldSyncConcept2Value;
80
+ cloned.newSyncConcept2Value = this.newSyncConcept2Value;
81
+ cloned.subjectTypeUUID = this.subjectTypeUUID;
57
82
  cloned.hasMigrated = this.hasMigrated;
58
83
  return cloned;
59
84
  }
@@ -66,8 +91,31 @@ _defineProperty(SubjectMigration, "schema", {
66
91
  properties: {
67
92
  uuid: 'string',
68
93
  subjectUUID: 'string',
69
- oldAddressLevelUUID: 'string',
70
- newAddressLevelUUID: 'string',
94
+ oldAddressLevelUUID: {
95
+ type: 'string',
96
+ optional: true
97
+ },
98
+ newAddressLevelUUID: {
99
+ type: 'string',
100
+ optional: true
101
+ },
102
+ oldSyncConcept1Value: {
103
+ type: 'string',
104
+ optional: true
105
+ },
106
+ newSyncConcept1Value: {
107
+ type: 'string',
108
+ optional: true
109
+ },
110
+ oldSyncConcept2Value: {
111
+ type: 'string',
112
+ optional: true
113
+ },
114
+ newSyncConcept2Value: {
115
+ type: 'string',
116
+ optional: true
117
+ },
118
+ subjectTypeUUID: 'string',
71
119
  hasMigrated: {
72
120
  type: 'bool',
73
121
  default: false
@@ -11,6 +11,8 @@ var _General = _interopRequireDefault(require("./utility/General"));
11
11
 
12
12
  var _Format = _interopRequireDefault(require("./application/Format"));
13
13
 
14
+ var _ResourceUtil = _interopRequireDefault(require("./utility/ResourceUtil"));
15
+
14
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
17
 
16
18
  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; }
@@ -59,6 +61,8 @@ class SubjectType extends _ReferenceEntity.default {
59
61
  subjectType.validFirstNameFormat = _Format.default.fromResource(operationalSubjectType["validFirstNameFormat"]);
60
62
  subjectType.validLastNameFormat = _Format.default.fromResource(operationalSubjectType["validLastNameFormat"]);
61
63
  subjectType.iconFileS3Key = operationalSubjectType.iconFileS3Key;
64
+ subjectType.syncRegistrationConcept1 = _ResourceUtil.default.getUUIDFor(operationalSubjectType, 'syncRegistrationConcept1');
65
+ subjectType.syncRegistrationConcept2 = _ResourceUtil.default.getUUIDFor(operationalSubjectType, 'syncRegistrationConcept2');
62
66
  return subjectType;
63
67
  }
64
68
 
@@ -77,6 +81,8 @@ class SubjectType extends _ReferenceEntity.default {
77
81
  cloned.validFirstNameFormat = this.validFirstNameFormat;
78
82
  cloned.validLastNameFormat = this.validLastNameFormat;
79
83
  cloned.iconFileS3Key = this.iconFileS3Key;
84
+ cloned.syncRegistrationConcept1 = this.syncRegistrationConcept1;
85
+ cloned.syncRegistrationConcept2 = this.syncRegistrationConcept2;
80
86
  return cloned;
81
87
  }
82
88
 
@@ -148,6 +154,14 @@ _defineProperty(SubjectType, "schema", {
148
154
  iconFileS3Key: {
149
155
  type: "string",
150
156
  optional: true
157
+ },
158
+ syncRegistrationConcept1: {
159
+ type: "string",
160
+ optional: true
161
+ },
162
+ syncRegistrationConcept2: {
163
+ type: "string",
164
+ optional: true
151
165
  }
152
166
  }
153
167
  });
package/dist/UserInfo.js CHANGED
@@ -19,6 +19,7 @@ class UserInfo {
19
19
  userInfo.organisationName = resource.organisationName;
20
20
  userInfo.settings = _lodash.default.isNil(resource.settings) ? UserInfo.DEFAULT_SETTINGS : JSON.stringify(resource.settings);
21
21
  userInfo.name = resource.name;
22
+ userInfo.syncSettings = _lodash.default.isNil(resource.syncSettings) ? '{}' : JSON.stringify(resource.syncSettings);
22
23
  return userInfo;
23
24
  }
24
25
 
@@ -30,6 +31,10 @@ class UserInfo {
30
31
  return JSON.parse(this.settings);
31
32
  }
32
33
 
34
+ getSyncSettings() {
35
+ return JSON.parse(this.syncSettings);
36
+ }
37
+
33
38
  getDisplayUsername() {
34
39
  return _lodash.default.isNil(this.name) ? this.username : this.name;
35
40
  }
@@ -47,6 +52,7 @@ class UserInfo {
47
52
  userInfo.uuid = this.uuid;
48
53
  userInfo.organisationName = this.organisationName;
49
54
  userInfo.settings = this.settings;
55
+ userInfo.syncSettings = this.syncSettings;
50
56
  userInfo.name = this.name;
51
57
  return userInfo;
52
58
  }
@@ -54,6 +60,7 @@ class UserInfo {
54
60
  static createEmptyInstance() {
55
61
  const userInfo = new UserInfo();
56
62
  userInfo.settings = UserInfo.DEFAULT_SETTINGS;
63
+ userInfo.syncSettings = '{}';
57
64
  return userInfo;
58
65
  }
59
66
 
@@ -74,6 +81,10 @@ _defineProperty(UserInfo, "schema", {
74
81
  name: {
75
82
  type: "string",
76
83
  optional: true
84
+ },
85
+ syncSettings: {
86
+ type: "string",
87
+ optional: true
77
88
  }
78
89
  }
79
90
  });
@@ -180,17 +180,31 @@ class Form {
180
180
  return sections;
181
181
  }
182
182
 
183
+ orderQuestionGroupObservations(observations, groupUuid) {
184
+ const childFormElements = [];
185
+ const orderedChildObs = [];
186
+
187
+ _lodash.default.forEach(this.formElementGroups, feg => _lodash.default.forEach(feg.getFormElements(), fe => {
188
+ if (fe.groupUuid === groupUuid) {
189
+ childFormElements.push(fe);
190
+ }
191
+ }));
192
+
193
+ const orderedFormElements = _lodash.default.sortBy(childFormElements, fe => fe.displayOrder);
194
+
195
+ _lodash.default.forEach(orderedFormElements, formElement => this.addSortedObservations(formElement, observations, orderedChildObs));
196
+
197
+ return orderedChildObs;
198
+ }
199
+
183
200
  addSortedObservations(formElement, observations, orderedObservations) {
184
201
  const concept = formElement.concept;
185
202
  const foundObs = observations.find(obs => obs.concept.uuid === concept.uuid);
186
203
 
187
204
  if (!_lodash.default.isNil(foundObs) && concept.isQuestionGroup()) {
188
205
  const clonedObs = foundObs.cloneForEdit();
189
- const sortedChildObs = this.orderObservations(clonedObs.getValueWrapper().getValue());
190
-
191
- const uniqueObs = _lodash.default.uniqBy(sortedChildObs, obs => obs.concept.uuid);
192
-
193
- clonedObs.valueJSON = JSON.stringify(new _QuestionGroup.default(uniqueObs));
206
+ const sortedChildObs = this.orderQuestionGroupObservations(clonedObs.getValueWrapper().getValue(), formElement.uuid);
207
+ clonedObs.valueJSON = JSON.stringify(new _QuestionGroup.default(sortedChildObs));
194
208
  if (!_lodash.default.isEmpty(sortedChildObs)) orderedObservations.push(clonedObs);
195
209
  } else {
196
210
  if (!_lodash.default.isNil(foundObs)) orderedObservations.push(foundObs);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "openchs-models",
3
3
  "description": "OpenCHS data model to be used by front end clients",
4
- "version": "1.11.4",
4
+ "version": "1.12.2",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",