openchs-models 1.31.83 → 1.31.84
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
|
|
|
@@ -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
|
}
|