openchs-models 1.31.79 → 1.31.81

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,49 +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;
61
+ }
62
+
63
+ set ruleInputJSON(x) {
64
+ this.that.ruleInputJSON = x;
49
65
  }
50
66
 
51
- set dashboard(x) {
52
- this.that.dashboard = this.fromObject(x);
67
+ get transformedFiltersJSON() {
68
+ return this.that.transformedFiltersJSON;
53
69
  }
54
70
 
55
- static create(uuid, updatedAt, selectedValuesJSON = '{}', filterApplied) {
71
+ set transformedFiltersJSON(x) {
72
+ this.that.transformedFiltersJSON = x;
73
+ }
74
+
75
+ static create(uuid, checksum, updatedAt, selectedValuesJSON, filterApplied, filterErrorsJSON, ruleInputJSON, transformedFiltersJSON) {
56
76
  const customDashboardCache = new CustomDashboardCache();
57
77
  customDashboardCache.uuid = uuid;
78
+ customDashboardCache.checksum = checksum;
58
79
  customDashboardCache.updatedAt = updatedAt;
59
80
  customDashboardCache.selectedValuesJSON = selectedValuesJSON;
60
81
  customDashboardCache.filterApplied = filterApplied;
82
+ customDashboardCache.filterErrorsJSON = filterErrorsJSON;
83
+ customDashboardCache.ruleInputJSON = ruleInputJSON;
84
+ customDashboardCache.transformedFiltersJSON = transformedFiltersJSON;
61
85
  return customDashboardCache;
62
86
  }
63
87
 
64
- static newInstance(dashboard) {
65
- const customDashboardCache = new CustomDashboardCache();
66
- customDashboardCache.uuid = _General.default.randomUUID();
67
- customDashboardCache.dashboard = dashboard;
68
- customDashboardCache.reset();
69
- 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;
97
+ }
98
+
99
+ static createEmptyInstance() {
100
+ return new CustomDashboardCache();
70
101
  }
71
102
 
72
- reset() {
73
- this.filterApplied = false;
74
- this.selectedValuesJSON = JSON.stringify({});
75
- this.updatedAt = new Date();
103
+ getChecksum() {
104
+ return this.checksum;
76
105
  }
77
106
 
78
107
  getSelectedValues() {
79
- return JSON.parse(this.selectedValuesJSON);
108
+ return this.selectedValuesJSON && JSON.parse(this.selectedValuesJSON) || {};
80
109
  }
81
110
 
82
- clone() {
83
- const customDashboardCache = new CustomDashboardCache();
84
- customDashboardCache.uuid = this.uuid;
85
- customDashboardCache.dashboard = this.dashboard;
86
- customDashboardCache.updatedAt = this.updatedAt;
87
- customDashboardCache.selectedValuesJSON = this.selectedValuesJSON;
88
- customDashboardCache.filterApplied = this.filterApplied;
89
- 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
+ };
90
129
  }
91
130
 
92
131
  }
@@ -96,10 +135,16 @@ _defineProperty(CustomDashboardCache, "schema", {
96
135
  primaryKey: "uuid",
97
136
  properties: {
98
137
  uuid: "string",
99
- dashboard: "Dashboard",
138
+ checksum: "string",
100
139
  updatedAt: "date",
101
140
  selectedValuesJSON: "string",
102
- filterApplied: "bool"
141
+ filterApplied: {
142
+ type: "bool",
143
+ default: false
144
+ },
145
+ filterErrorsJSON: "string",
146
+ ruleInputJSON: "string",
147
+ transformedFiltersJSON: "string"
103
148
  }
104
149
  });
105
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", {
@@ -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", {
@@ -15,25 +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
- return reportCard;
35
- }
22
+ function throwInvalidIndexError(index, reportCardsLength) {
23
+ throw new Error(`Invalid index ${index} specified for reportCard with length ${reportCardsLength}`);
24
+ }
36
25
 
26
+ class ReportCard extends _BaseEntity.default {
37
27
  constructor(that = null) {
38
28
  super(that);
39
29
  }
@@ -106,30 +96,6 @@ class ReportCard extends _BaseEntity.default {
106
96
  get textColor() {
107
97
  return _lodash.default.isNil(this.standardReportCardType) ? '#ffffff' : this.standardReportCardType.textColor;
108
98
  }
109
-
110
- get standardReportCardInputSubjectTypes() {
111
- return this.toEntityList("standardReportCardInputSubjectTypes", _SubjectType.default);
112
- }
113
-
114
- set standardReportCardInputSubjectTypes(x) {
115
- this.that.standardReportCardInputSubjectTypes = this.fromEntityList(x);
116
- }
117
-
118
- get standardReportCardInputPrograms() {
119
- return this.toEntityList("standardReportCardInputPrograms", _Program.default);
120
- }
121
-
122
- set standardReportCardInputPrograms(x) {
123
- this.that.standardReportCardInputPrograms = this.fromEntityList(x);
124
- }
125
-
126
- get standardReportCardInputEncounterTypes() {
127
- return this.toEntityList("standardReportCardInputEncounterTypes", _EncounterType.default);
128
- }
129
-
130
- set standardReportCardInputEncounterTypes(x) {
131
- this.that.standardReportCardInputEncounterTypes = this.fromEntityList(x);
132
- }
133
99
  /**
134
100
  * Helper method used to generate unique key value for Nested Report Cards using UUID and Index of the Report Card.
135
101
  * The Nested Report Card's query responses would be mapped to the corresponding Dashboard Report cards using the UUID and Index.
@@ -156,18 +122,9 @@ class ReportCard extends _BaseEntity.default {
156
122
  }
157
123
 
158
124
  static fromResource(resource, entityService) {
159
- 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"]);
160
126
 
161
127
  reportCard.standardReportCardType = entityService.findByKey("uuid", _ResourceUtil.default.getUUIDFor(resource, "standardReportCardUUID"), _StandardReportCardType.default.schema.name);
162
- resource.standardReportCardInputSubjectTypes.forEach(uuid => {
163
- reportCard.standardReportCardInputSubjectTypes.push(entityService.findByUUID(uuid, _SubjectType.default.schema.name));
164
- });
165
- resource.standardReportCardInputPrograms.forEach(uuid => {
166
- reportCard.standardReportCardInputPrograms.push(entityService.findByUUID(uuid, _Program.default.schema.name));
167
- });
168
- resource.standardReportCardInputEncounterTypes.forEach(uuid => {
169
- reportCard.standardReportCardInputEncounterTypes.push(entityService.findByUUID(uuid, _EncounterType.default.schema.name));
170
- });
171
128
  return reportCard;
172
129
  }
173
130
 
@@ -175,14 +132,6 @@ class ReportCard extends _BaseEntity.default {
175
132
  return _lodash.default.isNil(this.standardReportCardType) ? false : this.standardReportCardType.isTaskType();
176
133
  }
177
134
 
178
- isStandardReportType() {
179
- return !_lodash.default.isNil(this.standardReportCardType);
180
- }
181
-
182
- isSubjectTypeFilterSupported() {
183
- return this.isStandardReportType() && this.standardReportCardType.isSubjectTypeFilterSupported();
184
- }
185
-
186
135
  }
187
136
 
188
137
  _defineProperty(ReportCard, "schema", {
@@ -217,20 +166,8 @@ _defineProperty(ReportCard, "schema", {
217
166
  type: "int",
218
167
  default: 1,
219
168
  optional: true
220
- },
221
- //Used only by nested ReportCards
222
- standardReportCardInputSubjectTypes: {
223
- type: "list",
224
- objectType: "SubjectType"
225
- },
226
- standardReportCardInputPrograms: {
227
- type: "list",
228
- objectType: "Program"
229
- },
230
- standardReportCardInputEncounterTypes: {
231
- type: "list",
232
- objectType: "EncounterType"
233
- }
169
+ } //Used only by nested ReportCards
170
+
234
171
  }
235
172
  });
236
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: 191,
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
  }
@@ -118,10 +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].includes(this.name);
123
- }
124
-
125
121
  }
126
122
 
127
123
  _defineProperty(StandardReportCardType, "schema", {
@@ -111,8 +111,6 @@ const dateFilterTypes = [_CustomFilter.default.type.RegistrationDate, _CustomFil
111
111
 
112
112
  class DashboardFilterConfig {
113
113
  constructor() {
114
- _defineProperty(this, "subjectType", void 0);
115
-
116
114
  _defineProperty(this, "type", void 0);
117
115
 
118
116
  _defineProperty(this, "widget", void 0);
@@ -142,10 +140,6 @@ class DashboardFilterConfig {
142
140
  return this.type === _CustomFilter.default.type.GroupSubject;
143
141
  }
144
142
 
145
- isSubjectTypeFilter() {
146
- return this.type === _CustomFilter.default.type.SubjectType;
147
- }
148
-
149
143
  isValid() {
150
144
  const valid = !_lodash.default.isNil(this.type);
151
145
  if (!valid) return valid;
@@ -155,7 +149,6 @@ class DashboardFilterConfig {
155
149
  toServerRequest() {
156
150
  const request = {
157
151
  type: this.type,
158
- subjectTypeUUID: this.subjectType && this.subjectType.uuid,
159
152
  widget: this.widget
160
153
  };
161
154
  if (this.isConceptTypeFilter()) request.observationBasedFilter = this.observationBasedFilter.toServerRequest();else if (this.isGroupSubjectTypeFilter()) request.groupSubjectTypeFilter = this.groupSubjectTypeFilter.toServerRequest();
@@ -182,12 +175,6 @@ class DashboardFilterConfig {
182
175
  return [RegistrationDate, EnrolmentDate, ProgramEncounterDate, EncounterDate].includes(this.type) || this.isConceptTypeFilter() && this.observationBasedFilter.isWidgetRequired();
183
176
  }
184
177
 
185
- setSubjectType(subjectType) {
186
- if (_lodash.default.get(subjectType, "uuid") !== _lodash.default.get(this.subjectType, "uuid")) {
187
- this.subjectType = subjectType;
188
- }
189
- }
190
-
191
178
  willObservationBeInScopeOfProgramEnrolment() {
192
179
  return this.isConceptTypeFilter() && this.observationBasedFilter.willObservationBeInScopeOfProgramEnrolment();
193
180
  }
@@ -213,7 +200,6 @@ class DashboardFilterConfig {
213
200
  clone() {
214
201
  const clone = new DashboardFilterConfig();
215
202
  clone.type = this.type;
216
- clone.subjectType = this.subjectType;
217
203
  clone.widget = this.widget;
218
204
  clone.groupSubjectTypeFilter = this.groupSubjectTypeFilter;
219
205
  clone.observationBasedFilter = this.observationBasedFilter;
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.79",
4
+ "version": "1.31.81",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",