Skip to content

Commit

Permalink
BAH-3407| Add check for concept to choose correct locale
Browse files Browse the repository at this point in the history
  • Loading branch information
poojadeshpande01 committed Jan 8, 2024
1 parent ddceedc commit 7c6384f
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
import org.openmrs.api.ConceptService;
import org.openmrs.api.ObsService;
import org.openmrs.api.VisitService;
import org.openmrs.api.context.Context;
import org.openmrs.module.bahmniemrapi.encountertransaction.contract.BahmniObservation;
import org.openmrs.module.bahmniemrapi.encountertransaction.mapper.OMRSObsToBahmniObsMapper;
import org.openmrs.util.LocaleUtility;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

Expand Down Expand Up @@ -69,11 +71,20 @@ public Collection<BahmniObservation> observationsFor(String patientUuid, Collect
private List<String> getConceptNames(Collection<Concept> concepts) {
List<String> conceptNames = new ArrayList<>();
for (Concept concept : concepts) {
conceptNames.add(concept.getName().getName());
if(concept != null) {
conceptNames.add(getConceptName(concept, Context.getLocale()));
}
}
return conceptNames;
}

private String getConceptName(Concept concept, Locale searchLocale) {
if (concept.getName(searchLocale) != null)
return concept.getName(searchLocale).getName();
else
return concept.getName(LocaleUtility.getDefaultLocale()).getName();
}

@Override
public Collection<BahmniObservation> observationsFor(String patientUuid, Concept rootConcept, Concept childConcept, Integer numberOfVisits, Date startDate, Date endDate, String patientProgramUuid) {
Collection<Encounter> encounters = programWorkflowService.getEncountersByPatientProgramUuid(patientProgramUuid);
Expand Down

0 comments on commit 7c6384f

Please sign in to comment.