← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8245: Make automatic scheduling optional for specifying a program-stage is auto-generate or not.

 

------------------------------------------------------------
revno: 8245
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-09-25 10:50:14 +0700
message:
  Make automatic scheduling optional for specifying a program-stage is auto-generate or not.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.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/jsonProgramStage.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageAction.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/addProgramStageForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageList.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.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/ProgramStage.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java	2012-09-18 08:31:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java	2012-09-25 03:50:14 +0000
@@ -77,6 +77,8 @@
     
     private Set<PatientReminder> patientReminders = new HashSet<PatientReminder>();
     
+    private Boolean autoGenerateEvent = true;
+    
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
@@ -244,6 +246,16 @@
     {
         this.reportDateDescription = reportDateDescription;
     }
+    
+    public Boolean getAutoGenerateEvent()
+    {
+        return autoGenerateEvent;
+    }
+
+    public void setAutoGenerateEvent( Boolean autoGenerateEvent )
+    {
+        this.autoGenerateEvent = autoGenerateEvent;
+    }
 
     public String getDataEntryType()
     {

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2012-09-14 12:53:55 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2012-09-25 03:50:14 +0000
@@ -129,6 +129,8 @@
         executeSql( "UPDATE programstage SET reportDateDescription='Report date' WHERE reportDateDescription is null" );
         
         executeSql( "CREATE INDEX programstageinstance_executiondate ON programstageinstance (executiondate)" );
+        
+        executeSql( "UPDATE programstage SET autoGenerateEvent=true WHERE autoGenerateEvent is null" );
     }
 
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml	2012-09-18 08:31:07 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml	2012-09-25 03:50:14 +0000
@@ -46,5 +46,7 @@
       <one-to-many class="org.hisp.dhis.patient.PatientReminder" />
     </set>
     
+    <property name="autoGenerateEvent"/>
+    
   </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-08-28 05:48:46 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java	2012-09-25 03:50:14 +0000
@@ -111,7 +111,7 @@
     {
         this.programId = programId;
     }
-    
+
     private String enrollmentDate;
 
     public void setEnrollmentDate( String enrollmentDate )
@@ -127,14 +127,14 @@
     }
 
     private ProgramInstance programInstance;
-    
+
     public ProgramInstance getProgramInstance()
     {
         return programInstance;
     }
 
     private ProgramStageInstance activeProgramStageInstance;
-    
+
     public ProgramStageInstance getActiveProgramStageInstance()
     {
         return activeProgramStageInstance;
@@ -181,20 +181,23 @@
             boolean isFirstStage = false;
             for ( ProgramStage programStage : program.getProgramStages() )
             {
-                ProgramStageInstance programStageInstance = new ProgramStageInstance();
-                programStageInstance.setProgramInstance( programInstance );
-                programStageInstance.setProgramStage( programStage );
-                Date dueDate = DateUtils.getDateAfterAddition( format.parseDate( dateOfIncident ),
-                    programStage.getMinDaysFromStart() );
-
-                programStageInstance.setDueDate( dueDate );
-
-                programStageInstanceService.addProgramStageInstance( programStageInstance );
-                
-                if( !isFirstStage )
+                if ( programStage.getAutoGenerateEvent() )
                 {
-                    activeProgramStageInstance = programStageInstance;
-                    isFirstStage = true;
+                    ProgramStageInstance programStageInstance = new ProgramStageInstance();
+                    programStageInstance.setProgramInstance( programInstance );
+                    programStageInstance.setProgramStage( programStage );
+                    Date dueDate = DateUtils.getDateAfterAddition( format.parseDate( dateOfIncident ),
+                        programStage.getMinDaysFromStart() );
+
+                    programStageInstance.setDueDate( dueDate );
+
+                    programStageInstanceService.addProgramStageInstance( programStageInstance );
+
+                    if ( !isFirstStage )
+                    {
+                        activeProgramStageInstance = programStageInstance;
+                        isFirstStage = true;
+                    }
                 }
             }
         }
@@ -215,7 +218,7 @@
                 programStageInstanceService.updateProgramStageInstance( programStageInstance );
             }
         }
-        
+
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgramStage.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgramStage.vm	2012-09-17 06:40:26 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgramStage.vm	2012-09-25 03:50:14 +0000
@@ -10,6 +10,8 @@
 	"reportDateDescription": "$!encoder.jsonEncode( ${programStage.reportDateDescription} )",
 	"daysAllowedSendMessage": "$!programStage.daysAllowedSendMessage",
 	"templateMessage": "$!encoder.jsonEncode( ${programStage.templateMessage} )",
+	"irregular": "$!programStage.irregular",
+	"autoGenerateEvent": "$!programStage.autoGenerateEvent",
 	
 	#set( $size = ${programStageDataElements.size()} )
 	"dataElement": [

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java	2012-09-18 08:31:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java	2012-09-25 03:50:14 +0000
@@ -177,6 +177,13 @@
         this.templateMessages = templateMessages;
     }
 
+    private Boolean autoGenerateEvent;
+
+    public void setAutoGenerateEvent( Boolean autoGenerateEvent )
+    {
+        this.autoGenerateEvent = autoGenerateEvent;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -184,12 +191,11 @@
     public String execute()
         throws Exception
     {
-
         minDaysFromStart = (minDaysFromStart == null) ? 0 : minDaysFromStart;
         irregular = (irregular == null) ? false : irregular;
+        autoGenerateEvent = (autoGenerateEvent == null) ? false : autoGenerateEvent;
         
         ProgramStage programStage = new ProgramStage();
-
         Program program = programService.getProgram( id );
 
         programStage.setName( name );
@@ -200,15 +206,17 @@
         programStage.setReportDateDescription( reportDateDescription );
         programStage.setIrregular( irregular );
         programStage.setMinDaysFromStart( minDaysFromStart );
+        programStage.setAutoGenerateEvent( autoGenerateEvent );
         
         Set<PatientReminder> patientReminders = new HashSet<PatientReminder>();
         for ( int i = 0; i < daysAllowedSendMessages.size(); i++ )
         {
-            PatientReminder reminder = new PatientReminder( "", daysAllowedSendMessages.get( i ), templateMessages.get( i ));
+            PatientReminder reminder = new PatientReminder( "", daysAllowedSendMessages.get( i ),
+                templateMessages.get( i ) );
             patientReminders.add( reminder );
         }
         programStage.setPatientReminders( patientReminders );
-        
+
         programStageService.saveProgramStage( programStage );
 
         for ( int i = 0; i < this.selectedDataElementsValidator.size(); i++ )

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageAction.java	2012-09-18 08:31:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageAction.java	2012-09-25 03:50:14 +0000
@@ -155,7 +155,7 @@
     {
         this.reportDateDescription = reportDateDescription;
     }
-    
+
     private List<Integer> daysAllowedSendMessages = new ArrayList<Integer>();
 
     public void setDaysAllowedSendMessages( List<Integer> daysAllowedSendMessages )
@@ -169,7 +169,14 @@
     {
         this.templateMessages = templateMessages;
     }
-    
+
+    private Boolean autoGenerateEvent;
+
+    public void setAutoGenerateEvent( Boolean autoGenerateEvent )
+    {
+        this.autoGenerateEvent = autoGenerateEvent;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -179,7 +186,8 @@
     {
         minDaysFromStart = (minDaysFromStart == null) ? 0 : minDaysFromStart;
         irregular = (irregular == null) ? false : irregular;
-        
+        autoGenerateEvent = (autoGenerateEvent == null) ? false : autoGenerateEvent;
+
         ProgramStage programStage = programStageService.getProgramStage( id );
 
         programStage.setName( name );
@@ -188,11 +196,13 @@
         programStage.setReportDateDescription( reportDateDescription );
         programStage.setMinDaysFromStart( minDaysFromStart );
         programStage.setIrregular( irregular );
-        
+        programStage.setAutoGenerateEvent( autoGenerateEvent );
+
         Set<PatientReminder> patientReminders = new HashSet<PatientReminder>();
         for ( int i = 0; i < this.daysAllowedSendMessages.size(); i++ )
         {
-            PatientReminder reminder = new PatientReminder( "", daysAllowedSendMessages.get( i ), templateMessages.get( i ));
+            PatientReminder reminder = new PatientReminder( "", daysAllowedSendMessages.get( i ),
+                templateMessages.get( i ) );
             patientReminders.add( reminder );
         }
         programStage.setPatientReminders( patientReminders );

=== 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-09-23 09:30:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-09-25 03:50:14 +0000
@@ -296,4 +296,5 @@
 define_template_message = Define template message
 remove_reminder = Remove reminder
 add_more = Add more ...
-inherit = Inherit
\ No newline at end of file
+inherit = Inherit
+auto_generate_event = Auto-generate event
\ 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/addProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm	2012-09-18 08:31:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm	2012-09-25 03:50:14 +0000
@@ -27,6 +27,11 @@
 	</tr>
 
 	<tr>
+		<td><label>$i18n.getString( "auto_generate_event" )</label></td>
+		<td><input type="checkbox" id="autoGenerateEvent" name="autoGenerateEvent" value='true' checked /></td>
+	</tr>	
+	
+	<tr>
 		<td><label>$i18n.getString( "repeatable" )</label></td>
 		<td><input type="checkbox" id="irregular" name="irregular" value='true' onchange='repeatableOnChange();' /></td>
 	</tr>	
@@ -99,33 +104,6 @@
 
 <table>
 	<tbody id='programStageMessage'>
-		<tr name="tr1">
-			<td colspan='2'>
-				$i18n.getString( "reminder" ) 1
-				<span style="align:right"><a href='javascript:removeTemplateMessageForm(1)'> ( $i18n.getString("remove_reminder") )</a>
-			</td>
-		</tr>
-		<tr name="tr1">
-			<td><label>$i18n.getString( "days_before_after_due_date" )</label></td>
-			<td><input type="text" id="daysAllowedSendMessage1" name="daysAllowedSendMessage" class="daysAllowedSendMessage {validate:{required:true,number:true}}"/></td>
-		</tr>
-		<tr name="tr1">
-			<td>$i18n.getString( "params" )</td>
-			<td>
-				<select multiple size='4' ondblclick="insertParams(this.value, 1);">
-					<option value="{patient-name}">$i18n.getString("patient_name")</option>
-					<option value="{program-name}">$i18n.getString("program_name")</option>
-					<option value="{program-stage-name}">$i18n.getString("program_stage_name")</option>
-					<option value="{due-date}">$i18n.getString("due_date")</option>
-					<option value="{days-since-due-date}">$i18n.getString("days_since_due_date")</option>
-					<option value="{orgunit-name}">$i18n.getString("orgunit_name")</option>
-				</select>
-			</td>
-		</tr>
-		<tr name="tr1">
-			<td><label>$i18n.getString( "template_message" )</label></td>
-			<td><textarea id="templateMessage1" name="templateMessage1" style="width:320px" class="templateMessage {validate:{required:true}}"></textarea></td>
-		</tr>
 	</tbody>
 	<tr>
 		<td></td>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js	2012-09-18 08:31:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js	2012-09-25 03:50:14 +0000
@@ -59,6 +59,10 @@
 
 		var irregular = (json.programStage.irregular=='true') ? i18n_yes : i18n_no;
 		setInnerHTML( 'irregularField', irregular );  
+		
+		var autoGenerateEvent = (json.programStage.autoGenerateEvent=='true') ? i18n_yes : i18n_no;
+		setInnerHTML( 'autoGenerateEventField', autoGenerateEvent );  
+		
 		setInnerHTML( 'standardIntervalField', json.programStage.standardInterval );  
 		setInnerHTML( 'dataElementCountField', json.programStage.dataElementCount );   
 		setInnerHTML( 'reportDateDescriptionField', json.programStage.reportDateDescription );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageList.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageList.vm	2012-09-17 06:40:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageList.vm	2012-09-25 03:50:14 +0000
@@ -45,6 +45,7 @@
 				<p><label class="bold">$i18n.getString( "description" ):</label><br><span id="descriptionField"></span></p>				
 				<p><label class="bold">$i18n.getString( "stage_in_program" ):</label><br><span id="stageInProgramField"></span></p>
 				<p><label class="bold">$i18n.getString( "scheduled_days_from_start" ):</label><br><span id="scheduledDaysFromStartField"></span></p>
+				<p><label class="bold">$i18n.getString( "auto_generate_event" ):</label><br><span id="autoGenerateEventField"></span></p>
 				<p><label class="bold">$i18n.getString( "irregular" ):</label><br><span id="irregularField"></span></p>
 				<p><label class="bold">$i18n.getString( "standard_interval_days" ):</label><br><span id="standardIntervalField"></span></p>
 				<p><label class="bold">$i18n.getString( "report_date_description" ):</label><br><span id="reportDateDescriptionField"></span></p>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm	2012-09-18 08:31:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm	2012-09-25 03:50:14 +0000
@@ -27,6 +27,11 @@
 				<td><input type="text" id="minDaysFromStart" name="minDaysFromStart" value="$programStage.minDaysFromStart" class="{validate:{number:true,min:0}}"/></td>
 			</tr>
 			
+			<tr>
+				<td><label>$i18n.getString( "auto_generate_event" )</label></td>
+				<td><input type="checkbox" id="autoGenerateEvent" name="autoGenerateEvent" value='true' #if( $programStage.autoGenerateEvent && $programStage.autoGenerateEvent=='true' ) checked #end /></td>
+			</tr>	
+	
 			#if($programStage.program.type!=3)
 			<tr>
 				<td><label>$i18n.getString( "repeatable" )</label></td>