openchs-models 1.22.0 → 1.22.3
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/Individual.js +30 -6
- package/dist/Schema.js +1 -1
- package/dist/SubjectType.js +16 -0
- package/package.json +1 -1
package/dist/Individual.js
CHANGED
|
@@ -83,6 +83,8 @@ class Individual extends _BaseEntity.default {
|
|
|
83
83
|
|
|
84
84
|
_defineProperty(this, "firstName", void 0);
|
|
85
85
|
|
|
86
|
+
_defineProperty(this, "middleName", void 0);
|
|
87
|
+
|
|
86
88
|
_defineProperty(this, "lastName", void 0);
|
|
87
89
|
|
|
88
90
|
_defineProperty(this, "profilePicture", void 0);
|
|
@@ -129,7 +131,7 @@ class Individual extends _BaseEntity.default {
|
|
|
129
131
|
}
|
|
130
132
|
|
|
131
133
|
get toResource() {
|
|
132
|
-
const resource = _lodash.default.pick(this, ["uuid", "firstName", "lastName", "profilePicture", "dateOfBirthVerified", "voided"]);
|
|
134
|
+
const resource = _lodash.default.pick(this, ["uuid", "firstName", "middleName", "lastName", "profilePicture", "dateOfBirthVerified", "voided"]);
|
|
133
135
|
|
|
134
136
|
resource.dateOfBirth = this.dateOfBirth ? (0, _moment.default)(this.dateOfBirth).format("YYYY-MM-DD") : null;
|
|
135
137
|
resource.registrationDate = (0, _moment.default)(this.registrationDate).format("YYYY-MM-DD");
|
|
@@ -176,11 +178,11 @@ class Individual extends _BaseEntity.default {
|
|
|
176
178
|
const gender = entityService.findByKey("uuid", _ResourceUtil.default.getUUIDFor(individualResource, "genderUUID"), _Gender.default.schema.name);
|
|
177
179
|
const subjectType = entityService.findByKey("uuid", _ResourceUtil.default.getUUIDFor(individualResource, "subjectTypeUUID"), _SubjectType.default.schema.name);
|
|
178
180
|
|
|
179
|
-
const individual = _General.default.assignFields(individualResource, new Individual(),
|
|
181
|
+
const individual = _General.default.assignFields(individualResource, new Individual(), this.directCopyFields, this.dateFields, ["observations"], entityService);
|
|
180
182
|
|
|
181
183
|
individual.gender = gender;
|
|
182
184
|
individual.lowestAddressLevel = addressLevel;
|
|
183
|
-
individual.name =
|
|
185
|
+
individual.name = individual.nameString;
|
|
184
186
|
if (!_lodash.default.isNil(individualResource.registrationLocation)) individual.registrationLocation = _Point.default.fromResource(individualResource.registrationLocation);
|
|
185
187
|
individual.subjectType = subjectType;
|
|
186
188
|
return individual;
|
|
@@ -254,6 +256,11 @@ class Individual extends _BaseEntity.default {
|
|
|
254
256
|
this.name = this.nameString;
|
|
255
257
|
}
|
|
256
258
|
|
|
259
|
+
setMiddleName(middleName) {
|
|
260
|
+
this.middleName = middleName;
|
|
261
|
+
this.name = this.nameString;
|
|
262
|
+
}
|
|
263
|
+
|
|
257
264
|
setLastName(lastName) {
|
|
258
265
|
this.lastName = lastName;
|
|
259
266
|
this.name = this.nameString;
|
|
@@ -285,7 +292,7 @@ class Individual extends _BaseEntity.default {
|
|
|
285
292
|
}
|
|
286
293
|
|
|
287
294
|
get nameString() {
|
|
288
|
-
return this.isPerson() ? `${this.firstName} ${this.lastName}` : this.firstName;
|
|
295
|
+
return this.isPerson() ? `${this.firstName} ${this.middleName ? this.middleName : ''} ${this.lastName}` : this.firstName;
|
|
289
296
|
} //TODO: this will be fixed later where we specify the option to create a template to display another unique field along with the name
|
|
290
297
|
|
|
291
298
|
|
|
@@ -368,10 +375,10 @@ class Individual extends _BaseEntity.default {
|
|
|
368
375
|
return validationResult;
|
|
369
376
|
}
|
|
370
377
|
|
|
371
|
-
validateName(value, validationKey, validFormat) {
|
|
378
|
+
validateName(value, validationKey, validFormat, mandatory = true) {
|
|
372
379
|
const failure = new _ValidationResult.default(false, validationKey);
|
|
373
380
|
|
|
374
|
-
if (_lodash.default.isEmpty(value)) {
|
|
381
|
+
if (_lodash.default.isEmpty(value) && mandatory) {
|
|
375
382
|
failure.messageKey = "emptyValidationMessage";
|
|
376
383
|
} else if (!_lodash.default.isEmpty(validFormat) && !validFormat.valid(value)) {
|
|
377
384
|
failure.messageKey = validFormat.descriptionKey;
|
|
@@ -386,6 +393,10 @@ class Individual extends _BaseEntity.default {
|
|
|
386
393
|
return this.validateName(this.firstName, Individual.validationKeys.FIRST_NAME, this.subjectType.validFirstNameFormat);
|
|
387
394
|
}
|
|
388
395
|
|
|
396
|
+
validateMiddleName() {
|
|
397
|
+
if (this.subjectType.allowMiddleName) return this.validateName(this.middleName, Individual.validationKeys.MIDDLE_NAME, this.subjectType.validMiddleNameFormat, false);
|
|
398
|
+
}
|
|
399
|
+
|
|
389
400
|
validateLastName() {
|
|
390
401
|
return this.validateName(this.lastName, Individual.validationKeys.LAST_NAME, this.subjectType.validLastNameFormat);
|
|
391
402
|
}
|
|
@@ -406,6 +417,7 @@ class Individual extends _BaseEntity.default {
|
|
|
406
417
|
validationResults.push(this.validateFirstName());
|
|
407
418
|
|
|
408
419
|
if (this.subjectType.isPerson()) {
|
|
420
|
+
validationResults.push(this.validateMiddleName());
|
|
409
421
|
validationResults.push(this.validateLastName());
|
|
410
422
|
validationResults.push(this.validateDateOfBirth());
|
|
411
423
|
validationResults.push(this.validateGender());
|
|
@@ -462,6 +474,7 @@ class Individual extends _BaseEntity.default {
|
|
|
462
474
|
individual.subjectType = this.subjectType.clone();
|
|
463
475
|
individual.name = this.name;
|
|
464
476
|
individual.firstName = this.firstName;
|
|
477
|
+
individual.middleName = this.middleName;
|
|
465
478
|
individual.lastName = this.lastName;
|
|
466
479
|
individual.profilePicture = this.profilePicture;
|
|
467
480
|
individual.dateOfBirth = this.dateOfBirth;
|
|
@@ -488,6 +501,7 @@ class Individual extends _BaseEntity.default {
|
|
|
488
501
|
individual.uuid = this.uuid;
|
|
489
502
|
individual.name = this.name;
|
|
490
503
|
individual.firstName = this.firstName;
|
|
504
|
+
individual.middleName = this.middleName;
|
|
491
505
|
individual.lastName = this.lastName;
|
|
492
506
|
individual.profilePicture = this.profilePicture;
|
|
493
507
|
individual.dateOfBirth = this.dateOfBirth;
|
|
@@ -800,6 +814,7 @@ class Individual extends _BaseEntity.default {
|
|
|
800
814
|
return {
|
|
801
815
|
uuid: this.uuid,
|
|
802
816
|
firstName: this.firstName,
|
|
817
|
+
middleName: this.middleName,
|
|
803
818
|
lastName: this.lastName,
|
|
804
819
|
profilePicture: this.profilePicture,
|
|
805
820
|
enrolments: this.enrolments,
|
|
@@ -830,6 +845,10 @@ _defineProperty(Individual, "schema", {
|
|
|
830
845
|
subjectType: "SubjectType",
|
|
831
846
|
name: "string",
|
|
832
847
|
firstName: "string",
|
|
848
|
+
middleName: {
|
|
849
|
+
type: "string",
|
|
850
|
+
optional: true
|
|
851
|
+
},
|
|
833
852
|
lastName: {
|
|
834
853
|
type: "string",
|
|
835
854
|
optional: true
|
|
@@ -899,6 +918,7 @@ _defineProperty(Individual, "validationKeys", {
|
|
|
899
918
|
DOB: "DOB",
|
|
900
919
|
GENDER: "GENDER",
|
|
901
920
|
FIRST_NAME: "FIRST_NAME",
|
|
921
|
+
MIDDLE_NAME: "MIDDLE_NAME",
|
|
902
922
|
LAST_NAME: "LAST_NAME",
|
|
903
923
|
PROFILE_PICTURE: "PROFILE_PICTURE",
|
|
904
924
|
REGISTRATION_DATE: "REGISTRATION_DATE",
|
|
@@ -915,6 +935,10 @@ _defineProperty(Individual, "nonIndividualValidationKeys", {
|
|
|
915
935
|
NAME: "NAME"
|
|
916
936
|
});
|
|
917
937
|
|
|
938
|
+
_defineProperty(Individual, "directCopyFields", ["uuid", "firstName", "middleName", "lastName", "profilePicture", "dateOfBirthVerified", "voided"]);
|
|
939
|
+
|
|
940
|
+
_defineProperty(Individual, "dateFields", ["dateOfBirth", "registrationDate"]);
|
|
941
|
+
|
|
918
942
|
_defineProperty(Individual, "merge", childEntityClass => _BaseEntity.default.mergeOn(new Map([[_ProgramEnrolment.default, "enrolments"], [_Encounter.default, "encounters"], [_IndividualRelationship.default, "relationships"], [_Comment.default, "comments"]]).get(childEntityClass)));
|
|
919
943
|
|
|
920
944
|
_defineProperty(Individual, "mergeMultipleParents", (childEntityClass, entities) => {
|
package/dist/Schema.js
CHANGED
|
@@ -174,7 +174,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
174
174
|
var _default = {
|
|
175
175
|
//order is important, should be arranged according to the dependency
|
|
176
176
|
schema: [_LocaleMapping.default, _Settings.default, _Concept.ConceptAnswer, _Concept.default, _EncounterType.default, _Gender.default, _UserDefinedIndividualProperty.default, _AddressLevel.LocationMapping, _AddressLevel.default, _KeyValue.default, _Form.default, _FormMapping.default, _FormElementGroup.default, _FormElement.default, _SubjectType.default, _Individual.default, _ProgramOutcome.default, _Program.default, _ProgramEnrolment.default, _Observation.default, _ProgramEncounter.default, _Encounter.default, _EntitySyncStatus.default, _EntityQueue.default, _ConfigFile.default, _Checklist.default, _ChecklistItem.default, _Format.default, _UserInfo.default, _StringKeyNumericValue.default, _VisitScheduleInterval.default, _VisitScheduleConfig.default, _ProgramConfig.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, _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],
|
|
177
|
-
schemaVersion:
|
|
177
|
+
schemaVersion: 159,
|
|
178
178
|
migration: function (oldDB, newDB) {
|
|
179
179
|
if (oldDB.schemaVersion < 10) {
|
|
180
180
|
var oldObjects = oldDB.objects("DecisionConfig");
|
package/dist/SubjectType.js
CHANGED
|
@@ -33,8 +33,12 @@ class SubjectType extends _ReferenceEntity.default {
|
|
|
33
33
|
|
|
34
34
|
_defineProperty(this, "uniqueName", void 0);
|
|
35
35
|
|
|
36
|
+
_defineProperty(this, "allowMiddleName", void 0);
|
|
37
|
+
|
|
36
38
|
_defineProperty(this, "validFirstNameFormat", void 0);
|
|
37
39
|
|
|
40
|
+
_defineProperty(this, "validMiddleNameFormat", void 0);
|
|
41
|
+
|
|
38
42
|
_defineProperty(this, "validLastNameFormat", void 0);
|
|
39
43
|
}
|
|
40
44
|
|
|
@@ -60,8 +64,10 @@ class SubjectType extends _ReferenceEntity.default {
|
|
|
60
64
|
subjectType.type = operationalSubjectType.type;
|
|
61
65
|
subjectType.subjectSummaryRule = operationalSubjectType.subjectSummaryRule;
|
|
62
66
|
subjectType.uniqueName = operationalSubjectType.uniqueName;
|
|
67
|
+
subjectType.allowMiddleName = operationalSubjectType.allowMiddleName;
|
|
63
68
|
subjectType.allowProfilePicture = operationalSubjectType.allowProfilePicture;
|
|
64
69
|
subjectType.validFirstNameFormat = _Format.default.fromResource(operationalSubjectType["validFirstNameFormat"]);
|
|
70
|
+
subjectType.validMiddleNameFormat = _Format.default.fromResource(operationalSubjectType["validMiddleNameFormat"]);
|
|
65
71
|
subjectType.validLastNameFormat = _Format.default.fromResource(operationalSubjectType["validLastNameFormat"]);
|
|
66
72
|
subjectType.iconFileS3Key = operationalSubjectType.iconFileS3Key;
|
|
67
73
|
subjectType.syncRegistrationConcept1 = _ResourceUtil.default.getUUIDFor(operationalSubjectType, 'syncRegistrationConcept1');
|
|
@@ -81,9 +87,11 @@ class SubjectType extends _ReferenceEntity.default {
|
|
|
81
87
|
cloned.type = this.type;
|
|
82
88
|
cloned.subjectSummaryRule = this.subjectSummaryRule;
|
|
83
89
|
cloned.allowEmptyLocation = this.allowEmptyLocation;
|
|
90
|
+
cloned.allowMiddleName = this.allowMiddleName;
|
|
84
91
|
cloned.allowProfilePicture = this.allowProfilePicture;
|
|
85
92
|
cloned.uniqueName = this.uniqueName;
|
|
86
93
|
cloned.validFirstNameFormat = this.validFirstNameFormat;
|
|
94
|
+
cloned.validMiddleNameFormat = this.validMiddleNameFormat;
|
|
87
95
|
cloned.validLastNameFormat = this.validLastNameFormat;
|
|
88
96
|
cloned.iconFileS3Key = this.iconFileS3Key;
|
|
89
97
|
cloned.syncRegistrationConcept1 = this.syncRegistrationConcept1;
|
|
@@ -153,6 +161,10 @@ _defineProperty(SubjectType, "schema", {
|
|
|
153
161
|
type: "Format",
|
|
154
162
|
optional: true
|
|
155
163
|
},
|
|
164
|
+
validMiddleNameFormat: {
|
|
165
|
+
type: "Format",
|
|
166
|
+
optional: true
|
|
167
|
+
},
|
|
156
168
|
validLastNameFormat: {
|
|
157
169
|
type: "Format",
|
|
158
170
|
optional: true
|
|
@@ -173,6 +185,10 @@ _defineProperty(SubjectType, "schema", {
|
|
|
173
185
|
type: 'bool',
|
|
174
186
|
default: false
|
|
175
187
|
},
|
|
188
|
+
allowMiddleName: {
|
|
189
|
+
type: 'bool',
|
|
190
|
+
default: false
|
|
191
|
+
},
|
|
176
192
|
nameHelpText: {
|
|
177
193
|
type: "string",
|
|
178
194
|
optional: true
|