dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24469
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11995: fix bug for mujhu database - program stage instance is null
------------------------------------------------------------
revno: 11995
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-09-10 00:13:07 +0700
message:
fix bug for mujhu database - program stage instance is null
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 2013-09-09 12:57:33 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-09-09 17:13:07 +0000
@@ -954,7 +954,7 @@
mobileProgramList.add( getMobileProgram( patient, each ) );
}
}
-
+
patientModel.setPrograms( mobileProgramList );
/*
* List<Integer> mobileProgramIDList = new ArrayList<Integer>(); for (
@@ -1060,75 +1060,78 @@
private List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage> getMobileProgramStages( Patient patient,
ProgramInstance programInstance )
{
-
List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage> mobileProgramStages = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage>();
for ( ProgramStage eachProgramStage : programInstance.getProgram().getProgramStages() )
{
ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance(
programInstance, eachProgramStage );
- org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage mobileProgramStage = new org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage();
- List<org.hisp.dhis.api.mobile.model.LWUITmodel.Section> mobileSections = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.Section>();
- mobileProgramStage.setId( programStageInstance.getId() );
- mobileProgramStage.setName( eachProgramStage.getName() );
-
- // get report date
- if ( programStageInstance.getExecutionDate() != null )
- {
- mobileProgramStage.setReportDate( PeriodUtil.dateToString( programStageInstance.getExecutionDate() ) );
- }
- else
- {
- mobileProgramStage.setReportDate( "" );
- }
-
- if ( programStageInstance.getProgramStage().getReportDateDescription() == null )
- {
- mobileProgramStage.setReportDateDescription( "Report Date" );
- }
- else
- {
- mobileProgramStage.setReportDateDescription( programStageInstance.getProgramStage()
- .getReportDateDescription() );
- }
-
- // is repeatable
- mobileProgramStage.setRepeatable( eachProgramStage.getIrregular() );
-
- // is completed
- mobileProgramStage.setCompleted( checkIfProgramStageCompleted( patient, programInstance.getProgram(),
- eachProgramStage ) );
-
- // is single event
- mobileProgramStage.setSingleEvent( programInstance.getProgram().isSingleEvent() );
-
- // Set all data elements
- mobileProgramStage.setDataElements( getDataElementsForMobile( eachProgramStage, programStageInstance ) );
-
- // Set all program sections
- if ( eachProgramStage.getProgramStageSections().size() > 0 )
- {
- for ( ProgramStageSection eachSection : eachProgramStage.getProgramStageSections() )
- {
- org.hisp.dhis.api.mobile.model.LWUITmodel.Section mobileSection = new org.hisp.dhis.api.mobile.model.LWUITmodel.Section();
- mobileSection.setId( eachSection.getId() );
- mobileSection.setName( eachSection.getName() );
-
- // Set all data elements' id, then we could have full from
- // data element list of program stage
- List<Integer> dataElementIds = new ArrayList<Integer>();
- for ( ProgramStageDataElement eachPogramStageDataElement : eachSection
- .getProgramStageDataElements() )
+
+ //only for Mujhu database, because there is null program stage instance. This condition should be removed in the future
+ if( programStageInstance != null )
+ {
+ org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage mobileProgramStage = new org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage();
+ List<org.hisp.dhis.api.mobile.model.LWUITmodel.Section> mobileSections = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.Section>();
+ mobileProgramStage.setId( programStageInstance.getId() );
+ mobileProgramStage.setName( eachProgramStage.getName() );
+
+ // get report date
+ if ( programStageInstance.getExecutionDate() != null )
+ {
+ mobileProgramStage.setReportDate( PeriodUtil.dateToString( programStageInstance.getExecutionDate() ) );
+ }
+ else
+ {
+ mobileProgramStage.setReportDate( "" );
+ }
+
+ if ( programStageInstance.getProgramStage().getReportDateDescription() == null )
+ {
+ mobileProgramStage.setReportDateDescription( "Report Date" );
+ }
+ else
+ {
+ mobileProgramStage.setReportDateDescription( programStageInstance.getProgramStage()
+ .getReportDateDescription() );
+ }
+
+ // is repeatable
+ mobileProgramStage.setRepeatable( eachProgramStage.getIrregular() );
+
+ // is completed
+ mobileProgramStage.setCompleted( checkIfProgramStageCompleted( patient, programInstance.getProgram(),
+ eachProgramStage ) );
+
+ // is single event
+ mobileProgramStage.setSingleEvent( programInstance.getProgram().isSingleEvent() );
+
+ // Set all data elements
+ mobileProgramStage.setDataElements( getDataElementsForMobile( eachProgramStage, programStageInstance ) );
+
+ // Set all program sections
+ if ( eachProgramStage.getProgramStageSections().size() > 0 )
+ {
+ for ( ProgramStageSection eachSection : eachProgramStage.getProgramStageSections() )
{
- dataElementIds.add( eachPogramStageDataElement.getDataElement().getId() );
+ org.hisp.dhis.api.mobile.model.LWUITmodel.Section mobileSection = new org.hisp.dhis.api.mobile.model.LWUITmodel.Section();
+ mobileSection.setId( eachSection.getId() );
+ mobileSection.setName( eachSection.getName() );
+
+ // Set all data elements' id, then we could have full from
+ // data element list of program stage
+ List<Integer> dataElementIds = new ArrayList<Integer>();
+ for ( ProgramStageDataElement eachPogramStageDataElement : eachSection
+ .getProgramStageDataElements() )
+ {
+ dataElementIds.add( eachPogramStageDataElement.getDataElement().getId() );
+ }
+ mobileSection.setDataElementIds( dataElementIds );
+ mobileSections.add( mobileSection );
}
- mobileSection.setDataElementIds( dataElementIds );
- mobileSections.add( mobileSection );
}
+ mobileProgramStage.setSections( mobileSections );
+
+ mobileProgramStages.add( mobileProgramStage );
}
- mobileProgramStage.setSections( mobileSections );
-
- mobileProgramStages.add( mobileProgramStage );
-
}
return mobileProgramStages;
}