openchs-models 1.31.61 → 1.31.62

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.
@@ -227,6 +227,32 @@ class Form extends _BaseEntity.default {
227
227
 
228
228
  const extraObs = observations.filter(obs => _lodash.default.isNil(orderedObservations.find(oobs => oobs.concept.uuid === obs.concept.uuid)));
229
229
  return orderedObservations.concat(extraObs);
230
+ } //TODO add tests
231
+
232
+
233
+ orderObservationsPerFEG(observations) {
234
+ const orderedObservations = [];
235
+
236
+ const formElementOrdering = _lodash.default.sortBy(this.formElementGroups, feg => feg.displayOrder).map(feg => {
237
+ let fegOrderedObservations = [];
238
+ const returnValue = {};
239
+ returnValue.uuid = feg.uuid;
240
+ returnValue.feg = feg;
241
+ returnValue.sortedObservationsArray = fegOrderedObservations;
242
+ this.orderObservationsWithinAFEG(feg.getFormElements(), observations, fegOrderedObservations);
243
+ orderedObservations.concat(fegOrderedObservations);
244
+ return returnValue;
245
+ });
246
+
247
+ return formElementOrdering;
248
+ }
249
+
250
+ orderObservationsWithinAFEG(formElements, observations, orderedObservations) {
251
+ _lodash.default.sortBy(formElements, fe => fe.displayOrder).forEach(formElement => this.addSortedObservations(formElement, observations, orderedObservations));
252
+
253
+ const extraObs = observations.filter(obs => _lodash.default.isNil(orderedObservations.find(oobs => oobs.concept.uuid === obs.concept.uuid)));
254
+ orderedObservations.concat(extraObs);
255
+ return extraObs;
230
256
  }
231
257
 
232
258
  sectionWiseOrderedObservations(observations) {
@@ -31,6 +31,8 @@ var _BaseEntity = _interopRequireDefault(require("../BaseEntity"));
31
31
 
32
32
  var _SchemaNames = _interopRequireDefault(require("../SchemaNames"));
33
33
 
34
+ var _RepeatableQuestionGroup = _interopRequireDefault(require("../observation/RepeatableQuestionGroup"));
35
+
34
36
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
37
 
36
38
  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; }
@@ -149,8 +151,18 @@ class FormElement extends _BaseEntity.default {
149
151
  return formElement;
150
152
  }
151
153
 
154
+ newFormElement() {
155
+ return new FormElement();
156
+ }
157
+
152
158
  getType() {
153
- return this.concept.datatype === _Concept.default.dataType.Coded ? this.type : this.concept.datatype;
159
+ if (this.concept.datatype === _Concept.default.dataType.Coded) {
160
+ return this.type;
161
+ } else if (this.concept.datatype === _Concept.default.dataType.QuestionGroup && this.repeatable) {
162
+ return _RepeatableQuestionGroup.default.TypeName;
163
+ } else {
164
+ return this.concept.datatype;
165
+ }
154
166
  }
155
167
 
156
168
  isMultiSelect() {
@@ -387,7 +399,7 @@ class FormElement extends _BaseEntity.default {
387
399
  }
388
400
 
389
401
  clone() {
390
- const formElement = new FormElement();
402
+ const formElement = this.newFormElement();
391
403
  formElement.uuid = this.uuid;
392
404
  formElement.name = this.name;
393
405
  formElement.displayOrder = this.displayOrder;
@@ -88,6 +88,8 @@ class RepeatableQuestionGroup {
88
88
 
89
89
  }
90
90
 
91
+ _defineProperty(RepeatableQuestionGroup, "TypeName", "RepeatableQuestionGroup");
92
+
91
93
  _defineProperty(RepeatableQuestionGroup, "actions", {
92
94
  add: 'add',
93
95
  remove: 'remove'
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.31.61",
4
+ "version": "1.31.62",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",