openchs-models 1.31.81 → 1.31.83
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.
- package/dist/CustomDashboardCache.js +39 -71
- package/dist/CustomFilter.js +2 -1
- package/dist/Dashboard.js +8 -0
- package/dist/MediaQueue.js +1 -15
- package/dist/ReportCard.js +70 -7
- package/dist/Schema.js +5 -1
- package/dist/StandardReportCardType.js +4 -0
- package/dist/index.js +16 -0
- package/dist/location/Locations.js +21 -0
- package/dist/reports/DashboardFilterConfig.js +20 -6
- package/dist/reports/Range.js +37 -0
- package/package.json +1 -1
|
@@ -7,23 +7,21 @@ 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
|
+
|
|
10
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
15
|
|
|
12
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; }
|
|
13
17
|
|
|
18
|
+
const EmptyObjectHash = "99914b932bd37a50b983c5e7c90ae93b";
|
|
19
|
+
|
|
14
20
|
class CustomDashboardCache extends _BaseEntity.default {
|
|
15
21
|
constructor(that = null) {
|
|
16
22
|
super(that);
|
|
17
23
|
}
|
|
18
24
|
|
|
19
|
-
get checksum() {
|
|
20
|
-
return this.that.checksum;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
set checksum(x) {
|
|
24
|
-
this.that.checksum = x;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
25
|
get updatedAt() {
|
|
28
26
|
return this.that.updatedAt;
|
|
29
27
|
}
|
|
@@ -48,84 +46,59 @@ class CustomDashboardCache extends _BaseEntity.default {
|
|
|
48
46
|
this.that.filterApplied = x;
|
|
49
47
|
}
|
|
50
48
|
|
|
51
|
-
get
|
|
52
|
-
return this.
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
set filterErrorsJSON(x) {
|
|
56
|
-
this.that.filterErrorsJSON = x;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
get ruleInputJSON() {
|
|
60
|
-
return this.that.ruleInputJSON;
|
|
49
|
+
get dashboard() {
|
|
50
|
+
return this.toEntity("dashboard", _Dashboard.default);
|
|
61
51
|
}
|
|
62
52
|
|
|
63
|
-
set
|
|
64
|
-
this.that.
|
|
53
|
+
set dashboard(x) {
|
|
54
|
+
this.that.dashboard = this.fromObject(x);
|
|
65
55
|
}
|
|
66
56
|
|
|
67
|
-
get
|
|
68
|
-
return this.that.
|
|
57
|
+
get dashboardFiltersHash() {
|
|
58
|
+
return this.that.dashboardFiltersHash;
|
|
69
59
|
}
|
|
70
60
|
|
|
71
|
-
set
|
|
72
|
-
this.that.
|
|
61
|
+
set dashboardFiltersHash(x) {
|
|
62
|
+
this.that.dashboardFiltersHash = x;
|
|
73
63
|
}
|
|
74
64
|
|
|
75
|
-
static create(uuid,
|
|
65
|
+
static create(uuid, updatedAt, selectedValuesJSON = '{}', filterApplied) {
|
|
76
66
|
const customDashboardCache = new CustomDashboardCache();
|
|
77
67
|
customDashboardCache.uuid = uuid;
|
|
78
|
-
customDashboardCache.checksum = checksum;
|
|
79
68
|
customDashboardCache.updatedAt = updatedAt;
|
|
80
69
|
customDashboardCache.selectedValuesJSON = selectedValuesJSON;
|
|
81
70
|
customDashboardCache.filterApplied = filterApplied;
|
|
82
|
-
customDashboardCache.filterErrorsJSON = filterErrorsJSON;
|
|
83
|
-
customDashboardCache.ruleInputJSON = ruleInputJSON;
|
|
84
|
-
customDashboardCache.transformedFiltersJSON = transformedFiltersJSON;
|
|
85
71
|
return customDashboardCache;
|
|
86
72
|
}
|
|
87
73
|
|
|
88
|
-
static
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
selectedGenders: state.selectedGenders
|
|
95
|
-
};
|
|
96
|
-
return filterCache;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
static createEmptyInstance() {
|
|
100
|
-
return new CustomDashboardCache();
|
|
74
|
+
static newInstance(dashboard) {
|
|
75
|
+
const customDashboardCache = new CustomDashboardCache();
|
|
76
|
+
customDashboardCache.uuid = _General.default.randomUUID();
|
|
77
|
+
customDashboardCache.dashboard = dashboard;
|
|
78
|
+
customDashboardCache.reset();
|
|
79
|
+
return customDashboardCache;
|
|
101
80
|
}
|
|
102
81
|
|
|
103
|
-
|
|
104
|
-
|
|
82
|
+
reset() {
|
|
83
|
+
this.filterApplied = false;
|
|
84
|
+
this.selectedValuesJSON = JSON.stringify({});
|
|
85
|
+
this.dashboardFiltersHash = EmptyObjectHash;
|
|
86
|
+
this.updatedAt = new Date();
|
|
105
87
|
}
|
|
106
88
|
|
|
107
89
|
getSelectedValues() {
|
|
108
|
-
return
|
|
109
|
-
}
|
|
110
|
-
|
|
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
|
-
};
|
|
90
|
+
return JSON.parse(this.selectedValuesJSON);
|
|
119
91
|
}
|
|
120
92
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
93
|
+
clone() {
|
|
94
|
+
const customDashboardCache = new CustomDashboardCache();
|
|
95
|
+
customDashboardCache.uuid = this.uuid;
|
|
96
|
+
customDashboardCache.dashboard = this.dashboard;
|
|
97
|
+
customDashboardCache.updatedAt = this.updatedAt;
|
|
98
|
+
customDashboardCache.selectedValuesJSON = this.selectedValuesJSON;
|
|
99
|
+
customDashboardCache.filterApplied = this.filterApplied;
|
|
100
|
+
customDashboardCache.dashboardFiltersHash = this.dashboardFiltersHash;
|
|
101
|
+
return customDashboardCache;
|
|
129
102
|
}
|
|
130
103
|
|
|
131
104
|
}
|
|
@@ -135,16 +108,11 @@ _defineProperty(CustomDashboardCache, "schema", {
|
|
|
135
108
|
primaryKey: "uuid",
|
|
136
109
|
properties: {
|
|
137
110
|
uuid: "string",
|
|
138
|
-
|
|
111
|
+
dashboard: "Dashboard",
|
|
139
112
|
updatedAt: "date",
|
|
140
113
|
selectedValuesJSON: "string",
|
|
141
|
-
filterApplied:
|
|
142
|
-
|
|
143
|
-
default: false
|
|
144
|
-
},
|
|
145
|
-
filterErrorsJSON: "string",
|
|
146
|
-
ruleInputJSON: "string",
|
|
147
|
-
transformedFiltersJSON: "string"
|
|
114
|
+
filterApplied: "bool",
|
|
115
|
+
dashboardFiltersHash: "string"
|
|
148
116
|
}
|
|
149
117
|
});
|
|
150
118
|
|
package/dist/CustomFilter.js
CHANGED
|
@@ -41,7 +41,8 @@ _defineProperty(CustomFilter, "type", {
|
|
|
41
41
|
EncounterDate: "EncounterDate",
|
|
42
42
|
Address: "Address",
|
|
43
43
|
Concept: "Concept",
|
|
44
|
-
GroupSubject: "GroupSubject"
|
|
44
|
+
GroupSubject: "GroupSubject",
|
|
45
|
+
SubjectType: "SubjectType"
|
|
45
46
|
});
|
|
46
47
|
|
|
47
48
|
_defineProperty(CustomFilter, "scope", {
|
package/dist/Dashboard.js
CHANGED
|
@@ -36,6 +36,14 @@ 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
|
+
|
|
39
47
|
static fromResource(resource) {
|
|
40
48
|
return _General.default.assignFields(resource, new Dashboard(), ["uuid", "name", "description", "voided"]);
|
|
41
49
|
}
|
package/dist/MediaQueue.js
CHANGED
|
@@ -9,8 +9,6 @@ var _General = _interopRequireDefault(require("./utility/General"));
|
|
|
9
9
|
|
|
10
10
|
var _BaseEntity = _interopRequireDefault(require("./BaseEntity"));
|
|
11
11
|
|
|
12
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
13
|
-
|
|
14
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
13
|
|
|
16
14
|
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; }
|
|
@@ -69,7 +67,7 @@ class MediaQueue extends _BaseEntity.default {
|
|
|
69
67
|
}
|
|
70
68
|
|
|
71
69
|
static create(entityUUID, entityName, fileName, type, entityTargetField, conceptUUID, uuid = _General.default.randomUUID()) {
|
|
72
|
-
|
|
70
|
+
var mediaQueue = new MediaQueue();
|
|
73
71
|
mediaQueue.entityUUID = entityUUID;
|
|
74
72
|
mediaQueue.uuid = uuid;
|
|
75
73
|
mediaQueue.entityName = entityName;
|
|
@@ -92,18 +90,6 @@ class MediaQueue extends _BaseEntity.default {
|
|
|
92
90
|
return mediaQueueItem;
|
|
93
91
|
}
|
|
94
92
|
|
|
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
|
-
|
|
107
93
|
}
|
|
108
94
|
|
|
109
95
|
_defineProperty(MediaQueue, "schema", {
|
package/dist/ReportCard.js
CHANGED
|
@@ -15,15 +15,25 @@ 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
|
+
|
|
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
|
-
function throwInvalidIndexError(index, reportCardsLength) {
|
|
23
|
-
throw new Error(`Invalid index ${index} specified for reportCard with length ${reportCardsLength}`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
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
|
+
}
|
|
36
|
+
|
|
27
37
|
constructor(that = null) {
|
|
28
38
|
super(that);
|
|
29
39
|
}
|
|
@@ -96,6 +106,30 @@ class ReportCard extends _BaseEntity.default {
|
|
|
96
106
|
get textColor() {
|
|
97
107
|
return _lodash.default.isNil(this.standardReportCardType) ? '#ffffff' : this.standardReportCardType.textColor;
|
|
98
108
|
}
|
|
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
|
+
}
|
|
99
133
|
/**
|
|
100
134
|
* Helper method used to generate unique key value for Nested Report Cards using UUID and Index of the Report Card.
|
|
101
135
|
* The Nested Report Card's query responses would be mapped to the corresponding Dashboard Report cards using the UUID and Index.
|
|
@@ -122,9 +156,18 @@ class ReportCard extends _BaseEntity.default {
|
|
|
122
156
|
}
|
|
123
157
|
|
|
124
158
|
static fromResource(resource, entityService) {
|
|
125
|
-
const reportCard = _General.default.assignFields(resource,
|
|
159
|
+
const reportCard = _General.default.assignFields(resource, ReportCard.newReportCard(), ["uuid", "name", "query", "description", "colour", "voided", "nested", "countOfCards"]);
|
|
126
160
|
|
|
127
161
|
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
|
+
});
|
|
128
171
|
return reportCard;
|
|
129
172
|
}
|
|
130
173
|
|
|
@@ -132,6 +175,14 @@ class ReportCard extends _BaseEntity.default {
|
|
|
132
175
|
return _lodash.default.isNil(this.standardReportCardType) ? false : this.standardReportCardType.isTaskType();
|
|
133
176
|
}
|
|
134
177
|
|
|
178
|
+
isStandardReportType() {
|
|
179
|
+
return !_lodash.default.isNil(this.standardReportCardType);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
isSubjectTypeFilterSupported() {
|
|
183
|
+
return this.isStandardReportType() && this.standardReportCardType.isSubjectTypeFilterSupported();
|
|
184
|
+
}
|
|
185
|
+
|
|
135
186
|
}
|
|
136
187
|
|
|
137
188
|
_defineProperty(ReportCard, "schema", {
|
|
@@ -166,8 +217,20 @@ _defineProperty(ReportCard, "schema", {
|
|
|
166
217
|
type: "int",
|
|
167
218
|
default: 1,
|
|
168
219
|
optional: true
|
|
169
|
-
}
|
|
170
|
-
|
|
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
|
+
}
|
|
171
234
|
}
|
|
172
235
|
});
|
|
173
236
|
|
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: 192,
|
|
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,6 +913,10 @@ 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
|
+
}
|
|
916
920
|
}
|
|
917
921
|
};
|
|
918
922
|
}
|
|
@@ -118,6 +118,10 @@ 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
|
+
|
|
121
125
|
}
|
|
122
126
|
|
|
123
127
|
_defineProperty(StandardReportCardType, "schema", {
|
package/dist/index.js
CHANGED
|
@@ -789,6 +789,18 @@ 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
|
+
});
|
|
792
804
|
|
|
793
805
|
var _AbstractEncounter = _interopRequireDefault(require("./AbstractEncounter"));
|
|
794
806
|
|
|
@@ -1042,6 +1054,10 @@ var _DashboardCacheFilter = _interopRequireDefault(require("./application/Dashbo
|
|
|
1042
1054
|
|
|
1043
1055
|
var _JsonStringify = require("./utility/JsonStringify");
|
|
1044
1056
|
|
|
1057
|
+
var _Locations = _interopRequireDefault(require("./location/Locations"));
|
|
1058
|
+
|
|
1059
|
+
var _Range = _interopRequireDefault(require("./reports/Range"));
|
|
1060
|
+
|
|
1045
1061
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
1046
1062
|
|
|
1047
1063
|
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; }
|
|
@@ -0,0 +1,21 @@
|
|
|
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;
|
|
@@ -13,6 +13,8 @@ var _lodash = _interopRequireDefault(require("lodash"));
|
|
|
13
13
|
|
|
14
14
|
var _DateTimeUtil = _interopRequireDefault(require("../utility/DateTimeUtil"));
|
|
15
15
|
|
|
16
|
+
var _Range = _interopRequireDefault(require("./Range"));
|
|
17
|
+
|
|
16
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
19
|
|
|
18
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; }
|
|
@@ -111,6 +113,8 @@ const dateFilterTypes = [_CustomFilter.default.type.RegistrationDate, _CustomFil
|
|
|
111
113
|
|
|
112
114
|
class DashboardFilterConfig {
|
|
113
115
|
constructor() {
|
|
116
|
+
_defineProperty(this, "subjectType", void 0);
|
|
117
|
+
|
|
114
118
|
_defineProperty(this, "type", void 0);
|
|
115
119
|
|
|
116
120
|
_defineProperty(this, "widget", void 0);
|
|
@@ -125,8 +129,10 @@ class DashboardFilterConfig {
|
|
|
125
129
|
return this.observationBasedFilter.concept.datatype;
|
|
126
130
|
} else if (this.isGroupSubjectTypeFilter()) {
|
|
127
131
|
return _Concept.default.dataType.Subject;
|
|
128
|
-
} else if (dateFilterTypes.includes(this.type)) {
|
|
132
|
+
} else if (dateFilterTypes.includes(this.type) && this.widget === _CustomFilter.default.widget.Default) {
|
|
129
133
|
return _Concept.default.dataType.Date;
|
|
134
|
+
} else if (dateFilterTypes.includes(this.type) && this.widget === _CustomFilter.default.widget.Range) {
|
|
135
|
+
return _Range.default.DateRange;
|
|
130
136
|
} else {
|
|
131
137
|
return this.type;
|
|
132
138
|
}
|
|
@@ -140,6 +146,10 @@ class DashboardFilterConfig {
|
|
|
140
146
|
return this.type === _CustomFilter.default.type.GroupSubject;
|
|
141
147
|
}
|
|
142
148
|
|
|
149
|
+
isSubjectTypeFilter() {
|
|
150
|
+
return this.type === _CustomFilter.default.type.SubjectType;
|
|
151
|
+
}
|
|
152
|
+
|
|
143
153
|
isValid() {
|
|
144
154
|
const valid = !_lodash.default.isNil(this.type);
|
|
145
155
|
if (!valid) return valid;
|
|
@@ -149,6 +159,7 @@ class DashboardFilterConfig {
|
|
|
149
159
|
toServerRequest() {
|
|
150
160
|
const request = {
|
|
151
161
|
type: this.type,
|
|
162
|
+
subjectTypeUUID: this.subjectType && this.subjectType.uuid,
|
|
152
163
|
widget: this.widget
|
|
153
164
|
};
|
|
154
165
|
if (this.isConceptTypeFilter()) request.observationBasedFilter = this.observationBasedFilter.toServerRequest();else if (this.isGroupSubjectTypeFilter()) request.groupSubjectTypeFilter = this.groupSubjectTypeFilter.toServerRequest();
|
|
@@ -175,6 +186,12 @@ class DashboardFilterConfig {
|
|
|
175
186
|
return [RegistrationDate, EnrolmentDate, ProgramEncounterDate, EncounterDate].includes(this.type) || this.isConceptTypeFilter() && this.observationBasedFilter.isWidgetRequired();
|
|
176
187
|
}
|
|
177
188
|
|
|
189
|
+
setSubjectType(subjectType) {
|
|
190
|
+
if (_lodash.default.get(subjectType, "uuid") !== _lodash.default.get(this.subjectType, "uuid")) {
|
|
191
|
+
this.subjectType = subjectType;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
178
195
|
willObservationBeInScopeOfProgramEnrolment() {
|
|
179
196
|
return this.isConceptTypeFilter() && this.observationBasedFilter.willObservationBeInScopeOfProgramEnrolment();
|
|
180
197
|
}
|
|
@@ -186,20 +203,17 @@ class DashboardFilterConfig {
|
|
|
186
203
|
validate(filterValue) {
|
|
187
204
|
const inputDataType = this.getInputDataType();
|
|
188
205
|
|
|
189
|
-
if (
|
|
206
|
+
if (_Range.default.DateRange === inputDataType) {
|
|
190
207
|
return _DateTimeUtil.default.validateDateRange(filterValue.minValue, filterValue.maxValue);
|
|
191
208
|
}
|
|
192
209
|
|
|
193
|
-
if (_Concept.default.dataType.Time === inputDataType && this.widget === _CustomFilter.default.widget.Range) {
|
|
194
|
-
return _DateTimeUtil.default.validateTimeRange(filterValue.minValue, filterValue.maxValue);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
210
|
return [true];
|
|
198
211
|
}
|
|
199
212
|
|
|
200
213
|
clone() {
|
|
201
214
|
const clone = new DashboardFilterConfig();
|
|
202
215
|
clone.type = this.type;
|
|
216
|
+
clone.subjectType = this.subjectType;
|
|
203
217
|
clone.widget = this.widget;
|
|
204
218
|
clone.groupSubjectTypeFilter = this.groupSubjectTypeFilter;
|
|
205
219
|
clone.observationBasedFilter = this.observationBasedFilter;
|
|
@@ -0,0 +1,37 @@
|
|
|
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;
|