openchs-models 1.33.19 → 1.33.21
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 +1 -4
- package/dist/Individual.js +18 -0
- package/dist/Schema.js +16 -2
- package/dist/SubjectLocation.js +83 -0
- package/dist/index.js +7 -0
- package/package.json +1 -1
package/.circleci/config.yml
CHANGED
package/dist/Individual.js
CHANGED
|
@@ -20,6 +20,7 @@ var _ObservationsHolder = _interopRequireDefault(require("./ObservationsHolder")
|
|
|
20
20
|
var _Media = require("./Media");
|
|
21
21
|
var _Point = _interopRequireDefault(require("./geo/Point"));
|
|
22
22
|
var _SubjectType = _interopRequireDefault(require("./SubjectType"));
|
|
23
|
+
var _SubjectLocation = _interopRequireDefault(require("./SubjectLocation"));
|
|
23
24
|
var _Observation = _interopRequireDefault(require("./Observation"));
|
|
24
25
|
var _GroupSubject = _interopRequireDefault(require("./GroupSubject"));
|
|
25
26
|
var _EntityApprovalStatus = _interopRequireDefault(require("./EntityApprovalStatus"));
|
|
@@ -143,6 +144,12 @@ class Individual extends _BaseEntity.default {
|
|
|
143
144
|
set registrationLocation(x) {
|
|
144
145
|
this.that.registrationLocation = this.fromObject(x);
|
|
145
146
|
}
|
|
147
|
+
get subjectLocation() {
|
|
148
|
+
return this.toEntity("subjectLocation", _SubjectLocation.default);
|
|
149
|
+
}
|
|
150
|
+
set subjectLocation(x) {
|
|
151
|
+
this.that.subjectLocation = this.fromObject(x);
|
|
152
|
+
}
|
|
146
153
|
get latestEntityApprovalStatus() {
|
|
147
154
|
return _lodash.default.maxBy(this.approvalStatuses, 'statusDateTime');
|
|
148
155
|
}
|
|
@@ -234,6 +241,9 @@ class Individual extends _BaseEntity.default {
|
|
|
234
241
|
if (!_lodash.default.isNil(this.registrationLocation)) {
|
|
235
242
|
resource["registrationLocation"] = this.registrationLocation.toResource;
|
|
236
243
|
}
|
|
244
|
+
if (!_lodash.default.isNil(this.subjectLocation)) {
|
|
245
|
+
resource["subjectLocation"] = this.subjectLocation.toResource;
|
|
246
|
+
}
|
|
237
247
|
resource["observations"] = [];
|
|
238
248
|
this.observations.forEach(obs => {
|
|
239
249
|
resource["observations"].push(obs.toResource);
|
|
@@ -276,6 +286,7 @@ class Individual extends _BaseEntity.default {
|
|
|
276
286
|
individual.lowestAddressLevel = this.initLowestAddressLevel(addressLevel, subjectType, entityService);
|
|
277
287
|
individual.name = individual.nameString;
|
|
278
288
|
if (!_lodash.default.isNil(individualResource.registrationLocation)) individual.registrationLocation = _Point.default.fromResource(individualResource.registrationLocation);
|
|
289
|
+
if (!_lodash.default.isNil(individualResource.subjectLocation)) individual.subjectLocation = _SubjectLocation.default.fromResource(individualResource.subjectLocation);
|
|
279
290
|
individual.subjectType = subjectType;
|
|
280
291
|
(0, _AuditUtil.mapAuditFields)(individual, individualResource);
|
|
281
292
|
return individual;
|
|
@@ -514,6 +525,7 @@ class Individual extends _BaseEntity.default {
|
|
|
514
525
|
individual.lowestAddressLevel = _lodash.default.isNil(this.lowestAddressLevel) ? null : _lodash.default.assignIn({}, this.lowestAddressLevel);
|
|
515
526
|
individual.observations = _ObservationsHolder.default.clone(this.observations);
|
|
516
527
|
individual.registrationLocation = _lodash.default.isNil(this.registrationLocation) ? null : this.registrationLocation.clone();
|
|
528
|
+
individual.subjectLocation = _lodash.default.isNil(this.subjectLocation) ? null : this.subjectLocation.clone();
|
|
517
529
|
individual.relationships = this.relationships;
|
|
518
530
|
individual.groupSubjects = this.groupSubjects;
|
|
519
531
|
individual.groups = this.groups;
|
|
@@ -839,6 +851,7 @@ class Individual extends _BaseEntity.default {
|
|
|
839
851
|
groups: this.groups,
|
|
840
852
|
voided: this.voided,
|
|
841
853
|
registrationLocation: this.registrationLocation,
|
|
854
|
+
subjectLocation: this.subjectLocation,
|
|
842
855
|
subjectType: this.subjectType,
|
|
843
856
|
comments: this.comments
|
|
844
857
|
};
|
|
@@ -923,6 +936,11 @@ _defineProperty(Individual, "schema", {
|
|
|
923
936
|
objectType: 'Point',
|
|
924
937
|
optional: true
|
|
925
938
|
},
|
|
939
|
+
subjectLocation: {
|
|
940
|
+
type: 'object',
|
|
941
|
+
objectType: 'SubjectLocation',
|
|
942
|
+
optional: true
|
|
943
|
+
},
|
|
926
944
|
comments: {
|
|
927
945
|
type: "list",
|
|
928
946
|
objectType: "Comment"
|
package/dist/Schema.js
CHANGED
|
@@ -96,9 +96,10 @@ var _MigrationsHelper = _interopRequireDefault(require("./MigrationsHelper"));
|
|
|
96
96
|
var _MetaDataService = _interopRequireDefault(require("./service/MetaDataService"));
|
|
97
97
|
var _ReportCardResult = _interopRequireDefault(require("./reports/ReportCardResult"));
|
|
98
98
|
var _NestedReportCardResult = _interopRequireDefault(require("./reports/NestedReportCardResult"));
|
|
99
|
+
var _SubjectLocation = _interopRequireDefault(require("./SubjectLocation"));
|
|
99
100
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
100
101
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
101
|
-
const entities = [_ReportCardResult.default, _NestedReportCardResult.default, _DashboardFilter.default, _LocaleMapping.default, _Settings.default, _ConceptAnswer.default, _ConceptMedia.default, _Concept.default, _EncounterType.default, _Gender.default, _AddressLevel.LocationMapping, _AddressLevel.default, _KeyValue.default, _Form.default, _FormMapping.default, _FormElementGroup.default, _FormElement.default, _SubjectType.default, _Individual.default, _Program.default, _ProgramEnrolment.default, _Observation.default, _ProgramEncounter.default, _Encounter.default, _EntitySyncStatus.default, _EntityQueue.default, _Checklist.default, _ChecklistItem.default, _Format.default, _UserInfo.default, _StringKeyNumericValue.default, _Family.default, _IndividualRelation.default, _IndividualRelationGenderMapping.default, _IndividualRelationshipType.default, _IndividualRelationship.default, _RuleDependency.default, _Rule.default, _ChecklistItemStatus.default, _ChecklistDetail.default, _ChecklistItemDetail.default, _VideoTelemetric.default, _Video.default, _MediaQueue.default, _Point.default, _SyncTelemetry.default, _IdentifierSource.default, _IdentifierAssignment.default, _RuleFailureTelemetry.default, _BeneficiaryModePin.default, _OrganisationConfig.default, _PlatformTranslation.default, _Translation.default, _Groups.default, _MyGroups.default, _GroupPrivileges.default, _Privilege.default, _GroupRole.default, _GroupSubject.default, _DashboardCache.default, _CustomDashboardCache.default, _LocationHierarchy.default, _ReportCard.default, _Dashboard.default, _DashboardSectionCardMapping.default, _DraftSubject.default, _StandardReportCardType.default, _ApprovalStatus.default, _EntityApprovalStatus.default, _GroupDashboard.default, _DashboardSection.default, _News.default, _Comment.default, _CommentThread.default, _Extension.default, _SubjectMigration.default, _ResetSync.default, _Documentation.default, _DocumentationItem.default, _TaskType.default, _TaskStatus.default, _Task.default, _TaskUnAssignment.default, _DraftEncounter.default, _SubjectProgramEligibility.default, _MenuItem.default, _UserSubjectAssignment.default];
|
|
102
|
+
const entities = [_ReportCardResult.default, _NestedReportCardResult.default, _SubjectLocation.default, _DashboardFilter.default, _LocaleMapping.default, _Settings.default, _ConceptAnswer.default, _ConceptMedia.default, _Concept.default, _EncounterType.default, _Gender.default, _AddressLevel.LocationMapping, _AddressLevel.default, _KeyValue.default, _Form.default, _FormMapping.default, _FormElementGroup.default, _FormElement.default, _SubjectType.default, _Individual.default, _Program.default, _ProgramEnrolment.default, _Observation.default, _ProgramEncounter.default, _Encounter.default, _EntitySyncStatus.default, _EntityQueue.default, _Checklist.default, _ChecklistItem.default, _Format.default, _UserInfo.default, _StringKeyNumericValue.default, _Family.default, _IndividualRelation.default, _IndividualRelationGenderMapping.default, _IndividualRelationshipType.default, _IndividualRelationship.default, _RuleDependency.default, _Rule.default, _ChecklistItemStatus.default, _ChecklistDetail.default, _ChecklistItemDetail.default, _VideoTelemetric.default, _Video.default, _MediaQueue.default, _Point.default, _SyncTelemetry.default, _IdentifierSource.default, _IdentifierAssignment.default, _RuleFailureTelemetry.default, _BeneficiaryModePin.default, _OrganisationConfig.default, _PlatformTranslation.default, _Translation.default, _Groups.default, _MyGroups.default, _GroupPrivileges.default, _Privilege.default, _GroupRole.default, _GroupSubject.default, _DashboardCache.default, _CustomDashboardCache.default, _LocationHierarchy.default, _ReportCard.default, _Dashboard.default, _DashboardSectionCardMapping.default, _DraftSubject.default, _StandardReportCardType.default, _ApprovalStatus.default, _EntityApprovalStatus.default, _GroupDashboard.default, _DashboardSection.default, _News.default, _Comment.default, _CommentThread.default, _Extension.default, _SubjectMigration.default, _ResetSync.default, _Documentation.default, _DocumentationItem.default, _TaskType.default, _TaskStatus.default, _Task.default, _TaskUnAssignment.default, _DraftEncounter.default, _SubjectProgramEligibility.default, _MenuItem.default, _UserSubjectAssignment.default];
|
|
102
103
|
function migrateObjectTypeFieldToEmbedded(newDB, oldDB, schemaName, field, creatorFn) {
|
|
103
104
|
console.log(`schema: ${schemaName}, field: ${field}`);
|
|
104
105
|
newDB.objects(schemaName).forEach(newDbParentEntity => {
|
|
@@ -177,7 +178,7 @@ function createRealmConfig() {
|
|
|
177
178
|
return doCompact;
|
|
178
179
|
},
|
|
179
180
|
//order is important, should be arranged according to the dependency
|
|
180
|
-
schemaVersion:
|
|
181
|
+
schemaVersion: 206,
|
|
181
182
|
onMigration: function (oldDB, newDB) {
|
|
182
183
|
console.log("[AvniModels.Schema]", `Running migration with old schema version: ${oldDB.schemaVersion} and new schema version: ${newDB.schemaVersion}`);
|
|
183
184
|
if (oldDB.schemaVersion === VersionWithEmbeddedMigrationProblem) throw new Error(`Update from schema version ${VersionWithEmbeddedMigrationProblem} is not allowed. Please uninstall and install app.`);
|
|
@@ -760,6 +761,19 @@ function createRealmConfig() {
|
|
|
760
761
|
}
|
|
761
762
|
});
|
|
762
763
|
}
|
|
764
|
+
if (oldDB.schemaVersion < 205) {
|
|
765
|
+
_lodash.default.forEach(newDB.objects("Concept"), concept => {
|
|
766
|
+
const oldConcept = oldDB.objects("Concept").filtered(`uuid = "${concept.uuid}"`)[0];
|
|
767
|
+
if (oldConcept && oldConcept.mediaUrl && oldConcept.mediaType) {
|
|
768
|
+
const conceptMedia = {
|
|
769
|
+
uuid: _General.default.randomUUID(),
|
|
770
|
+
url: oldConcept.mediaUrl,
|
|
771
|
+
type: oldConcept.mediaType
|
|
772
|
+
};
|
|
773
|
+
concept.media.push(conceptMedia);
|
|
774
|
+
}
|
|
775
|
+
});
|
|
776
|
+
}
|
|
763
777
|
}
|
|
764
778
|
};
|
|
765
779
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _PersistedObject = _interopRequireDefault(require("./PersistedObject"));
|
|
8
|
+
var _Point = _interopRequireDefault(require("./geo/Point"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
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; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
12
|
+
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); }
|
|
13
|
+
class SubjectLocation extends _PersistedObject.default {
|
|
14
|
+
constructor(that = null) {
|
|
15
|
+
super(that);
|
|
16
|
+
}
|
|
17
|
+
get coordinates() {
|
|
18
|
+
return this.toEntity("coordinates", _Point.default);
|
|
19
|
+
}
|
|
20
|
+
set coordinates(x) {
|
|
21
|
+
this.that.coordinates = this.fromObject(x);
|
|
22
|
+
}
|
|
23
|
+
get accuracy() {
|
|
24
|
+
return this.that.accuracy;
|
|
25
|
+
}
|
|
26
|
+
set accuracy(accuracy) {
|
|
27
|
+
this.that.accuracy = accuracy;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Convenience methods for latitude/longitude access
|
|
31
|
+
get latitude() {
|
|
32
|
+
return this.coordinates ? this.coordinates.y : null;
|
|
33
|
+
}
|
|
34
|
+
get longitude() {
|
|
35
|
+
return this.coordinates ? this.coordinates.x : null;
|
|
36
|
+
}
|
|
37
|
+
static newInstance(position, accuracy) {
|
|
38
|
+
const subjectLocation = new SubjectLocation();
|
|
39
|
+
subjectLocation.coordinates = position;
|
|
40
|
+
subjectLocation.accuracy = accuracy;
|
|
41
|
+
return subjectLocation;
|
|
42
|
+
}
|
|
43
|
+
static fromResource(resource) {
|
|
44
|
+
const subjectLocation = new SubjectLocation();
|
|
45
|
+
if (resource.coordinates) {
|
|
46
|
+
subjectLocation.coordinates = _Point.default.fromResource(resource.coordinates);
|
|
47
|
+
}
|
|
48
|
+
subjectLocation.accuracy = resource.accuracy;
|
|
49
|
+
return subjectLocation;
|
|
50
|
+
}
|
|
51
|
+
get toResource() {
|
|
52
|
+
const resource = {};
|
|
53
|
+
if (this.coordinates) {
|
|
54
|
+
resource.coordinates = this.coordinates.toResource;
|
|
55
|
+
}
|
|
56
|
+
resource.accuracy = this.accuracy;
|
|
57
|
+
return resource;
|
|
58
|
+
}
|
|
59
|
+
clone() {
|
|
60
|
+
const cloned = new SubjectLocation();
|
|
61
|
+
if (this.coordinates) {
|
|
62
|
+
cloned.coordinates = this.coordinates.clone();
|
|
63
|
+
}
|
|
64
|
+
cloned.accuracy = this.accuracy;
|
|
65
|
+
return cloned;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
_defineProperty(SubjectLocation, "schema", {
|
|
69
|
+
name: "SubjectLocation",
|
|
70
|
+
properties: {
|
|
71
|
+
coordinates: {
|
|
72
|
+
type: 'object',
|
|
73
|
+
objectType: 'Point',
|
|
74
|
+
optional: true
|
|
75
|
+
},
|
|
76
|
+
accuracy: {
|
|
77
|
+
type: "double",
|
|
78
|
+
optional: true
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
var _default = SubjectLocation;
|
|
83
|
+
exports.default = _default;
|
package/dist/index.js
CHANGED
|
@@ -831,6 +831,12 @@ Object.defineProperty(exports, "NestedReportCardResult", {
|
|
|
831
831
|
return _NestedReportCardResult.default;
|
|
832
832
|
}
|
|
833
833
|
});
|
|
834
|
+
Object.defineProperty(exports, "SubjectLocation", {
|
|
835
|
+
enumerable: true,
|
|
836
|
+
get: function () {
|
|
837
|
+
return _SubjectLocation.default;
|
|
838
|
+
}
|
|
839
|
+
});
|
|
834
840
|
var _AbstractEncounter = _interopRequireDefault(require("./AbstractEncounter"));
|
|
835
841
|
var _AddressLevel = _interopRequireWildcard(require("./AddressLevel"));
|
|
836
842
|
var _BaseEntity = _interopRequireDefault(require("./BaseEntity"));
|
|
@@ -964,5 +970,6 @@ var _Locations = _interopRequireDefault(require("./location/Locations"));
|
|
|
964
970
|
var _Range = _interopRequireDefault(require("./reports/Range"));
|
|
965
971
|
var _ReportCardResult = _interopRequireDefault(require("./reports/ReportCardResult"));
|
|
966
972
|
var _NestedReportCardResult = _interopRequireDefault(require("./reports/NestedReportCardResult"));
|
|
973
|
+
var _SubjectLocation = _interopRequireDefault(require("./SubjectLocation"));
|
|
967
974
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
968
975
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|