=== 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 searchPatients( List searchKeys, Collection orgunit, - Boolean followup, Collection patientAttributes, Integer min, Integer max ); + Boolean followup, Collection patientAttributes, Integer statusEnrollment, Integer min, Integer max ); - int countSearchPatients( List searchKeys, Collection orgunit, Boolean followup ); + int countSearchPatients( List searchKeys, Collection orgunit, Boolean followup, Integer statusEnrollment ); Collection getPatientPhoneNumbers( List searchKeys, Collection orgunit, - Boolean followup, Integer min, Integer max ); + Boolean followup, Integer statusEnrollment, Integer min, Integer max ); List getProgramStageInstances( List searchKeys, Collection orgunit, - Boolean followup, Integer min, Integer max ); + Boolean followup, Integer statusEnrollment, Integer min, Integer max ); - Grid getScheduledEventsReport( List searchKeys, Collection orgunits, Boolean followup, + Grid getScheduledEventsReport( List searchKeys, Collection orgunits, Boolean followup, Integer statusEnrollment, Integer min, Integer max, I18n i18n ); Collection getPatientsByPhone( String phoneNumber, Integer min, Integer max ); @@ -284,5 +284,5 @@ Collection getRegistrationOrgunitIds( Date startDate, Date endDate ); Grid getTrackingEventsReport( Program program, List searchKeys, Collection 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 searchKeys, Collection orgunit, Boolean followup ); + int countSearch( List searchKeys, Collection orgunit, Boolean followup, Integer statusEnrollment ); Collection getByPhoneNumber( String phoneNumber, Integer min, Integer max ); @@ -80,17 +80,17 @@ Collection getRegistrationOrgunitIds( Date startDate, Date endDate ); Collection search( List searchKeys, Collection orgunit, Boolean followup, - Collection patientAttributes, Integer min, Integer max ); + Collection patientAttributes, Integer statusEnrollment, Integer min, Integer max ); Collection getPatientPhoneNumbers( List searchKeys, Collection orgunits, Boolean followup, - Collection patientAttributes, Integer min, Integer max ); + Collection patientAttributes, Integer statusEnrollment, Integer min, Integer max ); Grid getPatientEventReport( Grid grid, List searchKeys, Collection orgunit, Boolean followup, - Collection patientAttributes, Collection identifierTypes, Integer min, + Collection patientAttributes, Collection identifierTypes, Integer statusEnrollment, Integer min, Integer max ); List getProgramStageInstances( List searchKeys, Collection orgunits, Boolean followup, - Collection patientAttributes, Collection identifierTypes, Integer min, + Collection patientAttributes, Collection identifierTypes, Integer statusEnrollment, Integer min, Integer max ); Collection 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 stageInstanceIds = patientService.getProgramStageInstances( searchTextList, orgUnitList, true, null, null ); + List 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 getPatientsLikeName( OrganisationUnit organisationUnit, String name, Integer min, Integer max ) + public Collection 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 searchPatients( List searchKeys, Collection orgunits, - Boolean followup, Collection patientAttributes, Integer min, Integer max ) + Boolean followup, Collection 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 searchKeys, Collection orgunits, Boolean followup ) + public int countSearchPatients( List searchKeys, Collection orgunits, Boolean followup, + Integer statusEnrollment ) { - return patientStore.countSearch( searchKeys, orgunits, followup ); + return patientStore.countSearch( searchKeys, orgunits, followup, statusEnrollment ); } public Collection getPatientPhoneNumbers( List searchKeys, Collection 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 getProgramStageInstances( List searchKeys, Collection 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 searchKeys, Collection 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 searchKeys, - Collection orgunits, Boolean followup, I18n i18n ) + Collection 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 getByOrgUnitAndNameLike( OrganisationUnit organisationUnit, String nameLike, Integer min, Integer max ) + public Collection 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 search( List searchKeys, Collection orgunits, - Boolean followup, Collection patientAttributes, Integer min, Integer max ) + Boolean followup, Collection 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 patients = new HashSet(); try { @@ -394,9 +396,11 @@ @Override public Collection getPatientPhoneNumbers( List searchKeys, Collection orgunits, - Boolean followup, Collection patientAttributes, Integer min, Integer max ) + Boolean followup, Collection 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 phoneNumbers = new HashSet(); try { @@ -420,10 +424,10 @@ @Override public List getProgramStageInstances( List searchKeys, Collection orgunits, Boolean followup, Collection patientAttributes, - Collection identifierTypes, Integer min, Integer max ) + Collection 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 programStageInstanceIds = new ArrayList(); try { @@ -444,23 +448,24 @@ return programStageInstanceIds; } - public int countSearch( List searchKeys, Collection orgunits, Boolean followup ) + public int countSearch( List searchKeys, Collection 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 searchKeys, Collection orgunits, Boolean followup, Collection patientAttributes, - Collection identifierTypes, Integer min, Integer max ) + Collection 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 searchKeys, Collection orgunits, Boolean followup, Collection patientAttributes, - Collection identifierTypes, Integer min, Integer max ) + Collection 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 orgunits = new HashSet(); 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 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 searchTexts = new ArrayList(); + 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 programStageInstanceIds = patientService.getProgramStageInstances( searchTexts, orgunits, - followup, null, null ); + followup, ProgramInstance.STATUS_ACTIVE, null, null ); Set phoneNumberList = new HashSet( 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 + \ 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 @@ - + - + @@ -67,6 +67,11 @@ + + + + +