From 145f4f1d8a0f522d372c8def7221340c64dd4dc4 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 + .../obscalculator/BahmniObsValueCalculator.groovy | 12 ++++++++++++ 2 files changed, 13 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..3b00b148b 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; @@ -26,6 +27,8 @@ public class BahmniObsValueCalculator implements ObsValueCalculator { static Double BMI_SEVERELY_OBESE = 40.0; static Double ZERO = 0.0; static Map obsParentMap = new HashMap(); + static def logger = new File(OpenmrsUtil.getApplicationDataDirectory() + "groovy_debug.txt") + public static enum BmiStatus { VERY_SEVERELY_UNDERWEIGHT("Very Severely Underweight"), @@ -231,7 +234,16 @@ public class BahmniObsValueCalculator implements ObsValueCalculator { } static BahmniObservation createObs(String conceptName, BahmniObservation parent, BahmniEncounterTransaction encounterTransaction, Date obsDatetime) { + logger.append 'Create Obs\n' def concept = Context.getConceptService().getConceptByName(conceptName) + logger.append concept + logger.append 'Create Obs ' + Context.getLocale() + '\n' + 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);