← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9678: Creating new objects which are used for LWUIT framework - j2me

 

------------------------------------------------------------
revno: 9678
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-02-01 14:09:23 +0700
message:
  Creating new objects which are used for LWUIT framework - j2me
added:
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/
  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/LWUITmodel/ProgramStage.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramStageDataElement.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Relationship.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Section.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/mobile/service/ActivityReportingServiceImpl.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml
  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-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.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	2013-01-17 09:23:01 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java	2013-02-01 07:09:23 +0000
@@ -29,7 +29,7 @@
 
 import org.hisp.dhis.api.mobile.model.ActivityPlan;
 import org.hisp.dhis.api.mobile.model.ActivityValue;
-import org.hisp.dhis.api.mobile.model.Beneficiary;
+import org.hisp.dhis.api.mobile.model.LWUITmodel.Patient;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 
 /**
@@ -48,6 +48,6 @@
     public void saveActivityReport( OrganisationUnit unit, ActivityValue activityValue, Integer programStageSectionId )
         throws NotAllowedException;
 
-    public Beneficiary findPatient( String name )
+    public Patient findPatient( String name )
         throws NotAllowedException;
 }

=== added directory 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel'
=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java	2013-02-01 07:09:23 +0000
@@ -0,0 +1,552 @@
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.api.mobile.model.LWUITmodel;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.Date;
+import java.util.List;
+
+import org.hisp.dhis.api.mobile.model.Beneficiary;
+import org.hisp.dhis.api.mobile.model.DataStreamSerializable;
+import org.hisp.dhis.api.mobile.model.PatientAttribute;
+import org.hisp.dhis.api.mobile.model.PatientIdentifier;
+
+/**
+ * @author Nguyen Kim Lai
+ * 
+ * @version $ Patient.java Jan 22, 2013 $
+ */
+public class Patient
+    implements DataStreamSerializable
+{
+
+    private String clientVersion;
+
+    private int id;
+
+    private String firstName;
+
+    private String middleName;
+
+    private String lastName;
+
+    private int age;
+
+    private List<PatientAttribute> patientAttValues;
+
+    private PatientAttribute groupAttribute;
+
+    private List<PatientIdentifier> identifiers;
+
+    private String gender;
+
+    private Date birthDate;
+
+    private Date registrationDate;
+
+    private Character dobType;
+
+    private List<Program> programs;
+
+    private List<Relationship> relationships;
+
+    public List<PatientIdentifier> getIdentifiers()
+    {
+        return identifiers;
+    }
+
+    public void setIdentifiers( List<PatientIdentifier> identifiers )
+    {
+        this.identifiers = identifiers;
+    }
+
+    public List<Program> getPrograms()
+    {
+        return programs;
+    }
+
+    public void setPrograms( List<Program> programs )
+    {
+        this.programs = programs;
+    }
+
+    public List<Relationship> getRelationships()
+    {
+        return relationships;
+    }
+
+    public void setRelationships( List<Relationship> relationships )
+    {
+        this.relationships = relationships;
+    }
+
+    public String getFullName()
+    {
+        boolean space = false;
+        String name = "";
+
+        if ( firstName != null && firstName.length() != 0 )
+        {
+            name = firstName;
+            space = true;
+        }
+        if ( middleName != null && middleName.length() != 0 )
+        {
+            if ( space )
+                name += " ";
+            name += middleName;
+            space = true;
+        }
+        if ( lastName != null && lastName.length() != 0 )
+        {
+            if ( space )
+                name += " ";
+            name += lastName;
+        }
+        return name;
+    }
+
+    public int getAge()
+    {
+        return age;
+    }
+
+    public String getGender()
+    {
+        return gender;
+    }
+
+    public void setGender( String gender )
+    {
+        this.gender = gender;
+    }
+
+    public Date getBirthDate()
+    {
+        return birthDate;
+    }
+
+    public void setBirthDate( Date 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 PatientAttribute getGroupAttribute()
+    {
+        return groupAttribute;
+    }
+
+    public void setGroupAttribute( PatientAttribute groupAttribute )
+    {
+        this.groupAttribute = groupAttribute;
+    }
+
+    public List<PatientAttribute> getPatientAttValues()
+    {
+        return patientAttValues;
+    }
+
+    public void setPatientAttValues( List<PatientAttribute> patientAttValues )
+    {
+        this.patientAttValues = patientAttValues;
+    }
+
+    public int getId()
+    {
+        return id;
+    }
+
+    public void setId( int id )
+    {
+        this.id = id;
+    }
+
+    public String getFirstName()
+    {
+        return firstName;
+    }
+
+    public void setFirstName( String firstName )
+    {
+        this.firstName = firstName;
+    }
+
+    public String getMiddleName()
+    {
+        return middleName;
+    }
+
+    public void setMiddleName( String middleName )
+    {
+        this.middleName = middleName;
+    }
+
+    public String getLastName()
+    {
+        return lastName;
+    }
+
+    public void setLastName( String lastName )
+    {
+        this.lastName = lastName;
+    }
+
+    public String getClientVersion()
+    {
+        return clientVersion;
+    }
+
+    public void setClientVersion( String clientVersion )
+    {
+        this.clientVersion = clientVersion;
+    }
+
+    @Override
+    public void serialize( DataOutputStream out )
+        throws IOException
+    {
+        ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        DataOutputStream dout = new DataOutputStream( bout );
+
+        dout.writeInt( this.getId() );
+        dout.writeUTF( this.getFirstName() );
+        dout.writeUTF( this.getMiddleName() );
+        dout.writeUTF( this.getLastName() );
+        dout.writeInt( this.getAge() );
+
+        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.writeLong( birthDate.getTime() );
+        }
+        else
+        {
+            dout.writeBoolean( false );
+        }
+        // doesn't transfer blood group to client
+        dout.writeBoolean( false );
+
+        if ( registrationDate != null )
+        {
+            dout.writeBoolean( true );
+            dout.writeLong( registrationDate.getTime() );
+        }
+        else
+        {
+            dout.writeBoolean( false );
+        }
+
+        /*
+         * 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 );
+            this.getGroupAttribute().serialize( dout );
+        }
+        else
+        {
+            dout.writeBoolean( false );
+        }
+
+        List<PatientAttribute> atts = this.getPatientAttValues();
+        dout.writeInt( atts.size() );
+        for ( PatientAttribute att : atts )
+        {
+            dout.writeUTF( att.getName() + ":" + att.getValue() );
+        }
+
+        // Write PatientIdentifier
+        dout.writeInt( identifiers.size() );
+        for ( PatientIdentifier each : identifiers )
+        {
+            each.serialize( dout );
+        }
+
+        // Write Enrolled Programs
+
+        dout.writeInt( programs.size() );
+        for ( Program each : programs )
+        {
+            each.serialize( dout );
+        }
+
+        // Write Relationships
+        dout.writeInt( relationships.size() );
+        for ( Relationship each : relationships )
+        {
+            each.serialize( dout );
+        }
+
+        bout.flush();
+        bout.writeTo( out );
+    }
+
+    @Override
+    public void deSerialize( DataInputStream dataInputStream )
+        throws IOException
+    {
+
+    }
+
+    @Override
+    public boolean equals( Object otherObject )
+    {
+        Beneficiary otherBeneficiary = (Beneficiary) otherObject;
+        return this.getId() == otherBeneficiary.getId();
+    }
+
+    @Override
+    public void serializeVerssion2_8( DataOutputStream out )
+        throws IOException
+    {
+        ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        DataOutputStream dout = new DataOutputStream( bout );
+
+        dout.writeInt( this.getId() );
+        dout.writeUTF( this.getFirstName() );
+        dout.writeUTF( this.getMiddleName() );
+        dout.writeUTF( this.getLastName() );
+        dout.writeInt( this.getAge() );
+
+        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.writeLong( birthDate.getTime() );
+        }
+        else
+        {
+            dout.writeBoolean( false );
+        }
+        // doesn't transfer blood group to client
+        dout.writeBoolean( false );
+
+        if ( registrationDate != null )
+        {
+            dout.writeBoolean( true );
+            dout.writeLong( registrationDate.getTime() );
+        }
+        else
+        {
+            dout.writeBoolean( false );
+        }
+
+        /*
+         * 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 );
+            this.getGroupAttribute().serialize( dout );
+        }
+        else
+        {
+            dout.writeBoolean( false );
+        }
+
+        List<PatientAttribute> atts = this.getPatientAttValues();
+        dout.writeInt( atts.size() );
+        for ( PatientAttribute att : atts )
+        {
+            dout.writeUTF( att.getName() + ":" + att.getValue() );
+        }
+
+        // Write PatientIdentifier
+        dout.writeInt( identifiers.size() );
+        for ( PatientIdentifier each : identifiers )
+        {
+            each.serializeVerssion2_8( dout );
+        }
+
+        bout.flush();
+        bout.writeTo( out );
+    }
+
+    @Override
+    public void serializeVerssion2_9( DataOutputStream dout )
+        throws IOException
+    {
+        dout.writeInt( this.getId() );
+        dout.writeUTF( this.getFirstName() );
+        dout.writeUTF( this.getMiddleName() );
+        dout.writeUTF( this.getLastName() );
+        dout.writeInt( this.getAge() );
+
+        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.writeLong( birthDate.getTime() );
+        }
+        else
+        {
+            dout.writeBoolean( false );
+        }
+        // doesn't transfer blood group to client
+        dout.writeBoolean( false );
+
+        if ( registrationDate != null )
+        {
+            dout.writeBoolean( true );
+            dout.writeLong( registrationDate.getTime() );
+        }
+        else
+        {
+            dout.writeBoolean( false );
+        }
+
+        /*
+         * 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 );
+            this.getGroupAttribute().serialize( dout );
+        }
+        else
+        {
+            dout.writeBoolean( false );
+        }
+
+        List<PatientAttribute> atts = this.getPatientAttValues();
+        dout.writeInt( atts.size() );
+        for ( PatientAttribute att : atts )
+        {
+            dout.writeUTF( att.getName() + ":" + att.getValue() );
+        }
+
+        // Write PatientIdentifier
+        dout.writeInt( identifiers.size() );
+        for ( PatientIdentifier each : identifiers )
+        {
+            each.serializeVerssion2_9( dout );
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.hisp.dhis.api.mobile.model.DataStreamSerializable#serializeVerssion2_10(java.io.DataOutputStream)
+     */
+    @Override
+    public void serializeVerssion2_10( DataOutputStream dataOutputStream )
+        throws IOException
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
+}

=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Program.java	2013-02-01 07:09:23 +0000
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.api.mobile.model.LWUITmodel;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.List;
+
+import org.hisp.dhis.api.mobile.model.Model;
+
+/**
+ * @author Nguyen Kim Lai
+ * 
+ * @version Program.java 11:35:39 AM Jan 22, 2013 $
+ */
+public class Program
+    extends Model
+{
+    private String clientVersion;
+    
+    private int version;
+    
+    private boolean isCompleted;
+
+    private List<ProgramStage> programStages;
+
+    public List<ProgramStage> getProgramStages()
+    {
+        return programStages;
+    }
+
+    public void setProgramStages( List<ProgramStage> programStages )
+    {
+        this.programStages = programStages;
+    }
+
+    public int getVersion()
+    {
+        return version;
+    }
+
+    public void setVersion( int version )
+    {
+        this.version = version;
+    }
+    
+    public String getClientVersion()
+    {
+        return clientVersion;
+    }
+
+    public void setClientVersion( String clientVersion )
+    {
+        this.clientVersion = clientVersion;
+    }
+
+    public boolean isCompleted()
+    {
+        return isCompleted;
+    }
+
+    public void setCompleted( boolean isCompleted )
+    {
+        this.isCompleted = isCompleted;
+    }
+
+    @Override
+    public void serialize( DataOutputStream dout )
+        throws IOException
+    {
+        super.serialize( dout );
+        dout.writeBoolean( this.isCompleted() );
+        dout.writeInt( this.getVersion() );
+        dout.writeInt( programStages.size() );
+        for ( int i = 0; i < programStages.size(); i++ )
+        {
+            ProgramStage ps = (ProgramStage) programStages.get( i );
+            ps.serialize( dout );
+        }
+    }
+
+    @Override
+    public void deSerialize( DataInputStream dataInputStream )
+        throws IOException
+    {
+        // FIXME: Get implementation from client
+    }
+}

=== added file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramStage.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramStage.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/ProgramStage.java	2013-02-01 07:09:23 +0000
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.api.mobile.model.LWUITmodel;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.List;
+
+import org.hisp.dhis.api.mobile.model.DataElement;
+import org.hisp.dhis.api.mobile.model.Model;
+
+ /**
+ * @author Nguyen Kim Lai
+ *
+ * @version ProgramStage.java 1:04:07 PM Jan 22, 2013 $
+ */
+public class ProgramStage extends Model
+{
+    private String clientVersion;
+    
+    private boolean isRepeatable;
+    
+    private boolean isCompleted;
+
+    private List<Section> sections;
+    
+    private List<ProgramStageDataElement> dataElements;
+
+    public List<Section> getSections()
+    {
+        return sections;
+    }
+
+    public void setSections( List<Section> sections )
+    {
+        this.sections = sections;
+    }
+
+    public List<ProgramStageDataElement> getDataElements()
+    {
+        return dataElements;
+    }
+
+    public void setDataElements( List<ProgramStageDataElement> dataElements )
+    {
+        this.dataElements = dataElements;
+    }
+
+    public String getClientVersion()
+    {
+        return clientVersion;
+    }
+
+    public void setClientVersion( String clientVersion )
+    {
+        this.clientVersion = clientVersion;
+    }
+
+    public boolean isRepeatable()
+    {
+        return isRepeatable;
+    }
+
+    public void setRepeatable( boolean isRepeatable )
+    {
+        this.isRepeatable = isRepeatable;
+    }
+    
+    public boolean isCompleted()
+    {
+        return isCompleted;
+    }
+
+    public void setCompleted( boolean isCompleted )
+    {
+        this.isCompleted = isCompleted;
+    }
+
+    @Override
+    public void serialize( DataOutputStream dout )
+        throws IOException
+    {
+        super.serialize( dout );
+        dout.writeBoolean( this.isRepeatable() );
+        dout.writeBoolean( this.isCompleted() );
+        
+        dout.writeInt( this.dataElements.size() );
+        for ( int i = 0; i < this.dataElements.size(); i++ )
+        {
+            this.dataElements.get( i ).serialize( dout );
+        }
+        
+        dout.writeInt( this.sections.size() );
+        for ( int i = 0; i < this.sections.size(); i++ )
+        {
+            this.sections.get( i ).serialize( dout );
+        }
+    }
+
+    @Override
+    public void deSerialize( DataInputStream dataInputStream )
+        throws IOException
+    {
+        // FIXME: Get implementation from client
+    }
+}

=== added file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramStageDataElement.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramStageDataElement.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/ProgramStageDataElement.java	2013-02-01 07:09:23 +0000
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.api.mobile.model.LWUITmodel;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.List;
+
+import org.hisp.dhis.api.mobile.model.Model;
+import org.hisp.dhis.api.mobile.model.ModelList;
+import org.hisp.dhis.api.mobile.model.OptionSet;
+
+ /**
+ * @author Nguyen Kim Lai
+ *
+ * @version ProgramStageDataElement.java 11:21:39 AM Jan 30, 2013 $
+ */
+public class ProgramStageDataElement extends Model
+{
+    private String clientVersion;
+    
+    private String type;
+    
+    private boolean compulsory;
+
+    private ModelList categoryOptionCombos;
+
+    private OptionSet optionSet;
+    
+    private String value;
+    
+    @Override
+    public void serialize( DataOutputStream dout )
+        throws IOException
+    {
+        dout.writeUTF( this.getType() );
+        dout.writeBoolean( this.isCompulsory() );
+        
+        List<Model> cateOptCombos = this.getCategoryOptionCombos().getModels();
+        if ( cateOptCombos == null || cateOptCombos.size() <= 0 )
+        {
+            dout.writeInt( 0 );
+        }
+        else
+        {
+            dout.writeInt( cateOptCombos.size() );
+            for ( Model each : cateOptCombos )
+            {
+                each.setClientVersion( TWO_POINT_NINE );
+                each.serialize( dout );
+            }
+        }
+        
+        if ( optionSet == null || optionSet.getOptions().size() <= 0 )
+        {
+            dout.writeInt( 0 );
+        }
+        else
+        {
+            optionSet.setClientVersion( TWO_POINT_NINE );
+            optionSet.serialize( dout );
+        }
+        
+        dout.writeUTF( this.getValue() );
+    }
+    
+    @Override
+    public void deSerialize( DataInputStream dataInputStream )
+        throws IOException
+    {
+        // TODO Auto-generated method stub
+        super.deSerialize( dataInputStream );
+    }
+    
+    
+    public String getClientVersion()
+    {
+        return clientVersion;
+    }
+
+    public void setClientVersion( String clientVersion )
+    {
+        this.clientVersion = clientVersion;
+    }
+
+    public String getValue()
+    {
+        return value;
+    }
+
+    public void setValue( String value )
+    {
+        this.value = value;
+    }
+    
+    public String getType()
+    {
+        return type;
+    }
+
+    public void setType( String type )
+    {
+        this.type = type;
+    }
+
+    public boolean isCompulsory()
+    {
+        return compulsory;
+    }
+
+    public void setCompulsory( boolean compulsory )
+    {
+        this.compulsory = compulsory;
+    }
+
+    public ModelList getCategoryOptionCombos()
+    {
+        return categoryOptionCombos;
+    }
+
+    public void setCategoryOptionCombos( ModelList categoryOptionCombos )
+    {
+        this.categoryOptionCombos = categoryOptionCombos;
+    }
+
+    public OptionSet getOptionSet()
+    {
+        return optionSet;
+    }
+
+    public void setOptionSet( OptionSet optionSet )
+    {
+        this.optionSet = optionSet;
+    }
+}

=== added file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Relationship.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Relationship.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/Relationship.java	2013-02-01 07:09:23 +0000
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.api.mobile.model.LWUITmodel;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.hisp.dhis.api.mobile.model.Model;
+
+ /**
+ * @author Nguyen Kim Lai
+ *
+ * @version Relationship.java 4:34:43 PM Jan 25, 2013 $
+ */
+public class Relationship extends Model
+{
+    private String clientVersion;
+    
+    private String personName;
+
+    public String getClientVersion()
+    {
+        return clientVersion;
+    }
+
+    public void setClientVersion( String clientVersion )
+    {
+        this.clientVersion = clientVersion;
+    }
+
+    public String getPersonName()
+    {
+        return personName;
+    }
+
+    public void setPersonName( String personName )
+    {
+        this.personName = personName;
+    }
+    
+    public void serialize( DataOutputStream dout )
+        throws IOException
+    {
+        dout.writeUTF( this.getName() );
+        dout.writeUTF( this.getPersonName() );
+    }
+    
+    public void deSerialize( DataInputStream dataInputStream )
+        throws IOException
+    {
+        this.setName( dataInputStream.readUTF() );
+        this.setPersonName( dataInputStream.readUTF() );
+    }
+}

=== added file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Section.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Section.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/Section.java	2013-02-01 07:09:23 +0000
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.hisp.dhis.api.mobile.model.LWUITmodel;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+
+import org.hisp.dhis.api.mobile.model.DataElement;
+import org.hisp.dhis.api.mobile.model.Model;
+
+/**
+ * @author Nguyen Kim Lai
+ * 
+ * @version Section.java 1:11:03 PM Jan 22, 2013 $
+ */
+public class Section
+    extends Model
+{
+    private String clientVersion;
+
+    private List<Integer> dataElementIds;
+
+    public List<Integer> getDataElementIds()
+    {
+        return dataElementIds;
+    }
+
+    public void setDataElementIds( List<Integer> dataElementIds )
+    {
+        this.dataElementIds = dataElementIds;
+    }
+
+    public String getClientVersion()
+    {
+        return clientVersion;
+    }
+
+    public void setClientVersion( String clientVersion )
+    {
+        this.clientVersion = clientVersion;
+    }
+
+    @Override
+    public void serialize( DataOutputStream dout )
+        throws IOException
+    {
+        dout.writeInt( this.getId() );
+        dout.writeUTF( getName() );
+
+        if ( dataElementIds == null )
+        {
+            dout.writeInt( 0 );
+        }
+        else
+        {
+            dout.writeInt( dataElementIds.size() );
+            for ( int i = 0; i < dataElementIds.size(); i++ )
+            {
+                dout.writeInt( dataElementIds.get( i ) );
+            }
+        }
+    }
+
+    @Override
+    public void deSerialize( DataInputStream dataInputStream )
+        throws IOException
+    {
+        // FIXME: Get implementation from client
+    }
+
+}

=== 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	2013-01-21 08:13:02 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2013-02-01 07:09:23 +0000
@@ -63,11 +63,17 @@
 import org.hisp.dhis.patientdatavalue.PatientDataValue;
 import org.hisp.dhis.patientdatavalue.PatientDataValueService;
 import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramInstance;
+import org.hisp.dhis.program.ProgramInstanceService;
+import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageDataElement;
 import org.hisp.dhis.program.ProgramStageInstance;
 import org.hisp.dhis.program.ProgramStageInstanceService;
 import org.hisp.dhis.program.ProgramStageSection;
 import org.hisp.dhis.program.ProgramStageSectionService;
+import org.hisp.dhis.relationship.Relationship;
+import org.hisp.dhis.relationship.RelationshipService;
 import org.hisp.dhis.system.util.DateUtils;
 import org.joda.time.DateTime;
 import org.joda.time.Period;
@@ -100,12 +106,13 @@
 
     private ProgramStageSectionService programStageSectionService;
 
+    private ProgramInstanceService programInstanceService;
+
+    private RelationshipService relationshipService;
+
     private Beneficiary beneficiary;
-
-    public void setProgramStageSectionService( ProgramStageSectionService programStageSectionService )
-    {
-        this.programStageSectionService = programStageSectionService;
-    }
+    
+    private org.hisp.dhis.mobile.service.ModelMapping modelMapping;
 
     // -------------------------------------------------------------------------
     // MobileDataSetService
@@ -434,6 +441,263 @@
         return beneficiary;
     }
 
+    // get patient model for LWUIT
+    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.patient.PatientAttribute> atts;
+
+        patientModel.setId( patient.getId() );
+        patientModel.setFirstName( patient.getFirstName() );
+        patientModel.setLastName( patient.getLastName() );
+        patientModel.setMiddleName( patient.getMiddleName() );
+
+        Period period = new Period( new DateTime( patient.getBirthDate() ), new DateTime() );
+        patientModel.setAge( period.getYears() );
+
+        this.setSetting( getSettings() );
+
+        if ( setting != null )
+        {
+            if ( setting.getGender() )
+            {
+                patientModel.setGender( patient.getGender() );
+            }
+            if ( setting.getDobtype() )
+            {
+                patientModel.setDobType( patient.getDobType() );
+            }
+            if ( setting.getBirthdate() )
+            {
+                patientModel.setBirthDate( patient.getBirthDate() );
+            }
+            if ( setting.getRegistrationdate() )
+            {
+                patientModel.setRegistrationDate( patient.getRegistrationDate() );
+            }
+
+            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() ) );
+                }
+            }
+
+        }
+
+        // Set attribute which is used to group beneficiary on mobile (only if
+        // there is attribute which is set to be group factor)
+        PatientAttribute patientAttribute = null;
+
+        if ( groupByAttribute != null )
+        {
+            patientAttribute = new PatientAttribute();
+            patientAttribute.setName( groupByAttribute.getName() );
+            PatientAttributeValue value = patientAttValueService.getPatientAttributeValue( patient, groupByAttribute );
+            patientAttribute.setValue( value == null ? "Unknown" : value.getValue() );
+            patientModel.setGroupAttribute( patientAttribute );
+        }
+
+        // Set all identifier
+        Set<PatientIdentifier> patientIdentifiers = patient.getIdentifiers();
+        List<org.hisp.dhis.api.mobile.model.PatientIdentifier> identifiers = new ArrayList<org.hisp.dhis.api.mobile.model.PatientIdentifier>();
+        if ( patientIdentifiers.size() > 0 )
+        {
+
+            for ( PatientIdentifier id : patientIdentifiers )
+            {
+
+                String idTypeName = "DHIS2 ID";
+
+                // MIGHT BE NULL because of strange design..
+                PatientIdentifierType identifierType = id.getIdentifierType();
+
+                if ( identifierType != null )
+                {
+                    idTypeName = identifierType.getName();
+                }
+
+                identifiers
+                    .add( new org.hisp.dhis.api.mobile.model.PatientIdentifier( idTypeName, id.getIdentifier() ) );
+            }
+
+            patientModel.setIdentifiers( identifiers );
+        }
+
+        patientModel.setPatientAttValues( patientAtts );
+
+        // Set all programs
+
+        List<ProgramInstance> listOfProgramInstance = new ArrayList<ProgramInstance>(
+            programInstanceService.getProgramInstances( patient ) );
+        if ( listOfProgramInstance.size() > 0 )
+        {
+            for ( ProgramInstance each : listOfProgramInstance )
+            {
+                org.hisp.dhis.api.mobile.model.LWUITmodel.Program mobileProgram = new org.hisp.dhis.api.mobile.model.LWUITmodel.Program();
+                mobileProgram.setVersion( each.getProgram().getVersion() );
+                mobileProgram.setId( each.getId() );
+                mobileProgram.setName( each.getProgram().getName() );
+                mobileProgram.setCompleted( each.isCompleted() );
+                mobileProgram.setProgramStages( getMobileProgramStages( patient, each, each.getProgram() ) );
+                mobileProgramList.add( mobileProgram );
+            }
+        }
+
+        /*Set<Program> programs = patient.getPrograms();
+        if ( programs.size() > 0 )
+        {
+            for ( Program each : programs )
+            {
+
+                org.hisp.dhis.api.mobile.model.LWUITmodel.Program mobileProgram = new org.hisp.dhis.api.mobile.model.LWUITmodel.Program();
+                mobileProgram.setVersion( each.getVersion() );
+                mobileProgram.setId( listOfProgramInstance.get( 0 ).getId() );
+                mobileProgram.setName( each.getName() );
+                mobileProgram.setProgramStages( getMobileProgramStages( patient, each ) );
+                mobileProgramList.add( mobileProgram );
+            }
+        }*/
+
+        patientModel.setPrograms( mobileProgramList );
+
+        // Set Relationship
+        List<Relationship> relationships = new ArrayList<Relationship>(
+            relationshipService.getRelationshipsForPatient( patient ) );
+        List<org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship> relationshipList = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship>();
+        for ( Relationship eachRelationship : relationships )
+        {
+            org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship relationshipMobile = new org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship();
+            relationshipMobile.setId( eachRelationship.getId() );
+            // relationshipMobile.setName(
+            // eachRelationship.getRelationshipType().getName() );
+            if ( eachRelationship.getPatientA().getId() == patient.getId() )
+            {
+                relationshipMobile.setName( eachRelationship.getRelationshipType().getaIsToB() );
+                relationshipMobile.setPersonName( eachRelationship.getPatientB().getFullName() );
+            }
+            else
+            {
+                relationshipMobile.setName( eachRelationship.getRelationshipType().getbIsToA() );
+                relationshipMobile.setPersonName( eachRelationship.getPatientA().getFullName() );
+            }
+            relationshipList.add( relationshipMobile );
+        }
+        patientModel.setRelationships( relationshipList );
+        return patientModel;
+    }
+
+    private List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage> getMobileProgramStages( Patient patient, ProgramInstance programInstance,
+        Program program )
+    {
+        
+        List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage> mobileProgramStages = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage>();
+        for ( ProgramStage eachProgramStage : program.getProgramStages() )
+        {
+            ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( programInstance, eachProgramStage );
+            org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage mobileProgramStage = new org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage();
+            List<org.hisp.dhis.api.mobile.model.LWUITmodel.Section> mobileSections = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.Section>();
+            mobileProgramStage.setId( programStageInstance.getId() );
+            mobileProgramStage.setName( eachProgramStage.getName() );
+            
+            // is repeatable
+            mobileProgramStage.setRepeatable( eachProgramStage.getIrregular() );
+
+            // is completed
+            mobileProgramStage.setCompleted( checkIfProgramStageCompleted( patient, program, eachProgramStage ) );
+
+            // Set all data elements
+            mobileProgramStage.setDataElements( getDataElementsForMobile( eachProgramStage,programStageInstance ) );
+            
+            // Set all program sections
+            if ( eachProgramStage.getProgramStageSections().size() > 0 )
+            {
+                for ( ProgramStageSection eachSection : eachProgramStage.getProgramStageSections() )
+                {
+                    org.hisp.dhis.api.mobile.model.LWUITmodel.Section mobileSection = new org.hisp.dhis.api.mobile.model.LWUITmodel.Section();
+                    mobileSection.setId( eachSection.getId() );
+                    mobileSection.setName( eachSection.getName() );
+                    
+                    // Set all data elements' id, then we could have full from data element list of program stage
+                    List<Integer> dataElementIds = new ArrayList<Integer>();
+                    for ( ProgramStageDataElement eachPogramStageDataElement : eachSection.getProgramStageDataElements() )
+                    {
+                        dataElementIds.add( eachPogramStageDataElement.getDataElement().getId() );
+                    }
+                    mobileSection.setDataElementIds( dataElementIds );
+                    mobileSections.add( mobileSection );
+                }
+            }
+            mobileProgramStage.setSections( mobileSections );
+
+            mobileProgramStages.add( mobileProgramStage );
+
+        }
+        return mobileProgramStages;
+    }
+
+    private boolean checkIfProgramStageCompleted( Patient patient, Program program, ProgramStage programstage )
+    {
+
+        Collection<ProgramInstance> programIntances = programInstanceService.getProgramInstances( patient, program,
+            false );
+        ProgramStageInstance programStageInstance = new ProgramStageInstance();
+        if ( programIntances != null && programIntances.size() == 1 )
+        {
+            for ( ProgramInstance each : programIntances )
+            {
+                programStageInstance = programStageInstanceService.getProgramStageInstance( each, programstage );
+            }
+        }
+        return programStageInstance.isCompleted();
+    }
+    
+    private List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement> getDataElementsForMobile( ProgramStage programStage, ProgramStageInstance programStageInstance )
+    {
+        List<ProgramStageDataElement> programStageDataElements = new ArrayList<ProgramStageDataElement>(programStage.getProgramStageDataElements());
+        List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement> mobileDataElements = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement>();
+        for ( ProgramStageDataElement programStageDataElement : programStageDataElements )
+        {
+            org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement mobileDataElement = new org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement();
+            mobileDataElement.setId( programStageDataElement.getDataElement().getId() );
+            mobileDataElement.setName( programStageDataElement.getDataElement().getName() );
+            mobileDataElement.setType( programStageDataElement.getDataElement().getType() );
+            mobileDataElement.setCompulsory( programStageDataElement.isCompulsory()  );
+            PatientDataValue patientDataValue = dataValueService.getPatientDataValue( programStageInstance, programStageDataElement.getDataElement() );
+            if( patientDataValue != null )
+            {
+                mobileDataElement.setValue( patientDataValue.getValue() );
+            }
+            else
+            {
+                mobileDataElement.setValue("");
+            }
+            if(programStageDataElement.getDataElement().getOptionSet() != null)
+            {
+                mobileDataElement.setOptionSet( modelMapping.getOptionSet( programStageDataElement.getDataElement()));
+            }
+            else
+            {
+                mobileDataElement.setOptionSet( null );
+            }
+            if( programStageDataElement.getDataElement().getCategoryCombo() != null )
+            {
+                mobileDataElement.setCategoryOptionCombos( modelMapping.getCategoryOptionCombos( programStageDataElement.getDataElement() ) );
+            }
+            else
+            {
+                mobileDataElement.setCategoryOptionCombos( null );
+            }
+            mobileDataElements.add( mobileDataElement );
+        }
+        return mobileDataElements;
+    }
+
     private PatientMobileSetting getSettings()
     {
         PatientMobileSetting setting = null;
@@ -530,12 +794,19 @@
         this.patientMobileSettingService = patientMobileSettingService;
     }
 
+    @Required
+    public void setModelMapping( org.hisp.dhis.mobile.service.ModelMapping modelMapping )
+    {
+        this.modelMapping = modelMapping;
+    }
+    
     // public void setActivityPlanService(
     // org.hisp.dhis.activityplan.ActivityPlanService activityPlanService )
     // {
     // this.activityPlanService = activityPlanService;
     // }
 
+
     public PatientMobileSetting getSetting()
     {
         return setting;
@@ -578,8 +849,25 @@
         this.beneficiary = beneficiary;
     }
 
+    @Required
+    public void setProgramInstanceService( ProgramInstanceService programInstanceService )
+    {
+        this.programInstanceService = programInstanceService;
+    }
+
+    public void setRelationshipService( RelationshipService relationshipService )
+    {
+        this.relationshipService = relationshipService;
+    }
+
+    @Required
+    public void setProgramStageSectionService( ProgramStageSectionService programStageSectionService )
+    {
+        this.programStageSectionService = programStageSectionService;
+    }
+    
     @Override
-    public Beneficiary findPatient( String fullName )
+    public org.hisp.dhis.api.mobile.model.LWUITmodel.Patient findPatient( String fullName )
         throws NotAllowedException
     {
         int startIndex = fullName.indexOf( ' ' );
@@ -604,7 +892,7 @@
             }
         }
         List<Patient> patients = (List<Patient>) this.patientService.getPatientByFullname( firstName + middleName
-            + lastName);
+            + lastName );
 
         if ( patients.size() > 1 )
         {
@@ -616,8 +904,9 @@
         }
         else
         {
-            return getBeneficiaryModel( patients.get( 0 ) );
+            org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patient = getPatientModel( patients.get( 0 ) );
+
+            return patient;
         }
     }
-
 }

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml	2012-12-18 08:47:37 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml	2013-02-01 07:09:23 +0000
@@ -26,6 +26,10 @@
     <property name="patientIdentifierService" ref="org.hisp.dhis.patient.PatientIdentifierService" />
     <property name="programStageSectionService" ref="org.hisp.dhis.program.ProgramStageSectionService"/>
 	<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
+	<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
+	<property name="relationshipService" ref="org.hisp.dhis.relationship.RelationshipService" />
+	<property name="modelMapping" ref="org.hisp.dhis.mobile.service.ModelMapping" />
+	
   </bean>
 
   <bean id="org.hisp.dhis.mobile.api.IProgramService" class="org.hisp.dhis.mobile.service.DefaultProgramService">

=== 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	2013-01-22 08:08:14 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java	2013-02-01 07:09:23 +0000
@@ -11,13 +11,13 @@
 import org.hisp.dhis.api.mobile.NotAllowedException;
 import org.hisp.dhis.api.mobile.model.ActivityPlan;
 import org.hisp.dhis.api.mobile.model.ActivityValue;
-import org.hisp.dhis.api.mobile.model.Beneficiary;
 import org.hisp.dhis.api.mobile.model.Contact;
 import org.hisp.dhis.api.mobile.model.DataSetList;
 import org.hisp.dhis.api.mobile.model.DataSetValue;
 import org.hisp.dhis.api.mobile.model.DataStreamSerializable;
 import org.hisp.dhis.api.mobile.model.MobileModel;
 import org.hisp.dhis.api.mobile.model.ModelList;
+import org.hisp.dhis.api.mobile.model.LWUITmodel.Patient;
 import org.hisp.dhis.api.mobile.model.SMSCode;
 import org.hisp.dhis.api.mobile.model.SMSCommand;
 import org.hisp.dhis.i18n.I18nService;
@@ -274,8 +274,8 @@
 
     @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/orgUnits/{id}/findPatient" )
     @ResponseBody
-    public Beneficiary findPatientByName( @PathVariable int id, @RequestHeader( "name" ) String fullName )
-        throws NotAllowedException
+    public Patient findPatientByName( @PathVariable int id, @RequestHeader( "name" ) String fullName)
+    throws NotAllowedException
     {
         return activityReportingService.findPatient( fullName );
     }

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.java	2013-01-28 09:42:58 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.java	2013-02-01 07:09:23 +0000
@@ -479,6 +479,7 @@
                 // build patient data value
                 PatientDataValue patientDataValue = new PatientDataValue( programStageInstance, dataElement,
                     new Date(), value );
+                
                 String providedElseWhereValue = parameterMap.get( "CB" + dataElementId );
 
                 if ( providedElseWhereValue != null )