← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2648: Iinto ProgramUnenrollment function, only show programs which selected patient enrolled.

 

------------------------------------------------------------
revno: 2648
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-01-20 09:15:19 +0700
message:
  Iinto ProgramUnenrollment function, only show programs which selected patient enrolled.
removed:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programUnenrollmentForm.vm
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/RemoveEnrollmentAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/RemoveEnrollmentSelectAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programUnenrollmentSelectForm.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-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/RemoveEnrollmentAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/RemoveEnrollmentAction.java	2011-01-11 07:06:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/RemoveEnrollmentAction.java	2011-01-20 02:15:19 +0000
@@ -63,272 +63,215 @@
  * @author Abyot Asalefew Gizaw
  * @version $Id$
  */
-public class RemoveEnrollmentAction
-    implements Action
-{
-    public static final String PREFIX_ATTRIBUTE = "attr";
-
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private PatientService patientService;
-
-    public void setPatientService( PatientService patientService )
-    {
-        this.patientService = patientService;
-    }
-
-    private ProgramService programService;
-
-    public void setProgramService( ProgramService programService )
-    {
-        this.programService = programService;
-    }
-
-    private ProgramInstanceService programInstanceService;
-
-    public void setProgramInstanceService( ProgramInstanceService programInstanceService )
-    {
-        this.programInstanceService = programInstanceService;
-    }
-
-    private SelectedStateManager selectedStateManager;
-
-    public void setSelectedStateManager( SelectedStateManager selectedStateManager )
-    {
-        this.selectedStateManager = selectedStateManager;
-    }
-
-    private ProgramAttributeService programAttributeService;
-
-    public void setProgramAttributeService( ProgramAttributeService programAttributeService )
-    {
-        this.programAttributeService = programAttributeService;
-    }
-
-    private ProgramAttributeOptionService programAttributeOptionService;
-
-    public void setProgramAttributeOptionService( ProgramAttributeOptionService programAttributeOptionService )
-    {
-        this.programAttributeOptionService = programAttributeOptionService;
-    }
-
-    private ProgramAttributeValueService programAttributeValueService;
-
-    public void setProgramAttributeValueService( ProgramAttributeValueService programAttributeValueService )
-    {
-        this.programAttributeValueService = programAttributeValueService;
-    }
-
-    private I18nFormat format;
-
-    public void setFormat( I18nFormat format )
-    {
-        this.format = format;
-    }
-
-    // -------------------------------------------------------------------------
-    // Input/Output
-    // -------------------------------------------------------------------------
-
-    private Integer id;
-
-    public void setId( Integer id )
-    {
-        this.id = id;
-    }
-
-    public Integer getId()
-    {
-        return id;
-    }
-
-    private Patient patient;
-
-    public Patient getPatient()
-    {
-        return patient;
-    }
-
-    public void setPatient( Patient patient )
-    {
-        this.patient = patient;
-    }
-
-    private ProgramInstance programInstance;
-
-    public ProgramInstance getProgramInstance()
-    {
-        return programInstance;
-    }
-
-    private Integer programId;
-
-    public void setProgramId( Integer programId )
-    {
-        this.programId = programId;
-    }
-
-    public Integer getProgramId()
-    {
-        return programId;
-    }
-
-    private Integer programInstanceId;
-
-    public Integer getProgramInstanceId()
-    {
-        return programInstanceId;
-    }
-
-    public void setProgramInstanceId( Integer programInstanceId )
-    {
-        this.programInstanceId = programInstanceId;
-    }
-
-    private Collection<Program> programs = new ArrayList<Program>();
-
-    public Collection<Program> getPrograms()
-    {
-        return programs;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    public String execute()
-        throws Exception
-    {
-        patient = selectedStateManager.getSelectedPatient();
-
-        Program program = selectedStateManager.getSelectedProgram();
-
-        programs = programService.getAllPrograms();
-
-        Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstances( patient, program,
-            false );
-
-        if ( programInstances.iterator().hasNext() )
-        {
-            programInstance = programInstances.iterator().next();
-        }
-
-        if ( programInstance != null )
-        {
-            programInstance.setEndDate( new Date() );
-            programInstance.setCompleted( true );
-
-            programInstanceService.updateProgramInstance( programInstance );
-
-            patient.getPrograms().remove( program );
-            patientService.updatePatient( patient );
-
-            selectedStateManager.clearSelectedProgram();
-        }
-
-        // --------------------------------------------------------------------------------------------------------
-        // Save Program Attributes
-        // -----------------------------------------------------------------------------------------------------
-
-        HttpServletRequest request = ServletActionContext.getRequest();
-
-        Collection<ProgramAttribute> attributes = programAttributeService.getAllProgramAttributes();
-
-        Set<ProgramAttribute> programAttributes = new HashSet<ProgramAttribute>();
-
-        // End-user inputs attribute value for DEAD-attribute
-        boolean flag = false;
-
-        if ( attributes != null && attributes.size() > 0 )
-        {
-            programInstance.getAttributes().clear();
-
-            // Save other attributes
-            for ( ProgramAttribute attribute : attributes )
-            {
-                String value = request.getParameter( RemoveEnrollmentAction.PREFIX_ATTRIBUTE + attribute.getId() );
-
-                if ( StringUtils.isNotBlank( value ) )
-                {
-                    programAttributes.add( attribute );
-
-                    ProgramAttributeValue attributeValue = programAttributeValueService.getProgramAttributeValue(
-                        programInstance, attribute );
-
-                    // attributeValue is not exist
-                    if ( attributeValue == null )
-                    {
-                        attributeValue = new ProgramAttributeValue();
-                        attributeValue.setProgramInstance( programInstance );
-                        attributeValue.setProgramAttribute( attribute );
-
-                        // DEAD program-attribute
-                        if ( attribute.getName().equalsIgnoreCase( ProgramAttribute.DEAD_NAME )
-                            && attribute.getValueType().equalsIgnoreCase( ProgramAttribute.TYPE_BOOL ) )
-                        {
-                            attributeValue.setValue( value.trim() );
-                            patient.setIsDead( Boolean.parseBoolean( value.trim() ) );
-                            patientService.updatePatient( patient );
-                            flag = true;
-                        }
-                        else if ( ProgramAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) )
-                        {
-                            ProgramAttributeOption option = programAttributeOptionService.get( NumberUtils.toInt(
-                                value, 0 ) );
-                            if ( option != null )
-                            {
-                                attributeValue.setProgramAttributeOption( option );
-                                attributeValue.setValue( option.getName() );
-                            }
-                        }
-                        else
-                        {
-                            attributeValue.setValue( value.trim() );
-                        }
-
-                        // CLOSED-DATE program-attribute
-                        if ( attribute.getName().equalsIgnoreCase( ProgramAttribute.CLOSED_DATE )
-                            && attribute.getValueType().equalsIgnoreCase( ProgramAttribute.TYPE_DATE ) && flag )
-                        {
-                            patient.setDeathDate( format.parseDate( value.trim() ) );
-                            patientService.updatePatient( patient );
-                        }
-
-                        // save values
-                        programAttributeValueService.saveProgramAttributeValue( attributeValue );
-
-                    }
-                    // attributeValue is exist
-                    else
-                    {
-                        if ( ProgramAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) )
-                        {
-                            ProgramAttributeOption option = programAttributeOptionService.get( NumberUtils.toInt(
-                                value, 0 ) );
-                            if ( option != null )
-                            {
-                                attributeValue.setProgramAttributeOption( option );
-                                attributeValue.setValue( option.getName() );
-                            }
-                        }
-                        else
-                        {
-                            attributeValue.setValue( value.trim() );
-                        }
-                    }
-
-                    // update values
-                    programAttributeValueService.updateProgramAttributeValue( attributeValue );
-                }
-            }
-        }
-System.out.println("\n\n ++++++++ \n programAttributes : " + programAttributes );
-        programInstance.setAttributes( programAttributes );
-
-        programInstanceService.updateProgramInstance( programInstance );
-
-        return SUCCESS;
-    }
+public class RemoveEnrollmentAction implements Action {
+	public static final String PREFIX_ATTRIBUTE = "attr";
+
+	// -------------------------------------------------------------------------
+	// Dependencies
+	// -------------------------------------------------------------------------
+
+	private PatientService patientService;
+
+	private ProgramService programService;
+
+	private ProgramInstanceService programInstanceService;
+
+	private ProgramAttributeService programAttributeService;
+
+	private ProgramAttributeOptionService programAttributeOptionService;
+
+	private ProgramAttributeValueService programAttributeValueService;
+
+	private I18nFormat format;
+
+	// -------------------------------------------------------------------------
+	// Input/Output
+	// -------------------------------------------------------------------------
+	
+	private Integer programInstanceId;
+
+	private Collection<Program> programs = new ArrayList<Program>();
+	
+	private Patient patient;
+
+	// -------------------------------------------------------------------------
+	// Getters && Setters
+	// -------------------------------------------------------------------------
+
+	public void setPatientService(PatientService patientService) {
+		this.patientService = patientService;
+	}
+
+	public void setProgramService(ProgramService programService) {
+		this.programService = programService;
+	}
+
+	public void setProgramInstanceService(
+			ProgramInstanceService programInstanceService) {
+		this.programInstanceService = programInstanceService;
+	}
+
+	public void setProgramAttributeService(
+			ProgramAttributeService programAttributeService) {
+		this.programAttributeService = programAttributeService;
+	}
+
+	public void setProgramAttributeOptionService(
+			ProgramAttributeOptionService programAttributeOptionService) {
+		this.programAttributeOptionService = programAttributeOptionService;
+	}
+
+	public void setProgramAttributeValueService(
+			ProgramAttributeValueService programAttributeValueService) {
+		this.programAttributeValueService = programAttributeValueService;
+	}
+
+	public void setFormat(I18nFormat format) {
+		this.format = format;
+	}
+
+	public Patient getPatient() {
+		return patient;
+	}
+
+	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 );
+		
+		// Get selected patient from programInstance
+		patient = programInstance.getPatient();
+		
+		// Get selected program from programInstance
+		Program program = programInstance.getProgram();
+		
+		// ---------------------------------------------------------------------
+		// Update Information of programInstance
+		// ---------------------------------------------------------------------
+		
+		programInstance.setEndDate(new Date());
+		programInstance.setCompleted(true);
+
+		programInstanceService.updateProgramInstance(programInstance);
+
+		patient.getPrograms().remove(program);
+		patientService.updatePatient(patient);
+
+		// ---------------------------------------------------------------------
+		// Save Program Attributes
+		// ---------------------------------------------------------------------
+
+		HttpServletRequest request = ServletActionContext.getRequest();
+
+		Collection<ProgramAttribute> attributes = programAttributeService
+				.getAllProgramAttributes();
+
+		Set<ProgramAttribute> programAttributes = new HashSet<ProgramAttribute>();
+
+		// End-user inputs attribute value for DEAD-attribute
+		boolean flag = false;
+
+		if (attributes != null && attributes.size() > 0) {
+			programInstance.getAttributes().clear();
+
+			// Save other attributes
+			for (ProgramAttribute attribute : attributes) {
+				String value = request
+						.getParameter(RemoveEnrollmentAction.PREFIX_ATTRIBUTE
+								+ attribute.getId());
+
+				if (StringUtils.isNotBlank(value)) {
+					programAttributes.add(attribute);
+
+					ProgramAttributeValue attributeValue = programAttributeValueService
+							.getProgramAttributeValue(programInstance,
+									attribute);
+
+					// attributeValue is not exist
+					if (attributeValue == null) {
+						attributeValue = new ProgramAttributeValue();
+						attributeValue.setProgramInstance(programInstance);
+						attributeValue.setProgramAttribute(attribute);
+
+						// DEAD program-attribute
+						if (attribute.getName().equalsIgnoreCase(
+								ProgramAttribute.DEAD_NAME)
+								&& attribute.getValueType().equalsIgnoreCase(
+										ProgramAttribute.TYPE_BOOL)) {
+							attributeValue.setValue(value.trim());
+							patient.setIsDead(Boolean
+									.parseBoolean(value.trim()));
+							patientService.updatePatient(patient);
+							flag = true;
+						} else if (ProgramAttribute.TYPE_COMBO
+								.equalsIgnoreCase(attribute.getValueType())) {
+							ProgramAttributeOption option = programAttributeOptionService
+									.get(NumberUtils.toInt(value, 0));
+							if (option != null) {
+								attributeValue
+										.setProgramAttributeOption(option);
+								attributeValue.setValue(option.getName());
+							}
+						} else {
+							attributeValue.setValue(value.trim());
+						}
+
+						// CLOSED-DATE program-attribute
+						if (attribute.getName().equalsIgnoreCase(
+								ProgramAttribute.CLOSED_DATE)
+								&& attribute.getValueType().equalsIgnoreCase(
+										ProgramAttribute.TYPE_DATE) && flag) {
+							patient
+									.setDeathDate(format
+											.parseDate(value.trim()));
+							patientService.updatePatient(patient);
+						}
+
+						// save values
+						programAttributeValueService
+								.saveProgramAttributeValue(attributeValue);
+
+					}
+					// attributeValue is exist
+					else {
+						if (ProgramAttribute.TYPE_COMBO
+								.equalsIgnoreCase(attribute.getValueType())) {
+							ProgramAttributeOption option = programAttributeOptionService
+									.get(NumberUtils.toInt(value, 0));
+							if (option != null) {
+								attributeValue
+										.setProgramAttributeOption(option);
+								attributeValue.setValue(option.getName());
+							}
+						} else {
+							attributeValue.setValue(value.trim());
+						}
+					}
+
+					// update values
+					programAttributeValueService
+							.updateProgramAttributeValue(attributeValue);
+				}
+			}
+		}
+		System.out.println("\n\n ++++++++ \n programAttributes : "
+				+ programAttributes);
+		programInstance.setAttributes(programAttributes);
+
+		programInstanceService.updateProgramInstance(programInstance);
+
+		return SUCCESS;
+	}
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/RemoveEnrollmentSelectAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/RemoveEnrollmentSelectAction.java	2011-01-11 07:06:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/RemoveEnrollmentSelectAction.java	2011-01-20 02:15:19 +0000
@@ -26,11 +26,17 @@
  */
 package org.hisp.dhis.patient.action.patient;
 
+import java.util.ArrayList;
 import java.util.Collection;
 
+import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientService;
+import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramAttribute;
 import org.hisp.dhis.program.ProgramAttributeService;
 import org.hisp.dhis.program.ProgramInstance;
+import org.hisp.dhis.program.ProgramInstanceService;
+import org.hisp.dhis.program.ProgramService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -38,83 +44,122 @@
  * @author Chau Thu Tran
  * @version $ID : RemoveEnrollmentSelectAction.java Jan 11, 2011 10:00:55 AM $
  */
-public class RemoveEnrollmentSelectAction
-    implements Action
-{
-    // -------------------------------------------------------------------------
-    // Dependency
-    // -------------------------------------------------------------------------
-
-    private ProgramAttributeService programAttributeService;
-
-    // -------------------------------------------------------------------------
-    // Input/Output
-    // -------------------------------------------------------------------------
-
-    private Integer id;
-
-    private Integer programId;
-
-    private ProgramInstance programInstance;
-
-    private Collection<ProgramAttribute> programAttributes;
-    
-
-    // -------------------------------------------------------------------------
-    // Getter
-    // -------------------------------------------------------------------------
-
-    public void setProgramAttributeService( ProgramAttributeService programAttributeService )
-    {
-        this.programAttributeService = programAttributeService;
-    }
-
-    public void setId( Integer id )
-    {
-        this.id = id;
-    }
-
-    public Integer getId()
-    {
-        return id;
-    }
-
-    public void setProgramId( Integer programId )
-    {
-        this.programId = programId;
-    }
-
-    public ProgramInstance getProgramInstance()
-    {
-        return programInstance;
-    }
-
-    public void setProgramInstance( ProgramInstance programInstance )
-    {
-        this.programInstance = programInstance;
-    }
-
-    public Integer getProgramId()
-    {
-        return programId;
-    }
-
-    public Collection<ProgramAttribute> getProgramAttributes()
-    {
-        return programAttributes;
-    }
-
-    // -------------------------------------------------------------------------
-    // Implementation Action
-    // -------------------------------------------------------------------------
-
-    @Override
-    public String execute()
-        throws Exception
-    {
-        programAttributes = programAttributeService.getAllProgramAttributes();
-        
-        return SUCCESS;
-    }
+public class RemoveEnrollmentSelectAction implements Action {
+	// -------------------------------------------------------------------------
+	// Dependency
+	// -------------------------------------------------------------------------
+
+	private ProgramAttributeService programAttributeService;
+
+	private ProgramInstanceService programInstanceService;
+
+	private ProgramService programService;
+	
+	private PatientService patientService;
+
+	// -------------------------------------------------------------------------
+	// Input/Output
+	// -------------------------------------------------------------------------
+
+	private Integer patientId;
+
+	private Integer programInstanceId;
+	
+	private Collection<ProgramInstance> programInstances;
+
+	private Collection<ProgramAttribute> programAttributes;
+
+	private ProgramInstance programInstance;
+	
+	private Patient patient;
+	
+	// -------------------------------------------------------------------------
+	// Getter
+	// -------------------------------------------------------------------------
+
+	public void setProgramAttributeService(
+			ProgramAttributeService programAttributeService) {
+		this.programAttributeService = programAttributeService;
+	}
+
+	public ProgramInstance getProgramInstance() {
+		return programInstance;
+	}
+
+	public void setPatientService(PatientService patientService) {
+		this.patientService = patientService;
+	}
+
+	public void setProgramService(ProgramService programService) {
+		this.programService = programService;
+	}
+
+	public Patient getPatient() {
+		return patient;
+	}
+
+	public void setPatientId(Integer patientId) {
+		this.patientId = patientId;
+	}
+
+	public void setProgramInstanceId(Integer programInstanceId) {
+		this.programInstanceId = programInstanceId;
+	}
+
+	public Collection<ProgramInstance> getProgramInstances() {
+		return programInstances;
+	}
+
+	public Collection<ProgramAttribute> getProgramAttributes() {
+		return programAttributes;
+	}
+
+	public void setProgramInstanceService(
+			ProgramInstanceService programInstanceService) {
+		this.programInstanceService = programInstanceService;
+	}
+
+	// -------------------------------------------------------------------------
+	// Implementation Action
+	// -------------------------------------------------------------------------
+
+	@Override
+	public String execute() throws Exception {
+
+		programAttributes = programAttributeService.getAllProgramAttributes();
+
+		// ---------------------------------------------------------------------
+		// Get programInstance
+		// ---------------------------------------------------------------------
+
+		programInstances = new ArrayList<ProgramInstance>();
+
+		// Get selected patient
+		patient = patientService.getPatient( patientId );
+		// Get all of programs
+		Collection<Program> programs = programService.getAllPrograms();
+		
+		for( Program program : programs )
+		{
+			Collection<ProgramInstance> instances = programInstanceService
+					.getProgramInstances(patient, program, false);
+			
+			if (instances.iterator().hasNext()) {
+				programInstances.add( instances.iterator().next() );
+			}
+			
+		}
+		
+		// ---------------------------------------------------------------------
+		// Get selected programInstance
+		// ---------------------------------------------------------------------
+		
+		if( programInstanceId != null )
+		{
+			programInstance = programInstanceService.getProgramInstance( programInstanceId );
+		}
+
+		return SUCCESS;
+	}
 
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2011-01-12 02:26:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2011-01-20 02:15:19 +0000
@@ -563,6 +563,12 @@
 		scope="prototype">
 		<property name="programAttributeService"
 			ref="org.hisp.dhis.program.ProgramAttributeService" />
+		<property name="programInstanceService" 
+			ref="org.hisp.dhis.program.ProgramInstanceService" />
+		<property name="patientService" 
+			ref="org.hisp.dhis.patient.PatientService" />
+		<property name="programService" 
+			ref="org.hisp.dhis.program.ProgramService" />
 	</bean>
 	
 	<bean id="org.hisp.dhis.patient.action.patient.RemoveEnrollmentAction"
@@ -571,8 +577,6 @@
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
-		<property name="selectedStateManager"
-			ref="org.hisp.dhis.patient.state.SelectedStateManager" />
 		<property name="programAttributeService"
 			ref="org.hisp.dhis.program.ProgramAttributeService" />
 		<property name="programAttributeOptionService"

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2011-01-12 02:26:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2011-01-20 02:15:19 +0000
@@ -182,11 +182,14 @@
 			<param name="javascripts">
 				../dhis-web-commons/ouwt/ouwt.js
 				,../dhis-web-commons/javascripts/date.js
-				,javascript/jquery/thickbox/thickbox-compressed.js
+				,../dhis-web-commons/javascripts/jquery/ui/ui.thickbox.min.js
 				,javascript/relationshipPatient.js
 				,javascript/commons.js
 			</param>
-			<param name="stylesheets">javascript/jquery/thickbox/thickbox.css, style/basic.css</param>
+			<param name="stylesheets">
+				../dhis-web-commons/javascripts/jquery/ui/css/theme/thickbox.css
+				, style/basic.css
+			</param>
 			<param name="requiredAuthorities">F_PATIENT_ADD</param>
 		</action>
 
@@ -257,8 +260,8 @@
 				/dhis-web-maintenance-patient/updatePatientAttibuteForm.vm</param>
 			<param name="menu">/dhis-web-maintenance-patient/patientAndProgramMenu.vm</param>
 			<param name="javascripts">javascript/patientAttribute.js
-				,javascript/jquery/cluetip/jquery.cluetip.min.js</param>
-			<param name="stylesheets">javascript/jquery/cluetip/jquery.cluetip.css</param>
+				,../dhis-web-commons/javascripts/jquery/ui/jquery.cluetip.min.js</param>
+			<param name="stylesheets">../dhis-web-commons/javascripts/jquery/ui/css/theme/jquery.cluetip.css</param>
 			<param name="requiredAuthorities">F_PATIENTATTRIBUTE_UPDATE</param>
 		</action>
 
@@ -427,11 +430,15 @@
 			<param name="javascripts">
 				../dhis-web-commons/ouwt/ouwt.js
 				,../dhis-web-commons/javascripts/date.js				
-				,javascript/jquery/cluetip/jquery.cluetip.min.js
+				,../dhis-web-commons/javascripts/jquery/ui/jquery.cluetip.min.js
 				,javascript/patient.js
 				,javascript/commons.js						
 			</param>
-			<param name="stylesheets">javascript/jquery/thickbox/thickbox.css,javascript/jquery/cluetip/jquery.cluetip.css,style/basic.css</param>
+			<param name="stylesheets">
+				../dhis-web-commons/javascripts/jquery/ui/css/theme/thickbox.css
+				,../dhis-web-commons/javascripts/jquery/ui/css/theme/jquery.cluetip.css
+				,style/basic.css
+			</param>
 			<param name="requiredAuthorities">F_PATIENT_UPDATE</param>
 		</action>
 
@@ -538,7 +545,7 @@
 				javascript/patient.js</param>
 		</action>
 		
-		<action name="showProgramUnEnrollmentForm"
+		<!--  <action name="showProgramUnEnrollmentForm"
 			class="org.hisp.dhis.patient.action.patient.ProgramEnrollmentSelectAction">
 			<result name="enrollmentform" type="chain">enrollChain</result>
 			<result name="success" type="chain">unEnrollmentFormChain</result>
@@ -548,15 +555,15 @@
 		<action name="enrollChain"
 			class="org.hisp.dhis.patient.action.patient.ProgramEnrollmentAction">
 			<result name="success" type="chain">unEnrollmentFormChain</result>
-		</action>
+		</action>  -->
 		
-		<action name="unEnrollmentFormChain"
+		<action name="showProgramUnEnrollmentForm"
 			class="org.hisp.dhis.patient.action.patient.RemoveEnrollmentSelectAction">
 			<interceptor-ref name="organisationUnitTreeStack" />
 			<result name="success" type="velocity">/main.vm</result>
 			<param name="menu">/dhis-web-maintenance-patient/patientAndProgramMenuWithTree.vm</param>
 			<param name="menuTreeHeight">321</param>
-			<param name="page">/dhis-web-maintenance-patient/programUnenrollmentForm.vm</param>
+			<param name="page">/dhis-web-maintenance-patient/programUnenrollmentSelectForm.vm</param>
 			<param name="javascripts">
 				../dhis-web-commons/ouwt/ouwt.js,
 				../dhis-web-commons/javascripts/date.js,
@@ -566,7 +573,7 @@
 		
 		<action name="removeEnrollment"
 			class="org.hisp.dhis.patient.action.patient.RemoveEnrollmentAction">
-			<result name="success" type="redirect">showProgramUnEnrollmentForm.action?id=${id}
+			<result name="success" type="redirect">showProgramUnEnrollmentForm.action?patientId=${patient.id}
 			</result>
 			<param name="requiredAuthorities">F_PATIENT_DELETE</param>
 		</action>

=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programUnenrollmentForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programUnenrollmentForm.vm	2011-01-11 07:06:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programUnenrollmentForm.vm	1970-01-01 00:00:00 +0000
@@ -1,104 +0,0 @@
-
-<script>
-	//-----------------------------------------------------------------------
-	//init jQuery validation for programEnrollmentForm
-	//-----------------------------------------------------------------------
-	jQuery(document).ready(
-			function()
-			{
-				jQuery("#programUnenrollmentForm").validate({
-					 meta:"validate"
-					,errorElement:"td"
-					,submitHandler: function(form)
-									{
-										validateProgramEnrollment();
-									}
-				});
-
-                datePickerValid( 'enrollmentDate' );
-                datePickerValid( 'dateOfIncident' );
-			}
-	);
-
-</script>
-
-<form id="programEnrollmentForm" name="programEnrollmentForm" method="post" action='showProgramUnEnrollmentForm.action'>
-
-#parse( "/dhis-web-maintenance-patient/programUnenrollmentSelectForm.vm" )
-
-<table width="100%">
-    <tr>
-        <td style="width:180px"><label for="enrollmentDate" #if($selectedProgram) title="$!selectedProgram.dateOfEnrollmentDescription" #end>$i18n.getString( "date_of_enrollment" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-        <td><input type="text" id="enrollmentDate" name="enrollmentDate" #if( $programInstance ) value="$!format.formatDate( $programInstance.enrollmentDate )" #end> <i>( $!selectedProgram.dateOfEnrollmentDescription )</i></td>
-    </tr>
-    
-    <tr>
-        <td style="width:180px"><label for="dateOfIncident" #if($selectedProgram) title="$!selectedProgram.dateOfIncidentDescription" #end>$i18n.getString( "date_of_incident" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-        <td><input type="text" id="dateOfIncident" name="dateOfIncident" #if( $programInstance ) value="$!format.formatDate( $programInstance.dateOfIncident )" #end><i>( $!selectedProgram.dateOfIncidentDescription )</i></td>
-    </tr>
-	<tr>
-        <td></td>
-        <td></td>                           
-    </tr>
-
-#if($!programInstance.enrollmentDate) 
-	<tr>
-		<td colspan='2'><hr/></td>	
-	<tr>
-	#foreach($attribute in $programAttributes)
-	<tr>
-        <td>$attribute.name</td>
-		<td class="input-column">
-			#if( $attribute.valueType == "YES/NO" )
-				<select id="attr$attribute.id"  name="attr$attribute.id" style="width:100"> 
-					<option value="">[$i18n.getString( "please_select" )]</option>
-					<option value="true">$i18n.getString( "yes" )</option>
-					<option value="false" selected="selected">$i18n.getString( "no" )</option>
-				</select>                
-			#elseif( $attribute.valueType == "DATE" )
-				<input type="text" id="attr$attribute.id"  name="attr$attribute.id">
-				<script type="text/javascript">
-					datePickerValid( 'attr$attribute.id' );
-				</script>                    
-			#elseif( $attribute.valueType == "COMBO" )
-				<select  id="attr$attribute.id"  name="attr$attribute.id">
-					<option value="">[$i18n.getString( "please_select" )]</option>
-					#foreach ($option in $attribute.attributeOptions )
-						<option value="$option.id" >$option.name</option>
-					#end
-				</select>
-			#else 
-				<input type="text"  id="attr$attribute.id"  name="attr$attribute.id">
-			#end
-			
-			#if($!programAttribute.description) <i>($!programAttribute.description)</i> #end
-		</td>		
-    </tr>
-	#end
-	<tr>
-        <td></td>
-        <td></td>                            
-    </tr>
-	
-</table>
-#end
-
-<table>
-	<tr>
-		<td style="width:180px">
-			<input type="button" value='$i18n.getString( "unenroll" )' onclick="javascript: removeEnrollment();" #if( $!programInstance.enrollmentDate ) #else disabled #end>
-		</td>                                        
-	</tr>
-</table>
-
-</form>
-
-<span id="message"></span>
-
-<script type="text/javascript">    
-    var i18n_program_enrollment_failed = '$encoder.jsEscape( $i18n.getString( "program_enrollment_failed" ) , "'")';
-    var i18n_saving_value_failed_status_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_status_code" ) , "'")';
-    var i18n_saving_value_failed_error_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_error_code" ) , "'")';
-    var i18n_searching_patient_failed = '$encoder.jsEscape( $i18n.getString( "searching_patient_failed" ) , "'")'; 
-	var i18n_due_date_invalid = '$encoder.jsEscape( $i18n.getString( "due_date_invalid" ) , "'")';
-</script>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programUnenrollmentSelectForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programUnenrollmentSelectForm.vm	2011-01-11 07:06:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programUnenrollmentSelectForm.vm	2011-01-20 02:15:19 +0000
@@ -1,14 +1,33 @@
+
+<script>
+	//-----------------------------------------------------------------------
+	//init jQuery validation for programEnrollmentForm
+	//-----------------------------------------------------------------------
+	jQuery(document).ready(
+			function()
+			{
+				jQuery("#programUnenrollmentForm").validate({
+					 meta:"validate"
+					,errorElement:"td"
+					,submitHandler: function(form)
+									{
+										validateProgramEnrollment();
+									}
+				});
+
+                datePickerValid( 'enrollmentDate' );
+                datePickerValid( 'dateOfIncident' );
+			}
+	);
+
+</script>
+
 <div>
     <input type="button" value="$i18n.getString( "back_to_search" )" onclick="window.location.href='searchPatient.action'" style="width:10em">
 </div>
 
-
 <h3>$i18n.getString( "program_unenrollment" )</h3>
 
-<div>
-    <input type="hidden" id="id" name="id" value="$patient.id">    
-</div>
-
 <table>
     <tr>
         <td><strong>$i18n.getString( "full_name" ):</strong></td>
@@ -33,19 +52,103 @@
 
 <hr style="clear:both">
 
+<form id="programEnrollmentForm" name="programEnrollmentForm" method="get" action='showProgramUnEnrollmentForm.action'>
+<input type="hidden" id="patientId" name="patientId" value="$patient.id">    
 <table>    
     <tr>
         <td style="width:180px"><label for="programId">$i18n.getString( "program" )</label></td>
         <td>
-            <select id="programId" name="programId" onchange="byId( 'programEnrollmentForm' ).submit();" style="min-width:200px" #if( $programs.size() == 0 ) disabled="disabled"#end>
+            <select id="programInstanceId" name="programInstanceId" onchange="window.location.href='showProgramUnEnrollmentForm.action?patientId=$patient.id&programInstanceId=' + this.value" style="min-width:200px" >
                 <option value="0">[$i18n.getString( "select" )]</option>
-                #foreach( $program in $programs )
-                    <option value="$program.id" #if( $!programId && $!program.id == $!programId ) #set( $selectedProgram = $program) selected="selected" #end>$encoder.htmlEncode( $program.name )
-                    </option>
-                    
+                #foreach( $instance in $programInstances )
+                    <option value="$instance.id" #if($instance.id == $programInstance.id) selected #end>$encoder.htmlEncode( $instance.program.name )</option>
                 #end
             </select>
         </td>
     </tr>   
         
 </table>
+#if( $!programInstance )
+	
+	<table width="100%">
+		<tr>
+			<td style="width:20px"><label for="enrollmentDate">$i18n.getString( "date_of_enrollment" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+			<td><input type="text" style="width:180px" id="enrollmentDate" name="enrollmentDate" value="$!format.formatDate( $programInstance.enrollmentDate )"> <i>( $!programInstance.program.dateOfEnrollmentDescription )</i></td>
+		</tr>
+		
+		<tr>
+			<td style="width:180px"><label for="dateOfIncident">$i18n.getString( "date_of_incident" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+			<td><input type="text" style="width:180px" id="dateOfIncident" name="dateOfIncident" value="$!format.formatDate( $programInstance.dateOfIncident )"><i>( $!programInstance.program.dateOfIncidentDescription )</i></td>
+		</tr>
+		<tr>
+			<td></td>
+			<td></td>                           
+		</tr>
+
+		<tr>
+			<td colspan='2'><hr/></td>	
+		<tr>
+	
+		<!-- ------------------------------------------------------------ -->
+		<!--                   Show Program - Attributes                  -->
+		<!-- ------------------------------------------------------------ -->
+		
+		#foreach($attribute in $programAttributes)
+		<tr>
+			<td style="width:180px">$attribute.name</td>
+			<td class="input-column">
+				#if( $attribute.valueType == "YES/NO" )
+					<select id="attr$attribute.id" name="attr$attribute.id" style="width:200px"> 
+						<option value="">[$i18n.getString( "please_select" )]</option>
+						<option value="true">$i18n.getString( "yes" )</option>
+						<option value="false">$i18n.getString( "no" )</option>
+					</select>                     
+				#elseif( $attribute.valueType == "DATE" )
+					<input type="text" style="width:180px" id="attr$attribute.id" name="attr$attribute.id" class=' #validate( "default"  $attribute.mandatory )'>
+					<script type="text/javascript">
+						datePickerValid( 'attr$attribute.id' );
+					</script>                       
+				#elseif( $attribute.valueType == "COMBO" )
+					<select id="attr$attribute.id" name="attr$attribute.id" style="width:200px">
+						<option value="">[$i18n.getString( "please_select" )]</option>
+						#foreach ($option in $attribute.attributeOptions )
+							<option value="$option.id" >$option.name</option>
+						#end
+					</select>
+				#else 
+					<input type="text" id="attr$attribute.id" name="attr$attribute.id" style="width:180px" >
+				#end
+				
+				#if($!programAttribute.description) <i>($!programAttribute.description)</i> #end
+			</td>		
+		</tr>
+		#end
+		
+		<tr>
+			<td></td>
+			<td></td>                            
+		</tr>
+	
+	</table>
+
+
+	<table>
+		<tr>
+			<td style="width:180px">
+				<input type="button" value='$i18n.getString( "unenroll" )' onclick="javascript: removeEnrollment();" #if( $!programInstance.enrollmentDate ) #else disabled #end>
+			</td>                                        
+		</tr>
+	</table>
+#end
+
+</form>
+
+<span id="message"></span>
+
+<script type="text/javascript">    
+    var i18n_program_enrollment_failed = '$encoder.jsEscape( $i18n.getString( "program_enrollment_failed" ) , "'")';
+    var i18n_saving_value_failed_status_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_status_code" ) , "'")';
+    var i18n_saving_value_failed_error_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_error_code" ) , "'")';
+    var i18n_searching_patient_failed = '$encoder.jsEscape( $i18n.getString( "searching_patient_failed" ) , "'")'; 
+	var i18n_due_date_invalid = '$encoder.jsEscape( $i18n.getString( "due_date_invalid" ) , "'")';
+</script>