=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java 2012-03-27 01:29:30 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java 2012-03-29 04:15:07 +0000 @@ -62,5 +62,6 @@ Collection getPatientAttributes( Program program, PatientAttributeGroup group ); + Collection getPatientAttributes( Program program ); } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeStore.java 2012-03-27 01:29:30 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeStore.java 2012-03-29 04:15:07 +0000 @@ -52,4 +52,6 @@ Collection getWithoutGroup(); PatientAttribute getByGroupBy( boolean groupBy ); + + Collection get( Program program ); } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeService.java 2012-03-27 01:29:30 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeService.java 2012-03-29 04:15:07 +0000 @@ -113,5 +113,10 @@ { return patientAttributeStore.getWithoutGroup(); } + + public Collection getPatientAttributes( Program program ) + { + return patientAttributeStore.get( program ); + } } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeStore.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeStore.java 2012-03-27 01:29:30 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeStore.java 2012-03-29 04:15:07 +0000 @@ -70,7 +70,6 @@ } @SuppressWarnings("unchecked") - @Override public Collection get( Program program, PatientAttributeGroup group ) { Criteria criteria = getCriteria(); @@ -101,5 +100,12 @@ { return getCriteria( Restrictions.isNull( "patientAttributeGroup" ) ).list(); } + + @SuppressWarnings("unchecked") + @Override + public Collection get( Program program ) + { + return getCriteria( Restrictions.eq( "program", program ) ).list(); + } } === removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SavePatientAttributeValueAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SavePatientAttributeValueAction.java 2012-03-27 01:29:30 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SavePatientAttributeValueAction.java 1970-01-01 00:00:00 +0000 @@ -1,206 +0,0 @@ -/* - * Copyright (c) 2004-2012, 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.patient; - -import org.apache.commons.lang.math.NumberUtils; -import org.hisp.dhis.patient.Patient; -import org.hisp.dhis.patient.PatientAttribute; -import org.hisp.dhis.patient.PatientAttributeOption; -import org.hisp.dhis.patient.PatientAttributeOptionService; -import org.hisp.dhis.patient.PatientAttributeService; -import org.hisp.dhis.patient.PatientService; -import org.hisp.dhis.patientattributevalue.PatientAttributeValue; -import org.hisp.dhis.patientattributevalue.PatientAttributeValueService; - -import com.opensymphony.xwork2.Action; - -/** - * @author Chau Thu Tran - * - * @version $SavePatientAttributeValueAction.java Mar 26, 2012 4:06:46 PM$ - */ -public class SavePatientAttributeValueAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private PatientService patientService; - - private PatientAttributeValueService patientAttributeValueService; - - private PatientAttributeService patientAttributeService; - - private PatientAttributeOptionService patientAttributeOptionService; - - // ------------------------------------------------------------------------- - // Input/Output - // ------------------------------------------------------------------------- - - private Integer patientId; - - private Integer attributeId; - - private String value; - - private Integer statusCode; - - // ------------------------------------------------------------------------- - // Getters && Setters - // ------------------------------------------------------------------------- - - - public Integer getStatusCode() - { - return statusCode; - } - - public void setPatientService( PatientService patientService ) - { - this.patientService = patientService; - } - - public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService ) - { - this.patientAttributeValueService = patientAttributeValueService; - } - - public void setPatientAttributeService( PatientAttributeService patientAttributeService ) - { - this.patientAttributeService = patientAttributeService; - } - - public void setPatientAttributeOptionService( PatientAttributeOptionService patientAttributeOptionService ) - { - this.patientAttributeOptionService = patientAttributeOptionService; - } - - public void setPatientId( Integer patientId ) - { - this.patientId = patientId; - } - - public void setAttributeId( Integer attributeId ) - { - this.attributeId = attributeId; - } - - public void setValue( String value ) - { - this.value = value; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - @Override - public String execute() - throws Exception - { - Patient patient = patientService.getPatient( patientId ); - - PatientAttribute attribute = patientAttributeService.getPatientAttribute( attributeId ); - - if ( value != null && value.trim().length() == 0 ) - { - value = null; - } - - PatientAttributeValue attributeValue = patientAttributeValueService.getPatientAttributeValue( patient, - attribute ); - - if ( value != null ) - { - attributeValue = patientAttributeValueService.getPatientAttributeValue( patient, attribute ); - - if ( !patient.getAttributes().contains( attribute ) ) - { - patient.getAttributes().add( attribute ); - } - - if ( attributeValue == null ) - { - attributeValue = new PatientAttributeValue(); - attributeValue.setPatient( patient ); - attributeValue.setPatientAttribute( attribute ); - if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) ) - { - PatientAttributeOption option = patientAttributeOptionService.get( NumberUtils.toInt( value, 0 ) ); - if ( option != null ) - { - attributeValue.setPatientAttributeOption( option ); - attributeValue.setValue( option.getName() ); - } - else - { - // This option was deleted ??? - } - } - else - { - attributeValue.setValue( value.trim() ); - } - patientAttributeValueService.savePatientAttributeValue( attributeValue ); - } - else - { - if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) ) - { - PatientAttributeOption option = patientAttributeOptionService.get( NumberUtils.toInt( value, 0 ) ); - if ( option != null ) - { - attributeValue.setPatientAttributeOption( option ); - attributeValue.setValue( option.getName() ); - } - else - { - // This option was deleted ??? - } - } - else - { - attributeValue.setValue( value.trim() ); - } - patientAttributeValueService.updatePatientAttributeValue( attributeValue ); - } - } - else if ( attributeValue != null ) - { - patientAttributeValueService.deletePatientAttributeValue( attributeValue ); - patient.getAttributes().remove( attribute ); - patientService.updatePatient( patient ); - } - - statusCode = 0; - - return SUCCESS; - } - -} === removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SavePatientIdentifierAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SavePatientIdentifierAction.java 2012-03-27 01:29:30 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SavePatientIdentifierAction.java 1970-01-01 00:00:00 +0000 @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2004-2012, 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.patient; - -import org.hisp.dhis.patient.Patient; -import org.hisp.dhis.patient.PatientIdentifier; -import org.hisp.dhis.patient.PatientIdentifierService; -import org.hisp.dhis.patient.PatientIdentifierType; -import org.hisp.dhis.patient.PatientIdentifierTypeService; -import org.hisp.dhis.patient.PatientService; - -import com.opensymphony.xwork2.Action; - -/** - * @author Chau Thu Tran - * - * @version $SavePatientIdentifierAction.java Mar 26, 2012 11:50:50 AM$ - */ -public class SavePatientIdentifierAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private PatientService patientService; - - private PatientIdentifierTypeService identifierTypeService; - - private PatientIdentifierService patientIdentifierService; - - // ------------------------------------------------------------------------- - // Input/Output - // ------------------------------------------------------------------------- - - private Integer patientId; - - private Integer identifierTypeId; - - private String value; - - private Integer statusCode; - - // ------------------------------------------------------------------------- - // Input/Output - // ------------------------------------------------------------------------- - - public void setPatientService( PatientService patientService ) - { - this.patientService = patientService; - } - - public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService ) - { - this.patientIdentifierService = patientIdentifierService; - } - - public void setIdentifierTypeService( PatientIdentifierTypeService identifierTypeService ) - { - this.identifierTypeService = identifierTypeService; - } - - public void setPatientId( Integer patientId ) - { - this.patientId = patientId; - } - - public Integer getStatusCode() - { - return statusCode; - } - - public void setIdentifierTypeId( Integer identifierTypeId ) - { - this.identifierTypeId = identifierTypeId; - } - - public void setValue( String value ) - { - this.value = value; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - @Override - public String execute() - throws Exception - { - Patient patient = patientService.getPatient( patientId ); - PatientIdentifierType identifierType = identifierTypeService.getPatientIdentifierType( identifierTypeId ); - - if ( value != null && value.trim().length() == 0 ) - { - value = null; - } - - PatientIdentifier patientIdentifier = patientIdentifierService.getPatientIdentifier( identifierType, patient ); - - if ( value != null ) - { - if ( patientIdentifier == null ) - { - patientIdentifier = new PatientIdentifier(); - patientIdentifier.setIdentifierType( identifierType ); - patientIdentifier.setPatient( patient ); - } - - patientIdentifier.setIdentifier( value.trim() ); - patient.getIdentifiers().add( patientIdentifier ); - patientService.updatePatient( patient ); - } - else if ( patientIdentifier != null ) - { - patientIdentifierService.deletePatientIdentifier( patientIdentifier ); - } - - statusCode = 0; - - 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-03-28 07:10:48 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-03-29 04:15:07 +0000 @@ -688,22 +688,16 @@ - - - - + === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2012-03-28 07:10:48 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2012-03-29 04:15:07 +0000 @@ -567,14 +567,8 @@ F_PROGRAM_ENROLLMENT - - status.vm - F_PATIENT_UPDATE, F_PROGRAM_ENROLLMENT - - - + status.vm F_PATIENT_UPDATE, F_PROGRAM_ENROLLMENT === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js 2012-03-28 07:10:48 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js 2012-03-29 04:15:07 +0000 @@ -794,176 +794,17 @@ showById('enrollBtn'); } -function savePatientIdentifier( identifierTypeId, field ) -{ - field.style.backgroundColor = COLOR_WHITE; - field.blur(); - if( validateValue( "iden" + identifierTypeId ) ) - { - var patientId = getFieldValue("patientId"); - field.style.backgroundColor = COLOR_YELLOW; - - var valueSaver = new PatientIdentifierSaver( patientId, identifierTypeId, field.value, COLOR_GREEN ); - valueSaver.save(); - } - else - { - field.style.backgroundColor = COLOR_ORANGE; - } -} - -function savePatientAttrValue( patientAttributeId, field ) -{ - field.style.backgroundColor = COLOR_WHITE; - field.blur(); - if( validateValue( "attr" + patientAttributeId ) ) - { - var patientId = getFieldValue("patientId"); - field.style.backgroundColor = COLOR_YELLOW; - - var valueSaver = new PatientAttributeValueSaver( patientId, patientAttributeId, field.value, COLOR_GREEN ); - valueSaver.save(); - } - else - { - field.style.backgroundColor = COLOR_ORANGE; - } -} - -//-------------------------------------------------------------------------------------------- -// For saving patient-identifier and patient-attribute-value -//-------------------------------------------------------------------------------------------- - -function validateValue( spanErrorId ) -{ - var classes = jQuery( 'span[for=' + spanErrorId + ']' ).attr('class'); - return ( classes == "error") ? false : true; -} - -function PatientIdentifierSaver( patientId_, identifierTypeId_, value_, resultColor_ ) -{ - var patientId = patientId_; - var identifierTypeId = identifierTypeId_; - var value = value_; - var resultColor = resultColor_; - - this.save = function() - { - var params = 'patientId=' + patientId; - params += '&identifierTypeId=' + identifierTypeId; - params += '&value=' + value; - - $.ajax({ - url: "savePatientIdentifier.action", - data: params, - type: "POST", - dataType: "xml", - success: function(result){ - handleResponse (result); - }, - error: function(request,status,errorThrown) { - handleHttpError (request); - } - }); - }; - - function handleResponse( rootElement ) - { - var codeElement = rootElement.getElementsByTagName( 'code' )[0]; - var code = parseInt( codeElement.firstChild.nodeValue ); - if ( code == 0 ) - { - markValue( resultColor ); - } - else - { - if(value!="") - { - markValue( COLOR_GREY ); - window.alert( i18n_saving_value_failed_status_code + '\n\n' + code ); - } - else - { - markValue( resultColor ); - } - } - } - - function handleHttpError( errorCode ) - { - markValue( COLOR_GREY ); - window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode ); - } - - function markValue( color ) - { - var programStageId = getFieldValue('programStageId'); - var element = byId( 'iden' + identifierTypeId ); - element.style.backgroundColor = color; - } -} - -function PatientAttributeValueSaver( patientId_, attributeId_, value_, resultColor_ ) -{ - var patientId = patientId_; - var attributeId = attributeId_; - var value = value_; - var resultColor = resultColor_; - - this.save = function() - { - var params = 'patientId=' + patientId; - params += '&attributeId=' + attributeId; - params += '&value=' + value; - - $.ajax({ - url: "savePatientAttribueValue.action", - data: params, - type: "POST", - dataType: "xml", - success: function(result){ - handleResponse (result); - }, - error: function(request,status,errorThrown) { - handleHttpError (request); - } - }); - }; - - function handleResponse( rootElement ) - { - var codeElement = rootElement.getElementsByTagName( 'code' )[0]; - var code = parseInt( codeElement.firstChild.nodeValue ); - if ( code == 0 ) - { - markValue( resultColor ); - } - else - { - if(value!="") - { - markValue( COLOR_GREY ); - window.alert( i18n_saving_value_failed_status_code + '\n\n' + code ); - } - else - { - markValue( resultColor ); - } - } - } - - function handleHttpError( errorCode ) - { - markValue( COLOR_GREY ); - window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode ); - } - - function markValue( color ) - { - var programStageId = getFieldValue('programStageId'); - var element = byId( 'attr' + attributeId ); - element.style.backgroundColor = color; - } +function saveIdentifierAndAttribute() +{ + $.ajax({ + type: "POST", + url: 'savePatientIdentifierAndAttribute.action', + data: getParamsForDiv('programEnrollmentInforForm'), + success: function(json) + { + showSuccessMessage( i18n_save_success ); + } + }); } //-------------------------------------------------------------------------------------------- @@ -1057,4 +898,4 @@ { showSuccessMessage( i18n_save_success ); } ); -} \ No newline at end of file +} === 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-03-28 07:10:48 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm 2012-03-29 04:15:07 +0000 @@ -13,6 +13,8 @@
+ + #if( $identifierTypes || $noGroupAttributes || $attributeGroups ) @@ -25,12 +27,13 @@ #end #set( $mark = false ) - #foreach ($identifierType in $identifierTypes) + #foreach ($identifierType in $identifierTypes) + #set( $identifier = '') #set( $identifier = $identiferMap.get( $identifierType.id ) ) #set( $mark = !$mark ) @@ -43,30 +46,31 @@ #set( $mark = false ) #foreach($attribute in $attributeGroup.attributes) #if( $!attribute.program ) + #set( $attributeValue = '') #set( $attributeValue = $!patientAttributeValueMap.get( $attribute.id ) ) @@ -83,30 +87,31 @@ #set( $mark = false ) #foreach($attribute in $noGroupAttributes ) #if( $attribute.program ) + #set( $attributeValue = '') #set( $attributeValue = $!patientAttributeValueMap.get( $attribute.id ) ) @@ -114,9 +119,12 @@ #end #end #end + + + +
- +
#if( $attribute.valueType == "YES/NO" ) - #elseif( $attribute.valueType == "DATE" ) - + #elseif( $attribute.valueType == "COMBO" ) - #foreach ($option in $attribute.attributeOptions ) #end #else - + #end
#if( $attribute.valueType == "YES/NO" ) - #elseif( $attribute.valueType == "DATE" ) - + #elseif( $attribute.valueType == "COMBO" ) - #foreach ($option in $attribute.attributeOptions ) #end #else - + #end
#end -
@@ -220,15 +228,15 @@