← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10244: check the blocking entry and only enroll once property

 

------------------------------------------------------------
revno: 10244
committer: Long <Long@Long-Laptop>
branch nick: dhis2
timestamp: Fri 2013-03-15 15:55:20 +0700
message:
  check the blocking entry and only enroll once property
modified:
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetPatientProgramListAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetProgramStageSectionAction.java


--
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/GetPatientProgramListAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetPatientProgramListAction.java	2013-01-28 09:42:58 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetPatientProgramListAction.java	2013-03-15 08:55:20 +0000
@@ -31,6 +31,7 @@
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -307,7 +308,12 @@
         {
             if ( (program.isSingleEvent() && program.isRegistration()) || !program.isSingleEvent() )
             {
-                if ( programInstanceService.getProgramInstances( patient, program ).size() == 0 )
+                if ( programInstanceService.getProgramInstances( patient, program, false ).size() == 0 )
+                {
+                    programs.add( program );
+                }
+                else if ( programInstanceService.getProgramInstances( patient, program, true ).size() > 0
+                    && !program.getOnlyEnrollOnce() )
                 {
                     programs.add( program );
                 }

=== 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-12-04 12:58:11 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetProgramStageSectionAction.java	2013-03-15 08:55:20 +0000
@@ -47,39 +47,41 @@
 
 /**
  * @author Nguyen Kim Lai
- *
+ * 
  * @version $ GetProgramStageSectionAction.java Oct 10, 2012 $
  */
-public class GetProgramStageSectionAction implements Action
+public class GetProgramStageSectionAction
+    implements Action
 {
     private static final String REDIRECT = "redirect";
+
     private static final String REDIRECT_COMPLETED_FORM = "redirectCompletedForm";
-    
+
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
-    
+
     private NamebasedUtils util;
-    
+
     public void setUtil( NamebasedUtils util )
     {
         this.util = util;
     }
-    
+
     private PatientService patientService;
 
     public void setPatientService( PatientService patientService )
     {
         this.patientService = patientService;
     }
-    
+
     private ProgramStageInstanceService programStageInstanceService;
 
     public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
     {
         this.programStageInstanceService = programStageInstanceService;
     }
-    
+
     private ProgramService programService;
 
     public void setProgramService( ProgramService programService )
@@ -102,7 +104,7 @@
     {
         this.programInstanceId = programInstanceId;
     }
-    
+
     private Integer programStageInstanceId;
 
     public Integer getProgramStageInstanceId()
@@ -114,7 +116,7 @@
     {
         this.programStageInstanceId = programStageInstanceId;
     }
-    
+
     private Integer patientId;
 
     public Integer getPatientId()
@@ -126,14 +128,14 @@
     {
         this.patientId = patientId;
     }
-    
+
     private Patient patient;
-    
+
     public Patient getPatient()
     {
         return patient;
     }
-    
+
     private Integer programId;
 
     public void setProgramId( Integer programId )
@@ -145,7 +147,7 @@
     {
         return programId;
     }
-    
+
     private Integer programStageId;
 
     public void setProgramStageId( Integer programStageId )
@@ -157,7 +159,7 @@
     {
         return programStageId;
     }
-    
+
     private Integer orgUnitId;
 
     public void setOrgUnitId( Integer orgUnitId )
@@ -169,16 +171,16 @@
     {
         return this.orgUnitId;
     }
-    
+
     private ProgramStage programStage;
 
     public ProgramStage getProgramStage()
     {
         return this.programStage;
     }
-    
+
     private List<ProgramStageSection> listOfProgramStageSections;
-    
+
     public List<ProgramStageSection> getListOfProgramStageSections()
     {
         return listOfProgramStageSections;
@@ -190,26 +192,26 @@
     {
         return listOfProgramStageDataElement;
     }
-    
+
     public DateFormat getDateFormat()
     {
         return new SimpleDateFormat( "yyyy-MM-dd" );
     }
-    
+
     public ProgramStageInstance programStageInstance;
-    
+
     public ProgramStageInstance getProgramStageInstance()
     {
         return programStageInstance;
     }
-    
+
     private Program program;
 
     public Program getProgram()
     {
         return this.program;
     }
-    
+
     private boolean validated;
 
     public boolean isValidated()
@@ -221,16 +223,16 @@
     {
         this.validated = validated;
     }
-    
+
     public String sectionName;
 
     public String getSectionName()
     {
         return sectionName;
     }
-    
+
     public Integer programStageSectionId;
-    
+
     public void setProgramStageSectionId( Integer programStageSectionId )
     {
         this.programStageSectionId = programStageSectionId;
@@ -239,39 +241,39 @@
     @Override
     public String execute()
         throws Exception
-    {   
-        
+    {
+
         program = programService.getProgram( programId );
-        
+
         programStageInstance = programStageInstanceService.getProgramStageInstance( programStageInstanceId );
-        
+
         patient = patientService.getPatient( patientId );
-        
+
         programStage = util.getProgramStage( programId, programStageId );
-        
-        this.listOfProgramStageSections = new ArrayList<ProgramStageSection>(programStage.getProgramStageSections());
-        
-        if ( programStageSectionId != null && programStageSectionId != 0)
+
+        this.listOfProgramStageSections = new ArrayList<ProgramStageSection>( programStage.getProgramStageSections() );
+
+        if ( programStageSectionId != null && programStageSectionId != 0 )
         {
-            for ( ProgramStageSection each: this.listOfProgramStageSections )
+            for ( ProgramStageSection each : this.listOfProgramStageSections )
             {
                 if ( each.getId() == programStageSectionId )
                 {
                     sectionName = each.getName();
-
                     break;
                 }
             }
         }
-        
-        if( this.listOfProgramStageSections.size() == 0 && programStageInstance.isCompleted() == false)
+
+        if ( this.listOfProgramStageSections.size() == 0 && programStageInstance.isCompleted() == true
+            && programStage.getProgram().getBlockEntryForm() )
+        {
+            return REDIRECT_COMPLETED_FORM;
+        }
+        else if ( this.listOfProgramStageSections.size() == 0 )
         {
             return REDIRECT;
         }
-        else if( this.listOfProgramStageSections.size() == 0 && programStageInstance.isCompleted() == true )
-        {
-            return REDIRECT_COMPLETED_FORM;
-        }
 
         return SUCCESS;
     }