dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24471
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11997: Fixed bug - Search persons in all facilitites doesn't work.
------------------------------------------------------------
revno: 11997
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-09-10 01:25:50 +0700
message:
Fixed bug - Search persons in all facilitites doesn't work.
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchPatientAction.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-09-06 08:35:43 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2013-09-09 18:25:50 +0000
@@ -401,7 +401,11 @@
boolean hasIdentifier = false;
boolean isSearchEvent = false;
boolean isPriorityEvent = false;
- Collection<Integer> orgunitChilrenIds = getOrgunitChildren( orgunits );
+ Collection<Integer> orgunitChilrenIds = null;
+ if ( orgunits != null )
+ {
+ orgunitChilrenIds = getOrgunitChildren( orgunits );
+ }
for ( String searchKey : searchKeys )
{
@@ -480,103 +484,103 @@
int statusEvent = Integer.parseInt( keys[index] );
switch ( statusEvent )
{
- case ProgramStageInstance.COMPLETED_STATUS:
- patientWhere += condition + operatorStatus
- + "( psi.executiondate is not null and psi.executiondate>='" + keys[2]
- + "' and psi.executiondate<='" + keys[3] + "' and psi.completed=true ";
- // get events by orgunit children
- if ( keys[4].equals( "-1" ) )
- {
- patientWhere += " and psi.organisationunitid in( "
- + TextUtils.getCommaDelimitedString( orgunitChilrenIds ) + " )";
- }
- // get events by selected
- else if ( !keys[4].equals( "0" ) )
- {
- patientWhere += " and psi.organisationunitid=" + keys[4];
- }
- patientWhere += ")";
- operatorStatus = " OR ";
- condition = "";
- continue;
- case ProgramStageInstance.VISITED_STATUS:
- patientWhere += condition + operatorStatus
- + "( psi.executiondate is not null and psi.executiondate>='" + keys[2]
- + "' and psi.executiondate<='" + keys[3] + "' and psi.completed=false ";
+ case ProgramStageInstance.COMPLETED_STATUS:
+ patientWhere += condition + operatorStatus
+ + "( psi.executiondate is not null and psi.executiondate>='" + keys[2]
+ + "' and psi.executiondate<='" + keys[3] + "' and psi.completed=true ";
+ // get events by orgunit children
+ if ( keys[4].equals( "-1" ) )
+ {
+ patientWhere += " and psi.organisationunitid in( "
+ + TextUtils.getCommaDelimitedString( orgunitChilrenIds ) + " )";
+ }
+ // get events by selected orgunit
+ else if ( !keys[4].equals( "0" ) )
+ {
+ patientWhere += " and psi.organisationunitid=" + keys[4];
+ }
+ patientWhere += ")";
+ operatorStatus = " OR ";
+ condition = "";
+ continue;
+ case ProgramStageInstance.VISITED_STATUS:
+ patientWhere += condition + operatorStatus
+ + "( psi.executiondate is not null and psi.executiondate>='" + keys[2]
+ + "' and psi.executiondate<='" + keys[3] + "' and psi.completed=false ";
- // get events by orgunit children
- if ( keys[4].equals( "-1" ) )
- {
- patientWhere += " and psi.organisationunitid in( "
- + TextUtils.getCommaDelimitedString( orgunitChilrenIds ) + " )";
- }
- // get events by selected
- else if ( !keys[4].equals( "0" ) )
- {
- patientWhere += " and psi.organisationunitid=" + keys[4];
- }
- patientWhere += ")";
- operatorStatus = " OR ";
- condition = "";
- continue;
- case ProgramStageInstance.FUTURE_VISIT_STATUS:
- patientWhere += condition + operatorStatus + "( psi.executiondate is null and psi.duedate>='"
- + keys[2] + "' and psi.duedate<='" + keys[3]
- + "' and psi.status is null and (DATE(now()) - DATE(psi.duedate) <= 0) ";
- // get events by orgunit children
- if ( keys[4].equals( "-1" ) )
- {
- patientWhere += " and p.organisationunitid in( "
- + TextUtils.getCommaDelimitedString( orgunitChilrenIds ) + " )";
- }
- // get events by selected
- else if ( !keys[4].equals( "0" ) )
- {
- patientWhere += " and p.organisationunitid=" + keys[4];
- }
- patientWhere += ")";
- operatorStatus = " OR ";
- condition = "";
- continue;
- case ProgramStageInstance.LATE_VISIT_STATUS:
- patientWhere += condition + operatorStatus + "( psi.executiondate is null and psi.duedate>='"
- + keys[2] + "' and psi.duedate<='" + keys[3]
- + "' and psi.status is null and (DATE(now()) - DATE(psi.duedate) > 0) ";
- // get events by orgunit children
- if ( keys[4].equals( "-1" ) )
- {
- patientWhere += " and p.organisationunitid in( "
- + TextUtils.getCommaDelimitedString( orgunitChilrenIds ) + " )";
- }
- // get events by selected
- else if ( !keys[4].equals( "0" ) )
- {
- patientWhere += " and p.organisationunitid=" + keys[4];
- }
- patientWhere += ")";
- operatorStatus = " OR ";
- condition = "";
- continue;
- case ProgramStageInstance.SKIPPED_STATUS:
- patientWhere += condition + operatorStatus + "( psi.status=5 and psi.duedate>='" + keys[2]
- + "' and psi.duedate<='" + keys[3] + "' ";
- // get events by orgunit children
- if ( keys[4].equals( "-1" ) )
- {
- patientWhere += " and psi.organisationunitid in( "
- + TextUtils.getCommaDelimitedString( orgunitChilrenIds ) + " )";
- }
- // get events by selected
- else if ( !keys[4].equals( "0" ) )
- {
- patientWhere += " and p.organisationunitid=" + keys[4];
- }
- patientWhere += ")";
- operatorStatus = " OR ";
- condition = "";
- continue;
- default:
- continue;
+ // get events by orgunit children
+ if ( keys[4].equals( "-1" ) )
+ {
+ patientWhere += " and psi.organisationunitid in( "
+ + TextUtils.getCommaDelimitedString( orgunitChilrenIds ) + " )";
+ }
+ // get events by selected orgunit
+ else if ( !keys[4].equals( "0" ) )
+ {
+ patientWhere += " and psi.organisationunitid=" + keys[4];
+ }
+ patientWhere += ")";
+ operatorStatus = " OR ";
+ condition = "";
+ continue;
+ case ProgramStageInstance.FUTURE_VISIT_STATUS:
+ patientWhere += condition + operatorStatus + "( psi.executiondate is null and psi.duedate>='"
+ + keys[2] + "' and psi.duedate<='" + keys[3]
+ + "' and psi.status is null and (DATE(now()) - DATE(psi.duedate) <= 0) ";
+ // get events by orgunit children
+ if ( keys[4].equals( "-1" ) )
+ {
+ patientWhere += " and p.organisationunitid in( "
+ + TextUtils.getCommaDelimitedString( orgunitChilrenIds ) + " )";
+ }
+ // get events by selected orgunit
+ else if ( !keys[4].equals( "0" ) )
+ {
+ patientWhere += " and p.organisationunitid=" + keys[4];
+ }
+ patientWhere += ")";
+ operatorStatus = " OR ";
+ condition = "";
+ continue;
+ case ProgramStageInstance.LATE_VISIT_STATUS:
+ patientWhere += condition + operatorStatus + "( psi.executiondate is null and psi.duedate>='"
+ + keys[2] + "' and psi.duedate<='" + keys[3]
+ + "' and psi.status is null and (DATE(now()) - DATE(psi.duedate) > 0) ";
+ // get events by orgunit children
+ if ( keys[4].equals( "-1" ) )
+ {
+ patientWhere += " and p.organisationunitid in( "
+ + TextUtils.getCommaDelimitedString( orgunitChilrenIds ) + " )";
+ }
+ // get events by selected orgunit
+ else if ( !keys[4].equals( "0" ) )
+ {
+ patientWhere += " and p.organisationunitid=" + keys[4];
+ }
+ patientWhere += ")";
+ operatorStatus = " OR ";
+ condition = "";
+ continue;
+ case ProgramStageInstance.SKIPPED_STATUS:
+ patientWhere += condition + operatorStatus + "( psi.status=5 and psi.duedate>='" + keys[2]
+ + "' and psi.duedate<='" + keys[3] + "' ";
+ // get events by orgunit children
+ if ( keys[4].equals( "-1" ) )
+ {
+ patientWhere += " and psi.organisationunitid in( "
+ + TextUtils.getCommaDelimitedString( orgunitChilrenIds ) + " )";
+ }
+ // get events by selected orgunit
+ else if ( !keys[4].equals( "0" ) )
+ {
+ patientWhere += " and p.organisationunitid=" + keys[4];
+ }
+ patientWhere += ")";
+ operatorStatus = " OR ";
+ condition = "";
+ continue;
+ default:
+ continue;
}
}
if ( condition.isEmpty() )
@@ -597,20 +601,20 @@
int statusEvent = Integer.parseInt( keys[2] );
switch ( statusEvent )
{
- case ProgramStageInstance.COMPLETED_STATUS:
- patientWhere += "psi.completed=true";
- break;
- case ProgramStageInstance.VISITED_STATUS:
- patientWhere += "psi.executiondate is not null and psi.completed=false";
- break;
- case ProgramStageInstance.FUTURE_VISIT_STATUS:
- patientWhere += "psi.executiondate is null and psi.duedate >= now()";
- break;
- case ProgramStageInstance.LATE_VISIT_STATUS:
- patientWhere += "psi.executiondate is null and psi.duedate < now()";
- break;
- default:
- break;
+ case ProgramStageInstance.COMPLETED_STATUS:
+ patientWhere += "psi.completed=true";
+ break;
+ case ProgramStageInstance.VISITED_STATUS:
+ patientWhere += "psi.executiondate is not null and psi.completed=false";
+ break;
+ case ProgramStageInstance.FUTURE_VISIT_STATUS:
+ patientWhere += "psi.executiondate is null and psi.duedate >= now()";
+ break;
+ case ProgramStageInstance.LATE_VISIT_STATUS:
+ patientWhere += "psi.executiondate is null and psi.duedate < now()";
+ break;
+ default:
+ break;
}
patientWhere += " and pgi.status=" + ProgramInstance.STATUS_ACTIVE + " ";
@@ -750,7 +754,8 @@
for ( OrganisationUnit orgunit : orgunits )
{
- orgUnitIds.addAll( organisationUnitService.getOrganisationUnitHierarchy().getChildren( orgunit.getId() ) );
+ orgUnitIds
+ .addAll( organisationUnitService.getOrganisationUnitHierarchy().getChildren( orgunit.getId() ) );
orgUnitIds.remove( orgunit.getId() );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchPatientAction.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchPatientAction.java 2013-09-09 18:25:50 +0000
@@ -194,7 +194,7 @@
}
else
{
- organisationUnit = null;
+ orgunits = null;
}
total = patientService.countSearchPatients( searchTexts, orgunits, null );