openchs-models 1.31.34 → 1.31.35

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.
Files changed (51) hide show
  1. package/.circleci/config.yml +0 -1
  2. package/Makefile +0 -4
  3. package/dist/AbstractEncounter.js +0 -53
  4. package/dist/AddressLevel.js +1 -1
  5. package/dist/Checklist.js +2 -41
  6. package/dist/ChecklistItem.js +5 -43
  7. package/dist/ChecklistItemDetail.js +1 -1
  8. package/dist/ChecklistItemStatus.js +2 -3
  9. package/dist/Comment.js +2 -41
  10. package/dist/Concept.js +13 -9
  11. package/dist/DashboardCache.js +37 -21
  12. package/dist/Encounter.js +10 -22
  13. package/dist/EntityApprovalStatus.js +2 -41
  14. package/dist/EntityMetaData.js +1 -5
  15. package/dist/Family.js +2 -2
  16. package/dist/GroupSubject.js +2 -41
  17. package/dist/IdentifierAssignment.js +2 -41
  18. package/dist/Individual.js +6 -44
  19. package/dist/Observation.js +3 -8
  20. package/dist/ObservationsHolder.js +76 -42
  21. package/dist/ProgramEncounter.js +8 -22
  22. package/dist/ProgramEnrolment.js +8 -46
  23. package/dist/ReportCard.js +6 -63
  24. package/dist/Schema.js +6 -121
  25. package/dist/SchemaNames.js +4 -12
  26. package/dist/SubjectMigration.js +2 -41
  27. package/dist/SubjectType.js +3 -5
  28. package/dist/UserInfo.js +0 -13
  29. package/dist/VisitScheduleConfig.js +73 -0
  30. package/dist/VisitScheduleInterval.js +71 -0
  31. package/dist/application/Form.js +1 -13
  32. package/dist/application/FormElement.js +6 -4
  33. package/dist/application/Format.js +0 -1
  34. package/dist/application/KeyValue.js +1 -2
  35. package/dist/application/StringKeyNumericValue.js +0 -1
  36. package/dist/assignment/UserSubjectAssignment.js +2 -41
  37. package/dist/draft/DraftEncounter.js +6 -6
  38. package/dist/draft/DraftSubject.js +2 -2
  39. package/dist/framework/RealmProxy.js +1 -9
  40. package/dist/framework/RealmResultsProxy.js +0 -8
  41. package/dist/geo/Point.js +1 -2
  42. package/dist/index.js +23 -9
  43. package/dist/program/SubjectProgramEligibility.js +3 -42
  44. package/dist/relationship/IndividualRelationship.js +7 -42
  45. package/dist/service/MetaDataService.js +5 -80
  46. package/dist/task/Task.js +4 -43
  47. package/dist/task/TaskUnAssignment.js +2 -41
  48. package/dist/utility/ResourceUtil.js +0 -4
  49. package/package.json +1 -1
  50. package/dist/application/DashboardCacheFilter.js +0 -80
  51. package/dist/utility/AuditUtil.js +0 -39
@@ -634,11 +634,7 @@ class EntityMetaData {
634
634
  }
635
635
 
636
636
  static entitiesLoadedFromServer() {
637
- return _lodash.default.differenceBy(_Schema.default.getInstance().getEntities(), [_Settings.default, _LocaleMapping.default].concat(EntityMetaData.embeddedEntities()), "schema.name");
638
- }
639
-
640
- static embeddedEntities() {
641
- return _lodash.default.filter(_Schema.default.getInstance().getEntities(), entity => entity.schema.embedded);
637
+ return _lodash.default.differenceBy(_Schema.default.getInstance().getEntities(), [_Settings.default, _LocaleMapping.default], "schema.name");
642
638
  }
643
639
 
644
640
  static findByName(entityName) {
package/dist/Family.js CHANGED
@@ -211,7 +211,7 @@ class Family extends _BaseEntity.default {
211
211
  }
212
212
 
213
213
  _defineProperty(Family, "schema", {
214
- name: _SchemaNames.default.Family,
214
+ name: "Family",
215
215
  primaryKey: "uuid",
216
216
  properties: {
217
217
  uuid: "string",
@@ -226,7 +226,7 @@ _defineProperty(Family, "schema", {
226
226
  },
227
227
  observations: {
228
228
  type: "list",
229
- objectType: "EmbeddedObservation"
229
+ objectType: "Observation"
230
230
  }
231
231
  }
232
232
  });
@@ -17,14 +17,8 @@ var _General = _interopRequireDefault(require("./utility/General"));
17
17
 
18
18
  var _GroupRole = _interopRequireDefault(require("./GroupRole"));
19
19
 
20
- var _AuditUtil = require("./utility/AuditUtil");
21
-
22
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
21
 
24
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
25
-
26
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
27
-
28
22
  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; }
29
23
 
30
24
  class GroupSubject extends _BaseEntity.default {
@@ -72,38 +66,6 @@ class GroupSubject extends _BaseEntity.default {
72
66
  this.that.membershipEndDate = x;
73
67
  }
74
68
 
75
- get createdBy() {
76
- return this.that.createdBy;
77
- }
78
-
79
- set createdBy(x) {
80
- this.that.createdBy = x;
81
- }
82
-
83
- get lastModifiedBy() {
84
- return this.that.lastModifiedBy;
85
- }
86
-
87
- set lastModifiedBy(x) {
88
- this.that.lastModifiedBy = x;
89
- }
90
-
91
- get createdByUUID() {
92
- return this.that.createdByUUID;
93
- }
94
-
95
- set createdByUUID(x) {
96
- this.that.createdByUUID = x;
97
- }
98
-
99
- get lastModifiedByUUID() {
100
- return this.that.lastModifiedByUUID;
101
- }
102
-
103
- set lastModifiedByUUID(x) {
104
- this.that.lastModifiedByUUID = x;
105
- }
106
-
107
69
  get toResource() {
108
70
  const resource = _lodash.default.pick(this, ["uuid"]);
109
71
 
@@ -160,7 +122,6 @@ class GroupSubject extends _BaseEntity.default {
160
122
  groupSubjectEntity.groupSubject = groupOrHouseholdSubject;
161
123
  groupSubjectEntity.memberSubject = memberSubject;
162
124
  groupSubjectEntity.groupRole = groupRole;
163
- (0, _AuditUtil.mapAuditFields)(groupSubjectEntity, resource);
164
125
  return groupSubjectEntity;
165
126
  }
166
127
 
@@ -229,7 +190,7 @@ _defineProperty(GroupSubject, "EXPLICIT_ERROR_CODE_KEY_FOR_MISSING_MEMBER", 'Gro
229
190
  _defineProperty(GroupSubject, "schema", {
230
191
  name: "GroupSubject",
231
192
  primaryKey: "uuid",
232
- properties: _objectSpread({
193
+ properties: {
233
194
  uuid: "string",
234
195
  groupSubject: "Individual",
235
196
  memberSubject: "Individual",
@@ -243,7 +204,7 @@ _defineProperty(GroupSubject, "schema", {
243
204
  type: "bool",
244
205
  default: false
245
206
  }
246
- }, _AuditUtil.AuditFields)
207
+ }
247
208
  });
248
209
 
249
210
  var _default = GroupSubject;
@@ -19,14 +19,8 @@ var _IdentifierSource = _interopRequireDefault(require("./IdentifierSource"));
19
19
 
20
20
  var _lodash = _interopRequireDefault(require("lodash"));
21
21
 
22
- var _AuditUtil = require("./utility/AuditUtil");
23
-
24
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
23
 
26
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
27
-
28
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
29
-
30
24
  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; }
31
25
 
32
26
  class IdentifierAssignment extends _BaseEntity.default {
@@ -82,45 +76,12 @@ class IdentifierAssignment extends _BaseEntity.default {
82
76
  this.that.used = x;
83
77
  }
84
78
 
85
- get createdBy() {
86
- return this.that.createdBy;
87
- }
88
-
89
- set createdBy(x) {
90
- this.that.createdBy = x;
91
- }
92
-
93
- get lastModifiedBy() {
94
- return this.that.lastModifiedBy;
95
- }
96
-
97
- set lastModifiedBy(x) {
98
- this.that.lastModifiedBy = x;
99
- }
100
-
101
- get createdByUUID() {
102
- return this.that.createdByUUID;
103
- }
104
-
105
- set createdByUUID(x) {
106
- this.that.createdByUUID = x;
107
- }
108
-
109
- get lastModifiedByUUID() {
110
- return this.that.lastModifiedByUUID;
111
- }
112
-
113
- set lastModifiedByUUID(x) {
114
- this.that.lastModifiedByUUID = x;
115
- }
116
-
117
79
  static fromResource(identifierAssignmentResource, entityService) {
118
80
  const identifierAssignment = _General.default.assignFields(identifierAssignmentResource, new IdentifierAssignment(), ["uuid", "identifier", "assignmentOrder", "voided"]);
119
81
 
120
82
  identifierAssignment.identifierSource = entityService.findByKey("uuid", _ResourceUtil.default.getUUIDFor(identifierAssignmentResource, "identifierSourceUUID"), _IdentifierSource.default.schema.name);
121
83
  identifierAssignment.individual = entityService.findByKey("uuid", _ResourceUtil.default.getUUIDFor(identifierAssignmentResource, "individualUUID"), _Individual.default.schema.name);
122
84
  identifierAssignment.programEnrolment = entityService.findByKey("uuid", _ResourceUtil.default.getUUIDFor(identifierAssignmentResource, "programEnrolmentUUID"), _ProgramEnrolment.default.schema.name);
123
- (0, _AuditUtil.mapAuditFields)(identifierAssignment, identifierAssignmentResource);
124
85
  return identifierAssignment;
125
86
  }
126
87
 
@@ -151,7 +112,7 @@ exports.default = IdentifierAssignment;
151
112
  _defineProperty(IdentifierAssignment, "schema", {
152
113
  name: "IdentifierAssignment",
153
114
  primaryKey: "uuid",
154
- properties: _objectSpread({
115
+ properties: {
155
116
  uuid: "string",
156
117
  identifierSource: "IdentifierSource",
157
118
  identifier: "string",
@@ -173,5 +134,5 @@ _defineProperty(IdentifierAssignment, "schema", {
173
134
  default: false,
174
135
  optional: false
175
136
  }
176
- }, _AuditUtil.AuditFields)
137
+ }
177
138
  });
@@ -53,14 +53,8 @@ var _MergeUtil = _interopRequireDefault(require("./utility/MergeUtil"));
53
53
 
54
54
  var _AgeUtil = _interopRequireDefault(require("./utility/AgeUtil"));
55
55
 
56
- var _AuditUtil = require("./utility/AuditUtil");
57
-
58
56
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
59
57
 
60
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
61
-
62
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
63
-
64
58
  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; }
65
59
 
66
60
  const mergeMap = new Map([[_SchemaNames.default.ProgramEnrolment, "enrolments"], [_SchemaNames.default.Encounter, "encounters"], [_SchemaNames.default.IndividualRelationship, "relationships"], [_SchemaNames.default.EntityApprovalStatus, "approvalStatuses"], [_SchemaNames.default.Comment, "comments"]]);
@@ -234,38 +228,6 @@ class Individual extends _BaseEntity.default {
234
228
  this.that.approvalStatuses = this.fromEntityList(x);
235
229
  }
236
230
 
237
- get createdBy() {
238
- return this.that.createdBy;
239
- }
240
-
241
- set createdBy(x) {
242
- this.that.createdBy = x;
243
- }
244
-
245
- get lastModifiedBy() {
246
- return this.that.lastModifiedBy;
247
- }
248
-
249
- set lastModifiedBy(x) {
250
- this.that.lastModifiedBy = x;
251
- }
252
-
253
- get createdByUUID() {
254
- return this.that.createdByUUID;
255
- }
256
-
257
- set createdByUUID(x) {
258
- this.that.createdByUUID = x;
259
- }
260
-
261
- get lastModifiedByUUID() {
262
- return this.that.lastModifiedByUUID;
263
- }
264
-
265
- set lastModifiedByUUID(x) {
266
- this.that.lastModifiedByUUID = x;
267
- }
268
-
269
231
  static createEmptyInstance() {
270
232
  const individual = new Individual();
271
233
  individual.uuid = _General.default.randomUUID();
@@ -356,7 +318,6 @@ class Individual extends _BaseEntity.default {
356
318
  individual.name = individual.nameString;
357
319
  if (!_lodash.default.isNil(individualResource.registrationLocation)) individual.registrationLocation = _Point.default.fromResource(individualResource.registrationLocation);
358
320
  individual.subjectType = subjectType;
359
- (0, _AuditUtil.mapAuditFields)(individual, individualResource);
360
321
  return individual;
361
322
  }
362
323
 
@@ -1059,7 +1020,7 @@ class Individual extends _BaseEntity.default {
1059
1020
  _defineProperty(Individual, "schema", {
1060
1021
  name: _SchemaNames.default.Individual,
1061
1022
  primaryKey: "uuid",
1062
- properties: _objectSpread({
1023
+ properties: {
1063
1024
  uuid: "string",
1064
1025
  subjectType: "SubjectType",
1065
1026
  name: "string",
@@ -1104,7 +1065,7 @@ _defineProperty(Individual, "schema", {
1104
1065
  },
1105
1066
  observations: {
1106
1067
  type: "list",
1107
- objectType: "EmbeddedObservation"
1068
+ objectType: "Observation"
1108
1069
  },
1109
1070
  relationships: {
1110
1071
  type: "list",
@@ -1115,7 +1076,7 @@ _defineProperty(Individual, "schema", {
1115
1076
  objectType: "GroupSubject"
1116
1077
  },
1117
1078
  registrationLocation: {
1118
- type: _SchemaNames.default.EmbeddedPoint,
1079
+ type: "Point",
1119
1080
  optional: true
1120
1081
  },
1121
1082
  comments: {
@@ -1133,8 +1094,9 @@ _defineProperty(Individual, "schema", {
1133
1094
  latestEntityApprovalStatus: {
1134
1095
  type: "EntityApprovalStatus",
1135
1096
  optional: true
1136
- }
1137
- }, _AuditUtil.AuditFields)
1097
+ } //Reporting purposes
1098
+
1099
+ }
1138
1100
  });
1139
1101
 
1140
1102
  _defineProperty(Individual, "validationKeys", {
@@ -49,7 +49,7 @@ class Observation extends _PersistedObject.default {
49
49
  this.that.valueJSON = x;
50
50
  }
51
51
 
52
- static create(concept, value) {
52
+ static create(concept, value, abnormal = false) {
53
53
  const observation = new Observation();
54
54
  observation.concept = concept;
55
55
  observation.valueJSON = value;
@@ -164,7 +164,7 @@ class Observation extends _PersistedObject.default {
164
164
  }
165
165
 
166
166
  cloneForEdit() {
167
- return clone(this.concept, this.getValueWrapper().cloneForEdit());
167
+ return clone(this.concept.cloneForReference(), this.getValueWrapper().cloneForEdit());
168
168
  }
169
169
 
170
170
  shallowClone() {
@@ -254,15 +254,10 @@ class Observation extends _PersistedObject.default {
254
254
  return this.concept.isMobileNo();
255
255
  }
256
256
 
257
- isForMedia(mediaName) {
258
- return _Concept.default.dataType.Media.includes(this.concept.datatype) && this.valueJSON.includes(mediaName);
259
- }
260
-
261
257
  }
262
258
 
263
259
  _defineProperty(Observation, "schema", {
264
- name: "EmbeddedObservation",
265
- embedded: true,
260
+ name: "Observation",
266
261
  properties: {
267
262
  concept: "Concept",
268
263
  valueJSON: "string"
@@ -72,10 +72,54 @@ class ObservationsHolder {
72
72
  findObservationByValue(value) {
73
73
  return _lodash.default.find(this.observations, observation => observation.getValue() === value);
74
74
  }
75
- /*
76
- Called from the wizard on changes done by the user for primitive fields (including Date)
77
- */
78
75
 
76
+ updateObs(formElement, value) {
77
+ const currentValue = this.getObservation(formElement.concept);
78
+
79
+ _ArrayHelper.default.remove(this.observations, obs => obs.concept.uuid === formElement.concept.uuid);
80
+
81
+ if (formElement.concept.isPrimitive() && (0, _lodash.isNil)(formElement.durationOptions)) {
82
+ this.addOrUpdatePrimitiveObs(formElement.concept, value);
83
+ }
84
+
85
+ if (formElement.getType() === _Concept.default.dataType.Id) {
86
+ if (!_lodash.default.isEmpty(value)) {
87
+ this.observations.push(_Observation.default.create(formElement.concept, _Identifier.default.fromObs(_objectSpread({}, currentValue, {
88
+ value
89
+ }))));
90
+ }
91
+ }
92
+
93
+ if (formElement.isSingleSelect()) {
94
+ if (!_lodash.default.isEmpty(value)) {
95
+ const observation = _Observation.default.create(formElement.concept, new _SingleCodedValue.default(value));
96
+
97
+ this.observations.push(observation);
98
+ }
99
+ }
100
+
101
+ if (formElement.isMultiSelect()) {
102
+ if (!_lodash.default.isEmpty(value)) {
103
+ const observation = _Observation.default.create(formElement.concept, new _MultipleCodedValues.default(value));
104
+
105
+ this.observations.push(observation);
106
+ }
107
+ }
108
+
109
+ if (formElement.getType() === _Concept.default.dataType.Duration && !(0, _lodash.isNil)(formElement.durationOptions)) {
110
+ if (!_lodash.default.isEmpty(value) && !_lodash.default.isEmpty(value.durations)) {
111
+ const observation = _Observation.default.create(formElement.concept, _CompositeDuration.default.fromObs(value));
112
+
113
+ this.observations.push(observation);
114
+ }
115
+ }
116
+
117
+ if (formElement.getType() === _Concept.default.dataType.PhoneNumber) {
118
+ const observation = _Observation.default.create(formElement.concept, _PhoneNumber.default.fromObs(value));
119
+
120
+ this.observations.push(observation);
121
+ }
122
+ }
79
123
 
80
124
  addOrUpdatePrimitiveObs(concept, value, answerSource = _Observation.default.AnswerSource.Manual) {
81
125
  let currentObservation = this.findObservation(concept);
@@ -92,8 +136,7 @@ class ObservationsHolder {
92
136
  this.observations.push(_Observation.default.create(concept, new _PrimitiveValue.default(value, concept.datatype, answerSource)));
93
137
  }
94
138
  }
95
- } //private
96
-
139
+ }
97
140
 
98
141
  _removeExistingObs(concept) {
99
142
  const observation = this.getObservation(concept);
@@ -101,8 +144,7 @@ class ObservationsHolder {
101
144
  if (!_lodash.default.isEmpty(observation)) {
102
145
  _ArrayHelper.default.remove(this.observations, obs => obs.concept.uuid === observation.concept.uuid);
103
146
  }
104
- } //private
105
-
147
+ }
106
148
 
107
149
  addOrUpdateCodedObs(concept, value, isSingleSelect, answerSource = _Observation.default.AnswerSource.Auto) {
108
150
  this._removeExistingObs(concept);
@@ -117,10 +159,6 @@ class ObservationsHolder {
117
159
  this.observations.push(observation);
118
160
  }
119
161
  }
120
- /*
121
- called during edit of form element by the user and when the page transition takes place
122
- */
123
-
124
162
 
125
163
  removeNonApplicableObs(allFormElements, applicableFormElements) {
126
164
  const formElementsIncludingRepeatableElements = [];
@@ -155,10 +193,9 @@ class ObservationsHolder {
155
193
  }
156
194
  });
157
195
  return _lodash.default.flatten(inApplicableFormElements.map(fe => this._removeObs(fe))).filter(obs => !_lodash.default.isEmpty(obs));
158
- } //private
159
-
196
+ }
160
197
 
161
- removeNonApplicableAnswersFromQuestionGroup(fe, isSingleSelect) {
198
+ removeNonApplicableAnswersFromQuestionGroup(fe, isSingleSelect, allFormElements) {
162
199
  const questionGroup = this.getQuestionGroups(fe);
163
200
  const questionGroupObservation = questionGroup && questionGroup.getGroupObservationAtIndex(fe.questionGroupIndex);
164
201
  const observation = questionGroupObservation && questionGroupObservation.getObservation(fe.concept);
@@ -175,8 +212,7 @@ class ObservationsHolder {
175
212
 
176
213
  questionGroupObservation.addObservation(newObservation);
177
214
  }
178
- } //private
179
-
215
+ }
180
216
 
181
217
  _removeObs(formElement) {
182
218
  if (formElement.isQuestionGroup()) {
@@ -192,8 +228,7 @@ class ObservationsHolder {
192
228
  const parentFormElement = formElement.getParentFormElement();
193
229
  const questionGroupObservations = this.getObservation(parentFormElement.concept);
194
230
  return questionGroupObservations && questionGroupObservations.getValueWrapper();
195
- } //private
196
-
231
+ }
197
232
 
198
233
  removeNonApplicableAnswers(fe, isSingleSelect, observation) {
199
234
  if (!_lodash.default.isEmpty(observation)) {
@@ -210,10 +245,6 @@ class ObservationsHolder {
210
245
  this.observations.push(newObservation);
211
246
  }
212
247
  }
213
- /*
214
- Called from wizard after the update of the fields is called for all types. This is to sync up the coded fields based on the rules.
215
- */
216
-
217
248
 
218
249
  updatePrimitiveCodedObs(applicableFormElements, formElementStatuses) {
219
250
  const updateQuestionGroupObs = (parentFormElement, questionGroupIndex, fe, value) => {
@@ -274,15 +305,10 @@ class ObservationsHolder {
274
305
  }
275
306
  });
276
307
  }
277
- /*
278
- called for direct edit of single select field
279
- */
280
-
281
308
 
282
309
  toggleSingleSelectAnswer(concept, answerUUID) {
283
310
  return this.toggleCodedAnswer(concept, answerUUID, true);
284
- } //private
285
-
311
+ }
286
312
 
287
313
  toggleCodedAnswer(concept, answerUUID, isSingleSelect) {
288
314
  let observation = this.getObservation(concept);
@@ -304,10 +330,6 @@ class ObservationsHolder {
304
330
  return observation;
305
331
  }
306
332
  }
307
- /*
308
- called for direct edit of duration field
309
- */
310
-
311
333
 
312
334
  updateCompositeDurationValue(concept, duration) {
313
335
  let observation = this.getObservation(concept);
@@ -322,10 +344,6 @@ class ObservationsHolder {
322
344
  this.observations.push(observation);
323
345
  return observation;
324
346
  }
325
- /*
326
- called for direct edit of phone number field
327
- */
328
-
329
347
 
330
348
  updatePhoneNumberValue(concept, phoneNumber, verified = false, skipVerification = false) {
331
349
  let observation = this.getObservation(concept);
@@ -356,8 +374,7 @@ class ObservationsHolder {
356
374
  if (!childObservations.isEmpty()) {
357
375
  this.observations.push(_Observation.default.create(parentConcept, childObservations));
358
376
  }
359
- } //private
360
-
377
+ }
361
378
 
362
379
  updateChildObservations(childFormElement, childObservations, value, verified = false, skipVerification = false) {
363
380
  const childConcept = childFormElement.concept;
@@ -449,8 +466,7 @@ class ObservationsHolder {
449
466
  observation.valueJSON = JSON.stringify(observation.valueJSON);
450
467
  }
451
468
  });
452
- } //private
453
-
469
+ }
454
470
 
455
471
  getObservationReadableValue(concept) {
456
472
  let obs = this.getObservation(concept);
@@ -466,8 +482,7 @@ class ObservationsHolder {
466
482
  } else {
467
483
  this.observations.push(_Observation.default.create(concept, valueWrapper));
468
484
  }
469
- } //private
470
-
485
+ }
471
486
 
472
487
  updateObservationBasedOnValue(oldValue, newValue) {
473
488
  const observation = this.findObservationByValue(oldValue);
@@ -502,6 +517,25 @@ class ObservationsHolder {
502
517
  }
503
518
  }
504
519
 
520
+ migrateMultiSelectMediaObservations(form) {
521
+ _lodash.default.forEach(form.nonVoidedFormElementGroups(), feg => {
522
+ _lodash.default.forEach(feg.getFormElements(), fe => {
523
+ const concept = fe.concept;
524
+ const observation = this.getObservation(concept);
525
+
526
+ if (_lodash.default.includes(_Concept.default.dataType.Media, fe.getType()) && observation && fe.isMultiSelect()) {
527
+ const valueWrapper = observation.getValueWrapper();
528
+
529
+ if (!_lodash.default.isArray(valueWrapper.getValue())) {
530
+ _General.default.logDebug("ObservationHolder", `Found string value ${valueWrapper.getValue()} for multi select media element, doing migration`);
531
+
532
+ observation.valueJSON = new _MultipleCodedValues.default([valueWrapper.getValue()]);
533
+ }
534
+ }
535
+ });
536
+ });
537
+ }
538
+
505
539
  toString(I18n) {
506
540
  let display = "";
507
541
  this.observations.forEach(obs => {
@@ -25,14 +25,8 @@ var _SchemaNames = _interopRequireDefault(require("./SchemaNames"));
25
25
 
26
26
  var _BaseEntity = _interopRequireDefault(require("./BaseEntity"));
27
27
 
28
- var _AuditUtil = require("./utility/AuditUtil");
29
-
30
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
29
 
32
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
33
-
34
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
35
-
36
30
  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; }
37
31
 
38
32
  class ProgramEncounter extends _AbstractEncounter.default {
@@ -170,7 +164,7 @@ _defineProperty(ProgramEncounter, "validationKeys", {
170
164
  _defineProperty(ProgramEncounter, "schema", {
171
165
  name: _SchemaNames.default.ProgramEncounter,
172
166
  primaryKey: "uuid",
173
- properties: _objectSpread({
167
+ properties: {
174
168
  uuid: {
175
169
  type: "string"
176
170
  },
@@ -196,7 +190,7 @@ _defineProperty(ProgramEncounter, "schema", {
196
190
  programEnrolment: _SchemaNames.default.ProgramEnrolment,
197
191
  observations: {
198
192
  type: "list",
199
- objectType: "EmbeddedObservation"
193
+ objectType: "Observation"
200
194
  },
201
195
  cancelDateTime: {
202
196
  type: "date",
@@ -204,14 +198,14 @@ _defineProperty(ProgramEncounter, "schema", {
204
198
  },
205
199
  cancelObservations: {
206
200
  type: "list",
207
- objectType: "EmbeddedObservation"
201
+ objectType: "Observation"
208
202
  },
209
203
  encounterLocation: {
210
- type: _SchemaNames.default.EmbeddedPoint,
204
+ type: "Point",
211
205
  optional: true
212
206
  },
213
207
  cancelLocation: {
214
- type: _SchemaNames.default.EmbeddedPoint,
208
+ type: "Point",
215
209
  optional: true
216
210
  },
217
211
  voided: {
@@ -225,17 +219,9 @@ _defineProperty(ProgramEncounter, "schema", {
225
219
  latestEntityApprovalStatus: {
226
220
  type: "EntityApprovalStatus",
227
221
  optional: true
228
- }
229
- }, _AuditUtil.AuditFields, {
230
- filledBy: {
231
- type: "string",
232
- optional: true
233
- },
234
- filledByUUID: {
235
- type: "string",
236
- optional: true
237
- }
238
- })
222
+ } //Reporting purposes
223
+
224
+ }
239
225
  });
240
226
 
241
227
  var _default = ProgramEncounter;