dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #30253
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15351: clean up & bug fix for offline tracked entity data entry
------------------------------------------------------------
revno: 15351
committer: Long <long.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2014-05-22 15:57:05 +0700
message:
clean up & bug fix for offline tracked entity data entry
modified:
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/mobile/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2014-05-22 08:23:41 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2014-05-22 08:57:05 +0000
@@ -420,6 +420,7 @@
// ---------------------------------------------------------------------
// Add a new program-instance
+ //
// ---------------------------------------------------------------------
ProgramInstance programInstance = new ProgramInstance();
programInstance.setEnrollmentDate( new Date() );
@@ -432,6 +433,7 @@
// ---------------------------------------------------------------------
// Add a new program-stage-instance
+ //
// ---------------------------------------------------------------------
ProgramStageInstance programStageInstance = new ProgramStageInstance();
@@ -445,6 +447,7 @@
// ---------------------------------------------------------------------
// Save value
+ //
// ---------------------------------------------------------------------
List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement> dataElements = mobileProgramStage
@@ -486,27 +489,31 @@
{
DataElement dataElement = dataElementService.getDataElement( dataElements.get( i ).getId() );
String value = dataElements.get( i ).getValue();
-
- if ( dataElement.getType().equalsIgnoreCase( "date" ) && !value.trim().equals( "" ) )
- {
- value = PeriodUtil.convertDateFormat( value );
- }
-
- TrackedEntityDataValue previousPatientDataValue = dataValueService.getTrackedEntityDataValue(
- programStageInstance, dataElement );
-
- if ( previousPatientDataValue == null )
- {
- TrackedEntityDataValue patientDataValue = new TrackedEntityDataValue( programStageInstance,
- dataElement, new Date(), value );
- dataValueService.saveTrackedEntityDataValue( patientDataValue );
- }
- else
- {
- previousPatientDataValue.setValue( value );
- previousPatientDataValue.setTimestamp( new Date() );
- previousPatientDataValue.setProvidedElsewhere( false );
- dataValueService.updateTrackedEntityDataValue( previousPatientDataValue );
+ if ( value != null )
+ {
+
+ if ( dataElement.getType().equalsIgnoreCase( "date" ) && !value.trim().equals( "" ) )
+ {
+ value = PeriodUtil.convertDateFormat( value );
+ }
+
+ TrackedEntityDataValue previousPatientDataValue = dataValueService.getTrackedEntityDataValue(
+ programStageInstance, dataElement );
+
+ if ( previousPatientDataValue == null )
+ {
+ TrackedEntityDataValue patientDataValue = new TrackedEntityDataValue( programStageInstance,
+ dataElement, new Date(), value );
+ dataValueService.saveTrackedEntityDataValue( patientDataValue );
+ }
+ else
+ {
+ previousPatientDataValue.setValue( value );
+ previousPatientDataValue.setTimestamp( new Date() );
+ previousPatientDataValue.setProvidedElsewhere( false );
+ dataValueService.updateTrackedEntityDataValue( previousPatientDataValue );
+ }
+
}
}
@@ -528,29 +535,18 @@
else
{
programStageInstance.setCompleted( mobileProgramStage.isCompleted() );
-
- // check if any compulsory value is null
- for ( int i = 0; i < dataElements.size(); i++ )
- {
- if ( dataElements.get( i ).isCompulsory() == true )
- {
- if ( dataElements.get( i ).getValue() == null )
- {
- 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.setStatus( ProgramInstance.STATUS_COMPLETED );
programInstanceService.updateProgramInstance( programInstance );
}
+
if ( mobileProgramStage.isRepeatable() )
{
Date nextDate = DateUtils.getDateAfterAddition( new Date(),
@@ -572,6 +568,10 @@
Collection<ProgramStageInstance> programStageInstances = programInstance.getProgramStageInstances();
if ( programStageInstances != null )
{
+ if ( programStageInstances.size() < programInstance.getProgram().getProgramStages().size() )
+ {
+ return false;
+ }
Iterator<ProgramStageInstance> iterator = programStageInstances.iterator();
while ( iterator.hasNext() )
@@ -654,7 +654,6 @@
entityInstanceService.updateTrackedEntityInstance( patient );
patient = entityInstanceService.getTrackedEntityInstance( patientId );
-
return getPatientModel( patient );
}
@@ -1391,7 +1390,6 @@
throws NotAllowedException
{
TrackedEntityInstance patientWeb = new TrackedEntityInstance();
-
patientWeb.setOrganisationUnit( organisationUnitService.getOrganisationUnit( orgUnitId ) );
Set<TrackedEntityAttribute> patientAttributeSet = new HashSet<TrackedEntityAttribute>();