=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/SavePatientAttributeValueAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/SavePatientAttributeValueAction.java 2010-02-17 13:38:15 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/SavePatientAttributeValueAction.java 2010-03-05 13:00:37 +0000 @@ -26,10 +26,13 @@ */ package org.hisp.dhis.patient.action.patientattribute; +import org.apache.commons.lang.math.NumberUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; 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; @@ -71,7 +74,13 @@ { this.patientAttributeValueService = patientAttributeValueService; } + + private PatientAttributeOptionService patientAttributeOptionService; + public void setPatientAttributeOptionService( PatientAttributeOptionService patientAttributeOptionService ) + { + this.patientAttributeOptionService = patientAttributeOptionService; + } // ------------------------------------------------------------------------- // Input/Output // ------------------------------------------------------------------------- @@ -136,9 +145,20 @@ { LOG.debug( "Adding PatientAttributeValue, value added" ); - - patientAttributeValue = new PatientAttributeValue( patientAttribute, patient, value ); - + + if( patientAttribute.getValueType().equalsIgnoreCase( PatientAttribute.TYPE_COMBO ) ) + { + PatientAttributeOption option = patientAttributeOptionService.get( NumberUtils.toInt( value,0 ) ); + if( option != null ) + { + patientAttributeValue = new PatientAttributeValue( patientAttribute, patient ); + patientAttributeValue.setPatientAttributeOption( option ); + patientAttributeValue.setValue( option.getName() ); + } + }else + { + patientAttributeValue = new PatientAttributeValue( patientAttribute, patient, value ); + } patientAttributeValueService.savePatientAttributeValue( patientAttributeValue ); } } @@ -146,11 +166,23 @@ { LOG.debug( "Updating PatientAttributeValue, value added/changed" ); - patientAttributeValue.setValue( value ); + if( patientAttribute.getValueType().equalsIgnoreCase( PatientAttribute.TYPE_COMBO ) ) + { + PatientAttributeOption option = patientAttributeOptionService.get( NumberUtils.toInt( value, 0 ) ); + if( option != null ) + { + patientAttributeValue.setPatientAttributeOption( option ); + patientAttributeValue.setValue( option.getName() ); + } + }else + { + patientAttributeValue.setValue( value ); + } patientAttributeValueService.updatePatientAttributeValue( patientAttributeValue ); } return SUCCESS; } + } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/ShowUpdatePatientAttributeValueAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/ShowUpdatePatientAttributeValueAction.java 2010-01-29 03:08:45 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/ShowUpdatePatientAttributeValueAction.java 2010-03-05 13:00:37 +0000 @@ -36,6 +36,7 @@ import org.hisp.dhis.patient.PatientAttribute; import org.hisp.dhis.patient.PatientAttributeGroup; import org.hisp.dhis.patient.PatientAttributeGroupService; +import org.hisp.dhis.patient.PatientAttributeService; import org.hisp.dhis.patient.PatientService; import org.hisp.dhis.patientattributevalue.PatientAttributeValue; import org.hisp.dhis.patientattributevalue.PatientAttributeValueService; @@ -60,13 +61,13 @@ this.patientService = patientService; } - // private PatientAttributeService patientAttributeService; - // - // public void setPatientAttributeService( PatientAttributeService - // patientAttributeService ) - // { - // this.patientAttributeService = patientAttributeService; - // } + private PatientAttributeService patientAttributeService; + + public void setPatientAttributeService( PatientAttributeService + patientAttributeService ) + { + this.patientAttributeService = patientAttributeService; + } private PatientAttributeGroupService patientAttributeGroupService; @@ -100,11 +101,11 @@ return patient; } - Collection patientAttributes; + Collection patientNoGroupAttributes; - public Collection getPatientAttributes() + public Collection getPatientNoGroupAttributes() { - return patientAttributes; + return patientNoGroupAttributes; } private Map patientAttributeValueMap; @@ -147,19 +148,21 @@ { patient = patientService.getPatient( id ); - if ( patientAttributeGroups == null ) +// if ( patientAttributeGroups == null ) patientAttributeGroups = patientAttributeGroupService.getAllPatientAttributeGroups(); - if ( patientAttributeGroupId != 0 ) - { - patientAttributes = new ArrayList(); - - patientAttributes = patientAttributeGroupService.getPatientAttributeGroup( - patientAttributeGroupId ).getAttributes(); - } - - // patientAttributes = - // patientAttributeService.getAllPatientAttributes(); +// if ( patientAttributeGroupId != 0 ) +// { +// patientAttributes = new ArrayList(); +// +// patientAttributes = patientAttributeGroupService.getPatientAttributeGroup( +// patientAttributeGroupId ).getAttributes(); +// }else +// { +// patientAttributes = patientAttributeService.getAllPatientAttributes(); +// } + + patientNoGroupAttributes = patientAttributeService.getPatientAttributesNotGroup(); Collection patientAttributeValues = patientAttributeValueService .getPatientAttributeValues( patient ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2010-03-03 11:02:53 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2010-03-05 13:00:37 +0000 @@ -237,11 +237,10 @@ id="org.hisp.dhis.patient.action.patientattribute.ShowUpdatePatientAttributeValueAction" class="org.hisp.dhis.patient.action.patientattribute.ShowUpdatePatientAttributeValueAction" scope="prototype"> - - + $i18n.getString( "no" ) #elseif( $attribute.valueType == "DATE" ) - - $i18n.getString( - + $i18n.getString( + + #elseif( $attribute.valueType == "COMBO" ) #elseif( $attribute.valueType == "DATE" ) - $i18n.getString( + + $rowCount + + ##attribute name + + + $encoder.htmlEncode( $patientAttribute.name ) + + + ##type + + $encoder.htmlEncode( $patientAttribute.valueType ) + + ##entry + + #if( $patientAttribute.valueType == "YES/NO" ) + + #elseif( $patientAttribute.valueType == "DATE" ) + + $i18n.getString( + + #elseif( $patientAttribute.valueType == "COMBO" ) + + #else + + #end + + + #set( $tabIndex = $tabIndex + 1 ) +#end +#end +$i18n.getString("other_attributes") +#foreach( $patientAttribute in $patientNoGroupAttributes ) + #set( $rowCount = $rowCount + 1 ) + #if( $mark == 1 ) + #set( $mark = 0 ) + #else + #set( $mark = 1 ) + #end + #set( $patientAttributeValue = false ) + #set( $patientAttributeValue = $patientAttributeValueMap.get( $patientAttribute.id ) ) + + ##rowCount + $rowCount + + ##attribute name + + + $encoder.htmlEncode( $patientAttribute.name ) + + + ##type + + $encoder.htmlEncode( $patientAttribute.valueType ) + + ##entry + + #if( $patientAttribute.valueType == "YES/NO" ) + + #elseif( $patientAttribute.valueType == "DATE" ) + + $i18n.getString( + + #elseif( $patientAttribute.valueType == "COMBO" ) + #else #end