← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8248: Make an optional for generating a program-stage-instance based on enrollment-date.

 

------------------------------------------------------------
revno: 8248
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-09-25 12:18:34 +0700
message:
  Make an optional for generating a program-stage-instance based on enrollment-date.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.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/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-09-22 12:23:40 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2012-09-25 05:18:34 +0000
@@ -87,6 +87,8 @@
     private Boolean displayProvidedOtherFacility;
 
     private Boolean displayIncidentDate;
+    
+    private Boolean generatedByEnrollmentDate;
 
     private List<PatientIdentifierType> patientIdentifierTypes;
 
@@ -344,6 +346,16 @@
         return Patient.class.getMethod( "get" + property ).invoke( patient );
     }
 
+    public Boolean getGeneratedByEnrollmentDate()
+    {
+        return generatedByEnrollmentDate;
+    }
+
+    public void setGeneratedByEnrollmentDate( Boolean generatedByEnrollmentDate )
+    {
+        this.generatedByEnrollmentDate = generatedByEnrollmentDate;
+    }
+
     public boolean isSingleEvent()
     {
         return type != null && (SINGLE_EVENT_WITH_REGISTRATION == type || SINGLE_EVENT_WITHOUT_REGISTRATION == type);

=== 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-25 03:50:14 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2012-09-25 05:18:34 +0000
@@ -131,6 +131,8 @@
         executeSql( "CREATE INDEX programstageinstance_executiondate ON programstageinstance (executiondate)" );
         
         executeSql( "UPDATE programstage SET autoGenerateEvent=true WHERE autoGenerateEvent is null" );
+        
+        executeSql( "UPDATE program SET generatedByEnrollmentDate=false WHERE generatedByEnrollmentDate is null" );
     }
 
     // -------------------------------------------------------------------------

=== 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-09-22 12:23:40 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml	2012-09-25 05:18:34 +0000
@@ -58,6 +58,8 @@
 		<many-to-many column="patientattributeid" class="org.hisp.dhis.patient.PatientAttribute" 
 			foreign-key="fk_program_patientAttributes_patientattributeid" />
 	</list>
-        
+    
+    <property name="generatedByEnrollmentDate" />
+    
   </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-09-25 03:50:14 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java	2012-09-25 05:18:34 +0000
@@ -178,6 +178,11 @@
             patient.getPrograms().add( program );
             patientService.updatePatient( patient );
 
+            Date dateCreatedEvent = format.parseDate( dateOfIncident );
+            if( program.getGeneratedByEnrollmentDate())
+            {
+                dateCreatedEvent = format.parseDate( enrollmentDate );
+            }
             boolean isFirstStage = false;
             for ( ProgramStage programStage : program.getProgramStages() )
             {
@@ -186,7 +191,7 @@
                     ProgramStageInstance programStageInstance = new ProgramStageInstance();
                     programStageInstance.setProgramInstance( programInstance );
                     programStageInstance.setProgramStage( programStage );
-                    Date dueDate = DateUtils.getDateAfterAddition( format.parseDate( dateOfIncident ),
+                    Date dueDate = DateUtils.getDateAfterAddition( dateCreatedEvent,
                         programStage.getMinDaysFromStart() );
 
                     programStageInstance.setDueDate( dueDate );

=== 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-09-17 06:40:26 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgram.vm	2012-09-25 05:18:34 +0000
@@ -6,6 +6,7 @@
 	"type": "$!program.type",
 	"displayProvidedOtherFacility": "$!program.displayProvidedOtherFacility",
 	"displayIncidentDate": "$!program.displayIncidentDate",
+	"generatedByEnrollmentDate": "$!program.generatedByEnrollmentDate",
 	"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-09-22 12:23:40 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java	2012-09-25 05:18:34 +0000
@@ -53,6 +53,7 @@
     implements Action
 {
     private static String SINGLE_EVENT = "Single-Event";
+
     private static String REPORT_DATE_DESCRIPTION = "Report date";
 
     // -------------------------------------------------------------------------
@@ -168,6 +169,13 @@
         this.personDisplayNames = personDisplayNames;
     }
 
+    private Boolean generateBydEnrollmentDate;
+
+    public void setGeneratedByEnrollmentDate( Boolean generateBydEnrollmentDate )
+    {
+        this.generateBydEnrollmentDate = generateBydEnrollmentDate;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -177,7 +185,8 @@
     {
         displayProvidedOtherFacility = (displayProvidedOtherFacility == null) ? false : displayProvidedOtherFacility;
         displayIncidentDate = (displayIncidentDate == null) ? false : displayIncidentDate;
-
+        generateBydEnrollmentDate= (generateBydEnrollmentDate == null) ? false : generateBydEnrollmentDate;
+        
         Program program = new Program();
 
         program.setName( name );
@@ -189,6 +198,7 @@
         program.setType( type );
         program.setDisplayProvidedOtherFacility( displayProvidedOtherFacility );
         program.setDisplayIncidentDate( displayIncidentDate );
+        program.setGeneratedByEnrollmentDate( generateBydEnrollmentDate );
 
         List<PatientIdentifierType> identifierTypes = new ArrayList<PatientIdentifierType>();
         List<PatientAttribute> patientAttributes = new ArrayList<PatientAttribute>();

=== 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-09-22 12:23:40 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java	2012-09-25 05:18:34 +0000
@@ -157,14 +157,21 @@
     {
         this.selectedPropertyIds = selectedPropertyIds;
     }
-    
+
     private List<Boolean> personDisplayNames = new ArrayList<Boolean>();
 
     public void setPersonDisplayNames( List<Boolean> personDisplayNames )
     {
         this.personDisplayNames = personDisplayNames;
     }
-    
+
+    private Boolean generateBydEnrollmentDate;
+
+    public void setGeneratedByEnrollmentDate( Boolean generateBydEnrollmentDate )
+    {
+        this.generateBydEnrollmentDate = generateBydEnrollmentDate;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -174,7 +181,8 @@
     {
         displayProvidedOtherFacility = (displayProvidedOtherFacility == null) ? false : displayProvidedOtherFacility;
         displayIncidentDate = (displayIncidentDate == null) ? false : displayIncidentDate;
-        
+        generateBydEnrollmentDate = (generateBydEnrollmentDate == null) ? false : generateBydEnrollmentDate;
+
         Program program = programService.getProgram( id );
         program.setName( name );
         program.setDescription( description );
@@ -184,35 +192,38 @@
         program.setMaxDaysAllowedInputData( maxDaysAllowedInputData );
         program.setType( type );
         program.setDisplayProvidedOtherFacility( displayProvidedOtherFacility );
-        program.setDisplayIncidentDate(displayIncidentDate);
+        program.setDisplayIncidentDate( displayIncidentDate );
+        program.setGeneratedByEnrollmentDate( generateBydEnrollmentDate );
 
         List<PatientIdentifierType> identifierTypes = new ArrayList<PatientIdentifierType>();
         List<PatientAttribute> patientAttributes = new ArrayList<PatientAttribute>();
         int index = 0;
-        for( String selectedPropertyId : selectedPropertyIds )
+        for ( String selectedPropertyId : selectedPropertyIds )
         {
             String[] ids = selectedPropertyId.split( "_" );
-            
-            if( ids[0].equals( Patient.PREFIX_IDENTIFIER_TYPE ))
+
+            if ( ids[0].equals( Patient.PREFIX_IDENTIFIER_TYPE ) )
             {
-                PatientIdentifierType identifierType = patientIdentifierTypeService.getPatientIdentifierType( Integer.parseInt( ids[1] ));
-                
+                PatientIdentifierType identifierType = patientIdentifierTypeService.getPatientIdentifierType( Integer
+                    .parseInt( ids[1] ) );
+
                 identifierType.setPersonDisplayName( personDisplayNames.get( index ) );
                 patientIdentifierTypeService.updatePatientIdentifierType( identifierType );
-                
+
                 identifierTypes.add( identifierType );
             }
-            else if( ids[0].equals( Patient.PREFIX_PATIENT_ATTRIBUTE ))
+            else if ( ids[0].equals( Patient.PREFIX_PATIENT_ATTRIBUTE ) )
             {
-                PatientAttribute patientAttribute = patientAttributeService.getPatientAttribute( Integer.parseInt( ids[1] ));
+                PatientAttribute patientAttribute = patientAttributeService.getPatientAttribute( Integer
+                    .parseInt( ids[1] ) );
                 patientAttributes.add( patientAttribute );
             }
             index++;
         }
-        
+
         program.setPatientIdentifierTypes( identifierTypes );
         program.setPatientAttributes( patientAttributes );
-        
+
         programService.updateProgram( program );
 
         return SUCCESS;

=== 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-25 03:50:14 +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 05:18:34 +0000
@@ -297,4 +297,5 @@
 remove_reminder = Remove reminder
 add_more = Add more ...
 inherit = Inherit
-auto_generate_event = Auto-generate event
\ No newline at end of file
+auto_generate_event = Auto-generate event
+generated_by_enrollment_date = Generated by enrollment date
\ 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-09-22 12:23:40 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm	2012-09-25 05:18:34 +0000
@@ -50,6 +50,12 @@
 		</tr>
 		
 		<tr>
+			<td><label>$i18n.getString( "generated_by_enrollment_date" )</label></td>
+			<td><input style="margin: 0;"type="checkbox" id="generatedByEnrollmentDate" name="generatedByEnrollmentDate" value='true'></td>
+			<td></td>
+		</tr>
+		
+		<tr>
 			<td><label>$i18n.getString( "date_of_enrollment_description" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
 			<td><input style="width: 330px;" type="text" id="dateOfEnrollmentDescription" name="dateOfEnrollmentDescription" class="{validate:{required:true,minlength:4}}"></td>
 			<td></td>

=== 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-09-22 12:23:40 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/program.js	2012-09-25 05:18:34 +0000
@@ -23,6 +23,9 @@
 		var displayIncidentDate = ( json.program.displayIncidentDate == 'true') ? i18n_yes : i18n_no;
 		setInnerHTML( 'displayIncidentDateField', displayIncidentDate );   	
 		
+		var generatedByEnrollmentDate = ( json.program.generatedByEnrollmentDate == 'true') ? i18n_yes : i18n_no;
+		setInnerHTML( 'generatedByEnrollmentDateField', generatedByEnrollmentDate );   	
+		
 		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-09-17 06:40:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programList.vm	2012-09-25 05:18:34 +0000
@@ -52,6 +52,7 @@
 				<p><label class="bold">$i18n.getString( "type" ):</label><br><span id="typeField"></span></p>				
 				<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( "generated_by_enrollment_date" ):</label><br><span id="generatedByEnrollmentDateField"></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( "stage_in_program" ):</label><br><span id="programStageCountField"></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-09-22 12:23:40 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm	2012-09-25 05:18:34 +0000
@@ -50,6 +50,12 @@
 		</tr>
 
 		<tr>
+			<td><label>$i18n.getString( "generated_by_enrollment_date" )</label></td>
+			<td><input style="margin: 0;"type="checkbox" id="generatedByEnrollmentDate" name="generatedByEnrollmentDate" value='true' #if($program.generatedByEnrollmentDate=='true') checked #end></td>
+			<td></td>
+		</tr>
+		
+		<tr>
 			<td><label>$i18n.getString( "version" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
 			<td><input style="width: 330px;" type="text" id="version" name="version" value="$program.version" class="{validate:{required:true,number:true}}"></td>
 			<td></td>