Skip to content

Commit

Permalink
FIX DRM-09
Browse files Browse the repository at this point in the history
ReportController Up

TestCase for evaluateDataValueTemplate
  • Loading branch information
Choxmi committed Oct 17, 2017
1 parent 8053271 commit 46e3161
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
Expand Up @@ -184,8 +184,18 @@ public String evaluateDataValueTemplate( DataValueTemplate dvt, Period period, L
{
query.setParameter( "locationId", location.getId().toString() );
}
query.setParameter( "startOfPeriod", period.getStartDate() );
query.setParameter( "endOfPeriod", period.getEndDate() );
if ( parameters.contains( "startOfPeriod" ) )
{
query.setParameter( "startOfPeriod", period.getStartDate() );
}
if ( parameters.contains( "endOfPeriod" ) )
{
query.setParameter( "endOfPeriod", period.getEndDate() );
}
if ( !parameters.contains( "startOfPeriod" ) && !parameters.contains( "endOfPeriod" ) )
{
return "NoParam";
}
return query.uniqueResult().toString();
}

Expand Down
Expand Up @@ -86,6 +86,18 @@ public void shouldevaluateDataValueTemplate()
assertEquals("3", dvs);
}
}

for ( ReportDefinition rd : rds )
{
for ( DataValueTemplate r : rd.getDataValueTemplates() )
{
String query = "select count(distinct p.person_id) from person p inner join obs o on o.person_id = p.person_id\n"
+ "where p.voided = 0 and o.voided = 0 and o.concept_id = 1425 and o.value_numeric = 4";
r.setQuery( query );
String dvs = dao.evaluateDataValueTemplate( r, period, location );
assertEquals( "NoParam", dvs );
}
}
}

@Test
Expand Down
Expand Up @@ -444,8 +444,16 @@ AdxType getAdxType( DataValueSet dvs, String timeperiod )
{
DataValueType dvtype = new DataValueType();
dvtype.setDataElement( dv.getDataElement() );
dvtype.setValue( new BigDecimal( dv.getValue() ) );
try
{
BigDecimal bd = new BigDecimal( dv.getValue() );
dvtype.setValue( bd );
dvTypeList.add( dvtype );
}
catch ( NumberFormatException e )
{
dvTypeList.add( null );
}
}
gt.getDataValue().addAll( dvTypeList );
gt.setOrgUnit( dvs.getOrgUnit() );
Expand Down
3 changes: 2 additions & 1 deletion omod/src/main/resources/messages.properties
Expand Up @@ -100,4 +100,5 @@ ${project.parent.artifactId}.openMRSLocationMapped = OpenMRS Location is Mapped
${project.parent.artifactId}.openMRSLocationDoesNotExist = OpenMRS Location Does Not Exists.
${project.parent.artifactId}.orgUnitCodeDoesNotExist = "Code" Attribute in DHIS2 ORG UNIT is not set. Please set it and then try Mapping.

${project.parent.artifactId}.editReportMapping = Edit Report Mapping
${project.parent.artifactId}.editReportMapping = Edit Report Mapping
${project.parent.artifactId}.missingParameters = Parameters missing
7 changes: 6 additions & 1 deletion omod/src/main/webapp/executeReport.jsp
Expand Up @@ -36,7 +36,12 @@
<tr>
<td>${dvm.key.name}</td>
<td>${dvm.key.code}</td>
<td>${dvm.value}</td>
<c:if test="${dvm.value!='NoParam'}">
<td>${dvm.value}</td>
</c:if>
<c:if test="${dvm.value=='NoParam'}">
<td><div id="openmrs_msg"><spring:message code="dhisreport.missingParameters" /> </div></td>
</c:if>
</tr>
<tr>
</c:forEach>
Expand Down

0 comments on commit 46e3161

Please sign in to comment.