← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13953: [mobile] re-write mobile api to support better for tracker

 

------------------------------------------------------------
revno: 13953
committer: Long <Long@Long-Laptop>
branch nick: dhis2
timestamp: Fri 2014-02-07 17:03:41 +0700
message:
  [mobile] re-write mobile api to support better for tracker
added:
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramInstance.java
modified:
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Program.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientAttribute.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java
  dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.java
  dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java	2014-01-23 14:18:27 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java	2014-02-07 10:03:41 +0000
@@ -54,13 +54,13 @@
     public void saveActivityReport( OrganisationUnit unit, ActivityValue activityValue, Integer programStageSectionId )
         throws NotAllowedException;
 
-    public Patient findPatient( String name, int orgUnitId )
+    public String findPatient( String name, int orgUnitId )
         throws NotAllowedException;
 
     public Patient findPatient( int patientId )
         throws NotAllowedException;
 
-    public Patient findPatientInAdvanced( String keyword, int orgUnitId, int programId )
+    public String findPatientInAdvanced( String keyword, int orgUnitId, int programId )
         throws NotAllowedException;
 
     public String saveProgramStage( ProgramStage programStage, int patientId, int orgUnitId )

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java	2014-01-24 08:41:50 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java	2014-02-07 10:03:41 +0000
@@ -28,13 +28,11 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.io.ByteArrayOutputStream;
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.EOFException;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.List;
 
 import org.hisp.dhis.api.mobile.model.DataStreamSerializable;
@@ -49,51 +47,22 @@
     private String clientVersion;
 
     private int id;
-
-    private String name;
-
-    private int age;
-
-    private List<PatientAttribute> attributes;
-
-    private String gender;
-
-    private String birthDate;
-
-    private Date registrationDate;
-
-    private Character dobType;
-
-    private List<Program> programs;
-
-    private List<Program> enrollmentPrograms;
-
-    private List<Relationship> relationships;
-
-    private List<Relationship> enrollmentRelationships;
-
-    private String phoneNumber;
-
+    
     private String organisationUnitName;
 
-    private List<Program> completedPrograms;
-
-    private String incidentDate;
+    private List<PatientAttribute> attributes = new ArrayList<PatientAttribute>();
+
+    private List<ProgramInstance> enrollmentPrograms = new ArrayList<ProgramInstance>();
+
+    private List<ProgramInstance> completedPrograms = new ArrayList<ProgramInstance>();
+
+    private List<Relationship> relationships = new ArrayList<Relationship>();
+
 
     // -------------------------------------------------------------------------
     // Getters and setters
     // -------------------------------------------------------------------------
 
-    public List<Program> getPrograms()
-    {
-        return programs;
-    }
-
-    public void setPrograms( List<Program> programs )
-    {
-        this.programs = programs;
-    }
-
     public List<Relationship> getRelationships()
     {
         return relationships;
@@ -104,66 +73,6 @@
         this.relationships = relationships;
     }
 
-    public List<Program> getEnrollmentPrograms()
-    {
-        return enrollmentPrograms;
-    }
-
-    public void setEnrollmentPrograms( List<Program> enrollmentPrograms )
-    {
-        this.enrollmentPrograms = enrollmentPrograms;
-    }
-
-    public int getAge()
-    {
-        return age;
-    }
-
-    public String getGender()
-    {
-        return gender;
-    }
-
-    public void setGender( String gender )
-    {
-        this.gender = gender;
-    }
-
-    public String getBirthDate()
-    {
-        return birthDate;
-    }
-
-    public void setBirthDate( String birthDate )
-    {
-        this.birthDate = birthDate;
-    }
-
-    public Date getRegistrationDate()
-    {
-        return registrationDate;
-    }
-
-    public void setRegistrationDate( Date registrationDate )
-    {
-        this.registrationDate = registrationDate;
-    }
-
-    public Character getDobType()
-    {
-        return dobType;
-    }
-
-    public void setDobType( Character dobType )
-    {
-        this.dobType = dobType;
-    }
-
-    public void setAge( int age )
-    {
-        this.age = age;
-    }
-
     public List<PatientAttribute> getAttributes()
     {
         return attributes;
@@ -184,16 +93,6 @@
         this.id = id;
     }
 
-    public String getName()
-    {
-        return name;
-    }
-
-    public void setName( String name )
-    {
-        this.name = name;
-    }
-
     public String getClientVersion()
     {
         return clientVersion;
@@ -204,26 +103,6 @@
         this.clientVersion = clientVersion;
     }
 
-    public String getPhoneNumber()
-    {
-        return phoneNumber;
-    }
-
-    public void setPhoneNumber( String phoneNumber )
-    {
-        this.phoneNumber = phoneNumber;
-    }
-
-    public List<Relationship> getEnrollmentRelationships()
-    {
-        return enrollmentRelationships;
-    }
-
-    public void setEnrollmentRelationships( List<Relationship> enrollmentRelationships )
-    {
-        this.enrollmentRelationships = enrollmentRelationships;
-    }
-
     public String getOrganisationUnitName()
     {
         return organisationUnitName;
@@ -233,136 +112,58 @@
     {
         this.organisationUnitName = organisationUnitName;
     }
-
-    public List<Program> getCompletedPrograms()
+    
+    public List<ProgramInstance> getEnrollmentPrograms()
+    {
+        return enrollmentPrograms;
+    }
+
+    public void setEnrollmentPrograms( List<ProgramInstance> enrollmentPrograms )
+    {
+        this.enrollmentPrograms = enrollmentPrograms;
+    }
+
+    public List<ProgramInstance> getCompletedPrograms()
     {
         return completedPrograms;
     }
 
-    public void setCompletedPrograms( List<Program> completedPrograms )
+    public void setCompletedPrograms( List<ProgramInstance> completedPrograms )
     {
         this.completedPrograms = completedPrograms;
     }
 
-    public String getIncidentDate()
-    {
-        return incidentDate;
-    }
-
-    public void setIncidentDate( String incidentDate )
-    {
-        this.incidentDate = incidentDate;
-    }
-
     // -------------------------------------------------------------------------
     // Override Methods
     // -------------------------------------------------------------------------
 
     @Override
-    public void serialize( DataOutputStream out )
+    public void serialize( DataOutputStream dout )
         throws IOException
     {
-        ByteArrayOutputStream bout = new ByteArrayOutputStream();
-        DataOutputStream dout = new DataOutputStream( bout );
+//        ByteArrayOutputStream bout = new ByteArrayOutputStream();
+//        DataOutputStream dout = new DataOutputStream( bout );
 
         dout.writeInt( this.getId() );
-
-        if ( name != null )
-        {
-            dout.writeBoolean( true );
-            dout.writeUTF( name );
-        }
-        else
-        {
-            dout.writeBoolean( false );
-        }
-        if ( organisationUnitName != null )
-        {
-            dout.writeBoolean( true );
-            dout.writeUTF( organisationUnitName );
-        }
-        else
-        {
-            dout.writeBoolean( false );
-        }
-
-        if ( gender != null )
-        {
-            dout.writeBoolean( true );
-            dout.writeUTF( gender );
-        }
-        else
-        {
-            dout.writeBoolean( false );
-        }
-
-        if ( dobType != null )
-        {
-            dout.writeBoolean( true );
-            dout.writeChar( dobType );
-        }
-        else
-        {
-            dout.writeBoolean( false );
-        }
-
-        if ( birthDate != null )
-        {
-            dout.writeBoolean( true );
-            dout.writeUTF( birthDate );
-        }
-        else
-        {
-            dout.writeBoolean( false );
-        }
-
-        if ( registrationDate != null )
-        {
-            dout.writeBoolean( true );
-            dout.writeLong( registrationDate.getTime() );
-        }
-        else
-        {
-            dout.writeBoolean( false );
-        }
-
-        if ( incidentDate != null )
-        {
-            dout.writeBoolean( true );
-            dout.writeUTF( incidentDate );
-        }
-        else
-        {
-            dout.writeBoolean( false );
-        }
-
-        if ( phoneNumber != null )
-        {
-            dout.writeBoolean( true );
-            dout.writeUTF( phoneNumber );
-        }
-        else
-        {
-            dout.writeBoolean( false );
-        }
+        dout.writeUTF( this.getOrganisationUnitName() );
 
         // Write Patient Attribute
-        if ( attributes != null )
-        {
-            dout.writeInt( attributes.size() );
-            for ( PatientAttribute patientAtt : attributes )
-            {
-                patientAtt.serialize( dout );
-            }
-        }
-        else
-        {
-            dout.writeInt( 0 );
-        }
-
-        // Write Programs
-        dout.writeInt( programs.size() );
-        for ( Program each : programs )
+        dout.writeInt( attributes.size() );
+        for ( PatientAttribute patientAtt : attributes )
+        {
+            patientAtt.serialize( dout );
+        }
+
+        // Write Enrollment Programs
+        dout.writeInt( enrollmentPrograms.size() );
+        for ( ProgramInstance program : enrollmentPrograms )
+        {
+            program.serialize( dout );
+        }
+
+        // Write completed Programs
+        dout.writeInt( completedPrograms.size() );
+        for ( ProgramInstance each : completedPrograms )
         {
             each.serialize( dout );
         }
@@ -374,31 +175,8 @@
             each.serialize( dout );
         }
 
-        // Write Enrolled Programs
-
-        dout.writeInt( enrollmentPrograms.size() );
-        for ( Program each : enrollmentPrograms )
-        {
-            each.serialize( dout );
-        }
-
-        // Write Enrolled Relationships
-
-        dout.writeInt( enrollmentRelationships.size() );
-        for ( Relationship each : enrollmentRelationships )
-        {
-            each.serialize( dout );
-        }
-
-        // Write completed Programs
-        dout.writeInt( completedPrograms.size() );
-        for ( Program each : completedPrograms )
-        {
-            each.serialize( dout );
-        }
-
-        bout.flush();
-        bout.writeTo( out );
+//        bout.flush();
+//        bout.writeTo( out );
     }
 
     @Override
@@ -406,88 +184,9 @@
         throws IOException, EOFException
     {
         this.setId( din.readInt() );
-
-        if ( din.readBoolean() )
-        {
-            this.setName( din.readUTF() );
-        }
-        else
-        {
-            this.setName( null );
-        }
-
-        // Org Name
-        if ( din.readBoolean() )
-        {
-            this.setOrganisationUnitName( din.readUTF() );
-        }
-        else
-        {
-            this.setOrganisationUnitName( null );
-        }
-
-        // Gender
-        if ( din.readBoolean() )
-        {
-            this.setGender( din.readUTF() );
-        }
-        else
-        {
-            this.setGender( null );
-        }
-
-        // DOB Type
-        if ( din.readBoolean() )
-        {
-            char dobTypeDeserialized = din.readChar();
-            this.setDobType( Character.valueOf( dobTypeDeserialized ) );
-        }
-        else
-        {
-            this.setDobType( null );
-        }
-
-        // DOB
-        if ( din.readBoolean() )
-        {
-            this.setBirthDate( din.readUTF() );
-        }
-        else
-        {
-            this.setBirthDate( null );
-        }
-
-        // Registration Date
-        if ( din.readBoolean() )
-        {
-            this.setRegistrationDate( new Date( din.readLong() ) );
-        }
-        else
-        {
-            this.setRegistrationDate( null );
-        }
-
-        // Incident Date
-        if ( din.readBoolean() )
-        {
-            this.setIncidentDate( din.readUTF() );
-        }
-        else
-        {
-            this.setIncidentDate( null );
-        }
-
-        // Phone Number
-        if ( din.readBoolean() )
-        {
-            this.setPhoneNumber( din.readUTF() );
-        }
-        else
-        {
-            this.setPhoneNumber( null );
-        }
-
-        // Patient Attribute & Identifiers
+        this.setOrganisationUnitName( din.readUTF() );
+
+        // Read Attribute
         int attsNumb = din.readInt();
         if ( attsNumb > 0 )
         {
@@ -499,90 +198,44 @@
                 attributes.add( pa );
             }
         }
-        else
-        {
-            attributes = null;
-        }
-
-        // Program & Relationship
-        int numbPrograms = din.readInt();
-        if ( numbPrograms > 0 )
-        {
-            this.programs = new ArrayList<Program>();
-            for ( int i = 0; i < numbPrograms; i++ )
-            {
-                Program program = new Program();
-                program.deSerialize( din );
-                this.programs.add( program );
-            }
-        }
-        else
-        {
-            this.programs = null;
-        }
-
-        int numbRelationships = din.readInt();
-        if ( numbRelationships > 0 )
-        {
-            this.relationships = new ArrayList<Relationship>();
-            for ( int i = 0; i < numbRelationships; i++ )
-            {
-                Relationship relationship = new Relationship();
-                relationship.deSerialize( din );
-                this.relationships.add( relationship );
-            }
-        }
-        else
-        {
-            this.relationships = null;
-        }
-
+
+        // Read enrollment programs
         int numbEnrollmentPrograms = din.readInt();
         if ( numbEnrollmentPrograms > 0 )
         {
-            this.enrollmentPrograms = new ArrayList<Program>();
+            this.enrollmentPrograms = new ArrayList<ProgramInstance>();
             for ( int i = 0; i < numbEnrollmentPrograms; i++ )
             {
-                Program program = new Program();
+                ProgramInstance program = new ProgramInstance();
                 program.deSerialize( din );
                 this.enrollmentPrograms.add( program );
             }
         }
-        else
-        {
-            this.enrollmentPrograms = null;
-        }
-
-        int numbEnrollmentRelationships = din.readInt();
-        if ( numbEnrollmentRelationships > 0 )
-        {
-            this.enrollmentRelationships = new ArrayList<Relationship>();
-            for ( int i = 0; i < numbEnrollmentRelationships; i++ )
-            {
-                Relationship relationship = new Relationship();
-                relationship.deSerialize( din );
-                this.enrollmentRelationships.add( relationship );
-            }
-        }
-        else
-        {
-            this.enrollmentRelationships = null;
-        }
-
+
+        // Read completed programs
         int numbCompletedPrograms = din.readInt();
         if ( numbCompletedPrograms > 0 )
         {
-            this.completedPrograms = new ArrayList<Program>();
+            this.completedPrograms = new ArrayList<ProgramInstance>();
             for ( int i = 0; i < numbCompletedPrograms; i++ )
             {
-                Program program = new Program();
+                ProgramInstance program = new ProgramInstance();
                 program.deSerialize( din );
                 this.completedPrograms.add( program );
             }
         }
-        else
+
+        // Read relationships
+        int numbRelationships = din.readInt();
+        if ( numbRelationships > 0 )
         {
-            this.completedPrograms = null;
+            this.relationships = new ArrayList<Relationship>();
+            for ( int i = 0; i < numbRelationships; i++ )
+            {
+                Relationship relationship = new Relationship();
+                relationship.deSerialize( din );
+                this.relationships.add( relationship );
+            }
         }
     }
 
@@ -604,59 +257,10 @@
             return false;
         }
 
-        final Patient otherPatient = (Patient) otherObject;
-
-        if ( birthDate == null )
-        {
-            if ( otherPatient.birthDate != null )
-            {
-                return false;
-            }
-        }
-        else if ( !birthDate.equals( otherPatient.birthDate ) )
-        {
-            return false;
-        }
-
-        if ( name == null )
-        {
-            if ( otherPatient.name != null )
-            {
-                return false;
-            }
-        }
-        else if ( !name.equals( otherPatient.name ) )
-        {
-            return false;
-        }
-
-        if ( gender == null )
-        {
-            if ( otherPatient.gender != null )
-                return false;
-        }
-        else if ( !gender.equals( otherPatient.gender ) )
-        {
-            return false;
-        }
-
         return true;
     }
 
     @Override
-    public int hashCode()
-    {
-        final int prime = 31;
-        int result = 1;
-
-        result = prime * result + ((birthDate == null) ? 0 : birthDate.hashCode());
-        result = prime * result + ((name == null) ? 0 : name.hashCode());
-        result = prime * result + ((gender == null) ? 0 : gender.hashCode());
-
-        return result;
-    }
-
-    @Override
     public void serializeVersion2_8( DataOutputStream out )
         throws IOException
     {

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Program.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Program.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Program.java	2014-02-07 10:03:41 +0000
@@ -31,9 +31,11 @@
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 
 import org.hisp.dhis.api.mobile.model.Model;
+import org.hisp.dhis.api.mobile.model.PatientAttribute;
 
 /**
  * @author Nguyen Kim Lai
@@ -41,23 +43,24 @@
 public class Program
     extends Model
 {
+    // Work as Program and ProgramInstance
     private String clientVersion;
-    
+
     private int version;
-    
-    private Integer status;
-
-    public Integer getStatus()
-    {
-        return status;
-    }
-
-    public void setStatus( Integer status )
-    {
-        this.status = status;
-    }
-
-    private List<ProgramStage> programStages;
+
+    // multiple event with registration: 1
+    // single event with registration: 2
+    // single event without registration: 3
+
+    private Integer type;
+
+    private String dateOfEnrollmentDescription = "Date of Enrollment";
+
+    private String dateOfIncidentDescription = "Date of Incident";
+
+    private List<ProgramStage> programStages = new ArrayList<ProgramStage>();
+
+    private List<PatientAttribute> programAttributes = new ArrayList<PatientAttribute>();
 
     public List<ProgramStage> getProgramStages()
     {
@@ -78,7 +81,7 @@
     {
         this.version = version;
     }
-    
+
     public String getClientVersion()
     {
         return clientVersion;
@@ -89,33 +92,106 @@
         this.clientVersion = clientVersion;
     }
 
+    public Integer getType()
+    {
+        return type;
+    }
+
+    public void setType( Integer type )
+    {
+        this.type = type;
+    }
+
+    public String getDateOfEnrollmentDescription()
+    {
+        return dateOfEnrollmentDescription;
+    }
+
+    public void setDateOfEnrollmentDescription( String dateOfEnrollmentDescription )
+    {
+        this.dateOfEnrollmentDescription = dateOfEnrollmentDescription;
+    }
+
+    public String getDateOfIncidentDescription()
+    {
+        return dateOfIncidentDescription;
+    }
+
+    public void setDateOfIncidentDescription( String dateOfIncidentDescription )
+    {
+        this.dateOfIncidentDescription = dateOfIncidentDescription;
+    }
+
+    public List<PatientAttribute> getProgramAttributes()
+    {
+        return programAttributes;
+    }
+
+    public void setProgramAttributes( List<PatientAttribute> programAttributes )
+    {
+        this.programAttributes = programAttributes;
+    }
 
     @Override
     public void serialize( DataOutputStream dout )
         throws IOException
     {
         super.serialize( dout );
-        dout.writeInt( getStatus() );
         dout.writeInt( getVersion() );
-        if( programStages == null )
-        {
-            dout.writeInt( 0 );
-        }
-        else
-        {
-            dout.writeInt( programStages.size() );
-            for ( int i = 0; i < programStages.size(); i++ )
-            {
-                ProgramStage ps = programStages.get( i );
-                ps.serialize( dout );
-            }
-        }
+        dout.writeInt( this.getType() );
+        dout.writeUTF( getDateOfEnrollmentDescription() );
+        dout.writeUTF( getDateOfIncidentDescription() );
+
+        // Write program stage
+        dout.writeInt( programStages.size() );
+        for ( int i = 0; i < programStages.size(); i++ )
+        {
+            ProgramStage ps = programStages.get( i );
+            ps.serialize( dout );
+        }
+
+        // Write program attribute
+        dout.writeInt( programAttributes.size() );
+        for ( int i = 0; i < programAttributes.size(); i++ )
+        {
+            PatientAttribute pa = programAttributes.get( i );
+            pa.serialize( dout );
+        }
+
     }
 
     @Override
     public void deSerialize( DataInputStream dataInputStream )
         throws IOException
     {
-        // FIXME: Get implementation from client
+        super.deSerialize( dataInputStream );
+        this.setVersion( dataInputStream.readInt() );
+        this.setType( dataInputStream.readInt() );
+        this.setDateOfEnrollmentDescription( dataInputStream.readUTF() );
+        this.setDateOfIncidentDescription( dataInputStream.readUTF() );
+
+        // Read program stage
+        int programStageNumber = dataInputStream.readInt();
+        if ( programStageNumber > 0 )
+        {
+            for ( int i = 0; i < programStageNumber; i++ )
+            {
+                ProgramStage programStage = new ProgramStage();
+                programStage.deSerialize( dataInputStream );
+                programStages.add( programStage );
+            }
+        }
+
+        // Read program attribute
+        int programAttSize = dataInputStream.readInt();
+        if ( programAttSize > 0 )
+        {
+            for ( int i = 0; i < programAttSize; i++ )
+            {
+                PatientAttribute pa = new PatientAttribute();
+                pa.deSerialize( dataInputStream );
+                programAttributes.add( pa );
+            }
+        }
     }
 }

=== added file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramInstance.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramInstance.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramInstance.java	2014-02-07 10:03:41 +0000
@@ -0,0 +1,180 @@
+package org.hisp.dhis.api.mobile.model.LWUITmodel;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hisp.dhis.api.mobile.model.DataStreamSerializable;
+
+public class ProgramInstance
+    implements DataStreamSerializable
+{
+    private Integer id;
+
+    private Integer patientId;
+
+    private Integer programId;
+    
+    private String name;
+
+    // status active = 0
+    // status complete = 1
+    // status canceled = 2
+    private Integer status;
+
+    private String dateOfEnrollment;
+
+    private String dateOfIncident;
+
+    private List<ProgramStage> programStageInstances = new ArrayList<ProgramStage>();
+
+    public Integer getId()
+    {
+        return id;
+    }
+
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+
+    public Integer getPatientId()
+    {
+        return patientId;
+    }
+
+    public void setPatientId( Integer patientId )
+    {
+        this.patientId = patientId;
+    }
+
+    public Integer getProgramId()
+    {
+        return programId;
+    }
+
+    public void setProgramId( Integer programId )
+    {
+        this.programId = programId;
+    }
+
+    public Integer getStatus()
+    {
+        return status;
+    }
+
+    public void setStatus( Integer status )
+    {
+        this.status = status;
+    }
+
+    public String getDateOfEnrollment()
+    {
+        return dateOfEnrollment;
+    }
+
+    public void setDateOfEnrollment( String dateOfEnrollment )
+    {
+        this.dateOfEnrollment = dateOfEnrollment;
+    }
+
+    public String getDateOfIncident()
+    {
+        return dateOfIncident;
+    }
+
+    public void setDateOfIncident( String dateOfIncident )
+    {
+        this.dateOfIncident = dateOfIncident;
+    }
+
+    public List<ProgramStage> getProgramStageInstances()
+    {
+        return programStageInstances;
+    }
+
+    public void setProgramStageInstances( List<ProgramStage> programStageInstances )
+    {
+        this.programStageInstances = programStageInstances;
+    }
+    
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+    @Override
+    public void serialize( DataOutputStream dataOutputStream )
+        throws IOException
+    {
+        dataOutputStream.writeInt( this.getId() );
+        dataOutputStream.writeInt( this.getPatientId() );
+        dataOutputStream.writeInt( this.getProgramId() );
+        dataOutputStream.writeUTF( this.getName() );
+        dataOutputStream.writeInt( this.getStatus() );
+        dataOutputStream.writeUTF( this.getDateOfEnrollment() );
+        dataOutputStream.writeUTF( this.getDateOfIncident() );
+
+        dataOutputStream.writeInt( programStageInstances.size() );
+        for ( ProgramStage programStageInstance : programStageInstances )
+        {
+            programStageInstance.serialize( dataOutputStream );
+        }
+
+    }
+
+    @Override
+    public void deSerialize( DataInputStream dataInputStream )
+        throws IOException
+    {
+        this.setId( dataInputStream.readInt() );
+        this.setPatientId( dataInputStream.readInt() );
+        this.setProgramId( dataInputStream.readInt() );
+        this.setName( dataInputStream.readUTF() );
+        this.setStatus( dataInputStream.readInt() );
+        this.setDateOfEnrollment( dataInputStream.readUTF() );
+        this.setDateOfIncident( dataInputStream.readUTF() );
+
+        // Read programstage instance
+        int programStageInstanceSize = dataInputStream.readInt();
+        for ( int i = 0; i < programStageInstanceSize; i++ )
+        {
+            ProgramStage programStageInstance = new ProgramStage();
+            programStageInstance.deSerialize( dataInputStream );
+            programStageInstances.add( programStageInstance );
+        }
+
+    }
+
+    @Override
+    public void serializeVersion2_8( DataOutputStream dataOutputStream )
+        throws IOException
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void serializeVersion2_9( DataOutputStream dataOutputStream )
+        throws IOException
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void serializeVersion2_10( DataOutputStream dataOutputStream )
+        throws IOException
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+}

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientAttribute.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientAttribute.java	2013-09-16 17:07:25 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientAttribute.java	2014-02-07 10:03:41 +0000
@@ -47,17 +47,22 @@
 
     private String type;
 
+    private boolean isMandatory;
+    
+    private boolean isDisplayedInList = false;
+
     private List<String> predefinedValues = new ArrayList<String>();
 
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
 
-    public PatientAttribute( String name, String value, String type, List<String> predefinedValues )
+    public PatientAttribute( String name, String value, String type, boolean isMandatory, List<String> predefinedValues )
     {
         this.name = name;
         this.value = value;
         this.type = type;
+        this.isMandatory = isMandatory;
         this.predefinedValues = predefinedValues;
     }
 
@@ -121,6 +126,26 @@
         this.predefinedValues = predefinedValues;
     }
 
+    public boolean isMandatory()
+    {
+        return isMandatory;
+    }
+
+    public void setMandatory( boolean isMandatory )
+    {
+        this.isMandatory = isMandatory;
+    }
+    
+    public boolean isDisplayedInList()
+    {
+        return isDisplayedInList;
+    }
+
+    public void setDisplayedInList( boolean isDisplayedInList )
+    {
+        this.isDisplayedInList = isDisplayedInList;
+    }
+
     @Override
     public void serialize( DataOutputStream dout )
         throws IOException
@@ -128,6 +153,8 @@
         dout.writeUTF( this.name );
         dout.writeUTF( this.value );
         dout.writeUTF( this.type );
+        dout.writeBoolean( this.isMandatory );
+        dout.writeBoolean( this.isDisplayedInList );
 
         int valueSize = this.predefinedValues.size();
         dout.writeInt( valueSize );
@@ -148,6 +175,8 @@
         name = dataInputStream.readUTF();
         value = dataInputStream.readUTF();
         type = dataInputStream.readUTF();
+        isMandatory = dataInputStream.readBoolean();
+        isDisplayedInList = dataInputStream.readBoolean();
 
         List<String> optionList = new ArrayList<String>();
 

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2014-01-24 08:41:50 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2014-02-07 10:03:41 +0000
@@ -407,44 +407,35 @@
     }
 
     @Override
-    public org.hisp.dhis.api.mobile.model.LWUITmodel.Patient findPatient( String keyword, int orgUnitId )
+    public String findPatient( String keyword, int orgUnitId )
         throws NotAllowedException
     {
-        if ( isNumber( keyword ) == false )
-        {
-            List<Patient> patients = new ArrayList<Patient>();
-
-            if ( patients.size() > 1 )
-            {
-                String patientsInfo = "";
-
-                for ( Patient each : patients )
-                {
-                    patientsInfo += each.getId() + "/" + each.getName() + "$";
-                }
-
-                throw new NotAllowedException( patientsInfo );
-            }
-            else if ( patients.size() == 0 )
-            {
-                throw NotAllowedException.NO_BENEFICIARY_FOUND;
-            }
-            else
-            {
-                org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patientMobile = getPatientModel( patients.get( 0 ) );
-
-                return patientMobile;
-            }
-        }
-        else
-        {
-            Patient patient = patientService.getPatient( Integer.parseInt( keyword ) );
-
-            org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patientMobile = getPatientModel( patient );
-
-            return patientMobile;
-        }
-
+        Collection<Patient> patients = patientAttValueService.getPatient( null, keyword );
+
+        if ( patients.size() == 0 )
+        {
+            throw NotAllowedException.NO_BENEFICIARY_FOUND;
+        }
+
+        Collection<org.hisp.dhis.patient.PatientAttribute> displayAttributes = patientAttributeService
+            .getPatientAttributesDisplayed( true );
+        String resultSet = "";
+
+        for ( Patient patient : patients )
+        {
+            resultSet += patient.getId() + "/";
+            String attText = "";
+            for ( org.hisp.dhis.patient.PatientAttribute displayAttribute : displayAttributes )
+            {
+                PatientAttributeValue value = patientAttValueService.getPatientAttributeValue( patient,
+                    displayAttribute );
+                attText += value + " ";
+            }
+            attText = attText.trim();
+            resultSet += attText + "$";
+        }
+
+        return resultSet;
     }
 
     @Override
@@ -458,8 +449,6 @@
             ProgramStageInstance prStageInstance = programStageInstanceService
                 .getProgramStageInstance( mobileProgramStage.getId() );
             ProgramStage programStage = programStageService.getProgramStage( prStageInstance.getProgramStage().getId() );
-            // ProgramStage programStage = programStageService.getProgramStage(
-            // mobileProgramStage.getId() );
             OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
 
             // ---------------------------------------------------------------------
@@ -523,23 +512,6 @@
             ProgramStageInstance programStageInstance = programStageInstanceService
                 .getProgramStageInstance( mobileProgramStage.getId() );
 
-            /*
-             * //Begin Changes ProgramStage programStage =
-             * programStageService.getProgramStage( mobileProgramStage.getId()
-             * ); Patient patient = patientService.getPatient( patientId );
-             * Program program = programStage.getProgram();
-             * 
-             * Collection<ProgramInstance> programInstances =
-             * programInstanceService.getProgramInstances( patient, program );
-             * ProgramStageInstance programStageInstance = null; for (
-             * ProgramInstance each : programInstances ) { if(
-             * each.getStatus()==ProgramInstance.STATUS_ACTIVE ) {
-             * programStageInstance =
-             * programStageInstanceService.getProgramStageInstance( each,
-             * programStage ); break; } }
-             * 
-             * //End Changes
-             */
             List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement> dataElements = mobileProgramStage
                 .getDataElements();
 
@@ -751,8 +723,9 @@
                 PatientAttributeValue value = patientAttValueService.getPatientAttributeValue( patient, each );
                 if ( value != null )
                 {
-                    patientAtts.add( new PatientAttribute( each.getName(), value.getValue(), each.getValueType(),
-                        new ArrayList<String>() ) );
+                    // patientAtts.add( new PatientAttribute( each.getName(),
+                    // value.getValue(), each.getValueType(),
+                    // new ArrayList<String>() ) );
                 }
             }
 
@@ -779,26 +752,14 @@
     private org.hisp.dhis.api.mobile.model.LWUITmodel.Patient getPatientModel( Patient patient )
     {
         org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patientModel = new org.hisp.dhis.api.mobile.model.LWUITmodel.Patient();
-
         List<PatientAttribute> patientAtts = new ArrayList<PatientAttribute>();
 
-        List<org.hisp.dhis.api.mobile.model.LWUITmodel.Program> mobileProgramList = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.Program>();
-
-        List<org.hisp.dhis.api.mobile.model.LWUITmodel.Program> mobileCompletedProgramList = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.Program>();
-
-        List<org.hisp.dhis.patient.PatientAttribute> atts;
+        List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramInstance> mobileProgramInstanceList = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramInstance>();
+
+        List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramInstance> mobileCompletedProgramInstanceList = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramInstance>();
 
         patientModel.setId( patient.getId() );
 
-        if ( patient.getName() != null )
-        {
-            patientModel.setName( patient.getName() );
-        }
-
-        /*
-         * DateFormat dateFormat = new SimpleDateFormat( "dd-MM-yyyy" );
-         * patientModel.setAge( dateFormat.format( patient.getBirthDate() ) );
-         */
         if ( patient.getOrganisationUnit() != null )
         {
             patientModel.setOrganisationUnitName( patient.getOrganisationUnit().getName() );
@@ -806,17 +767,23 @@
 
         this.setSetting( getSettings() );
 
-        if ( setting != null )
+        List<PatientAttributeValue> atts = new ArrayList<PatientAttributeValue>(
+            patientAttValueService.getPatientAttributeValues( patient ) );
+
+        Set<org.hisp.dhis.patient.PatientAttribute> displayAttributes = new HashSet<org.hisp.dhis.patient.PatientAttribute>(
+            patientAttributeService.getPatientAttributesDisplayed( true ) );
+
+        for ( PatientAttributeValue value : atts )
         {
-            atts = setting.getPatientAttributes();
-            for ( org.hisp.dhis.patient.PatientAttribute each : atts )
+            if ( value != null )
             {
-                PatientAttributeValue value = patientAttValueService.getPatientAttributeValue( patient, each );
-                if ( value != null )
+                PatientAttribute patientAttribute = new PatientAttribute( value.getPatientAttribute().getName(),
+                    value.getValue(), value.getPatientAttribute().getValueType(), false, new ArrayList<String>() );
+                if ( displayAttributes.contains( value.getPatientAttribute() ) )
                 {
-                    patientAtts.add( new PatientAttribute( each.getName(), value.getValue(), each.getValueType(),
-                        new ArrayList<String>() ) );
+                    patientAttribute.setDisplayedInList( true );
                 }
+                patientAtts.add( patientAttribute );
             }
         }
 
@@ -830,10 +797,10 @@
         {
             for ( ProgramInstance each : listOfProgramInstance )
             {
-                mobileProgramList.add( getMobileProgram( each ) );
+                mobileProgramInstanceList.add( getMobileProgramInstance( each ) );
             }
         }
-        patientModel.setPrograms( mobileProgramList );
+        patientModel.setEnrollmentPrograms( mobileProgramInstanceList );
 
         // Set completed programs
         List<ProgramInstance> listOfCompletedProgramInstance = new ArrayList<ProgramInstance>(
@@ -843,31 +810,11 @@
         {
             for ( ProgramInstance each : listOfCompletedProgramInstance )
             {
-                mobileCompletedProgramList.add( getMobileProgram( each ) );
+                mobileCompletedProgramInstanceList.add( getMobileProgramInstance( each ) );
             }
         }
-        patientModel.setCompletedPrograms( mobileCompletedProgramList );
 
-        /*
-         * List<Integer> mobileProgramIDList = new ArrayList<Integer>(); for (
-         * Program eachProgram : patient.getPrograms()) {
-         * mobileProgramIDList.add( eachProgram.getId() ); }
-         * patientModel.setProgramsID( mobileProgramIDList );
-         * 
-         * // Set patient Data value for off-line storage function Map<Integer,
-         * String> patientDataValues = new HashMap<Integer, String>(); for (
-         * ProgramInstance eachProgramInstance :
-         * programInstanceService.getProgramInstances( patient,
-         * ProgramInstance.STATUS_ACTIVE ) ) { for ( ProgramStageInstance
-         * eachProgramStageInstance :
-         * eachProgramInstance.getProgramStageInstances() ) { for (
-         * PatientDataValue each : patientDataValueService.getPatientDataValues(
-         * eachProgramStageInstance ) ) { if( each.getValue() != null &&
-         * !each.getValue().isEmpty()) { Integer dataElementID =
-         * each.getDataElement().getId(); String value = each.getValue();
-         * patientDataValues.put( dataElementID, value ); } } } }
-         * patientModel.setPatientDataValues( patientDataValues );
-         */
+        patientModel.setCompletedPrograms( mobileCompletedProgramInstanceList );
 
         // Set Relationship
         List<Relationship> relationships = new ArrayList<Relationship>(
@@ -894,49 +841,46 @@
         }
         patientModel.setRelationships( relationshipList );
 
-        // Set available enrollment programs
-         List<Program> enrollmentProgramList = generateEnrollmentProgramList( patient );
-        List<org.hisp.dhis.api.mobile.model.LWUITmodel.Program> enrollmentProgramListMobileList = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.Program>();
-
-        for ( Program enrollmentProgram : enrollmentProgramList )
-        {
-            org.hisp.dhis.api.mobile.model.LWUITmodel.Program enrollmentProgramMobile = new org.hisp.dhis.api.mobile.model.LWUITmodel.Program();
-            enrollmentProgramMobile.setId( enrollmentProgram.getId() );
-            enrollmentProgramMobile.setName( enrollmentProgram.getName() );
-            enrollmentProgramMobile.setStatus( ProgramInstance.STATUS_ACTIVE );
-            enrollmentProgramMobile.setVersion( enrollmentProgram.getVersion() );
-            enrollmentProgramMobile.setProgramStages( null );
-            enrollmentProgramListMobileList.add( enrollmentProgramMobile );
-        }
-        patientModel.setEnrollmentPrograms( enrollmentProgramListMobileList );
-
         // Set available enrollment relationships
-        List<RelationshipType> enrollmentRelationshipList = new ArrayList<RelationshipType>(
-            relationshipTypeService.getAllRelationshipTypes() );
-        List<org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship> enrollmentRelationshipMobileList = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship>();
-        for ( RelationshipType enrollmentRelationship : enrollmentRelationshipList )
-        {
-            org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship enrollmentRelationshipMobile = new org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship();
-            enrollmentRelationshipMobile.setId( enrollmentRelationship.getId() );
-            enrollmentRelationshipMobile.setName( enrollmentRelationship.getName() );
-            enrollmentRelationshipMobile.setaIsToB( enrollmentRelationship.getaIsToB() );
-            enrollmentRelationshipMobile.setbIsToA( enrollmentRelationship.getbIsToA() );
-            enrollmentRelationshipMobileList.add( enrollmentRelationshipMobile );
-        }
-        patientModel.setEnrollmentRelationships( enrollmentRelationshipMobileList );
+        // List<RelationshipType> enrollmentRelationshipList = new
+        // ArrayList<RelationshipType>(
+        // relationshipTypeService.getAllRelationshipTypes() );
+        // List<org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship>
+        // enrollmentRelationshipMobileList = new
+        // ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship>();
+        // for ( RelationshipType enrollmentRelationship :
+        // enrollmentRelationshipList )
+        // {
+        // org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship
+        // enrollmentRelationshipMobile = new
+        // org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship();
+        // enrollmentRelationshipMobile.setId( enrollmentRelationship.getId() );
+        // enrollmentRelationshipMobile.setName(
+        // enrollmentRelationship.getName() );
+        // enrollmentRelationshipMobile.setaIsToB(
+        // enrollmentRelationship.getaIsToB() );
+        // enrollmentRelationshipMobile.setbIsToA(
+        // enrollmentRelationship.getbIsToA() );
+        // enrollmentRelationshipMobileList.add( enrollmentRelationshipMobile );
+        // }
+        // patientModel.setRelationships( enrollmentRelationshipMobileList );
         return patientModel;
     }
 
-    private org.hisp.dhis.api.mobile.model.LWUITmodel.Program getMobileProgram( ProgramInstance programInstance )
+    private org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramInstance getMobileProgramInstance(
+        ProgramInstance programInstance )
     {
-        org.hisp.dhis.api.mobile.model.LWUITmodel.Program mobileProgram = new org.hisp.dhis.api.mobile.model.LWUITmodel.Program();
+        org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramInstance mobileProgramInstance = new org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramInstance();
 
-        mobileProgram.setVersion( programInstance.getProgram().getVersion() );
-        mobileProgram.setId( programInstance.getId() );
-        mobileProgram.setName( programInstance.getProgram().getName() );
-        mobileProgram.setStatus( programInstance.getStatus() );
-        mobileProgram.setProgramStages( getMobileProgramStages( programInstance ) );
-        return mobileProgram;
+        mobileProgramInstance.setId( programInstance.getId() );
+        mobileProgramInstance.setName( programInstance.getProgram().getName() );
+        mobileProgramInstance.setStatus( programInstance.getStatus() );
+        mobileProgramInstance.setDateOfEnrollment( PeriodUtil.dateToString( programInstance.getEnrollmentDate() ) );
+        mobileProgramInstance.setDateOfIncident( PeriodUtil.dateToString( programInstance.getDateOfIncident() ) );
+        mobileProgramInstance.setPatientId( programInstance.getPatient().getId() );
+        mobileProgramInstance.setProgramId( programInstance.getProgram().getId() );
+        mobileProgramInstance.setProgramStageInstances( getMobileProgramStages( programInstance ) );
+        return mobileProgramInstance;
     }
 
     private List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage> getMobileProgramStages(
@@ -1125,8 +1069,6 @@
     {
         List<Program> programs = new ArrayList<Program>();
 
-        // for ( Program program : programService.getPrograms(
-        // orgUnitService.getOrganisationUnit( orgId ) ) )
         for ( Program program : programService.getPrograms( patient.getOrganisationUnit() ) )
         {
             if ( (program.isSingleEvent() && program.isRegistration()) || !program.isSingleEvent() )
@@ -1322,7 +1264,8 @@
         {
             anonymousProgramMobile.setVersion( program.getVersion() );
 
-            anonymousProgramMobile.setStatus( ProgramInstance.STATUS_ACTIVE );
+            // anonymousProgramMobile.setStatus( ProgramInstance.STATUS_ACTIVE
+            // );
 
             ProgramStage programStage = program.getProgramStages().iterator().next();
 
@@ -1486,8 +1429,8 @@
 
         for ( org.hisp.dhis.patient.PatientAttribute patientAtt : getPatientAtts( null ) )
         {
-            list.add( new PatientAttribute( patientAtt.getName(), null, patientAtt.getValueType(),
-                new ArrayList<String>() ) );
+            list.add( new PatientAttribute( patientAtt.getName(), null, patientAtt.getValueType(), patientAtt
+                .isMandatory(), new ArrayList<String>() ) );
         }
 
         return list;
@@ -1551,7 +1494,6 @@
     {
         org.hisp.dhis.patient.Patient patientWeb = new org.hisp.dhis.patient.Patient();
 
-        patientWeb.setName( patient.getName() );
         patientWeb.setOrganisationUnit( organisationUnitService.getOrganisationUnit( orgUnitId ) );
 
         Set<org.hisp.dhis.patient.PatientAttribute> patientAttributeSet = new HashSet<org.hisp.dhis.patient.PatientAttribute>();
@@ -1583,9 +1525,12 @@
 
         try
         {
-            int programId = Integer.parseInt( programIdText );
-            Date incidentDate = PeriodUtil.stringToDate( patient.getIncidentDate() );
-            enrollProgram( patientId + "-" + programId, incidentDate );
+            for ( org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramInstance mobileProgramInstance : patient
+                .getEnrollmentPrograms() )
+            {
+                Date incidentDate = PeriodUtil.stringToDate( mobileProgramInstance.getDateOfIncident() );
+                enrollProgram( patientId + "-" + mobileProgramInstance.getProgramId(), incidentDate );
+            }
         }
         catch ( Exception e )
         {
@@ -1609,79 +1554,62 @@
     }
 
     @Override
-    public org.hisp.dhis.api.mobile.model.LWUITmodel.Patient findPatientInAdvanced( String keyword, int orgUnitId,
-        int programId )
+    public String findPatientInAdvanced( String keyword, int orgUnitId, int programId )
         throws NotAllowedException
     {
-        Collection<Patient> patients = new HashSet<Patient>( patientService.getPatientsForMobile( keyword, orgUnitId ) );
-        OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
-
-        if ( programId != 0 )
-        {
-            Program program = programService.getProgram( programId );
-            List<Patient> tempPatients = (List<Patient>) patientService.getPatients( program );
-            patients.retainAll( tempPatients );
-        }
-
-        if ( programId != 0 && orgUnitId != 0 )
-        {
-            boolean isProgramBelongToOrgUnit = false;
-            for ( Program program : programService.getPrograms( orgUnit ) )
-            {
-                if ( program.getId() == programId )
-                {
-                    isProgramBelongToOrgUnit = true;
-                    break;
-                }
-            }
-            if ( isProgramBelongToOrgUnit == false )
-            {
-                throw NotAllowedException.NO_PROGRAM_BELONG_ORGUNIT;
-            }
-        }
-
-        if ( patients.size() > 1 )
-        {
-            String patientsInfo = "";
-
-            int i = 1;
-            String name = "";
-            for ( Patient each : patients )
-            {
-                if ( i > 10 )
-                {
-                    break;
-                }
-
-                if ( each.getName() != null )
-                {
-                    name = each.getName();
-                }
-                else
-                {
-                    name = "unknown";
-                }
-
-                patientsInfo += each.getId() + "/" + name + "$";
-                i++;
-            }
-
-            throw new NotAllowedException( patientsInfo );
-        }
-        else if ( patients.size() == 0 )
+        Set<Patient> patients = new HashSet<Patient>();
+
+        Collection<org.hisp.dhis.patient.PatientAttribute> attributes = patientAttributeService
+            .getAllPatientAttributes();
+
+        for ( org.hisp.dhis.patient.PatientAttribute displayAttribute : attributes )
+        {
+            Collection<Patient> resultPatients = patientAttValueService.getPatient( displayAttribute, keyword );
+            // Search in specific OrgUnit
+            if ( orgUnitId != 0 )
+            {
+                for ( Patient patient : resultPatients )
+                {
+                    if ( patient.getOrganisationUnit().getId() == orgUnitId )
+                    {
+                        patients.add( patient );
+                    }
+                }
+            }
+            // Search in all OrgUnit
+            else
+            {
+                patients.addAll( resultPatients );
+            }
+
+        }
+
+        if ( patients.size() == 0 )
         {
             throw NotAllowedException.NO_BENEFICIARY_FOUND;
         }
-        else
+
+        String resultSet = "";
+
+        Collection<org.hisp.dhis.patient.PatientAttribute> displayAttributes = patientAttributeService
+            .getPatientAttributesDisplayed( true );
+        for ( Patient patient : patients )
         {
-            org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patientMobile = new org.hisp.dhis.api.mobile.model.LWUITmodel.Patient();
-            for ( Patient each : patients )
+            resultSet += patient.getId() + "/";
+            String attText = "";
+            for ( org.hisp.dhis.patient.PatientAttribute displayAttribute : displayAttributes )
             {
-                patientMobile = getPatientModel( each );
-                break;
+                PatientAttributeValue value = patientAttValueService.getPatientAttributeValue( patient,
+                    displayAttribute );
+                if ( value != null )
+                {
+                    attText += value.getValue() + " ";
+                }
             }
-            return patientMobile;
+            attText = attText.trim();
+            resultSet += attText + "$";
         }
+        return resultSet;
     }
 
     @Override

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java	2013-12-16 15:34:06 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java	2014-02-07 10:03:41 +0000
@@ -35,7 +35,11 @@
 import org.hisp.dhis.api.mobile.model.Program;
 import org.hisp.dhis.api.mobile.model.ProgramStage;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeOption;
+import org.hisp.dhis.patient.PatientAttributeService;
 import org.hisp.dhis.program.ProgramInstance;
+import org.hisp.dhis.program.ProgramPatientAttribute;
 import org.hisp.dhis.program.ProgramStageDataElement;
 import org.hisp.dhis.program.ProgramStageSection;
 import org.springframework.beans.factory.annotation.Required;
@@ -43,6 +47,7 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
@@ -75,7 +80,8 @@
     {
         Collection<org.hisp.dhis.program.Program> programByUnit = programService.getPrograms( unit );
 
-        Collection<org.hisp.dhis.program.Program> programByCurrentUser = new HashSet<org.hisp.dhis.program.Program>( programService.getProgramsByCurrentUser() );
+        Collection<org.hisp.dhis.program.Program> programByCurrentUser = new HashSet<org.hisp.dhis.program.Program>(
+            programService.getProgramsByCurrentUser() );
 
         programByCurrentUser.retainAll( programByUnit );
 
@@ -127,7 +133,7 @@
     {
         org.hisp.dhis.program.Program program = programService.getProgram( programId );
 
-        //program = i18n( i18nService, locale, program );
+        // program = i18n( i18nService, locale, program );
 
         Program pr = new Program();
 
@@ -139,7 +145,7 @@
 
         for ( org.hisp.dhis.program.ProgramStage programStage : program.getProgramStages() )
         {
-            //programStage = i18n( i18nService, locale, programStage );
+            // programStage = i18n( i18nService, locale, programStage );
 
             ProgramStage prStg = new ProgramStage();
 
@@ -153,8 +159,6 @@
 
             for ( ProgramStageDataElement programStagedataElement : programStageDataElements )
             {
-                //programStagedataElement = i18n( i18nService, locale, programStagedataElement );
-
                 org.hisp.dhis.dataelement.DataElement dataElement = programStagedataElement.getDataElement();
 
                 DataElement de = ModelMapping.getDataElement( dataElement );
@@ -179,24 +183,26 @@
     {
         org.hisp.dhis.program.Program program = programService.getProgram( programId );
 
-        //program = i18n( i18nService, locale, program );
+        // program = i18n( i18nService, locale, program );
 
         org.hisp.dhis.api.mobile.model.LWUITmodel.Program pr = new org.hisp.dhis.api.mobile.model.LWUITmodel.Program();
 
         pr.setId( program.getId() );
         pr.setName( program.getName() );
+        pr.setType( program.getType() );
         pr.setVersion( program.getVersion() );
-        pr.setStatus( ProgramInstance.STATUS_ACTIVE );
+        pr.setDateOfEnrollmentDescription( program.getDateOfEnrollmentDescription() );
+        pr.setDateOfIncidentDescription( program.getDateOfIncidentDescription() );
 
         List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage> prStgs = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage>();
 
         for ( org.hisp.dhis.program.ProgramStage programStage : program.getProgramStages() )
         {
-            //programStage = i18n( i18nService, locale, programStage );
+            // programStage = i18n( i18nService, locale, programStage );
 
             org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage prStg = new org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage();
 
-            //add report date
+            // add report date
 
             prStg.setReportDate( "" );
 
@@ -227,11 +233,10 @@
 
             for ( ProgramStageDataElement programStageDataElement : programStageDataElements )
             {
-                //programStagedataElement = i18n( i18nService, locale, programStagedataElement );
-
                 org.hisp.dhis.dataelement.DataElement dataElement = programStageDataElement.getDataElement();
 
-                org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement de = ModelMapping.getDataElementLWUIT( dataElement );
+                org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement de = ModelMapping
+                    .getDataElementLWUIT( dataElement );
 
                 de.setCompulsory( programStageDataElement.isCompulsory() );
 
@@ -271,9 +276,67 @@
 
         pr.setProgramStages( prStgs );
 
+        List<ProgramPatientAttribute> programPatientAttributes = new ArrayList<ProgramPatientAttribute>(
+            program.getProgramPatientAttributes() );
+
+        for ( int i = 0; i < programPatientAttributes.size(); i++ )
+        {
+            ProgramPatientAttribute ppa = programPatientAttributes.get( i );
+            pr.getProgramAttributes().add( this.getPatientAttributeForMobile( ppa ) );
+        }
+
         return pr;
     }
 
+    private org.hisp.dhis.api.mobile.model.PatientAttribute getPatientAttributeForMobile( PatientAttribute pa )
+    {
+        PatientAttributeService patientAttributeService;
+        List<String> optionList = new ArrayList<String>();
+        if ( pa.getAttributeOptions() != null )
+        {
+            for ( PatientAttributeOption pao : pa.getAttributeOptions() )
+            {
+                optionList.add( pao.getName() );
+            }
+        }
+        org.hisp.dhis.api.mobile.model.PatientAttribute mobileAttribute = new org.hisp.dhis.api.mobile.model.PatientAttribute();
+        mobileAttribute.setName( pa.getName() );
+        mobileAttribute.setMandatory( pa.isMandatory() );
+        mobileAttribute.setType( pa.getValueType() );
+        mobileAttribute.setValue( "" );
+        mobileAttribute.setPredefinedValues( optionList );
+        mobileAttribute.setDisplayedInList( false );
+        return mobileAttribute;
+    }
+
+    private org.hisp.dhis.api.mobile.model.PatientAttribute getPatientAttributeForMobile( ProgramPatientAttribute ppa )
+    {
+        PatientAttribute pa = ppa.getPatientAttribute();
+        List<String> optionList = new ArrayList<String>();
+        if ( pa.getAttributeOptions() != null )
+        {
+            for ( PatientAttributeOption pao : pa.getAttributeOptions() )
+            {
+                optionList.add( pao.getName() );
+            }
+        }
+        org.hisp.dhis.api.mobile.model.PatientAttribute mobileAttribute = new org.hisp.dhis.api.mobile.model.PatientAttribute();
+        mobileAttribute.setName( pa.getName() );
+        mobileAttribute.setMandatory( pa.isMandatory() );
+        mobileAttribute.setType( pa.getValueType() );
+        mobileAttribute.setValue( "" );
+        mobileAttribute.setPredefinedValues( optionList );
+        if ( ppa.getDisplayedInList() )
+        {
+            mobileAttribute.setDisplayedInList( true );
+        }
+        else
+        {
+            mobileAttribute.setDisplayedInList( false );
+        }
+        return mobileAttribute;
+    }
+
     @Required
     public void setProgramService( org.hisp.dhis.program.ProgramService programService )
     {

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.java	2014-01-23 14:18:27 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.java	2014-02-07 10:03:41 +0000
@@ -67,24 +67,14 @@
 
         patientA = activityReportingService.findPatient( patientAId );
         assertEquals( patientAId, patientA.getId() );
-        assertEquals( "FirstnameA", patientA.getName() );
 
         patientB = activityReportingService.findPatient( patientBId );
         assertEquals( patientBId, patientB.getId() );
-        assertEquals( "FirstnameB", patientB.getName() );
     }
 
     private Patient createLWUITPatient( char uniqueCharacter )
     {
         Patient patient = new Patient();
-        patient.setAge( 1 );
-        patient.setBirthDate( "25-09-1990" );
-        patient.setName( "Firstname" + uniqueCharacter );
-        patient.setGender( "male" );
-        patient.setOrganisationUnitName( "OrgUnitName" );
-        patient.setPhoneNumber( "095678943" );
-        patient.setRegistrationDate( new Date() );
-        patient.setIncidentDate( "Incident Date" );
         patient.setAttributes( new ArrayList<PatientAttribute>() );
         return patient;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java'
--- dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java	2014-01-23 14:18:27 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java	2014-02-07 10:03:41 +0000
@@ -109,9 +109,7 @@
     // For client version 2.8 and lower
     @RequestMapping( method = RequestMethod.GET, value = "orgUnits/{id}/all" )
     @ResponseBody
-    public MobileModel getAllDataForOrgUnit2_8( @PathVariable
-    int id, @RequestHeader( "accept-language" )
-    String locale )
+    public MobileModel getAllDataForOrgUnit2_8( @PathVariable int id, @RequestHeader( "accept-language" ) String locale )
     {
         MobileModel mobileModel = new MobileModel();
         mobileModel.setClientVersion( DataStreamSerializable.TWO_POINT_EIGHT );
@@ -126,10 +124,8 @@
 
     @RequestMapping( method = RequestMethod.POST, value = "orgUnits/{id}/updateDataSets" )
     @ResponseBody
-    public DataSetList checkUpdatedDataSet2_8( @PathVariable
-    int id, @RequestBody
-    DataSetList dataSetList, @RequestHeader( "accept-language" )
-    String locale )
+    public DataSetList checkUpdatedDataSet2_8( @PathVariable int id, @RequestBody DataSetList dataSetList,
+        @RequestHeader( "accept-language" ) String locale )
     {
         DataSetList returnList = facilityReportingService.getUpdatedDataSet( dataSetList, getUnit( id ), locale );
         returnList.setClientVersion( DataStreamSerializable.TWO_POINT_EIGHT );
@@ -144,9 +140,7 @@
      */
     @RequestMapping( method = RequestMethod.POST, value = "orgUnits/{id}/dataSets" )
     @ResponseBody
-    public String saveDataSetValues2_8( @PathVariable
-    int id, @RequestBody
-    DataSetValue dataSetValue )
+    public String saveDataSetValues2_8( @PathVariable int id, @RequestBody DataSetValue dataSetValue )
         throws NotAllowedException
     {
         facilityReportingService.saveDataSetValues( getUnit( id ), dataSetValue );
@@ -162,9 +156,7 @@
      */
     @RequestMapping( method = RequestMethod.POST, value = "orgUnits/{id}/activities" )
     @ResponseBody
-    public String saveActivityReport2_8( @PathVariable
-    int id, @RequestBody
-    ActivityValue activityValue )
+    public String saveActivityReport2_8( @PathVariable int id, @RequestBody ActivityValue activityValue )
         throws NotAllowedException
     {
         // FIXME set the last argument to 0 to fix compilation error
@@ -174,10 +166,8 @@
 
     @RequestMapping( method = RequestMethod.POST, value = "orgUnits/{id}/activitiyplan" )
     @ResponseBody
-    public MobileModel updatePrograms2_8( @PathVariable
-    int id, @RequestHeader( "accept-language" )
-    String locale, @RequestBody
-    ModelList programsFromClient )
+    public MobileModel updatePrograms2_8( @PathVariable int id, @RequestHeader( "accept-language" ) String locale,
+        @RequestBody ModelList programsFromClient )
     {
         MobileModel model = new MobileModel();
         model.setClientVersion( DataStreamSerializable.TWO_POINT_EIGHT );
@@ -189,9 +179,7 @@
 
     @RequestMapping( method = RequestMethod.GET, value = "orgUnits/{id}/changeLanguageDataSet" )
     @ResponseBody
-    public DataSetList changeLanguageDataSet2_8( @PathVariable
-    int id, @RequestHeader( "accept-language" )
-    String locale )
+    public DataSetList changeLanguageDataSet2_8( @PathVariable int id, @RequestHeader( "accept-language" ) String locale )
     {
         return facilityReportingService.getDataSetsForLocale( getUnit( id ), locale );
     }
@@ -200,10 +188,8 @@
 
     @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/orgUnits/{id}/all" )
     @ResponseBody
-    public MobileModel getAllDataForOrgUnit( @PathVariable
-    String clientVersion, @PathVariable
-    int id, @RequestHeader( "accept-language" )
-    String locale )
+    public MobileModel getAllDataForOrgUnit( @PathVariable String clientVersion, @PathVariable int id,
+        @RequestHeader( "accept-language" ) String locale )
     {
         MobileModel mobileModel = new MobileModel();
         mobileModel.setClientVersion( clientVersion );
@@ -221,11 +207,8 @@
 
     @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/orgUnits/{id}/updateDataSets" )
     @ResponseBody
-    public DataSetList checkUpdatedDataSet( @PathVariable
-    String clientVersion, @PathVariable
-    int id, @RequestBody
-    DataSetList dataSetList, @RequestHeader( "accept-language" )
-    String locale )
+    public DataSetList checkUpdatedDataSet( @PathVariable String clientVersion, @PathVariable int id,
+        @RequestBody DataSetList dataSetList, @RequestHeader( "accept-language" ) String locale )
     {
         DataSetList returnList = facilityReportingService.getUpdatedDataSet( dataSetList, getUnit( id ), locale );
         returnList.setClientVersion( clientVersion );
@@ -241,9 +224,7 @@
 
     @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/orgUnits/{id}/dataSets" )
     @ResponseBody
-    public String saveDataSetValues( @PathVariable
-    int id, @RequestBody
-    DataSetValue dataSetValue )
+    public String saveDataSetValues( @PathVariable int id, @RequestBody DataSetValue dataSetValue )
         throws NotAllowedException
     {
         facilityReportingService.saveDataSetValues( getUnit( id ), dataSetValue );
@@ -252,11 +233,8 @@
 
     @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/orgUnits/{id}/activitiyplan" )
     @ResponseBody
-    public MobileModel updatePrograms( @PathVariable
-    String clientVersion, @PathVariable
-    int id, @RequestHeader( "accept-language" )
-    String locale, @RequestBody
-    ModelList programsFromClient )
+    public MobileModel updatePrograms( @PathVariable String clientVersion, @PathVariable int id,
+        @RequestHeader( "accept-language" ) String locale, @RequestBody ModelList programsFromClient )
     {
         MobileModel model = new MobileModel();
         model.setClientVersion( clientVersion );
@@ -294,9 +272,7 @@
      */
     @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/orgUnits/{id}/activities" )
     @ResponseBody
-    public String saveActivityReport( @PathVariable
-    int id, @RequestBody
-    ActivityValue activityValue )
+    public String saveActivityReport( @PathVariable int id, @RequestBody ActivityValue activityValue )
         throws NotAllowedException
     {
         // FIXME set the last argument to 0 to fix compilation error
@@ -306,9 +282,7 @@
 
     @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/orgUnits/{id}/changeLanguageDataSet" )
     @ResponseBody
-    public DataSetList changeLanguageDataSet( @PathVariable
-    int id, @RequestHeader( "accept-language" )
-    String locale )
+    public DataSetList changeLanguageDataSet( @PathVariable int id, @RequestHeader( "accept-language" ) String locale )
     {
         return facilityReportingService.getDataSetsForLocale( getUnit( id ), locale );
     }
@@ -322,9 +296,8 @@
 
     @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/all" )
     @ResponseBody
-    public org.hisp.dhis.api.mobile.model.LWUITmodel.MobileModel getAllDataForOrgUnitLWUIT( @PathVariable
-    String clientVersion, @PathVariable
-    int id )
+    public org.hisp.dhis.api.mobile.model.LWUITmodel.MobileModel getAllDataForOrgUnitLWUIT(
+        @PathVariable String clientVersion, @PathVariable int id )
     {
         org.hisp.dhis.api.mobile.model.LWUITmodel.MobileModel mobileModel = new org.hisp.dhis.api.mobile.model.LWUITmodel.MobileModel();
         mobileModel.setClientVersion( clientVersion );
@@ -343,20 +316,16 @@
 
     @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/findPatient" )
     @ResponseBody
-    public Patient findPatientByName( @PathVariable
-    int id, @RequestHeader( "name" )
-    String keyword )
+    public Patient findPatientByName( @PathVariable int id, @RequestHeader( "patientId" ) String patientId )
         throws NotAllowedException
     {
-        return activityReportingService.findPatient( keyword, id );
+        return activityReportingService.findPatient( Integer.parseInt( patientId ) );
     }
 
     @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/findPatientInAdvanced/{programId}" )
     @ResponseBody
-    public Patient findPatientInAdvanced( @PathVariable
-    int programId, @PathVariable
-    int id, @RequestHeader( "name" )
-    String keyword )
+    public String findPatientInAdvanced( @PathVariable int programId, @PathVariable int id,
+        @RequestHeader( "name" ) String keyword )
         throws NotAllowedException
     {
         return activityReportingService.findPatientInAdvanced( keyword, id, programId );
@@ -364,10 +333,8 @@
 
     @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/LWUIT/orgUnits/{id}/uploadProgramStage/{patientId}" )
     @ResponseBody
-    public String saveProgramStage( @PathVariable
-    int patientId, @PathVariable
-    int id, @RequestBody
-    ProgramStage programStage )
+    public String saveProgramStage( @PathVariable int patientId, @PathVariable int id,
+        @RequestBody ProgramStage programStage )
         throws NotAllowedException
     {
         return activityReportingService.saveProgramStage( programStage, patientId, id );
@@ -375,9 +342,7 @@
 
     @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/enrollProgram" )
     @ResponseBody
-    public Patient enrollProgram( @PathVariable
-    int id, @RequestHeader( "enrollInfo" )
-    String enrollInfo )
+    public Patient enrollProgram( @PathVariable int id, @RequestHeader( "enrollInfo" ) String enrollInfo )
         throws NotAllowedException
     {
         return activityReportingService.enrollProgram( enrollInfo, new Date() );
@@ -385,9 +350,7 @@
 
     @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/LWUIT/orgUnits/{id}/addRelationship" )
     @ResponseBody
-    public Patient addRelationship( @PathVariable
-    int id, @RequestBody
-    Relationship enrollmentRelationship )
+    public Patient addRelationship( @PathVariable int id, @RequestBody Relationship enrollmentRelationship )
         throws NotAllowedException
     {
         return activityReportingService.addRelationship( enrollmentRelationship, id );
@@ -395,9 +358,7 @@
 
     @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/downloadAnonymousProgram" )
     @ResponseBody
-    public Program getAnonymousProgram( @PathVariable
-    int id, @RequestHeader( "programType" )
-    String programType )
+    public Program getAnonymousProgram( @PathVariable int id, @RequestHeader( "programType" ) String programType )
         throws NotAllowedException
     {
         return activityReportingService.getAllProgramByOrgUnit( id, programType );
@@ -405,9 +366,7 @@
 
     @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/findProgram" )
     @ResponseBody
-    public Program findProgram( @PathVariable
-    int id, @RequestHeader( "info" )
-    String programInfo )
+    public Program findProgram( @PathVariable int id, @RequestHeader( "info" ) String programInfo )
         throws NotAllowedException
     {
         return activityReportingService.findProgram( programInfo );
@@ -415,9 +374,7 @@
 
     @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/findLostToFollowUp" )
     @ResponseBody
-    public String findLostToFollowUp( @PathVariable
-    int id, @RequestHeader( "searchEventInfos" )
-    String searchEventInfos )
+    public String findLostToFollowUp( @PathVariable int id, @RequestHeader( "searchEventInfos" ) String searchEventInfos )
         throws NotAllowedException
     {
         return activityReportingService.findLostToFollowUp( id, searchEventInfos );
@@ -425,9 +382,7 @@
 
     @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/LWUIT/orgUnits/{id}/handleLostToFollowUp" )
     @ResponseBody
-    public Notification handleLostToFollowUp( @PathVariable
-    int id, @RequestBody
-    LostEvent lostEvent )
+    public Notification handleLostToFollowUp( @PathVariable int id, @RequestBody LostEvent lostEvent )
         throws NotAllowedException
     {
         return activityReportingService.handleLostToFollowUp( lostEvent );
@@ -435,9 +390,7 @@
 
     @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/generateRepeatableEvent" )
     @ResponseBody
-    public Patient generateRepeatableEvent( @PathVariable
-    int id, @RequestHeader( "eventInfo" )
-    String eventInfo )
+    public Patient generateRepeatableEvent( @PathVariable int id, @RequestHeader( "eventInfo" ) String eventInfo )
         throws NotAllowedException
     {
         return activityReportingService.generateRepeatableEvent( id, eventInfo );
@@ -495,10 +448,8 @@
 
     @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/LWUIT/orgUnits/{id}/registerPerson" )
     @ResponseBody
-    public Patient savePatient( @PathVariable
-    int id, @RequestBody
-    Patient patient, @RequestHeader( "programid" )
-    String programId )
+    public Patient savePatient( @PathVariable int id, @RequestBody Patient patient,
+        @RequestHeader( "programid" ) String programId )
         throws NotAllowedException
     {
         if ( activityReportingService.savePatient( patient, id, programId ) != null )
@@ -513,11 +464,8 @@
 
     @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/getVariesInfo" )
     @ResponseBody
-    public PatientIdentifierAndAttribute getVariesInfo( @PathVariable
-    String clientVersion, @PathVariable
-    int id, @RequestHeader( "accept-language" )
-    String locale, @RequestHeader( "programid" )
-    String programId )
+    public PatientIdentifierAndAttribute getVariesInfo( @PathVariable String clientVersion, @PathVariable int id,
+        @RequestHeader( "accept-language" ) String locale, @RequestHeader( "programid" ) String programId )
     {
         PatientIdentifierAndAttribute patientIdentifierAndAttribute = new PatientIdentifierAndAttribute();
         patientIdentifierAndAttribute.setClientVersion( clientVersion );