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 99f79a7
Show file tree
Hide file tree
Showing 2 changed files with 9 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
8 changes: 8 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 @@ -27,6 +28,7 @@ public class BahmniObsValueCalculator implements ObsValueCalculator {
static Double ZERO = 0.0;
static Map<BahmniObservation, BahmniObservation> obsParentMap = new HashMap<BahmniObservation, BahmniObservation>();


public static enum BmiStatus {
VERY_SEVERELY_UNDERWEIGHT("Very Severely Underweight"),
SEVERELY_UNDERWEIGHT("Severely Underweight"),
Expand Down Expand Up @@ -232,6 +234,12 @@ public class BahmniObsValueCalculator implements ObsValueCalculator {

static BahmniObservation createObs(String conceptName, BahmniObservation parent, BahmniEncounterTransaction encounterTransaction, Date obsDatetime) {
def concept = Context.getConceptService().getConceptByName(conceptName)
if (concept == null && !LocaleUtility.getDefaultLocale().equals(Context.getLocale())) {
List<Concept> conceptsByName = Context.getConceptService().getConceptsByName(conceptName, LocaleUtility.getDefaultLocale(), false);
if (!conceptsByName.isEmpty()) {
concept = conceptsByName[0];
}
}
BahmniObservation newObservation = new BahmniObservation()
newObservation.setConcept(new EncounterTransaction.Concept(concept.getUuid(), conceptName))
newObservation.setObservationDateTime(obsDatetime);
Expand Down

0 comments on commit 99f79a7

Please sign in to comment.