Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BAH 3455| Locale issue while sending request with diagnoses #247

Merged
merged 5 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;

import static java.util.stream.Collectors.toList;
Expand All @@ -37,16 +38,21 @@ public class BahmniDiagnosisMetadata {

private EncounterTransactionMapper encounterTransactionMapper;

private Concept getConceptsByNameAndLocale(String name, Locale locale) {
List<Concept> conceptList = conceptService.getConceptsByName(name, locale, false);
return conceptList.isEmpty() ? null : conceptList.get(0);
}

public Concept getBahmniInitialDiagnosisConcept() {
return conceptService.getConceptByName(BAHMNI_INITIAL_DIAGNOSIS);
return getConceptsByNameAndLocale(BAHMNI_INITIAL_DIAGNOSIS, Locale.ENGLISH);
}

public Concept getBahmniDiagnosisRevisedConcept() {
return conceptService.getConceptByName(BAHMNI_DIAGNOSIS_REVISED);
return getConceptsByNameAndLocale(BAHMNI_DIAGNOSIS_REVISED, Locale.ENGLISH);
}

public Concept getBahmniDiagnosisStatusConcept() {
return conceptService.getConceptByName(BAHMNI_DIAGNOSIS_STATUS);
return getConceptsByNameAndLocale(BAHMNI_DIAGNOSIS_STATUS, Locale.ENGLISH);
}

@Autowired
Expand Down Expand Up @@ -179,8 +185,8 @@ public Obs findMatchingDiagnosis(Collection<Obs> observations, BahmniDiagnosis b
private boolean isDiagnosisNotRevised(Obs obs) {
return !obs.getGroupMembers(false).stream()
.anyMatch(groupMember -> {
return groupMember.getConcept().equals(getBahmniDiagnosisRevisedConcept())
&& groupMember.getValueAsBoolean();});
return groupMember.getConcept().equals(getBahmniDiagnosisRevisedConcept())
&& groupMember.getValueAsBoolean();});
}

private boolean isDiagnosisMatching(Obs obs, EncounterTransaction.Diagnosis diagnosis) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.powermock.modules.junit4.PowerMockRunner;

import java.util.Arrays;
import java.util.List;
import java.util.Locale;

import static org.hamcrest.CoreMatchers.is;
Expand Down Expand Up @@ -82,7 +83,7 @@ public void shouldMatchCodedDiagnosis() {
Obs diagnosisObs =
new ObsBuilder().withConcept(diagnosisSetConcept)
.withGroupMembers(
new ObsBuilder().withConcept(codedDiagnosisConcept)
new ObsBuilder().withConcept(codedDiagnosisConcept)
.withValue(feverConcept).build(),
new ObsBuilder().withConcept(conceptForName("Diagnosis Order"))
.withValue(conceptForName("Primary")).build(),
Expand Down Expand Up @@ -213,7 +214,7 @@ public void shouldNotConsiderRevisedObsWhileFindingMatchingObs() throws Exceptio
when(properties.getDiagnosisMetadata().getCodedDiagnosisConcept()).thenReturn(codedDiagnosisConcept);
when(properties.getDiagnosisMetadata().getNonCodedDiagnosisConcept()).thenReturn(nonCodedDiagnosisConcept);
when(conceptService.getTrueConcept()).thenReturn(conceptTrue);
when(conceptService.getConceptByName(BAHMNI_DIAGNOSIS_REVISED)).thenReturn(revised);
when(conceptService.getConceptsByName(BAHMNI_DIAGNOSIS_REVISED,Locale.ENGLISH,false)).thenReturn(Arrays.asList(revised));
Concept feverConcept = conceptForName("Fever");
Obs aCodedDiagnosisObs =
new ObsBuilder().withConcept(diagnosisSetConcept)
Expand Down
Loading