dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20510
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9385: Minor fix for calculated patient attribute.
------------------------------------------------------------
revno: 9385
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-12-21 20:15:04 +0700
message:
Minor fix for calculated patient attribute.
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/DefaultPatientAttributeValueService.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/DefaultPatientAttributeValueService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/DefaultPatientAttributeValueService.java 2012-12-21 09:23:20 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/DefaultPatientAttributeValueService.java 2012-12-21 13:15:04 +0000
@@ -73,13 +73,12 @@
implements PatientAttributeValueService
{
private final String CURRENT_DATE = "current_date";
-
- private final String regExp = "\\[(" + CURRENT_DATE + "|" + OBJECT_PATIENT + "|" + OBJECT_PROGRAM + "|" + OBJECT_PROGRAM_STAGE + "|"
- + OBJECT_PROGRAM_STAGE_PROPERTY + "|" + OBJECT_PATIENT_PROGRAM_STAGE_PROPERTY + "|"
- + OBJECT_PROGRAM_STAGE_DATAELEMENT + "|" + OBJECT_PATIENT_ATTRIBUTE + "|" + OBJECT_PATIENT_PROPERTY + "|"
+
+ private final String regExp = "\\[(" + CURRENT_DATE + "|" + OBJECT_PATIENT + "|" + OBJECT_PROGRAM + "|"
+ + OBJECT_PROGRAM_STAGE + "|" + OBJECT_PROGRAM_STAGE_PROPERTY + "|" + OBJECT_PATIENT_PROGRAM_STAGE_PROPERTY
+ + "|" + OBJECT_PROGRAM_STAGE_DATAELEMENT + "|" + OBJECT_PATIENT_ATTRIBUTE + "|" + OBJECT_PATIENT_PROPERTY + "|"
+ OBJECT_PROGRAM_PROPERTY + ")" + SEPARATOR_OBJECT + "([0-9]+[" + SEPARATOR_ID + "[a-zA-Z0-9]*]*)" + "\\]";
-
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -295,7 +294,7 @@
matcher.appendReplacement( result, "0" );
}
else
- {
+ {
String[] infor = matcher.group( 2 ).split( SEPARATOR_ID );
int id = Integer.parseInt( infor[0] );
@@ -304,14 +303,18 @@
PatientAttribute attribute = patientAttributeService.getPatientAttribute( id );
PatientAttributeValue attributeValue = patientAttributeValueStore.get( patient, attribute );
- if ( PatientAttribute.TYPE_INT.equals( attributeValue.getPatientAttribute().getValueType() ) )
- {
- matcher.appendReplacement( result, attributeValue.getValue() );
- }
- else if ( PatientAttribute.TYPE_DATE.equals( attributeValue.getPatientAttribute().getValueType() ) )
- {
- matcher.appendReplacement( result,
- getDays( currentDate, format.parseDate( attributeValue.getValue() ) ) + "" );
+ if ( attributeValue != null )
+ {
+ if ( PatientAttribute.TYPE_INT.equals( attributeValue.getPatientAttribute().getValueType() ) )
+ {
+ matcher.appendReplacement( result, attributeValue.getValue() );
+ }
+ else if ( PatientAttribute.TYPE_DATE.equals( attributeValue.getPatientAttribute()
+ .getValueType() ) )
+ {
+ matcher.appendReplacement( result,
+ getDays( currentDate, format.parseDate( attributeValue.getValue() ) ) + "" );
+ }
}
}
else if ( property.equalsIgnoreCase( OBJECT_PATIENT_PROPERTY ) )
@@ -325,7 +328,7 @@
program, false );
Date value = null;
- if ( programInstances != null && programInstances.size() > 0)
+ if ( programInstances != null && programInstances.size() > 0 )
{
ProgramInstance programInstance = programInstances.iterator().next();
String propProgram = infor[1];
@@ -340,13 +343,13 @@
}
else
{
- return 0.0;
+ return null;
}
matcher.appendReplacement( result, getDays( currentDate, value ) + "" );
}
}
}
-
+
final JEP parser = new JEP();
parser.parseExpression( result.toString() );
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java 2012-12-21 09:23:20 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java 2012-12-21 13:15:04 +0000
@@ -77,7 +77,7 @@
private CurrentUserService currentUserService;
private PatientAttributeService patientAttributeService;
-
+
private I18nFormat format;
// -------------------------------------------------------------------------
@@ -215,14 +215,19 @@
attributeValues = patientAttributeValueService.getPatientAttributeValues( patient );
- Collection<PatientAttribute> calAttributes = patientAttributeService.getPatientAttributesByValueType(PatientAttribute.TYPE_CALCULATED);
-
- for( PatientAttribute calAttribute : calAttributes )
+ Collection<PatientAttribute> calAttributes = patientAttributeService
+ .getPatientAttributesByValueType( PatientAttribute.TYPE_CALCULATED );
+
+ for ( PatientAttribute calAttribute : calAttributes )
{
- Double value = patientAttributeValueService.getCalculatedPatientAttributeValue( patient, calAttribute, format );
- calAttributeValueMap.put( calAttribute.getName(), value );
+ Double value = patientAttributeValueService.getCalculatedPatientAttributeValue( patient, calAttribute,
+ format );
+ if ( value != null )
+ {
+ calAttributeValueMap.put( calAttribute.getName(), value );
+ }
}
-
+
relationship = relationshipService.getRelationshipsForPatient( patient );
Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstances( patient );