dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21830
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10431: support and add new functions for LWUIT framework, fix bugs
------------------------------------------------------------
revno: 10431
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-03-29 14:39:49 +0700
message:
support and add new functions for LWUIT framework, fix bugs
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/NotAllowedException.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/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/MobileOrgUnitLinks.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/OptionSet.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/OrgUnits.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-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitTest.java
dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitsTest.java
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
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/anonymous/action/GetAllAnonymousProgramAction.java
dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/J2meClientUpdateAction.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-03-06 04:25:38 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java 2013-03-29 07:39:49 +0000
@@ -27,10 +27,14 @@
* 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.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;
/**
@@ -38,7 +42,6 @@
*/
public interface ActivityReportingService
{
-
public ActivityPlan getCurrentActivityPlan( OrganisationUnit unit, String localeString );
public ActivityPlan getAllActivityPlan( OrganisationUnit unit, String localeString );
@@ -52,10 +55,16 @@
public Patient findPatient( String name, int orgUnitId )
throws NotAllowedException;
- public String saveProgramStage( ProgramStage programStage )
+ public String saveProgramStage( ProgramStage programStage, int orgUnitId )
throws NotAllowedException;
public Patient enrollProgram( String enrollInfo, int orgUnitId )
throws NotAllowedException;
-
+
+ public Patient addRelationship( Relationship enrollmentRelationship, int orgUnitId )
+ throws NotAllowedException;
+
+ public Program getAllAnonymousProgram( int orgUnitId )
+ throws NotAllowedException;
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/NotAllowedException.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/NotAllowedException.java 2011-11-04 11:27:33 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/NotAllowedException.java 2013-03-29 07:39:49 +0000
@@ -49,9 +49,11 @@
public static final NotAllowedException NO_BENEFICIARY_FOUND = new NotAllowedException( "NO_BENEFICIARY_FOUND");
+ public static final NotAllowedException NO_PROGRAM_FOUND = new NotAllowedException( "NO_PROGRAM_FOUND");
+
private String reason;
- private NotAllowedException( String reason )
+ public NotAllowedException( String reason )
{
this.reason = reason;
}
=== 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-13 10:11:52 +0000
+++ 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
@@ -78,6 +78,8 @@
private List<Program> enrollmentPrograms;
private List<Relationship> relationships;
+
+ private List<Relationship> enrollmentRelationships;
private String phoneNumber;
@@ -289,6 +291,16 @@
this.organisationUnit = organisationUnit;
}
+ public List<Relationship> getEnrollmentRelationships()
+ {
+ return enrollmentRelationships;
+ }
+
+ public void setEnrollmentRelationships( List<Relationship> enrollmentRelationships )
+ {
+ this.enrollmentRelationships = enrollmentRelationships;
+ }
+
@Override
public void serialize( DataOutputStream out )
throws IOException
@@ -403,6 +415,14 @@
{
each.serialize( dout );
}
+
+ // Write Enrolled
+
+ dout.writeInt( enrollmentRelationships.size() );
+ for ( Relationship each : enrollmentRelationships )
+ {
+ each.serialize( dout );
+ }
bout.flush();
bout.writeTo( out );
=== modified 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 2013-03-13 10:11:52 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramStage.java 2013-03-29 07:39:49 +0000
@@ -44,6 +44,8 @@
private boolean isRepeatable;
private boolean isCompleted;
+
+ private boolean isSingleEvent;
private List<Section> sections;
@@ -99,6 +101,16 @@
this.isCompleted = isCompleted;
}
+ public boolean isSingleEvent()
+ {
+ return isSingleEvent;
+ }
+
+ public void setSingleEvent( boolean isSingleEvent )
+ {
+ this.isSingleEvent = isSingleEvent;
+ }
+
@Override
public void serialize( DataOutputStream dout )
throws IOException
@@ -106,6 +118,7 @@
super.serialize( dout );
dout.writeBoolean( this.isRepeatable() );
dout.writeBoolean( this.isCompleted() );
+ dout.writeBoolean( this.isSingleEvent );
dout.writeInt( this.dataElements.size() );
for ( int i = 0; i < this.dataElements.size(); i++ )
@@ -127,6 +140,7 @@
super.deSerialize( dint );
this.setRepeatable( dint.readBoolean() );
this.setCompleted( dint.readBoolean() );
+ this.setSingleEvent( dint.readBoolean() );
int dataElementSize = dint.readInt();
if ( dataElementSize > 0 )
{
=== modified 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 2013-03-13 10:11:52 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramStageDataElement.java 2013-03-29 07:39:49 +0000
@@ -88,10 +88,11 @@
if ( optionSet == null || optionSet.getOptions().size() <= 0 )
{
- dout.writeInt( 0 );
+ dout.writeBoolean( false );
}
else
{
+ dout.writeBoolean( true );
optionSet.setClientVersion( TWO_POINT_TEN );
optionSet.serialize( dout );
}
@@ -116,12 +117,19 @@
this.setCompulsory( dint.readBoolean() );
this.categoryOptionCombos = new ModelList();
this.categoryOptionCombos.deSerialize( dint );
- this.optionSet = new OptionSet();
- this.optionSet.deSerialize( dint );
+
+ if( dint.readBoolean() == false )
+ {
+ this.optionSet = null;
+ }
+ else
+ {
+ this.optionSet = new OptionSet();
+ this.optionSet.deSerialize( dint );
+ }
this.setValue( dint.readUTF() );
}
-
public String getClientVersion()
{
return clientVersion;
=== modified 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 2013-03-13 10:11:52 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Relationship.java 2013-03-29 07:39:49 +0000
@@ -39,39 +39,263 @@
{
private String clientVersion;
- private String personName;
+ private String personAName;
+
+ private String personBName;
+
+ private int personAId;
+
+ private int personBId;
+
+ private String chosenRelationship;
+
+ private String aIsToB;
+ private String bIsToA;
+
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 String getPersonAName()
+ {
+ return personAName;
+ }
+
+ public void setPersonAName( String personAName )
+ {
+ this.personAName = personAName;
+ }
+
+ public String getPersonBName()
+ {
+ return personBName;
+ }
+
+ public void setPersonBName( String personBName )
+ {
+ this.personBName = personBName;
+ }
+
+ public int getPersonAId()
+ {
+ return personAId;
+ }
+
+ public void setPersonAId( int personAId )
+ {
+ this.personAId = personAId;
+ }
+
+ public int getPersonBId()
+ {
+ return personBId;
+ }
+
+ public void setPersonBId( int personBId )
+ {
+ this.personBId = personBId;
+ }
+
+ public String getChosenRelationship()
+ {
+ return chosenRelationship;
+ }
+
+ public void setChosenRelationship( String chosenRelationship )
+ {
+ this.chosenRelationship = chosenRelationship;
+ }
+
+ public String getaIsToB()
+ {
+ return aIsToB;
+ }
+
+ public void setaIsToB( String aIsToB )
+ {
+ this.aIsToB = aIsToB;
+ }
+
+ public String getbIsToA()
+ {
+ return bIsToA;
+ }
+
+ public void setbIsToA( String bIsToA )
+ {
+ this.bIsToA = bIsToA;
+ }
+
public void serialize( DataOutputStream dout )
throws IOException
{
dout.writeUTF( this.getName() );
- dout.writeUTF( this.getPersonName() );
+
+ if( this.getPersonAName() != null )
+ {
+ dout.writeBoolean( true );
+ dout.writeUTF( this.getPersonAName() );
+ }
+ else
+ {
+ dout.writeBoolean( false );
+ }
+
+ if( this.getPersonBName() != null )
+ {
+ dout.writeBoolean( true );
+ dout.writeUTF( this.getPersonBName() );
+ }
+ else
+ {
+ dout.writeBoolean( false );
+ }
+
+ // for enrollment relationship, attributes below belong to relationship type
+ if( this.getId() != 0 )
+ {
+ dout.writeBoolean( true );
+ dout.writeInt( this.getId() );
+ }
+ else
+ {
+ dout.writeBoolean( false );
+ }
+
+ // relationship between A and B
+ if( this.getaIsToB() != null )
+ {
+ dout.writeBoolean( true );
+ dout.writeUTF( this.getaIsToB() );
+ }
+ else
+ {
+ dout.writeBoolean( false );
+ }
+
+ if( this.getbIsToA() != null )
+ {
+ dout.writeBoolean( true );
+ dout.writeUTF( this.getbIsToA() );
+ }
+ else
+ {
+ dout.writeBoolean( false );
+ }
+
+ // A and B id
+ if( this.getPersonAId() != 0 )
+ {
+ dout.writeBoolean( true );
+ dout.writeInt( this.getPersonAId() );
+ }
+ else
+ {
+ dout.writeBoolean( false );
+ }
+
+ if( this.getPersonBId() != 0 )
+ {
+ dout.writeBoolean( true );
+ dout.writeInt( this.getPersonBId() );
+ }
+ else
+ {
+ dout.writeBoolean( false );
+ }
+
+ if( this.getChosenRelationship() != null )
+ {
+ dout.writeBoolean( true );
+ dout.writeUTF( this.getChosenRelationship() );
+ }
+ else
+ {
+ dout.writeBoolean( false );
+ }
}
- public void deSerialize( DataInputStream dataInputStream )
+ public void deSerialize( DataInputStream dint )
throws IOException
{
- this.setName( dataInputStream.readUTF() );
- this.setPersonName( dataInputStream.readUTF() );
+ this.setName( dint.readUTF() );
+ if ( dint.readBoolean() == true )
+ {
+ this.setPersonAName( dint.readUTF() );
+ }
+ else
+ {
+ this.setPersonAName( null );
+ }
+
+ if ( dint.readBoolean() == true )
+ {
+ this.setPersonBName( dint.readUTF() );
+ }
+ else
+ {
+ this.setPersonBName( null );
+ }
+
+ if ( dint.readBoolean() == true )
+ {
+ this.setId( dint.readInt() );
+ }
+ else
+ {
+ this.setId( 0 );
+ }
+
+ if ( dint.readBoolean() == true )
+ {
+ this.setaIsToB( dint.readUTF() );
+ }
+ else
+ {
+ this.setaIsToB( null );
+ }
+
+ if ( dint.readBoolean() == true )
+ {
+ this.setbIsToA( dint.readUTF() );
+ }
+ else
+ {
+ this.setbIsToA( null );
+ }
+
+ if ( dint.readBoolean() == true )
+ {
+ this.setPersonAId( dint.readInt() );
+ }
+ else
+ {
+ this.setPersonAId( 0 );
+ }
+
+ if ( dint.readBoolean() == true )
+ {
+ this.setPersonBId( dint.readInt() );
+ }
+ else
+ {
+ this.setPersonBId( 0 );
+ }
+
+ if ( dint.readBoolean() == true )
+ {
+ this.setChosenRelationship( dint.readUTF() );
+ }
+ else
+ {
+ this.setChosenRelationship( null );
+ }
}
}
=== 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-20 07:14:26 +0000
+++ 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
@@ -71,6 +71,12 @@
private String enrollProgramUrl;
private String registerPersonUrl;
+
+ private String addRelationshipUrl;
+
+ private String downloadAnonymousProgramUrl;
+
+ private String findProgramUrl;
@XmlAttribute
public int getId()
@@ -234,6 +240,36 @@
this.registerPersonUrl = registerPersonUrl;
}
+ public String getAddRelationshipUrl()
+ {
+ return addRelationshipUrl;
+ }
+
+ public void setAddRelationshipUrl( String addRelationshipUrl )
+ {
+ this.addRelationshipUrl = addRelationshipUrl;
+ }
+
+ public String getDownloadAnonymousProgramUrl()
+ {
+ return downloadAnonymousProgramUrl;
+ }
+
+ public void setDownloadAnonymousProgramUrl( String downloadAnonymousProgramUrl )
+ {
+ this.downloadAnonymousProgramUrl = downloadAnonymousProgramUrl;
+ }
+
+ public String getFindProgramUrl()
+ {
+ return findProgramUrl;
+ }
+
+ public void setFindProgramUrl( String findProgramUrl )
+ {
+ this.findProgramUrl = findProgramUrl;
+ }
+
public void serialize( DataOutputStream dataOutputStream )
throws IOException
@@ -253,6 +289,9 @@
dataOutputStream.writeUTF( this.registerPersonUrl );
dataOutputStream.writeUTF( this.uploadProgramStageUrl );
dataOutputStream.writeUTF( this.enrollProgramUrl );
+ dataOutputStream.writeUTF( this.addRelationshipUrl );
+ dataOutputStream.writeUTF( this.downloadAnonymousProgramUrl );
+ dataOutputStream.writeUTF( this.findProgramUrl );
}
public void deSerialize( DataInputStream dataInputStream )
@@ -273,6 +312,8 @@
this.uploadProgramStageUrl = dataInputStream.readUTF();
this.registerPersonUrl = dataInputStream.readUTF();
this.enrollProgramUrl = dataInputStream.readUTF();
+ this.addRelationshipUrl = dataInputStream.readUTF();
+ this.downloadAnonymousProgramUrl = dataInputStream.readUTF();
}
@Override
@@ -326,6 +367,9 @@
dataOutputStream.writeUTF( this.uploadProgramStageUrl );
dataOutputStream.writeUTF( this.registerPersonUrl );
dataOutputStream.writeUTF( this.enrollProgramUrl );
+ 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/OptionSet.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/OptionSet.java 2013-03-13 10:11:52 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/OptionSet.java 2013-03-29 07:39:49 +0000
@@ -30,6 +30,7 @@
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
public class OptionSet
@@ -38,7 +39,7 @@
{
private String clientVersion;
- private List<String> options;
+ private List<String> options = new ArrayList<String>();
public List<String> getOptions()
{
@@ -64,7 +65,6 @@
public void serialize( DataOutputStream dout )
throws IOException
{
-
dout.writeInt( this.getId() );
dout.writeUTF( this.getName() );
dout.writeInt( this.options.size() );
@@ -73,7 +73,6 @@
{
dout.writeUTF( option );
}
-
}
@Override
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/OrgUnits.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/OrgUnits.java 2013-03-19 08:20:05 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/OrgUnits.java 2013-03-29 07:39:49 +0000
@@ -135,6 +135,7 @@
public void serializeVersion2_10( DataOutputStream dataOutputStream )
throws IOException
{
+ // send the current version to client for updating or not
dataOutputStream.writeDouble( MobileOrgUnitLinks.currentVersion );
dataOutputStream.writeInt( orgUnits.size() );
for ( MobileOrgUnitLinks unit : orgUnits )
=== 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-03-13 08:59:09 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-03-29 07:39:49 +0000
@@ -27,10 +27,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
+import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
@@ -48,6 +51,7 @@
import org.hisp.dhis.api.mobile.model.DataValue;
import org.hisp.dhis.api.mobile.model.PatientAttribute;
import org.hisp.dhis.api.mobile.model.Task;
+import org.hisp.dhis.api.mobile.model.LWUITmodel.Section;
import org.hisp.dhis.api.mobile.model.comparator.ActivityComparator;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementService;
@@ -75,8 +79,11 @@
import org.hisp.dhis.program.ProgramStageInstanceService;
import org.hisp.dhis.program.ProgramStageSection;
import org.hisp.dhis.program.ProgramStageSectionService;
+import org.hisp.dhis.program.ProgramStageService;
import org.hisp.dhis.relationship.Relationship;
import org.hisp.dhis.relationship.RelationshipService;
+import org.hisp.dhis.relationship.RelationshipType;
+import org.hisp.dhis.relationship.RelationshipTypeService;
import org.hisp.dhis.system.util.DateUtils;
import org.joda.time.DateTime;
import org.joda.time.Period;
@@ -89,6 +96,8 @@
private static final String PROGRAM_STAGE_SECTION_UPLOADED = "program_stage_section_uploaded";
+ private static final String ANONYMOUS_PROGRAM_UPLOADED = "anonymous_program_uploaded";
+
private ActivityComparator activityComparator = new ActivityComparator();
// -------------------------------------------------------------------------
@@ -117,13 +126,17 @@
private RelationshipService relationshipService;
+ private RelationshipTypeService relationshipTypeService;
+
private DataElementService dataElementService;
private PatientDataValueService patientDataValueService;
private ProgramService programService;
- private OrganisationUnitService organisationUnitService;
+ private ProgramStageService programStageService;
+
+ private OrganisationUnitService orgUnitService;
private org.hisp.dhis.mobile.service.ModelMapping modelMapping;
@@ -334,125 +347,199 @@
}
@Override
- public org.hisp.dhis.api.mobile.model.LWUITmodel.Patient findPatient( String fullName, int orgUnitId )
+ public org.hisp.dhis.api.mobile.model.LWUITmodel.Patient findPatient( String keyword, int orgUnitId )
throws NotAllowedException
{
- int startIndex = fullName.indexOf( ' ' );
- int endIndex = fullName.lastIndexOf( ' ' );
-
- String firstName = fullName.toString();
- String middleName = " ";
- String lastName = " ";
-
- if ( fullName.indexOf( ' ' ) != -1 )
+ if ( isNumber( keyword ) == false )
{
- firstName = fullName.substring( 0, startIndex );
- if ( startIndex == endIndex )
- {
- middleName = " ";
- lastName = fullName.substring( startIndex + 1, fullName.length() );
+
+ int startIndex = keyword.indexOf( ' ' );
+ int endIndex = keyword.lastIndexOf( ' ' );
+
+ String firstName = keyword.toString();
+ String middleName = " ";
+ String lastName = " ";
+
+ if ( keyword.indexOf( ' ' ) != -1 )
+ {
+ firstName = keyword.substring( 0, startIndex );
+ if ( startIndex == endIndex )
+ {
+ middleName = " ";
+ lastName = keyword.substring( startIndex + 1, keyword.length() );
+ }
+ else
+ {
+ middleName = " " + keyword.substring( startIndex + 1, endIndex ) + " ";
+ lastName = keyword.substring( endIndex + 1, keyword.length() );
+ }
+ }
+ List<Patient> patients = (List<Patient>) this.patientService.getPatientByFullname( firstName + middleName
+ + lastName, orgUnitId );
+
+ if ( patients.size() > 1 )
+ {
+ String patientsInfo = new String();
+
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
+
+ for ( Patient each : patients )
+ {
+ patientsInfo += each.getId() + "/" + each.getFullName() + "/"
+ + dateFormat.format( each.getBirthDate() ) + "$";
+ }
+
+ throw new NotAllowedException( patientsInfo );
+ }
+ else if ( patients.size() == 0 )
+ {
+ throw NotAllowedException.NO_BENEFICIARY_FOUND;
}
else
{
- middleName = " " + fullName.substring( startIndex + 1, endIndex ) + " ";
- lastName = fullName.substring( endIndex + 1, fullName.length() );
+ org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patientMobile = getPatientModel( orgUnitId,
+ patients.get( 0 ) );
+
+ return patientMobile;
}
}
- List<Patient> patients = (List<Patient>) this.patientService.getPatientByFullname( firstName + middleName
- + lastName, orgUnitId );
-
- if ( patients.size() > 1 )
- {
- throw NotAllowedException.NEED_MORE_SPECIFIC;
- }
- else if ( patients.size() == 0 )
- {
- throw NotAllowedException.NO_BENEFICIARY_FOUND;
- }
else
{
- org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patient = getPatientModel( orgUnitId, patients.get( 0 ) );
-
- return patient;
+ Patient patient = patientService.getPatient( Integer.parseInt( keyword ) );
+
+ org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patientMobile = getPatientModel( orgUnitId, patient );
+
+ return patientMobile;
}
+
}
@Override
- public String saveProgramStage( org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage programStage )
+ public String saveProgramStage( org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage mobileProgramStage,
+ int orgUnitId )
throws NotAllowedException
{
- ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( programStage
- .getId() );
-
- List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement> dataElements = programStage
- .getDataElements();
-
- for ( int i = 0; i < dataElements.size(); i++ )
+ if ( mobileProgramStage.isSingleEvent() )
{
- DataElement dataElement = dataElementService.getDataElement( dataElements.get( i ).getId() );
-
- PatientDataValue patientDataValue = new PatientDataValue( programStageInstance, dataElement, new Date(),
- dataElements.get( i ).getValue() );
-
- PatientDataValue previousPatientDataValue = patientDataValueService.getPatientDataValue(
- patientDataValue.getProgramStageInstance(), patientDataValue.getDataElement() );
-
- if ( previousPatientDataValue == null )
+ ProgramStage programStage = programStageService.getProgramStage( mobileProgramStage.getId() );
+
+ ProgramInstance programInstance = new ProgramInstance();
+
+ programInstance.setEnrollmentDate( new Date() );
+
+ programInstance.setDateOfIncident( new Date() );
+
+ programInstance.setProgram( programStage.getProgram() );
+
+ programInstance.setCompleted( true );
+
+ programInstanceService.addProgramInstance( programInstance );
+
+ ProgramStageInstance programStageInstance = new ProgramStageInstance();
+
+ programStageInstance.setProgramInstance( programInstance );
+
+ programStageInstance.setProgramStage( programStage );
+
+ programStageInstance.setDueDate( new Date() );
+
+ programStageInstance.setExecutionDate( new Date() );
+
+ programStageInstance.setCompleted( true );
+
+ programStageInstance.setOrganisationUnit( orgUnitService.getOrganisationUnit( orgUnitId ) );
+
+ programStageInstanceService.addProgramStageInstance( programStageInstance );
+
+ List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement> dataElements = mobileProgramStage
+ .getDataElements();
+
+ for ( int i = 0; i < dataElements.size(); i++ )
{
+ DataElement dataElement = dataElementService.getDataElement( dataElements.get( i ).getId() );
+
+ PatientDataValue patientDataValue = new PatientDataValue( programStageInstance, dataElement,
+ new Date(), dataElements.get( i ).getValue() );
+
patientDataValueService.savePatientDataValue( patientDataValue );
}
- else
- {
- previousPatientDataValue.setValue( patientDataValue.getValue() );
- previousPatientDataValue.setTimestamp( new Date() );
- previousPatientDataValue.setProvidedElsewhere( patientDataValue.getProvidedElsewhere() );
- patientDataValueService.updatePatientDataValue( previousPatientDataValue );
- }
-
- }
-
- programStageInstance.setExecutionDate( new Date() );
-
- if ( programStageInstance.getProgramStage().getProgramStageDataElements().size() > dataElements.size() )
- {
- programStageInstanceService.updateProgramStageInstance( programStageInstance );
- return PROGRAM_STAGE_SECTION_UPLOADED;
+
+ return ANONYMOUS_PROGRAM_UPLOADED;
}
else
{
- programStageInstance.setCompleted( true );
-
- // check if any compulsory value is null
+ ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( mobileProgramStage.getId() );
+
+ List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement> dataElements = mobileProgramStage
+ .getDataElements();
+
for ( int i = 0; i < dataElements.size(); i++ )
{
- if ( dataElements.get( i ).isCompulsory() == true )
- {
- if ( dataElements.get( i ).getValue().equals( "" ) )
+ DataElement dataElement = dataElementService.getDataElement( dataElements.get( i ).getId() );
+
+ PatientDataValue previousPatientDataValue = patientDataValueService.getPatientDataValue(
+ programStageInstance, dataElement );
+
+ if ( previousPatientDataValue == null )
+ {
+ PatientDataValue patientDataValue = new PatientDataValue( programStageInstance, dataElement,
+ new Date(), dataElements.get( i ).getValue() );
+ patientDataValueService.savePatientDataValue( patientDataValue );
+ }
+ else
+ {
+ previousPatientDataValue.setValue( dataElements.get( i ).getValue() );
+ previousPatientDataValue.setTimestamp( new Date() );
+ previousPatientDataValue.setProvidedElsewhere( false );
+ patientDataValueService.updatePatientDataValue( previousPatientDataValue );
+ }
+
+ }
+
+ programStageInstance.setExecutionDate( new Date() );
+
+ if ( programStageInstance.getProgramStage().getProgramStageDataElements().size() > dataElements.size() )
+ {
+ programStageInstanceService.updateProgramStageInstance( programStageInstance );
+ return PROGRAM_STAGE_SECTION_UPLOADED;
+ }
+ else
+ {
+ programStageInstance.setCompleted( true );
+
+ // check if any compulsory value is null
+ for ( int i = 0; i < dataElements.size(); i++ )
+ {
+ if ( dataElements.get( i ).isCompulsory() == true )
{
- programStageInstance.setCompleted( false );
- // break;
- throw NotAllowedException.INVALID_PROGRAM_STAGE;
+ if ( dataElements.get( i ).getValue().equals( "" ) )
+ {
+ programStageInstance.setCompleted( false );
+ // break;
+ throw NotAllowedException.INVALID_PROGRAM_STAGE;
+ }
}
}
- }
- programStageInstanceService.updateProgramStageInstance( programStageInstance );
-
- // check if all belonged program stage are completed
- if ( isAllProgramStageFinished( programStageInstance ) == true )
- {
- ProgramInstance programInstance = programStageInstance.getProgramInstance();
- programInstance.setCompleted( true );
- programInstanceService.updateProgramInstance( programInstance );
- }
-
- return PROGRAM_STAGE_UPLOADED;
+ programStageInstanceService.updateProgramStageInstance( programStageInstance );
+
+ // check if all belonged program stage are completed
+ if ( isAllProgramStageFinished( programStageInstance ) == true )
+ {
+ ProgramInstance programInstance = programStageInstance.getProgramInstance();
+ programInstance.setCompleted( true );
+ programInstanceService.updateProgramInstance( programInstance );
+ }
+
+ return PROGRAM_STAGE_UPLOADED;
+ }
}
+
}
-
+
private boolean isAllProgramStageFinished( ProgramStageInstance programStageInstance )
{
ProgramInstance programInstance = programStageInstance.getProgramInstance();
- Collection<ProgramStageInstance> programStageInstances = programInstance.getProgramStageInstances();
+ Collection<ProgramStageInstance> programStageInstances = programInstance.getProgramStageInstances();
if ( programStageInstances != null )
{
Iterator<ProgramStageInstance> iterator = programStageInstances.iterator();
@@ -460,7 +547,7 @@
while ( iterator.hasNext() )
{
ProgramStageInstance each = iterator.next();
- if( !each.isCompleted() )
+ if ( !each.isCompleted() )
{
return false;
}
@@ -771,12 +858,12 @@
if ( eachRelationship.getPatientA().getId() == patient.getId() )
{
relationshipMobile.setName( eachRelationship.getRelationshipType().getaIsToB() );
- relationshipMobile.setPersonName( eachRelationship.getPatientB().getFullName() );
+ relationshipMobile.setPersonBName( eachRelationship.getPatientB().getFullName() );
}
else
{
relationshipMobile.setName( eachRelationship.getRelationshipType().getbIsToA() );
- relationshipMobile.setPersonName( eachRelationship.getPatientA().getFullName() );
+ relationshipMobile.setPersonBName( eachRelationship.getPatientA().getFullName() );
}
relationshipList.add( relationshipMobile );
}
@@ -786,6 +873,7 @@
List<Program> enrollmentProgramList = new ArrayList<Program>();
enrollmentProgramList = generateEnrollmentProgramList( orgUnitId, patient );
List<org.hisp.dhis.api.mobile.model.LWUITmodel.Program> enrollmentProgramListMobileList = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.Program>();
+
for ( Program enrollmentProgram : enrollmentProgramList )
{
org.hisp.dhis.api.mobile.model.LWUITmodel.Program enrollmentProgramMobile = new org.hisp.dhis.api.mobile.model.LWUITmodel.Program();
@@ -796,9 +884,22 @@
enrollmentProgramMobile.setProgramStages( null );
enrollmentProgramListMobileList.add( enrollmentProgramMobile );
}
-
patientModel.setEnrollmentPrograms( enrollmentProgramListMobileList );
+ // Set available enrollment relationships
+ List<RelationshipType> enrollmentRelationshipList = new ArrayList<RelationshipType>(
+ relationshipTypeService.getAllRelationshipTypes() );
+ List<org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship> enrollmentRelationshipMobileList = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship>();
+ for ( RelationshipType enrollmentRelationship : enrollmentRelationshipList )
+ {
+ org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship enrollmentRelationshipMobile = new org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship();
+ enrollmentRelationshipMobile.setId( enrollmentRelationship.getId() );
+ enrollmentRelationshipMobile.setName( enrollmentRelationship.getName() );
+ enrollmentRelationshipMobile.setaIsToB( enrollmentRelationship.getaIsToB() );
+ enrollmentRelationshipMobile.setbIsToA( enrollmentRelationship.getbIsToA() );
+ enrollmentRelationshipMobileList.add( enrollmentRelationshipMobile );
+ }
+ patientModel.setEnrollmentRelationships( enrollmentRelationshipMobileList );
return patientModel;
}
@@ -822,6 +923,9 @@
// is completed
mobileProgramStage.setCompleted( checkIfProgramStageCompleted( patient, program, eachProgramStage ) );
+ // is single event
+ mobileProgramStage.setSingleEvent( programInstance.getProgram().isSingleEvent() );
+
// Set all data elements
mobileProgramStage.setDataElements( getDataElementsForMobile( eachProgramStage, programStageInstance ) );
@@ -882,10 +986,10 @@
mobileDataElement.setId( programStageDataElement.getDataElement().getId() );
mobileDataElement.setName( programStageDataElement.getDataElement().getName() );
mobileDataElement.setType( programStageDataElement.getDataElement().getType() );
- if ( programStageDataElement.getDataElement().getNumberType() != null )
- {
- mobileDataElement.setCompulsory( programStageDataElement.isCompulsory() );
- }
+
+ //problem
+ mobileDataElement.setCompulsory( programStageDataElement.isCompulsory() );
+
mobileDataElement.setNumberType( programStageDataElement.getDataElement().getNumberType() );
PatientDataValue patientDataValue = dataValueService.getPatientDataValue( programStageInstance,
@@ -934,7 +1038,7 @@
private List<Program> generateEnrollmentProgramList( int orgId, Patient patient )
{
List<Program> programs = new ArrayList<Program>();
- for ( Program program : programService.getPrograms( organisationUnitService.getOrganisationUnit( orgId ) ) )
+ for ( Program program : programService.getPrograms( orgUnitService.getOrganisationUnit( orgId ) ) )
{
if ( (program.isSingleEvent() && program.isRegistration()) || !program.isSingleEvent() )
@@ -949,6 +1053,202 @@
return programs;
}
+ private boolean isNumber( String value )
+ {
+ try
+ {
+ Double.parseDouble( value );
+ }
+ catch ( NumberFormatException e )
+ {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public org.hisp.dhis.api.mobile.model.LWUITmodel.Patient addRelationship(
+ org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship enrollmentRelationship, int orgUnitId )
+ throws NotAllowedException
+ {
+ String fullName = enrollmentRelationship.getPersonBName();
+ int startIndex = fullName.indexOf( ' ' );
+ int endIndex = fullName.lastIndexOf( ' ' );
+
+ String firstName = fullName.toString();
+ String middleName = " ";
+ String lastName = " ";
+
+ if ( fullName.indexOf( ' ' ) != -1 )
+ {
+ firstName = fullName.substring( 0, startIndex );
+ if ( startIndex == endIndex )
+ {
+ middleName = " ";
+ lastName = fullName.substring( startIndex + 1, fullName.length() );
+ }
+ else
+ {
+ middleName = " " + fullName.substring( startIndex + 1, endIndex ) + " ";
+ lastName = fullName.substring( endIndex + 1, fullName.length() );
+ }
+ }
+ List<Patient> patients = (List<Patient>) this.patientService.getPatientByFullname( firstName + middleName
+ + lastName, orgUnitId );
+
+ if ( patients.size() > 1 )
+ {
+ throw NotAllowedException.NEED_MORE_SPECIFIC;
+ }
+ else if ( patients.size() == 0 )
+ {
+ throw NotAllowedException.NO_BENEFICIARY_FOUND;
+ }
+ else
+ {
+ Patient patientB = patients.get( 0 );
+ Patient patientA = patientService.getPatient( enrollmentRelationship.getPersonAId() );
+ RelationshipType relationshipType = relationshipTypeService.getRelationshipType( enrollmentRelationship
+ .getId() );
+
+ Relationship relationship = new Relationship();
+ relationship.setRelationshipType( relationshipType );
+ if ( enrollmentRelationship.getChosenRelationship().equals( relationshipType.getaIsToB() ) )
+ {
+ relationship.setPatientA( patientA );
+ relationship.setPatientB( patientB );
+ }
+ else
+ {
+ relationship.setPatientA( patientB );
+ relationship.setPatientB( patientA );
+ }
+ relationshipService.saveRelationship( relationship );
+ return getPatientModel( orgUnitId, patientA );
+ }
+ }
+
+ @Override
+ public org.hisp.dhis.api.mobile.model.LWUITmodel.Program getAllAnonymousProgram( int orgUnitId )
+ throws NotAllowedException
+ {
+ String programsInfo = "";
+
+ OrganisationUnit organisationUnit = orgUnitService.getOrganisationUnit( orgUnitId );
+
+ 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 ) )
+ {
+ programs.add( program );
+ }
+ }
+
+ if ( programs.size() != 0 )
+ {
+ if ( programs.size() == 1 )
+ {
+ Program anonymousProgram = programs.get( 0 );
+
+ return getMobileAnonymousProgram( anonymousProgram );
+ }
+ else
+ {
+ for ( Program program : programs )
+ {
+ if ( program.getOrganisationUnits().contains( organisationUnit ) )
+ {
+ programsInfo += program.getId() + "/" + program.getName() + "$";
+ }
+ }
+ throw new NotAllowedException( programsInfo );
+ }
+ }
+ else
+ {
+ throw NotAllowedException.NO_PROGRAM_FOUND;
+ }
+ }
+
+ private org.hisp.dhis.api.mobile.model.LWUITmodel.Program getMobileAnonymousProgram( Program anonymousProgram )
+ {
+ Comparator<ProgramStageDataElement> OrderBySortOrder = new Comparator<ProgramStageDataElement>()
+ {
+ public int compare( ProgramStageDataElement i1, ProgramStageDataElement i2 )
+ {
+ return i1.getSortOrder().compareTo( i2.getSortOrder() );
+ }
+ };
+
+ org.hisp.dhis.api.mobile.model.LWUITmodel.Program anonymousProgramMobile = new org.hisp.dhis.api.mobile.model.LWUITmodel.Program();
+
+ anonymousProgramMobile.setId( anonymousProgram.getId() );
+
+ anonymousProgramMobile.setName( anonymousProgram.getName() );
+
+ ProgramStage programStage = anonymousProgram.getProgramStages().iterator().next();
+
+ List<ProgramStageDataElement> programStageDataElements = new ArrayList<ProgramStageDataElement>(
+ programStage.getProgramStageDataElements() );
+ Collections.sort( programStageDataElements, OrderBySortOrder );
+
+ List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage> mobileProgramStages = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage>();
+
+ 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.ProgramStageDataElement> mobileProgramStageDataElements = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement>();
+
+ mobileProgramStage.setId( programStage.getId() );
+ mobileProgramStage.setName( programStage.getName() );
+ mobileProgramStage.setCompleted( false );
+ mobileProgramStage.setRepeatable( false );
+ mobileProgramStage.setSingleEvent( true );
+ mobileProgramStage.setSections( new ArrayList<Section>() );
+
+ 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() );
+
+ //problem
+ mobileDataElement.setCompulsory( programStageDataElement.isCompulsory() );
+
+ mobileDataElement.setNumberType( programStageDataElement.getDataElement().getNumberType() );
+
+ mobileDataElement.setValue( "" );
+
+ if ( programStageDataElement.getDataElement().getOptionSet() != null )
+ {
+ mobileDataElement.setOptionSet( modelMapping.getLWUITOptionSet( programStageDataElement
+ .getDataElement() ) );
+ }
+ else
+ {
+ mobileDataElement.setOptionSet( null );
+ }
+ if ( programStageDataElement.getDataElement().getCategoryCombo() != null )
+ {
+ mobileDataElement.setCategoryOptionCombos( modelMapping
+ .getCategoryOptionCombos( programStageDataElement.getDataElement() ) );
+ }
+ else
+ {
+ mobileDataElement.setCategoryOptionCombos( null );
+ }
+ mobileProgramStageDataElements.add( mobileDataElement );
+ }
+ mobileProgramStage.setDataElements( mobileProgramStageDataElements );
+ mobileProgramStages.add( mobileProgramStage );
+ anonymousProgramMobile.setProgramStages( mobileProgramStages );
+
+ return anonymousProgramMobile;
+ }
+
private void saveDataValues( ActivityValue activityValue, ProgramStageInstance programStageInstance,
Map<Integer, DataElement> dataElementMap )
{
@@ -1104,9 +1404,9 @@
}
@Required
- public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ public void setOrgUnitService( OrganisationUnitService orgUnitService )
{
- this.organisationUnitService = organisationUnitService;
+ this.orgUnitService = orgUnitService;
}
@Required
@@ -1114,4 +1414,17 @@
{
this.programService = programService;
}
+
+ @Required
+ public void setRelationshipTypeService( RelationshipTypeService relationshipTypeService )
+ {
+ this.relationshipTypeService = relationshipTypeService;
+ }
+
+ @Required
+ public void setProgramStageService( ProgramStageService programStageService )
+ {
+ this.programStageService = programStageService;
+ }
+
}
=== 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-06 04:25:38 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml 2013-03-29 07:39:49 +0000
@@ -31,8 +31,10 @@
<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
<property name="patientDataValueService" ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
- <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService"></property>
+ <property name="orgUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService"></property>
<property name="modelMapping" ref="org.hisp.dhis.mobile.service.ModelMapping" />
+ <property name="relationshipTypeService" ref="org.hisp.dhis.relationship.RelationshipTypeService"></property>
+ <property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
</bean>
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitTest.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitTest.java 2013-03-08 10:55:15 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitTest.java 2013-03-29 07:39:49 +0000
@@ -62,6 +62,9 @@
unit.setUploadProgramStageUrl( "uploadProgramStageUrl" );
unit.setEnrollProgramUrl( "enrollProgramUrl" );
unit.setRegisterPersonUrl( "registerPersonUrl" );
+ unit.setAddRelationshipUrl( "addRelationshipUrl" );
+ unit.setDownloadAnonymousProgramUrl( "downloadAnonymousProgramUrl" );
+ unit.setFindProgramUrl( "findProgramUrl" );
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream( baos );
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitsTest.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitsTest.java 2013-03-08 10:55:15 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitsTest.java 2013-03-29 07:39:49 +0000
@@ -87,6 +87,9 @@
unit.setUploadProgramStageUrl( "uploadProgramStageUrl" );
unit.setEnrollProgramUrl( "enrollProgramUrl" );
unit.setRegisterPersonUrl( "registerPersonUrl" );
+ unit.setAddRelationshipUrl( "addRelationshipUrl" );
+ unit.setDownloadAnonymousProgramUrl( "downloadAnonymousProgramUrl" );
+ unit.setFindProgramUrl( "findProgramUrl" );
return unit;
}
}
=== 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-19 08:20:05 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java 2013-03-29 07:39:49 +0000
@@ -145,6 +145,8 @@
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" ) );
// generate URL for download new version
String full = UrlUtils.buildFullRequestUrl( request );
=== 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-03-14 07:19:34 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java 2013-03-29 07:39:49 +0000
@@ -45,7 +45,9 @@
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;
@@ -300,12 +302,19 @@
return facilityReportingService.updateContactForMobile();
}
+ @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/updateContactForMobile" )
+ @ResponseBody
+ public Contact updateContactForMobileLWUIT()
+ {
+ return facilityReportingService.updateContactForMobile();
+ }
+
@RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/findPatient" )
@ResponseBody
- public Patient findPatientByName( @PathVariable int id, @RequestHeader( "name" ) String fullName )
+ public Patient findPatientByName( @PathVariable int id, @RequestHeader( "name" ) String keyword )
throws NotAllowedException
{
- return activityReportingService.findPatient( fullName, id );
+ return activityReportingService.findPatient( keyword, id );
}
@RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/LWUIT/orgUnits/{id}/uploadProgramStage" )
@@ -313,7 +322,7 @@
public String saveProgramStage( @PathVariable int id, @RequestBody ProgramStage programStage )
throws NotAllowedException
{
- return activityReportingService.saveProgramStage( programStage );
+ return activityReportingService.saveProgramStage( programStage, id );
}
@RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/enrollProgram" )
@@ -324,6 +333,22 @@
return activityReportingService.enrollProgram( enrollInfo, id );
}
+ @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/LWUIT/orgUnits/{id}/addRelationship" )
+ @ResponseBody
+ public Patient addRelationship( @PathVariable int id, @RequestBody Relationship enrollmentRelationship )
+ throws NotAllowedException
+ {
+ return activityReportingService.addRelationship( enrollmentRelationship, id );
+ }
+
+ @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/downloadAnonymousProgramUrl" )
+ @ResponseBody
+ public Program getAnonymousProgram( @PathVariable int id, @RequestHeader( "useless-part" ) String enrollInfo )
+ throws NotAllowedException
+ {
+ return activityReportingService.getAllAnonymousProgram( id );
+ }
+
// Supportive methods
private Collection<String> getLocalStrings( Collection<Locale> locales )
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/anonymous/action/GetAllAnonymousProgramAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/anonymous/action/GetAllAnonymousProgramAction.java 2013-03-22 03:45:13 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/anonymous/action/GetAllAnonymousProgramAction.java 2013-03-29 07:39:49 +0000
@@ -30,6 +30,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramService;
@@ -55,6 +56,13 @@
this.programService = programService;
}
+ private OrganisationUnitService orgUnitService;
+
+ public void setOrgUnitService( OrganisationUnitService orgUnitService )
+ {
+ this.orgUnitService = orgUnitService;
+ }
+
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
@@ -89,18 +97,6 @@
{
this.orgUnitId = orgUnitId;
}
-
- private OrganisationUnitService organisationUnitService;
-
- public OrganisationUnitService getOrganisationUnitService()
- {
- return organisationUnitService;
- }
-
- public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
- {
- this.organisationUnitService = organisationUnitService;
- }
// -------------------------------------------------------------------------
// Implementation Action
@@ -110,14 +106,19 @@
public String execute()
throws Exception
{
- programs = new ArrayList<Program>();
- for ( Program program : programService.getProgramsByCurrentUser() )
+ OrganisationUnit organisationUnit = orgUnitService.getOrganisationUnit( orgUnitId );
+
+ if( programService.getProgramsByCurrentUser( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) != null )
{
- if ( program.isSingleEvent() && !program.isRegistration() && program.getOrganisationUnits().contains( organisationUnitService.getOrganisationUnit( orgUnitId ) ) )
+ for ( Program program : programService.getProgramsByCurrentUser( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) )
{
- programs.add( program );
+ if ( program.getOrganisationUnits().contains( organisationUnit ) )
+ {
+ programs.add( program );
+ }
}
}
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml 2013-03-22 03:45:13 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml 2013-03-29 07:39:49 +0000
@@ -535,7 +535,7 @@
class="org.hisp.dhis.light.anonymous.action.GetAllAnonymousProgramAction"
scope="prototype">
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
- <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ <property name="orgUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
</bean>
<bean id="org.hisp.dhis.light.anonymous.action.ShowAnonymousFormAction"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/J2meClientUpdateAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/J2meClientUpdateAction.java 2013-03-13 10:11:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/J2meClientUpdateAction.java 2013-03-29 07:39:49 +0000
@@ -81,12 +81,22 @@
public String execute()
throws Exception
{
- List<PatientMobileSetting> list = new ArrayList<PatientMobileSetting>();
+ List<PatientMobileSetting> list;
list = (List<PatientMobileSetting>) patientMobileSettingService.getCurrentSetting();
- this.patientMobileSetting = list.get( 0 );
-
+ if( list.size() == 0 )
+ {
+ this.patientMobileSetting = new PatientMobileSetting();
+ patientMobileSetting.setGender( false );
+ patientMobileSetting.setDobtype( false );
+ patientMobileSetting.setBirthdate( false );
+ patientMobileSetting.setRegistrationdate( false );
+ }
+ else
+ {
+ this.patientMobileSetting = list.get( 0 );
+ }
if ( this.version != 0 )
{
this.patientMobileSetting.setVersionToUpdate( this.version );
@@ -101,7 +111,6 @@
this.patientMobileSetting.setAutoUpdateClient( false );
}
patientMobileSettingService.savePatientMobileSetting( this.patientMobileSetting );
-
return SUCCESS;
}