openchs-models 1.9.3 → 1.9.4

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.
@@ -143,6 +143,53 @@ class Form {
143
143
  return orderedObservations.concat(extraObs);
144
144
  }
145
145
 
146
+ sectionWiseOrderedObservations(observations) {
147
+ const sections = [];
148
+ const allObservations = [];
149
+
150
+ const orderedFEG = _lodash.default.sortBy(this.formElementGroups, ({
151
+ displayOrder
152
+ }) => displayOrder);
153
+
154
+ _lodash.default.forEach(orderedFEG, feg => {
155
+ const conceptOrdering = _lodash.default.sortBy(feg.getFormElements(), fe => fe.displayOrder).map(fe => fe.concept);
156
+
157
+ const fegObs = [];
158
+
159
+ _lodash.default.forEach(conceptOrdering, concept => {
160
+ const foundObs = observations.find(obs => obs.concept.uuid === concept.uuid);
161
+ if (!_lodash.default.isNil(foundObs)) fegObs.push(foundObs);
162
+ });
163
+
164
+ if (!_lodash.default.isEmpty(fegObs)) {
165
+ sections.push({
166
+ groupName: feg.name,
167
+ groupUUID: feg.uuid,
168
+ observations: fegObs
169
+ });
170
+ allObservations.push(...fegObs);
171
+ }
172
+ });
173
+
174
+ const decisionObs = observations.filter(obs => _lodash.default.isNil(allObservations.find(oobs => oobs.concept.uuid === obs.concept.uuid)));
175
+ if (!_lodash.default.isEmpty(decisionObs)) sections.push({
176
+ groupName: 'decisions',
177
+ groupUUID: null,
178
+ observations: decisionObs
179
+ });
180
+ return sections;
181
+ }
182
+
183
+ getFormElementGroupOrder(groupUUID) {
184
+ const orderedFEG = _lodash.default.sortBy(this.formElementGroups, ({
185
+ displayOrder
186
+ }) => displayOrder);
187
+
188
+ return _lodash.default.findIndex(orderedFEG, ({
189
+ uuid
190
+ }) => uuid === groupUUID) + 1;
191
+ }
192
+
146
193
  }
147
194
 
148
195
  _defineProperty(Form, "schema", {
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.9.3",
4
+ "version": "1.9.4",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",