Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BAH-3102 | Add. Configurable Additional Patient Identifiers In Patient Dashboard #641

Merged
merged 3 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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