=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java 2012-07-13 02:46:02 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java 2012-08-16 06:20:33 +0000 @@ -63,6 +63,7 @@ public static String PREFIX_FIXED_ATTRIBUTE = "fixedAttr"; public static String PREFIX_PATIENT_ATTRIBUTE = "attr"; public static String PREFIX_PROGRAM = "prg"; + public static String PREFIX_PROGRAM_STAGE = "prgst"; public static String FIXED_ATTR_BIRTH_DATE = "birthDate"; public static String FIXED_ATTR_AGE = "age"; === 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 2012-08-02 10:32:32 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2012-08-16 06:20:33 +0000 @@ -48,6 +48,7 @@ import org.hisp.dhis.patient.Patient; import org.hisp.dhis.patient.PatientStore; import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramStageInstance; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.transaction.annotation.Transactional; @@ -317,17 +318,17 @@ } else if ( keys[0].equals( Patient.PREFIX_IDENTIFIER_TYPE ) ) { - patientWhere = patientOperator + "( ( lower( " + statementBuilder.getPatientFullName() + " ) like '%" + id - + "%' ) or lower(pi.identifier)='" + id + "' "; - + patientWhere += patientOperator + "( ( lower( " + statementBuilder.getPatientFullName() + " ) like '%" + + id + "%' ) or lower(pi.identifier)='" + id + "' "; + String[] keyValues = id.split( " " ); - if( keyValues.length==2) + if ( keyValues.length == 2 ) { - String otherId = keyValues[0] + " " + keyValues[1]; + String otherId = keyValues[0] + " " + keyValues[1]; patientWhere += " or lower( " + statementBuilder.getPatientFullName() + " ) like '%" + otherId + "%' "; } - patientWhere += ")"; + patientWhere += ")"; patientOperator = " and "; hasIdentifier = true; } @@ -335,33 +336,64 @@ { sql += "(select value from patientattributevalue where patientid=p.patientid and patientattributeid=" + id + " ) as " + Patient.PREFIX_PATIENT_ATTRIBUTE + "_" + id + ","; - otherWhere = operator + "lower(" + Patient.PREFIX_PATIENT_ATTRIBUTE + "_" + id + ")='" + value + "'"; + otherWhere += operator + "lower(" + Patient.PREFIX_PATIENT_ATTRIBUTE + "_" + id + ")='" + value + "'"; operator = " and "; } else if ( keys[0].equals( Patient.PREFIX_PROGRAM ) ) { sql += "(select programid from patient_programs where patientid=p.patientid and programid=" + keys[1] + " ) as " + Patient.PREFIX_PROGRAM + "_" + id + ","; - otherWhere = operator + Patient.PREFIX_PROGRAM + "_" + id + "=" + id; + otherWhere += operator + Patient.PREFIX_PROGRAM + "_" + id + "=" + id; + operator = " and "; + } + else if ( keys[0].equals( Patient.PREFIX_PROGRAM_STAGE ) ) + { + sql += "(select COUNT(psi.programstageinstanceid) from programstageinstance psi "; + sql += "left join programinstance pgi on (psi.programinstanceid=pgi.programinstanceid) "; + sql += "where pgi.patientid=p.patientid and psi.programstageid=" + id + " and "; + + int statusEvent = Integer.parseInt( keys[2] ); + switch ( statusEvent ) + { + case ProgramStageInstance.COMPLETED_STATUS: + sql += "psi.completed=true"; + break; + case ProgramStageInstance.VISITED_STATUS: + sql += "psi.executiondate is not null"; + break; + case ProgramStageInstance.FUTURE_VISIT_STATUS: + sql += "psi.executiondate is null and psi.duedate >= now()"; + break; + case ProgramStageInstance.LATE_VISIT_STATUS: + sql += "psi.executiondate is null and psi.duedate < now()"; + break; + default: + break; + } + + sql += " ) as " + Patient.PREFIX_PROGRAM_STAGE + "_" + id + ","; + + otherWhere += operator + Patient.PREFIX_PROGRAM_STAGE + "_" + id + ">0"; operator = " and "; } } if ( orgunit != null ) { - sql += "(select organisationunitid from patient where patientid=p.patientid and organisationunitid = " + orgunit.getId() + " ) as orgunitid,"; + sql += "(select organisationunitid from patient where patientid=p.patientid and organisationunitid = " + + orgunit.getId() + " ) as orgunitid,"; otherWhere += operator + "orgunitid=" + orgunit.getId(); } - + sql = sql.substring( 0, sql.length() - 1 ) + " "; // Removing last comma - + sql += " from patient p "; if ( hasIdentifier ) { sql += " left join patientidentifier pi on p.patientid=pi.patientid "; } - sql += patientWhere ; + sql += patientWhere; sql += " ) as searchresult"; sql += otherWhere; === 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 2012-07-26 08:53:44 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchPatientAction.java 2012-08-16 06:20:33 +0000 @@ -63,7 +63,7 @@ private Boolean searchBySelectedOrgunit; private boolean listAll; - + private Collection patients = new ArrayList(); // ------------------------------------------------------------------------- === 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 2012-08-15 02:57:56 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-08-16 06:20:33 +0000 @@ -408,4 +408,6 @@ completed_programs = Completed programs active_programs = Active programs completed = Completed -create_event_success = Create event successfully. \ No newline at end of file +create_event_success = Create event successfully. +overdue = Overdue +scheduled_in_future = Scheduled in future \ 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 2012-08-16 02:08:22 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2012-08-16 06:20:33 +0000 @@ -221,6 +221,13 @@ } }) }); + + if( getFieldValue('searchByProgramStage') == "true"){ + var programStageId = jQuery('#programStageAddPatientTR [id=programStageAddPatient_' + getFieldValue('programIdAddPatient') + ']').val(); + var statusEvent = jQuery('#programStageAddPatientTR [id=statusEvent]:checked').val(); + params += '&searchTexts=prgst_' + programStageId + '_' + statusEvent; + } + params += '&listAll=false'; params += '&searchBySelectedOrgunit=' + byId('searchBySelectedOrgunit').checked; @@ -412,6 +419,9 @@ function enableBtn(){ var programIdAddPatient = getFieldValue('programIdAddPatient'); + jQuery('#programStageAddPatientTR [name=programStageAddPatient]').addClass("hidden"); + jQuery('#programStageAddPatientTR [id=programStageAddPatient_' + programIdAddPatient + ']').removeClass("hidden"); + if( programIdAddPatient!='' ){ enable('listPatientBtn'); enable('addPatientBtn'); @@ -419,6 +429,7 @@ jQuery('#advanced-search :input').each( function( idx, item ){ enable(this.id); }); + jQuery('#programStageAddPatientTR [name=statusEvent]').attr("disabled", true); } else { @@ -431,6 +442,17 @@ } } +function enableRadioButton( programId ) +{ + var prorgamStageId = jQuery('#programStageAddPatientTR [id=programStageAddPatient_' + programId + ']').val(); + if( prorgamStageId== ''){ + jQuery('#programStageAddPatientTR [name=statusEvent]').attr("disabled", true); + } + else{ + jQuery('#programStageAddPatientTR [name=statusEvent]').removeAttr("disabled"); + } +} + function showColorHelp() { jQuery('#colorHelpDiv').dialog({ === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js 2012-08-09 14:21:01 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js 2012-08-16 06:20:33 +0000 @@ -103,8 +103,6 @@ } ); } - - function loadProgramStageRecords( programStageInstanceId ) { setInnerHTML('dataEntryFormDiv', ''); === 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 2012-08-07 05:43:56 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm 2012-08-16 06:20:33 +0000 @@ -1,3 +1,4 @@ + - +
@@ -12,7 +13,7 @@