dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21249
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10001: add enroll Program handler - lwuit
------------------------------------------------------------
revno: 10001
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-03-06 11:25:38 +0700
message:
add enroll Program handler - lwuit
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.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/model/LWUITmodel/Patient.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Program.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileOrgUnitLinks.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-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.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/webapp/dhis-web-light/enrollment/programEnrollmentForm.vm
--
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/PatientService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java 2013-03-05 07:29:03 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java 2013-03-06 04:25:38 +0000
@@ -217,5 +217,5 @@
Collection<Patient> getPatientsByPhone( String phoneNumber, Integer min, Integer max );
- Collection<Patient> getPatientByFullname( String fullName );
+ Collection<Patient> getPatientByFullname( String fullName, int orgUnitId );
}
=== 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-02-25 06:32:56 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java 2013-03-06 04:25:38 +0000
@@ -49,10 +49,13 @@
public void saveActivityReport( OrganisationUnit unit, ActivityValue activityValue, Integer programStageSectionId )
throws NotAllowedException;
- public Patient findPatient( String name )
- throws NotAllowedException;
-
- public void saveProgramStage( ProgramStage programStage )
- throws NotAllowedException;
-
+ public Patient findPatient( String name, int orgUnitId )
+ throws NotAllowedException;
+
+ public String saveProgramStage( ProgramStage programStage )
+ throws NotAllowedException;
+
+ public Patient enrollProgram( String enrollInfo, 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-02-25 06:32:56 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java 2013-03-06 04:25:38 +0000
@@ -77,6 +77,8 @@
private List<Program> programs;
private List<Relationship> relationships;
+
+ private List<Program> enrollmentPrograms;
public List<PatientIdentifier> getIdentifiers()
{
@@ -108,6 +110,16 @@
this.relationships = relationships;
}
+ public List<Program> getEnrollmentPrograms()
+ {
+ return enrollmentPrograms;
+ }
+
+ public void setEnrollmentPrograms( List<Program> enrollmentPrograms )
+ {
+ this.enrollmentPrograms = enrollmentPrograms;
+ }
+
public String getFullName()
{
boolean space = false;
@@ -344,7 +356,7 @@
{
each.serialize( dout );
}
-
+
// Write Relationships
dout.writeInt( relationships.size() );
for ( Relationship each : relationships )
@@ -352,6 +364,13 @@
each.serialize( dout );
}
+ // Write Available Program To Enroll
+ dout.writeInt( enrollmentPrograms.size() );
+ for ( Program each : enrollmentPrograms )
+ {
+ 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/Program.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Program.java 2013-02-01 07:09:23 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Program.java 2013-03-06 04:25:38 +0000
@@ -96,11 +96,18 @@
super.serialize( dout );
dout.writeBoolean( this.isCompleted() );
dout.writeInt( this.getVersion() );
- dout.writeInt( programStages.size() );
- for ( int i = 0; i < programStages.size(); i++ )
- {
- ProgramStage ps = (ProgramStage) programStages.get( i );
- ps.serialize( dout );
+ if( programStages == null )
+ {
+ dout.writeInt( 0 );
+ }
+ else
+ {
+ dout.writeInt( programStages.size() );
+ for ( int i = 0; i < programStages.size(); i++ )
+ {
+ ProgramStage ps = (ProgramStage) programStages.get( i );
+ ps.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-02-25 06:32:56 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileOrgUnitLinks.java 2013-03-06 04:25:38 +0000
@@ -67,6 +67,9 @@
private String findPatientUrl;
private String uploadProgramStageUrl;
+
+ private String enrollProgramUrl;
+
@XmlAttribute
public int getId()
@@ -210,6 +213,16 @@
this.uploadProgramStageUrl = uploadProgramStageUrl;
}
+ public String getEnrollProgramUrl()
+ {
+ return enrollProgramUrl;
+ }
+
+ public void setEnrollProgramUrl( String enrollProgramUrl )
+ {
+ this.enrollProgramUrl = enrollProgramUrl;
+ }
+
public void serialize( DataOutputStream dataOutputStream )
throws IOException
@@ -227,6 +240,7 @@
dataOutputStream.writeUTF( this.updateContactUrl );
dataOutputStream.writeUTF( this.findPatientUrl );
dataOutputStream.writeUTF( this.uploadProgramStageUrl );
+ dataOutputStream.writeUTF( this.enrollProgramUrl );
}
public void deSerialize( DataInputStream dataInputStream )
@@ -245,6 +259,7 @@
this.updateContactUrl = dataInputStream.readUTF();
this.findPatientUrl = dataInputStream.readUTF();
this.uploadProgramStageUrl = dataInputStream.readUTF();
+ this.enrollProgramUrl = dataInputStream.readUTF();
}
@Override
@@ -296,7 +311,7 @@
dataOutputStream.writeUTF( this.updateContactUrl );
dataOutputStream.writeUTF( this.findPatientUrl );
dataOutputStream.writeUTF( this.uploadProgramStageUrl );
-
+ dataOutputStream.writeUTF( this.enrollProgramUrl );
}
}
=== 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-02-25 06:32:56 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-03-06 04:25:38 +0000
@@ -50,7 +50,9 @@
import org.hisp.dhis.api.mobile.model.Task;
import org.hisp.dhis.api.mobile.model.comparator.ActivityComparator;
import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.patient.Patient;
import org.hisp.dhis.patient.PatientAttributeService;
import org.hisp.dhis.patient.PatientIdentifier;
@@ -66,6 +68,7 @@
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramInstance;
import org.hisp.dhis.program.ProgramInstanceService;
+import org.hisp.dhis.program.ProgramService;
import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageDataElement;
import org.hisp.dhis.program.ProgramStageInstance;
@@ -77,11 +80,17 @@
import org.hisp.dhis.system.util.DateUtils;
import org.joda.time.DateTime;
import org.joda.time.Period;
+import org.joda.time.format.DateTimeFormatter;
+import org.joda.time.format.ISODateTimeFormat;
import org.springframework.beans.factory.annotation.Required;
public class ActivityReportingServiceImpl
implements ActivityReportingService
{
+ private static final String PROGRAM_STAGE_UPLOADED = "program_stage_uploaded";
+
+ private static final String PROGRAM_STAGE_SECTION_UPLOADED = "program_stage_section_uploaded";
+
private ActivityComparator activityComparator = new ActivityComparator();
// -------------------------------------------------------------------------
@@ -109,8 +118,14 @@
private ProgramInstanceService programInstanceService;
private RelationshipService relationshipService;
-
- private Beneficiary beneficiary;
+
+ private DataElementService dataElementService;
+
+ private PatientDataValueService patientDataValueService;
+
+ private ProgramService programService;
+
+ private OrganisationUnitService organisationUnitService;
private org.hisp.dhis.mobile.service.ModelMapping modelMapping;
@@ -442,7 +457,7 @@
}
// get patient model for LWUIT
- private org.hisp.dhis.api.mobile.model.LWUITmodel.Patient getPatientModel( Patient patient )
+ private org.hisp.dhis.api.mobile.model.LWUITmodel.Patient getPatientModel(int orgUnitId, 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>();
@@ -545,25 +560,11 @@
mobileProgram.setName( each.getProgram().getName() );
mobileProgram.setCompleted( each.isCompleted() );
mobileProgram.setProgramStages( getMobileProgramStages( patient, each, each.getProgram() ) );
+
mobileProgramList.add( mobileProgram );
}
}
- /*Set<Program> programs = patient.getPrograms();
- if ( programs.size() > 0 )
- {
- for ( Program each : programs )
- {
-
- org.hisp.dhis.api.mobile.model.LWUITmodel.Program mobileProgram = new org.hisp.dhis.api.mobile.model.LWUITmodel.Program();
- mobileProgram.setVersion( each.getVersion() );
- mobileProgram.setId( listOfProgramInstance.get( 0 ).getId() );
- mobileProgram.setName( each.getName() );
- mobileProgram.setProgramStages( getMobileProgramStages( patient, each ) );
- mobileProgramList.add( mobileProgram );
- }
- }*/
-
patientModel.setPrograms( mobileProgramList );
// Set Relationship
@@ -574,8 +575,6 @@
{
org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship relationshipMobile = new org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship();
relationshipMobile.setId( eachRelationship.getId() );
- // relationshipMobile.setName(
- // eachRelationship.getRelationshipType().getName() );
if ( eachRelationship.getPatientA().getId() == patient.getId() )
{
relationshipMobile.setName( eachRelationship.getRelationshipType().getaIsToB() );
@@ -589,6 +588,23 @@
relationshipList.add( relationshipMobile );
}
patientModel.setRelationships( relationshipList );
+
+ // Set available enrollment programs
+ 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();
+ enrollmentProgramMobile.setId( enrollmentProgram.getId() );
+ enrollmentProgramMobile.setName( enrollmentProgram.getName() );
+ enrollmentProgramMobile.setCompleted( false );
+ enrollmentProgramMobile.setVersion( enrollmentProgram.getVersion() );
+ enrollmentProgramMobile.setProgramStages( null );
+ enrollmentProgramListMobileList.add( enrollmentProgramMobile );
+ }
+ patientModel.setEnrollmentPrograms( enrollmentProgramListMobileList );
+
return patientModel;
}
@@ -799,13 +815,6 @@
{
this.modelMapping = modelMapping;
}
-
- // public void setActivityPlanService(
- // org.hisp.dhis.activityplan.ActivityPlanService activityPlanService )
- // {
- // this.activityPlanService = activityPlanService;
- // }
-
public PatientMobileSetting getSetting()
{
@@ -827,11 +836,6 @@
this.groupByAttribute = groupByAttribute;
}
- public PatientIdentifierService getPatientIdentifierService()
- {
- return patientIdentifierService;
- }
-
@Required
public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService )
{
@@ -844,17 +848,13 @@
this.patientService = patientService;
}
- public void setBeneficiary( Beneficiary beneficiary )
- {
- this.beneficiary = beneficiary;
- }
-
@Required
public void setProgramInstanceService( ProgramInstanceService programInstanceService )
{
this.programInstanceService = programInstanceService;
}
+ @Required
public void setRelationshipService( RelationshipService relationshipService )
{
this.relationshipService = relationshipService;
@@ -866,8 +866,32 @@
this.programStageSectionService = programStageSectionService;
}
+ @Required
+ public void setDataElementService( DataElementService dataElementService )
+ {
+ this.dataElementService = dataElementService;
+ }
+
+ @Required
+ public void setPatientDataValueService( PatientDataValueService patientDataValueService )
+ {
+ this.patientDataValueService = patientDataValueService;
+ }
+
+ @Required
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+ @Required
+ public void setProgramService( ProgramService programService )
+ {
+ this.programService = programService;
+ }
+
@Override
- public org.hisp.dhis.api.mobile.model.LWUITmodel.Patient findPatient( String fullName )
+ public org.hisp.dhis.api.mobile.model.LWUITmodel.Patient findPatient( String fullName, int orgUnitId )
throws NotAllowedException
{
int startIndex = fullName.indexOf( ' ' );
@@ -892,7 +916,7 @@
}
}
List<Patient> patients = (List<Patient>) this.patientService.getPatientByFullname( firstName + middleName
- + lastName );
+ + lastName, orgUnitId );
if ( patients.size() > 1 )
{
@@ -904,17 +928,128 @@
}
else
{
- org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patient = getPatientModel( patients.get( 0 ) );
+ org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patient = getPatientModel( orgUnitId, patients.get( 0 ) );
return patient;
}
}
@Override
- public void saveProgramStage( org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage programStage )
- throws NotAllowedException
- {
- System.out.println("name: "+programStage.getName());
-
+ public String saveProgramStage( org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage programStage )
+ 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++ )
+ {
+ 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 )
+ {
+ 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;
+ }
+ else
+ {
+ programStageInstance.setCompleted( true );
+ programStageInstanceService.updateProgramStageInstance( programStageInstance );
+ return PROGRAM_STAGE_UPLOADED;
+ }
+ }
+
+ private List<Program> generateEnrollmentProgramList( int orgId, Patient patient )
+ {
+ List<Program> programs = new ArrayList<Program>();
+ for ( Program program : programService.getPrograms( organisationUnitService.getOrganisationUnit( orgId ) ) )
+
+ {
+ if ( (program.isSingleEvent() && program.isRegistration()) || !program.isSingleEvent() )
+ {
+ //wrong here
+ if ( programInstanceService.getProgramInstances( patient, program ).size() == 0 )
+ {
+ programs.add( program );
+ }
+ }
+ }
+ return programs;
+ }
+
+ @Override
+ public org.hisp.dhis.api.mobile.model.LWUITmodel.Patient enrollProgram( String enrollInfo, int orgUnitId )
+ throws NotAllowedException
+ {
+ String[] enrollProgramInfos = enrollInfo.split( "-" );
+ int patientId = Integer.parseInt( enrollProgramInfos[0] );
+ int programId = Integer.parseInt( enrollProgramInfos[1] );
+
+ Patient patient = patientService.getPatient( patientId );
+ Program program = programService.getProgram( programId );
+
+ DateTimeFormatter sdf = ISODateTimeFormat.yearMonthDay();
+ ProgramInstance programInstance = new ProgramInstance();
+ //programInstance.setEnrollmentDate( sdf.parseDateTime( enrollmentDate ).toDate() );
+ //programInstance.setDateOfIncident( sdf.parseDateTime( incidentDate ).toDate() );
+ programInstance.setEnrollmentDate( new Date() );
+ programInstance.setDateOfIncident( new Date() );
+ programInstance.setProgram( program );
+ programInstance.setPatient( patient );
+ programInstance.setCompleted( false );
+ programInstanceService.addProgramInstance( programInstance );
+ patient.getPrograms().add( program );
+ patientService.updatePatient( patient );
+ for ( ProgramStage programStage : program.getProgramStages() )
+ {
+ if ( programStage.getAutoGenerateEvent() )
+ {
+ ProgramStageInstance programStageInstance = new ProgramStageInstance();
+ programStageInstance.setProgramInstance( programInstance );
+ programStageInstance.setProgramStage( programStage );
+
+ //Date dateCreatedEvent = sdf.parseDateTime( incidentDate ).toDate();
+ Date dateCreatedEvent = new Date();
+ if ( program.getGeneratedByEnrollmentDate() )
+ {
+ //dateCreatedEvent = sdf.parseDateTime( enrollmentDate ).toDate();
+ }
+ Date dueDate = DateUtils
+ .getDateAfterAddition( dateCreatedEvent, programStage.getMinDaysFromStart() );
+
+ programStageInstance.setDueDate( dueDate );
+
+ if ( program.isSingleEvent() )
+ {
+ programStageInstance.setExecutionDate( dueDate );
+ }
+
+ programStageInstanceService.addProgramStageInstance( programStageInstance );
+
+ }
+
+ }
+
+ return getPatientModel( orgUnitId, patient );
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml 2013-02-01 07:09:23 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/resources/META-INF/dhis/beans.xml 2013-03-06 04:25:38 +0000
@@ -28,6 +28,10 @@
<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
<property name="relationshipService" ref="org.hisp.dhis.relationship.RelationshipService" />
+ <property name="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="modelMapping" ref="org.hisp.dhis.mobile.service.ModelMapping" />
</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-02-25 06:32:56 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitTest.java 2013-03-06 04:25:38 +0000
@@ -60,6 +60,7 @@
unit.setUpdateContactUrl( "updateContactUrl" );
unit.setFindPatientUrl( "findPatientUrl" );
unit.setUploadProgramStageUrl( "uploadProgramStageUrl" );
+ unit.setEnrollProgramUrl( "enrollProgramUrl" );
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-02-25 06:32:56 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitsTest.java 2013-03-06 04:25:38 +0000
@@ -85,6 +85,7 @@
unit.setUpdateContactUrl( "updateContactUrl" );
unit.setFindPatientUrl( "findPatientUrl" );
unit.setUploadProgramStageUrl( "uploadProgramStageUrl" );
+ unit.setEnrollProgramUrl( "enrollProgramUrl" );
return unit;
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2013-03-05 07:29:03 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2013-03-06 04:25:38 +0000
@@ -590,9 +590,28 @@
}
@Override
- public Collection<Patient> getPatientByFullname( String fullName )
+ public Collection<Patient> getPatientByFullname( String fullName, int orgUnitId )
{
- return patientStore.getByFullName( fullName );
+ Collection<Patient> patients = new HashSet<Patient>();
+
+ patients = patientStore.getByFullName( fullName );
+
+ if ( orgUnitId != 0 )
+ {
+ Set<Patient> toRemoveList = new HashSet<Patient>();
+
+ for ( Patient patient : patients )
+ {
+ if ( patient.getOrganisationUnit().getId() != orgUnitId )
+ {
+ toRemoveList.add( patient );
+ }
+ }
+
+ patients.removeAll( toRemoveList );
+ }
+
+ return patients;
}
}
=== 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-02-25 06:32:56 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java 2013-03-06 04:25:38 +0000
@@ -92,6 +92,7 @@
orgUnit.setUpdateContactUrl( getUrl( request, unit.getId(), "updateContactForMobile" ) );
orgUnit.setFindPatientUrl( getUrl( request, unit.getId(), "findPatient" ) );
orgUnit.setUploadProgramStageUrl( getUrl( request, unit.getId(), "uploadProgramStage" ) );
+ orgUnit.setEnrollProgramUrl( getUrl( request, unit.getId(), "enrollProgram" ) );
// generate URL for download new version
String full = UrlUtils.buildFullRequestUrl( request );
@@ -105,7 +106,14 @@
private static String getUrl( HttpServletRequest request, int id, String path )
{
String url = UrlUtils.buildFullRequestUrl( request );
- url = url + "/orgUnits/" + id + "/" + path;
+ 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-03-05 07:46:13 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java 2013-03-06 04:25:38 +0000
@@ -281,7 +281,7 @@
public Patient findPatientByName( @PathVariable int id, @RequestHeader( "name" ) String fullName )
throws NotAllowedException
{
- return activityReportingService.findPatient( fullName );
+ return activityReportingService.findPatient( fullName, id );
}
@RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/orgUnits/{id}/uploadProgramStage" )
@@ -289,8 +289,15 @@
public String saveProgramStage( @PathVariable int id, @RequestBody ProgramStage programStage )
throws NotAllowedException
{
- activityReportingService.saveProgramStage( programStage );
- return PROGRAM_STAGE_UPLOADED;
+ return activityReportingService.saveProgramStage( programStage );
+ }
+
+ @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/orgUnits/{id}/enrollProgram" )
+ @ResponseBody
+ public Patient enrollProgram( @PathVariable int id, @RequestHeader( "enrollInfo" ) String enrollInfo )
+ throws NotAllowedException
+ {
+ return activityReportingService.enrollProgram( enrollInfo, id );
}
// Supportive methods
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/enrollment/programEnrollmentForm.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/enrollment/programEnrollmentForm.vm 2012-10-03 07:23:08 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/enrollment/programEnrollmentForm.vm 2013-03-06 04:25:38 +0000
@@ -4,6 +4,7 @@
<input type="hidden" name="patientId" value="$patientId"/>
<input type="hidden" name="programId" value="$programId"/>
<p style="text-align: left;">
+
<label>$!encoder.htmlEncode( $program.dateOfEnrollmentDescription ) [yyyy-MM-dd] </label>
#if( $validationMap.get( "enrollmentDate" ) )
<br /><span style="color: #990000;"> $i18n.getString($validationMap.get( "enrollmentDate" ))</span>