openchs-models 1.33.2 → 1.33.4
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/.circleci/config.yml +15 -5
- package/.commit-message.txt +21 -0
- package/.nvmrc +1 -1
- package/Makefile +32 -10
- package/REALM_V12_NOTES.md +46 -0
- package/dist/AbstractEncounter.js +4 -105
- package/dist/AddressLevel.js +5 -62
- package/dist/ApprovalStatus.js +4 -17
- package/dist/BaseEntity.js +5 -42
- package/dist/BeneficiaryModePin.js +4 -13
- package/dist/Checklist.js +6 -52
- package/dist/ChecklistDetail.js +4 -22
- package/dist/ChecklistItem.js +16 -96
- package/dist/ChecklistItemDetail.js +4 -43
- package/dist/ChecklistItemStatus.js +4 -33
- package/dist/Comment.js +6 -51
- package/dist/CommentThread.js +4 -26
- package/dist/CompositeDuration.js +1 -18
- package/dist/Concept.js +5 -107
- package/dist/ConceptAnswer.js +4 -21
- package/dist/CustomDashboardCache.js +4 -38
- package/dist/CustomFilter.js +5 -15
- package/dist/Dashboard.js +4 -23
- package/dist/DashboardCache.js +4 -23
- package/dist/DashboardSection.js +4 -24
- package/dist/DashboardSectionCardMapping.js +4 -21
- package/dist/Displayable.js +3 -11
- package/dist/Documentation.js +4 -21
- package/dist/DocumentationItem.js +4 -20
- package/dist/Duration.js +4 -39
- package/dist/Encounter.js +6 -41
- package/dist/EncounterType.js +4 -26
- package/dist/EntityApprovalStatus.js +6 -56
- package/dist/EntityMetaData.js +7 -105
- package/dist/EntityQueue.js +4 -15
- package/dist/EntityRule.js +1 -29
- package/dist/EntitySyncStatus.js +4 -19
- package/dist/Extension.js +4 -18
- package/dist/Family.js +4 -56
- package/dist/FileFormat.js +0 -7
- package/dist/Gender.js +4 -17
- package/dist/GroupDashboard.js +4 -23
- package/dist/GroupPrivileges.js +4 -28
- package/dist/GroupRole.js +4 -34
- package/dist/GroupSubject.js +6 -59
- package/dist/Groups.js +4 -14
- package/dist/Identifier.js +4 -20
- package/dist/IdentifierAssignment.js +6 -45
- package/dist/IdentifierSource.js +4 -15
- package/dist/Individual.js +17 -265
- package/dist/LocaleMapping.js +4 -13
- package/dist/LocationHierarchy.js +4 -25
- package/dist/Media.js +35 -35
- package/dist/MediaQueue.js +4 -26
- package/dist/MigrationsHelper.js +15 -22
- package/dist/MyGroups.js +4 -14
- package/dist/News.js +4 -31
- package/dist/Observation.js +4 -54
- package/dist/ObservationsHolder.js +104 -216
- package/dist/OrganisationConfig.js +4 -19
- package/dist/PersistedObject.js +1 -19
- package/dist/PhoneNumber.js +0 -11
- package/dist/PlatformTranslation.js +4 -17
- package/dist/Privilege.js +5 -22
- package/dist/Program.js +4 -39
- package/dist/ProgramEncounter.js +6 -48
- package/dist/ProgramEnrolment.js +8 -162
- package/dist/ReferenceEntity.js +1 -10
- package/dist/ReportCard.js +5 -60
- package/dist/ResetSync.js +4 -17
- package/dist/Rule.js +4 -28
- package/dist/RuleDependency.js +4 -17
- package/dist/RuleFailureTelemetry.js +4 -36
- package/dist/Schema.js +16 -268
- package/dist/SchemaNames.js +3 -46
- package/dist/Settings.js +4 -53
- package/dist/StandardReportCardType.js +4 -39
- package/dist/SubjectMigration.js +6 -45
- package/dist/SubjectType.js +6 -72
- package/dist/SyncTelemetry.js +4 -40
- package/dist/Translation.js +4 -17
- package/dist/UserInfo.js +4 -33
- package/dist/application/DashboardCacheFilter.js +4 -24
- package/dist/application/Filter.js +3 -16
- package/dist/application/Form.js +6 -93
- package/dist/application/FormElement.js +5 -100
- package/dist/application/FormElementGroup.js +4 -75
- package/dist/application/FormElementStatus.js +1 -11
- package/dist/application/FormMapping.js +6 -44
- package/dist/application/Format.js +4 -20
- package/dist/application/KeyValue.js +4 -19
- package/dist/application/MenuItem.js +4 -35
- package/dist/application/MultiSelectFilter.js +1 -11
- package/dist/application/NullProgramEnrolment.js +0 -8
- package/dist/application/SingleSelectFilter.js +1 -12
- package/dist/application/StaticFormElementGroup.js +0 -11
- package/dist/application/StringKeyNumericValue.js +4 -17
- package/dist/application/ValidationResult.js +6 -20
- package/dist/application/ValidationResults.js +1 -14
- package/dist/application/WorkItem.js +4 -20
- package/dist/application/WorkList.js +1 -24
- package/dist/application/WorkLists.js +1 -13
- package/dist/assignment/UserSubjectAssignment.js +6 -26
- package/dist/draft/DraftEncounter.js +4 -40
- package/dist/draft/DraftSubject.js +4 -46
- package/dist/error/IgnorableSyncError.js +1 -6
- package/dist/error/SyncError.js +1 -6
- package/dist/framework/ArrayHelper.js +3 -11
- package/dist/framework/DefinedObjectSchema.js +4 -12
- package/dist/framework/RealmCollectionHelper.js +1 -9
- package/dist/framework/RealmListProxy.js +1 -10
- package/dist/framework/RealmObjectSchema.js +1 -11
- package/dist/framework/RealmProxy.js +2 -31
- package/dist/framework/RealmResultsProxy.js +3 -37
- package/dist/framework/RealmResultsProxyHandler.js +2 -5
- package/dist/geo/Point.js +4 -17
- package/dist/index.js +2 -137
- package/dist/location/Locations.js +1 -6
- package/dist/observation/MultipleCodedValues.js +1 -21
- package/dist/observation/PrimitiveValue.js +1 -17
- package/dist/observation/QuestionGroup.js +1 -36
- package/dist/observation/RepeatableQuestionGroup.js +4 -27
- package/dist/observation/SingleCodedValue.js +1 -15
- package/dist/program/SubjectProgramEligibility.js +6 -56
- package/dist/relationship/IndividualRelation.js +6 -18
- package/dist/relationship/IndividualRelationGenderMapping.js +4 -22
- package/dist/relationship/IndividualRelationship.js +6 -51
- package/dist/relationship/IndividualRelationshipType.js +4 -24
- package/dist/relationship/IndividualRelative.js +4 -31
- package/dist/reports/DashboardFilter.js +4 -20
- package/dist/reports/DashboardFilterConfig.js +5 -85
- package/dist/reports/NestedReportCardResult.js +5 -35
- package/dist/reports/Range.js +4 -13
- package/dist/reports/ReportCardResult.js +5 -24
- package/dist/service/MetaDataService.js +1 -30
- package/dist/task/Task.js +6 -62
- package/dist/task/TaskStatus.js +4 -21
- package/dist/task/TaskType.js +4 -23
- package/dist/task/TaskUnAssignment.js +6 -30
- package/dist/utility/AgeUtil.js +1 -15
- package/dist/utility/ArrayUtil.js +1 -6
- package/dist/utility/AuditUtil.js +1 -8
- package/dist/utility/DateTimeUtil.js +1 -8
- package/dist/utility/General.js +4 -71
- package/dist/utility/JsonStringify.js +15 -28
- package/dist/utility/MergeUtil.js +1 -10
- package/dist/utility/ResourceUtil.js +1 -7
- package/dist/videos/Video.js +4 -23
- package/dist/videos/VideoTelemetric.js +6 -37
- package/package.json +6 -3
- package/scripts/validateSchemas.js +40 -0
- package/tsconfig.json +1 -1
- package/yarn.lock +0 -6744
package/dist/Checklist.js
CHANGED
|
@@ -4,140 +4,102 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
|
-
|
|
10
8
|
var _ResourceUtil = _interopRequireDefault(require("./utility/ResourceUtil"));
|
|
11
|
-
|
|
12
9
|
var _General = _interopRequireDefault(require("./utility/General"));
|
|
13
|
-
|
|
14
10
|
var _ProgramEnrolment = _interopRequireDefault(require("./ProgramEnrolment"));
|
|
15
|
-
|
|
16
11
|
var _BaseEntity = _interopRequireDefault(require("./BaseEntity"));
|
|
17
|
-
|
|
18
12
|
var _ChecklistItem = _interopRequireDefault(require("./ChecklistItem"));
|
|
19
|
-
|
|
20
13
|
var _ChecklistDetail = _interopRequireDefault(require("./ChecklistDetail"));
|
|
21
|
-
|
|
22
14
|
var _SchemaNames = _interopRequireDefault(require("./SchemaNames"));
|
|
23
|
-
|
|
24
15
|
var _EntityApprovalStatus = _interopRequireDefault(require("./EntityApprovalStatus"));
|
|
25
|
-
|
|
26
16
|
var _AuditUtil = require("./utility/AuditUtil");
|
|
27
|
-
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
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; }
|
|
35
|
-
|
|
17
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
19
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
20
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
21
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
22
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
36
23
|
class Checklist extends _BaseEntity.default {
|
|
37
24
|
constructor(that = null) {
|
|
38
25
|
super(that);
|
|
39
26
|
}
|
|
40
|
-
|
|
41
27
|
get detail() {
|
|
42
28
|
return this.toEntity("detail", _ChecklistDetail.default);
|
|
43
29
|
}
|
|
44
|
-
|
|
45
30
|
set detail(x) {
|
|
46
31
|
this.that.detail = this.fromObject(x);
|
|
47
32
|
}
|
|
48
|
-
|
|
49
33
|
get baseDate() {
|
|
50
34
|
return this.that.baseDate;
|
|
51
35
|
}
|
|
52
|
-
|
|
53
36
|
set baseDate(x) {
|
|
54
37
|
this.that.baseDate = x;
|
|
55
38
|
}
|
|
56
|
-
|
|
57
39
|
get items() {
|
|
58
40
|
return this.toEntityList("items", _ChecklistItem.default);
|
|
59
41
|
}
|
|
60
|
-
|
|
61
42
|
set items(x) {
|
|
62
43
|
this.that.items = this.fromEntityList(x);
|
|
63
44
|
}
|
|
64
|
-
|
|
65
45
|
get programEnrolment() {
|
|
66
46
|
return this.toEntity("programEnrolment", _ProgramEnrolment.default);
|
|
67
47
|
}
|
|
68
|
-
|
|
69
48
|
set programEnrolment(x) {
|
|
70
49
|
this.that.programEnrolment = this.fromObject(x);
|
|
71
50
|
}
|
|
72
|
-
|
|
73
51
|
get createdBy() {
|
|
74
52
|
return this.that.createdBy;
|
|
75
53
|
}
|
|
76
|
-
|
|
77
54
|
set createdBy(x) {
|
|
78
55
|
this.that.createdBy = x;
|
|
79
56
|
}
|
|
80
|
-
|
|
81
57
|
get lastModifiedBy() {
|
|
82
58
|
return this.that.lastModifiedBy;
|
|
83
59
|
}
|
|
84
|
-
|
|
85
60
|
set lastModifiedBy(x) {
|
|
86
61
|
this.that.lastModifiedBy = x;
|
|
87
62
|
}
|
|
88
|
-
|
|
89
63
|
get createdByUUID() {
|
|
90
64
|
return this.that.createdByUUID;
|
|
91
65
|
}
|
|
92
|
-
|
|
93
66
|
set createdByUUID(x) {
|
|
94
67
|
this.that.createdByUUID = x;
|
|
95
68
|
}
|
|
96
|
-
|
|
97
69
|
get lastModifiedByUUID() {
|
|
98
70
|
return this.that.lastModifiedByUUID;
|
|
99
71
|
}
|
|
100
|
-
|
|
101
72
|
set lastModifiedByUUID(x) {
|
|
102
73
|
this.that.lastModifiedByUUID = x;
|
|
103
74
|
}
|
|
104
|
-
|
|
105
75
|
static create() {
|
|
106
76
|
const checklist = new Checklist();
|
|
107
77
|
checklist.uuid = _General.default.randomUUID();
|
|
108
78
|
checklist.items = [];
|
|
109
79
|
return checklist;
|
|
110
80
|
}
|
|
111
|
-
|
|
112
81
|
static fromResource(checklistResource, entityService) {
|
|
113
82
|
const programEnrolment = entityService.findByKey("uuid", _ResourceUtil.default.getUUIDFor(checklistResource, "programEnrolmentUUID"), _ProgramEnrolment.default.schema.name);
|
|
114
|
-
|
|
115
83
|
const checklist = _General.default.assignFields(checklistResource, new Checklist(), ["uuid"], ["baseDate"]);
|
|
116
|
-
|
|
117
84
|
const checklistDetail = entityService.findByKey("uuid", _ResourceUtil.default.getUUIDFor(checklistResource, "checklistDetailUUID"), _ChecklistDetail.default.schema.name);
|
|
118
85
|
checklist.programEnrolment = programEnrolment;
|
|
119
86
|
checklist.detail = checklistDetail;
|
|
120
87
|
(0, _AuditUtil.mapAuditFields)(checklist, checklistResource);
|
|
121
88
|
return checklist;
|
|
122
89
|
}
|
|
123
|
-
|
|
124
90
|
get toResource() {
|
|
125
91
|
const resource = _lodash.default.pick(this, ["uuid"]);
|
|
126
|
-
|
|
127
92
|
resource["baseDate"] = _General.default.isoFormat(this.baseDate);
|
|
128
93
|
resource["programEnrolmentUUID"] = this.programEnrolment.uuid;
|
|
129
94
|
resource["checklistDetailUUID"] = this.detail.uuid;
|
|
130
95
|
return resource;
|
|
131
96
|
}
|
|
132
|
-
|
|
133
97
|
static associateChild(child, childEntityClass, childResource, entityService) {
|
|
134
98
|
let checklist = _BaseEntity.default.getParentEntity(entityService, childEntityClass, childResource, "checklistUUID", Checklist.schema.name);
|
|
135
|
-
|
|
136
99
|
checklist = _General.default.pick(checklist, ["uuid"], ["items"]);
|
|
137
100
|
if (childEntityClass === _ChecklistItem.default) _BaseEntity.default.addNewChild(child, checklist.items);else throw `${childEntityClass.name} not support by ${Checklist.name}`;
|
|
138
101
|
return checklist;
|
|
139
102
|
}
|
|
140
|
-
|
|
141
103
|
clone() {
|
|
142
104
|
const checklist = new Checklist();
|
|
143
105
|
checklist.uuid = this.uuid;
|
|
@@ -147,16 +109,13 @@ class Checklist extends _BaseEntity.default {
|
|
|
147
109
|
checklist.items = _lodash.default.map(this.items, item => item.clone());
|
|
148
110
|
return checklist;
|
|
149
111
|
}
|
|
150
|
-
|
|
151
112
|
setCompletionDate(checklistItemName, value) {
|
|
152
113
|
const checklistItem = this.getChecklistItem(checklistItemName);
|
|
153
114
|
checklistItem.completionDate = value;
|
|
154
115
|
}
|
|
155
|
-
|
|
156
116
|
addItem(item) {
|
|
157
117
|
this.items.push(item);
|
|
158
118
|
}
|
|
159
|
-
|
|
160
119
|
print() {
|
|
161
120
|
return `Checklist{
|
|
162
121
|
uuid=${this.uuid},
|
|
@@ -166,13 +125,10 @@ class Checklist extends _BaseEntity.default {
|
|
|
166
125
|
programEnrolment=${this.programEnrolment.print()}
|
|
167
126
|
}`;
|
|
168
127
|
}
|
|
169
|
-
|
|
170
128
|
addApprovalDescendantsWithLatestStatus(approvalStatus_status, list) {
|
|
171
129
|
_EntityApprovalStatus.default.addMatchingApprovalStatusEntity(this.items, approvalStatus_status, list, "uuid");
|
|
172
130
|
}
|
|
173
|
-
|
|
174
131
|
}
|
|
175
|
-
|
|
176
132
|
_defineProperty(Checklist, "schema", {
|
|
177
133
|
name: _SchemaNames.default.Checklist,
|
|
178
134
|
primaryKey: "uuid",
|
|
@@ -193,8 +149,6 @@ _defineProperty(Checklist, "schema", {
|
|
|
193
149
|
}
|
|
194
150
|
}, _AuditUtil.AuditFields)
|
|
195
151
|
});
|
|
196
|
-
|
|
197
152
|
_defineProperty(Checklist, "merge", () => _BaseEntity.default.mergeOn("items"));
|
|
198
|
-
|
|
199
153
|
var _default = Checklist;
|
|
200
154
|
exports.default = _default;
|
package/dist/ChecklistDetail.js
CHANGED
|
@@ -4,54 +4,40 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _General = _interopRequireDefault(require("./utility/General"));
|
|
9
|
-
|
|
10
8
|
var _BaseEntity = _interopRequireDefault(require("./BaseEntity"));
|
|
11
|
-
|
|
12
9
|
var _ChecklistItemDetail = _interopRequireDefault(require("./ChecklistItemDetail"));
|
|
13
|
-
|
|
14
10
|
var _SchemaNames = _interopRequireDefault(require("./SchemaNames"));
|
|
15
|
-
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
20
15
|
class ChecklistDetail extends _BaseEntity.default {
|
|
21
16
|
constructor(that = null) {
|
|
22
17
|
super(that);
|
|
23
18
|
}
|
|
24
|
-
|
|
25
19
|
get name() {
|
|
26
20
|
return this.that.name;
|
|
27
21
|
}
|
|
28
|
-
|
|
29
22
|
set name(x) {
|
|
30
23
|
this.that.name = x;
|
|
31
24
|
}
|
|
32
|
-
|
|
33
25
|
get items() {
|
|
34
26
|
return this.toEntityList("items", _ChecklistItemDetail.default);
|
|
35
27
|
}
|
|
36
|
-
|
|
37
28
|
set items(x) {
|
|
38
29
|
this.that.items = this.fromEntityList(x);
|
|
39
30
|
}
|
|
40
|
-
|
|
41
31
|
static fromResource(checklistResource, entityService) {
|
|
42
32
|
const checklistDetail = _General.default.assignFields(checklistResource, new ChecklistDetail(), ["uuid", "name", "voided"]);
|
|
43
|
-
|
|
44
33
|
return checklistDetail;
|
|
45
34
|
}
|
|
46
|
-
|
|
47
35
|
static associateChild(child, childEntityClass, childResource, entityService) {
|
|
48
36
|
let checklistDetail = _BaseEntity.default.getParentEntity(entityService, childEntityClass, childResource, "checklistDetailUUID", ChecklistDetail.schema.name);
|
|
49
|
-
|
|
50
37
|
checklistDetail = _General.default.pick(checklistDetail, ["uuid"], ["items"]);
|
|
51
38
|
if (childEntityClass === _ChecklistItemDetail.default) _BaseEntity.default.addNewChild(child, checklistDetail.items);else throw `${childEntityClass.name} not support by ${ChecklistDetail.name}`;
|
|
52
39
|
return checklistDetail;
|
|
53
40
|
}
|
|
54
|
-
|
|
55
41
|
print() {
|
|
56
42
|
return `ChecklistDetail{
|
|
57
43
|
uuid=${this.uuid},
|
|
@@ -59,9 +45,7 @@ class ChecklistDetail extends _BaseEntity.default {
|
|
|
59
45
|
items=${this.items}
|
|
60
46
|
}`;
|
|
61
47
|
}
|
|
62
|
-
|
|
63
48
|
}
|
|
64
|
-
|
|
65
49
|
_defineProperty(ChecklistDetail, "schema", {
|
|
66
50
|
name: _SchemaNames.default.ChecklistDetail,
|
|
67
51
|
primaryKey: "uuid",
|
|
@@ -78,8 +62,6 @@ _defineProperty(ChecklistDetail, "schema", {
|
|
|
78
62
|
}
|
|
79
63
|
}
|
|
80
64
|
});
|
|
81
|
-
|
|
82
65
|
_defineProperty(ChecklistDetail, "merge", () => _BaseEntity.default.mergeOn("items"));
|
|
83
|
-
|
|
84
66
|
var _default = ChecklistDetail;
|
|
85
67
|
exports.default = _default;
|
package/dist/ChecklistItem.js
CHANGED
|
@@ -4,118 +4,82 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
|
-
|
|
10
8
|
var _General = _interopRequireDefault(require("./utility/General"));
|
|
11
|
-
|
|
12
9
|
var _ResourceUtil = _interopRequireDefault(require("./utility/ResourceUtil"));
|
|
13
|
-
|
|
14
10
|
var _Checklist = _interopRequireDefault(require("./Checklist"));
|
|
15
|
-
|
|
16
11
|
var _ChecklistItemStatus = _interopRequireDefault(require("./ChecklistItemStatus"));
|
|
17
|
-
|
|
18
12
|
var _ObservationsHolder = _interopRequireDefault(require("./ObservationsHolder"));
|
|
19
|
-
|
|
20
13
|
var _ChecklistItemDetail = _interopRequireDefault(require("./ChecklistItemDetail"));
|
|
21
|
-
|
|
22
14
|
var _moment = _interopRequireDefault(require("moment"));
|
|
23
|
-
|
|
24
15
|
var _EntityApprovalStatus = _interopRequireDefault(require("./EntityApprovalStatus"));
|
|
25
|
-
|
|
26
16
|
var _SchemaNames = _interopRequireDefault(require("./SchemaNames"));
|
|
27
|
-
|
|
28
17
|
var _BaseEntity = _interopRequireDefault(require("./BaseEntity"));
|
|
29
|
-
|
|
30
18
|
var _Observation = _interopRequireDefault(require("./Observation"));
|
|
31
|
-
|
|
32
19
|
var _MergeUtil = _interopRequireDefault(require("./utility/MergeUtil"));
|
|
33
|
-
|
|
34
20
|
var _AuditUtil = require("./utility/AuditUtil");
|
|
35
|
-
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
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; }
|
|
43
|
-
|
|
21
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
23
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
24
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
25
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
26
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
44
27
|
const mergeMap = new Map([[_SchemaNames.default.EntityApprovalStatus, "approvalStatuses"]]);
|
|
45
|
-
|
|
46
28
|
class ChecklistItem extends _BaseEntity.default {
|
|
47
29
|
constructor(that = null) {
|
|
48
30
|
super(that);
|
|
49
31
|
}
|
|
50
|
-
|
|
51
32
|
get detail() {
|
|
52
33
|
return this.toEntity("detail", _ChecklistItemDetail.default);
|
|
53
34
|
}
|
|
54
|
-
|
|
55
35
|
set detail(x) {
|
|
56
36
|
this.that.detail = this.fromObject(x);
|
|
57
37
|
}
|
|
58
|
-
|
|
59
38
|
get completionDate() {
|
|
60
39
|
return this.that.completionDate;
|
|
61
40
|
}
|
|
62
|
-
|
|
63
41
|
set completionDate(x) {
|
|
64
42
|
this.that.completionDate = x;
|
|
65
43
|
}
|
|
66
|
-
|
|
67
44
|
get observations() {
|
|
68
45
|
return this.toEntityList("observations", _Observation.default);
|
|
69
46
|
}
|
|
70
|
-
|
|
71
47
|
set observations(x) {
|
|
72
48
|
this.that.observations = this.fromEntityList(x);
|
|
73
49
|
}
|
|
74
|
-
|
|
75
50
|
get checklist() {
|
|
76
51
|
return this.toEntity("checklist", _Checklist.default);
|
|
77
52
|
}
|
|
78
|
-
|
|
79
53
|
set checklist(x) {
|
|
80
54
|
this.that.checklist = this.fromObject(x);
|
|
81
55
|
}
|
|
82
|
-
|
|
83
56
|
get latestEntityApprovalStatus() {
|
|
84
57
|
return _lodash.default.maxBy(this.approvalStatuses, 'statusDateTime');
|
|
85
58
|
}
|
|
86
|
-
|
|
87
59
|
get createdBy() {
|
|
88
60
|
return this.that.createdBy;
|
|
89
61
|
}
|
|
90
|
-
|
|
91
62
|
set createdBy(x) {
|
|
92
63
|
this.that.createdBy = x;
|
|
93
64
|
}
|
|
94
|
-
|
|
95
65
|
get lastModifiedBy() {
|
|
96
66
|
return this.that.lastModifiedBy;
|
|
97
67
|
}
|
|
98
|
-
|
|
99
68
|
set lastModifiedBy(x) {
|
|
100
69
|
this.that.lastModifiedBy = x;
|
|
101
70
|
}
|
|
102
|
-
|
|
103
71
|
get createdByUUID() {
|
|
104
72
|
return this.that.createdByUUID;
|
|
105
73
|
}
|
|
106
|
-
|
|
107
74
|
set createdByUUID(x) {
|
|
108
75
|
this.that.createdByUUID = x;
|
|
109
76
|
}
|
|
110
|
-
|
|
111
77
|
get lastModifiedByUUID() {
|
|
112
78
|
return this.that.lastModifiedByUUID;
|
|
113
79
|
}
|
|
114
|
-
|
|
115
80
|
set lastModifiedByUUID(x) {
|
|
116
81
|
this.that.lastModifiedByUUID = x;
|
|
117
82
|
}
|
|
118
|
-
|
|
119
83
|
static create({
|
|
120
84
|
uuid = _General.default.randomUUID(),
|
|
121
85
|
observations = [],
|
|
@@ -129,22 +93,17 @@ class ChecklistItem extends _BaseEntity.default {
|
|
|
129
93
|
detail
|
|
130
94
|
});
|
|
131
95
|
}
|
|
132
|
-
|
|
133
96
|
static fromResource(checklistItemResource, entityService) {
|
|
134
97
|
const checklist = entityService.findByKey("uuid", _ResourceUtil.default.getUUIDFor(checklistItemResource, "checklistUUID"), _Checklist.default.schema.name);
|
|
135
98
|
const checklistItemDetail = entityService.findByKey("uuid", _ResourceUtil.default.getUUIDFor(checklistItemResource, "checklistItemDetailUUID"), _ChecklistItemDetail.default.schema.name);
|
|
136
|
-
|
|
137
99
|
const checklistItem = _General.default.assignFields(checklistItemResource, new ChecklistItem(), ["uuid"], ["completionDate"], ["observations"], entityService);
|
|
138
|
-
|
|
139
100
|
checklistItem.checklist = checklist;
|
|
140
101
|
checklistItem.detail = checklistItemDetail;
|
|
141
102
|
(0, _AuditUtil.mapAuditFields)(checklistItem, checklistItemResource);
|
|
142
103
|
return checklistItem;
|
|
143
104
|
}
|
|
144
|
-
|
|
145
105
|
get toResource() {
|
|
146
106
|
const resource = _lodash.default.pick(this, ["uuid", "name"]);
|
|
147
|
-
|
|
148
107
|
resource["completionDate"] = _General.default.isoFormat(this.completionDate);
|
|
149
108
|
resource["checklistUUID"] = this.checklist.uuid;
|
|
150
109
|
resource["checklistItemDetailUUID"] = this.detail.uuid;
|
|
@@ -154,7 +113,6 @@ class ChecklistItem extends _BaseEntity.default {
|
|
|
154
113
|
});
|
|
155
114
|
return resource;
|
|
156
115
|
}
|
|
157
|
-
|
|
158
116
|
clone() {
|
|
159
117
|
const checklistItem = new ChecklistItem();
|
|
160
118
|
checklistItem.uuid = this.uuid;
|
|
@@ -165,84 +123,68 @@ class ChecklistItem extends _BaseEntity.default {
|
|
|
165
123
|
checklistItem.observations = _ObservationsHolder.default.clone(this.observations);
|
|
166
124
|
return checklistItem;
|
|
167
125
|
}
|
|
168
|
-
|
|
169
126
|
cloneForEdit() {
|
|
170
127
|
return this.clone();
|
|
171
128
|
}
|
|
172
|
-
|
|
173
129
|
validate() {
|
|
174
130
|
return null;
|
|
175
131
|
}
|
|
176
|
-
|
|
177
132
|
get completed() {
|
|
178
133
|
return !_lodash.default.isNil(this.completionDate);
|
|
179
134
|
}
|
|
180
|
-
|
|
181
135
|
expired(currentDate) {
|
|
182
136
|
return !_lodash.default.isNil(this.detail.expiresAfter) && currentDate.isSameOrAfter(this.expiryDate);
|
|
183
137
|
}
|
|
184
|
-
|
|
185
138
|
get expiryDate() {
|
|
186
139
|
return _lodash.default.isNil(this.detail.expiresAfter) ? null : (0, _moment.default)(this.checklist.baseDate).add(this.detail.expiresAfter, "day");
|
|
187
140
|
}
|
|
188
|
-
|
|
189
141
|
get firstState() {
|
|
190
142
|
return this.detail.stateConfig.find(status => status.displayOrder === 1);
|
|
191
143
|
}
|
|
192
|
-
|
|
193
144
|
get _leadingItem() {
|
|
194
145
|
return this.isDependent ? this.checklist.items.find(item => item.detail.uuid === this.detail.dependentOn.uuid) : null;
|
|
195
146
|
}
|
|
196
|
-
|
|
197
147
|
get conceptName() {
|
|
198
148
|
return this.detail.concept.name;
|
|
199
149
|
}
|
|
200
|
-
|
|
201
150
|
get approvalStatuses() {
|
|
202
151
|
return this.toEntityList("approvalStatuses", _EntityApprovalStatus.default);
|
|
203
152
|
}
|
|
204
|
-
|
|
205
153
|
set approvalStatuses(x) {
|
|
206
154
|
this.that.approvalStatuses = this.fromEntityList(x);
|
|
207
155
|
}
|
|
208
|
-
|
|
209
156
|
calculateApplicableState(currentDate = (0, _moment.default)()) {
|
|
210
157
|
if (this.completed) {
|
|
211
158
|
return {
|
|
212
159
|
status: _ChecklistItemStatus.default.completed,
|
|
213
160
|
statusDate: this.completionDate
|
|
214
161
|
};
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
|
|
162
|
+
}
|
|
163
|
+
//console.log(`0 ${this.conceptName} ${this.checklist.baseDate} ${this.detail.expiresAfter} ${this.expiryDate} ${moment(this.checklist.baseDate).add(this.detail.expiresAfter, "day").toDate()}`);
|
|
218
164
|
if (this.expired(currentDate)) {
|
|
219
165
|
return {
|
|
220
166
|
status: _ChecklistItemStatus.default.expired,
|
|
221
167
|
statusDate: this.expiryDate
|
|
222
168
|
};
|
|
223
169
|
}
|
|
224
|
-
|
|
225
170
|
let isLeadingItemExpired = false;
|
|
226
171
|
let statusDate = null;
|
|
227
172
|
const leadingItem = this._leadingItem;
|
|
228
|
-
|
|
229
173
|
if (!_lodash.default.isNil(leadingItem) && this.scheduleOnExpiryOfDependency) {
|
|
230
174
|
const leadingItemState = leadingItem.calculateApplicableState().status;
|
|
231
|
-
|
|
232
175
|
if (_lodash.default.isNil(leadingItemState)) {
|
|
233
176
|
return {
|
|
234
177
|
status: null,
|
|
235
178
|
statusDate: null
|
|
236
179
|
};
|
|
237
180
|
}
|
|
238
|
-
|
|
239
181
|
isLeadingItemExpired = leadingItemState.state === "Expired";
|
|
240
182
|
}
|
|
241
|
-
|
|
242
183
|
let nonCompletedState = this.detail.stateConfig.find((status, index) => {
|
|
243
184
|
if (!this.isDependent) {
|
|
244
185
|
const minDate = (0, _moment.default)(this.checklist.baseDate).add(status.start, "day").startOf("day");
|
|
245
|
-
const maxDate = (0, _moment.default)(this.checklist.baseDate).add(status.end, "day").endOf("day");
|
|
186
|
+
const maxDate = (0, _moment.default)(this.checklist.baseDate).add(status.end, "day").endOf("day");
|
|
187
|
+
//console.log(`a ${this.conceptName} ${status.state} ${minDate.toDate()} ${maxDate.toDate()}`);
|
|
246
188
|
|
|
247
189
|
if (currentDate.isBetween(minDate, maxDate, null, "[]")) {
|
|
248
190
|
statusDate = minDate.toDate();
|
|
@@ -251,105 +193,85 @@ class ChecklistItem extends _BaseEntity.default {
|
|
|
251
193
|
} else if (leadingItem.completed) {
|
|
252
194
|
let minDate, maxDate;
|
|
253
195
|
minDate = _moment.default.max((0, _moment.default)(this.checklist.baseDate).add(this.detail.minDaysFromStartDate, "day").add(status.start, "day"), (0, _moment.default)(leadingItem.completionDate).add(this.detail.minDaysFromDependent, "day").add(status.start, "day"));
|
|
254
|
-
maxDate = _moment.default.max((0, _moment.default)(this.checklist.baseDate).add(this.detail.minDaysFromStartDate, "day").add(status.end, "day"), (0, _moment.default)(leadingItem.completionDate).add(this.detail.minDaysFromDependent, "day").add(status.end, "day"));
|
|
196
|
+
maxDate = _moment.default.max((0, _moment.default)(this.checklist.baseDate).add(this.detail.minDaysFromStartDate, "day").add(status.end, "day"), (0, _moment.default)(leadingItem.completionDate).add(this.detail.minDaysFromDependent, "day").add(status.end, "day"));
|
|
255
197
|
|
|
198
|
+
//console.log(`b ${this.conceptName} ${status.state} ${minDate.toDate()} ${maxDate.toDate()}`);
|
|
256
199
|
if (currentDate.isBetween(minDate, maxDate, null, "[]")) {
|
|
257
|
-
statusDate = minDate.toDate();
|
|
258
|
-
|
|
200
|
+
statusDate = minDate.toDate();
|
|
201
|
+
//console.log(`b ${statusDate}`);
|
|
259
202
|
return true;
|
|
260
203
|
}
|
|
261
204
|
} else if (isLeadingItemExpired) {
|
|
262
205
|
const minDate = (0, _moment.default)(this.checklist.baseDate).add(this.detail.minDaysFromStartDate, "day").add(status.start, "day").startOf("day");
|
|
263
|
-
const maxDate = (0, _moment.default)(this.checklist.baseDate).add(this.detail.minDaysFromStartDate, "day").add(status.end, "day").endOf("day");
|
|
206
|
+
const maxDate = (0, _moment.default)(this.checklist.baseDate).add(this.detail.minDaysFromStartDate, "day").add(status.end, "day").endOf("day");
|
|
207
|
+
//console.log(`c ${this.conceptName} ${status.state} ${this.detail.minDaysFromStartDate} ${minDate.toDate()} ${maxDate.toDate()}`);
|
|
264
208
|
|
|
265
209
|
if (currentDate.isBetween(minDate, maxDate, null, "[]")) {
|
|
266
210
|
statusDate = minDate.toDate();
|
|
267
211
|
return true;
|
|
268
212
|
}
|
|
269
213
|
}
|
|
270
|
-
|
|
271
214
|
return false;
|
|
272
215
|
});
|
|
273
|
-
|
|
274
216
|
if (!_lodash.default.isNil(nonCompletedState)) {
|
|
275
217
|
return {
|
|
276
218
|
status: nonCompletedState,
|
|
277
219
|
statusDate: statusDate
|
|
278
220
|
};
|
|
279
221
|
}
|
|
280
|
-
|
|
281
222
|
return {
|
|
282
223
|
status: null,
|
|
283
224
|
statusDate: null
|
|
284
225
|
};
|
|
285
226
|
}
|
|
286
|
-
|
|
287
227
|
get isDependent() {
|
|
288
228
|
return this.detail.isDependent;
|
|
289
229
|
}
|
|
290
|
-
|
|
291
230
|
get scheduleOnExpiryOfDependency() {
|
|
292
231
|
return this.detail.scheduleOnExpiryOfDependency;
|
|
293
232
|
}
|
|
294
|
-
|
|
295
233
|
get editable() {
|
|
296
234
|
return !this.detail.voided;
|
|
297
235
|
}
|
|
298
|
-
|
|
299
236
|
setCompletionDate(date = new Date()) {
|
|
300
237
|
this.completionDate = date;
|
|
301
238
|
}
|
|
302
|
-
|
|
303
239
|
print() {
|
|
304
240
|
return `ChecklistItem{uuid=${this.uuid}}`;
|
|
305
241
|
}
|
|
306
|
-
|
|
307
242
|
findObservation(conceptNameOrUuid) {
|
|
308
243
|
return _lodash.default.find(this.observations, observation => {
|
|
309
244
|
return observation.concept.name === conceptNameOrUuid || observation.concept.uuid === conceptNameOrUuid;
|
|
310
245
|
});
|
|
311
246
|
}
|
|
312
|
-
|
|
313
247
|
get individual() {
|
|
314
248
|
return this.checklist.programEnrolment.individual;
|
|
315
249
|
}
|
|
316
|
-
|
|
317
250
|
getName() {
|
|
318
251
|
return "ChecklistItem";
|
|
319
252
|
}
|
|
320
|
-
|
|
321
253
|
getEntityTypeName() {
|
|
322
254
|
return this.checklist.detail.name;
|
|
323
255
|
}
|
|
324
|
-
|
|
325
256
|
isRejectedEntity() {
|
|
326
257
|
return this.latestEntityApprovalStatus && this.latestEntityApprovalStatus.isRejected;
|
|
327
258
|
}
|
|
328
|
-
|
|
329
259
|
static associateChild(child, childEntityClass, childResource, entityService) {
|
|
330
260
|
let realmChecklistItem = _BaseEntity.default.getParentEntity(entityService, childEntityClass, childResource, "entityUUID", ChecklistItem.schema.name);
|
|
331
|
-
|
|
332
261
|
realmChecklistItem = _General.default.pick(realmChecklistItem, ["uuid", "latestEntityApprovalStatus"], ["approvalStatuses"]);
|
|
333
|
-
|
|
334
262
|
if (childEntityClass === _EntityApprovalStatus.default) {
|
|
335
263
|
_BaseEntity.default.addNewChild(child, realmChecklistItem.approvalStatuses);
|
|
336
|
-
|
|
337
264
|
realmChecklistItem.latestEntityApprovalStatus = _lodash.default.maxBy(realmChecklistItem.approvalStatuses, 'statusDateTime');
|
|
338
265
|
}
|
|
339
|
-
|
|
340
266
|
return realmChecklistItem;
|
|
341
267
|
}
|
|
342
|
-
|
|
343
268
|
setLatestEntityApprovalStatus(entityApprovalStatus) {
|
|
344
269
|
this.that.latestEntityApprovalStatus = this.fromObject(entityApprovalStatus);
|
|
345
270
|
}
|
|
346
|
-
|
|
347
271
|
getSchemaName() {
|
|
348
272
|
return _SchemaNames.default.ChecklistItem;
|
|
349
273
|
}
|
|
350
|
-
|
|
351
274
|
}
|
|
352
|
-
|
|
353
275
|
_defineProperty(ChecklistItem, "schema", {
|
|
354
276
|
name: _SchemaNames.default.ChecklistItem,
|
|
355
277
|
primaryKey: "uuid",
|
|
@@ -382,8 +304,6 @@ _defineProperty(ChecklistItem, "schema", {
|
|
|
382
304
|
}
|
|
383
305
|
}, _AuditUtil.AuditFields)
|
|
384
306
|
});
|
|
385
|
-
|
|
386
307
|
_defineProperty(ChecklistItem, "merge", childEntityName => _MergeUtil.default.getMergeFunction(childEntityName, mergeMap));
|
|
387
|
-
|
|
388
308
|
var _default = ChecklistItem;
|
|
389
309
|
exports.default = _default;
|