← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8652: improvement for saving program stage section - web light

 

------------------------------------------------------------
revno: 8652
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-10-23 14:56:15 +0700
message:
  improvement for saving program stage section - web light
modified:
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetProgramStageFormAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetProgramStageSectionAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/beneficiaryProgramStageList.vm
  dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/selectProgramStageSection.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-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetProgramStageFormAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetProgramStageFormAction.java	2012-10-12 09:22:44 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetProgramStageFormAction.java	2012-10-23 07:56:15 +0000
@@ -27,7 +27,6 @@
 
 package org.hisp.dhis.light.namebaseddataentry.action;
 
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetProgramStageSectionAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetProgramStageSectionAction.java	2012-10-12 09:22:44 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetProgramStageSectionAction.java	2012-10-23 07:56:15 +0000
@@ -33,11 +33,14 @@
 import java.util.HashMap;
 import java.util.List;
 
+import org.hisp.dhis.dataset.Section;
 import org.hisp.dhis.light.utils.NamebasedUtils;
 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 org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageDataElement;
 import org.hisp.dhis.program.ProgramStageInstance;
@@ -80,6 +83,13 @@
     {
         this.programStageInstanceService = programStageInstanceService;
     }
+    
+    private ProgramService programService;
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
 
     // -------------------------------------------------------------------------
     // Input & Output
@@ -196,11 +206,47 @@
     {
         return programStageInstance;
     }
+    
+    private Program program;
+
+    public Program getProgram()
+    {
+        return this.program;
+    }
+    
+    private boolean validated;
+
+    public boolean isValidated()
+    {
+        return validated;
+    }
+
+    public void setValidated( boolean validated )
+    {
+        this.validated = validated;
+    }
+    
+    public String sectionName;
+
+    public String getSectionName()
+    {
+        return sectionName;
+    }
+    
+    public Integer programStageSectionId;
+    
+    public void setProgramStageSectionId( Integer programStageSectionId )
+    {
+        this.programStageSectionId = programStageSectionId;
+    }
 
     @Override
     public String execute()
         throws Exception
     {   
+        
+        program = programService.getProgram( programId );
+        
         programStageInstance = programStageInstanceService.getProgramStageInstance( programStageInstanceId );
         
         patient = patientService.getPatient( patientId );
@@ -209,6 +255,19 @@
         
         this.listOfProgramStageSections = new ArrayList<ProgramStageSection>(programStage.getProgramStageSections());
         
+        if ( programStageSectionId != null && programStageSectionId != 0)
+        {
+            for ( ProgramStageSection each: this.listOfProgramStageSections )
+            {
+                if ( each.getId() == programStageSectionId )
+                {
+                    sectionName = each.getName();
+
+                    break;
+                }
+            }
+        }
+        
         if( this.listOfProgramStageSections.size() == 0 && programStageInstance.isCompleted() == false)
         {
             return REDIRECT;
@@ -217,8 +276,7 @@
         {
             return REDIRECT_COMPLETED_FORM;
         }
-             
-        //this.listOfProgramStageDataElement = listOfProgramStageSections.get( 0 ).getProgramStageDataElements();
+
         return SUCCESS;
     }
 

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.java	2012-10-12 09:22:44 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.java	2012-10-23 07:56:15 +0000
@@ -78,9 +78,11 @@
 public class SaveProgramStageFormAction
     implements Action
 {
-    private static final String SUCCESS_AND_BACK_TO_PROGRAMSTAGE = "success_back_to_programstage";
+    private static final String SUCCESS_AND_BACK_TO_PROGRAMSTAGE = "success_back_to_programStage";
 
     private static final String REGISTER_NEXT_DUEDATE = "register_next_duedate";
+    
+    private static final String SUCCESS_AND_BACK_TO_PROGRAMSTAGE_SECTION = "success_back_to_programStageSection";
 
     // -------------------------------------------------------------------------
     // Dependencies
@@ -407,6 +409,18 @@
     {
         return programStageSection;
     }
+    
+    private Boolean validated;
+
+    public void setValidated( Boolean validated )
+    {
+        this.validated = validated;
+    }
+
+    public Boolean getValidated()
+    {
+        return validated;
+    }
 
     private I18n i18n;
 
@@ -534,7 +548,14 @@
         {
             return REGISTER_NEXT_DUEDATE;
         }
-
+        
+        validated = true;
+        
+        if ( programStageSectionId != null && programStageSectionId != 0 )
+        {
+            return SUCCESS_AND_BACK_TO_PROGRAMSTAGE_SECTION;
+        }
+        
         if ( orgUnitId != 0 )
         {
             return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml	2012-10-12 09:22:44 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml	2012-10-23 07:56:15 +0000
@@ -150,6 +150,7 @@
 		class="org.hisp.dhis.light.namebaseddataentry.action.GetProgramStageSectionAction">
 		<property name="util" ref="org.hisp.dhis.light.utils.NamebasedUtils" />
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 		<property name="programStageInstanceService"
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />	
 	</bean>

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml	2012-10-12 09:22:44 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml	2012-10-23 07:56:15 +0000
@@ -134,9 +134,12 @@
       <result name="success" type="redirect">
         /light/selectBeneficiary.action?organisationUnitId=${orgUnitId}&amp;current=${current}&amp;validated=true
       </result>
-      <result name="success_back_to_programstage" type="redirect">
+      <result name="success_back_to_programStage" type="redirect">
         /light/showPatientProgramList.action?patientId=${patientId}
       </result>
+      <result name="success_back_to_programStageSection" type="redirect">
+        /light/showProgramStageSection.action?programId=${programId}&amp;programStageId=${programStageId}&amp;programStageInstanceId=${programStageInstanceId}&amp;patientId=${patientId}&amp;programInstanceId=${programInstanceId}&amp;validated=${validated}&amp;programStageSectionId=${programStageSectionId}&amp;orgUnitId=0
+      </result>
       <result name="register_next_duedate" type="redirect">
         showRepeatableEventRegistrationForm.action?programInstanceId=${programInstanceId}&amp;programStageId=${programStageId}&amp;currentProgramStageInstanceId=${programStageInstanceId}
       </result>

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/beneficiaryProgramStageList.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/beneficiaryProgramStageList.vm	2012-10-12 09:22:44 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/beneficiaryProgramStageList.vm	2012-10-23 07:56:15 +0000
@@ -17,10 +17,10 @@
 	#end
 	<li>
 		 #if( $programStageInstance.isCompleted() == true )
-		 	<a href="showProgramStageSection.action?programId=$programId&programStageId=$programStageInstance.getProgramStage().getId()&programStageInstanceId=$programStageInstance.getId()&patientId=$patient.getId()&programInstanceId=$programStageInstance.getProgramInstance().getId()&orgUnitId=0">
+		 	<a href="showProgramStageSection.action?programId=$programId&programStageId=$programStageInstance.getProgramStage().getId()&programStageInstanceId=$programStageInstance.getId()&patientId=$patient.getId()&programInstanceId=$programStageInstance.getProgramInstance().getId()&orgUnitId=0&validated=false">
 			$programStageInstance.getProgramStage().getName() (${dateFormat.format( $programStageInstance.executionDate )}) <img src="../dhis-web-light/images/checkmark.jpg" /></a>
 		 #else
-		 	<a href="showProgramStageSection.action?programId=$programId&programStageId=$programStageInstance.getProgramStage().getId()&programStageInstanceId=$programStageInstance.getId()&patientId=$patient.getId()&programInstanceId=$programStageInstance.getProgramInstance().getId()&orgUnitId=0">
+		 	<a href="showProgramStageSection.action?programId=$programId&programStageId=$programStageInstance.getProgramStage().getId()&programStageInstanceId=$programStageInstance.getId()&patientId=$patient.getId()&programInstanceId=$programStageInstance.getProgramInstance().getId()&orgUnitId=0&validated=false">
 		 	$programStageInstance.getProgramStage().getName() (${dateFormat.format( $programStageInstance.dueDate)})</a>
 		 #end
 	</li>

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/selectProgramStageSection.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/selectProgramStageSection.vm	2012-10-12 09:22:44 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/selectProgramStageSection.vm	2012-10-23 07:56:15 +0000
@@ -5,6 +5,15 @@
     </p>
 </div>
 
+#if( $validated == true )
+<div class="header-box" align="center">
+    <h3 style="text-align: left; background-color: #719953; border-color: #719953; color: white;">$i18n.getString( "saved_section" )</h3>
+    <p style="text-align: left;">
+        $sectionName
+    </p>
+</div>
+#end
+
 <h2>$i18n.getString( "sections" )</h2>
 <div>
 	<ul>
@@ -25,6 +34,12 @@
 <div id="footer">
 <h2>$i18n.getString( "navigate_to" )</h2>
 <ul>
+	#if($orgUnitId == 0)
+		<li><a href="showPatientProgramStageList.action?patientId=$patientId&programInstanceId=$programInstanceId&programId=$programId&validated=false">$!encoder.htmlEncode( ${program.getName()} )</a></li>
+	#else
+		<li><a href="selectActivity.action?organisationUnitId=$orgUnitId&patientId=$patientId&current=$current"> $i18n.getString("activity_list")</a></li>
+	#end
+	<li><a href="showPatientProgramList.action?patientId=$patientId">$!encoder.htmlEncode( ${patient.getFullName()} )</a></li>
 	<li><a href="index.action">$i18n.getString("home")</a></li>
 </ul>
 </div>
\ No newline at end of file