=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java 2014-07-12 21:07:29 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java 2014-07-29 17:14:27 +0000 @@ -34,6 +34,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; + import org.hisp.dhis.common.BaseIdentifiableObject; import org.hisp.dhis.common.DxfNamespaces; import org.hisp.dhis.common.IdentifiableObject; @@ -43,7 +44,9 @@ import org.hisp.dhis.dataentryform.DataEntryForm; import org.hisp.dhis.trackedentity.TrackedEntityInstanceReminder; +import java.util.ArrayList; import java.util.HashSet; +import java.util.List; import java.util.Set; /** @@ -72,7 +75,9 @@ private Program program; - private Set programStageDataElements = new HashSet<>(); + private Set programStageDataElements = new HashSet(); + + private List programIndicators = new ArrayList(); @Scanned private Set programStageSections = new HashSet<>(); @@ -419,6 +424,20 @@ this.reportDateToUse = reportDateToUse; } + @JsonProperty + @JsonView( { DetailedView.class, ExportView.class } ) + @JacksonXmlElementWrapper( localName = "programIndicators", namespace = DxfNamespaces.DXF_2_0 ) + @JacksonXmlProperty( localName = "programIndicator", namespace = DxfNamespaces.DXF_2_0 ) + public List getProgramIndicators() + { + return programIndicators; + } + + public void setProgramIndicators( List programIndicators ) + { + this.programIndicators = programIndicators; + } + @Override public void mergeWith( IdentifiableObject other ) { === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml' --- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml 2014-06-12 09:41:31 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml 2014-07-29 17:14:27 +0000 @@ -70,6 +70,12 @@ + + + + + + === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java 2014-07-29 17:14:27 +0000 @@ -310,7 +310,7 @@ // --------------------------------------------------------------------- // Get program indicators // --------------------------------------------------------------------- - + programIndicatorsMap.putAll( programIndicatorService.getProgramIndicatorValues( programStageInstance .getProgramInstance() ) ); === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm 2014-07-08 06:30:54 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm 2014-07-29 17:14:27 +0000 @@ -50,16 +50,16 @@ #end - #foreach($key in $programIndicatorsMap.keySet()) + #foreach( $indicator in $programStage.programIndicators ) - $key: $programIndicatorsMap.get($key) + $indicator.displayName + $encoder.htmlEncode( $programIndicatorsMap.get($indicator.displayName) ) #end -
- + #if( $customDataEntryFormCode ) #parse( "/dhis-web-caseentry/customDataEntryForm.vm" ) #elseif( $sections && $sections.size() > 0 ) === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/GetProgramAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/GetProgramAction.java 2014-05-14 15:14:18 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/GetProgramAction.java 2014-07-29 17:14:27 +0000 @@ -29,15 +29,20 @@ */ import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; import org.hisp.dhis.organisationunit.OrganisationUnitGroup; import org.hisp.dhis.organisationunit.OrganisationUnitLevel; import org.hisp.dhis.oust.manager.SelectionTreeManager; import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramIndicator; +import org.hisp.dhis.program.ProgramIndicatorService; import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.user.UserGroup; import org.hisp.dhis.user.UserGroupService; +import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; @@ -73,6 +78,9 @@ this.userGroupService = userGroupService; } + @Autowired + private ProgramIndicatorService programIndicatorService; + // ------------------------------------------------------------------------- // Input/Output // ------------------------------------------------------------------------- @@ -129,6 +137,13 @@ return userGroups; } + private List programIndicators; + + public List getProgramIndicators() + { + return programIndicators; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -141,7 +156,11 @@ selectionTreeManager.setSelectedOrganisationUnits( program.getOrganisationUnits() ); userGroups = new ArrayList( userGroupService.getAllUserGroups() ); - + + programIndicators = new ArrayList( programIndicatorService.getProgramIndicators( program ) ); + + Collections.sort( programIndicators, IdentifiableObjectNameComparator.INSTANCE ); + return SUCCESS; } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/AddProgramStageAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/AddProgramStageAction.java 2014-07-27 12:49:21 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/AddProgramStageAction.java 2014-07-29 17:14:27 +0000 @@ -37,6 +37,8 @@ import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramIndicator; +import org.hisp.dhis.program.ProgramIndicatorService; import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.program.ProgramStage; import org.hisp.dhis.program.ProgramStageDataElement; @@ -46,6 +48,7 @@ import org.hisp.dhis.trackedentity.TrackedEntityInstanceReminder; import org.hisp.dhis.user.UserGroup; import org.hisp.dhis.user.UserGroupService; +import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; @@ -96,6 +99,9 @@ this.userGroupService = userGroupService; } + @Autowired + private ProgramIndicatorService programIndicatorService; + // ------------------------------------------------------------------------- // Input/Output // ------------------------------------------------------------------------- @@ -308,6 +314,13 @@ this.reportDateToUse = reportDateToUse; } + private List selectedIndicators = new ArrayList(); + + public void setSelectedIndicators( List selectedIndicators ) + { + this.selectedIndicators = selectedIndicators; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -356,13 +369,26 @@ programStage.setOpenAfterEnrollment( openAfterEnrollment ); programStage.setReportDateToUse( reportDateToUse ); + // Program indicators + + List programIndicators = new ArrayList(); + for ( Integer id : selectedIndicators ) + { + ProgramIndicator indicator = programIndicatorService.getProgramIndicator( id ); + programIndicators.add( indicator ); + } + programStage.setProgramIndicators( programIndicators ); + + + // SMS Reminder + Set reminders = new HashSet(); for ( int i = 0; i < daysAllowedSendMessages.size(); i++ ) { - TrackedEntityInstanceReminder reminder = new TrackedEntityInstanceReminder( "", daysAllowedSendMessages.get( i ), - templateMessages.get( i ) ); + TrackedEntityInstanceReminder reminder = new TrackedEntityInstanceReminder( "", + daysAllowedSendMessages.get( i ), templateMessages.get( i ) ); reminder.setDateToCompare( TrackedEntityInstanceReminder.DUE_DATE_TO_COMPARE ); - reminder.setName(program.getName() + "-" + name + "-" + i); + reminder.setName( program.getName() + "-" + name + "-" + i ); reminder.setSendTo( sendTo.get( i ) ); reminder.setWhenToSend( whenToSend.get( i ) ); reminder.setMessageType( messageType.get( i ) ); @@ -379,14 +405,17 @@ } programStage.setReminders( reminders ); program.getProgramStages().add( programStage ); + programStageService.saveProgramStage( programStage ); List programStages = new ArrayList( program.getProgramStages() ); Collections.sort( programStages, new ProgramStageMinDaysComparator() ); program.getProgramStages().clear(); - program.setProgramStages(programStages); + program.setProgramStages( programStages ); programService.updateProgram( program ); - + + // Data elements + for ( int i = 0; i < this.selectedDataElementsValidator.size(); i++ ) { DataElement dataElement = dataElementService.getDataElement( selectedDataElementsValidator.get( i ) ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/GetProgramStageAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/GetProgramStageAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/GetProgramStageAction.java 2014-07-29 17:14:27 +0000 @@ -32,11 +32,14 @@ import java.util.Collection; import java.util.List; +import org.hisp.dhis.program.ProgramIndicator; +import org.hisp.dhis.program.ProgramIndicatorService; import org.hisp.dhis.program.ProgramStage; import org.hisp.dhis.program.ProgramStageDataElement; import org.hisp.dhis.program.ProgramStageService; import org.hisp.dhis.user.UserGroup; import org.hisp.dhis.user.UserGroupService; +import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; @@ -66,6 +69,9 @@ this.userGroupService = userGroupService; } + @Autowired + private ProgramIndicatorService programIndicatorService; + // ------------------------------------------------------------------------- // Input/Output // ------------------------------------------------------------------------- @@ -107,6 +113,13 @@ { this.userGroups = userGroups; } + + private List programIndicators; + + public List getProgramIndicators() + { + return programIndicators; + } // ------------------------------------------------------------------------- // Action implementation @@ -120,7 +133,10 @@ programStageDataElements = programStage.getProgramStageDataElements(); userGroups = new ArrayList( userGroupService.getAllUserGroups() ); - + + programIndicators = new ArrayList( programIndicatorService.getProgramIndicators( programStage.getProgram() ) ); + programIndicators.removeAll( programStage.getProgramIndicators() ); + return SUCCESS; } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/RemoveProgramStageAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/RemoveProgramStageAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/RemoveProgramStageAction.java 2014-07-29 17:14:27 +0000 @@ -28,9 +28,18 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import org.hisp.dhis.common.DeleteNotAllowedException; import org.hisp.dhis.i18n.I18n; +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramService; +import org.hisp.dhis.program.ProgramStage; import org.hisp.dhis.program.ProgramStageService; +import org.hisp.dhis.program.comparator.ProgramStageMinDaysComparator; +import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; @@ -52,6 +61,9 @@ { this.programStageService = programStageService; } + + @Autowired + private ProgramService programService; // ------------------------------------------------------------------------- // Input/Output @@ -91,7 +103,15 @@ { try { - programStageService.deleteProgramStage( programStageService.getProgramStage( id ) ); + ProgramStage programStage = programStageService.getProgramStage( id ); + Program program = programStage.getProgram(); + program.getProgramStages().remove( programStage ); + programStageService.deleteProgramStage( programStage ); + + List programStages = new ArrayList( program.getProgramStages() ); + Collections.sort( programStages, new ProgramStageMinDaysComparator() ); + program.setProgramStages( programStages ); + programService.updateProgram( program ); } catch ( DeleteNotAllowedException ex ) { === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/UpdateProgramStageAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/UpdateProgramStageAction.java 2014-07-27 12:49:21 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/UpdateProgramStageAction.java 2014-07-29 17:14:27 +0000 @@ -37,6 +37,8 @@ import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramIndicator; +import org.hisp.dhis.program.ProgramIndicatorService; import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.program.ProgramStage; import org.hisp.dhis.program.ProgramStageDataElement; @@ -306,7 +308,17 @@ { this.reportDateToUse = reportDateToUse; } - + + private List selectedIndicators = new ArrayList(); + + public void setSelectedIndicators( List selectedIndicators ) + { + this.selectedIndicators = selectedIndicators; + } + + @Autowired + private ProgramIndicatorService programIndicatorService; + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -356,7 +368,18 @@ programStage.setValidCompleteOnly( validCompleteOnly ); programStage.setCaptureCoordinates( captureCoordinates ); + // Program indicators + + List programIndicators = new ArrayList(); + for ( Integer id : selectedIndicators ) + { + ProgramIndicator indicator = programIndicatorService.getProgramIndicator( id ); + programIndicators.add( indicator ); + } + programStage.setProgramIndicators( programIndicators ); + // SMS Reminder + programStage.getReminders().clear(); Set reminders = new HashSet(); for ( int i = 0; i < this.daysAllowedSendMessages.size(); i++ ) @@ -380,7 +403,6 @@ reminders.add( reminder ); } programStage.setReminders( reminders ); - programStageService.updateProgramStage( programStage ); Program program = programStage.getProgram(); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties 2014-07-02 12:11:16 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties 2014-07-29 17:14:27 +0000 @@ -496,4 +496,7 @@ hide_advanced_options = Hide advanced options tracked_entity_registration_form_manegement = Tracked entity registration form management program_validation_rule_management=Program validation rule management -confidential = Confidential \ No newline at end of file +confidential = Confidential +available_indicators = Available indicators +selected_indicators = Selected indicators +program_indicator_management_form = Program indicator management form \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramStageForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramStageForm.vm 2014-07-27 15:02:58 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramStageForm.vm 2014-07-29 17:14:27 +0000 @@ -208,6 +208,42 @@ + + + + + + + + + + + + + + + + + + +
$i18n.getString( "available_indicators" )$i18n.getString( "filter" )$i18n.getString( "selected_indicators" )
+ + +
+
+
+ +
+ + + $i18n.getString( 'move_up' )

+ $i18n.getString( 'move_up' ) +
+

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addProgramStageForm.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addProgramStageForm.js 2014-06-21 09:56:19 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addProgramStageForm.js 2014-07-29 17:14:27 +0000 @@ -4,6 +4,8 @@ validation( 'addProgramStageForm', function( form ){ form.submit(); }, function(){ + selectAllById('selectedIndicators'); + var selectedDataElementsValidator = jQuery( "#selectedDataElementsValidator" ); selectedDataElementsValidator.empty(); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateProgramStageForm.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateProgramStageForm.js 2014-06-21 09:56:19 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateProgramStageForm.js 2014-07-29 17:14:27 +0000 @@ -5,6 +5,8 @@ validation( 'updateProgramStageForm', function( form ){ form.submit(); }, function(){ + selectAllById('selectedIndicators'); + var selectedDataElementsValidator = jQuery( "#selectedDataElementsValidator" ); selectedDataElementsValidator.empty(); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramStageForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramStageForm.vm 2014-07-28 09:24:17 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramStageForm.vm 2014-07-29 17:14:27 +0000 @@ -235,6 +235,47 @@ + + + + + + + + + + + + + + + + + + + +
$i18n.getString( "available_indicators" )$i18n.getString( "filter" )$i18n.getString( "selected_indicators" )
+ + +
+
+
+ +
+ + + $i18n.getString( 'move_up' )

+ $i18n.getString( 'move_up' ) +
+