From 02854d235e6b1afe85e65cfdebbe7765e4e45ecd Mon Sep 17 00:00:00 2001 From: Siva Reddy Date: Wed, 15 Nov 2023 15:26:00 +0530 Subject: [PATCH] BAH-3266 | Siva Reddy | Fetching concepts from default locale if no concepts in requested locale --- .github/workflows/build_upload.yml | 1 + openmrs/obscalculator/BahmniObsValueCalculator.groovy | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/build_upload.yml b/.github/workflows/build_upload.yml index f770d8a31..e1e4071b7 100644 --- a/.github/workflows/build_upload.yml +++ b/.github/workflows/build_upload.yml @@ -4,6 +4,7 @@ on: branches: - master - 'release-*' + - BAH-3266-test tags: - '[0-9]+.[0-9]+.[0-9]+' paths-ignore: diff --git a/openmrs/obscalculator/BahmniObsValueCalculator.groovy b/openmrs/obscalculator/BahmniObsValueCalculator.groovy index 91a4a0e86..3bb3270f9 100644 --- a/openmrs/obscalculator/BahmniObsValueCalculator.groovy +++ b/openmrs/obscalculator/BahmniObsValueCalculator.groovy @@ -11,6 +11,7 @@ import org.openmrs.api.context.Context; import org.openmrs.module.bahmniemrapi.obscalculator.ObsValueCalculator; import org.openmrs.module.bahmniemrapi.encountertransaction.contract.BahmniEncounterTransaction import org.openmrs.module.emrapi.encounter.domain.EncounterTransaction; +import org.openmrs.util.LocaleUtility; import org.joda.time.LocalDate; import org.joda.time.Months; @@ -232,6 +233,12 @@ public class BahmniObsValueCalculator implements ObsValueCalculator { static BahmniObservation createObs(String conceptName, BahmniObservation parent, BahmniEncounterTransaction encounterTransaction, Date obsDatetime) { def concept = Context.getConceptService().getConceptByName(conceptName) + if (StringUtils.isEmpty(concept) && !LocaleUtility.getDefaultLocale().equals(Context.getLocale())) { + def conceptsByName = Context.getConceptService().getConceptsByName(conceptName, LocaleUtility.getDefaultLocale(), false); + if (!StringUtils.isEmpty(concept)) { + concept = conceptsByName[0]; + } + } BahmniObservation newObservation = new BahmniObservation() newObservation.setConcept(new EncounterTransaction.Concept(concept.getUuid(), conceptName)) newObservation.setObservationDateTime(obsDatetime);