openchs-models 1.21.0 → 1.22.2
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 +26 -6
- package/dist/Schema.js +1 -1
- package/dist/SubjectType.js +16 -0
- package/dist/application/Form.js +13 -4
- package/dist/application/FormElement.js +20 -0
- package/dist/application/FormElementGroup.js +30 -2
- 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(), ["uuid", "firstName", "lastName", "profilePicture", "dateOfBirthVerified", "voided"], ["dateOfBirth", "registrationDate"], ["observations"], entityService);
|
|
181
|
+
const individual = _General.default.assignFields(individualResource, new Individual(), ["uuid", "firstName", "middleName", "lastName", "profilePicture", "dateOfBirthVerified", "voided"], ["dateOfBirth", "registrationDate"], ["observations"], entityService);
|
|
180
182
|
|
|
181
183
|
individual.gender = gender;
|
|
182
184
|
individual.lowestAddressLevel = addressLevel;
|
|
183
|
-
individual.name = `${individual.firstName} ${individual.lastName}`;
|
|
185
|
+
individual.name = `${individual.firstName} ${individual.middleName ? individual.middleName : ''} ${individual.lastName}`;
|
|
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",
|
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
|
package/dist/application/Form.js
CHANGED
|
@@ -167,7 +167,8 @@ class Form {
|
|
|
167
167
|
sections.push({
|
|
168
168
|
groupName: feg.name,
|
|
169
169
|
groupUUID: feg.uuid,
|
|
170
|
-
observations: fegObs
|
|
170
|
+
observations: fegObs,
|
|
171
|
+
groupStyles: feg.styles
|
|
171
172
|
});
|
|
172
173
|
allObservations.push(...fegObs);
|
|
173
174
|
}
|
|
@@ -177,7 +178,8 @@ class Form {
|
|
|
177
178
|
if (!_lodash.default.isEmpty(decisionObs)) sections.push({
|
|
178
179
|
groupName: 'decisions',
|
|
179
180
|
groupUUID: null,
|
|
180
|
-
observations: decisionObs
|
|
181
|
+
observations: decisionObs,
|
|
182
|
+
groupStyles: {}
|
|
181
183
|
});
|
|
182
184
|
return sections;
|
|
183
185
|
}
|
|
@@ -209,9 +211,16 @@ class Form {
|
|
|
209
211
|
const isRepeatable = valueWrapper.isRepeatable();
|
|
210
212
|
const sortedChildObs = isRepeatable ? _lodash.default.flatMap(valueWrapper.getValue(), questionGroup => new _QuestionGroup.default(this.orderQuestionGroupObservations(questionGroup.getValue(), formElement.uuid))) : this.orderQuestionGroupObservations(valueWrapper.getValue(), formElement.uuid);
|
|
211
213
|
clonedObs.valueJSON = JSON.stringify(isRepeatable ? new _RepeatableQuestionGroup.default(sortedChildObs) : new _QuestionGroup.default(sortedChildObs));
|
|
212
|
-
|
|
214
|
+
|
|
215
|
+
if (!_lodash.default.isEmpty(sortedChildObs)) {
|
|
216
|
+
clonedObs.styles = formElement.styles;
|
|
217
|
+
orderedObservations.push(clonedObs);
|
|
218
|
+
}
|
|
213
219
|
} else {
|
|
214
|
-
if (!_lodash.default.isNil(foundObs))
|
|
220
|
+
if (!_lodash.default.isNil(foundObs)) {
|
|
221
|
+
foundObs.styles = formElement.styles;
|
|
222
|
+
orderedObservations.push(foundObs);
|
|
223
|
+
}
|
|
215
224
|
}
|
|
216
225
|
}
|
|
217
226
|
|
|
@@ -201,6 +201,26 @@ class FormElement {
|
|
|
201
201
|
return _lodash.default.isNil(unique) ? false : unique.getValue();
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
get styles() {
|
|
205
|
+
const style = {};
|
|
206
|
+
const backgroundColour = this.recordValueByKey("backgroundColour");
|
|
207
|
+
const textColour = this.recordValueByKey("textColour");
|
|
208
|
+
|
|
209
|
+
if (!_lodash.default.isEmpty(backgroundColour)) {
|
|
210
|
+
style['backgroundColor'] = backgroundColour;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (!_lodash.default.isEmpty(textColour)) {
|
|
214
|
+
style['color'] = textColour;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (!_lodash.default.isEmpty(style)) {
|
|
218
|
+
style['paddingHorizontal'] = 5;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return style;
|
|
222
|
+
}
|
|
223
|
+
|
|
204
224
|
matches(elementNameOrUUID) {
|
|
205
225
|
return this.name === elementNameOrUUID || this.uuid === elementNameOrUUID;
|
|
206
226
|
}
|
|
@@ -27,7 +27,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
27
27
|
|
|
28
28
|
class FormElementGroup {
|
|
29
29
|
static fromResource(resource, entityService) {
|
|
30
|
-
const formElementGroup = _General.default.assignFields(resource, new FormElementGroup(), ["uuid", "name", "displayOrder", "display", "voided", "rule", "startTime", "stayTime", "timed"]);
|
|
30
|
+
const formElementGroup = _General.default.assignFields(resource, new FormElementGroup(), ["uuid", "name", "displayOrder", "display", "voided", "rule", "startTime", "stayTime", "timed", "textColour", "backgroundColour"]);
|
|
31
31
|
|
|
32
32
|
formElementGroup.form = entityService.findByKey("uuid", _ResourceUtil.default.getUUIDFor(resource, "formUUID"), _Form.default.schema.name);
|
|
33
33
|
return formElementGroup;
|
|
@@ -65,6 +65,24 @@ class FormElementGroup {
|
|
|
65
65
|
return this.displayOrder === 1;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
get styles() {
|
|
69
|
+
const style = {};
|
|
70
|
+
|
|
71
|
+
if (!_lodash.default.isEmpty(this.backgroundColour)) {
|
|
72
|
+
style['backgroundColor'] = this.backgroundColour;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!_lodash.default.isEmpty(this.textColour)) {
|
|
76
|
+
style['color'] = this.textColour;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!_lodash.default.isEmpty(style)) {
|
|
80
|
+
style['paddingHorizontal'] = 5;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return style;
|
|
84
|
+
}
|
|
85
|
+
|
|
68
86
|
getFormElementsOfType(type) {
|
|
69
87
|
return _lodash.default.filter(this.formElements, formElement => formElement.concept.datatype === type || formElement.type === type);
|
|
70
88
|
}
|
|
@@ -169,7 +187,9 @@ class FormElementGroup {
|
|
|
169
187
|
formUUID: this.form.uuid,
|
|
170
188
|
startTime: this.startTime,
|
|
171
189
|
stayTime: this.stayTime,
|
|
172
|
-
timed: this.timed
|
|
190
|
+
timed: this.timed,
|
|
191
|
+
textColour: this.textColour,
|
|
192
|
+
backgroundColour: this.backgroundColour
|
|
173
193
|
};
|
|
174
194
|
}
|
|
175
195
|
|
|
@@ -210,6 +230,14 @@ _defineProperty(FormElementGroup, "schema", {
|
|
|
210
230
|
timed: {
|
|
211
231
|
type: "bool",
|
|
212
232
|
default: false
|
|
233
|
+
},
|
|
234
|
+
textColour: {
|
|
235
|
+
type: "string",
|
|
236
|
+
optional: true
|
|
237
|
+
},
|
|
238
|
+
backgroundColour: {
|
|
239
|
+
type: "string",
|
|
240
|
+
optional: true
|
|
213
241
|
}
|
|
214
242
|
}
|
|
215
243
|
});
|