=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientMobileSetting.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientMobileSetting.java 2010-11-22 10:23:44 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientMobileSetting.java 2010-11-23 07:16:02 +0000 @@ -27,24 +27,25 @@ package org.hisp.dhis.patient; +import java.util.List; import java.util.Set; import org.hisp.dhis.common.IdentifiableObject; public class PatientMobileSetting extends IdentifiableObject { - private Set patientAttributes; + private List patientAttributes; public PatientMobileSetting() { } - public Set getPatientAttributes() + public List getPatientAttributes() { return patientAttributes; } - public void setPatientAttributes( Set patientAttributes ) + public void setPatientAttributes( List patientAttributes ) { this.patientAttributes = patientAttributes; } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientMobileSetting.hbm.xml' --- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientMobileSetting.hbm.xml 2010-11-22 10:23:44 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientMobileSetting.hbm.xml 2010-11-23 07:16:02 +0000 @@ -9,9 +9,10 @@ - + + - + \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/ActivityReportingServiceImpl.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/ActivityReportingServiceImpl.java 2010-11-20 08:35:36 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/ActivityReportingServiceImpl.java 2010-11-23 07:16:02 +0000 @@ -15,6 +15,8 @@ import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.patient.Patient; import org.hisp.dhis.patient.PatientAttributeService; +import org.hisp.dhis.patient.PatientMobileSetting; +import org.hisp.dhis.patient.PatientMobileSettingService; import org.hisp.dhis.patientattributevalue.PatientAttributeValue; import org.hisp.dhis.patientattributevalue.PatientAttributeValueService; import org.hisp.dhis.patientdatavalue.PatientDataValue; @@ -55,6 +57,8 @@ private org.hisp.dhis.patientdatavalue.PatientDataValueService dataValueService; private CurrentUserService currentUserService; + + private PatientMobileSettingService patientMobileSettingService; // ------------------------------------------------------------------------- // MobileDataSetService @@ -173,37 +177,49 @@ patientAttribute = null; // Set all attributes - org.hisp.dhis.patient.PatientAttribute houseName = patientAttService.getPatientAttributeByName( "House Name" ); - org.hisp.dhis.patient.PatientAttribute houseNumber = patientAttService - .getPatientAttributeByName( "House Number" ); - org.hisp.dhis.patient.PatientAttribute wardNumber = patientAttService.getPatientAttributeByName( "Ward Number" ); - org.hisp.dhis.patient.PatientAttribute nearestContact = patientAttService - .getPatientAttributeByName( "Nearest Contact Person Name" ); - - PatientAttributeValue houseNameValue = patientAttValueService.getPatientAttributeValue( patient, houseName ); - if ( houseNameValue != null ) - { - patientAtts.add( new PatientAttribute( "House Name", houseNameValue.getValue() ) ); - } - - PatientAttributeValue houseNumberValue = patientAttValueService.getPatientAttributeValue( patient, houseNumber ); - if ( houseNumberValue != null ) - { - patientAtts.add( new PatientAttribute( "House Number", houseNumberValue.getValue() ) ); - } - - PatientAttributeValue wardNumberValue = patientAttValueService.getPatientAttributeValue( patient, wardNumber ); - if ( wardNumberValue != null ) - { - patientAtts.add( new PatientAttribute( "Ward Number", wardNumberValue.getValue() ) ); - } - - PatientAttributeValue nearestContactValue = patientAttValueService.getPatientAttributeValue( patient, - nearestContact ); - if ( nearestContactValue != null ) - { - patientAtts.add( new PatientAttribute( "Nearest Contact", nearestContactValue.getValue() ) ); - } + PatientMobileSetting setting = patientMobileSettingService.getCurrentSetting()==null?null:patientMobileSettingService.getCurrentSetting().iterator().next(); + List atts; + if(setting != null){ + atts = setting.getPatientAttributes(); + for(org.hisp.dhis.patient.PatientAttribute each : atts){ + PatientAttributeValue value = patientAttValueService.getPatientAttributeValue( patient, each ); + if ( value != null ) + { + patientAtts.add( new PatientAttribute( each.getName(), value.getValue() ) ); + } + } + } +// org.hisp.dhis.patient.PatientAttribute houseName = patientAttService.getPatientAttributeByName( "House Name" ); +// org.hisp.dhis.patient.PatientAttribute houseNumber = patientAttService +// .getPatientAttributeByName( "House Number" ); +// org.hisp.dhis.patient.PatientAttribute wardNumber = patientAttService.getPatientAttributeByName( "Ward Number" ); +// org.hisp.dhis.patient.PatientAttribute nearestContact = patientAttService +// .getPatientAttributeByName( "Nearest Contact Person Name" ); + +// PatientAttributeValue houseNameValue = patientAttValueService.getPatientAttributeValue( patient, houseName ); +// if ( houseNameValue != null ) +// { +// patientAtts.add( new PatientAttribute( "House Name", houseNameValue.getValue() ) ); +// } +// +// PatientAttributeValue houseNumberValue = patientAttValueService.getPatientAttributeValue( patient, houseNumber ); +// if ( houseNumberValue != null ) +// { +// patientAtts.add( new PatientAttribute( "House Number", houseNumberValue.getValue() ) ); +// } +// +// PatientAttributeValue wardNumberValue = patientAttValueService.getPatientAttributeValue( patient, wardNumber ); +// if ( wardNumberValue != null ) +// { +// patientAtts.add( new PatientAttribute( "Ward Number", wardNumberValue.getValue() ) ); +// } +// +// PatientAttributeValue nearestContactValue = patientAttValueService.getPatientAttributeValue( patient, +// nearestContact ); +// if ( nearestContactValue != null ) +// { +// patientAtts.add( new PatientAttribute( "Nearest Contact", nearestContactValue.getValue() ) ); +// } beneficiary.setPatientAttValues( patientAtts ); @@ -386,4 +402,12 @@ this.currentUserService = currentUserService; } + @Required + public void setPatientMobileSettingService( PatientMobileSettingService patientMobileSettingService ) + { + this.patientMobileSettingService = patientMobileSettingService; + } + + + } === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml 2010-11-18 11:32:14 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml 2010-11-23 07:16:02 +0000 @@ -36,6 +36,7 @@ + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/mobilesetting/ShowMobileSettingFormAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/mobilesetting/ShowMobileSettingFormAction.java 2010-11-22 10:23:44 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/mobilesetting/ShowMobileSettingFormAction.java 2010-11-23 07:16:02 +0000 @@ -1,8 +1,10 @@ package org.hisp.dhis.patient.action.mobilesetting; +import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Set; import org.hisp.dhis.patient.PatientAttribute; @@ -46,14 +48,14 @@ // Input/Output // ------------------------------------------------------------------------- - private Set patientAtts; + private List patientAtts; - public Set getPatientAtts() + public List getPatientAtts() { return patientAtts; } - public void setPatientAtts( Set patientAtts ) + public void setPatientAtts( List patientAtts ) { this.patientAtts = patientAtts; } @@ -99,7 +101,7 @@ else { System.out.println( "Setting is null" ); - patientAtts = new HashSet(); + patientAtts = new ArrayList(); } } // System.out.println( "List " + patientAtts + " has size: " + patientAtts.size() ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/mobilesetting/UpdateMobileSettingAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/mobilesetting/UpdateMobileSettingAction.java 2010-11-22 10:23:44 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/mobilesetting/UpdateMobileSettingAction.java 2010-11-23 07:16:02 +0000 @@ -1,8 +1,9 @@ package org.hisp.dhis.patient.action.mobilesetting; +import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; -import java.util.Set; +import java.util.List; import org.hisp.dhis.patient.PatientAttribute; import org.hisp.dhis.patient.PatientAttributeService; @@ -58,13 +59,13 @@ PatientMobileSetting setting; if(patientMobileSettingService.getCurrentSetting().size()>0){ setting = patientMobileSettingService.getCurrentSetting().iterator().next(); - Set attributes = new HashSet(); + List attributes = new ArrayList(); setting.setPatientAttributes( attributes ); fillValues( attributes ); patientMobileSettingService.updatePatientMobileSetting( setting ); }else{ setting = new PatientMobileSetting(); - Set attributes = new HashSet(); + List attributes = new ArrayList(); setting.setPatientAttributes( attributes ); fillValues( attributes ); patientMobileSettingService.savePatientMobileSetting( setting ); @@ -73,13 +74,13 @@ PatientMobileSetting setting; if(patientMobileSettingService.getCurrentSetting().size()>0){ setting = patientMobileSettingService.getCurrentSetting().iterator().next(); - Set attributes = new HashSet(); + List attributes = new ArrayList(); setting.setPatientAttributes( attributes ); fillValues( attributes ); patientMobileSettingService.updatePatientMobileSetting( setting ); }else{ setting = new PatientMobileSetting(); - Set attributes = new HashSet(); + List attributes = new ArrayList(); setting.setPatientAttributes( attributes ); fillValues( attributes ); patientMobileSettingService.savePatientMobileSetting( setting ); @@ -88,7 +89,7 @@ return SUCCESS; } - private void fillValues(Set attributes){ + private void fillValues(List attributes){ for(String id : selectedList){ attributes.add( patientAttributeService.getPatientAttribute( Integer.parseInt( id )) ); }