dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #22671
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10969: [mobile] update single-event function
------------------------------------------------------------
revno: 10969
committer: Hong Em <em.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-05-24 13:05:04 +0700
message:
[mobile] update single-event function
modified:
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/mobile/service/ActivityReportingServiceImpl.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/ProgramStage.java'
--- 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
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramStage.java 2013-05-24 06:05:04 +0000
@@ -34,21 +34,22 @@
import org.hisp.dhis.api.mobile.model.Model;
- /**
+/**
* @author Nguyen Kim Lai
*/
-public class ProgramStage extends Model
+public class ProgramStage
+ extends Model
{
private String clientVersion;
-
+
private boolean isRepeatable;
-
+
private boolean isCompleted;
-
+
private boolean isSingleEvent;
private List<Section> sections;
-
+
private List<ProgramStageDataElement> dataElements = new ArrayList<ProgramStageDataElement>();
public List<Section> getSections()
@@ -90,7 +91,7 @@
{
this.isRepeatable = isRepeatable;
}
-
+
public boolean isCompleted()
{
return isCompleted;
@@ -119,13 +120,13 @@
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++ )
{
this.dataElements.get( i ).serialize( dout );
}
-
+
dout.writeInt( this.sections.size() );
for ( int i = 0; i < this.sections.size(); i++ )
{
@@ -154,7 +155,7 @@
else
{
}
-
+
int sectionSize = dint.readInt();
if ( sectionSize > 0 )
{
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-05-17 04:15:47 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-05-24 06:05:04 +0000
@@ -104,6 +104,8 @@
private static final String PATIENT_REGISTERED = "patient_registered";
+ private static final String SINGLE_EVENT_UPLOADED = "single_event_uploaded";
+
private ActivityComparator activityComparator = new ActivityComparator();
// -------------------------------------------------------------------------
@@ -478,7 +480,6 @@
// patientMobile = getPatientModel( orgUnitId, patients.get( 0 )
// );
org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patientMobile = getPatientModel( patients.get( 0 ) );
- System.out.println( "patientmobile: " + patientMobile.getPrograms() );
return patientMobile;
}
}
@@ -502,43 +503,44 @@
{
if ( mobileProgramStage.isSingleEvent() )
{
- ProgramStage programStage = programStageService.getProgramStage( mobileProgramStage.getId() );
+ Patient patient = patientService.getPatient( patientId );
+ ProgramStageInstance prStageInstance = programStageInstanceService
+ .getProgramStageInstance( mobileProgramStage.getId() );
+ OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
+ ProgramStage programStage = programStageService.getProgramStage( prStageInstance.getProgramStage().getId() );
+ // ---------------------------------------------------------------------
+ // Add a new program-instance
+ // ---------------------------------------------------------------------
ProgramInstance programInstance = new ProgramInstance();
-
programInstance.setEnrollmentDate( new Date() );
-
programInstance.setDateOfIncident( new Date() );
-
programInstance.setProgram( programStage.getProgram() );
-
programInstance.setStatus( ProgramInstance.STATUS_COMPLETED );
+ programInstance.setPatient( patient );
+
+ patient.getPrograms().add( programStage.getProgram() );
+ patientService.updatePatient( patient );
programInstanceService.addProgramInstance( programInstance );
+ // ---------------------------------------------------------------------
+ // Add a new program-stage-instance
+ // ---------------------------------------------------------------------
+
ProgramStageInstance programStageInstance = new ProgramStageInstance();
-
programStageInstance.setProgramInstance( programInstance );
-
programStageInstance.setProgramStage( programStage );
-
programStageInstance.setDueDate( new Date() );
-
programStageInstance.setExecutionDate( new Date() );
-
+ programStageInstance.setOrganisationUnit( organisationUnit );
programStageInstance.setCompleted( true );
-
- if ( patientId != 0 )
- {
- programStageInstance.setOrganisationUnit( patientService.getPatient( patientId ).getOrganisationUnit() );
- }
- else
- {
- programStageInstance.setOrganisationUnit( orgUnitService.getOrganisationUnit( orgUnitId ) );
- }
-
programStageInstanceService.addProgramStageInstance( programStageInstance );
+ // ---------------------------------------------------------------------
+ // Save value
+ // ---------------------------------------------------------------------
+
List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement> dataElements = mobileProgramStage
.getDataElements();
@@ -546,13 +548,18 @@
{
DataElement dataElement = dataElementService.getDataElement( dataElements.get( i ).getId() );
- PatientDataValue patientDataValue = new PatientDataValue( programStageInstance, dataElement,
- new Date(), dataElements.get( i ).getValue() );
+ PatientDataValue patientDataValue = new PatientDataValue();
+ patientDataValue.setDataElement( dataElement );
+ patientDataValue.setValue( dataElements.get( i ).getValue() );
+ patientDataValue.setProgramStageInstance( programStageInstance );
+ patientDataValue.setTimestamp( new Date() );
patientDataValueService.savePatientDataValue( patientDataValue );
+
}
- return ANONYMOUS_PROGRAM_UPLOADED;
+ return SINGLE_EVENT_UPLOADED;
+
}
else
{