dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24478
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12002: [mobile ]support more attribute type for mobile, bug fix
------------------------------------------------------------
revno: 12002
committer: Long <Long@Long-Laptop>
branch nick: dhis2
timestamp: Tue 2013-09-10 14:22:13 +0700
message:
[mobile ]support more attribute type for mobile, bug fix
modified:
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/PatientAttribute.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/model/LWUITmodel/Patient.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java 2013-09-10 07:22:13 +0000
@@ -31,6 +31,7 @@
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
+import java.io.EOFException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
@@ -463,7 +464,7 @@
@Override
public void deSerialize( DataInputStream din )
- throws IOException
+ throws IOException, EOFException
{
this.setId( din.readInt() );
this.setFirstName( din.readUTF() );
@@ -552,9 +553,9 @@
}
int numbIdentifiers = din.readInt();
+ this.identifiers = new ArrayList<PatientIdentifier>();
if ( numbIdentifiers > 0 )
{
- this.identifiers = new ArrayList<PatientIdentifier>();
for ( int i = 0; i < numbIdentifiers; i++ )
{
PatientIdentifier identifier = new PatientIdentifier();
@@ -563,10 +564,6 @@
}
}
- else
- {
- this.identifiers = null;
- }
// Program & Relationship
int numbPrograms = din.readInt();
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientAttribute.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientAttribute.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientAttribute.java 2013-09-10 07:22:13 +0000
@@ -31,6 +31,9 @@
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute;
@@ -43,14 +46,20 @@
private String value;
+ private String type;
+
+ private List<String> predefinedValues = new ArrayList<String>();
+
// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
- public PatientAttribute( String name, String value )
+ public PatientAttribute( String name, String value, String type, List<String> predefinedValues )
{
this.name = name;
this.value = value;
+ this.type = type;
+ this.predefinedValues = predefinedValues;
}
public PatientAttribute()
@@ -93,12 +102,44 @@
this.clientVersion = clientVersion;
}
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType( String type )
+ {
+ this.type = type;
+ }
+
+ public List<String> getPredefinedValues()
+ {
+ return predefinedValues;
+ }
+
+ public void setPredefinedValues( List<String> predefinedValues )
+ {
+ this.predefinedValues = predefinedValues;
+ }
+
@Override
public void serialize( DataOutputStream dout )
throws IOException
{
dout.writeUTF( this.name );
dout.writeUTF( this.value );
+ dout.writeUTF( this.type );
+
+ int valueSize = this.predefinedValues.size();
+ dout.writeInt( valueSize );
+ if ( valueSize > 0 )
+ {
+ for ( String option : predefinedValues )
+ {
+ dout.writeUTF( option );
+ }
+ }
+
}
@Override
@@ -107,6 +148,17 @@
{
name = dataInputStream.readUTF();
value = dataInputStream.readUTF();
+ type = dataInputStream.readUTF();
+
+ List<String> optionList = new ArrayList<String>();
+
+ int size = dataInputStream.readInt();
+
+ for ( int i = 0; i < size; i++ )
+ {
+ optionList.add( dataInputStream.readUTF() );
+ }
+ predefinedValues = optionList;
}
@Override
@@ -130,7 +182,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-09-09 17:13:07 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-09-10 07:22:13 +0000
@@ -60,6 +60,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientAttributeOption;
import org.hisp.dhis.patient.PatientAttributeService;
import org.hisp.dhis.patient.PatientIdentifier;
import org.hisp.dhis.patient.PatientIdentifierService;
@@ -619,7 +620,7 @@
}
else
{
- programStageInstance.setCompleted( true );
+ programStageInstance.setCompleted( mobileProgramStage.isCompleted() );
// check if any compulsory value is null
for ( int i = 0; i < dataElements.size(); i++ )
@@ -791,7 +792,8 @@
PatientAttributeValue value = patientAttValueService.getPatientAttributeValue( patient, each );
if ( value != null )
{
- patientAtts.add( new PatientAttribute( each.getName(), value.getValue() ) );
+ patientAtts.add( new PatientAttribute( each.getName(), value.getValue(), each.getValueType(),
+ new ArrayList<String>() ) );
}
}
@@ -849,26 +851,26 @@
List<org.hisp.dhis.patient.PatientAttribute> atts;
patientModel.setId( patient.getId() );
-
+
String firstName = "";
String lastName = "";
String middleName = "";
-
+
if ( patient.getFirstName() != null )
{
firstName = patient.getFirstName();
}
-
+
if ( patient.getLastName() != null )
{
lastName = patient.getLastName();
}
-
+
if ( patient.getMiddleName() != null )
{
middleName = patient.getMiddleName();
}
-
+
patientModel.setFirstName( firstName );
patientModel.setLastName( lastName );
patientModel.setMiddleName( middleName );
@@ -908,7 +910,8 @@
PatientAttributeValue value = patientAttValueService.getPatientAttributeValue( patient, each );
if ( value != null )
{
- patientAtts.add( new PatientAttribute( each.getName(), value.getValue() ) );
+ patientAtts.add( new PatientAttribute( each.getName(), value.getValue(), each.getValueType(),
+ new ArrayList<String>() ) );
}
}
@@ -954,7 +957,7 @@
mobileProgramList.add( getMobileProgram( patient, each ) );
}
}
-
+
patientModel.setPrograms( mobileProgramList );
/*
* List<Integer> mobileProgramIDList = new ArrayList<Integer>(); for (
@@ -1065,9 +1068,10 @@
{
ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance(
programInstance, eachProgramStage );
-
- //only for Mujhu database, because there is null program stage instance. This condition should be removed in the future
- if( programStageInstance != null )
+
+ // only for Mujhu database, because there is null program stage
+ // instance. This condition should be removed in the future
+ if ( programStageInstance != null )
{
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>();
@@ -1077,7 +1081,8 @@
// get report date
if ( programStageInstance.getExecutionDate() != null )
{
- mobileProgramStage.setReportDate( PeriodUtil.dateToString( programStageInstance.getExecutionDate() ) );
+ mobileProgramStage
+ .setReportDate( PeriodUtil.dateToString( programStageInstance.getExecutionDate() ) );
}
else
{
@@ -1116,7 +1121,8 @@
mobileSection.setId( eachSection.getId() );
mobileSection.setName( eachSection.getName() );
- // Set all data elements' id, then we could have full from
+ // 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
@@ -1682,12 +1688,12 @@
patientAttributes = patientAttributeService.getAllPatientAttributes();
- Collection<Program> programs = programService.getAllPrograms();
-
- for ( Program program : programs )
- {
- patientAttributes.removeAll( program.getPatientAttributes() );
- }
+ // Collection<Program> programs = programService.getAllPrograms();
+ //
+ // for ( Program program : programs )
+ // {
+ // patientAttributes.removeAll( program.getPatientAttributes() );
+ // }
return patientAttributes;
}
@@ -1711,7 +1717,8 @@
for ( org.hisp.dhis.patient.PatientAttribute patientAtt : getPatientAtts() )
{
- list.add( new PatientAttribute( patientAtt.getName(), null ) );
+ list.add( new PatientAttribute( patientAtt.getName(), null, patientAtt.getValueType(),
+ new ArrayList<String>() ) );
}
return list;
@@ -1741,13 +1748,27 @@
Collection<PatientAttribute> list = new HashSet<PatientAttribute>();
for ( org.hisp.dhis.patient.PatientAttribute pa : getPatientAtts() )
{
+ PatientAttribute patientAttribute = new PatientAttribute();
String name = pa.getName();
- if ( pa.isMandatory() == true )
+ // if ( pa.isMandatory() == true )
+ // {
+ // name += " (*)";
+ // }
+ patientAttribute.setName( name );
+ patientAttribute.setType( pa.getValueType() );
+ patientAttribute.setValue( "" );
+ List<String> optionList = new ArrayList<String>();
+ if ( pa.getAttributeOptions() != null )
{
- name += " (*)";
+ for ( PatientAttributeOption option : pa.getAttributeOptions() )
+ {
+ optionList.add( option.getName() );
+ }
}
- String value = "";
- list.add( new PatientAttribute( name, value ) );
+ // list.add( new PatientAttribute( name, value, pa.getValueType(),
+ // pa.getP ) );
+ patientAttribute.setPredefinedValues( optionList );
+ list.add( patientAttribute );
}
return list;
}
@@ -1906,11 +1927,11 @@
List<Patient> tempPatients = (List<Patient>) patientService.getPatients( orgUnit, program, null, null );
patients.retainAll( tempPatients );
}
-
+
if ( programId != 0 && orgUnitId != 0 )
{
boolean isProgramBelongToOrgUnit = false;
- for( Program program: programService.getPrograms( orgUnit ))
+ for ( Program program : programService.getPrograms( orgUnit ) )
{
if ( program.getId() == programId )
{
@@ -1939,8 +1960,8 @@
}
if ( each.getBirthDate() != null )
{
- patientsInfo += each.getId() + "/" + each.getFullName() + "/" + dateFormat.format( each.getBirthDate() )
- + "$";
+ patientsInfo += each.getId() + "/" + each.getFullName() + "/"
+ + dateFormat.format( each.getBirthDate() ) + "$";
}
else
{
=== 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-08 08:36:32 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java 2013-09-10 07:22:13 +0000
@@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.io.EOFException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;