dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21927
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10493: multiple updates to anonymous program, removed some of the server-side states. check online for p...
------------------------------------------------------------
revno: 10493
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-04-08 11:57:19 +0700
message:
multiple updates to anonymous program, removed some of the server-side states. check online for programs first, then offline.
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/javascript/anonymousRegistration.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dhis2.storage.anonymous.js
--
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 2013-04-02 04:33:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java 2013-04-08 04:57:19 +0000
@@ -38,6 +38,8 @@
import org.hisp.dhis.dataentryform.DataEntryForm;
import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.orgunitdistribution.OrgUnitDistributionService;
import org.hisp.dhis.patient.Patient;
import org.hisp.dhis.patientdatavalue.PatientDataValue;
import org.hisp.dhis.patientdatavalue.PatientDataValueService;
@@ -58,7 +60,6 @@
/**
* @author Chau Thu Tran
* @version $ LoadDataEntryAction.java May 7, 2011 2:37:44 PM $
- *
*/
public class LoadDataEntryAction
implements Action
@@ -69,14 +70,46 @@
private ProgramDataEntryService programDataEntryService;
+ public void setProgramDataEntryService( ProgramDataEntryService programDataEntryService )
+ {
+ this.programDataEntryService = programDataEntryService;
+ }
+
private PatientDataValueService patientDataValueService;
+ public void setPatientDataValueService( PatientDataValueService patientDataValueService )
+ {
+ this.patientDataValueService = patientDataValueService;
+ }
+
private ProgramStageInstanceService programStageInstanceService;
+ public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+ {
+ this.programStageInstanceService = programStageInstanceService;
+ }
+
private SelectedStateManager selectedStateManager;
+ public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+ {
+ this.selectedStateManager = selectedStateManager;
+ }
+
private ProgramStageSectionService programStageSectionService;
+ public void setProgramStageSectionService( ProgramStageSectionService programStageSectionService )
+ {
+ this.programStageSectionService = programStageSectionService;
+ }
+
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
// -------------------------------------------------------------------------
// Input && Output
// -------------------------------------------------------------------------
@@ -93,6 +126,8 @@
private Map<Integer, PatientDataValue> patientDataValueMap;
+ private Integer organisationUnitId;
+
private OrganisationUnit organisationUnit;
private Program program;
@@ -107,16 +142,6 @@
// Getters && Setters
// -------------------------------------------------------------------------
- public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
- {
- this.programStageInstanceService = programStageInstanceService;
- }
-
- public void setProgramStageSectionService( ProgramStageSectionService programStageSectionService )
- {
- this.programStageSectionService = programStageSectionService;
- }
-
public void setProgramStageInstanceId( Integer programStageInstanceId )
{
this.programStageInstanceId = programStageInstanceId;
@@ -137,21 +162,6 @@
return programStage;
}
- public void setSelectedStateManager( SelectedStateManager selectedStateManager )
- {
- this.selectedStateManager = selectedStateManager;
- }
-
- public void setProgramDataEntryService( ProgramDataEntryService programDataEntryService )
- {
- this.programDataEntryService = programDataEntryService;
- }
-
- public void setPatientDataValueService( PatientDataValueService patientDataValueService )
- {
- this.patientDataValueService = patientDataValueService;
- }
-
public OrganisationUnit getOrganisationUnit()
{
return organisationUnit;
@@ -200,7 +210,7 @@
{
return calAttributeValueMap;
}
-
+
private String longitude;
public String getLongitude()
@@ -222,7 +232,8 @@
public String execute()
throws Exception
{
- organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
+ organisationUnit = organisationUnitId == null ? selectedStateManager.getSelectedOrganisationUnit() :
+ organisationUnitService.getOrganisationUnit( organisationUnitId );
// ---------------------------------------------------------------------
// Get program-stage-instance
=== 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-10-18 04:24:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveExecutionDateAction.java 2013-04-08 04:57:19 +0000
@@ -33,6 +33,8 @@
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.caseentry.state.SelectedStateManager;
import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.patient.Patient;
import org.hisp.dhis.patient.PatientService;
import org.hisp.dhis.program.Program;
@@ -86,6 +88,13 @@
this.patientService = patientService;
}
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
private SelectedStateManager selectedStateManager;
public void setSelectedStateManager( SelectedStateManager selectedStateManager )
@@ -99,11 +108,25 @@
{
this.format = format;
}
-
+
// -------------------------------------------------------------------------
// Input/Output
// -------------------------------------------------------------------------
+ private Integer organisationUnitId;
+
+ public void setOrganisationUnitId( Integer organisationUnitId )
+ {
+ this.organisationUnitId = organisationUnitId;
+ }
+
+ private Integer patientId;
+
+ public void setPatientId( Integer patientId )
+ {
+ this.patientId = patientId;
+ }
+
private String executionDate;
public void setExecutionDate( String executionDate )
@@ -112,7 +135,7 @@
}
private Integer programStageInstanceId;
-
+
public void setProgramStageInstanceId( Integer programStageInstanceId )
{
this.programStageInstanceId = programStageInstanceId;
@@ -140,9 +163,14 @@
throws Exception
{
Date dateValue = format.parseDate( executionDate );
-
+
+ OrganisationUnit organisationUnit = organisationUnitId == null ? selectedStateManager.getSelectedOrganisationUnit() :
+ organisationUnitService.getOrganisationUnit( organisationUnitId );
+
+ Patient patient = patientId == null ? selectedStateManager.getSelectedPatient() : patientService.getPatient( patientId );
+
if ( dateValue != null )
- {
+ {
ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( programStageInstanceId );
// If the program-stage-instance of the patient not exists,
@@ -158,7 +186,6 @@
programStage = program.getProgramStages().iterator().next();
}
- Patient patient = selectedStateManager.getSelectedPatient();
int type = program.getType();
ProgramInstance programInstance = null;
@@ -188,7 +215,7 @@
programStageInstance.setProgramStage( programStage );
programStageInstance.setDueDate( dateValue );
programStageInstance.setExecutionDate( dateValue );
- programStageInstance.setOrganisationUnit( selectedStateManager.getSelectedOrganisationUnit() );
+ programStageInstance.setOrganisationUnit( organisationUnit );
programStageInstanceService.addProgramStageInstance( programStageInstance );
selectedStateManager.setSelectedProgramInstance( programInstance );
@@ -197,7 +224,7 @@
else
{
programStageInstance.setExecutionDate( dateValue );
- programStageInstance.setOrganisationUnit( selectedStateManager.getSelectedOrganisationUnit() );
+ programStageInstance.setOrganisationUnit( organisationUnit );
if ( programStageInstance.getProgramInstance().getProgram().isSingleEvent() )
{
=== 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 2013-04-02 05:33:46 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-04-08 04:57:19 +0000
@@ -43,17 +43,14 @@
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
</bean>
- <bean
- id="org.hisp.dhis.caseentry.action.caseentry.SaveExecutionDateAction"
- class="org.hisp.dhis.caseentry.action.caseentry.SaveExecutionDateAction"
- scope="prototype">
- <property name="programStageInstanceService"
- ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+ <bean id="org.hisp.dhis.caseentry.action.caseentry.SaveExecutionDateAction"
+ class="org.hisp.dhis.caseentry.action.caseentry.SaveExecutionDateAction" scope="prototype">
+ <property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />
<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"
- ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+ <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ <property name="selectedStateManager" ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
</bean>
<bean id="org.hisp.dhis.caseentry.action.caseentry.SaveValueAction"
@@ -90,22 +87,17 @@
ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
</bean>
- <bean id="org.hisp.dhis.caseentry.action.caseentry.LoadDataEntryAction"
- class="org.hisp.dhis.caseentry.action.caseentry.LoadDataEntryAction"
- scope="prototype">
- <property name="programDataEntryService"
- ref="org.hisp.dhis.program.ProgramDataEntryService" />
- <property name="patientDataValueService"
- ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
- <property name="programStageInstanceService"
- ref="org.hisp.dhis.program.ProgramStageInstanceService" />
- <property name="selectedStateManager"
- ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
- <property name="programStageSectionService"
- ref="org.hisp.dhis.program.ProgramStageSectionService" />
- </bean>
+ <bean id="org.hisp.dhis.caseentry.action.caseentry.LoadDataEntryAction"
+ class="org.hisp.dhis.caseentry.action.caseentry.LoadDataEntryAction" scope="prototype">
+ <property name="programDataEntryService" ref="org.hisp.dhis.program.ProgramDataEntryService" />
+ <property name="patientDataValueService" ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
+ <property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+ <property name="selectedStateManager" ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+ <property name="programStageSectionService" ref="org.hisp.dhis.program.ProgramStageSectionService" />
+ <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ </bean>
- <bean
+ <bean
id="org.hisp.dhis.caseentry.action.caseentry.CompleteDataEntryAction"
class="org.hisp.dhis.caseentry.action.caseentry.CompleteDataEntryAction"
scope="prototype">
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js 2013-04-04 07:57:59 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js 2013-04-08 04:57:19 +0000
@@ -46,23 +46,21 @@
hideById( 'listDiv' );
hideById( 'dataEntryInfor' );
- DAO.programs.fetchAll( function ( store, arr ) {
- var programs = [];
-
- $.each( arr, function ( idx, item ) {
- if ( item.programAssociations.indexOf( orgUnits[0] ) != -1 ) {
- programs.push( item );
- }
- } );
-
- if( programs.length > 0) {
+ // try online first, then fallback to what we have stored in browser
+ dhis2.storage.Store.plugins['online-anonymous-programs'].call( {}, function ( arr ) {
+ updateProgramList( arr );
+ }, function () {
+ DAO.programs.fetchAll( function ( store, arr ) {
+ var programs = [];
+
+ $.each( arr, function ( idx, item ) {
+ if ( item.programAssociations.indexOf( orgUnits[0] ) != -1 ) {
+ programs.push( item );
+ }
+ } );
+
updateProgramList( programs );
- } else {
- // if we are online, also check server to see if there are any programs
- dhis2.storage.Store.plugins['anonymous-online'].call( {}, function ( arr ) {
- updateProgramList( arr );
- } );
- }
+ } );
} );
}
@@ -556,12 +554,16 @@
var programStageInstanceId = getFieldValue( 'programStageInstanceId' );
var programId = jQuery( '#programId option:selected' ).val();
var executionDate = getFieldValue( 'executionDate' );
+ var orgunitId = getFieldValue( 'orgunitId' );
+
jQuery( "#executionDate" ).css( 'background-color', SAVING_COLOR );
+
jQuery.postJSON( "saveExecutionDate.action",
{
programStageInstanceId: programStageInstanceId,
programId: programId,
- executionDate: executionDate
+ executionDate: executionDate,
+ organisationUnitId: orgunitId
},
function ( json ) {
if ( json.response == 'success' ) {
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dhis2.storage.anonymous.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dhis2.storage.anonymous.js 2013-03-30 10:45:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dhis2.storage.anonymous.js 2013-04-08 04:57:19 +0000
@@ -1,7 +1,7 @@
-dhis2.storage.Store.plugin( 'anonymous-online', (function () {
+dhis2.storage.Store.plugin( 'online-anonymous-programs', (function () {
return {
- call: function ( args, callback ) {
- $.ajax( {
+ call: function ( args, success, failure ) {
+ return $.ajax( {
type: 'POST',
url: "anonymousPrograms.action",
data: args,
@@ -23,8 +23,8 @@
delete arr[i].type;
}
- if ( callback ) callback( arr );
- } );
+ if ( success ) success( arr );
+ } ).fail(failure);
}
};
})() );