Skip to content

Commit

Permalink
Merge pull request #510 from pawelskij/TRUNK-4164
Browse files Browse the repository at this point in the history
TRUNK-4164 Obs.getValueAsString(Locale locale) should localize name if O...
  • Loading branch information
dkayiwa committed Jan 7, 2014
2 parents 9af2420 + 8dda738 commit ef13389
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
4 changes: 2 additions & 2 deletions api/src/main/java/org/openmrs/Obs.java
Original file line number Diff line number Diff line change
Expand Up @@ -917,9 +917,9 @@ else if (abbrev.equals("CWE")) {
if (getValueDrug() != null)
return getValueDrug().getFullName(locale);
else {
ConceptName valueCodedName = getValueCodedName();
ConceptName valueCodedName = getValueCodedName();
if (valueCodedName != null) {
return valueCodedName.getName();
return getValueCoded().getName(locale, false).getName();
} else {
ConceptName fallbackName = getValueCoded().getName();
if (fallbackName != null) {
Expand Down
22 changes: 21 additions & 1 deletion api/src/test/java/org/openmrs/ObsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@
*/
public class ObsTest {

private static final String VERO = "Vero";

/**
* Tests the addToGroup method in ObsGroup
*
*
* @throws Exception
*/
@Test
Expand Down Expand Up @@ -348,4 +350,22 @@ public void isObsGrouping_shouldIncludeVoidedObs() throws Exception {
parent.addGroupMember(child);
assertTrue("When checking for Obs grouping, should include voided Obs", parent.isObsGrouping());
}

@Test
@Verifies(value = "should return localized name of the value coded concept", method = "getValueAsString(Locale)")
public void getValueAsString_shouldReturnLocalizedCodedConcept() throws Exception {
ConceptDatatype cdt = new ConceptDatatype();
cdt.setHl7Abbreviation("CWE");

Concept cn = new Concept();
cn.setDatatype(cdt);
cn.addName(new ConceptName(VERO, Locale.ITALIAN));

Obs obs = new Obs();
obs.setValueCoded(cn);
obs.setConcept(cn);
obs.setValueCodedName(new ConceptName("True", Locale.US));

Assert.assertEquals(VERO, obs.getValueAsString(Locale.ITALIAN));
}
}

0 comments on commit ef13389

Please sign in to comment.