← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9250: Add option in Add/Update program form to ignore generating overdue events.

 

------------------------------------------------------------
revno: 9250
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-12-10 11:03:33 +0700
message:
  Add option in Add/Update program form to ignore generating overdue events.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgram.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programList.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.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-api/src/main/java/org/hisp/dhis/program/Program.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2012-10-03 03:46:16 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2012-12-10 04:03:33 +0000
@@ -88,10 +88,12 @@
     
     private Boolean generatedByEnrollmentDate;
 
+    private Boolean ignoreOverdueEvents;
+
     private List<PatientIdentifierType> patientIdentifierTypes;
 
     private List<PatientAttribute> patientAttributes;
-
+    
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
@@ -343,6 +345,16 @@
     {
         this.generatedByEnrollmentDate = generatedByEnrollmentDate;
     }
+    
+    public Boolean getIgnoreOverdueEvents()
+    {
+        return ignoreOverdueEvents;
+    }
+
+    public void setIgnoreOverdueEvents( Boolean ignoreOverdueEvents )
+    {
+        this.ignoreOverdueEvents = ignoreOverdueEvents;
+    }
 
     public boolean isSingleEvent()
     {

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml	2012-10-03 03:46:16 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml	2012-12-10 04:03:33 +0000
@@ -59,5 +59,7 @@
     
     <property name="generatedByEnrollmentDate" />
     
+    <property name="ignoreOverdueEvents" />
+    
   </class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java	2012-10-31 04:09:25 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java	2012-12-10 04:03:33 +0000
@@ -163,7 +163,7 @@
         {
             programInstance = programInstances.iterator().next();
         }
-        
+
         if ( programInstance == null )
         {
             programInstance = new ProgramInstance();
@@ -183,30 +183,34 @@
             {
                 dateCreatedEvent = format.parseDate( enrollmentDate );
             }
-            
+
             boolean isFirstStage = false;
+            Date currentDate = new Date();
             for ( ProgramStage programStage : program.getProgramStages() )
             {
                 if ( programStage.getAutoGenerateEvent() )
                 {
-                    ProgramStageInstance programStageInstance = new ProgramStageInstance();
-                    programStageInstance.setProgramInstance( programInstance );
-                    programStageInstance.setProgramStage( programStage );
                     Date dueDate = DateUtils
                         .getDateAfterAddition( dateCreatedEvent, programStage.getMinDaysFromStart() );
 
-                    programStageInstance.setDueDate( dueDate );
-
-                    if( program.isSingleEvent())
-                    {
-                        programStageInstance.setExecutionDate( dueDate );
-                    }
-                    programStageInstanceService.addProgramStageInstance( programStageInstance );
-
-                    if ( !isFirstStage )
-                    {
-                        activeProgramStageInstance = programStageInstance;
-                        isFirstStage = true;
+                    if ( !program.getIgnoreOverdueEvents() || !dueDate.before( currentDate ) )
+                    {
+                        ProgramStageInstance programStageInstance = new ProgramStageInstance();
+                        programStageInstance.setProgramInstance( programInstance );
+                        programStageInstance.setProgramStage( programStage );
+                        programStageInstance.setDueDate( dueDate );
+
+                        if ( program.isSingleEvent() )
+                        {
+                            programStageInstance.setExecutionDate( dueDate );
+                        }
+                        programStageInstanceService.addProgramStageInstance( programStageInstance );
+
+                        if ( !isFirstStage )
+                        {
+                            activeProgramStageInstance = programStageInstance;
+                            isFirstStage = true;
+                        }
                     }
                 }
             }

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgram.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgram.vm	2012-10-03 03:46:16 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgram.vm	2012-12-10 04:03:33 +0000
@@ -7,6 +7,7 @@
 	"displayProvidedOtherFacility": "$!program.displayProvidedOtherFacility",
 	"displayIncidentDate": "$!program.displayIncidentDate",
 	"generatedByEnrollmentDate": "$!program.generatedByEnrollmentDate",
+	"ignoreOverdueEvents": "$!program.ignoreOverdueEvents",
 	"dateOfEnrollmentDescription": "$!encoder.jsEncode( ${program.dateOfEnrollmentDescription} )",
 	"dateOfIncidentDescription": "$!encoder.jsEncode( ${program.dateOfIncidentDescription} )",
 	"programStageCount": "${program.programStages.size()}",

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java	2012-10-03 03:46:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java	2012-12-10 04:03:33 +0000
@@ -169,6 +169,13 @@
         this.generateBydEnrollmentDate = generateBydEnrollmentDate;
     }
 
+    private Boolean ignoreOverdueEvents;
+
+    public void setIgnoreOverdueEvents( Boolean ignoreOverdueEvents )
+    {
+        this.ignoreOverdueEvents = ignoreOverdueEvents;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -178,8 +185,9 @@
     {
         displayProvidedOtherFacility = (displayProvidedOtherFacility == null) ? false : displayProvidedOtherFacility;
         displayIncidentDate = (displayIncidentDate == null) ? false : displayIncidentDate;
-        generateBydEnrollmentDate= (generateBydEnrollmentDate == null) ? false : generateBydEnrollmentDate;
-        
+        generateBydEnrollmentDate = (generateBydEnrollmentDate == null) ? false : generateBydEnrollmentDate;
+        ignoreOverdueEvents = (ignoreOverdueEvents == null) ? false : ignoreOverdueEvents;
+
         Program program = new Program();
 
         program.setName( name );
@@ -191,7 +199,8 @@
         program.setDisplayProvidedOtherFacility( displayProvidedOtherFacility );
         program.setDisplayIncidentDate( displayIncidentDate );
         program.setGeneratedByEnrollmentDate( generateBydEnrollmentDate );
-
+        program.setIgnoreOverdueEvents( ignoreOverdueEvents );
+        
         List<PatientIdentifierType> identifierTypes = new ArrayList<PatientIdentifierType>();
         List<PatientAttribute> patientAttributes = new ArrayList<PatientAttribute>();
         int index = 0;

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java	2012-10-03 03:46:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java	2012-12-10 04:03:33 +0000
@@ -165,6 +165,13 @@
         this.generateBydEnrollmentDate = generateBydEnrollmentDate;
     }
 
+    private Boolean ignoreOverdueEvents;
+
+    public void setIgnoreOverdueEvents( Boolean ignoreOverdueEvents )
+    {
+        this.ignoreOverdueEvents = ignoreOverdueEvents;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -175,6 +182,7 @@
         displayProvidedOtherFacility = (displayProvidedOtherFacility == null) ? false : displayProvidedOtherFacility;
         displayIncidentDate = (displayIncidentDate == null) ? false : displayIncidentDate;
         generateBydEnrollmentDate = (generateBydEnrollmentDate == null) ? false : generateBydEnrollmentDate;
+        ignoreOverdueEvents = (ignoreOverdueEvents == null) ? false : ignoreOverdueEvents;
 
         Program program = programService.getProgram( id );
         program.setName( name );
@@ -186,7 +194,8 @@
         program.setDisplayProvidedOtherFacility( displayProvidedOtherFacility );
         program.setDisplayIncidentDate( displayIncidentDate );
         program.setGeneratedByEnrollmentDate( generateBydEnrollmentDate );
-
+        program.setIgnoreOverdueEvents( ignoreOverdueEvents );
+        
         List<PatientIdentifierType> identifierTypes = new ArrayList<PatientIdentifierType>();
         List<PatientAttribute> patientAttributes = new ArrayList<PatientAttribute>();
         int index = 0;

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-11-23 08:38:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-12-10 04:03:33 +0000
@@ -321,4 +321,5 @@
 update_program_validation_rule = Edit program validation rule
 description_not_null = Description is not null
 expression_not_null = Expression is not null
-complete_allowed_only_if_validation_passes = Complete allowed only if validation passes
\ No newline at end of file
+complete_allowed_only_if_validation_passes = Complete allowed only if validation passes
+ignore_overdue_events = Ignore overdue events
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm	2012-10-30 03:46:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm	2012-12-10 04:03:33 +0000
@@ -43,6 +43,12 @@
 		</tr>
 		
 		<tr>
+			<td><label>$i18n.getString( "ignore_overdue_events" )</label></td>
+			<td><input style="margin: 0;"type="checkbox" id="ignoreOverdueEvents" name="ignoreOverdueEvents" value='true'></td>
+			<td></td>
+		</tr>
+		
+		<tr>
 			<th colspan="2">$i18n.getString( "form_details" )</th>
 		</tr>
 	

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js	2012-10-03 04:54:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js	2012-12-10 04:03:33 +0000
@@ -26,6 +26,9 @@
 		var generatedByEnrollmentDate = ( json.program.generatedByEnrollmentDate == 'true') ? i18n_yes : i18n_no;
 		setInnerHTML( 'generatedByEnrollmentDateField', generatedByEnrollmentDate );   	
 		
+		var ignoreOverdueEvents = ( json.program.ignoreOverdueEvents == 'true') ? i18n_yes : i18n_no;
+		setInnerHTML( 'ignoreOverdueEventsField', ignoreOverdueEvents );   	
+		
 		setInnerHTML( 'dateOfEnrollmentDescriptionField', json.program.dateOfEnrollmentDescription );   
 		setInnerHTML( 'dateOfIncidentDescriptionField', json.program.dateOfIncidentDescription );   		
 		setInnerHTML( 'programStageCountField',  json.program.programStageCount );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programList.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programList.vm	2012-10-18 13:27:17 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programList.vm	2012-12-10 04:03:33 +0000
@@ -49,6 +49,7 @@
 				<p><label class="bold">$i18n.getString( "display_provided_other_facility_column" ):</label><br><span id="displayProvidedOtherFacilityField"></span></p>
 				<p><label class="bold">$i18n.getString( "display_date_of_incident" ):</label><br><span id="displayIncidentDateField"></span></p>
 				<p><label class="bold">$i18n.getString( "events_generated_by_enrollment_date" ):</label><br><span id="generatedByEnrollmentDateField"></span></p>
+				<p><label class="bold">$i18n.getString( "ignore_overdue_events" ):</label><br><span id="ignoreOverdueEventsField"></span></p>
 				<p><label class="bold">$i18n.getString( "date_of_enrollment_description" ):</label><br><span id="dateOfEnrollmentDescriptionField"></span></p>				
 				<p><label class="bold">$i18n.getString( "date_of_incident_description" ):</label><br><span id="dateOfIncidentDescriptionField"></span></p>				
 				<p><label class="bold">$i18n.getString( "number_of_attributes" ):</label><br><span id="noAttributesField"></span></p>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm	2012-10-30 03:46:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm	2012-12-10 04:03:33 +0000
@@ -43,6 +43,12 @@
 		</tr>
 		
 		<tr>
+			<td><label>$i18n.getString( "ignore_overdue_events" )</label></td>
+			<td><input style="margin: 0;"type="checkbox" id="ignoreOverdueEvents" name="ignoreOverdueEvents" value='true' #if($program.ignoreOverdueEvents=='true') checked #end #if( $program.type!='1' ) disabled #end ></td>></td>
+			<td></td>
+		</tr>
+		
+		<tr>
 			<td><label>$i18n.getString( "version" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
 			<td><input type="text" id="version" name="version" value="$program.version" class="{validate:{required:true,number:true}}"></td>
 			<td></td>