← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7115: [mobile] support repeatable event

 

------------------------------------------------------------
revno: 7115
committer: Long <thanhlongngo1988@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-05-31 16:37:26 +0700
message:
  [mobile] support repeatable event
modified:
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetProgramStageListAction.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/java/org/hisp/dhis/light/namebaseddataentry/action/SaveRepeatableEventAction.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/org/hisp/dhis/light/i18n_module.properties
  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/repeatableEventRegistrationForm.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/GetProgramStageListAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetProgramStageListAction.java	2012-05-26 12:31:07 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetProgramStageListAction.java	2012-05-31 09:37:26 +0000
@@ -27,7 +27,9 @@
 
 package org.hisp.dhis.light.namebaseddataentry.action;
 
+import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patient.PatientService;
@@ -155,28 +157,44 @@
     {
         this.repeatableStages = repeatableStages;
     }
+    
+    private Map<Integer, ProgramStage> exclusedRepeatableStages;
+    
+    public Map<Integer, ProgramStage> getExclusedRepeatableStages()
+    {
+        return exclusedRepeatableStages;
+    }
+
+    public void setExclusedRepeatableStages( Map<Integer, ProgramStage> exclusedRepeatableStages )
+    {
+        this.exclusedRepeatableStages = exclusedRepeatableStages;
+    }
 
     @Override
     public String execute()
         throws Exception
     {
         ProgramInstance programInstance = programInstanceService.getProgramInstance( programInstanceId );
+        exclusedRepeatableStages = new HashMap<Integer, ProgramStage>();
         patient = patientService.getPatient( patientId );
         programStageInstances = programInstance.getProgramStageInstances();
         repeatableStages = new HashSet<ProgramStage>();
+        Set<ProgramStage> programStages = programInstance.getProgram().getProgramStages();
+        
+        for (ProgramStage programStage : programStages) {
+            if (programStage.getIrregular()) {
+                repeatableStages.add( programStage );
+            }
+        }
         
         for ( ProgramStageInstance programStageInstance : programStageInstances )
         {
            ProgramStage programStage =  programStageInstance.getProgramStage();
-           if (programStage.getIrregular()) {
-               repeatableStages.add( programStage );
-           }
-           
            if (programStage.getIrregular() && !programStageInstance.isCompleted()) {
-               repeatableStages.remove(programStage);
+               exclusedRepeatableStages.put( programStage.getId(), programStage );
            }
         }
-        System.out.println("Size: " + repeatableStages.size());
+        
         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-05-26 12:31:07 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.java	2012-05-31 09:37:26 +0000
@@ -329,10 +329,10 @@
             return ERROR;
         }
 
-        if ( programStageService.getProgramStage( programStageId ).getIrregular() )
-        {
-            return REGISTER_NEXT_DUEDATE;
-        }
+//        if ( programStageService.getProgramStage( programStageId ).getIrregular() )
+//        {
+//            return REGISTER_NEXT_DUEDATE;
+//        }
 
         if ( orgUnitId != 0 )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveRepeatableEventAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveRepeatableEventAction.java	2012-05-30 08:49:09 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveRepeatableEventAction.java	2012-05-31 09:37:26 +0000
@@ -133,22 +133,57 @@
         this.currentProgramStageInstanceId = currentProgramStageInstanceId;
     }
 
+    private Integer patientId;
+
+    public Integer getPatientId()
+    {
+        return patientId;
+    }
+
+    public void setPatientId( Integer patientId )
+    {
+        this.patientId = patientId;
+    }
+
+    private Integer programId;
+
+    public Integer getProgramId()
+    {
+        return programId;
+    }
+
+    public void setProgramId( Integer programId )
+    {
+        this.programId = programId;
+    }
+
     @Override
     public String execute()
         throws Exception
     {
+
         ProgramStageInstance currentStageInstance = programStageInstanceService
             .getProgramStageInstance( currentProgramStageInstanceId );
         DateTimeFormatter sdf = ISODateTimeFormat.yearMonthDay();
         ProgramInstance programInstance = programInstanceService.getProgramInstance( programInstanceId );
         ProgramStage programStage = programStageService.getProgramStage( programStageId );
 
+        patientId = programInstance.getPatient().getId();
+        programId = programInstance.getProgram().getId();
+
         ProgramStageInstance programStageInstance = new ProgramStageInstance();
-        programStageInstance.setDueDate( sdf.parseDateTime( nextDueDate ).toDate() );
+        try
+        {
+            programStageInstance.setDueDate( sdf.parseDateTime( nextDueDate ).toDate() );
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
+
         programStageInstance.setProgramInstance( programInstance );
         programStageInstance.setProgramStage( programStage );
         programStageInstance.setStageInProgram( currentStageInstance.getStageInProgram() );
-        
         programStageInstanceService.addProgramStageInstance( programStageInstance );
         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-05-30 08:49:09 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml	2012-05-31 09:37:26 +0000
@@ -198,7 +198,9 @@
 			ref="org.hisp.dhis.dataelement.DataElementService"/>
 		<property name="util" ref="org.hisp.dhis.light.utils.NamebasedUtils"/>
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService"/>
-		<property name="dataElementCategoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService"/>
+		<property name="dataElementCategoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService"/>
+		<property name="programStageService"
+			ref="org.hisp.dhis.program.ProgramStageService"/>
 	</bean>
 	
 	<bean

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties	2012-05-30 07:22:33 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties	2012-05-31 09:37:26 +0000
@@ -81,4 +81,5 @@
 all_orgunit=All Organisation Unit
 tracking_menu=Tracking Menu
 due_date=Due Date
-register_due_date_for=Register Due Date For
\ No newline at end of file
+register_due_date_for=Register Due Date For
+register=Register
\ No newline at end of file

=== 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-05-26 12:31:07 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml	2012-05-31 09:37:26 +0000
@@ -188,6 +188,11 @@
 				/dhis-web-light/main.vm</result>
 			<param name="page">
 				/dhis-web-light/namebased/repeatableEventRegistrationForm.vm</param>
+		</action>
+		
+		<action name="saveRepeatableEvent"
+			class="org.hisp.dhis.light.namebaseddataentry.action.SaveRepeatableEventAction">
+			<result name="success" type="redirect">showPatientProgramStageList.action?patientId=${patientId}&amp;programInstanceId=${programInstanceId}&amp;programId=${programId}&amp;validated=false</result>
 		</action>
 		
 		<!-- Beneficiary Registration -->

=== 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-05-30 08:49:09 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/beneficiaryProgramStageList.vm	2012-05-31 09:37:26 +0000
@@ -29,7 +29,10 @@
 #end
 <br/>
 #foreach($programStage in $repeatableStages)
-	<li><a href="showRepeatableEventRegistrationForm.action?programInstanceId=$programInstanceId&programStageId=$programStage.getId()&currentProgramStageInstanceId=$currentProgramStageInstanceId">[+] $i18n.getString("add") $programStage.getName()</a></li>
+	#set($exclusedStage = $exclusedRepeatableStages.get( $programStage.getId() ))
+	#if(!$exclusedStage)
+		<li><a href="showRepeatableEventRegistrationForm.action?programInstanceId=$programInstanceId&programStageId=$programStage.getId()&currentProgramStageInstanceId=$currentProgramStageInstanceId">[+] $i18n.getString("add") $programStage.getName()</a></li>
+	#end
 #end
 
 </ul>

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/repeatableEventRegistrationForm.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/repeatableEventRegistrationForm.vm	2012-05-30 08:49:09 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/repeatableEventRegistrationForm.vm	2012-05-31 09:37:26 +0000
@@ -9,7 +9,7 @@
 		#if( $validationMap.get( "enrollmentDate" ) )
            	<br /><span style="color: #990000;"> $i18n.getString($validationMap.get( "dueDate" ))</span>
      	#end
-		<input type="text" name="enrollmentDate" value="$!previousValues.get("dueDate")" />
+		<input type="text" name="nextDueDate" value="$!previousValues.get("dueDate")" />
 	</p>
 </div>