dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17866
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7284: Error when loading dataentry form of single program.
------------------------------------------------------------
revno: 7284
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-06-13 15:22:35 +0700
message:
Error when loading dataentry form of single program.
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveExecutionDateAction.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/webapp/dhis-web-caseentry/anonymousRegistration.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties
--
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-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java 2012-06-07 04:23:40 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java 2012-06-13 08:22:35 +0000
@@ -165,12 +165,12 @@
// ---------------------------------------------------------------------
// Get program-stage-instance
// ---------------------------------------------------------------------
-
- programStageInstance = programStageInstanceService.getProgramStageInstance( programStageInstanceId );
- program = programStageInstance.getProgramStage().getProgram();
-
- if ( programStageInstance != null )
- {
+ if ( programStageInstanceId != null )
+ {
+ programStageInstance = programStageInstanceService.getProgramStageInstance( programStageInstanceId );
+
+ program = programStageInstance.getProgramStage().getProgram();
+
if ( program.getType() == Program.SINGLE_EVENT_WITHOUT_REGISTRATION && programStageInstance.isCompleted() )
{
return SUCCESS;
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveExecutionDateAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveExecutionDateAction.java 2012-06-04 10:03:56 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveExecutionDateAction.java 2012-06-13 08:22:35 +0000
@@ -38,10 +38,10 @@
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramInstance;
import org.hisp.dhis.program.ProgramInstanceService;
+import org.hisp.dhis.program.ProgramService;
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 org.hisp.dhis.user.CurrentUserService;
import com.opensymphony.xwork2.Action;
@@ -66,11 +66,11 @@
this.programStageInstanceService = programStageInstanceService;
}
- private ProgramStageService programStageService;
+ private ProgramService programService;
- public void setProgramStageService( ProgramStageService programStageService )
+ public void setProgramService( ProgramService programService )
{
- this.programStageService = programStageService;
+ this.programService = programService;
}
private ProgramInstanceService programInstanceService;
@@ -119,11 +119,11 @@
this.executionDate = executionDate;
}
- private Integer programStageId;
+ private Integer programId;
- public void setProgramStageId( Integer programStageId )
+ public void setProgramId( Integer programId )
{
- this.programStageId = programStageId;
+ this.programId = programId;
}
private String message;
@@ -141,7 +141,6 @@
throws Exception
{
Date dateValue = format.parseDate( executionDate );
-
String storedBy = currentUserService.getCurrentUsername();
if ( dateValue != null )
@@ -154,12 +153,18 @@
// single-event program
if ( programStageInstance == null )
{
+ Program program = programService.getProgram( programId );
+ ProgramStage programStage = null;
+
+ if ( program.getProgramStages() != null )
+ {
+ programStage = program.getProgramStages().iterator().next();
+ }
+
Patient patient = selectedStateManager.getSelectedPatient();
- ProgramStage programStage = programStageService.getProgramStage( programStageId );
- Program program = programStage.getProgram();
int type = program.getType();
ProgramInstance programInstance = null;
-
+
if ( type == Program.SINGLE_EVENT_WITH_REGISTRATION )
{
// Add a new program-instance
@@ -177,8 +182,7 @@
}
else if ( type == Program.SINGLE_EVENT_WITHOUT_REGISTRATION )
{
- programInstance = programInstanceService.getProgramInstances( patient, program )
- .iterator().next();
+ programInstance = programInstanceService.getProgramInstances( patient, program ).iterator().next();
}
// Add a new program-stage-instance
=== 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-06-12 03:38:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-06-13 08:22:35 +0000
@@ -64,7 +64,7 @@
scope="prototype">
<property name="programStageInstanceService"
ref="org.hisp.dhis.program.ProgramStageInstanceService" />
- <property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
+ <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
<property name="selectedStateManager"
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm 2012-06-07 09:55:49 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm 2012-06-13 08:22:35 +0000
@@ -8,6 +8,7 @@
<div id="dataRecordingSelectDiv" class="inputCriteria" style="width:480px;height:75px;">
<input type='hidden' id="programStageInstanceId">
+ <input type='hidden' id="programStageId">
<input type='hidden' id='selectedProgramId'>
<table>
<tr>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm 2012-06-07 09:55:49 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm 2012-06-13 08:22:35 +0000
@@ -1,6 +1,7 @@
<script>
jQuery("#entryFormContainer").ready(function(){
-
+ setFieldValue('programStageId', "$!programStageInstance.programStage.id");
+ setFieldValue('programId', "$!programStageInstance.programStage.program.id");
#if( $!programStageInstance.programStage.program.type=="3" && $!programStageInstance.completed=='true')
hideById('entryFormContainer');
#elseif( $programStageInstance )
@@ -9,14 +10,13 @@
#end
$('#executionDate').change(function() {
- saveExecutionDate( getFieldValue('programStageId'), getFieldValue('executionDate') );
+ saveExecutionDate( getFieldValue('programId'), getFieldValue('executionDate') );
});
entryFormContainerOnReady();
});
</script>
-
<div id='entryFormContainer'>
<input type='hidden' id='incidentDate' value='$!format.formatDate($programStageInstance.programInstance.dateOfIncident)'>
=== 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-06-08 07:22:50 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js 2012-06-13 08:22:35 +0000
@@ -78,7 +78,7 @@
showById('programInstanceFlowDiv');
}
// Load entry form for Single-event program or normal program with only one program-stage
- else
+ else
{
jQuery('#dueDateTR').attr('class','hidden');
enable('completeBtn');
@@ -86,7 +86,12 @@
hideById('historyPlanLink');
hideById('programStageIdTR');
hideById('programInstanceFlowDiv');
- loadDataEntry( json.programStageInstances[0].id );
+ var programStageInstanceId = '';
+ if( json.programStageInstances.length == 1 )
+ {
+ programStageInstanceId = json.programStageInstances[0].id;
+ }
+ loadDataEntry( programStageInstanceId );
}
});
}
@@ -245,13 +250,13 @@
}
-function saveExecutionDate( programStageId, executionDateValue )
+function saveExecutionDate( programId, executionDateValue )
{
var field = document.getElementById( 'executionDate' );
field.style.backgroundColor = '#ffffcc';
- var executionDateSaver = new ExecutionDateSaver( programStageId, executionDateValue, '#ccffcc' );
+ var executionDateSaver = new ExecutionDateSaver( programId, executionDateValue, '#ccffcc' );
executionDateSaver.save();
if( !jQuery("#entryForm").is(":visible") )
@@ -519,26 +524,28 @@
}
}
-function ExecutionDateSaver( programStageId_, executionDate_, resultColor_ )
+function ExecutionDateSaver( programId_, executionDate_, resultColor_ )
{
var SUCCESS = '#ccffcc';
var ERROR = '#ffcc00';
- var programStageId = programStageId_;
+ var programId = programId_;
var executionDate = executionDate_;
var resultColor = resultColor_;
this.save = function()
{
var params = "executionDate=" + executionDate;
- params += "&programStageId=" + programStageId;
+ params += "&programId=" + programId;
$.ajax({
type: "POST",
url: "saveExecutionDate.action",
data: params,
dataType: "xml",
- success: function(result){
+ success: function( result ){
+ handleResponse (result);
+
var selectedProgramStageInstance = jQuery( '#' + prefixId + getFieldValue('programStageInstanceId') );
jQuery(".stage-object-selected").css('border-color', COLOR_LIGHTRED);
jQuery(".stage-object-selected").css('background-color', COLOR_LIGHT_LIGHTRED);
@@ -549,7 +556,6 @@
disable('newEncounterBtn');
setFieldValue( 'programStageId', selectedProgramStageInstance.attr('psid') );
- handleResponse (result);
},
error: function(request,status,errorThrown) {
handleHttpError (request);
@@ -568,7 +574,7 @@
{
var programStageInstanceId = rootElement.firstChild.nodeValue;
setFieldValue('programStageInstanceId', programStageInstanceId);
- loadDataEntry( getFieldValue('programStageId') );
+ loadDataEntry( programStageInstanceId );
}
else
{
@@ -657,6 +663,7 @@
var irregular = jQuery('#entryFormContainer [name=irregular]').val();
if( irregular == 'true' )
{
+ enable('createEventBtn');
jQuery('#createNewEncounterDiv').dialog({
title: i18n_create_new_event,
maximize: true,
@@ -674,16 +681,17 @@
var y = date.getFullYear();
var edate= new Date(y, m, d);
- jQuery('#dueDateNewEncounter').datepicker( "setDate" , edate )
+ jQuery('#dueDateNewEncounter').datepicker( "setDate" , edate );
}
var selectedProgram = jQuery('#dataRecordingSelectForm [name=programId] option:selected');
if( selectedProgram.attr('type')=='2' && irregular == 'false' )
{
selectedProgram.remove();
+ hideById('programInstanceDiv');
+ hideById('entryFormContainer');
}
- enable('createEventBtn');
selection.enable();
hideLoader();
hideById('contentDiv');
=== 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-06-13 04:13:23 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2012-06-13 08:22:35 +0000
@@ -246,4 +246,5 @@
program_stage_properties = Program stage properties
allow_provided_elsewhere = Allow provided elsewhere
save_success=Save successful
-sort_by_scheduled_days = Sort by scheduled days
\ No newline at end of file
+sort_by_scheduled_days = Sort by scheduled days
+assign_program_to_orgunits_for_registering = Assign program to orgunits for registering
\ No newline at end of file