Skip to content

Commit

Permalink
Concept references header on the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
dicksonmulli committed Aug 28, 2024
1 parent 97bd354 commit 45c5846
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.openmrs.ConceptMapType;
import org.openmrs.ConceptName;
import org.openmrs.ConceptNumeric;
import org.openmrs.ConceptReferenceRange;
import org.openmrs.ConceptReferenceTerm;
import org.openmrs.ConceptSet;
import org.openmrs.Drug;
Expand Down Expand Up @@ -459,7 +460,7 @@ public class ConceptFormBackingObject {

public Collection<ConceptAttribute> activeAttributes;

// public List<ConceptReferenceRange> conceptReferenceRanges = new ArrayList<>();
public Set<ConceptReferenceRange> referenceRanges = new HashSet<>();

/**
* Default constructor must take in a Concept object to create itself
Expand Down Expand Up @@ -529,6 +530,11 @@ public ConceptFormBackingObject(Concept concept) {
}

this.activeAttributes = concept.getActiveAttributes();

if (concept.getDatatype().getName().equals("Numeric")

This comment has been minimized.

Copy link
@dkayiwa

dkayiwa Aug 28, 2024

Member

Why not just use concept.isNumeric()?

&& concept instanceof ConceptNumeric) {
this.referenceRanges = ((ConceptNumeric) concept).getReferenceRanges();
}
}

/**
Expand Down Expand Up @@ -663,6 +669,7 @@ public Concept getConceptFromFormData() {
cn.setAllowDecimal(allowDecimal);
cn.setDisplayPrecision(displayPrecision);
cn.setUnits(units);
cn.setReferenceRanges(referenceRanges);

concept = cn;

Expand Down
28 changes: 0 additions & 28 deletions omod/src/main/webapp/admin/dictionary/concept.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -319,34 +319,6 @@
</table>
</td>
</tr>
<tr id="referenceRangeRow">
<th valign="top" style="padding-top: 8px" title="<openmrs:message code="Concept.references"/>">
<openmrs:message code="Concept.references"/>
</th>
<td>
<table cellpadding="5" cellspacing="3" align="left" class="lightBorderBox">
<tr <c:if test="${fn:length(command.referenceRange) == 0}">style="display:none"</c:if>>
<th style="text-align: center"><openmrs:message code="Concept.referenceRange.hiAbsolute"/></th>
<th style="text-align: center"><openmrs:message code="Concept.referenceRange.lowAbsolute"/></th>
<th style="text-align: center"><openmrs:message code="Concept.referenceRange.hiNormal"/></th>
<th style="text-align: center"><openmrs:message code="Concept.referenceRange.lowNormal"/></th>
<th style="text-align: center"><openmrs:message code="Concept.referenceRange.hiCritical"/></th>
<th style="text-align: center"><openmrs:message code="Concept.referenceRange.lowCritical"/></th>
</tr>
<c:forEach var="reference" items="${reference.referenceRanges}" varStatus="mapStatus">
<tr <c:if test="${mapStatus.index % 2 == 0}">class='evenRow'</c:if>>
<td><c:out value="${reference.conceptReference.hiAbsolute}"/></td>
<td><c:out value="${reference.conceptReference.lowAbsolute}"/></td>
<td><c:out value="${reference.conceptReference.hiNormal}"/></td>
<td><c:out value="${reference.conceptReference.lowNormal}"/></td>
<td><c:out value="${reference.conceptReference.hiCritical}"/></td>
<td><c:out value="${reference.conceptReference.lowCritical}"/></td>
</tr>
</c:forEach>

</table>
</td>
</tr>

<c:if test="${command.concept.complex}">
<tr>
Expand Down
28 changes: 0 additions & 28 deletions omod/src/main/webapp/dictionary/concept.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -322,34 +322,6 @@
</table>
</td>
</tr>
<tr id="referenceRangeRow">
<th valign="top" style="padding-top: 8px" title="<openmrs:message code="Concept.references"/>">
<openmrs:message code="Concept.references"/>
</th>
<td>
<table cellpadding="5" cellspacing="3" align="left" class="lightBorderBox">
<tr <c:if test="${fn:length(command.referenceRange) == 0}">style="display:none"</c:if>>
<th style="text-align: center"><openmrs:message code="Concept.referenceRange.hiAbsolute"/></th>
<th style="text-align: center"><openmrs:message code="Concept.referenceRange.lowAbsolute"/></th>
<th style="text-align: center"><openmrs:message code="Concept.referenceRange.hiNormal"/></th>
<th style="text-align: center"><openmrs:message code="Concept.referenceRange.lowNormal"/></th>
<th style="text-align: center"><openmrs:message code="Concept.referenceRange.hiCritical"/></th>
<th style="text-align: center"><openmrs:message code="Concept.referenceRange.lowCritical"/></th>
</tr>
<c:forEach var="reference" items="${reference.referenceRanges}" varStatus="mapStatus">
<tr <c:if test="${mapStatus.index % 2 == 0}">class='evenRow'</c:if>>
<td><c:out value="${reference.conceptReference.hiAbsolute}"/></td>
<td><c:out value="${reference.conceptReference.lowAbsolute}"/></td>
<td><c:out value="${reference.conceptReference.hiNormal}"/></td>
<td><c:out value="${reference.conceptReference.lowNormal}"/></td>
<td><c:out value="${reference.conceptReference.hiCritical}"/></td>
<td><c:out value="${reference.conceptReference.lowCritical}"/></td>
</tr>
</c:forEach>

</table>
</td>
</tr>

<c:forEach var="attribute" items="${command.concept.activeAttributes}">
<tr id="conceptAttributeRow">
Expand Down
33 changes: 32 additions & 1 deletion omod/src/main/webapp/dictionary/conceptForm.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@
<td colspan="3" valign="top" align="left">
<c:choose>
<c:when test="${sourceID != null}">
<input id="addMapButton" type="button" value='<openmrs:message code="Concept.mapping.add"/>' class="smallButton"

This comment has been minimized.

Copy link
@dkayiwa

dkayiwa Aug 28, 2024

Member

Do you mind explaining the above change?

This comment has been minimized.

Copy link
@dicksonmulli

dicksonmulli Aug 28, 2024

Author

I was just testing something with this - I wanted to check which form to use. I have reverted this, and will be in the next commit. (It's in the spirit of pushing code after few changes)

This comment has been minimized.

Copy link
@dkayiwa

dkayiwa Aug 28, 2024

Member

Oh i see!!! Sounds fair enough 😊

<input id="addMapButton" type="button" value='<openmrs:message code="Concept.mappings.sourceCodeRequired"/>' class="smallButton"
onClick="addConceptMapping(${fn:length(command.conceptMappings)})" />
</c:when>
<c:otherwise>
Expand All @@ -815,6 +815,37 @@
</table>
</td>
</tr>
<tr id="referenceRangeRow">Concept.referenceRanges
<th valign="top" style="padding-top: 8px" title="<openmrs:message code="Concept.referenceRanges.help"/>">
<openmrs:message code="Concept.referenceRanges"/>
</th>
<td>
<table cellpadding="5" cellspacing="3" align="left" class="lightBorderBox">
<tr id="conceptReferenceRangeHeadersRow" <c:if test="${fn:length(command.referenceRanges) == 0}">style="display:none"</c:if>>
<th style="text-align: center"><openmrs:message code="ConceptNumeric.absoluteHigh"/></th>
<th style="text-align: center"><openmrs:message code="ConceptNumeric.absoluteLow"/></th>
<th style="text-align: center"><openmrs:message code="ConceptNumeric.criticalHigh"/></th>
<th style="text-align: center"><openmrs:message code="ConceptNumeric.criticalLow"/></th>
<th style="text-align: center"><openmrs:message code="ConceptNumeric.normalHigh"/></th>
<th style="text-align: center"><openmrs:message code="ConceptNumeric.normalLow"/></th>
<th style="text-align: center"><openmrs:message code="ConceptNumeric.normalLow"/></th>
<th style="text-align: center"><openmrs:message code="Concept.referenceRanges.criteria"/></th>
</tr>
<c:forEach var="reference" items="${reference.referenceRanges}" varStatus="mapStatus">
<tr <c:if test="${mapStatus.index % 2 == 0}">class='evenRow'</c:if>>
<td><c:out value="${reference.conceptReference.hiAbsolute}"/></td>
<td><c:out value="${reference.conceptReference.lowAbsolute}"/></td>
<td><c:out value="${reference.conceptReference.hiNormal}"/></td>
<td><c:out value="${reference.conceptReference.lowNormal}"/></td>
<td><c:out value="${reference.conceptReference.hiCritical}"/></td>
<td><c:out value="${reference.conceptReference.lowCritical}"/></td>
<td><c:out value="${reference.conceptReference.criteria}"/></td>
</tr>
</c:forEach>

</table>
</td>
</tr>

<spring:bind path="command.activeAttributes">
<c:if test="${status.error}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.mockito.Mockito;
import org.openmrs.ConceptMap;
import org.openmrs.ConceptNumeric;
import org.openmrs.ConceptReferenceRange;
import org.openmrs.web.controller.ConceptFormController;
import org.openmrs.web.test.BaseModuleWebContextSensitiveTest;

Expand Down Expand Up @@ -56,4 +57,37 @@ public void ConceptFormBackingObject_shouldCopyNumericAttributes() {

org.junit.Assert.assertEquals("ml", conceptFormBackingObject.getUnits());
}

@Test
public void testConceptFormBackingObject_shouldSetReferenceRangeAttributes() {
ConceptReferenceRange referenceRange = Mockito.mock(ConceptReferenceRange.class);
ConceptNumeric conceptNumeric = Mockito.mock(ConceptNumeric.class);

Mockito.when(referenceRange.getHiAbsolute()).thenReturn(5.2);
Mockito.when(referenceRange.getLowAbsolute()).thenReturn(1.0);

Mockito.when(referenceRange.getHiCritical()).thenReturn(4.1);
Mockito.when(referenceRange.getLowCritical()).thenReturn(2.1);

Mockito.when(referenceRange.getLowNormal()).thenReturn(3.1);
Mockito.when(referenceRange.getHiNormal()).thenReturn(3.9);

Mockito.when(referenceRange.getCriteria()).thenReturn("");

ConceptFormController controller = new ConceptFormController();
ConceptReferenceRange conceptReferenceRange = controller.new ConceptFormBackingObject(
conceptNumeric).referenceRanges
.iterator().next();

org.junit.Assert.assertEquals(Double.valueOf(5.2), conceptReferenceRange.getHiAbsolute());
org.junit.Assert.assertEquals(Double.valueOf(1.0), conceptReferenceRange.getLowAbsolute());

org.junit.Assert.assertEquals(Double.valueOf(4.1), conceptReferenceRange.getHiCritical());
org.junit.Assert.assertEquals(Double.valueOf(2.1), conceptReferenceRange.getLowCritical());

org.junit.Assert.assertEquals(Double.valueOf(3.1), conceptReferenceRange.getLowNormal());
org.junit.Assert.assertEquals(Double.valueOf(3.9), conceptReferenceRange.getHiNormal());

org.junit.Assert.assertEquals("", conceptReferenceRange.getCriteria());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.Arrays;
import java.util.List;

import javax.annotation.Resource;
//import javax.annotation.Resource;

This comment has been minimized.

Copy link
@dkayiwa

dkayiwa Aug 28, 2024

Member

Were these changes made accidentally?

This comment has been minimized.

Copy link
@dicksonmulli

dicksonmulli Aug 28, 2024

Author

Yes, I will revert it. What is happening is that this line is causing an error so I had to comment it out


import org.junit.Assert;
import org.junit.Test;
Expand All @@ -38,7 +38,7 @@ public class DownloadDictionaryServletTest extends BaseModuleWebContextSensitive
@Mock
private ConceptService conceptService;

@Resource(name = "conceptDAO")
// @Resource(name = "conceptDAO")
private ConceptDAO conceptDAO;

@Test
Expand Down

0 comments on commit 45c5846

Please sign in to comment.