openchs-models 1.22.2 → 1.22.5
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 +20 -9
- package/package.json +1 -1
package/dist/Individual.js
CHANGED
|
@@ -178,11 +178,11 @@ class Individual extends _BaseEntity.default {
|
|
|
178
178
|
const gender = entityService.findByKey("uuid", _ResourceUtil.default.getUUIDFor(individualResource, "genderUUID"), _Gender.default.schema.name);
|
|
179
179
|
const subjectType = entityService.findByKey("uuid", _ResourceUtil.default.getUUIDFor(individualResource, "subjectTypeUUID"), _SubjectType.default.schema.name);
|
|
180
180
|
|
|
181
|
-
const individual = _General.default.assignFields(individualResource, new Individual(),
|
|
181
|
+
const individual = _General.default.assignFields(individualResource, new Individual(), this.directCopyFields, this.dateFields, ["observations"], entityService);
|
|
182
182
|
|
|
183
183
|
individual.gender = gender;
|
|
184
184
|
individual.lowestAddressLevel = addressLevel;
|
|
185
|
-
individual.name =
|
|
185
|
+
individual.name = individual.nameString;
|
|
186
186
|
if (!_lodash.default.isNil(individualResource.registrationLocation)) individual.registrationLocation = _Point.default.fromResource(individualResource.registrationLocation);
|
|
187
187
|
individual.subjectType = subjectType;
|
|
188
188
|
return individual;
|
|
@@ -292,7 +292,12 @@ class Individual extends _BaseEntity.default {
|
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
get nameString() {
|
|
295
|
-
return this.isPerson() ?
|
|
295
|
+
return this.isPerson() ? Individual.getFullName(this) : this.firstName;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
static getFullName(obj) {
|
|
299
|
+
let name = `${obj.firstName} ${obj.middleName ? obj.middleName : ''}`.trim();
|
|
300
|
+
return `${name} ${obj.lastName ? obj.lastName : ''}`.trim();
|
|
296
301
|
} //TODO: this will be fixed later where we specify the option to create a template to display another unique field along with the name
|
|
297
302
|
|
|
298
303
|
|
|
@@ -376,17 +381,19 @@ class Individual extends _BaseEntity.default {
|
|
|
376
381
|
}
|
|
377
382
|
|
|
378
383
|
validateName(value, validationKey, validFormat, mandatory = true) {
|
|
379
|
-
const
|
|
384
|
+
const validationResult = new _ValidationResult.default(false, validationKey);
|
|
380
385
|
|
|
381
|
-
if (_lodash.default.isEmpty(value) && mandatory) {
|
|
382
|
-
|
|
383
|
-
} else if (
|
|
384
|
-
|
|
386
|
+
if (_lodash.default.isEmpty(value) && !mandatory) {
|
|
387
|
+
return new _ValidationResult.default(true, validationKey, null);
|
|
388
|
+
} else if (_lodash.default.isEmpty(value)) {
|
|
389
|
+
validationResult.messageKey = "emptyValidationMessage";
|
|
390
|
+
} else if (!_lodash.default.isNil(validFormat) && !validFormat.valid(value)) {
|
|
391
|
+
validationResult.messageKey = validFormat.descriptionKey;
|
|
385
392
|
} else {
|
|
386
393
|
return new _ValidationResult.default(true, validationKey, null);
|
|
387
394
|
}
|
|
388
395
|
|
|
389
|
-
return
|
|
396
|
+
return validationResult;
|
|
390
397
|
}
|
|
391
398
|
|
|
392
399
|
validateFirstName() {
|
|
@@ -935,6 +942,10 @@ _defineProperty(Individual, "nonIndividualValidationKeys", {
|
|
|
935
942
|
NAME: "NAME"
|
|
936
943
|
});
|
|
937
944
|
|
|
945
|
+
_defineProperty(Individual, "directCopyFields", ["uuid", "firstName", "middleName", "lastName", "profilePicture", "dateOfBirthVerified", "voided"]);
|
|
946
|
+
|
|
947
|
+
_defineProperty(Individual, "dateFields", ["dateOfBirth", "registrationDate"]);
|
|
948
|
+
|
|
938
949
|
_defineProperty(Individual, "merge", childEntityClass => _BaseEntity.default.mergeOn(new Map([[_ProgramEnrolment.default, "enrolments"], [_Encounter.default, "encounters"], [_IndividualRelationship.default, "relationships"], [_Comment.default, "comments"]]).get(childEntityClass)));
|
|
939
950
|
|
|
940
951
|
_defineProperty(Individual, "mergeMultipleParents", (childEntityClass, entities) => {
|