dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18128
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7517: Add unenroll program function.
------------------------------------------------------------
revno: 7517
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-07-05 16:07:21 +0700
message:
Add unenroll program function.
added:
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/RemoveEnrollmentAction.java
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
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/struts.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm
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/singleEventSelect.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
=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/RemoveEnrollmentAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/RemoveEnrollmentAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/RemoveEnrollmentAction.java 2012-07-05 09:07:21 +0000
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.caseentry.action.patient;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+
+import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramInstance;
+import org.hisp.dhis.program.ProgramInstanceService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Abyot Asalefew Gizaw
+ * @version $Id$
+ */
+public class RemoveEnrollmentAction
+ implements Action
+{
+ public static final String PREFIX_ATTRIBUTE = "attr";
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private PatientService patientService;
+
+ private ProgramInstanceService programInstanceService;
+
+ // -------------------------------------------------------------------------
+ // Input/Output
+ // -------------------------------------------------------------------------
+
+ private Integer programInstanceId;
+
+ private Collection<Program> programs = new ArrayList<Program>();
+
+ // -------------------------------------------------------------------------
+ // Getters && Setters
+ // -------------------------------------------------------------------------
+
+ public void setPatientService( PatientService patientService )
+ {
+ this.patientService = patientService;
+ }
+
+ public void setProgramInstanceService( ProgramInstanceService programInstanceService )
+ {
+ this.programInstanceService = programInstanceService;
+ }
+
+ public Collection<Program> getPrograms()
+ {
+ return programs;
+ }
+
+ public void setProgramInstanceId( Integer programInstanceId )
+ {
+ this.programInstanceId = programInstanceId;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ ProgramInstance programInstance = programInstanceService.getProgramInstance( programInstanceId );
+
+ Patient patient = programInstance.getPatient();
+
+ Program program = programInstance.getProgram();
+
+ // ---------------------------------------------------------------------
+ // Update Information of programInstance
+ // ---------------------------------------------------------------------
+
+ programInstance.setEndDate( new Date() );
+ programInstance.setCompleted( true );
+ programInstanceService.updateProgramInstance( programInstance );
+
+ // ---------------------------------------------------------------------
+ // Set Completed status all program-instaces of Death case
+ // ---------------------------------------------------------------------
+
+ patient.getPrograms().remove( program );
+ patientService.updatePatient( patient );
+
+ return SUCCESS;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-07-03 09:39:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-07-05 09:07:21 +0000
@@ -705,6 +705,14 @@
ref="org.hisp.dhis.patient.PatientAttributeOptionService" />
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
</bean>
+
+ <bean
+ id="org.hisp.dhis.caseentry.action.patient.RemoveEnrollmentAction"
+ class="org.hisp.dhis.caseentry.action.patient.RemoveEnrollmentAction"
+ scope="prototype">
+ <property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
+ <property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
+ </bean>
<!-- Relationship -->
=== 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-07-04 05:06:10 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-07-05 09:07:21 +0000
@@ -209,7 +209,7 @@
patient_profile=Person profile
other_details=Other details
register_event=Register event
-enroll_to_program=Enroll in program
+enroll=Enroll
add_dependent=Add dependent
edit_profile=Edit profile
case_aggregation_result=Person aggregation result
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2012-07-03 09:39:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2012-07-05 09:07:21 +0000
@@ -585,6 +585,12 @@
<param name="requiredAuthorities">F_PATIENT_UPDATE, F_PROGRAM_ENROLLMENT</param>
</action>
+ <action name="removeEnrollment"
+ class="org.hisp.dhis.caseentry.action.patient.RemoveEnrollmentAction">
+ <result name="success" type="velocity-xml">status.vm</result>
+ <param name="requiredAuthorities">F_PATIENT_UPDATE, F_PROGRAM_ENROLLMENT</param>
+ </action>
+
<!-- Relationship -->
<action name="getPartner"
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js 2012-07-05 06:42:40 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js 2012-07-05 09:07:21 +0000
@@ -465,18 +465,12 @@
});
}
-function unenrollmentForm( programInstanceId )
-{
- if( programInstanceId == 0 )
- {
- disable('enrollBtn');
- return;
- }
-
+function unenrollmentForm()
+{
$.ajax({
type: "POST",
url: 'removeEnrollment.action',
- data: getParamsForDiv('enrollmentDiv'),
+ data: "programInstanceId=" + getFieldValue('programInstanceId'),
success: function( json )
{
showSuccessMessage( i18n_unenrol_success );
@@ -713,6 +707,7 @@
hideById('enrollmentDateTR');
hideById('dateOfIncidentTR');
hideById('enrollBtn');
+ hideById('unenrollBtn');
}
function showEnrolmentField()
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm 2012-06-24 01:28:50 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm 2012-07-05 09:07:21 +0000
@@ -181,6 +181,10 @@
validation( 'programEnrollmentInforForm', function(form){
saveIdentifierAndAttribute();
});
+
+ #if( $!programInstance )
+ showById('unenrollBtn');
+ #end
});
#if( $programInstance || $hasDataEntry == 'true')
@@ -212,7 +216,7 @@
setFieldValue('dateOfIncident', "$!format.formatDate( $programInstance.dateOfIncident )");
if ( getFieldValue('enrollmentDate' ) == ''){
- jQuery('#enrollBtn').attr( 'value',i18n_enroll_to_program );
+ jQuery('#enrollBtn').attr( 'value',i18n_enroll );
}else{
jQuery('#enrollBtn').attr( 'value',i18n_update );
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm 2012-07-05 06:20:37 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm 2012-07-05 09:07:21 +0000
@@ -82,7 +82,7 @@
<td></td>
<td colspan='2'>
<input type="submit" id='enrollBtn' name='enrollBtn' class='button hidden' value="$i18n.getString( 'enroll' )" />
- <input type="submit" id='unenrollBtn' name='unenrollBtn' class='button hidden' value="$i18n.getString( 'unenroll' )" />
+ <input type="button" id='unenrollBtn' name='unenrollBtn' class='button hidden' value="$i18n.getString( 'unenroll' )" onclick='unenrollmentForm()'/>
</td>
</tr>
<tr>
@@ -108,7 +108,4 @@
datePickerInRange( 'dateOfIncident' , 'enrollmentDate' );
});
-
- datePickerValid( 'enrollmentDate' );
- datePickerValid( 'dateOfIncident' );
</script>
=== 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 2012-06-28 02:40:57 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm 2012-07-05 09:07:21 +0000
@@ -36,7 +36,7 @@
var i18n_searching_patient_failed = '$encoder.jsEscape( $i18n.getString( "searching_patient_failed" ) , "'")';
var i18n_date_invalid = '$encoder.jsEscape( $i18n.getString( "date_invalid" ) , "'")';
var i18n_date_less_incident = '$encoder.jsEscape( $i18n.getString( "date_less_incident" ) , "'")';
- var i18n_enroll_to_program = '$encoder.jsEscape( $i18n.getString( "enroll_to_program" ) , "'")';
+ var i18n_enroll = '$encoder.jsEscape( $i18n.getString( "enroll" ) , "'")';
var i18n_update = '$encoder.jsEscape( $i18n.getString( "update" ) , "'")';
var i18n_oucode_must_have_9_digits = '$encoder.jsEscape( $i18n.getString( "oucode_must_be_valid" ) , "'")';
var i18n_patient_identifiers = '$encoder.jsEscape( $i18n.getString( "patient_identifiers" ) , "'")';
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/singleEventSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/singleEventSelect.vm 2012-07-04 05:06:10 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/singleEventSelect.vm 2012-07-05 09:07:21 +0000
@@ -52,7 +52,7 @@
var i18n_searching_patient_failed = '$encoder.jsEscape( $i18n.getString( "searching_patient_failed" ) , "'")';
var i18n_date_invalid = '$encoder.jsEscape( $i18n.getString( "date_invalid" ) , "'")';
var i18n_date_less_incident = '$encoder.jsEscape( $i18n.getString( "date_less_incident" ) , "'")';
- var i18n_enroll_to_program = '$encoder.jsEscape( $i18n.getString( "enroll_to_program" ) , "'")';
+ var i18n_enroll = '$encoder.jsEscape( $i18n.getString( "enroll" ) , "'")';
var i18n_update = '$encoder.jsEscape( $i18n.getString( "update" ) , "'")';
var i18n_oucode_must_have_9_digits = '$encoder.jsEscape( $i18n.getString( "oucode_must_be_valid" ) , "'")';
var i18n_patient_identifiers = '$encoder.jsEscape( $i18n.getString( "patient_identifiers" ) , "'")';