=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java 2012-03-01 07:44:57 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java 2012-02-27 02:09:02 +0000 @@ -808,7 +808,7 @@ // Inline Javascript to add to HTML before outputting // --------------------------------------------------------------------- - final String jsCodeForDate = " name=\"entryfield\" $DISABLED data=\"{compulsory:$COMPULSORY, deName:'$DATAELEMENTNAME', provided:'$PROVIDED'}\" onchange=\"saveDate( $DATAELEMENTID )\" style=\" text-align:center;\" "; + final String jsCodeForDate = " name=\"entryfield\" $DISABLED data=\"{compulsory:$COMPULSORY, deName:'$DATAELEMENTNAME', provided:'$PROVIDED'}\" onchange=\"saveVal( $DATAELEMENTID )\" style=\" text-align:center;\" "; // --------------------------------------------------------------------- // Metadata code to add to HTML before outputting === removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveDateValueAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveDateValueAction.java 2012-02-11 13:58:02 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveDateValueAction.java 1970-01-01 00:00:00 +0000 @@ -1,191 +0,0 @@ -/* - * Copyright (c) 2004-2009, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.hisp.dhis.caseentry.action.caseentry; - -import java.util.Date; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hisp.dhis.caseentry.state.SelectedStateManager; -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dataelement.DataElementService; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.patientdatavalue.PatientDataValue; -import org.hisp.dhis.patientdatavalue.PatientDataValueService; -import org.hisp.dhis.program.ProgramStageInstance; -import org.hisp.dhis.program.ProgramStageInstanceService; - -import com.opensymphony.xwork2.Action; - -/** - * @author Abyot Asalefew Gizaw - * @version $Id$ - */ -public class SaveDateValueAction - implements Action -{ - private static final Log LOG = LogFactory.getLog( SaveDateValueAction.class ); - - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private ProgramStageInstanceService programStageInstanceService; - - public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService ) - { - this.programStageInstanceService = programStageInstanceService; - } - - private DataElementService dataElementService; - - public void setDataElementService( DataElementService dataElementService ) - { - this.dataElementService = dataElementService; - } - - private PatientDataValueService patientDataValueService; - - public void setPatientDataValueService( PatientDataValueService patientDataValueService ) - { - this.patientDataValueService = patientDataValueService; - } - - private SelectedStateManager selectedStateManager; - - public void setSelectedStateManager( SelectedStateManager selectedStateManager ) - { - this.selectedStateManager = selectedStateManager; - } - - // ------------------------------------------------------------------------- - // Input/Output - // ------------------------------------------------------------------------- - - private boolean providedByAnotherFacility; - - public void setProvidedByAnotherFacility( boolean providedByAnotherFacility ) - { - this.providedByAnotherFacility = providedByAnotherFacility; - } - - private String value; - - public void setValue( String value ) - { - this.value = value; - } - - private int dataElementId; - - public void setDataElementId( int dataElementId ) - { - this.dataElementId = dataElementId; - } - - public int getDataElementId() - { - return dataElementId; - } - - private int statusCode; - - public int getStatusCode() - { - return statusCode; - } - - public void setStatusCode( int statusCode ) - { - this.statusCode = statusCode; - } - - private String message; - - public String getMessage() - { - return message; - } - - // ------------------------------------------------------------------------- - // Implementation Action - // ------------------------------------------------------------------------- - - public String execute() - throws Exception - { - // --------------------------------------------------------------------- - // Get program-stage-instance - // --------------------------------------------------------------------- - - OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit(); - - ProgramStageInstance programStageInstance = selectedStateManager.getSelectedProgramStageInstance(); - - DataElement dataElement = dataElementService.getDataElement( dataElementId ); - - PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue( programStageInstance, - dataElement, organisationUnit ); - - if ( value != null && value.trim().length() == 0 ) - { - value = null; - } - - // --------------------------------------------------------------------- - // Save value - // --------------------------------------------------------------------- - - if ( programStageInstance.getExecutionDate() == null ) - { - programStageInstance.setExecutionDate( new Date() ); - programStageInstanceService.updateProgramStageInstance( programStageInstance ); - } - - if ( patientDataValue == null && value != null ) - { - LOG.debug( "Adding PatientDataValue, value added" ); - - patientDataValue = new PatientDataValue( programStageInstance, dataElement, organisationUnit, - new Date(), value, providedByAnotherFacility ); - - patientDataValueService.savePatientDataValue( patientDataValue ); - } - else - { - LOG.debug( "Updating PatientDataValue, value added/changed" ); - - patientDataValue.setValue( value ); - patientDataValue.setProvidedByAnotherFacility( providedByAnotherFacility ); - patientDataValue.setTimestamp( new Date() ); - - patientDataValueService.updatePatientDataValue( patientDataValue ); - } - - return SUCCESS; - } -} === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java 2012-02-11 13:58:02 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java 2012-02-27 02:09:02 +0000 @@ -76,7 +76,7 @@ { this.patientDataValueService = patientDataValueService; } - + private SelectedStateManager selectedStateManager; public void setSelectedStateManager( SelectedStateManager selectedStateManager ) @@ -140,35 +140,36 @@ public String execute() throws Exception { - // --------------------------------------------------------------------- - // Get program-stage-instance - // --------------------------------------------------------------------- - OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit(); ProgramStageInstance programStageInstance = selectedStateManager.getSelectedProgramStageInstance(); - // --------------------------------------------------------------------- - // Save value - // --------------------------------------------------------------------- - DataElement dataElement = dataElementService.getDataElement( dataElementId ); PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue( programStageInstance, dataElement, organisationUnit ); - + + if ( value != null && value.trim().length() == 0 ) + { + value = null; + } + + // --------------------------------------------------------------------- + // Save value + // --------------------------------------------------------------------- + if ( programStageInstance.getExecutionDate() == null ) { programStageInstance.setExecutionDate( new Date() ); programStageInstanceService.updateProgramStageInstance( programStageInstance ); } - if ( patientDataValue == null ) + if ( patientDataValue == null && value != null ) { LOG.debug( "Adding PatientDataValue, value added" ); - patientDataValue = new PatientDataValue( programStageInstance, dataElement, organisationUnit, - new Date(), value, providedByAnotherFacility ); + patientDataValue = new PatientDataValue( programStageInstance, dataElement, organisationUnit, new Date(), + value, providedByAnotherFacility ); patientDataValueService.savePatientDataValue( patientDataValue ); } === 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-02-25 12:24:41 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-02-27 02:09:02 +0000 @@ -81,18 +81,6 @@ ref="org.hisp.dhis.caseentry.state.SelectedStateManager" /> - - - - - - - plainTextError - - - - status.vm - plainTextError - + === 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-02-17 16:17:14 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm 2012-02-27 02:09:02 +0000 @@ -98,7 +98,7 @@ #elseif( $programStageDataElement.dataElement.type == "date" ) - + #if(!$programStageInstance.completed)