← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12028: [mobile] minor fix

 

------------------------------------------------------------
revno: 12028
committer: Long <Long@Long-Laptop>
branch nick: dhis2
timestamp: Tue 2013-09-10 23:29:20 +0700
message:
  [mobile] minor fix
modified:
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java
  dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java


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

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java	2013-09-10 09:00:47 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java	2013-09-10 16:29:20 +0000
@@ -72,15 +72,15 @@
 
     public Collection<PatientIdentifierType> getIdentifierTypes();
 
-    public Collection<org.hisp.dhis.patient.PatientAttribute> getPatientAtts();
+    public Collection<org.hisp.dhis.patient.PatientAttribute> getPatientAtts(String programId);
 
-    public Collection<PatientIdentifierType> getIdentifiers();
+    public Collection<PatientIdentifierType> getIdentifiers( String programId );
 
     public Collection<PatientAttribute> getAttsForMobile();
 
-    public Collection<org.hisp.dhis.api.mobile.model.PatientIdentifier> getIdentifiersForMobile();
+    public Collection<org.hisp.dhis.api.mobile.model.PatientIdentifier> getIdentifiersForMobile( String programId );
 
-    public Collection<PatientAttribute> getPatientAttributesForMobile();
+    public Collection<PatientAttribute> getPatientAttributesForMobile( String programId );
 
     public Patient addRelationship( Relationship enrollmentRelationship, int orgUnitId )
         throws NotAllowedException;

=== 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-09-10 15:20:42 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java	2013-09-10 16:29:20 +0000
@@ -565,6 +565,7 @@
         
         // Patient Attribute & Identifiers
         int attsNumb = din.readInt();
+        System.out.println("Att numb: " + attsNumb);
         if( attsNumb > 0 )
         {
             this.patientAttValues = new ArrayList<PatientAttribute>();
@@ -581,6 +582,7 @@
         }
 
         int numbIdentifiers = din.readInt();
+        System.out.println("Ids numb: " + attsNumb);
         this.identifiers = new ArrayList<PatientIdentifier>();
         if ( numbIdentifiers > 0 )
         {

=== 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-09-10 13:42:06 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2013-09-10 16:29:20 +0000
@@ -846,13 +846,13 @@
     private org.hisp.dhis.api.mobile.model.LWUITmodel.Patient getPatientModel( Patient patient )
     {
         org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patientModel = new org.hisp.dhis.api.mobile.model.LWUITmodel.Patient();
-        
+
         List<PatientAttribute> patientAtts = new ArrayList<PatientAttribute>();
-        
+
         List<org.hisp.dhis.api.mobile.model.LWUITmodel.Program> mobileProgramList = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.Program>();
-        
+
         List<org.hisp.dhis.api.mobile.model.LWUITmodel.Program> mobileCompletedProgramList = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.Program>();
-        
+
         List<org.hisp.dhis.patient.PatientAttribute> atts;
 
         patientModel.setId( patient.getId() );
@@ -962,7 +962,7 @@
             }
         }
         patientModel.setPrograms( mobileProgramList );
-        
+
         // Set completed programs
         List<ProgramInstance> listOfCompletedProgramInstance = new ArrayList<ProgramInstance>(
             programInstanceService.getProgramInstances( patient, ProgramInstance.STATUS_COMPLETED ) );
@@ -975,7 +975,7 @@
             }
         }
         patientModel.setCompletedPrograms( mobileCompletedProgramList );
-        
+
         /*
          * List<Integer> mobileProgramIDList = new ArrayList<Integer>(); for (
          * Program eachProgram : patient.getPrograms()) {
@@ -1187,7 +1187,8 @@
 
             String dataElementName;
 
-            if ( programStageDataElement.getDataElement().getFormName() != null && !programStageDataElement.getDataElement().getFormName().trim().equals( "" ) )
+            if ( programStageDataElement.getDataElement().getFormName() != null
+                && !programStageDataElement.getDataElement().getFormName().trim().equals( "" ) )
             {
                 dataElementName = programStageDataElement.getDataElement().getFormName();
             }
@@ -1699,31 +1700,33 @@
         return patientIdentifierTypes;
     }
 
-    public Collection<org.hisp.dhis.patient.PatientAttribute> getPatientAtts()
+    public Collection<org.hisp.dhis.patient.PatientAttribute> getPatientAtts( String programId )
     {
-
-        patientAttributes = patientAttributeService.getAllPatientAttributes();
-
-        // Collection<Program> programs = programService.getAllPrograms();
-        //
-        // for ( Program program : programs )
-        // {
-        // patientAttributes.removeAll( program.getPatientAttributes() );
-        // }
+        if ( programId != null && !programId.trim().equals( "" ) )
+        {
+            Program program = programService.getProgram( Integer.parseInt( programId ) );
+            patientAttributes = program.getPatientAttributes();
+        }
+        else
+        {
+            patientAttributes = patientAttributeService.getAllPatientAttributes();
+        }
 
         return patientAttributes;
     }
 
-    public Collection<PatientIdentifierType> getIdentifiers()
+    public Collection<PatientIdentifierType> getIdentifiers( String programId )
     {
-        patientIdentifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
+        if ( programId != null && !programId.trim().equals( "" ) )
+        {
+            Program program = programService.getProgram( Integer.parseInt( programId ) );
+            patientIdentifierTypes = program.getPatientIdentifierTypes();
+        }
+        else
+        {
+            patientIdentifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
+        }
 
-        // Collection<Program> programs = programService.getAllPrograms();
-        // for ( Program program : programs )
-        // {
-        // patientIdentifierTypes.removeAll( program.getPatientIdentifierTypes()
-        // );
-        // }
         return patientIdentifierTypes;
 
     }
@@ -1732,7 +1735,7 @@
     {
         Collection<PatientAttribute> list = new HashSet<PatientAttribute>();
 
-        for ( org.hisp.dhis.patient.PatientAttribute patientAtt : getPatientAtts() )
+        for ( org.hisp.dhis.patient.PatientAttribute patientAtt : getPatientAtts( null ) )
         {
             list.add( new PatientAttribute( patientAtt.getName(), null, patientAtt.getValueType(),
                 new ArrayList<String>() ) );
@@ -1743,10 +1746,10 @@
     }
 
     @Override
-    public Collection<org.hisp.dhis.api.mobile.model.PatientIdentifier> getIdentifiersForMobile()
+    public Collection<org.hisp.dhis.api.mobile.model.PatientIdentifier> getIdentifiersForMobile( String programId )
     {
         Collection<org.hisp.dhis.api.mobile.model.PatientIdentifier> list = new HashSet<org.hisp.dhis.api.mobile.model.PatientIdentifier>();
-        for ( PatientIdentifierType identifierType : getIdentifiers() )
+        for ( PatientIdentifierType identifierType : getIdentifiers( programId ) )
         {
             String id = "";
             String idt = identifierType.getName();
@@ -1760,17 +1763,14 @@
     }
 
     @Override
-    public Collection<PatientAttribute> getPatientAttributesForMobile()
+    public Collection<PatientAttribute> getPatientAttributesForMobile( String programId )
     {
         Collection<PatientAttribute> list = new HashSet<PatientAttribute>();
-        for ( org.hisp.dhis.patient.PatientAttribute pa : getPatientAtts() )
+        for ( org.hisp.dhis.patient.PatientAttribute pa : getPatientAtts( programId ) )
         {
             PatientAttribute patientAttribute = new PatientAttribute();
             String name = pa.getName();
-            // if ( pa.isMandatory() == true )
-            // {
-            // name += " (*)";
-            // }
+
             patientAttribute.setName( name );
             patientAttribute.setType( pa.getValueType() );
             patientAttribute.setValue( "" );
@@ -1782,8 +1782,7 @@
                     optionList.add( option.getName() );
                 }
             }
-            // list.add( new PatientAttribute( name, value, pa.getValueType(),
-            // pa.getP ) );
+
             patientAttribute.setPredefinedValues( optionList );
             list.add( patientAttribute );
         }
@@ -1813,7 +1812,8 @@
     }
 
     @Override
-    public Integer savePatient( org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patient, int orgUnitId, String programIdText )
+    public Integer savePatient( org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patient, int orgUnitId,
+        String programIdText )
         throws NotAllowedException
     {
         org.hisp.dhis.patient.Patient patientWeb = new org.hisp.dhis.patient.Patient();
@@ -1917,7 +1917,7 @@
         patientWeb.setAttributes( patientAttributeSet );
 
         patientId = patientService.createPatient( patientWeb, null, null, patientAttributeValues );
-        
+
         try
         {
             int programId = Integer.parseInt( programIdText );
@@ -1927,7 +1927,6 @@
         {
             return patientId;
         }
-        
 
         return patientId;
 
@@ -1949,7 +1948,7 @@
     {
         Collection<Patient> patients = new HashSet<Patient>( patientService.getPatientsForMobile( keyword, orgUnitId ) );
         OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
-        
+
         if ( programId != 0 )
         {
             Program program = programService.getProgram( programId );

=== 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-09-10 11:03:08 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java	2013-09-10 16:29:20 +0000
@@ -343,10 +343,11 @@
     {
         return activityReportingService.findPatient( keyword, id );
     }
-    
+
     @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/findPatientInAdvanced/{programId}" )
     @ResponseBody
-    public Patient findPatientInAdvanced( @PathVariable int programId, @PathVariable int id, @RequestHeader( "name" ) String keyword )
+    public Patient findPatientInAdvanced( @PathVariable int programId, @PathVariable int id,
+        @RequestHeader( "name" ) String keyword )
         throws NotAllowedException
     {
         return activityReportingService.findPatientInAdvanced( keyword, id, programId );
@@ -445,7 +446,8 @@
 
     @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/LWUIT/orgUnits/{id}/registerPerson" )
     @ResponseBody
-    public String savePatient( @PathVariable int id, @RequestBody Patient patient, @RequestHeader( "programid" ) String programId )
+    public String savePatient( @PathVariable int id, @RequestBody Patient patient,
+        @RequestHeader( "programid" ) String programId )
         throws NotAllowedException
     {
         if ( activityReportingService.savePatient( patient, id, programId ) != null )
@@ -461,12 +463,13 @@
     @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/getVariesInfo" )
     @ResponseBody
     public PatientIdentifierAndAttribute getVariesInfo( @PathVariable String clientVersion, @PathVariable int id,
-        @RequestHeader( "accept-language" ) String locale )
+        @RequestHeader( "accept-language" ) String locale, @RequestHeader( "programid" ) String programId )
     {
         PatientIdentifierAndAttribute patientIdentifierAndAttribute = new PatientIdentifierAndAttribute();
         patientIdentifierAndAttribute.setClientVersion( clientVersion );
-        patientIdentifierAndAttribute.setPatientIdentifiers( activityReportingService.getIdentifiersForMobile() );
-        patientIdentifierAndAttribute.setPatientAttributes( activityReportingService.getPatientAttributesForMobile() );
+        patientIdentifierAndAttribute.setPatientIdentifiers( activityReportingService
+            .getIdentifiersForMobile( programId ) );
+        patientIdentifierAndAttribute.setPatientAttributes( activityReportingService.getPatientAttributesForMobile(programId) );
 
         return patientIdentifierAndAttribute;