← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10460: [mobile] person registration update server

 

------------------------------------------------------------
revno: 10460
committer: Homg Em <em.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-04-03 15:06:46 +0700
message:
  [mobile] person registration update server
added:
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/PatientIdentifierAndAttribute.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java
  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/FacilityReportingService.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/MobileOrgUnitLinks.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientIdentifier.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/FacilityReportingServiceImpl.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/MobileClientController.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-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java	2013-03-07 05:15:13 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java	2013-04-03 08:06:46 +0000
@@ -43,7 +43,7 @@
     void updatePatientAttribute( PatientAttribute patientAttribute );
 
     PatientAttribute getPatientAttribute( int id );
-    
+
     PatientAttribute getPatientAttribute( String uid );
 
     PatientAttribute getPatientAttributeByName( String name );
@@ -51,12 +51,13 @@
     Collection<PatientAttribute> getAllPatientAttributes();
 
     Collection<PatientAttribute> getPatientAttributesByValueType( String valueType );
-    
+
     Collection<PatientAttribute> getOptionalPatientAttributesWithoutGroup();
-    
-    Collection<PatientAttribute> getPatientAttributesByMandatory(boolean mandatory);
-    
-    PatientAttribute getPatientAttributeByGroupBy(boolean groupBy);
-    
+
+    Collection<PatientAttribute> getPatientAttributesByMandatory( boolean mandatory );
+
+    PatientAttribute getPatientAttributeByGroupBy( boolean groupBy );
+
     Collection<PatientAttribute> getPatientAttributesWithoutGroup();
+
 }

=== 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-04-01 04:56:59 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java	2013-04-03 08:06:46 +0000
@@ -27,13 +27,17 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.Collection;
+
 import org.hisp.dhis.api.mobile.model.ActivityPlan;
 import org.hisp.dhis.api.mobile.model.ActivityValue;
+import org.hisp.dhis.api.mobile.model.PatientAttribute;
 import org.hisp.dhis.api.mobile.model.LWUITmodel.Patient;
 import org.hisp.dhis.api.mobile.model.LWUITmodel.Program;
 import org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage;
 import org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.patient.PatientIdentifierType;
 
 /**
  * Provides services for activity reporting
@@ -59,12 +63,24 @@
     public Patient enrollProgram( String enrollInfo, int orgUnitId )
         throws NotAllowedException;
 
+    public Collection<PatientIdentifierType> getIdentifierTypes();
+
+    public Collection<org.hisp.dhis.patient.PatientAttribute> getPatientAtts();
+
+    public Collection<PatientIdentifierType> getIdentifiers();
+
+    public Collection<PatientAttribute> getAttsForMobile();
+
+    public Collection<org.hisp.dhis.api.mobile.model.PatientIdentifier> getIdentifiersForMobile();
+
+    public Collection<PatientAttribute> getPatientAttributesForMobile();
+
     public Patient addRelationship( Relationship enrollmentRelationship, int orgUnitId )
         throws NotAllowedException;
 
     public Program getAllAnonymousProgram( int orgUnitId )
         throws NotAllowedException;
-    
+
     public Program findProgram( String programInfo )
         throws NotAllowedException;
 

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/FacilityReportingService.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/FacilityReportingService.java	2012-12-18 08:47:37 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/FacilityReportingService.java	2013-04-03 08:06:46 +0000
@@ -48,19 +48,20 @@
 
     public DataSet getDataSetForLocale( int dataSetId, Locale locale );
 
-    /** Save {@link DataSetValue} to given {@link OrganisationUnit}
+    /**
+     * Save {@link DataSetValue} to given {@link OrganisationUnit}
+     * 
      * @param unit - the Organisation unit to save to
      * @param dataSetValue - the data set value to save
      * @throws NotAllowedException if saving is not allowed
      */
     public void saveDataSetValues( OrganisationUnit unit, DataSetValue dataSetValue )
         throws NotAllowedException;
-    
-    public DataSetList getUpdatedDataSet(DataSetList dataSetList, OrganisationUnit unit, String locale);
-    
+
+    public DataSetList getUpdatedDataSet( DataSetList dataSetList, OrganisationUnit unit, String locale );
+
     public DataSetList getDataSetsForLocale( OrganisationUnit unit, String locale );
-    
+
     public Contact updateContactForMobile();
 
-
 }

=== 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	2013-03-29 07:39:49 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java	2013-04-03 08:06:46 +0000
@@ -31,6 +31,7 @@
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -74,7 +75,7 @@
     private Character dobType;
 
     private List<Program> programs;
-    
+
     private List<Program> enrollmentPrograms;
 
     private List<Relationship> relationships;
@@ -313,7 +314,7 @@
         dout.writeUTF( this.getMiddleName() );
         dout.writeUTF( this.getLastName() );
         dout.writeInt( this.getAge() );
-        
+
         if ( gender != null )
         {
             dout.writeBoolean( true );
@@ -384,7 +385,7 @@
         dout.writeInt( atts.size() );
         for ( PatientAttribute att : atts )
         {
-            dout.writeUTF( att.getName() + ":" + att.getValue() );
+            att.serialize( dout );
         }
 
         // Write PatientIdentifier
@@ -394,20 +395,23 @@
             each.serialize( dout );
         }
 
+        // Write Enrolled Programs
+
         // Write Program
+
         dout.writeInt( programs.size() );
-        for ( Program each: programs )
+        for ( Program each : programs )
         {
             each.serialize( dout );
         }
-        
+
         // Write Relationships
         dout.writeInt( relationships.size() );
         for ( Relationship each : relationships )
         {
             each.serialize( dout );
         }
-        
+
         // Write Enrolled Programs
 
         dout.writeInt( enrollmentPrograms.size() );
@@ -456,13 +460,27 @@
             this.setBirthDate( null );
         }
 
-        if ( din.readBoolean() )
+        // atts & identifiers
+
+        this.patientAttValues = new ArrayList<PatientAttribute>();
+        int attsNumb = din.readInt();
+        for ( int j = 0; j < attsNumb; j++ )
         {
-            this.setRegistrationDate( new Date( din.readLong() ) );
+            PatientAttribute pa = new PatientAttribute();
+            pa.deSerialize( din );
+            this.patientAttValues.add( pa );
+
         }
-        else
+
+        this.identifiers = new ArrayList<PatientIdentifier>();
+        int numbIdentifiers = din.readInt();
+
+        for ( int i = 0; i < numbIdentifiers; i++ )
         {
-            this.setRegistrationDate( null );
+            PatientIdentifier identifier = new PatientIdentifier();
+            identifier.deSerialize( din );
+            this.identifiers.add( identifier );
+
         }
 
     }

=== added file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/PatientIdentifierAndAttribute.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/PatientIdentifierAndAttribute.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/PatientIdentifierAndAttribute.java	2013-04-03 08:06:46 +0000
@@ -0,0 +1,130 @@
+package org.hisp.dhis.api.mobile.model.LWUITmodel;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.Collection;
+
+import org.hisp.dhis.api.mobile.model.DataStreamSerializable;
+import org.hisp.dhis.api.mobile.model.PatientAttribute;
+import org.hisp.dhis.api.mobile.model.PatientIdentifier;
+
+public class PatientIdentifierAndAttribute
+    implements DataStreamSerializable
+{
+    private String clientVersion;
+
+    private Collection<PatientIdentifier> patientIdentifiers;
+
+    private Collection<PatientAttribute> patientAttributes;
+
+    public String getClientVersion()
+    {
+        return clientVersion;
+    }
+
+    public void setClientVersion( String clientVersion )
+    {
+        this.clientVersion = clientVersion;
+    }
+
+    public Collection<PatientIdentifier> getPatientIdentifiers()
+    {
+        return patientIdentifiers;
+    }
+
+    public void setPatientIdentifiers( Collection<PatientIdentifier> patientIdentifiers )
+    {
+        this.patientIdentifiers = patientIdentifiers;
+    }
+
+    public Collection<PatientAttribute> getPatientAttributes()
+    {
+        return patientAttributes;
+    }
+
+    public void setPatientAttributes( Collection<PatientAttribute> patientAttributes )
+    {
+        this.patientAttributes = patientAttributes;
+    }
+
+    @Override
+    public void serialize( DataOutputStream dout )
+        throws IOException
+    {
+        if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_EIGHT ) )
+        {
+            this.serializeVersion2_8( dout );
+        }
+        else if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_NINE ) )
+        {
+            this.serializeVersion2_9( dout );
+        }
+        else if ( this.getClientVersion().equals( DataStreamSerializable.TWO_POINT_TEN ) )
+        {
+            this.serializeVersion2_10( dout );
+        }
+    }
+
+    @Override
+    public void deSerialize( DataInputStream dataInputStream )
+        throws IOException
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+    @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 dout )
+        throws IOException
+    {
+
+        if ( patientIdentifiers == null )
+        {
+            dout.writeInt( 0 );
+        }
+        else
+        {
+
+            dout.writeInt( patientIdentifiers.size() );
+
+            for ( PatientIdentifier ptype : patientIdentifiers )
+            {
+                ptype.setClientVersion( DataStreamSerializable.TWO_POINT_TEN );
+                ptype.serialize( dout );
+            }
+
+        }
+
+        if ( patientAttributes == null )
+        {
+            dout.writeInt( 0 );
+        }
+        else
+        {
+            dout.writeInt( patientAttributes.size() );
+            for ( PatientAttribute pa : patientAttributes )
+            {
+                pa.setClientVersion( DataStreamSerializable.TWO_POINT_TEN );
+                pa.serialize( dout );
+            }
+        }
+
+    }
+}

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileOrgUnitLinks.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileOrgUnitLinks.java	2013-03-29 07:39:49 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileOrgUnitLinks.java	2013-04-03 08:06:46 +0000
@@ -71,13 +71,15 @@
     private String enrollProgramUrl;
 
     private String registerPersonUrl;
-    
+
     private String addRelationshipUrl;
-    
+
     private String downloadAnonymousProgramUrl;
-    
+
     private String findProgramUrl;
 
+    private String getVariesInfoUrl;
+
     @XmlAttribute
     public int getId()
     {
@@ -240,6 +242,16 @@
         this.registerPersonUrl = registerPersonUrl;
     }
 
+    public String getGetVariesInfoUrl()
+    {
+        return getVariesInfoUrl;
+    }
+
+    public void setGetVariesInfoUrl( String getVariesInfoUrl )
+    {
+        this.getVariesInfoUrl = getVariesInfoUrl;
+    }
+
     public String getAddRelationshipUrl()
     {
         return addRelationshipUrl;
@@ -289,6 +301,7 @@
         dataOutputStream.writeUTF( this.registerPersonUrl );
         dataOutputStream.writeUTF( this.uploadProgramStageUrl );
         dataOutputStream.writeUTF( this.enrollProgramUrl );
+        dataOutputStream.writeUTF( this.getVariesInfoUrl );
         dataOutputStream.writeUTF( this.addRelationshipUrl );
         dataOutputStream.writeUTF( this.downloadAnonymousProgramUrl );
         dataOutputStream.writeUTF( this.findProgramUrl );
@@ -309,9 +322,10 @@
         this.updateNewVersionUrl = dataInputStream.readUTF();
         this.updateContactUrl = dataInputStream.readUTF();
         this.findPatientUrl = dataInputStream.readUTF();
+        this.registerPersonUrl = dataInputStream.readUTF();
         this.uploadProgramStageUrl = dataInputStream.readUTF();
-        this.registerPersonUrl = dataInputStream.readUTF();
         this.enrollProgramUrl = dataInputStream.readUTF();
+        this.getVariesInfoUrl = dataInputStream.readUTF();
         this.addRelationshipUrl = dataInputStream.readUTF();
         this.downloadAnonymousProgramUrl = dataInputStream.readUTF();
     }
@@ -364,12 +378,12 @@
         dataOutputStream.writeUTF( this.updateNewVersionUrl );
         dataOutputStream.writeUTF( this.updateContactUrl );
         dataOutputStream.writeUTF( this.findPatientUrl );
+        dataOutputStream.writeUTF( this.registerPersonUrl );
         dataOutputStream.writeUTF( this.uploadProgramStageUrl );
-        dataOutputStream.writeUTF( this.registerPersonUrl );
         dataOutputStream.writeUTF( this.enrollProgramUrl );
+        dataOutputStream.writeUTF( this.getVariesInfoUrl );
         dataOutputStream.writeUTF( this.addRelationshipUrl );
         dataOutputStream.writeUTF( this.downloadAnonymousProgramUrl );
         dataOutputStream.writeUTF( this.findProgramUrl );
     }
-
 }

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientIdentifier.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientIdentifier.java	2013-02-25 06:32:56 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientIdentifier.java	2013-04-03 08:06:46 +0000
@@ -121,7 +121,7 @@
         throws IOException
     {
         // TODO Auto-generated method stub
-        
+
     }
 
 }

=== 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-04-03 04:16:53 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2013-04-03 08:06:46 +0000
@@ -36,6 +36,7 @@
 import java.util.Comparator;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -62,6 +63,7 @@
 import org.hisp.dhis.patient.PatientIdentifier;
 import org.hisp.dhis.patient.PatientIdentifierService;
 import org.hisp.dhis.patient.PatientIdentifierType;
+import org.hisp.dhis.patient.PatientIdentifierTypeService;
 import org.hisp.dhis.patient.PatientMobileSetting;
 import org.hisp.dhis.patient.PatientService;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
@@ -140,6 +142,56 @@
 
     private org.hisp.dhis.mobile.service.ModelMapping modelMapping;
 
+    private PatientIdentifierTypeService patientIdentifierTypeService;
+
+    public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService )
+    {
+        this.patientIdentifierTypeService = patientIdentifierTypeService;
+    }
+
+    private Collection<PatientIdentifier> patientIdentifiers;
+
+    public Collection<PatientIdentifier> getPatientIdentifiers()
+    {
+        return patientIdentifiers;
+    }
+
+    public void setPatientIdentifiers( Collection<PatientIdentifier> patientIdentifiers )
+    {
+        this.patientIdentifiers = patientIdentifiers;
+    }
+
+    private Collection<PatientIdentifierType> patientIdentifierTypes;
+
+    public Collection<PatientIdentifierType> getPatientIdentifierTypes()
+    {
+        return patientIdentifierTypes;
+    }
+
+    public void setPatientIdentifierTypes( Collection<PatientIdentifierType> patientIdentifierTypes )
+    {
+        this.patientIdentifierTypes = patientIdentifierTypes;
+    }
+
+    private Collection<org.hisp.dhis.patient.PatientAttribute> patientAttributes;
+
+    public Collection<org.hisp.dhis.patient.PatientAttribute> getPatientAttributes()
+    {
+        return patientAttributes;
+    }
+
+    public void setPatientAttributes( Collection<org.hisp.dhis.patient.PatientAttribute> patientAttributes )
+    {
+        this.patientAttributes = patientAttributes;
+    }
+
+    private PatientAttributeService patientAttributeService;
+
+    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
+    {
+        this.patientAttributeService = patientAttributeService;
+    }
+
     // -------------------------------------------------------------------------
     // MobileDataSetService
     // -------------------------------------------------------------------------
@@ -422,7 +474,7 @@
         if ( mobileProgramStage.isSingleEvent() )
         {
             ProgramStage programStage = programStageService.getProgramStage( mobileProgramStage.getId() );
-            
+
             ProgramInstance programInstance = new ProgramInstance();
 
             programInstance.setEnrollmentDate( new Date() );
@@ -434,7 +486,7 @@
             programInstance.setCompleted( true );
 
             programInstanceService.addProgramInstance( programInstance );
-            
+
             ProgramStageInstance programStageInstance = new ProgramStageInstance();
 
             programStageInstance.setProgramInstance( programInstance );
@@ -450,7 +502,7 @@
             programStageInstance.setOrganisationUnit( orgUnitService.getOrganisationUnit( orgUnitId ) );
 
             programStageInstanceService.addProgramStageInstance( programStageInstance );
-            
+
             List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement> dataElements = mobileProgramStage
                 .getDataElements();
 
@@ -468,7 +520,8 @@
         }
         else
         {
-            ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( mobileProgramStage.getId() );
+            ProgramStageInstance programStageInstance = programStageInstanceService
+                .getProgramStageInstance( mobileProgramStage.getId() );
 
             List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement> dataElements = mobileProgramStage
                 .getDataElements();
@@ -827,7 +880,7 @@
         {
             for ( ProgramInstance each : listOfProgramInstance )
             {
-                mobileProgramList.add( getMobileProgram( patient, each ));
+                mobileProgramList.add( getMobileProgram( patient, each ) );
             }
         }
 
@@ -888,11 +941,12 @@
         patientModel.setEnrollmentRelationships( enrollmentRelationshipMobileList );
         return patientModel;
     }
-    
-    private org.hisp.dhis.api.mobile.model.LWUITmodel.Program getMobileProgram( Patient patient, ProgramInstance programInstance)
+
+    private org.hisp.dhis.api.mobile.model.LWUITmodel.Program getMobileProgram( Patient patient,
+        ProgramInstance programInstance )
     {
         org.hisp.dhis.api.mobile.model.LWUITmodel.Program mobileProgram = new org.hisp.dhis.api.mobile.model.LWUITmodel.Program();
-        
+
         mobileProgram.setVersion( programInstance.getProgram().getVersion() );
         mobileProgram.setId( programInstance.getId() );
         mobileProgram.setName( programInstance.getProgram().getName() );
@@ -900,8 +954,9 @@
         mobileProgram.setProgramStages( getMobileProgramStages( patient, programInstance ) );
         return mobileProgram;
     }
-    
-    private List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage> getMobileProgramStages( Patient patient, ProgramInstance programInstance )
+
+    private List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage> getMobileProgramStages( Patient patient,
+        ProgramInstance programInstance )
     {
 
         List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage> mobileProgramStages = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage>();
@@ -918,7 +973,8 @@
             mobileProgramStage.setRepeatable( eachProgramStage.getIrregular() );
 
             // is completed
-            mobileProgramStage.setCompleted( checkIfProgramStageCompleted( patient, programInstance.getProgram(), eachProgramStage ) );
+            mobileProgramStage.setCompleted( checkIfProgramStageCompleted( patient, programInstance.getProgram(),
+                eachProgramStage ) );
 
             // is single event
             mobileProgramStage.setSingleEvent( programInstance.getProgram().isSingleEvent() );
@@ -983,10 +1039,10 @@
             mobileDataElement.setId( programStageDataElement.getDataElement().getId() );
             mobileDataElement.setName( programStageDataElement.getDataElement().getName() );
             mobileDataElement.setType( programStageDataElement.getDataElement().getType() );
-            
-            //problem
+
+            // problem
             mobileDataElement.setCompulsory( programStageDataElement.isCompulsory() );
-            
+
             mobileDataElement.setNumberType( programStageDataElement.getDataElement().getNumberType() );
 
             PatientDataValue patientDataValue = dataValueService.getPatientDataValue( programStageInstance,
@@ -1133,9 +1189,10 @@
 
         OrganisationUnit organisationUnit = orgUnitService.getOrganisationUnit( orgUnitId );
 
-        List<Program> tempPrograms = new ArrayList<Program>( programService.getProgramsByCurrentUser( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ));
+        List<Program> tempPrograms = new ArrayList<Program>(
+            programService.getProgramsByCurrentUser( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) );
         List<Program> programs = new ArrayList<Program>();
-        
+
         for ( Program program : tempPrograms )
         {
             if ( program.getOrganisationUnits().contains( organisationUnit ) )
@@ -1143,7 +1200,7 @@
                 programs.add( program );
             }
         }
-        
+
         if ( programs.size() != 0 )
         {
             if ( programs.size() == 1 )
@@ -1169,7 +1226,6 @@
             throw NotAllowedException.NO_PROGRAM_FOUND;
         }
     }
-    
 
     @Override
     public org.hisp.dhis.api.mobile.model.LWUITmodel.Program findProgram( String programInfo )
@@ -1182,7 +1238,7 @@
         else
         {
             Program program = programService.getProgram( Integer.parseInt( programInfo ) );
-            if( program.isSingleEvent() )
+            if ( program.isSingleEvent() )
             {
                 return getMobileAnonymousProgram( program );
             }
@@ -1234,10 +1290,10 @@
             mobileDataElement.setId( programStageDataElement.getDataElement().getId() );
             mobileDataElement.setName( programStageDataElement.getDataElement().getName() );
             mobileDataElement.setType( programStageDataElement.getDataElement().getType() );
-            
-            //problem
+
+            // problem
             mobileDataElement.setCompulsory( programStageDataElement.isCompulsory() );
-            
+
             mobileDataElement.setNumberType( programStageDataElement.getDataElement().getNumberType() );
 
             mobileDataElement.setValue( "" );
@@ -1435,6 +1491,84 @@
         this.programService = programService;
     }
 
+    public Collection<PatientIdentifierType> getIdentifierTypes()
+    {
+        patientIdentifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
+        Collection<Program> programs = programService.getAllPrograms();
+        for ( Program program : programs )
+        {
+            patientIdentifierTypes.removeAll( program.getPatientIdentifierTypes() );
+        }
+        return patientIdentifierTypes;
+    }
+
+    public Collection<org.hisp.dhis.patient.PatientAttribute> getPatientAtts()
+    {
+
+        patientAttributes = patientAttributeService.getAllPatientAttributes();
+
+        Collection<Program> programs = programService.getAllPrograms();
+
+        for ( Program program : programs )
+        {
+            patientAttributes.removeAll( program.getPatientAttributes() );
+        }
+
+        return patientAttributes;
+    }
+
+    public Collection<PatientIdentifierType> getIdentifiers()
+    {
+        patientIdentifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
+
+        Collection<Program> programs = programService.getAllPrograms();
+        for ( Program program : programs )
+        {
+            patientIdentifierTypes.removeAll( program.getPatientIdentifierTypes() );
+        }
+        return patientIdentifierTypes;
+
+    }
+
+    public Collection<PatientAttribute> getAttsForMobile()
+    {
+        Collection<PatientAttribute> list = new HashSet<PatientAttribute>();
+
+        for ( org.hisp.dhis.patient.PatientAttribute patientAtt : getPatientAtts() )
+        {
+            list.add( new PatientAttribute( patientAtt.getName(), null ) );
+        }
+
+        return list;
+
+    }
+
+    @Override
+    public Collection<org.hisp.dhis.api.mobile.model.PatientIdentifier> getIdentifiersForMobile()
+    {
+        Collection<org.hisp.dhis.api.mobile.model.PatientIdentifier> list = new HashSet<org.hisp.dhis.api.mobile.model.PatientIdentifier>();
+        for ( PatientIdentifierType identifierType : getIdentifiers() )
+        {
+            String id = "";
+            String idt = identifierType.getName();
+            list.add( new org.hisp.dhis.api.mobile.model.PatientIdentifier( idt, id ) );
+        }
+        return list;
+    }
+
+    @Override
+    public Collection<PatientAttribute> getPatientAttributesForMobile()
+    {
+        Collection<PatientAttribute> list = new HashSet<PatientAttribute>();
+        for ( org.hisp.dhis.patient.PatientAttribute pa : getPatientAtts() )
+        {
+            String name = pa.getName();
+            String value = "";
+            list.add( new PatientAttribute( name, value ) );
+        }
+        return list;
+    }
+
     @Required
     public void setRelationshipTypeService( RelationshipTypeService relationshipTypeService )
     {

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/FacilityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/FacilityReportingServiceImpl.java	2012-12-26 08:33:13 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/FacilityReportingServiceImpl.java	2013-04-03 08:06:46 +0000
@@ -30,6 +30,7 @@
 import static org.hisp.dhis.i18n.I18nUtils.i18n;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
@@ -37,6 +38,7 @@
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.api.mobile.FacilityReportingService;
@@ -55,6 +57,9 @@
 import org.hisp.dhis.dataset.CompleteDataSetRegistrationService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.patient.PatientAttributeService;
+import org.hisp.dhis.patient.PatientIdentifierType;
+import org.hisp.dhis.patient.PatientIdentifierTypeService;
 import org.hisp.dhis.period.DailyPeriodType;
 import org.hisp.dhis.period.MonthlyPeriodType;
 import org.hisp.dhis.period.Period;
@@ -63,6 +68,8 @@
 import org.hisp.dhis.period.QuarterlyPeriodType;
 import org.hisp.dhis.period.WeeklyPeriodType;
 import org.hisp.dhis.period.YearlyPeriodType;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.user.CurrentUserService;
 import org.springframework.beans.factory.annotation.Required;
 
@@ -97,6 +104,18 @@
 
     private OrganisationUnitService oUnitService;
 
+    private ProgramService programService;
+
+    public ProgramService getProgramService()
+    {
+        return programService;
+    }
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
     // -------------------------------------------------------------------------
     // Service methods
     // -------------------------------------------------------------------------
@@ -263,8 +282,8 @@
                 Section section = new Section();
                 section.setId( s.getId() );
                 section.setName( s.getName() );
-                
-                //Remove grey fields(in order to not display them on mobile)
+
+                // Remove grey fields(in order to not display them on mobile)
                 List<DataElement> dataElementList = getDataElements( locale, s.getDataElements() );
 
                 List<DataElement> dataElementListFinal = new ArrayList<DataElement>( dataElementList );

=== 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	2013-03-29 07:39:49 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml	2013-04-03 08:06:46 +0000
@@ -33,9 +33,10 @@
 	<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 	<property name="orgUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService"></property>
 	<property name="modelMapping" ref="org.hisp.dhis.mobile.service.ModelMapping" />
+	<property name="patientIdentifierTypeService" ref="org.hisp.dhis.patient.PatientIdentifierTypeService"></property>
+	<property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService"></property>
 	<property name="relationshipTypeService" ref="org.hisp.dhis.relationship.RelationshipTypeService"></property>
 	<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
-	
   </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/MobileClientController.java'
--- dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java	2013-03-29 09:19:53 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java	2013-04-03 08:06:46 +0000
@@ -1,174 +1,152 @@
-package org.hisp.dhis.api.mobile.controller;
-
-/*
- * 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.
- */
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import javax.servlet.http.HttpServletRequest;
-import org.hisp.dhis.api.mobile.NotAllowedException;
-import org.hisp.dhis.api.mobile.model.DataStreamSerializable;
-import org.hisp.dhis.api.mobile.model.MobileOrgUnitLinks;
-import org.hisp.dhis.api.mobile.model.OrgUnits;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.user.CurrentUserService;
-import org.hisp.dhis.user.User;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.web.util.UrlUtils;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-@Controller
-@RequestMapping( value = "/mobile" )
-public class MobileClientController
-    extends AbstractMobileController
-{
-    @Autowired
-    private CurrentUserService currentUserService;
-
-    @RequestMapping( method = RequestMethod.GET )
-    @ResponseBody
-    public OrgUnits getOrgUnitsForUser2_8( HttpServletRequest request )
-        throws NotAllowedException
-    {
-        User user = currentUserService.getCurrentUser();
-
-        if ( user == null )
-        {
-            throw NotAllowedException.NO_USER;
-        }
-
-        Collection<OrganisationUnit> units = user.getOrganisationUnits();
-
-        List<MobileOrgUnitLinks> unitList = new ArrayList<MobileOrgUnitLinks>();
-        for ( OrganisationUnit unit : units )
-        {
-            unitList.add( getOrgUnit( unit, request ) );
-        }
-        OrgUnits orgUnits = new OrgUnits( unitList );
-        orgUnits.setClientVersion( DataStreamSerializable.TWO_POINT_EIGHT );
-        return orgUnits;
-    }
-
-    @RequestMapping( method = RequestMethod.GET, value = "/{version}" )
-    @ResponseBody
-    public OrgUnits getOrgUnitsForUser( HttpServletRequest request, @PathVariable String version )
-        throws NotAllowedException
-    {
-        User user = currentUserService.getCurrentUser();
-
-        if ( user == null )
-        {
-            throw NotAllowedException.NO_USER;
-        }
-
-        Collection<OrganisationUnit> units = user.getOrganisationUnits();
-
-        List<MobileOrgUnitLinks> unitList = new ArrayList<MobileOrgUnitLinks>();
-        for ( OrganisationUnit unit : units )
-        {
-            unitList.add( getOrgUnit( unit, request ) );
-        }
-        OrgUnits orgUnits = new OrgUnits( unitList );
-        orgUnits.setClientVersion( DataStreamSerializable.TWO_POINT_NINE );
-        return orgUnits;
-    }
-    
-    @RequestMapping( method = RequestMethod.GET, value = "/{version}/LWUIT" )
-    @ResponseBody
-    public OrgUnits getOrgUnitsForUserLWUIT( HttpServletRequest request, @PathVariable String version )
-        throws NotAllowedException
-    {
-        User user = currentUserService.getCurrentUser();
-
-        if ( user == null )
-        {
-            throw NotAllowedException.NO_USER;
-        }
-
-        Collection<OrganisationUnit> units = user.getOrganisationUnits();
-
-        List<MobileOrgUnitLinks> unitList = new ArrayList<MobileOrgUnitLinks>();
-        for ( OrganisationUnit unit : units )
-        {
-            unitList.add( getOrgUnit( unit, request ) );
-        }
-        OrgUnits orgUnits = new OrgUnits( unitList );
-        orgUnits.setClientVersion( version );
-        return orgUnits;
-    }
-
-    private MobileOrgUnitLinks getOrgUnit( OrganisationUnit unit, HttpServletRequest request )
-    {
-        MobileOrgUnitLinks orgUnit = new MobileOrgUnitLinks();
-
-        orgUnit.setId( unit.getId() );
-        orgUnit.setName( unit.getShortName() );
-
-        orgUnit.setDownloadAllUrl( getUrl( request, unit.getId(), "all" ) );
-        orgUnit.setUpdateActivityPlanUrl( getUrl( request, unit.getId(), "activitiyplan" ) );
-        orgUnit.setUploadFacilityReportUrl( getUrl( request, unit.getId(), "dataSets" ) );
-        orgUnit.setUploadActivityReportUrl( getUrl( request, unit.getId(), "activities" ) );
-        orgUnit.setUpdateDataSetUrl( getUrl( request, unit.getId(), "updateDataSets" ) );
-        orgUnit.setChangeUpdateDataSetLangUrl( getUrl( request, unit.getId(), "changeLanguageDataSet" ) );
-        orgUnit.setSearchUrl( getUrl( request, unit.getId(), "search" ) );
-        orgUnit.setUpdateContactUrl( getUrl( request, unit.getId(), "updateContactForMobile" ) );
-        orgUnit.setFindPatientUrl( getUrl( request, unit.getId(), "findPatient" ) );
-        orgUnit.setRegisterPersonUrl( getUrl( request, unit.getId(), "registerPerson" ) );
-        orgUnit.setUploadProgramStageUrl( getUrl( request, unit.getId(), "uploadProgramStage" ) );
-        orgUnit.setEnrollProgramUrl( getUrl( request, unit.getId(), "enrollProgram" ) );
-        orgUnit.setAddRelationshipUrl( getUrl( request, unit.getId(), "addRelationship" ) );
-        orgUnit.setDownloadAnonymousProgramUrl( getUrl( request, unit.getId(), "downloadAnonymousProgramUrl" ) );
-        orgUnit.setFindProgramUrl( getUrl( request, unit.getId(), "findProgram" ) );
-        
-        // generate URL for download new version
-        String full = UrlUtils.buildFullRequestUrl( request );
-        String root = full.substring( 0, full.length() - UrlUtils.buildRequestUrl( request ).length() );
-        String updateNewVersionUrl = root + "/dhis-web-api-mobile/updateClient.action";
-        orgUnit.setUpdateNewVersionUrl( updateNewVersionUrl );
-
-        return orgUnit;
-    }
-
-    private static String getUrl( HttpServletRequest request, int id, String path )
-    {
-        String url = UrlUtils.buildFullRequestUrl( request );
-        if ( url.endsWith( "/" ) )
-        {
-            url = url + "orgUnits/" + id + "/" + path;
-        }
-        else
-        {
-            url = url + "/orgUnits/" + id + "/" + path;
-        }
-        return url;
-    }
-}
+package org.hisp.dhis.api.mobile.controller;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.hisp.dhis.api.mobile.NotAllowedException;
+import org.hisp.dhis.api.mobile.model.DataStreamSerializable;
+import org.hisp.dhis.api.mobile.model.MobileOrgUnitLinks;
+import org.hisp.dhis.api.mobile.model.OrgUnits;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.User;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.web.util.UrlUtils;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+@Controller
+@RequestMapping( value = "/mobile" )
+public class MobileClientController
+    extends AbstractMobileController
+{
+    @Autowired
+    private CurrentUserService currentUserService;
+
+    @RequestMapping( method = RequestMethod.GET )
+    @ResponseBody
+    public OrgUnits getOrgUnitsForUser2_8( HttpServletRequest request )
+        throws NotAllowedException
+    {
+        User user = currentUserService.getCurrentUser();
+
+        if ( user == null )
+        {
+            throw NotAllowedException.NO_USER;
+        }
+
+        Collection<OrganisationUnit> units = user.getOrganisationUnits();
+
+        List<MobileOrgUnitLinks> unitList = new ArrayList<MobileOrgUnitLinks>();
+        for ( OrganisationUnit unit : units )
+        {
+            unitList.add( getOrgUnit( unit, request ) );
+        }
+        OrgUnits orgUnits = new OrgUnits( unitList );
+        orgUnits.setClientVersion( DataStreamSerializable.TWO_POINT_EIGHT );
+        return orgUnits;
+    }
+
+    @RequestMapping( method = RequestMethod.GET, value = "/{version}" )
+    @ResponseBody
+    public OrgUnits getOrgUnitsForUser( HttpServletRequest request, @PathVariable
+    String version )
+        throws NotAllowedException
+    {
+        User user = currentUserService.getCurrentUser();
+
+        if ( user == null )
+        {
+            throw NotAllowedException.NO_USER;
+        }
+
+        Collection<OrganisationUnit> units = user.getOrganisationUnits();
+
+        List<MobileOrgUnitLinks> unitList = new ArrayList<MobileOrgUnitLinks>();
+        for ( OrganisationUnit unit : units )
+        {
+            unitList.add( getOrgUnit( unit, request ) );
+        }
+        OrgUnits orgUnits = new OrgUnits( unitList );
+        orgUnits.setClientVersion( DataStreamSerializable.TWO_POINT_NINE );
+        return orgUnits;
+    }
+
+    @RequestMapping( method = RequestMethod.GET, value = "/{version}/LWUIT" )
+    @ResponseBody
+    public OrgUnits getOrgUnitsForUserLWUIT( HttpServletRequest request, @PathVariable
+    String version )
+        throws NotAllowedException
+    {
+        User user = currentUserService.getCurrentUser();
+
+        if ( user == null )
+        {
+            throw NotAllowedException.NO_USER;
+        }
+
+        Collection<OrganisationUnit> units = user.getOrganisationUnits();
+
+        List<MobileOrgUnitLinks> unitList = new ArrayList<MobileOrgUnitLinks>();
+        for ( OrganisationUnit unit : units )
+        {
+            unitList.add( getOrgUnit( unit, request ) );
+        }
+        OrgUnits orgUnits = new OrgUnits( unitList );
+        orgUnits.setClientVersion( version );
+        return orgUnits;
+    }
+
+    private MobileOrgUnitLinks getOrgUnit( OrganisationUnit unit, HttpServletRequest request )
+    {
+        MobileOrgUnitLinks orgUnit = new MobileOrgUnitLinks();
+
+        orgUnit.setId( unit.getId() );
+        orgUnit.setName( unit.getShortName() );
+
+        orgUnit.setDownloadAllUrl( getUrl( request, unit.getId(), "all" ) );
+        orgUnit.setUpdateActivityPlanUrl( getUrl( request, unit.getId(), "activitiyplan" ) );
+        orgUnit.setUploadFacilityReportUrl( getUrl( request, unit.getId(), "dataSets" ) );
+        orgUnit.setUploadActivityReportUrl( getUrl( request, unit.getId(), "activities" ) );
+        orgUnit.setUpdateDataSetUrl( getUrl( request, unit.getId(), "updateDataSets" ) );
+        orgUnit.setChangeUpdateDataSetLangUrl( getUrl( request, unit.getId(), "changeLanguageDataSet" ) );
+        orgUnit.setSearchUrl( getUrl( request, unit.getId(), "search" ) );
+        orgUnit.setUpdateContactUrl( getUrl( request, unit.getId(), "updateContactForMobile" ) );
+        orgUnit.setFindPatientUrl( getUrl( request, unit.getId(), "findPatient" ) );
+        orgUnit.setRegisterPersonUrl( getUrl( request, unit.getId(), "registerPerson" ) );
+        orgUnit.setUploadProgramStageUrl( getUrl( request, unit.getId(), "uploadProgramStage" ) );
+        orgUnit.setEnrollProgramUrl( getUrl( request, unit.getId(), "enrollProgram" ) );
+        orgUnit.setGetVariesInfoUrl( getUrl( request, unit.getId(), "getVariesInfo" ) );
+        orgUnit.setAddRelationshipUrl( getUrl( request, unit.getId(), "addRelationship" ) );
+        orgUnit.setDownloadAnonymousProgramUrl( getUrl( request, unit.getId(), "downloadAnonymousProgramUrl" ) );
+        orgUnit.setFindProgramUrl( getUrl( request, unit.getId(), "findProgram" ) );
+
+        // generate URL for download new version
+        String full = UrlUtils.buildFullRequestUrl( request );
+        String root = full.substring( 0, full.length() - UrlUtils.buildRequestUrl( request ).length() );
+        String updateNewVersionUrl = root + "/dhis-web-api-mobile/updateClient.action";
+        orgUnit.setUpdateNewVersionUrl( updateNewVersionUrl );
+
+        return orgUnit;
+    }
+
+    private static String getUrl( HttpServletRequest request, int id, String path )
+    {
+        String url = UrlUtils.buildFullRequestUrl( request );
+        if ( url.endsWith( "/" ) )
+        {
+            url = url + "orgUnits/" + id + "/" + path;
+        }
+        else
+        {
+            url = url + "/orgUnits/" + id + "/" + path;
+        }
+        return url;
+    }
+}

=== 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-04-01 04:56:59 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java	2013-04-03 08:06:46 +0000
@@ -1,68 +1,51 @@
-package org.hisp.dhis.api.mobile.controller;
-
-/*
- * 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.
- */
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-import org.hisp.dhis.api.mobile.ActivityReportingService;
-import org.hisp.dhis.api.mobile.FacilityReportingService;
-import org.hisp.dhis.api.mobile.IProgramService;
-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.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.LWUITmodel.Program;
-import org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage;
-import org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship;
-import org.hisp.dhis.api.mobile.model.SMSCode;
-import org.hisp.dhis.api.mobile.model.SMSCommand;
-import org.hisp.dhis.i18n.I18nService;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.patient.PatientService;
-import org.hisp.dhis.smscommand.SMSCommandService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
+package org.hisp.dhis.api.mobile.controller;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+
+import org.hisp.dhis.api.mobile.ActivityReportingService;
+import org.hisp.dhis.api.mobile.FacilityReportingService;
+import org.hisp.dhis.api.mobile.IProgramService;
+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.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.PatientIdentifier;
+import org.hisp.dhis.api.mobile.model.SMSCode;
+import org.hisp.dhis.api.mobile.model.SMSCommand;
+import org.hisp.dhis.api.mobile.model.LWUITmodel.Patient;
+import org.hisp.dhis.api.mobile.model.LWUITmodel.PatientIdentifierAndAttribute;
+import org.hisp.dhis.api.mobile.model.LWUITmodel.Program;
+import org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage;
+import org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship;
+import org.hisp.dhis.i18n.I18nService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeService;
+import org.hisp.dhis.patient.PatientIdentifierType;
+import org.hisp.dhis.patient.PatientIdentifierTypeService;
+import org.hisp.dhis.patient.PatientService;
+import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
+import org.hisp.dhis.smscommand.SMSCommandService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
 
 @Controller
 @RequestMapping( value = "/mobile" )
@@ -71,7 +54,9 @@
 {
     private static final String ACTIVITY_REPORT_UPLOADED = "activity_report_uploaded";
 
-    private static final String DATASET_REPORT_UPLOADED = "dataset_report_uploaded";
+    private static final String DATASET_REPORT_UPLOADED = "dataset_report_uploaded";
+    
+    private static final String PATIENT_REGISTERED = "patient_registered";
 
     @Autowired
     private ActivityReportingService activityReportingService;
@@ -92,7 +77,25 @@
     private PatientService patientService;
 
     @Autowired
-    private SMSCommandService smsCommandService;
+    private SMSCommandService smsCommandService;
+    
+    @Autowired
+    private PatientIdentifierTypeService patientIdentifierTypeService;
+
+    @Autowired
+    private PatientAttributeService patientAttributeService;
+
+    private Integer patientId;
+
+    public Integer getPatientId()
+    {
+        return patientId;
+    }
+
+    public void setPatientId( Integer patientId )
+    {
+        this.patientId = patientId;
+    }
 
     // For client version 2.8 and lower
     @RequestMapping( method = RequestMethod.GET, value = "orgUnits/{id}/all" )
@@ -405,5 +408,109 @@
     private OrganisationUnit getUnit( int id )
     {
         return organisationUnitService.getOrganisationUnit( id );
+    }
+    
+    @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/LWUIT/orgUnits/{id}/registerPerson" )
+    @ResponseBody
+    public String savePatient( @PathVariable
+    int id, @RequestBody
+    Patient patient )
+    {
+
+        org.hisp.dhis.patient.Patient patientWeb = new org.hisp.dhis.patient.Patient();
+
+        int startIndex = patient.getFirstName().indexOf( ' ' );
+        int endIndex = patient.getFirstName().lastIndexOf( ' ' );
+
+        String firstName = patient.getFirstName().toString();
+        String middleName = "";
+        String lastName = "";
+
+        if ( patient.getFirstName().indexOf( ' ' ) != -1 )
+        {
+            firstName = patient.getFirstName().substring( 0, startIndex );
+            if ( startIndex == endIndex )
+            {
+                middleName = "";
+                lastName = patient.getFirstName().substring( startIndex + 1, patient.getFirstName().length() );
+            }
+            else
+            {
+                middleName = patient.getFirstName().substring( startIndex + 1, endIndex );
+                lastName = patient.getFirstName().substring( endIndex + 1, patient.getFirstName().length() );
+            }
+        }
+
+        patientWeb.setFirstName( firstName );
+        patientWeb.setMiddleName( middleName );
+        patientWeb.setLastName( lastName );
+        patientWeb.setGender( patient.getGender() );
+        patientWeb.setDobType( patient.getDobType() );
+        patientWeb.setPhoneNumber( patient.getPhoneNumber() );
+        patientWeb.setBirthDate( patient.getBirthDate() );
+        patientWeb.setOrganisationUnit( organisationUnitService.getOrganisationUnit( id ) );
+        patientWeb.setRegistrationDate( new Date() );
+
+        Set<org.hisp.dhis.patient.PatientIdentifier> patientIdentifierSet = new HashSet<org.hisp.dhis.patient.PatientIdentifier>();
+        Set<PatientAttribute> patientAttributeSet = new HashSet<PatientAttribute>();
+        List<PatientAttributeValue> patientAttributeValues = new ArrayList<PatientAttributeValue>();
+
+        Collection<PatientIdentifier> identifiers = patient.getIdentifiers();
+
+        Collection<org.hisp.dhis.api.mobile.model.PatientAttribute> patientAttributesMobile = patient
+            .getPatientAttValues();
+        for ( PatientIdentifier identifier : identifiers )
+        {
+            PatientIdentifierType patientIdentifierType = patientIdentifierTypeService
+                .getPatientIdentifierType( identifier.getIdentifierType() );
+
+            org.hisp.dhis.patient.PatientIdentifier patientIdentifier = new org.hisp.dhis.patient.PatientIdentifier();
+            patientIdentifier.setIdentifierType( patientIdentifierType );
+            patientIdentifier.setPatient( patientWeb );
+            patientIdentifier.setIdentifier( identifier.getIdentifier() );
+            patientIdentifierSet.add( patientIdentifier );
+        }
+
+        for ( org.hisp.dhis.api.mobile.model.PatientAttribute paAtt : patientAttributesMobile )
+        {
+
+            PatientAttribute patientAttribute = patientAttributeService.getPatientAttributeByName( paAtt.getName() );
+
+            patientAttributeSet.add( patientAttribute );
+
+            PatientAttributeValue patientAttributeValue = new PatientAttributeValue();
+
+            patientAttributeValue.setPatient( patientWeb );
+            patientAttributeValue.setPatientAttribute( patientAttribute );
+            patientAttributeValue.setValue( paAtt.getValue() );
+
+            patientAttributeValues.add( patientAttributeValue );
+
+        }
+
+        patientWeb.setIdentifiers( patientIdentifierSet );
+        patientWeb.setAttributes( patientAttributeSet );
+
+        patientId = patientService.savePatient( patientWeb );
+
+        return PATIENT_REGISTERED;
+
+    }
+
+    @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 )
+    {
+        PatientIdentifierAndAttribute patientIdentifierAndAttribute = new PatientIdentifierAndAttribute();
+        patientIdentifierAndAttribute.setClientVersion( clientVersion );
+        patientIdentifierAndAttribute.setPatientIdentifiers( activityReportingService.getIdentifiersForMobile() );
+        patientIdentifierAndAttribute.setPatientAttributes( activityReportingService.getPatientAttributesForMobile() );
+
+        return patientIdentifierAndAttribute;
+
     }
 }
+