openchs-models 1.31.83 → 1.31.85
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.
|
@@ -15,8 +15,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
15
15
|
|
|
16
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; }
|
|
17
17
|
|
|
18
|
-
const EmptyObjectHash = "99914b932bd37a50b983c5e7c90ae93b";
|
|
19
|
-
|
|
20
18
|
class CustomDashboardCache extends _BaseEntity.default {
|
|
21
19
|
constructor(that = null) {
|
|
22
20
|
super(that);
|
|
@@ -71,18 +69,18 @@ class CustomDashboardCache extends _BaseEntity.default {
|
|
|
71
69
|
return customDashboardCache;
|
|
72
70
|
}
|
|
73
71
|
|
|
74
|
-
static newInstance(dashboard) {
|
|
72
|
+
static newInstance(dashboard, dashboardFiltersHash) {
|
|
75
73
|
const customDashboardCache = new CustomDashboardCache();
|
|
76
74
|
customDashboardCache.uuid = _General.default.randomUUID();
|
|
77
75
|
customDashboardCache.dashboard = dashboard;
|
|
78
|
-
customDashboardCache.reset();
|
|
76
|
+
customDashboardCache.reset(dashboardFiltersHash);
|
|
79
77
|
return customDashboardCache;
|
|
80
78
|
}
|
|
81
79
|
|
|
82
|
-
reset() {
|
|
80
|
+
reset(dashboardFiltersHash) {
|
|
83
81
|
this.filterApplied = false;
|
|
84
82
|
this.selectedValuesJSON = JSON.stringify({});
|
|
85
|
-
this.dashboardFiltersHash =
|
|
83
|
+
this.dashboardFiltersHash = dashboardFiltersHash;
|
|
86
84
|
this.updatedAt = new Date();
|
|
87
85
|
}
|
|
88
86
|
|
package/dist/ReportCard.js
CHANGED
|
@@ -31,6 +31,7 @@ class ReportCard extends _BaseEntity.default {
|
|
|
31
31
|
reportCard.standardReportCardInputSubjectTypes = [];
|
|
32
32
|
reportCard.standardReportCardInputPrograms = [];
|
|
33
33
|
reportCard.standardReportCardInputEncounterTypes = [];
|
|
34
|
+
reportCard.standardReportCardInputRecentDuration = null;
|
|
34
35
|
return reportCard;
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -130,6 +131,14 @@ class ReportCard extends _BaseEntity.default {
|
|
|
130
131
|
set standardReportCardInputEncounterTypes(x) {
|
|
131
132
|
this.that.standardReportCardInputEncounterTypes = this.fromEntityList(x);
|
|
132
133
|
}
|
|
134
|
+
|
|
135
|
+
get standardReportCardInputRecentDurationJSON() {
|
|
136
|
+
return JSON.parse(this.that.standardReportCardInputRecentDurationJSON);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
set standardReportCardInputRecentDurationJSON(x) {
|
|
140
|
+
this.that.standardReportCardInputRecentDurationJSON = x;
|
|
141
|
+
}
|
|
133
142
|
/**
|
|
134
143
|
* Helper method used to generate unique key value for Nested Report Cards using UUID and Index of the Report Card.
|
|
135
144
|
* The Nested Report Card's query responses would be mapped to the corresponding Dashboard Report cards using the UUID and Index.
|
|
@@ -168,6 +177,7 @@ class ReportCard extends _BaseEntity.default {
|
|
|
168
177
|
resource.standardReportCardInputEncounterTypes.forEach(uuid => {
|
|
169
178
|
reportCard.standardReportCardInputEncounterTypes.push(entityService.findByUUID(uuid, _EncounterType.default.schema.name));
|
|
170
179
|
});
|
|
180
|
+
reportCard.standardReportCardInputRecentDurationJSON = resource.standardReportCardInputRecentDuration;
|
|
171
181
|
return reportCard;
|
|
172
182
|
}
|
|
173
183
|
|
|
@@ -183,6 +193,10 @@ class ReportCard extends _BaseEntity.default {
|
|
|
183
193
|
return this.isStandardReportType() && this.standardReportCardType.isSubjectTypeFilterSupported();
|
|
184
194
|
}
|
|
185
195
|
|
|
196
|
+
isRecentType() {
|
|
197
|
+
return this.isStandardReportType() && this.standardReportCardType.isRecentType();
|
|
198
|
+
}
|
|
199
|
+
|
|
186
200
|
}
|
|
187
201
|
|
|
188
202
|
_defineProperty(ReportCard, "schema", {
|
|
@@ -230,6 +244,10 @@ _defineProperty(ReportCard, "schema", {
|
|
|
230
244
|
standardReportCardInputEncounterTypes: {
|
|
231
245
|
type: "list",
|
|
232
246
|
objectType: "EncounterType"
|
|
247
|
+
},
|
|
248
|
+
standardReportCardInputRecentDurationJSON: {
|
|
249
|
+
type: "string",
|
|
250
|
+
optional: true
|
|
233
251
|
}
|
|
234
252
|
}
|
|
235
253
|
});
|
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:
|
|
282
|
+
schemaVersion: 193,
|
|
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.`);
|
|
@@ -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.
|
|
84
|
+
return [StandardReportCardType.type.ScheduledVisits, StandardReportCardType.type.OverdueVisits, StandardReportCardType.type.RecentRegistrations, StandardReportCardType.type.RecentEnrolments, StandardReportCardType.type.RecentVisits, StandardReportCardType.type.Total];
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
isApprovalType() {
|
|
@@ -119,7 +119,11 @@ class StandardReportCardType extends _BaseEntity.default {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
isSubjectTypeFilterSupported() {
|
|
122
|
-
return [StandardReportCardType.type.ScheduledVisits, StandardReportCardType.type.OverdueVisits].includes(this.name);
|
|
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);
|
|
123
127
|
}
|
|
124
128
|
|
|
125
129
|
}
|
|
@@ -147,9 +151,9 @@ _defineProperty(StandardReportCardType, "type", {
|
|
|
147
151
|
Rejected: "Rejected",
|
|
148
152
|
ScheduledVisits: "Scheduled visits",
|
|
149
153
|
OverdueVisits: "Overdue visits",
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
154
|
+
RecentRegistrations: "Recent registrations",
|
|
155
|
+
RecentEnrolments: "Recent enrolments",
|
|
156
|
+
RecentVisits: "Recent visits",
|
|
153
157
|
Total: "Total",
|
|
154
158
|
Comments: "Comments",
|
|
155
159
|
CallTasks: "Call tasks",
|
|
@@ -157,6 +161,8 @@ _defineProperty(StandardReportCardType, "type", {
|
|
|
157
161
|
DueChecklist: "Due checklist"
|
|
158
162
|
});
|
|
159
163
|
|
|
164
|
+
_defineProperty(StandardReportCardType, "recentCardDurationUnits", ["days", "weeks", "months"]);
|
|
165
|
+
|
|
160
166
|
const typeToStatusMap = {
|
|
161
167
|
[StandardReportCardType.type.PendingApproval]: _ApprovalStatus.default.statuses.Pending,
|
|
162
168
|
[StandardReportCardType.type.Approved]: _ApprovalStatus.default.statuses.Approved,
|
|
@@ -15,11 +15,21 @@ var _DateTimeUtil = _interopRequireDefault(require("../utility/DateTimeUtil"));
|
|
|
15
15
|
|
|
16
16
|
var _Range = _interopRequireDefault(require("./Range"));
|
|
17
17
|
|
|
18
|
+
var _Gender = _interopRequireDefault(require("../Gender"));
|
|
19
|
+
|
|
20
|
+
var _AddressLevel = _interopRequireDefault(require("../AddressLevel"));
|
|
21
|
+
|
|
22
|
+
var _Individual = _interopRequireDefault(require("../Individual"));
|
|
23
|
+
|
|
18
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
25
|
|
|
20
26
|
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; }
|
|
21
27
|
|
|
22
28
|
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
|
+
};
|
|
23
33
|
|
|
24
34
|
class ObservationBasedFilter {
|
|
25
35
|
constructor() {
|
|
@@ -44,6 +54,15 @@ class ObservationBasedFilter {
|
|
|
44
54
|
return !_lodash.default.isNil(concept) && (!_lodash.default.isEmpty(programs) || !_lodash.default.isEmpty(encounterTypes) || this.scope === _CustomFilter.default.scope.Registration);
|
|
45
55
|
}
|
|
46
56
|
|
|
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
|
+
|
|
47
66
|
toServerRequest() {
|
|
48
67
|
return {
|
|
49
68
|
scope: this.scope,
|
|
@@ -110,6 +129,23 @@ class GroupSubjectTypeFilter {
|
|
|
110
129
|
|
|
111
130
|
exports.GroupSubjectTypeFilter = GroupSubjectTypeFilter;
|
|
112
131
|
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
|
+
}
|
|
113
149
|
|
|
114
150
|
class DashboardFilterConfig {
|
|
115
151
|
constructor() {
|
|
@@ -124,24 +160,92 @@ class DashboardFilterConfig {
|
|
|
124
160
|
_defineProperty(this, "observationBasedFilter", void 0);
|
|
125
161
|
}
|
|
126
162
|
|
|
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
|
+
|
|
127
177
|
getInputDataType() {
|
|
128
178
|
if (this.isConceptTypeFilter()) {
|
|
129
179
|
return this.observationBasedFilter.concept.datatype;
|
|
130
|
-
} else if (this.
|
|
131
|
-
return
|
|
180
|
+
} else if ([_CustomFilter.default.type.Gender, _CustomFilter.default.type.Address, _CustomFilter.default.type.GroupSubject].includes(this.type)) {
|
|
181
|
+
return DashboardFilterConfig.dataTypes.array;
|
|
132
182
|
} else if (dateFilterTypes.includes(this.type) && this.widget === _CustomFilter.default.widget.Default) {
|
|
133
183
|
return _Concept.default.dataType.Date;
|
|
134
184
|
} else if (dateFilterTypes.includes(this.type) && this.widget === _CustomFilter.default.widget.Range) {
|
|
135
185
|
return _Range.default.DateRange;
|
|
136
|
-
} else {
|
|
137
|
-
return
|
|
186
|
+
} else if (this.type === _CustomFilter.default.type.SubjectType) {
|
|
187
|
+
return DashboardFilterConfig.dataTypes.formMetaData;
|
|
138
188
|
}
|
|
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);
|
|
139
239
|
}
|
|
140
240
|
|
|
141
241
|
isConceptTypeFilter() {
|
|
142
242
|
return this.type === _CustomFilter.default.type.Concept;
|
|
143
243
|
}
|
|
144
244
|
|
|
245
|
+
isNonCodedObservationDataType() {
|
|
246
|
+
return this.isConceptTypeFilter() && this.observationBasedFilter.concept.datatype !== _Concept.default.dataType.Coded;
|
|
247
|
+
}
|
|
248
|
+
|
|
145
249
|
isGroupSubjectTypeFilter() {
|
|
146
250
|
return this.type === _CustomFilter.default.type.GroupSubject;
|
|
147
251
|
}
|
|
@@ -203,10 +307,14 @@ class DashboardFilterConfig {
|
|
|
203
307
|
validate(filterValue) {
|
|
204
308
|
const inputDataType = this.getInputDataType();
|
|
205
309
|
|
|
206
|
-
if (
|
|
310
|
+
if (this.isDateRangeFilterType()) {
|
|
207
311
|
return _DateTimeUtil.default.validateDateRange(filterValue.minValue, filterValue.maxValue);
|
|
208
312
|
}
|
|
209
313
|
|
|
314
|
+
if (this.isTimeRangeFilterType()) {
|
|
315
|
+
return _DateTimeUtil.default.validateTimeRange(filterValue.minValue, filterValue.maxValue);
|
|
316
|
+
}
|
|
317
|
+
|
|
210
318
|
return [true];
|
|
211
319
|
}
|
|
212
320
|
|
|
@@ -222,5 +330,10 @@ class DashboardFilterConfig {
|
|
|
222
330
|
|
|
223
331
|
}
|
|
224
332
|
|
|
333
|
+
_defineProperty(DashboardFilterConfig, "dataTypes", {
|
|
334
|
+
array: "array",
|
|
335
|
+
formMetaData: "formMetaData"
|
|
336
|
+
});
|
|
337
|
+
|
|
225
338
|
var _default = DashboardFilterConfig;
|
|
226
339
|
exports.default = _default;
|
|
@@ -99,6 +99,10 @@ 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
|
+
|
|
102
106
|
static getProgramsForSubjectType(allPrograms, subjectType, formMappings) {
|
|
103
107
|
if (_lodash.default.isNil(subjectType)) return allPrograms;
|
|
104
108
|
|
|
@@ -116,9 +120,9 @@ class MetaDataService {
|
|
|
116
120
|
}
|
|
117
121
|
|
|
118
122
|
static getEncounterTypesForPrograms(allEncounterTypes, programs, formMappings) {
|
|
119
|
-
const programEncounterTypeMappings = MetaDataService.
|
|
123
|
+
const programEncounterTypeMappings = MetaDataService.getProgramEncounterFormMappingsForFormType(formMappings, _Form.default.formTypes.ProgramEncounter);
|
|
120
124
|
|
|
121
|
-
const encounterTypeMappingsForPrograms = _lodash.default.
|
|
125
|
+
const encounterTypeMappingsForPrograms = _lodash.default.filter(programEncounterTypeMappings, formMapping => _lodash.default.some(programs, program => formMapping.programUUID === program.uuid));
|
|
122
126
|
|
|
123
127
|
return encounterTypeMappingsForPrograms.map(x => _lodash.default.find(allEncounterTypes, et => et.uuid === x.encounterTypeUUID));
|
|
124
128
|
}
|