Skip to content

Commit

Permalink
BAH-3102 | Add. Configurable Additional Patient Identifiers In Patien…
Browse files Browse the repository at this point in the history
…t Dashboard

* [Rahul] | BAH-3102 | Add. Additional Identifiers To Patient When Mapping

* [Rahul] | BAH-3102 | Add. Ability To Configure Additional Identifiers

* [Rahul] | BAH-3102 | Fix. Add If Null Check
  • Loading branch information
rahu1ramesh authored Jul 24, 2023
1 parent 4515cdb commit eb7d17b
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
<td class="value" ng-if="::!patient[attribute].isDateField">{{::(patient[attribute].value.display || patient[attribute].value) | booleanFilter}}</td>
<td class="value" ng-if="::patient[attribute].isDateField">{{::patient[attribute].value | bahmniDate}}</td>
</tr>
<tr ng-repeat="attribute in config.additionalPatientIdentifiers" ng-if="::patient.additionalIdentifiers[attribute]"
ng-show="::config.additionalPatientIdentifiers.length" ng-class="attribute">
<td class="name">{{patient.additionalIdentifiers[attribute].label}}</td>
<td class="value">{{patient.additionalIdentifiers[attribute].value}}</td>
</tr>
<tr ng-if="::relationships && relationships.length > 0">
<td>{{ 'PATIENT_PROFILE_RELATIONSHIPS_LABEL'|translate }}</td>
</tr>
Expand Down
15 changes: 15 additions & 0 deletions ui/app/common/patient/mappers/patientMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ Bahmni.PatientMapper = function (patientConfig, $rootScope, $translate) {
patient.identifier = primaryIdentifier ? primaryIdentifier : openmrsPatient.identifiers[0].identifier;
}

if (openmrsPatient.identifiers && openmrsPatient.identifiers.length > 1) {
patient.additionalIdentifiers = parseIdentifiers(openmrsPatient.identifiers.slice(1));
}

if (openmrsPatient.person.birthdate) {
patient.birthdate = parseDate(openmrsPatient.person.birthdate);
}
Expand Down Expand Up @@ -95,6 +99,17 @@ Bahmni.PatientMapper = function (patientConfig, $rootScope, $translate) {
return dateStr;
};

var parseIdentifiers = function (identifiers) {
var parseIdentifiers = {};
identifiers.forEach(function (identifier) {
if (identifier.identifierType) {
var label = identifier.identifierType.display;
parseIdentifiers[label] = {"label": label, "value": identifier.identifier};
}
});
return parseIdentifiers;
};

var mapGenderText = function (genderChar) {
if (genderChar == null) {
return null;
Expand Down
43 changes: 43 additions & 0 deletions ui/test/unit/common/patient/mappers/patientMapper.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,49 @@ describe('patient mapper', function () {
expect(patientMapper.mapBasic(patient).identifier).toEqual('OS1234');
});

it("should map additional identifiers if more than one identifier is there", function () {
var patient = {
"person": {
"birthdate": "1984-08-10T14:16:34.994+0530",
"birthdateEstimated": true,
"gender": "M",
"birthtime": "1970-01-01T04:20:00.000+0530",
"preferredName": {
"givenName": "Test",
"familyName": "Patient"
},
"preferredAddress": {
"preferred": true,
"address1": "Ad56",
"address2": null,
"address3": "Baria",
"address4": "Unions Of Gazipur Sadar Upazila",
"address5": "Gazipur Sadar",
"address6": null,
"cityVillage": null,
"countyDistrict": "Gazipur",
"stateProvince": "Dhaka",
"postalCode": null,
"country": null
}
},
"identifiers": [{
"identifier": "OS1234",
"primaryIdentifier": "BDH202048",
"extraIdentifiers": {"OpenMRS Identification Number": "OS1234"}
}, {
"identifier": "1234567891123",
"primaryIdentifier": undefined,
"identifierType": {
"uuid": "ada0b55b-0e3e-11ee-9960-0242ac150002",
"display": "ABHA Number",
},
}],
"uuid": "8a76aad9-9a2a-4686-de9c-caf0c89bc89c"
};
expect(patientMapper.mapBasic(patient).additionalIdentifiers).toEqual({ "ABHA Number" : { label : 'ABHA Number', value : '1234567891123' } } );
});

it("should map primary identifier if it is there", function () {
var patient = {
"person": {
Expand Down

0 comments on commit eb7d17b

Please sign in to comment.