=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Beneficiary.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Beneficiary.java 2010-11-16 16:28:41 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Beneficiary.java 2010-11-17 06:12:29 +0000 @@ -31,7 +31,7 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -import java.util.Set; +import java.util.List; public class Beneficiary implements MobileSerializable @@ -44,10 +44,22 @@ private String lastName; - private Set patientAttValues; + private int age; + + private List patientAttValues; private PatientAttribute groupAttribute; + public int getAge() + { + return age; + } + + public void setAge( int age ) + { + this.age = age; + } + public PatientAttribute getGroupAttribute() { return groupAttribute; @@ -58,12 +70,12 @@ this.groupAttribute = groupAttribute; } - public Set getPatientAttValues() + public List getPatientAttValues() { return patientAttValues; } - public void setPatientAttValues( Set patientAttValues ) + public void setPatientAttValues( List patientAttValues ) { this.patientAttValues = patientAttValues; } @@ -119,10 +131,11 @@ dout.writeUTF( this.getFirstName() ); dout.writeUTF( this.getMiddleName() ); dout.writeUTF( this.getLastName() ); - //Write attribute which is used as group factor of beneficiary. - /* False: no group factor - * True: with group factor - * */ + dout.writeInt( this.getAge() ); + // Write attribute which is used as group factor of beneficiary. + /* + * False: no group factor True: with group factor + */ if ( this.getGroupAttribute() != null ) { dout.writeBoolean( true ); @@ -133,11 +146,11 @@ dout.writeBoolean( false ); } - Set atts = this.getPatientAttValues(); + List atts = this.getPatientAttValues(); dout.writeInt( atts.size() ); - for ( String att : atts ) + for ( PatientAttribute att : atts ) { - dout.writeUTF( att ); + dout.writeUTF( att.getName() + ":" + att.getValue() ); } bout.flush(); === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/PatientAttribute.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/PatientAttribute.java 2010-11-16 16:28:41 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/PatientAttribute.java 2010-11-17 06:12:29 +0000 @@ -33,11 +33,20 @@ public class PatientAttribute implements MobileSerializable { - private String name; private String value; + public PatientAttribute( String name, String value ) + { + this.name = name; + this.value = value; + } + + public PatientAttribute() + { + } + public String getName() { return name; === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultActivityPlanService.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultActivityPlanService.java 2010-11-16 16:28:41 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultActivityPlanService.java 2010-11-17 06:12:29 +0000 @@ -1,7 +1,9 @@ package org.hisp.dhis.web.api.service; import java.util.ArrayList; +import java.util.Calendar; import java.util.Collection; +import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -161,12 +163,15 @@ Beneficiary beneficiary = new Beneficiary(); - Set patientAttValues = new HashSet(); + List patientAtts = new ArrayList(); beneficiary.setId( patient.getId() ); beneficiary.setFirstName( patient.getFirstName() ); beneficiary.setLastName( patient.getLastName() ); beneficiary.setMiddleName( patient.getMiddleName() ); + int currentYear = new Date().getYear(); + int age = currentYear - patient.getBirthDate().getYear(); + beneficiary.setAge( age ); // Set attribute which is used to group beneficiary on mobile (only if // there is attribute which is set to be group factor) @@ -184,11 +189,47 @@ patientAttribute = null; // Set all attributes - for ( PatientAttributeValue value : patientAttValueService.getPatientAttributeValues( patient ) ) - { - patientAttValues.add( value.getPatientAttribute().getName() + " : " + value.getValue() ); - } - beneficiary.setPatientAttValues( patientAttValues ); + 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 ); + + +// for ( PatientAttributeValue patientAttributeValue : +// patientAttValueService.getPatientAttributeValues( patient ) ) +// { +// patientAttValues.add( +// patientAttributeValue.getPatientAttribute().getName() + " : " +// + patientAttributeValue.getValue() ); +// } +// beneficiary.setPatientAttValues( patientAttValues ); return beneficiary; } === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultProgramService.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultProgramService.java 2010-11-16 16:28:41 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultProgramService.java 2010-11-17 06:12:29 +0000 @@ -57,12 +57,17 @@ } private CurrentUserService currentUserService; + + + public CurrentUserService getCurrentUserService() + { + return currentUserService; + } public void setCurrentUserService( CurrentUserService currentUserService ) { this.currentUserService = currentUserService; } - // ------------------------------------------------------------------------- // ProgramService // -------------------------------------------------------------------------