Skip to content

Commit

Permalink
Concept reference form - restructured
Browse files Browse the repository at this point in the history
  • Loading branch information
dicksonmulli committed Aug 29, 2024
1 parent 8004fd8 commit c6ee428
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,28 @@ public void setIndexTermsByLocale(Map<Locale, List<ConceptName>> indexTermsByLoc
public List<Form> getFormsInUse() {
return Context.getFormService().getFormsContainingConcept(concept);
}

/**
* Get reference ranges
*
* @return the referenceRanges
*
* @since 1.17.0
*/
public Set<ConceptReferenceRange> getReferenceRanges() {
return referenceRanges;
}

/**
* Sets reference ranges
*
* @param referenceRanges the referenceRanges to set
*
* @since 1.17.0
*/
public void setReferenceRanges(Set<ConceptReferenceRange> referenceRanges) {
this.referenceRanges = referenceRanges;
}

/**
* Get the list of extensions/metadata and the specific instances of them that use this
Expand Down
4 changes: 4 additions & 0 deletions omod/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Concept.referenceRanges=Reference Ranges
Concept.referenceRanges.criteria=Criteria
Concept.referenceRanges.help=Defines reference ranges of this concept with a criteria
Concept.referenceRanges.add=Add a Reference Range
73 changes: 55 additions & 18 deletions omod/src/main/webapp/dictionary/conceptForm.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@
$j(".hideableEle").hide();
});
$j(document).ready(function(){
if(${fn:length(command.referenceRanges)} == 0)
$j(".hideable").hide();
});
</script>

<script src="<openmrs:contextPath/>/dwr/interface/DWRConceptService.js"></script>
Expand Down Expand Up @@ -816,13 +821,13 @@
</table>
</td>
</tr>
<tr id="referenceRangeRow">Concept.referenceRanges
<tr id="referenceRangeRow">
<th valign="top" style="padding-top: 8px">
<openmrs:message code="Concept.referenceRanges"/> <img class="help_icon" src="${pageContext.request.contextPath}/images/help.gif" border="0" title="<openmrs:message code="Concept.referenceRanges.help"/>"/>
</th>
<td>
<table id="referenceTable" cellpadding="3" cellspacing="1" class="lightBorderBox">
<tr id="headerRow" class="headerRow hideableEle">
<table id="referenceTable" cellpadding="3" cellspacing="1">
<tr id="headerRow" class="headerRow hideable">
<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>
Expand All @@ -834,28 +839,60 @@
<th class="removeButtonCol">&nbsp;</th>
</tr>
<c:forEach var="reference" items="${reference.referenceRanges}" varStatus="mapStatus">
<spring:nestedPath path="command.conceptMappings[${mapStatus.index}]">
<spring:nestedPath path="command.referenceRanges[${reference.id}]">
<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>
<td <c:if test="${mapStatus.index % 2 == 0}">class='evenRow'</c:if>>
<input type="text" id="term[${mapStatus.index}].name" size="25" value="<c:out value="${reference.conceptReference.hiAbsolute}"/>" readonly="readonly" />
</td>
<td <c:if test="${mapStatus.index % 2 == 0}">class='evenRow'</c:if>>
<input type="text" id="term[${mapStatus.index}].name" size="25" value="<c:out value="${reference.conceptReference.lowAbsolute}"/>" readonly="readonly" />
</td>
<td <c:if test="${mapStatus.index % 2 == 0}">class='evenRow'</c:if>>
<input type="text" id="term[${mapStatus.index}].name" size="25" value="<c:out value="${reference.conceptReference.hiNormal}"/>" readonly="readonly" />
</td>
<td <c:if test="${mapStatus.index % 2 == 0}">class='evenRow'</c:if>>
<input type="text" id="term[${mapStatus.index}].name" size="25" value="<c:out value="${reference.conceptReference.lowNormal}"/>" readonly="readonly" />
</td>
<td <c:if test="${mapStatus.index % 2 == 0}">class='evenRow'</c:if>>
<input type="text" id="term[${mapStatus.index}].name" size="25" value="<c:out value="${reference.conceptReference.hiCritical}"/>" readonly="readonly" />
</td>
<td <c:if test="${mapStatus.index % 2 == 0}">class='evenRow'</c:if>>
<input type="text" id="term[${mapStatus.index}].name" size="25" value="<c:out value="${reference.conceptReference.lowCritical}"/>" readonly="readonly" />
</td>
<td <c:if test="${mapStatus.index % 2 == 0}">class='evenRow'</c:if>>
<input type="text" id="term[${mapStatus.index}].name" size="25" value="<c:out value="${reference.conceptReference.criteria}"/>" readonly="readonly" />
</td>
<td>
<input type="button" value='<openmrs:message code="general.remove"/>' class="smallButton" onClick="removeParentElement(this.parentNode)" />
<spring:bind path="command.conceptReferences[${reference.id}]" ignoreNestedPath="true">
<c:if test="${status.errorMessage != ''}"><span class="error">${status.errorMessage}</span></c:if>
</spring:bind>
</td>
</tr>
</spring:nestedPath>
</c:forEach>
<tr id="newReferenceRange" style="display: none">
<td valign="top">
<input type="text" name="term.code" size="25" />
<input type="hidden" name="termId" />
</td>
<td>
<input type="text" name="term.name" size="25" readonly="readonly" />
<input type="button" value='<openmrs:message code="general.remove"/>' class="smallButton"
onClick="removeParentElement(this.parentNode)" />
</td>
<td>
<input type="button" value='<openmrs:message code="general.remove"/>' class="smallButton" onClick="removeParentElement(this.parentNode)" />
</tr>
<tr>
<td colspan="3" valign="top" align="left">
<c:choose>
<c:when test="${sourceID != null}">
<input type="button" value='<openmrs:message code="Concept.referenceRanges.add"/>' class="smallButton"
onClick="addConceptReferences(${fn:length(command.referenceRanges)})" />
</c:when>
<c:otherwise>
<span>
<openmrs:message code="Concept.mapping.sourceUnavailable"/>
<a href="${pageContext.request.contextPath}/admin/concepts/conceptSource.list">
<openmrs:message code="Concept.mapping.sourceAdd"/>
</a>
</span>
</c:otherwise>
</c:choose>
</td>
</tr>

Expand Down
30 changes: 29 additions & 1 deletion omod/src/main/webapp/resources/scripts/dictionary/conceptForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ function addConceptMapping(initialSizeOfClonedSiblings){
input.id = 'term[' + index + '].name';
}
}

//find the select element and set the name attribute for the conceptSource and map type
for (var i in selects) {
var select = selects[i];
Expand Down Expand Up @@ -469,4 +469,32 @@ function addAutoComplete(displayInputId, sourceSelectElementId, hiddenElementId,
});
}

/**
* Method is invoked to add a new reference range
* @param initialSizeOfReferenceRanges the number of mappings on page load
*/
function addReferenceRanges(initialSizeOfReferenceRanges){

var inputNamePrefix = 'referenceRanges';
var newRow = cloneElement('newReferenceRange', initialSizeOfReferenceRanges, inputNamePrefix);

if(newRow){
newRow.id = "";
var index = numberOfClonedElements['newReferenceRange'];
var inputs = newRow.getElementsByTagName("input");

for (var x = 0; x < inputs.length; x++) {
var input = inputs[x];

if (input && input.name == 'termId' && input.type == 'hidden') {
input.name = inputNamePrefix+'[' + index + '].conceptReference';
input.id = inputNamePrefix+'[' + index + '].conceptReference';
}
}

if(!$j("#headerRow").is(":visible"))
$j(".hideable").show();
}
}

document.onkeypress = hotkeys;

0 comments on commit c6ee428

Please sign in to comment.