openchs-models 1.31.85 → 1.31.87

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.
@@ -7,10 +7,6 @@ exports.default = void 0;
7
7
 
8
8
  var _BaseEntity = _interopRequireDefault(require("./BaseEntity"));
9
9
 
10
- var _Dashboard = _interopRequireDefault(require("./Dashboard"));
11
-
12
- var _General = _interopRequireDefault(require("./utility/General"));
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
11
 
16
12
  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; }
@@ -20,6 +16,14 @@ class CustomDashboardCache extends _BaseEntity.default {
20
16
  super(that);
21
17
  }
22
18
 
19
+ get checksum() {
20
+ return this.that.checksum;
21
+ }
22
+
23
+ set checksum(x) {
24
+ this.that.checksum = x;
25
+ }
26
+
23
27
  get updatedAt() {
24
28
  return this.that.updatedAt;
25
29
  }
@@ -44,59 +48,84 @@ class CustomDashboardCache extends _BaseEntity.default {
44
48
  this.that.filterApplied = x;
45
49
  }
46
50
 
47
- get dashboard() {
48
- return this.toEntity("dashboard", _Dashboard.default);
51
+ get filterErrorsJSON() {
52
+ return this.that.filterErrorsJSON;
53
+ }
54
+
55
+ set filterErrorsJSON(x) {
56
+ this.that.filterErrorsJSON = x;
57
+ }
58
+
59
+ get ruleInputJSON() {
60
+ return this.that.ruleInputJSON;
49
61
  }
50
62
 
51
- set dashboard(x) {
52
- this.that.dashboard = this.fromObject(x);
63
+ set ruleInputJSON(x) {
64
+ this.that.ruleInputJSON = x;
53
65
  }
54
66
 
55
- get dashboardFiltersHash() {
56
- return this.that.dashboardFiltersHash;
67
+ get transformedFiltersJSON() {
68
+ return this.that.transformedFiltersJSON;
57
69
  }
58
70
 
59
- set dashboardFiltersHash(x) {
60
- this.that.dashboardFiltersHash = x;
71
+ set transformedFiltersJSON(x) {
72
+ this.that.transformedFiltersJSON = x;
61
73
  }
62
74
 
63
- static create(uuid, updatedAt, selectedValuesJSON = '{}', filterApplied) {
75
+ static create(uuid, checksum, updatedAt, selectedValuesJSON, filterApplied, filterErrorsJSON, ruleInputJSON, transformedFiltersJSON) {
64
76
  const customDashboardCache = new CustomDashboardCache();
65
77
  customDashboardCache.uuid = uuid;
78
+ customDashboardCache.checksum = checksum;
66
79
  customDashboardCache.updatedAt = updatedAt;
67
80
  customDashboardCache.selectedValuesJSON = selectedValuesJSON;
68
81
  customDashboardCache.filterApplied = filterApplied;
82
+ customDashboardCache.filterErrorsJSON = filterErrorsJSON;
83
+ customDashboardCache.ruleInputJSON = ruleInputJSON;
84
+ customDashboardCache.transformedFiltersJSON = transformedFiltersJSON;
69
85
  return customDashboardCache;
70
86
  }
71
87
 
72
- static newInstance(dashboard, dashboardFiltersHash) {
73
- const customDashboardCache = new CustomDashboardCache();
74
- customDashboardCache.uuid = _General.default.randomUUID();
75
- customDashboardCache.dashboard = dashboard;
76
- customDashboardCache.reset(dashboardFiltersHash);
77
- return customDashboardCache;
88
+ static getSelectedValuesFromState(state) {
89
+ const filterCache = {
90
+ date: state.date,
91
+ applied: false,
92
+ selectedLocations: state.selectedLocations,
93
+ selectedCustomFilters: state.selectedCustomFilters,
94
+ selectedGenders: state.selectedGenders
95
+ };
96
+ return filterCache;
78
97
  }
79
98
 
80
- reset(dashboardFiltersHash) {
81
- this.filterApplied = false;
82
- this.selectedValuesJSON = JSON.stringify({});
83
- this.dashboardFiltersHash = dashboardFiltersHash;
84
- this.updatedAt = new Date();
99
+ static createEmptyInstance() {
100
+ return new CustomDashboardCache();
101
+ }
102
+
103
+ getChecksum() {
104
+ return this.checksum;
85
105
  }
86
106
 
87
107
  getSelectedValues() {
88
- return JSON.parse(this.selectedValuesJSON);
108
+ return this.selectedValuesJSON && JSON.parse(this.selectedValuesJSON) || {};
89
109
  }
90
110
 
91
- clone() {
92
- const customDashboardCache = new CustomDashboardCache();
93
- customDashboardCache.uuid = this.uuid;
94
- customDashboardCache.dashboard = this.dashboard;
95
- customDashboardCache.updatedAt = this.updatedAt;
96
- customDashboardCache.selectedValuesJSON = this.selectedValuesJSON;
97
- customDashboardCache.filterApplied = this.filterApplied;
98
- customDashboardCache.dashboardFiltersHash = this.dashboardFiltersHash;
99
- return customDashboardCache;
111
+ getFilterErrors() {
112
+ return this.filterErrorsJSON && JSON.parse(this.filterErrorsJSON) || {};
113
+ }
114
+
115
+ getRuleInput() {
116
+ return this.ruleInputJSON && JSON.parse(this.ruleInputJSON) || {
117
+ ruleInputArray: null
118
+ };
119
+ }
120
+
121
+ getTransformedFilters() {
122
+ return this.transformedFiltersJSON && JSON.parse(this.transformedFiltersJSON) || {
123
+ date: new Date(),
124
+ applied: false,
125
+ selectedLocations: [],
126
+ selectedCustomFilters: [],
127
+ selectedGenders: []
128
+ };
100
129
  }
101
130
 
102
131
  }
@@ -106,11 +135,16 @@ _defineProperty(CustomDashboardCache, "schema", {
106
135
  primaryKey: "uuid",
107
136
  properties: {
108
137
  uuid: "string",
109
- dashboard: "Dashboard",
138
+ checksum: "string",
110
139
  updatedAt: "date",
111
140
  selectedValuesJSON: "string",
112
- filterApplied: "bool",
113
- dashboardFiltersHash: "string"
141
+ filterApplied: {
142
+ type: "bool",
143
+ default: false
144
+ },
145
+ filterErrorsJSON: "string",
146
+ ruleInputJSON: "string",
147
+ transformedFiltersJSON: "string"
114
148
  }
115
149
  });
116
150
 
@@ -41,8 +41,7 @@ _defineProperty(CustomFilter, "type", {
41
41
  EncounterDate: "EncounterDate",
42
42
  Address: "Address",
43
43
  Concept: "Concept",
44
- GroupSubject: "GroupSubject",
45
- SubjectType: "SubjectType"
44
+ GroupSubject: "GroupSubject"
46
45
  });
47
46
 
48
47
  _defineProperty(CustomFilter, "scope", {
package/dist/Dashboard.js CHANGED
@@ -36,14 +36,6 @@ class Dashboard extends _BaseEntity.default {
36
36
  this.that.description = x;
37
37
  }
38
38
 
39
- get filters() {
40
- return this.toEntityList("filters", _DashboardFilter.default);
41
- }
42
-
43
- set filters(x) {
44
- this.that.filters = this.fromEntityList(x);
45
- }
46
-
47
39
  static fromResource(resource) {
48
40
  return _General.default.assignFields(resource, new Dashboard(), ["uuid", "name", "description", "voided"]);
49
41
  }
@@ -9,6 +9,8 @@ var _General = _interopRequireDefault(require("./utility/General"));
9
9
 
10
10
  var _BaseEntity = _interopRequireDefault(require("./BaseEntity"));
11
11
 
12
+ var _lodash = _interopRequireDefault(require("lodash"));
13
+
12
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
15
 
14
16
  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; }
@@ -67,7 +69,7 @@ class MediaQueue extends _BaseEntity.default {
67
69
  }
68
70
 
69
71
  static create(entityUUID, entityName, fileName, type, entityTargetField, conceptUUID, uuid = _General.default.randomUUID()) {
70
- var mediaQueue = new MediaQueue();
72
+ const mediaQueue = new MediaQueue();
71
73
  mediaQueue.entityUUID = entityUUID;
72
74
  mediaQueue.uuid = uuid;
73
75
  mediaQueue.entityName = entityName;
@@ -90,6 +92,18 @@ class MediaQueue extends _BaseEntity.default {
90
92
  return mediaQueueItem;
91
93
  }
92
94
 
95
+ getDisplayText() {
96
+ // generate safe to string
97
+ let str = "";
98
+ if (!_lodash.default.isNil(this.entityName)) str += "EntityName: " + this.entityName + ", ";
99
+ if (!_lodash.default.isNil(this.entityUUID)) str += "EntityUUID: " + this.entityUUID + ", ";
100
+ if (!_lodash.default.isNil(this.entityTargetField)) str += "EntityTargetField: " + this.entityTargetField + ", ";
101
+ if (!_lodash.default.isNil(this.fileName)) str += "FileName: " + this.fileName + ", ";
102
+ if (!_lodash.default.isNil(this.type)) str += "Type: " + this.type + ", ";
103
+ if (!_lodash.default.isNil(this.conceptUUID)) str += "ConceptUUID: " + this.conceptUUID;
104
+ return str;
105
+ }
106
+
93
107
  }
94
108
 
95
109
  _defineProperty(MediaQueue, "schema", {
@@ -21,16 +21,19 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
21
21
 
22
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; }
23
23
 
24
- const clone = function (concept, valueJSON) {
24
+ const clone = function (concept, valueJSON, abnormal) {
25
25
  const observation = new Observation();
26
26
  observation.concept = concept;
27
27
  observation.valueJSON = valueJSON;
28
+ observation.abnormal = abnormal;
28
29
  return observation;
29
30
  };
30
31
 
31
32
  class Observation extends _PersistedObject.default {
32
33
  constructor(that = null) {
33
34
  super(that);
35
+
36
+ _defineProperty(this, "abnormal", void 0);
34
37
  }
35
38
 
36
39
  get concept() {
@@ -49,10 +52,11 @@ class Observation extends _PersistedObject.default {
49
52
  this.that.valueJSON = x;
50
53
  }
51
54
 
52
- static create(concept, value) {
55
+ static create(concept, value, abnormal = false) {
53
56
  const observation = new Observation();
54
57
  observation.concept = concept;
55
58
  observation.valueJSON = value;
59
+ observation.abnormal = abnormal;
56
60
  return observation;
57
61
  }
58
62
 
@@ -15,26 +15,15 @@ var _StandardReportCardType = _interopRequireDefault(require("./StandardReportCa
15
15
 
16
16
  var _lodash = _interopRequireDefault(require("lodash"));
17
17
 
18
- var _SubjectType = _interopRequireDefault(require("./SubjectType"));
19
-
20
- var _Program = _interopRequireDefault(require("./Program"));
21
-
22
- var _EncounterType = _interopRequireDefault(require("./EncounterType"));
23
-
24
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
19
 
26
20
  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; }
27
21
 
28
- class ReportCard extends _BaseEntity.default {
29
- static newReportCard() {
30
- const reportCard = new ReportCard();
31
- reportCard.standardReportCardInputSubjectTypes = [];
32
- reportCard.standardReportCardInputPrograms = [];
33
- reportCard.standardReportCardInputEncounterTypes = [];
34
- reportCard.standardReportCardInputRecentDuration = null;
35
- return reportCard;
36
- }
22
+ function throwInvalidIndexError(index, reportCardsLength) {
23
+ throw new Error(`Invalid index ${index} specified for reportCard with length ${reportCardsLength}`);
24
+ }
37
25
 
26
+ class ReportCard extends _BaseEntity.default {
38
27
  constructor(that = null) {
39
28
  super(that);
40
29
  }
@@ -107,38 +96,6 @@ class ReportCard extends _BaseEntity.default {
107
96
  get textColor() {
108
97
  return _lodash.default.isNil(this.standardReportCardType) ? '#ffffff' : this.standardReportCardType.textColor;
109
98
  }
110
-
111
- get standardReportCardInputSubjectTypes() {
112
- return this.toEntityList("standardReportCardInputSubjectTypes", _SubjectType.default);
113
- }
114
-
115
- set standardReportCardInputSubjectTypes(x) {
116
- this.that.standardReportCardInputSubjectTypes = this.fromEntityList(x);
117
- }
118
-
119
- get standardReportCardInputPrograms() {
120
- return this.toEntityList("standardReportCardInputPrograms", _Program.default);
121
- }
122
-
123
- set standardReportCardInputPrograms(x) {
124
- this.that.standardReportCardInputPrograms = this.fromEntityList(x);
125
- }
126
-
127
- get standardReportCardInputEncounterTypes() {
128
- return this.toEntityList("standardReportCardInputEncounterTypes", _EncounterType.default);
129
- }
130
-
131
- set standardReportCardInputEncounterTypes(x) {
132
- this.that.standardReportCardInputEncounterTypes = this.fromEntityList(x);
133
- }
134
-
135
- get standardReportCardInputRecentDurationJSON() {
136
- return JSON.parse(this.that.standardReportCardInputRecentDurationJSON);
137
- }
138
-
139
- set standardReportCardInputRecentDurationJSON(x) {
140
- this.that.standardReportCardInputRecentDurationJSON = x;
141
- }
142
99
  /**
143
100
  * Helper method used to generate unique key value for Nested Report Cards using UUID and Index of the Report Card.
144
101
  * The Nested Report Card's query responses would be mapped to the corresponding Dashboard Report cards using the UUID and Index.
@@ -165,19 +122,9 @@ class ReportCard extends _BaseEntity.default {
165
122
  }
166
123
 
167
124
  static fromResource(resource, entityService) {
168
- const reportCard = _General.default.assignFields(resource, ReportCard.newReportCard(), ["uuid", "name", "query", "description", "colour", "voided", "nested", "countOfCards"]);
125
+ const reportCard = _General.default.assignFields(resource, new ReportCard(), ["uuid", "name", "query", "description", "colour", "voided", "nested", "countOfCards"]);
169
126
 
170
127
  reportCard.standardReportCardType = entityService.findByKey("uuid", _ResourceUtil.default.getUUIDFor(resource, "standardReportCardUUID"), _StandardReportCardType.default.schema.name);
171
- resource.standardReportCardInputSubjectTypes.forEach(uuid => {
172
- reportCard.standardReportCardInputSubjectTypes.push(entityService.findByUUID(uuid, _SubjectType.default.schema.name));
173
- });
174
- resource.standardReportCardInputPrograms.forEach(uuid => {
175
- reportCard.standardReportCardInputPrograms.push(entityService.findByUUID(uuid, _Program.default.schema.name));
176
- });
177
- resource.standardReportCardInputEncounterTypes.forEach(uuid => {
178
- reportCard.standardReportCardInputEncounterTypes.push(entityService.findByUUID(uuid, _EncounterType.default.schema.name));
179
- });
180
- reportCard.standardReportCardInputRecentDurationJSON = resource.standardReportCardInputRecentDuration;
181
128
  return reportCard;
182
129
  }
183
130
 
@@ -185,18 +132,6 @@ class ReportCard extends _BaseEntity.default {
185
132
  return _lodash.default.isNil(this.standardReportCardType) ? false : this.standardReportCardType.isTaskType();
186
133
  }
187
134
 
188
- isStandardReportType() {
189
- return !_lodash.default.isNil(this.standardReportCardType);
190
- }
191
-
192
- isSubjectTypeFilterSupported() {
193
- return this.isStandardReportType() && this.standardReportCardType.isSubjectTypeFilterSupported();
194
- }
195
-
196
- isRecentType() {
197
- return this.isStandardReportType() && this.standardReportCardType.isRecentType();
198
- }
199
-
200
135
  }
201
136
 
202
137
  _defineProperty(ReportCard, "schema", {
@@ -231,24 +166,8 @@ _defineProperty(ReportCard, "schema", {
231
166
  type: "int",
232
167
  default: 1,
233
168
  optional: true
234
- },
235
- //Used only by nested ReportCards
236
- standardReportCardInputSubjectTypes: {
237
- type: "list",
238
- objectType: "SubjectType"
239
- },
240
- standardReportCardInputPrograms: {
241
- type: "list",
242
- objectType: "Program"
243
- },
244
- standardReportCardInputEncounterTypes: {
245
- type: "list",
246
- objectType: "EncounterType"
247
- },
248
- standardReportCardInputRecentDurationJSON: {
249
- type: "string",
250
- optional: true
251
- }
169
+ } //Used only by nested ReportCards
170
+
252
171
  }
253
172
  });
254
173
 
package/dist/Schema.js CHANGED
@@ -279,7 +279,7 @@ function createRealmConfig() {
279
279
  return doCompact;
280
280
  },
281
281
  //order is important, should be arranged according to the dependency
282
- schemaVersion: 193,
282
+ schemaVersion: 190,
283
283
  onMigration: function (oldDB, newDB) {
284
284
  console.log("[AvniModels.Schema]", `Running migration with old schema version: ${oldDB.schemaVersion} and new schema version: ${newDB.schemaVersion}`);
285
285
  if (oldDB.schemaVersion === VersionWithEmbeddedMigrationProblem) throw new Error(`Update from schema version ${VersionWithEmbeddedMigrationProblem} is not allowed. Please uninstall and install app.`);
@@ -913,10 +913,6 @@ function createRealmConfig() {
913
913
  if (oldDB.schemaVersion < 190) {// PlaceHolder for SubjectType.User changes, so that people with previous version of client
914
914
  // are not able to use fastSync of version 190 and above
915
915
  }
916
-
917
- if (oldDB.schemaVersion < 191) {
918
- newDB.delete(newDB.objects("CustomDashboardCache"));
919
- }
920
916
  }
921
917
  };
922
918
  }
@@ -81,7 +81,7 @@ class StandardReportCardType extends _BaseEntity.default {
81
81
  }
82
82
 
83
83
  defaultTypes() {
84
- return [StandardReportCardType.type.ScheduledVisits, StandardReportCardType.type.OverdueVisits, StandardReportCardType.type.RecentRegistrations, StandardReportCardType.type.RecentEnrolments, StandardReportCardType.type.RecentVisits, StandardReportCardType.type.Total];
84
+ return [StandardReportCardType.type.ScheduledVisits, StandardReportCardType.type.OverdueVisits, StandardReportCardType.type.LatestRegistrations, StandardReportCardType.type.LatestEnrolments, StandardReportCardType.type.LatestVisits, StandardReportCardType.type.Total];
85
85
  }
86
86
 
87
87
  isApprovalType() {
@@ -118,14 +118,6 @@ class StandardReportCardType extends _BaseEntity.default {
118
118
  return typeToStatusMap[this.name];
119
119
  }
120
120
 
121
- isSubjectTypeFilterSupported() {
122
- return [StandardReportCardType.type.ScheduledVisits, StandardReportCardType.type.OverdueVisits, StandardReportCardType.type.RecentRegistrations, StandardReportCardType.type.RecentEnrolments, StandardReportCardType.type.RecentVisits].includes(this.name);
123
- }
124
-
125
- isRecentType() {
126
- return [StandardReportCardType.type.RecentRegistrations, StandardReportCardType.type.RecentEnrolments, StandardReportCardType.type.RecentVisits].includes(this.name);
127
- }
128
-
129
121
  }
130
122
 
131
123
  _defineProperty(StandardReportCardType, "schema", {
@@ -151,9 +143,9 @@ _defineProperty(StandardReportCardType, "type", {
151
143
  Rejected: "Rejected",
152
144
  ScheduledVisits: "Scheduled visits",
153
145
  OverdueVisits: "Overdue visits",
154
- RecentRegistrations: "Recent registrations",
155
- RecentEnrolments: "Recent enrolments",
156
- RecentVisits: "Recent visits",
146
+ LatestRegistrations: "Last 24 hours registrations",
147
+ LatestEnrolments: "Last 24 hours enrolments",
148
+ LatestVisits: "Last 24 hours visits",
157
149
  Total: "Total",
158
150
  Comments: "Comments",
159
151
  CallTasks: "Call tasks",
@@ -161,8 +153,6 @@ _defineProperty(StandardReportCardType, "type", {
161
153
  DueChecklist: "Due checklist"
162
154
  });
163
155
 
164
- _defineProperty(StandardReportCardType, "recentCardDurationUnits", ["days", "weeks", "months"]);
165
-
166
156
  const typeToStatusMap = {
167
157
  [StandardReportCardType.type.PendingApproval]: _ApprovalStatus.default.statuses.Pending,
168
158
  [StandardReportCardType.type.Approved]: _ApprovalStatus.default.statuses.Approved,
package/dist/index.js CHANGED
@@ -789,18 +789,6 @@ Object.defineProperty(exports, "JSONStringify", {
789
789
  return _JsonStringify.JSONStringify;
790
790
  }
791
791
  });
792
- Object.defineProperty(exports, "Locations", {
793
- enumerable: true,
794
- get: function () {
795
- return _Locations.default;
796
- }
797
- });
798
- Object.defineProperty(exports, "Range", {
799
- enumerable: true,
800
- get: function () {
801
- return _Range.default;
802
- }
803
- });
804
792
 
805
793
  var _AbstractEncounter = _interopRequireDefault(require("./AbstractEncounter"));
806
794
 
@@ -1054,10 +1042,6 @@ var _DashboardCacheFilter = _interopRequireDefault(require("./application/Dashbo
1054
1042
 
1055
1043
  var _JsonStringify = require("./utility/JsonStringify");
1056
1044
 
1057
- var _Locations = _interopRequireDefault(require("./location/Locations"));
1058
-
1059
- var _Range = _interopRequireDefault(require("./reports/Range"));
1060
-
1061
1045
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
1062
1046
 
1063
1047
  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; }
@@ -13,23 +13,11 @@ var _lodash = _interopRequireDefault(require("lodash"));
13
13
 
14
14
  var _DateTimeUtil = _interopRequireDefault(require("../utility/DateTimeUtil"));
15
15
 
16
- var _Range = _interopRequireDefault(require("./Range"));
17
-
18
- var _Gender = _interopRequireDefault(require("../Gender"));
19
-
20
- var _AddressLevel = _interopRequireDefault(require("../AddressLevel"));
21
-
22
- var _Individual = _interopRequireDefault(require("../Individual"));
23
-
24
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
17
 
26
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; }
27
19
 
28
20
  const widgetConceptDataTypes = [_Concept.default.dataType.Date, _Concept.default.dataType.DateTime, _Concept.default.dataType.Time, _Concept.default.dataType.Numeric];
29
- const conceptEntityTypes = {
30
- [_Concept.default.dataType.Coded]: _Concept.default.schema.name,
31
- [_Concept.default.dataType.Location]: _AddressLevel.default.schema.name
32
- };
33
21
 
34
22
  class ObservationBasedFilter {
35
23
  constructor() {
@@ -54,15 +42,6 @@ class ObservationBasedFilter {
54
42
  return !_lodash.default.isNil(concept) && (!_lodash.default.isEmpty(programs) || !_lodash.default.isEmpty(encounterTypes) || this.scope === _CustomFilter.default.scope.Registration);
55
43
  }
56
44
 
57
- isMultiEntityType() {
58
- return [_Concept.default.dataType.Coded, _Concept.default.dataType.Location].includes(this.concept.datatype);
59
- }
60
-
61
- getEntityType() {
62
- if (this.isMultiEntityType()) return conceptEntityTypes[this.concept.datatype];
63
- throw new Error("Unsupported concept data type for getting entity type: " + this.concept.datatype);
64
- }
65
-
66
45
  toServerRequest() {
67
46
  return {
68
47
  scope: this.scope,
@@ -129,28 +108,9 @@ class GroupSubjectTypeFilter {
129
108
 
130
109
  exports.GroupSubjectTypeFilter = GroupSubjectTypeFilter;
131
110
  const dateFilterTypes = [_CustomFilter.default.type.RegistrationDate, _CustomFilter.default.type.EnrolmentDate, _CustomFilter.default.type.EncounterDate, _CustomFilter.default.type.ProgramEncounterDate];
132
- const entityTypes = {
133
- [_CustomFilter.default.type.Gender]: _Gender.default.schema.name,
134
- [_CustomFilter.default.type.Address]: _AddressLevel.default.schema.name,
135
- [_CustomFilter.default.type.GroupSubject]: _Individual.default.schema.name
136
- };
137
-
138
- function isDateDataType(dashboardFilterConfig) {
139
- return dateFilterTypes.includes(dashboardFilterConfig.type) || dashboardFilterConfig.isConceptTypeFilter() && dashboardFilterConfig.observationBasedFilter.concept.datatype === _Concept.default.dataType.Date;
140
- }
141
-
142
- function isDateTimeDataType(dashboardFilterConfig) {
143
- return dashboardFilterConfig.isConceptTypeFilter() && dashboardFilterConfig.observationBasedFilter.concept.datatype === _Concept.default.dataType.DateTime;
144
- }
145
-
146
- function isTimeDataType(dashboardFilterConfig) {
147
- return dashboardFilterConfig.isConceptTypeFilter() && dashboardFilterConfig.observationBasedFilter.concept.datatype === _Concept.default.dataType.Time;
148
- }
149
111
 
150
112
  class DashboardFilterConfig {
151
113
  constructor() {
152
- _defineProperty(this, "subjectType", void 0);
153
-
154
114
  _defineProperty(this, "type", void 0);
155
115
 
156
116
  _defineProperty(this, "widget", void 0);
@@ -160,100 +120,26 @@ class DashboardFilterConfig {
160
120
  _defineProperty(this, "observationBasedFilter", void 0);
161
121
  }
162
122
 
163
- toDisplayText() {
164
- let s = `Type: ${this.type}.`;
165
-
166
- if (this.widget === _CustomFilter.default.widget.Range) {
167
- s += ` Widget: ${this.widget}.`;
168
- }
169
-
170
- if (this.isConceptTypeFilter()) {
171
- s += ` Concept: ${this.observationBasedFilter.concept.name}. DataType: ${this.observationBasedFilter.concept.datatype}.`;
172
- }
173
-
174
- return s;
175
- }
176
-
177
123
  getInputDataType() {
178
124
  if (this.isConceptTypeFilter()) {
179
125
  return this.observationBasedFilter.concept.datatype;
180
- } else if ([_CustomFilter.default.type.Gender, _CustomFilter.default.type.Address, _CustomFilter.default.type.GroupSubject].includes(this.type)) {
181
- return DashboardFilterConfig.dataTypes.array;
182
- } else if (dateFilterTypes.includes(this.type) && this.widget === _CustomFilter.default.widget.Default) {
126
+ } else if (this.isGroupSubjectTypeFilter()) {
127
+ return _Concept.default.dataType.Subject;
128
+ } else if (dateFilterTypes.includes(this.type)) {
183
129
  return _Concept.default.dataType.Date;
184
- } else if (dateFilterTypes.includes(this.type) && this.widget === _CustomFilter.default.widget.Range) {
185
- return _Range.default.DateRange;
186
- } else if (this.type === _CustomFilter.default.type.SubjectType) {
187
- return DashboardFilterConfig.dataTypes.formMetaData;
130
+ } else {
131
+ return this.type;
188
132
  }
189
-
190
- throw new Error("Unsupported filter type: " + this.type);
191
- }
192
-
193
- isDateFilterType() {
194
- return isDateDataType(this) && this.widget !== _CustomFilter.default.widget.Range;
195
- }
196
-
197
- isDateRangeFilterType() {
198
- return isDateDataType(this) && this.widget === _CustomFilter.default.widget.Range;
199
- }
200
-
201
- isDateTimeFilterType() {
202
- return isDateTimeDataType(this) && this.widget !== _CustomFilter.default.widget.Range;
203
- }
204
-
205
- isDateTimeRangeFilterType() {
206
- return isDateTimeDataType(this) && this.widget === _CustomFilter.default.widget.Range;
207
- }
208
-
209
- isTimeFilterType() {
210
- return isTimeDataType(this) && this.widget !== _CustomFilter.default.widget.Range;
211
- }
212
-
213
- isTimeRangeFilterType() {
214
- return isTimeDataType(this) && this.widget === _CustomFilter.default.widget.Range;
215
- }
216
-
217
- isNumericRangeFilterType() {
218
- return this.isConceptTypeFilter() && this.observationBasedFilter.concept.datatype === _Concept.default.dataType.Numeric && this.widget === _CustomFilter.default.widget.Range;
219
- }
220
-
221
- isDateLikeFilterType() {
222
- return this.isDateFilterType() || this.isDateTimeFilterType() || this.isTimeFilterType();
223
- }
224
-
225
- isDateLikeRangeFilterType() {
226
- return this.isDateRangeFilterType() || this.isDateTimeRangeFilterType() || this.isTimeRangeFilterType();
227
- }
228
-
229
- isMultiEntityType() {
230
- return [_CustomFilter.default.type.Gender, _CustomFilter.default.type.Address, _CustomFilter.default.type.GroupSubject].includes(this.type) || this.isConceptTypeFilter() && this.observationBasedFilter.isMultiEntityType();
231
- }
232
-
233
- getEntityType() {
234
- if (this.isMultiEntityType()) {
235
- return _lodash.default.isNil(entityTypes[this.type]) ? this.observationBasedFilter.getEntityType() : entityTypes[this.type];
236
- }
237
-
238
- throw new Error("Unsupported filter type: " + this.type);
239
133
  }
240
134
 
241
135
  isConceptTypeFilter() {
242
136
  return this.type === _CustomFilter.default.type.Concept;
243
137
  }
244
138
 
245
- isNonCodedObservationDataType() {
246
- return this.isConceptTypeFilter() && this.observationBasedFilter.concept.datatype !== _Concept.default.dataType.Coded;
247
- }
248
-
249
139
  isGroupSubjectTypeFilter() {
250
140
  return this.type === _CustomFilter.default.type.GroupSubject;
251
141
  }
252
142
 
253
- isSubjectTypeFilter() {
254
- return this.type === _CustomFilter.default.type.SubjectType;
255
- }
256
-
257
143
  isValid() {
258
144
  const valid = !_lodash.default.isNil(this.type);
259
145
  if (!valid) return valid;
@@ -263,7 +149,6 @@ class DashboardFilterConfig {
263
149
  toServerRequest() {
264
150
  const request = {
265
151
  type: this.type,
266
- subjectTypeUUID: this.subjectType && this.subjectType.uuid,
267
152
  widget: this.widget
268
153
  };
269
154
  if (this.isConceptTypeFilter()) request.observationBasedFilter = this.observationBasedFilter.toServerRequest();else if (this.isGroupSubjectTypeFilter()) request.groupSubjectTypeFilter = this.groupSubjectTypeFilter.toServerRequest();
@@ -290,12 +175,6 @@ class DashboardFilterConfig {
290
175
  return [RegistrationDate, EnrolmentDate, ProgramEncounterDate, EncounterDate].includes(this.type) || this.isConceptTypeFilter() && this.observationBasedFilter.isWidgetRequired();
291
176
  }
292
177
 
293
- setSubjectType(subjectType) {
294
- if (_lodash.default.get(subjectType, "uuid") !== _lodash.default.get(this.subjectType, "uuid")) {
295
- this.subjectType = subjectType;
296
- }
297
- }
298
-
299
178
  willObservationBeInScopeOfProgramEnrolment() {
300
179
  return this.isConceptTypeFilter() && this.observationBasedFilter.willObservationBeInScopeOfProgramEnrolment();
301
180
  }
@@ -307,11 +186,11 @@ class DashboardFilterConfig {
307
186
  validate(filterValue) {
308
187
  const inputDataType = this.getInputDataType();
309
188
 
310
- if (this.isDateRangeFilterType()) {
189
+ if ([_Concept.default.dataType.Date, _Concept.default.dataType.DateTime].includes(inputDataType) && this.widget === _CustomFilter.default.widget.Range) {
311
190
  return _DateTimeUtil.default.validateDateRange(filterValue.minValue, filterValue.maxValue);
312
191
  }
313
192
 
314
- if (this.isTimeRangeFilterType()) {
193
+ if (_Concept.default.dataType.Time === inputDataType && this.widget === _CustomFilter.default.widget.Range) {
315
194
  return _DateTimeUtil.default.validateTimeRange(filterValue.minValue, filterValue.maxValue);
316
195
  }
317
196
 
@@ -321,7 +200,6 @@ class DashboardFilterConfig {
321
200
  clone() {
322
201
  const clone = new DashboardFilterConfig();
323
202
  clone.type = this.type;
324
- clone.subjectType = this.subjectType;
325
203
  clone.widget = this.widget;
326
204
  clone.groupSubjectTypeFilter = this.groupSubjectTypeFilter;
327
205
  clone.observationBasedFilter = this.observationBasedFilter;
@@ -330,10 +208,5 @@ class DashboardFilterConfig {
330
208
 
331
209
  }
332
210
 
333
- _defineProperty(DashboardFilterConfig, "dataTypes", {
334
- array: "array",
335
- formMetaData: "formMetaData"
336
- });
337
-
338
211
  var _default = DashboardFilterConfig;
339
212
  exports.default = _default;
@@ -99,10 +99,6 @@ class MetaDataService {
99
99
  return _lodash.default.filter(formMappings, formMapping => formMapping.formType === _Form.default.formTypes.ProgramEncounter || formMapping.formType === _Form.default.formTypes.ProgramEncounterCancellation);
100
100
  }
101
101
 
102
- static getProgramEncounterFormMappingsForFormType(formMappings, formType) {
103
- return _lodash.default.filter(formMappings, formMapping => formMapping.formType === formType);
104
- }
105
-
106
102
  static getProgramsForSubjectType(allPrograms, subjectType, formMappings) {
107
103
  if (_lodash.default.isNil(subjectType)) return allPrograms;
108
104
 
@@ -120,9 +116,9 @@ class MetaDataService {
120
116
  }
121
117
 
122
118
  static getEncounterTypesForPrograms(allEncounterTypes, programs, formMappings) {
123
- const programEncounterTypeMappings = MetaDataService.getProgramEncounterFormMappingsForFormType(formMappings, _Form.default.formTypes.ProgramEncounter);
119
+ const programEncounterTypeMappings = MetaDataService.getProgramEncounterFormMappings(formMappings);
124
120
 
125
- const encounterTypeMappingsForPrograms = _lodash.default.filter(programEncounterTypeMappings, formMapping => _lodash.default.some(programs, program => formMapping.programUUID === program.uuid));
121
+ const encounterTypeMappingsForPrograms = _lodash.default.intersectionWith(programEncounterTypeMappings, programs, (etMapping, program) => etMapping.programUUID === program.uuid);
126
122
 
127
123
  return encounterTypeMappingsForPrograms.map(x => _lodash.default.find(allEncounterTypes, et => et.uuid === x.encounterTypeUUID));
128
124
  }
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.85",
4
+ "version": "1.31.87",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _lodash = _interopRequireDefault(require("lodash"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- // AddressLevel = Location
13
- class Locations {
14
- static getUniqueLevels(locations) {
15
- return _lodash.default.uniq(locations.map(x => x.level));
16
- }
17
-
18
- }
19
-
20
- var _default = Locations;
21
- exports.default = _default;
@@ -1,37 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _lodash = _interopRequireDefault(require("lodash"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- 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; }
13
-
14
- class Range {
15
- constructor(minValue, maxValue) {
16
- _defineProperty(this, "minValue", void 0);
17
-
18
- _defineProperty(this, "maxValue", void 0);
19
-
20
- this.minValue = minValue;
21
- this.maxValue = maxValue;
22
- }
23
-
24
- static empty() {
25
- return new Range(null, null);
26
- }
27
-
28
- isEmpty() {
29
- return _lodash.default.isNil(this.minValue) || _lodash.default.isNil(this.maxValue);
30
- }
31
-
32
- }
33
-
34
- _defineProperty(Range, "DateRange", "DateRange");
35
-
36
- var _default = Range;
37
- exports.default = _default;