dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18722
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7914: Allow to create many repeatable events of a program in single data entry form.
------------------------------------------------------------
revno: 7914
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-08-15 09:57:56 +0700
message:
Allow to create many repeatable events of a program in single data entry form.
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramInstance.hbm.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadProgramStageInstancesAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/RegisterIrregularEncounterAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataRecordingSelect.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramStageInstances.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageInstanceFlow.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css
--
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-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramInstance.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramInstance.hbm.xml 2012-05-23 19:48:53 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramInstance.hbm.xml 2012-08-15 02:57:56 +0000
@@ -24,7 +24,7 @@
<many-to-one name="program" class="org.hisp.dhis.program.Program" column="programid" not-null="true"
foreign-key="fk_programinstance_programid" />
- <set name="programStageInstances" order-by="stageinprogram" >
+ <set name="programStageInstances" order-by="duedate" >
<key column="programinstanceid" />
<one-to-many class="org.hisp.dhis.program.ProgramStageInstance" />
</set>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadProgramStageInstancesAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadProgramStageInstancesAction.java 2012-07-26 04:32:29 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadProgramStageInstancesAction.java 2012-08-15 02:57:56 +0000
@@ -103,6 +103,13 @@
{
return statusMap;
}
+
+ private ProgramInstance programInstance;
+
+ public ProgramInstance getProgramInstance()
+ {
+ return programInstance;
+ }
private List<ProgramStageInstance> programStageInstances = new ArrayList<ProgramStageInstance>();
@@ -117,7 +124,7 @@
{
return program;
}
-
+
// -------------------------------------------------------------------------
// Implementation Action
// -------------------------------------------------------------------------
@@ -130,7 +137,7 @@
Patient patient = selectedStateManager.getSelectedPatient();
- Program program = programService.getProgram( programId );
+ program = programService.getProgram( programId );
List<ProgramInstance> programInstances = new ArrayList<ProgramInstance>();
@@ -151,7 +158,7 @@
if ( programInstances != null && programInstances.size() > 0 )
{
- ProgramInstance programInstance = programInstances.iterator().next();
+ programInstance = programInstances.iterator().next();
selectedStateManager.setSelectedProgramInstance( programInstance );
@@ -159,20 +166,8 @@
{
if ( program.isRegistration() )
{
- programStageInstances.addAll( programInstance.getProgramStageInstances() );
- Collections.sort( programStageInstances, new ProgramStageInstanceDueDateComparator() );
statusMap = programStageInstanceService.statusProgramStageInstances( programInstance.getProgramStageInstances() );
}
- else
- {
- ProgramStage programStage = program.getProgramStages().iterator().next();
- ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance(
- programInstance, programStage );
- if( programStageInstance!= null )
- {
- programStageInstances.add( programStageInstance );
- }
- }
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/RegisterIrregularEncounterAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/RegisterIrregularEncounterAction.java 2012-06-07 04:23:40 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/RegisterIrregularEncounterAction.java 2012-08-15 02:57:56 +0000
@@ -27,10 +27,13 @@
package org.hisp.dhis.caseentry.action.caseentry;
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.program.ProgramInstance;
+import org.hisp.dhis.program.ProgramInstanceService;
+import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageInstance;
import org.hisp.dhis.program.ProgramStageInstanceService;
+import org.hisp.dhis.program.ProgramStageService;
import com.opensymphony.xwork2.Action;
@@ -46,20 +49,27 @@
// Dependencies
// -------------------------------------------------------------------------
+ private ProgramInstanceService programInstanceService;
+
+ public void setProgramInstanceService( ProgramInstanceService programInstanceService )
+ {
+ this.programInstanceService = programInstanceService;
+ }
+
+ private ProgramStageService programStageService;
+
+ public void setProgramStageService( ProgramStageService programStageService )
+ {
+ this.programStageService = programStageService;
+ }
+
private ProgramStageInstanceService programStageInstanceService;
public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
{
this.programStageInstanceService = programStageInstanceService;
}
-
- private SelectedStateManager selectedStateManager;
-
- public void setSelectedStateManager( SelectedStateManager selectedStateManager )
- {
- this.selectedStateManager = selectedStateManager;
- }
-
+
private I18nFormat format;
public void setFormat( I18nFormat format )
@@ -71,6 +81,20 @@
// Input
// -------------------------------------------------------------------------
+ private Integer programInstanceId;
+
+ public void setProgramInstanceId( Integer programInstanceId )
+ {
+ this.programInstanceId = programInstanceId;
+ }
+
+ private Integer programStageId;
+
+ public void setProgramStageId( Integer programStageId )
+ {
+ this.programStageId = programStageId;
+ }
+
private String dueDate;
public void setDueDate( String dueDate )
@@ -93,19 +117,19 @@
public String execute()
throws Exception
{
- ProgramStageInstance currentStageInstance = selectedStateManager.getSelectedProgramStageInstance();
-
+ ProgramInstance programInstance = programInstanceService.getProgramInstance( programInstanceId );
+
+ ProgramStage progamStage = programStageService.getProgramStage( programStageId );
+
ProgramStageInstance programStageInstance = new ProgramStageInstance();
- programStageInstance.setProgramInstance( currentStageInstance.getProgramInstance() );
- programStageInstance.setProgramStage( currentStageInstance.getProgramStage() );
- programStageInstance.setStageInProgram( currentStageInstance.getStageInProgram() );
+ programStageInstance.setProgramInstance( programInstance );
+ programStageInstance.setProgramStage( progamStage );
+ programStageInstance.setStageInProgram( progamStage.getStageInProgram() );
programStageInstance.setDueDate( format.parseDate( dueDate ) );
int id = programStageInstanceService.addProgramStageInstance( programStageInstance );
message = id + "";
-
- selectedStateManager.setSelectedProgramStageInstance( programStageInstance );
-
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-08-12 06:10:50 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-08-15 02:57:56 +0000
@@ -127,8 +127,10 @@
scope="prototype">
<property name="programStageInstanceService"
ref="org.hisp.dhis.program.ProgramStageInstanceService" />
- <property name="selectedStateManager"
- ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+ <property name="programStageService"
+ ref="org.hisp.dhis.program.ProgramStageService" />
+ <property name="programInstanceService"
+ ref="org.hisp.dhis.program.ProgramInstanceService" />
</bean>
<bean
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-08-12 06:10:50 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-08-15 02:57:56 +0000
@@ -407,4 +407,5 @@
patient_dashboard = Person dashboard
completed_programs = Completed programs
active_programs = Active programs
-completed = Completed
\ No newline at end of file
+completed = Completed
+create_event_success = Create event successfully.
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataRecordingSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataRecordingSelect.vm 2012-08-13 05:15:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataRecordingSelect.vm 2012-08-15 02:57:56 +0000
@@ -39,7 +39,7 @@
</table>
</div>
-<div id='programInstanceDiv' class='hidden '>
+<div id='programInstanceDiv' class='hidden'>
#parse( "/dhis-web-caseentry/programStageInstanceFlow.vm" )
<br>
<table id='executionDateTB'>
@@ -59,23 +59,6 @@
</form>
<p></p>
-
-<div id='createNewEncounterDiv' class='hidden'>
- <table>
- <tr>
- <td>$i18n.getString( 'due_date' )</td>
- <td><input id='dueDateNewEncounter' name='dueDateNewEncounter' style='width:260px;'></td>
- <script type="text/javascript">
- datePicker( 'dueDateNewEncounter', false );
- </script>
- </tr>
- <tr>
- <td></td>
- <td>
- <input type='button' value='$i18n.getString("create")' onclick='registerIrregularEncounter( getFieldValue("dueDateNewEncounter" ) );' />
- <input type='button' value='$i18n.getString("cancel")' onclick="closeDueDateDiv();" />
- </td>
-</div>
<script>
jQuery('#dataRecordingSelectForm').ready(function(){
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js 2012-08-13 05:15:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js 2012-08-15 02:57:56 +0000
@@ -17,7 +17,6 @@
disableCompletedButton(true);
disable('uncompleteBtn');
disable('validationBtn');
- disable('newEncounterBtn');
hideById('inputCriteriaDiv');
$('#programStageIdTR').html('');
hideById('programInstanceDiv');
@@ -37,7 +36,11 @@
{
showById('programInstanceDiv');
hideById('executionDateTB');
-
+ if(byId('repeatableProgramStageId').options.length == 0)
+ {
+ hideById("newEncounterBtn");
+ }
+
var type = jQuery('#dataRecordingSelectDiv [name=programId] option:selected').attr('type');
if( type == 1 )
{
@@ -102,7 +105,6 @@
disable('validationBtn');
disableCompletedButton(true);
disable('uncompleteBtn');
- disable('newEncounterBtn');
jQuery(".stage-object-selected").removeClass('stage-object-selected');
var selectedProgramStageInstance = jQuery( '#' + prefixId + programStageInstanceId );
@@ -133,11 +135,6 @@
disableCompletedButton(true);
}
- if( completed == 'true' && irregular == 'true' )
- {
- enable( 'newEncounterBtn' );
- }
-
hideLoader();
hideById('contentDiv');
} );
@@ -508,7 +505,6 @@
jQuery(".stage-object-selected").css('background-color', COLOR_LIGHT_LIGHTRED);
disableCompletedButton(false);
enable('validationBtn');
- disable('newEncounterBtn');
setFieldValue( 'programStageId', selectedProgramStageInstance.attr('psid') );
},
@@ -624,29 +620,7 @@
var irregular = jQuery('#entryFormContainer [name=irregular]').val();
if( irregular == 'true' )
{
- enable('newEncounterBtn');
- jQuery('#createNewEncounterDiv').dialog({
- title: i18n_create_new_event,
- maximize: true,
- closable: true,
- modal:false,
- overlay:{background:'#000000', opacity:0.1},
- width: 400,
- height: 140
- }).show('fast');
-
- var standardInterval = jQuery('#dataRecordingSelectDiv [name=programStageId] option:selected').attr('standardInterval');
- var date = new Date();
- var d = date.getDate() + eval(standardInterval);
- var m = date.getMonth();
- var y = date.getFullYear();
- var edate= new Date(y, m, d);
-
- jQuery('#dueDateNewEncounter').datepicker( "setDate" , edate );
- }
- else
- {
- disable('newEncounterBtn');
+ showCreateNewEvent();
}
var selectedProgram = jQuery('#dataRecordingSelectForm [name=programId] option:selected');
@@ -688,6 +662,27 @@
}
+function showCreateNewEvent()
+{
+ jQuery('#createNewEncounterDiv').dialog({
+ title: i18n_create_new_event,
+ maximize: true,
+ closable: true,
+ modal:false,
+ overlay:{background:'#000000', opacity:0.1},
+ width: 450,
+ height: 160
+ }).show('fast');
+
+ var standardInterval = jQuery('#dataRecordingSelectDiv [name=programStageId] option:selected').attr('standardInterval');
+ var date = new Date();
+ var d = date.getDate() + eval(standardInterval);
+ var m = date.getMonth();
+ var y = date.getFullYear();
+ var edate= new Date(y, m, d);
+
+ jQuery('#dueDateNewEncounter').datepicker( "setDate" , edate );
+}
function closeDueDateDiv()
{
@@ -766,17 +761,20 @@
// Register Irregular-encounter
//------------------------------------------------------
-function registerIrregularEncounter( dueDate )
+function registerIrregularEncounter( programInstanceId, programStageId, programStageName, dueDate )
{
- jQuery.postJSON( "registerIrregularEncounter.action",{ dueDate: dueDate },
+ setInnerHTML('createEventMessage','');
+ jQuery.postJSON( "registerIrregularEncounter.action",
+ {
+ programInstanceId:programInstanceId,
+ programStageId: programStageId,
+ dueDate: dueDate
+ },
function( json )
{
var programStageInstanceId = json.message;
- jQuery('#createNewEncounterDiv').dialog('close');
disableCompletedButton(false);
- disable('newEncounterBtn');
- var programStageName = jQuery(".stage-object-selected").attr('psname');
var elementId = prefixId + programStageInstanceId;
var flag = false;
jQuery("#programStageIdTR input[name='programStageBtn']").each(function(i,item){
@@ -815,6 +813,7 @@
+ '></td>');
setEventColorStatus( elementId, 3 );
}
+ setInnerHTML('createEventMessage',i18n_create_event_success);
});
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramStageInstances.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramStageInstances.vm 2012-06-15 04:55:20 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramStageInstances.vm 2012-08-15 02:57:56 +0000
@@ -1,8 +1,7 @@
-
- #set( $size = $programStageInstances.size() )
+#set( $size = $programInstance.programStageInstances.size() )
{
"programStageInstances": [
- #foreach( $programStageInstance in $!programStageInstances )
+ #foreach( $programStageInstance in $!programInstance.programStageInstances )
{
"id": "$programStageInstance.id",
"programStageId": "$programStageInstance.programStage.id",
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm 2012-08-06 09:46:48 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm 2012-08-15 02:57:56 +0000
@@ -161,7 +161,7 @@
</td>
##entry
- #set( $duedateId = "value_"+$programStageInstance.id+"_date" )
+ #set( $duedateId = "value_" + $programStageInstance.id + "_date" )
<td class='input-column '>
<input type="text" id="$duedateId" name="entryfield" value="$!format.formatDate( $programStageInstance.dueDate )" onchange="saveDueDate( $programStageInstance.id, '$encoder.jsEncode( $programStageInstance.programStage.name )' )" />
<script type="text/javascript">
@@ -175,10 +175,11 @@
#end
</div>
-</div>
-
+</div>
#end
+#parse( "/dhis-web-caseentry/addRepeatableEventForm.vm" )
+
<script type="text/javascript">
jQuery("#programEnrollmentInforForm").ready( function(){
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageInstanceFlow.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageInstanceFlow.vm 2012-08-13 08:08:38 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageInstanceFlow.vm 2012-08-15 02:57:56 +0000
@@ -1,4 +1,4 @@
-<table id='programStageIdTB' style="width:850px;height:125px;">
+<table id='programStageIdTB$!programInstance.id' style="width:850px;height:125px;">
<tr>
<td>
<div class="arrow-left" onclick="moveLeft('flow_$!programInstance.id')"> </div>
@@ -28,7 +28,7 @@
</td>
<td> </td>
<td>
- <input type="button" class='stage-object' id="newEncounterBtn" value="$i18n.getString('create_new_event')" onClick="javascript: registerIrregularEncounter( getFieldValue('executionDate') );" disabled="disabled" #if($!programInstance.id) style='display:none' #end>
+ <input type="button" class='stage-object' id="newEncounterBtn$!programInstance.id" name="newEncounterBtn$!programInstance.id" value="$i18n.getString('create_new_event')" onClick="javascript:showCreateNewEvent();" #if($!programInstance.id) style='display:none' #end>
</td>
- </tr>
-</table>
\ No newline at end of file
+ </tr>
+</table>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css 2012-08-13 05:15:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css 2012-08-15 02:57:56 +0000
@@ -328,7 +328,7 @@
.stage-flow
{
width:750px;
- height:125px;
+ height:145px;
overflow-x:hidden;
overflow-y:hidden;
}