Skip to content

Commit

Permalink
BAH-3266 | Siva Reddy | Fetching concepts from default locale if no c…
Browse files Browse the repository at this point in the history
…oncepts in requested locale
  • Loading branch information
sivareddyp committed Nov 15, 2023
1 parent 3359332 commit 145f4f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build_upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- master
- 'release-*'
- BAH-3266-test
tags:
- '[0-9]+.[0-9]+.[0-9]+'
paths-ignore:
Expand Down
12 changes: 12 additions & 0 deletions openmrs/obscalculator/BahmniObsValueCalculator.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,6 +27,8 @@ public class BahmniObsValueCalculator implements ObsValueCalculator {
static Double BMI_SEVERELY_OBESE = 40.0;
static Double ZERO = 0.0;
static Map<BahmniObservation, BahmniObservation> obsParentMap = new HashMap<BahmniObservation, BahmniObservation>();
static def logger = new File(OpenmrsUtil.getApplicationDataDirectory() + "groovy_debug.txt")


public static enum BmiStatus {
VERY_SEVERELY_UNDERWEIGHT("Very Severely Underweight"),
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 145f4f1

Please sign in to comment.