dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #26665
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13187: minor fix in patientStore
------------------------------------------------------------
revno: 13187
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-12-10 09:51:03 +0100
message:
minor fix in patientStore
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.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/patient/hibernate/HibernatePatientStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2013-12-10 08:18:47 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2013-12-10 08:51:03 +0000
@@ -504,27 +504,11 @@
String id = keys[1];
String value = "";
- Integer orgUnitId = -1;
-
if ( keys.length >= 3 )
{
value = keys[2];
}
- if ( keys.length > 4 )
- {
- try
- {
- orgUnitId = Integer.parseInt( keys[4] );
- }
- catch ( NumberFormatException e )
- {
- // handle as uid
- OrganisationUnit ou = organisationUnitService.getOrganisationUnit( keys[4] );
- orgUnitId = ou.getId();
- }
- }
-
if ( keys[0].equals( PREFIX_FIXED_ATTRIBUTE ) )
{
patientWhere += patientOperator;
@@ -643,7 +627,7 @@
// get events by selected orgunit
else if ( !keys[4].equals( "0" ) )
{
- patientWhere += " and psi.organisationunitid=" + keys[4];
+ patientWhere += " and psi.organisationunitid=" + getOrgUnitId( keys );
}
patientWhere += ")";
@@ -665,7 +649,7 @@
// get events by selected orgunit
else if ( !keys[4].equals( "0" ) )
{
- patientWhere += " and psi.organisationunitid=" + keys[4];
+ patientWhere += " and psi.organisationunitid=" + getOrgUnitId( keys );
}
patientWhere += ")";
@@ -687,7 +671,7 @@
// get events by selected orgunit
else if ( !keys[4].equals( "0" ) )
{
- patientWhere += " and p.organisationunitid=" + orgUnitId;
+ patientWhere += " and p.organisationunitid=" + getOrgUnitId( keys );
}
patientWhere += ")";
@@ -709,7 +693,7 @@
// get events by selected orgunit
else if ( !keys[4].equals( "0" ) )
{
- patientWhere += " and p.organisationunitid=" + orgUnitId;
+ patientWhere += " and p.organisationunitid=" + getOrgUnitId( keys );
}
patientWhere += ")";
@@ -730,7 +714,7 @@
// get events by selected orgunit
else if ( !keys[4].equals( "0" ) )
{
- patientWhere += " and p.organisationunitid=" + keys[4];
+ patientWhere += " and p.organisationunitid=" + getOrgUnitId( keys );
}
patientWhere += ")";
operatorStatus = " OR ";
@@ -844,6 +828,22 @@
return sql;
}
+ private Integer getOrgUnitId( String[] keys )
+ {
+ Integer orgUnitId;
+ try
+ {
+ orgUnitId = Integer.parseInt( keys[4] );
+ }
+ catch ( NumberFormatException e )
+ {
+ // handle as uid
+ OrganisationUnit ou = organisationUnitService.getOrganisationUnit( keys[4] );
+ orgUnitId = ou.getId();
+ }
+ return orgUnitId;
+ }
+
private Collection<Integer> getOrgunitChildren( Collection<OrganisationUnit> orgunits )
{
Collection<Integer> orgUnitIds = new HashSet<Integer>();