------------------------------------------------------------ revno: 12381 committer: Tran Chau <tran.hispviet...@gmail.com> branch nick: dhis2 timestamp: Wed 2013-10-02 18:24:32 +0700 message: Improve advanced-search person ( WIP ) modified: dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 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/caseentry/GetDataRecordsAction.java 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/reminder/SendSmsToListAction.java dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm
-- 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-api/src/main/java/org/hisp/dhis/patient/PatientService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java 2013-09-18 03:49:35 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java 2013-10-02 11:24:32 +0000 @@ -264,17 +264,17 @@ Object getObjectValue( String property, String value, I18nFormat format ); Collection<Patient> searchPatients( List<String> searchKeys, Collection<OrganisationUnit> orgunit, - Boolean followup, Collection<PatientAttribute> patientAttributes, Integer min, Integer max ); + Boolean followup, Collection<PatientAttribute> patientAttributes, Integer statusEnrollment, Integer min, Integer max ); - int countSearchPatients( List<String> searchKeys, Collection<OrganisationUnit> orgunit, Boolean followup ); + int countSearchPatients( List<String> searchKeys, Collection<OrganisationUnit> orgunit, Boolean followup, Integer statusEnrollment ); Collection<String> getPatientPhoneNumbers( List<String> searchKeys, Collection<OrganisationUnit> orgunit, - Boolean followup, Integer min, Integer max ); + Boolean followup, Integer statusEnrollment, Integer min, Integer max ); List<Integer> getProgramStageInstances( List<String> searchKeys, Collection<OrganisationUnit> orgunit, - Boolean followup, Integer min, Integer max ); + Boolean followup, Integer statusEnrollment, Integer min, Integer max ); - Grid getScheduledEventsReport( List<String> searchKeys, Collection<OrganisationUnit> orgunits, Boolean followup, + Grid getScheduledEventsReport( List<String> searchKeys, Collection<OrganisationUnit> orgunits, Boolean followup, Integer statusEnrollment, Integer min, Integer max, I18n i18n ); Collection<Patient> getPatientsByPhone( String phoneNumber, Integer min, Integer max ); @@ -284,5 +284,5 @@ Collection<Integer> getRegistrationOrgunitIds( Date startDate, Date endDate ); Grid getTrackingEventsReport( Program program, List<String> searchKeys, Collection<OrganisationUnit> orgunit, - Boolean followup, I18n i18n ); + Boolean followup, Integer statusEnrollment, I18n i18n ); } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java 2013-09-27 13:56:18 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java 2013-10-02 11:24:32 +0000 @@ -71,7 +71,7 @@ int countGetPatientsByOrgUnitProgram( OrganisationUnit organisationUnit, Program program ); - int countSearch( List<String> searchKeys, Collection<OrganisationUnit> orgunit, Boolean followup ); + int countSearch( List<String> searchKeys, Collection<OrganisationUnit> orgunit, Boolean followup, Integer statusEnrollment ); Collection<Patient> getByPhoneNumber( String phoneNumber, Integer min, Integer max ); @@ -80,17 +80,17 @@ Collection<Integer> getRegistrationOrgunitIds( Date startDate, Date endDate ); Collection<Patient> search( List<String> searchKeys, Collection<OrganisationUnit> orgunit, Boolean followup, - Collection<PatientAttribute> patientAttributes, Integer min, Integer max ); + Collection<PatientAttribute> patientAttributes, Integer statusEnrollment, Integer min, Integer max ); Collection<String> getPatientPhoneNumbers( List<String> searchKeys, Collection<OrganisationUnit> orgunits, Boolean followup, - Collection<PatientAttribute> patientAttributes, Integer min, Integer max ); + Collection<PatientAttribute> patientAttributes, Integer statusEnrollment, Integer min, Integer max ); Grid getPatientEventReport( Grid grid, List<String> searchKeys, Collection<OrganisationUnit> orgunit, Boolean followup, - Collection<PatientAttribute> patientAttributes, Collection<PatientIdentifierType> identifierTypes, Integer min, + Collection<PatientAttribute> patientAttributes, Collection<PatientIdentifierType> identifierTypes, Integer statusEnrollment, Integer min, Integer max ); List<Integer> getProgramStageInstances( List<String> searchKeys, Collection<OrganisationUnit> orgunits, Boolean followup, - Collection<PatientAttribute> patientAttributes, Collection<PatientIdentifierType> identifierTypes, Integer min, + Collection<PatientAttribute> patientAttributes, Collection<PatientIdentifierType> identifierTypes, Integer statusEnrollment, Integer min, Integer max ); Collection<Patient> getByOrgUnitProgramGender( OrganisationUnit organisationUnit, Program program, String gender, Integer min, Integer max ); === modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java' --- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-10-01 08:28:26 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-10-02 11:24:32 +0000 @@ -1995,7 +1995,7 @@ searchTextList.add( searchText ); orgUnitList.add( organisationUnitService.getOrganisationUnit( orgUnitId ) ); - List<Integer> stageInstanceIds = patientService.getProgramStageInstances( searchTextList, orgUnitList, true, null, null ); + List<Integer> stageInstanceIds = patientService.getProgramStageInstances( searchTextList, orgUnitList, true, ProgramInstance.STATUS_ACTIVE, null, null ); return searchText; } } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2013-09-30 12:39:25 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2013-10-02 11:24:32 +0000 @@ -349,7 +349,8 @@ } @Override - public Collection<Patient> getPatientsLikeName( OrganisationUnit organisationUnit, String name, Integer min, Integer max ) + public Collection<Patient> getPatientsLikeName( OrganisationUnit organisationUnit, String name, Integer min, + Integer max ) { return patientStore.getByOrgUnitAndNameLike( organisationUnit, name, min, max ); } @@ -367,7 +368,8 @@ } else if ( identifierTypeId != null ) { - PatientIdentifierType identifierType = patientIdentifierTypeService.getPatientIdentifierType( identifierTypeId ); + PatientIdentifierType identifierType = patientIdentifierTypeService + .getPatientIdentifierType( identifierTypeId ); if ( identifierType != null ) { @@ -558,26 +560,29 @@ } public Collection<Patient> searchPatients( List<String> searchKeys, Collection<OrganisationUnit> orgunits, - Boolean followup, Collection<PatientAttribute> patientAttributes, Integer min, Integer max ) + Boolean followup, Collection<PatientAttribute> patientAttributes, Integer statusEnrollment, Integer min, + Integer max ) { - return patientStore.search( searchKeys, orgunits, followup, patientAttributes, min, max ); + return patientStore.search( searchKeys, orgunits, followup, patientAttributes, statusEnrollment, min, max ); } - public int countSearchPatients( List<String> searchKeys, Collection<OrganisationUnit> orgunits, Boolean followup ) + public int countSearchPatients( List<String> searchKeys, Collection<OrganisationUnit> orgunits, Boolean followup, + Integer statusEnrollment ) { - return patientStore.countSearch( searchKeys, orgunits, followup ); + return patientStore.countSearch( searchKeys, orgunits, followup, statusEnrollment ); } public Collection<String> getPatientPhoneNumbers( List<String> searchKeys, Collection<OrganisationUnit> orgunits, - Boolean followup, Integer min, Integer max ) + Boolean followup, Integer statusEnrollment, Integer min, Integer max ) { - return patientStore.getPatientPhoneNumbers( searchKeys, orgunits, followup, null, min, max ); + return patientStore.getPatientPhoneNumbers( searchKeys, orgunits, followup, null, statusEnrollment, min, max ); } public List<Integer> getProgramStageInstances( List<String> searchKeys, Collection<OrganisationUnit> orgunits, - Boolean followup, Integer min, Integer max ) + Boolean followup, Integer statusEnrollment, Integer min, Integer max ) { - return patientStore.getProgramStageInstances( searchKeys, orgunits, followup, null, null, min, max ); + return patientStore.getProgramStageInstances( searchKeys, orgunits, followup, null, null, statusEnrollment, + min, max ); } @Override @@ -588,7 +593,7 @@ @Override public Grid getScheduledEventsReport( List<String> searchKeys, Collection<OrganisationUnit> orgunits, - Boolean followup, Integer min, Integer max, I18n i18n ) + Boolean followup, Integer statusEnrollment, Integer min, Integer max, I18n i18n ) { String startDate = ""; String endDate = ""; @@ -627,14 +632,14 @@ grid.addHeader( new GridHeader( i18n.getString( "program_stage" ), false, true ) ); grid.addHeader( new GridHeader( i18n.getString( "due_date" ), false, true ) ); - return patientStore.getPatientEventReport( grid, searchKeys, orgunits, followup, patientAttributes, null, min, - max ); + return patientStore.getPatientEventReport( grid, searchKeys, orgunits, followup, patientAttributes, null, + statusEnrollment, min, max ); } @Override public Grid getTrackingEventsReport( Program program, List<String> searchKeys, - Collection<OrganisationUnit> orgunits, Boolean followup, I18n i18n ) + Collection<OrganisationUnit> orgunits, Boolean followup, Integer statusEnrollment, I18n i18n ) { String startDate = ""; String endDate = ""; @@ -673,7 +678,7 @@ grid.addHeader( new GridHeader( i18n.getString( "risk" ), false, true ) ); return patientStore.getPatientEventReport( grid, searchKeys, orgunits, followup, null, patientIdentifierTypes, - null, null ); + statusEnrollment, null, null ); } === 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-30 09:22:35 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2013-10-02 11:24:32 +0000 @@ -28,6 +28,14 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashSet; +import java.util.List; + import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Conjunction; @@ -53,14 +61,6 @@ import org.springframework.jdbc.support.rowset.SqlRowSet; import org.springframework.transaction.annotation.Transactional; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashSet; -import java.util.List; - /** * @author Abyot Asalefew Gizaw */ @@ -158,11 +158,11 @@ @Override @SuppressWarnings( "unchecked" ) - public Collection<Patient> getByOrgUnitAndNameLike( OrganisationUnit organisationUnit, String nameLike, Integer min, Integer max ) + public Collection<Patient> getByOrgUnitAndNameLike( OrganisationUnit organisationUnit, String nameLike, + Integer min, Integer max ) { String hql = "select p from Patient p where p.organisationUnit = :organisationUnit " - + " and lower(p.name) like :nameLike" - + " order by p.name"; + + " and lower(p.name) like :nameLike" + " order by p.name"; Query query = getQuery( hql ); query.setEntity( "organisationUnit", organisationUnit ); @@ -370,9 +370,11 @@ @Override public Collection<Patient> search( List<String> searchKeys, Collection<OrganisationUnit> orgunits, - Boolean followup, Collection<PatientAttribute> patientAttributes, Integer min, Integer max ) + Boolean followup, Collection<PatientAttribute> patientAttributes, Integer statusEnrollment, Integer min, + Integer max ) { - String sql = searchPatientSql( false, searchKeys, orgunits, followup, patientAttributes, null, min, max ); + String sql = searchPatientSql( false, searchKeys, orgunits, followup, patientAttributes, null, + statusEnrollment, min, max ); Collection<Patient> patients = new HashSet<Patient>(); try { @@ -394,9 +396,11 @@ @Override public Collection<String> getPatientPhoneNumbers( List<String> searchKeys, Collection<OrganisationUnit> orgunits, - Boolean followup, Collection<PatientAttribute> patientAttributes, Integer min, Integer max ) + Boolean followup, Collection<PatientAttribute> patientAttributes, Integer statusEnrollment, Integer min, + Integer max ) { - String sql = searchPatientSql( false, searchKeys, orgunits, followup, patientAttributes, null, min, max ); + String sql = searchPatientSql( false, searchKeys, orgunits, followup, patientAttributes, null, + statusEnrollment, min, max ); Collection<String> phoneNumbers = new HashSet<String>(); try { @@ -420,10 +424,10 @@ @Override public List<Integer> getProgramStageInstances( List<String> searchKeys, Collection<OrganisationUnit> orgunits, Boolean followup, Collection<PatientAttribute> patientAttributes, - Collection<PatientIdentifierType> identifierTypes, Integer min, Integer max ) + Collection<PatientIdentifierType> identifierTypes, Integer statusEnrollment, Integer min, Integer max ) { - String sql = searchPatientSql( false, searchKeys, orgunits, followup, patientAttributes, identifierTypes, min, - max ); + String sql = searchPatientSql( false, searchKeys, orgunits, followup, patientAttributes, identifierTypes, + statusEnrollment, min, max ); List<Integer> programStageInstanceIds = new ArrayList<Integer>(); try { @@ -444,23 +448,24 @@ return programStageInstanceIds; } - public int countSearch( List<String> searchKeys, Collection<OrganisationUnit> orgunits, Boolean followup ) + public int countSearch( List<String> searchKeys, Collection<OrganisationUnit> orgunits, Boolean followup, + Integer statusEnrollment ) { - String sql = searchPatientSql( true, searchKeys, orgunits, followup, null, null, null, null ); + String sql = searchPatientSql( true, searchKeys, orgunits, followup, null, null, statusEnrollment, null, null ); return jdbcTemplate.queryForObject( sql, Integer.class ); } @Override public Grid getPatientEventReport( Grid grid, List<String> searchKeys, Collection<OrganisationUnit> orgunits, Boolean followup, Collection<PatientAttribute> patientAttributes, - Collection<PatientIdentifierType> identifierTypes, Integer min, Integer max ) + Collection<PatientIdentifierType> identifierTypes, Integer statusEnrollment, Integer min, Integer max ) { // --------------------------------------------------------------------- // Get SQL and build grid // --------------------------------------------------------------------- - String sql = searchPatientSql( false, searchKeys, orgunits, followup, patientAttributes, identifierTypes, null, - null ); + String sql = searchPatientSql( false, searchKeys, orgunits, followup, patientAttributes, identifierTypes, + statusEnrollment, null, null ); SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql ); @@ -475,10 +480,9 @@ private String searchPatientSql( boolean count, List<String> searchKeys, Collection<OrganisationUnit> orgunits, Boolean followup, Collection<PatientAttribute> patientAttributes, - Collection<PatientIdentifierType> identifierTypes, Integer min, Integer max ) + Collection<PatientIdentifierType> identifierTypes, Integer statusEnrollment, Integer min, Integer max ) { String selector = count ? "count(*) " : "* "; - String sql = "select " + selector + " from ( select distinct p.patientid, p.name, p.gender, p.phonenumber,"; if ( identifierTypes != null ) @@ -594,8 +598,12 @@ } else if ( keys[0].equals( Patient.PREFIX_PROGRAM ) ) { - sql += "(select programid from programinstance pi where patientid=p.patientid and programid=" + id - + " and pi.status=0 ) as " + Patient.PREFIX_PROGRAM + "_" + id + ","; + sql += "(select programid from programinstance pi where patientid=p.patientid and programid=" + id; + if ( statusEnrollment != null ) + { + sql += " and pi.status=" + statusEnrollment; + } + sql += " limit 1 ) as " + Patient.PREFIX_PROGRAM + "_" + id + ","; otherWhere += operator + Patient.PREFIX_PROGRAM + "_" + id + "=" + id; operator = " and "; } @@ -630,103 +638,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 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 "; + 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 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; + // 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() ) @@ -747,20 +755,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 + " "; === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java 2013-09-27 11:13:20 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java 2013-10-02 11:24:32 +0000 @@ -224,7 +224,7 @@ Collection<OrganisationUnit> orgunits = new HashSet<OrganisationUnit>(); orgunits.add( orgunit ); - + if ( programId != null ) { program = programService.getProgram( programId ); @@ -241,11 +241,12 @@ Collections.sort( patientAttributes, IdentifiableObjectNameComparator.INSTANCE ); - total = patientService.countSearchPatients( searchTexts, orgunits, followup ); + total = patientService.countSearchPatients( searchTexts, orgunits, followup, + ProgramInstance.STATUS_ACTIVE ); this.paging = createPaging( total ); List<Integer> stageInstanceIds = patientService.getProgramStageInstances( searchTexts, orgunits, - followup, paging.getStartPos(), paging.getPageSize() ); + followup, ProgramInstance.STATUS_ACTIVE, paging.getStartPos(), paging.getPageSize() ); for ( Integer stageInstanceId : stageInstanceIds ) { @@ -272,13 +273,15 @@ } } } - else if(trackingReport != null && trackingReport ) + else if ( trackingReport != null && trackingReport ) { - grid = patientService.getTrackingEventsReport( program, searchTexts, orgunits, followup, i18n ); + grid = patientService.getTrackingEventsReport( program, searchTexts, orgunits, followup, + ProgramInstance.STATUS_ACTIVE, i18n ); } else { - grid = patientService.getScheduledEventsReport( searchTexts, orgunits, followup, null, null, i18n ); + grid = patientService.getScheduledEventsReport( searchTexts, orgunits, followup, + ProgramInstance.STATUS_ACTIVE, null, null, i18n ); } } === 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-09-27 11:13:20 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchPatientAction.java 2013-10-02 11:24:32 +0000 @@ -70,6 +70,8 @@ private List<String> searchTexts = new ArrayList<String>(); + private Integer statusEnrollment; + private Boolean searchBySelectedOrgunit; private Boolean searchByUserOrgunits; @@ -87,6 +89,11 @@ this.currentUserService = currentUserService; } + public void setStatusEnrollment( Integer statusEnrollment ) + { + this.statusEnrollment = statusEnrollment; + } + public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) { this.selectionManager = selectionManager; @@ -197,10 +204,10 @@ orgunits = null; } - total = patientService.countSearchPatients( searchTexts, orgunits, null ); + total = patientService.countSearchPatients( searchTexts, orgunits, null, statusEnrollment ); this.paging = createPaging( total ); - patients = patientService.searchPatients( searchTexts, orgunits, null, null, paging.getStartPos(), - paging.getPageSize() ); + patients = patientService.searchPatients( searchTexts, orgunits, null, null, statusEnrollment, + paging.getStartPos(), paging.getPageSize() ); if ( !searchBySelectedOrgunit || searchByUserOrgunits ) { === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/SendSmsToListAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/SendSmsToListAction.java 2013-08-27 06:52:06 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/SendSmsToListAction.java 2013-10-02 11:24:32 +0000 @@ -38,6 +38,7 @@ import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; import org.hisp.dhis.patient.PatientService; +import org.hisp.dhis.program.ProgramInstance; import org.hisp.dhis.program.ProgramStageInstanceService; import org.hisp.dhis.sms.SmsSender; import org.hisp.dhis.sms.SmsServiceException; @@ -176,10 +177,10 @@ } Collection<Integer> programStageInstanceIds = patientService.getProgramStageInstances( searchTexts, orgunits, - followup, null, null ); + followup, ProgramInstance.STATUS_ACTIVE, null, null ); Set<String> phoneNumberList = new HashSet<String>( patientService.getPatientPhoneNumbers( searchTexts, - orgunits, followup, null, null ) ); + orgunits, followup, ProgramInstance.STATUS_ACTIVE, null, null ) ); try { OutboundSms outboundSms = new OutboundSms(); === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2013-10-02 03:09:16 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2013-10-02 11:24:32 +0000 @@ -692,4 +692,7 @@ quarters_last_year = Quarters last year quarters_this_year = Quarters this year last_6_bimonths = Last 6 bimonths -bimonths = Bi-months \ No newline at end of file +bimonths = Bi-months +active_enrollments_only = Active enrollments only +completed_enrollments_only = Completed enrollments only +both = both \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2013-09-23 09:42:21 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2013-10-02 11:24:32 +0000 @@ -301,7 +301,7 @@ var searchByUserOrgunits = byId('searchByUserOrgunits').checked ? true : false; params += '&searchByUserOrgunits=' + searchByUserOrgunits; - + params += '&statusEnrollment=' + getFieldValue('statusEnrollment'); if( getFieldValue('searchByProgramStage') == "false"){ var searchInAllFacility = byId('searchInAllFacility').checked; params += '&searchBySelectedOrgunit=' + !searchInAllFacility; @@ -2355,3 +2355,21 @@ { $('.idxPhoneNumber' + idx).remove(); } + +function searchByIdsOnclick() +{ + var value = getFieldValue('searchPatientByIds'); + jQuery("#advSearchBox0").find('input[id=searchText]').val(value); + jQuery("#searchPatientBtn").click(); +} + +function advancedSearchOnclick() +{ + jQuery('#advanced-search').toggle(); + if(jQuery('#advanced-search').is(':visible')){ + hideById('searchByIdTR'); + } + else{ + showById('searchByIdTR'); + } +} === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm 2013-09-27 11:13:20 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm 2013-10-02 11:24:32 +0000 @@ -320,4 +320,5 @@ #else setFieldValue('phoneNumber',phoneNumberAreaCode) #end + </script> \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm 2013-09-17 07:53:28 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm 2013-10-02 11:24:32 +0000 @@ -11,10 +11,10 @@ <td> <input type="text" id='orgunitName' readonly="readonly" #if( $organisationUnit ) value="$encoder.htmlEncode( $organisationUnit.name )" #else value="[$i18n.getString( 'please_select_village' )]" #end > </td> - <td rowspan='5' valign='bottom'> + <td rowspan='4' valign='bottom' id='criteriaBtnTD'> <input type="button" style='width:130px' id='listPatientBtn' style='260px;' value="$i18n.getString( 'list_all_patients' )" onclick="javascript:listAllPatient();" > <input type="button" style='width:130px' id='addPatientBtn' name='addPatientBtn' class='large-button' value='$i18n.getString( "add_new" )' onclick="showAddPatientForm(getFieldValue('programIdAddPatient'),'', '');" > - <input type="button" style='width:130px' id='advancedSearchBtn' value='$i18n.getString( "advanced_search" )' onclick="jQuery('#advanced-search').toggle();" > + <input type="button" style='width:130px' id='advancedSearchBtn' value='$i18n.getString( "advanced_search" )' onclick="advancedSearchOnclick();" > </td> </tr> <tr id='programAddPatientTR'> @@ -67,6 +67,11 @@ <input type='checkbox' id='followup' name='followup' /> </td> </tr> + <tr id='searchByIdTR'> + <td colspan='2' ><input type='text' id='searchPatientByIds' name='searchPatientByIds' onchange='searchByIdsOnclick();' style='width:350px;' placeholder='$i18n.getString("search_by_name_identifier")' /></td> + <td><input type='button' value='$i18n.getString("search")' onclick='searchByIdsOnclick();' ></td> + </tr> + </table> <div id='advanced-search' name='advanced-search' class='hidden advanced-search'> <table> @@ -86,6 +91,16 @@ </td> </tr> + <tr id='enrollmentSelectTR' class='hidden' > + <td>$i18n.getString('show')</td> + <td> + <select id='statusEnrollment'> + <option value='0'>$i18n.getString('active_enrollments_only')</option> + <option value='1'>$i18n.getString('completed_enrollments_only')</option> + <option value=''>$i18n.getString('both')</option> + </select> + </td> + </tr> <tr id='dueDateTR' class='hidden'> <td>$i18n.getString('due_date_from_to')</td> <td> === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm 2013-09-11 16:02:06 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm 2013-10-02 11:24:32 +0000 @@ -1,3 +1,10 @@ +<script> +jQuery(document).ready( function(){ + jQuery('#criteriaBtnTD').attr('rowspan', 2); + showById('enrollmentSelectTR'); + }); +</script> + <h3 id='mainLinkLbl'>$i18n.getString( "patient_management" ) #openHelp( "patient" )</a></h3> <input type='hidden' id='isRegistration' name= 'isRegistration' value='false'>
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp