=== 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 2012-05-23 16:19:55 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java 2012-08-24 10:09:45 +0000 @@ -38,6 +38,12 @@ public class ProgramStage extends BaseIdentifiableObject { + public static final String TYPE_DEFAULT = "default"; + + public static final String TYPE_SECTION = "section"; + + public static final String TYPE_CUSTOM = "custom"; + /** * Determines if a de-serialized file is compatible with this class. */ @@ -55,8 +61,10 @@ private Set programStageDataElements = new HashSet(); + private Set programStageSections = new HashSet(); + private DataEntryForm dataEntryForm; - + private Integer standardInterval; // ------------------------------------------------------------------------- @@ -116,7 +124,7 @@ // ------------------------------------------------------------------------- // Getters and setters // ------------------------------------------------------------------------- - + public DataEntryForm getDataEntryForm() { return dataEntryForm; @@ -132,6 +140,16 @@ return description; } + public Set getProgramStageSections() + { + return programStageSections; + } + + public void setProgramStageSections( Set programStageSections ) + { + this.programStageSections = programStageSections; + } + public Integer getStandardInterval() { return standardInterval; @@ -197,4 +215,18 @@ this.programStageDataElements = programStageDataElements; } + public String getDataEntryType() + { + if ( dataEntryForm != null ) + { + return TYPE_CUSTOM; + } + + if ( programStageSections.size() > 0 ) + { + return TYPE_SECTION; + } + + return TYPE_DEFAULT; + } } === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSection.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSection.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSection.java 2012-08-24 10:09:45 +0000 @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2004-2009, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.program; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +import org.hisp.dhis.common.BaseIdentifiableObject; +import org.hisp.dhis.common.Dxf2Namespace; + +/** + * @author Chau Thu Tran + * + * @version ProgramStageSection.java 11:07:27 AM Aug 22, 2012 $ + */ +@XmlRootElement( name = "ProgramStageSection", namespace = Dxf2Namespace.NAMESPACE ) +@XmlAccessorType( value = XmlAccessType.NONE ) +public class ProgramStageSection + extends BaseIdentifiableObject +{ + private static final long serialVersionUID = 3141607927546197116L; + + private List programStageDataElements = new ArrayList(); + + private int sortOrder; + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + public ProgramStageSection() + { + + } + + public ProgramStageSection( String name, List programStageDataElements ) + { + this.name = name; + this.programStageDataElements = programStageDataElements; + } + + public ProgramStageSection( String name, List programStageDataElements, int sortOrder ) + { + this.name = name; + this.programStageDataElements = programStageDataElements; + this.sortOrder = sortOrder; + } + + // ------------------------------------------------------------------------- + // hashCode, equals and toString + // ------------------------------------------------------------------------- + + @Override + public int hashCode() + { + return name.hashCode(); + } + + @Override + public boolean equals( Object object ) + { + if ( this == object ) + { + return true; + } + + if ( object == null ) + { + return false; + } + + if ( getClass() != object.getClass() ) + { + return false; + } + + final ProgramStageSection other = (ProgramStageSection) object; + + return name.equals( other.getName() ); + } + + @Override + public String toString() + { + return "[" + name + "]"; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + public void setSortOrder( int sortOrder ) + { + this.sortOrder = sortOrder; + } + + public int getSortOrder() + { + return sortOrder; + } + + public List getProgramStageDataElements() + { + return programStageDataElements; + } + + public void setProgramStageDataElements( List programStageDataElements ) + { + this.programStageDataElements = programStageDataElements; + } +} === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSectionService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSectionService.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSectionService.java 2012-08-24 10:09:45 +0000 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2004-2009, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.program; + +import java.util.Collection; + +/** + * @author Chau Thu Tran + * + * @version ProgramStageSectionService.java 11:12:41 AM Aug 22, 2012 $ + */ +public interface ProgramStageSectionService +{ + String ID = ProgramStageSection.class.getName(); + + // ------------------------------------------------------------------------- + // ProgramStageSection + // ------------------------------------------------------------------------- + + int saveProgramStageSection( ProgramStageSection programStageSection ); + + void deleteProgramStageSection( ProgramStageSection programStageSection ); + + void updateProgramStageSection( ProgramStageSection programStageSection ); + + ProgramStageSection getProgramStageSection( int id ); + + ProgramStageSection getProgramStageSectionByName( String name ); + + Collection getAllProgramStageSections(); +} === added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageSectionService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageSectionService.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageSectionService.java 2012-08-24 10:09:45 +0000 @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2004-2009, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.program; + +import java.util.Collection; + +import org.hisp.dhis.common.GenericIdentifiableObjectStore; +import org.springframework.transaction.annotation.Transactional; + +/** + * @author Chau Thu Tran + * + * @version DefaultProgramStageSectionService.java 11:19:35 AM Aug 22, 2012 $ + */ +@Transactional +public class DefaultProgramStageSectionService + implements ProgramStageSectionService +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private GenericIdentifiableObjectStore programStageSectionStore; + + public void setProgramStageSectionStore( + GenericIdentifiableObjectStore programStageSectionStore ) + { + this.programStageSectionStore = programStageSectionStore; + } + + // ------------------------------------------------------------------------- + // ProgramStageSection implementation + // ------------------------------------------------------------------------- + + @Override + public int saveProgramStageSection( ProgramStageSection programStageSection ) + { + return programStageSectionStore.save( programStageSection ); + } + + @Override + public void deleteProgramStageSection( ProgramStageSection programStageSection ) + { + programStageSectionStore.delete( programStageSection ); + } + + @Override + public void updateProgramStageSection( ProgramStageSection programStageSection ) + { + programStageSectionStore.update( programStageSection ); + } + + @Override + public ProgramStageSection getProgramStageSection( int id ) + { + return programStageSectionStore.get( id ); + } + + @Override + public ProgramStageSection getProgramStageSectionByName( String name ) + { + return programStageSectionStore.getByName( name ); + } + + @Override + public Collection getAllProgramStageSections() + { + return programStageSectionStore.getAll(); + } + +} === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2012-08-17 06:42:32 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2012-08-24 10:09:45 +0000 @@ -50,6 +50,11 @@ + + + + + @@ -212,6 +217,10 @@ + + + + === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml' --- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml 2012-05-23 16:19:55 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml 2012-08-24 10:09:45 +0000 @@ -34,5 +34,10 @@ + + + + + === added file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageSection.hbm.xml' --- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageSection.hbm.xml 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageSection.hbm.xml 2012-08-24 10:09:45 +0000 @@ -0,0 +1,29 @@ + +] +> + + + + + + + + + &identifiableProperties; + + + + + + + + + + + + + + === 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 2012-07-10 01:41:49 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java 2012-08-24 10:09:45 +0000 @@ -31,8 +31,10 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.hisp.dhis.caseentry.state.SelectedStateManager; import org.hisp.dhis.dataentryform.DataEntryForm; @@ -42,9 +44,11 @@ import org.hisp.dhis.patientdatavalue.PatientDataValueService; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramDataEntryService; +import org.hisp.dhis.program.ProgramStage; import org.hisp.dhis.program.ProgramStageDataElement; import org.hisp.dhis.program.ProgramStageInstance; import org.hisp.dhis.program.ProgramStageInstanceService; +import org.hisp.dhis.program.ProgramStageSection; import org.hisp.dhis.program.comparator.ProgramStageDataElementSortOrderComparator; import com.opensymphony.xwork2.Action; @@ -89,6 +93,10 @@ private Program program; + private ProgramStage programStage; + + private Set sections = new HashSet(); + // ------------------------------------------------------------------------- // Getters && Setters // ------------------------------------------------------------------------- @@ -103,11 +111,21 @@ this.programStageInstanceId = programStageInstanceId; } + public Set getSections() + { + return sections; + } + public Program getProgram() { return program; } + public ProgramStage getProgramStage() + { + return programStage; + } + public void setSelectedStateManager( SelectedStateManager selectedStateManager ) { this.selectedStateManager = selectedStateManager; @@ -165,13 +183,15 @@ // --------------------------------------------------------------------- // Get program-stage-instance // --------------------------------------------------------------------- - + if ( programStageInstanceId != null ) - { + { programStageInstance = programStageInstanceService.getProgramStageInstance( programStageInstanceId ); - + program = programStageInstance.getProgramStage().getProgram(); - + + programStage = programStageInstance.getProgramStage(); + selectedStateManager.setSelectedProgramStageInstance( programStageInstance ); // --------------------------------------------------------------------- @@ -200,13 +220,18 @@ DataEntryForm dataEntryForm = programStageInstance.getProgramStage().getDataEntryForm(); - if ( dataEntryForm != null ) + if ( programStage.getDataEntryType().equals( ProgramStage.TYPE_CUSTOM ) ) { - Boolean disabled = ( program.getDisplayProvidedOtherFacility()==null)? true : !program.getDisplayProvidedOtherFacility(); - customDataEntryFormCode = programDataEntryService.prepareDataEntryFormForEntry( dataEntryForm - .getHtmlCode(), patientDataValues, disabled.toString(), i18n, + Boolean disabled = (program.getDisplayProvidedOtherFacility() == null) ? true : !program + .getDisplayProvidedOtherFacility(); + customDataEntryFormCode = programDataEntryService.prepareDataEntryFormForEntry( + dataEntryForm.getHtmlCode(), patientDataValues, disabled.toString(), i18n, programStageInstance.getProgramStage(), programStageInstance, organisationUnit ); } + else if ( programStage.getDataEntryType().equals( ProgramStage.TYPE_SECTION ) ) + { + sections = programStage.getProgramStageSections(); + } } return SUCCESS; === added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/customDataEntryForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/customDataEntryForm.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/customDataEntryForm.vm 2012-08-24 10:09:45 +0000 @@ -0,0 +1,3 @@ +
+ $customDataEntryFormCode +
\ No newline at end of file === 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 2012-08-02 13:10:04 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm 2012-08-24 10:09:45 +0000 @@ -30,114 +30,11 @@
#if( $customDataEntryFormCode ) -
- $customDataEntryFormCode -
+ #parse( "/dhis-web-caseentry/customDataEntryForm.vm" ) + #elseif( $sections ) + #parse( "/dhis-web-caseentry/sectionDataEntryForm.vm" ) #else - - - - - - - - - - - #if( $!programStageInstance.programStage.program.isRegistration() == 'true') - - #end - - #set( $dataElementRowCount = 0 ) - #set( $mark = true ) - #set( $tabIndex = 1 ) - #foreach( $programStageDataElement in $programStageDataElements ) - #set( $dataElementRowCount = $dataElementRowCount + 1 ) - #set( $mark = !$mark ) - #set( $patientDataValue = false ) - #set( $key = $programStageDataElement.dataElement.id ) - #set( $patientDataValue = $patientDataValueMap.get( $key ) ) - - ##data element name - - - ##entry - - #if( $!programStageInstance.programStage.program.isRegistration() == 'true' ) - - #end - - #set( $tabIndex = $tabIndex + 1 ) - #end -
$i18n.getString( "data_element" )$i18n.getString( "entry" )$i18n.getString( "provided_elsewhere" )
- - $encoder.htmlEncode( $programStageDataElement.dataElement.formNameFallback ) - #if ( $programStageDataElement.compulsory ) - * - #end - - ##type - - #set( $id = $programStageDataElement.programStage.id + '-' + $programStageDataElement.dataElement.id + '-val' ) - #if( $!programStageDataElement.dataElement.optionSet ) - #set( $hasOptionSet = 'true') - #else - #set( $hasOptionSet = 'false') - #end - #if( $programStageDataElement.dataElement.textType == "longText" ) - - #elseif( $programStageDataElement.dataElement.type == "bool" ) - - #elseif( $programStageDataElement.dataElement.type == "trueOnly" ) - - #elseif( $programStageDataElement.dataElement.type == "date" ) - - - #elseif($hasOptionSet=='true') - - #else - - #end - - #set( $id = $programStageDataElement.programStage.id + '_' + $programStageDataElement.dataElement.id + '_facility' ) - #if( $programStageDataElement.allowProvidedElsewhere == 'true') -
- -
- #end -
+ #parse( "/dhis-web-caseentry/defaultDataEntryForm.vm" ) #end
=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultDataEntryForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultDataEntryForm.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultDataEntryForm.vm 2012-08-24 10:09:45 +0000 @@ -0,0 +1,104 @@ + + + + + + + + + + + #if( $!programStageInstance.programStage.program.isRegistration() == 'true') + + #end + +#set( $dataElementRowCount = 0 ) +#set( $mark = true ) +#set( $tabIndex = 1 ) +#foreach( $programStageDataElement in $programStageDataElements ) + #set( $dataElementRowCount = $dataElementRowCount + 1 ) + #set( $mark = !$mark ) + #set( $patientDataValue = false ) + #set( $key = $programStageDataElement.dataElement.id ) + #set( $patientDataValue = $patientDataValueMap.get( $key ) ) + + ##data element name + + + ##entry + + #if( $!programStageInstance.programStage.program.isRegistration() == 'true' ) + + #end + + #set( $tabIndex = $tabIndex + 1 ) +#end +
$i18n.getString( "data_element" )$i18n.getString( "entry" )$i18n.getString( "provided_elsewhere" )
+ + $encoder.htmlEncode( $programStageDataElement.dataElement.formNameFallback ) + #if ( $programStageDataElement.compulsory ) + * + #end + + ##type + + #set( $id = $programStageDataElement.programStage.id + '-' + $programStageDataElement.dataElement.id + '-val' ) + #if( $!programStageDataElement.dataElement.optionSet ) + #set( $hasOptionSet = 'true') + #else + #set( $hasOptionSet = 'false') + #end + #if( $programStageDataElement.dataElement.textType == "longText" ) + + #elseif( $programStageDataElement.dataElement.type == "bool" ) + + #elseif( $programStageDataElement.dataElement.type == "trueOnly" ) + + #elseif( $programStageDataElement.dataElement.type == "date" ) + + + #elseif($hasOptionSet=='true') + + #else + + #end + + #set( $id = $programStageDataElement.programStage.id + '_' + $programStageDataElement.dataElement.id + '_facility' ) + #if( $programStageDataElement.allowProvidedElsewhere == 'true') +
+ +
+ #end +
=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sectionDataEntryForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sectionDataEntryForm.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sectionDataEntryForm.vm 2012-08-24 10:09:45 +0000 @@ -0,0 +1,121 @@ +#foreach( $section in $sections ) + + + + + + + +
+

$encoder.htmlEncode( $section.name )

+
+
+ + + + + #if( $!programStageInstance.programStage.program.isRegistration() == 'true') + + #end + + + + + + #if( $!programStageInstance.programStage.program.isRegistration() == 'true') + + #end + + #set( $dataElementRowCount = 0 ) + #set( $mark = true ) + #set( $tabIndex = 1 ) + #foreach( $programStageDataElement in $section.programStageDataElements ) + #set( $dataElementRowCount = $dataElementRowCount + 1 ) + #set( $mark = !$mark ) + #set( $patientDataValue = false ) + #set( $key = $programStageDataElement.dataElement.id ) + #set( $patientDataValue = $patientDataValueMap.get( $key ) ) + + ##data element name + + + ##entry + + #if( $!programStageInstance.programStage.program.isRegistration() == 'true' ) + + #end + + #set( $tabIndex = $tabIndex + 1 ) + #end +
$i18n.getString( "data_element" )$i18n.getString( "entry" )$i18n.getString( "provided_elsewhere" )
+ + $encoder.htmlEncode( $programStageDataElement.dataElement.formNameFallback ) + #if ( $programStageDataElement.compulsory ) + * + #end + + ##type + + #set( $id = $programStageDataElement.programStage.id + '-' + $programStageDataElement.dataElement.id + '-val' ) + #if( $!programStageDataElement.dataElement.optionSet ) + #set( $hasOptionSet = 'true') + #else + #set( $hasOptionSet = 'false') + #end + #if( $programStageDataElement.dataElement.textType == "longText" ) + + #elseif( $programStageDataElement.dataElement.type == "bool" ) + + #elseif( $programStageDataElement.dataElement.type == "trueOnly" ) + + #elseif( $programStageDataElement.dataElement.type == "date" ) + + + #elseif($hasOptionSet=='true') + + #else + + #end + + #set( $id = $programStageDataElement.programStage.id + '_' + $programStageDataElement.dataElement.id + '_facility' ) + #if( $programStageDataElement.allowProvidedElsewhere == 'true') +
+ +
+ #end +
+
+
+#end === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java 2012-06-04 16:20:41 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java 2012-08-24 10:09:45 +0000 @@ -117,7 +117,7 @@ { return this.customDataEntryFormCode; } - + private DataEntryForm dataEntryForm; public DataEntryForm getDataEntryForm() @@ -311,8 +311,8 @@ for ( DataElementOperand operand : section.getGreyedFields() ) { - greyedFields.put( operand.getDataElement().getId() + ":" + - operand.getCategoryOptionCombo().getId(), true ); + greyedFields.put( operand.getDataElement().getId() + ":" + operand.getCategoryOptionCombo().getId(), + true ); } } } === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageSectionAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageSectionAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageSectionAction.java 2012-08-24 10:09:45 +0000 @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2004-2009, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.patient.action.programstage; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementService; +import org.hisp.dhis.program.ProgramStage; +import org.hisp.dhis.program.ProgramStageDataElement; +import org.hisp.dhis.program.ProgramStageDataElementService; +import org.hisp.dhis.program.ProgramStageSection; +import org.hisp.dhis.program.ProgramStageService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * + * @version AddProgramStageSectionAction.java 11:29:40 AM Aug 22, 2012 $ + */ +public class AddProgramStageSectionAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramStageService programStageService; + + public void setProgramStageService( ProgramStageService programStageService ) + { + this.programStageService = programStageService; + } + + private DataElementService dataElementService; + + public void setDataElementService( DataElementService dataElementService ) + { + this.dataElementService = dataElementService; + } + + private ProgramStageDataElementService programStageDataElementService; + + public void setProgramStageDataElementService( ProgramStageDataElementService programStageDataElementService ) + { + this.programStageDataElementService = programStageDataElementService; + } + + // ------------------------------------------------------------------------- + // Input/Output + // ------------------------------------------------------------------------- + + private Integer programStageId; + + public Integer getProgramStageId() + { + return programStageId; + } + + public void setProgramStageId( Integer programStageId ) + { + this.programStageId = programStageId; + } + + private String name; + + public void setName( String name ) + { + this.name = name; + } + + private List dataElementIds; + + public void setDataElementIds( List dataElementIds ) + { + this.dataElementIds = dataElementIds; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + ProgramStage programStage = programStageService.getProgramStage( programStageId ); + + // --------------------------------------------------------------------- + // Section + // --------------------------------------------------------------------- + + List psDataElements = new ArrayList(); + for ( Integer id : dataElementIds ) + { + DataElement dataElement = dataElementService.getDataElement( id ); + ProgramStageDataElement psDataElement = programStageDataElementService.get( programStage, dataElement ); + psDataElements.add( psDataElement ); + } + + ProgramStageSection section = new ProgramStageSection( name, psDataElements, programStage + .getProgramStageSections().size() ); + + // --------------------------------------------------------------------- + // Update program stage + // --------------------------------------------------------------------- + + Set sections = programStage.getProgramStageSections(); + if ( sections == null ) + { + sections = new HashSet(); + } + sections.add( section ); + + programStage.setProgramStageSections( sections ); + programStageService.updateProgramStage( programStage ); + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageSectionAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageSectionAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageSectionAction.java 2012-08-24 10:09:45 +0000 @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2004-2009, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.patient.action.programstage; + +import java.util.Collection; + +import org.hisp.dhis.program.ProgramStage; +import org.hisp.dhis.program.ProgramStageDataElement; +import org.hisp.dhis.program.ProgramStageSection; +import org.hisp.dhis.program.ProgramStageSectionService; +import org.hisp.dhis.program.ProgramStageService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * + * @version GetProgramStageSectionAction.java 11:29:40 AM Aug 22, 2012 $ + */ +public class GetProgramStageSectionAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramStageService programStageService; + + public void setProgramStageService( ProgramStageService programStageService ) + { + this.programStageService = programStageService; + } + + private ProgramStageSectionService programStageSectionService; + + public void setProgramStageSectionService( ProgramStageSectionService programStageSectionService ) + { + this.programStageSectionService = programStageSectionService; + } + + // ------------------------------------------------------------------------- + // Input/Output + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + private Integer programStageId; + + public Integer getProgramStageId() + { + return programStageId; + } + + public void setProgramStageId( Integer programStageId ) + { + this.programStageId = programStageId; + } + + private ProgramStageSection section; + + public ProgramStageSection getSection() + { + return section; + } + + private Collection availableDataElements; + + public Collection getAvailableDataElements() + { + return availableDataElements; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + section = programStageSectionService.getProgramStageSection( id ); + + if ( programStageId != null ) + { + ProgramStage programStage = programStageService.getProgramStage( programStageId ); + + availableDataElements = programStage.getProgramStageDataElements(); + + for ( ProgramStageSection section : programStage.getProgramStageSections() ) + { + availableDataElements.removeAll( section.getProgramStageDataElements() ); + } + } + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/RemoveProgramStageSectionAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/RemoveProgramStageSectionAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/RemoveProgramStageSectionAction.java 2012-08-24 10:09:45 +0000 @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2004-2009, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.patient.action.programstage; + +import org.hisp.dhis.program.ProgramStage; +import org.hisp.dhis.program.ProgramStageSection; +import org.hisp.dhis.program.ProgramStageSectionService; +import org.hisp.dhis.program.ProgramStageService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * + * @version AddProgramStageSectionAction.java 11:29:40 AM Aug 22, 2012 $ + */ +public class RemoveProgramStageSectionAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramStageService programStageService; + + public void setProgramStageService( ProgramStageService programStageService ) + { + this.programStageService = programStageService; + } + + private ProgramStageSectionService programStageSectionService; + + public void setProgramStageSectionService( ProgramStageSectionService programStageSectionService ) + { + this.programStageSectionService = programStageSectionService; + } + + // ------------------------------------------------------------------------- + // Input/Output + // ------------------------------------------------------------------------- + + private Integer programStageId; + + public void setProgramStageId( Integer programStageId ) + { + this.programStageId = programStageId; + } + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + ProgramStage programStage = programStageService.getProgramStage( programStageId ); + + ProgramStageSection section = programStageSectionService.getProgramStageSection( id ); + + programStage.getProgramStageSections().remove( section ); + + programStageService.updateProgramStage( programStage ); + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/SaveProgramStageSectionSortOrderAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/SaveProgramStageSectionSortOrderAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/SaveProgramStageSectionSortOrderAction.java 2012-08-24 10:09:45 +0000 @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2004-2009, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.patient.action.programstage; + +import java.util.List; + +import org.hisp.dhis.program.ProgramStageSection; +import org.hisp.dhis.program.ProgramStageSectionService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * @version $Id$ + */ +public class SaveProgramStageSectionSortOrderAction + implements Action +{ + + // ------------------------------------------------------------------------- + // Dependency + // ------------------------------------------------------------------------- + + private ProgramStageSectionService programStageSectionService; + + public void setProgramStageSectionService( ProgramStageSectionService programStageSectionService ) + { + this.programStageSectionService = programStageSectionService; + } + + // ------------------------------------------------------------------------- + // Input/Output + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + public Integer getId() + { + return id; + } + + private List sectionIds; + + public void setSectionIds( List sectionIds ) + { + this.sectionIds = sectionIds; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + { + int index = 0; + for( Integer sectionId : sectionIds ) + { + ProgramStageSection section = programStageSectionService.getProgramStageSection( sectionId ); + section.setSortOrder( index++ ); + programStageSectionService.updateProgramStageSection( section ); + } + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/ShowAddProgramStageSectionAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/ShowAddProgramStageSectionAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/ShowAddProgramStageSectionAction.java 2012-08-24 10:09:45 +0000 @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2004-2009, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.patient.action.programstage; + +import java.util.Collection; + +import org.hisp.dhis.program.ProgramStage; +import org.hisp.dhis.program.ProgramStageDataElement; +import org.hisp.dhis.program.ProgramStageSection; +import org.hisp.dhis.program.ProgramStageService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * + * @version ShowAddProgramStageSectionAction.java 11:29:40 AM Aug 22, 2012 $ + */ +public class ShowAddProgramStageSectionAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramStageService programStageService; + + public void setProgramStageService( ProgramStageService programStageService ) + { + this.programStageService = programStageService; + } + + // ------------------------------------------------------------------------- + // Input/Output + // ------------------------------------------------------------------------- + + private Integer programStageId; + + public Integer getProgramStageId() + { + return programStageId; + } + + public void setProgramStageId( Integer programStageId ) + { + this.programStageId = programStageId; + } + + private ProgramStageSection section; + + public ProgramStageSection getSection() + { + return section; + } + + private Collection availableDataElements; + + public Collection getAvailableDataElements() + { + return availableDataElements; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + ProgramStage programStage = programStageService.getProgramStage( programStageId ); + + availableDataElements = programStage.getProgramStageDataElements(); + + for ( ProgramStageSection section : programStage.getProgramStageSections() ) + { + availableDataElements.removeAll( section.getProgramStageDataElements() ); + } + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageSectionAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageSectionAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageSectionAction.java 2012-08-24 10:09:45 +0000 @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2004-2009, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.patient.action.programstage; + +import java.util.ArrayList; +import java.util.List; + +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementService; +import org.hisp.dhis.program.ProgramStage; +import org.hisp.dhis.program.ProgramStageDataElement; +import org.hisp.dhis.program.ProgramStageDataElementService; +import org.hisp.dhis.program.ProgramStageSection; +import org.hisp.dhis.program.ProgramStageSectionService; +import org.hisp.dhis.program.ProgramStageService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * + * @version UpdateProgramStageSectionAction.java 11:29:40 AM Aug 22, 2012 $ + */ +public class UpdateProgramStageSectionAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramStageService programStageService; + + public void setProgramStageService( ProgramStageService programStageService ) + { + this.programStageService = programStageService; + } + + private ProgramStageSectionService programStageSectionService; + + public void setProgramStageSectionService( ProgramStageSectionService programStageSectionService ) + { + this.programStageSectionService = programStageSectionService; + } + + private DataElementService dataElementService; + + public void setDataElementService( DataElementService dataElementService ) + { + this.dataElementService = dataElementService; + } + + private ProgramStageDataElementService programStageDataElementService; + + public void setProgramStageDataElementService( ProgramStageDataElementService programStageDataElementService ) + { + this.programStageDataElementService = programStageDataElementService; + } + + // ------------------------------------------------------------------------- + // Input/Output + // ------------------------------------------------------------------------- + + private Integer programStageId; + + public Integer getProgramStageId() + { + return programStageId; + } + + public void setProgramStageId( Integer programStageId ) + { + this.programStageId = programStageId; + } + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + private String name; + + public void setName( String name ) + { + this.name = name; + } + + private List dataElementIds; + + public void setDataElementIds( List dataElementIds ) + { + this.dataElementIds = dataElementIds; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + ProgramStage programStage = programStageService.getProgramStage( programStageId ); + + // --------------------------------------------------------------------- + // Section + // --------------------------------------------------------------------- + + ProgramStageSection section = programStageSectionService.getProgramStageSection( id ); + + List psDataElements = new ArrayList(); + for ( Integer id : dataElementIds ) + { + DataElement dataElement = dataElementService.getDataElement( id ); + ProgramStageDataElement psDataElement = programStageDataElementService.get( programStage, dataElement ); + psDataElements.add( psDataElement ); + } + + section.setName( name ); + section.setProgramStageDataElements( psDataElements ); + + programStageSectionService.updateProgramStageSection( section ); + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/ValidateProgramStageSectionAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/ValidateProgramStageSectionAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/ValidateProgramStageSectionAction.java 2012-08-24 10:09:45 +0000 @@ -0,0 +1,112 @@ +package org.hisp.dhis.patient.action.programstage; + +/* + * Copyright (c) 2004-2009, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import org.hisp.dhis.i18n.I18n; +import org.hisp.dhis.program.ProgramStageSection; +import org.hisp.dhis.program.ProgramStageSectionService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * + * @version ValidateProgramStageSectionAction.java 08:20:59 AM Aug 23, 2012 $ + */ + +public class ValidateProgramStageSectionAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependency + // ------------------------------------------------------------------------- + + private ProgramStageSectionService programStageSectionService; + + public void setProgramStageSectionService( ProgramStageSectionService programStageSectionService ) + { + this.programStageSectionService = programStageSectionService; + } + + // ------------------------------------------------------------------------- + // Input/Output + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + private String name; + + public void setName( String name ) + { + this.name = name; + } + + private String message; + + public String getMessage() + { + return message; + } + + private I18n i18n; + + public void setI18n( I18n i18n ) + { + this.i18n = i18n; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + ProgramStageSection match = programStageSectionService.getProgramStageSectionByName( name ); + + if ( match != null && (id == null || match.getId() != id.intValue()) ) + { + message = i18n.getString( "duplicate_names" ); + + return ERROR; + } + + // --------------------------------------------------------------------- + // Validation success + // --------------------------------------------------------------------- + + message = i18n.getString( "everything_is_ok" ); + + return SUCCESS; + } +} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2012-07-30 10:10:18 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2012-08-24 10:09:45 +0000 @@ -278,7 +278,51 @@ scope="prototype"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /dhis-web-maintenance-patient/programStageList.vm javascript/programStage.js + + + + ../dhis-web-commons/ajax/jsonResponseSuccess.vm + + ../dhis-web-commons/ajax/jsonResponseError.vm + + + + + + /main.vm + + /dhis-web-maintenance-patient/programStageSection.vm + javascript/commons.js,javascript/programStageSection.js + style/basic.css + F_PROGRAMSTAGE_SECTION_MANAGEMENT + + + + /main.vm + + /dhis-web-maintenance-patient/addProgramStageSectionForm.vm + javascript/commons.js,javascript/programStageSection.js + style/basic.css + F_PROGRAMSTAGE_SECTION_ADD + + + + programStageSectionList.action?id=${programStageId} + + F_PROGRAMSTAGE_SECTION_ADD + + + + /main.vm + + /dhis-web-maintenance-patient/updateProgramStageSectionForm.vm + javascript/commons.js,javascript/programStageSection.js + style/basic.css + F_PROGRAMSTAGE_SECTION_UPDATE + + + + programStageSectionList.action?id=${programStageId} + + F_PROGRAMSTAGE_SECTION_UPDATE + + + + /dhis-web-maintenance-patient/jsonProgramStageSection.vm + + + + + ../dhis-web-commons/ajax/jsonResponseSuccess.vm + + ../dhis-web-commons/ajax/jsonResponseError.vm + F_PROGRAMSTAGE_SECTION_DELETE + + + + /main.vm + + /dhis-web-maintenance-patient/programStageSectionSortOder.vm + javascript/commons.js,javascript/programStageSection.js + style/basic.css + F_PROGRAMSTAGE_SECTION_MANAGEMENT + + + + programStageSectionList.action?id=${id} + + + +jQuery( document ).ready( function() +{ + validation( 'programStageSectionForm', function(form){ + form.submit(); + }); + checkValueIsExist( "name", "validateProgramStageSection.action"); + byId('name').focus(); +}); + + +

$i18n.getString( "create_new_program_stage_section" )

+ +
+ + + + + + + + + + + + +
$i18n.getString( "program_stage_details" )
+ + + + + + + + + + + + + + + + + + + + + +
$i18n.getString( "available_data_elements" )$i18n.getString( "selected_data_elements" )
+ + +
+
+
+ +
+ + +

+

+
+

+ + +

+ +
+ + \ No newline at end of file === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/images/sections.png' Binary files dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/images/sections.png 1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/images/sections.png 2012-08-24 10:09:45 +0000 differ === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStageSection.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStageSection.js 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStageSection.js 2012-08-24 10:09:45 +0000 @@ -0,0 +1,41 @@ + +function programStageSectionList( programStageId ) +{ + window.location.href = "programStage.action?id=" + programId; +} + +// ----------------------------------------------------------------------------- +// View details +// ----------------------------------------------------------------------------- + +function showSectionDetails( sectionId ) +{ + jQuery.getJSON( 'getProgramStageSection.action', { id: sectionId }, function ( json ) { + setInnerHTML( 'nameField', json.programStageSection.name ); + setInnerHTML( 'dataElementCountField', json.programStageSection.dataElementCount ); + showDetails(); + }); +} + +function removePatientAttribute( programStageId, sectionId, name ) +{ + var result = window.confirm( i18n_confirm_delete ); + if ( result ) + { + jQuery.getJSON( "removeProgramStageSection.action", + { + programStageId:programStageId, + id:sectionId + }, + function( json ) + { + jQuery( "tr#tr" + sectionId ).remove(); + jQuery( "table.listTable tbody tr" ).removeClass( "listRow listAlternateRow" ); + jQuery( "table.listTable tbody tr:odd" ).addClass( "listAlternateRow" ); + jQuery( "table.listTable tbody tr:even" ).addClass( "listRow" ); + jQuery( "table.listTable tbody" ).trigger("update"); + + showSuccessMessage( i18n_delete_success ); + }); + } +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/jsonProgramStageSection.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/jsonProgramStageSection.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/jsonProgramStageSection.vm 2012-08-24 10:09:45 +0000 @@ -0,0 +1,7 @@ +{ "programStageSection": + { + "id": "$!{section.id}", + "name": "$!encoder.jsonEncode( ${section.name} )", + "dataElementCount": "$!{section.programStageDataElements.size()}" + } +} \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageList.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageList.vm 2012-06-13 04:13:23 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageList.vm 2012-08-24 10:09:45 +0000 @@ -4,7 +4,7 @@ - + @@ -26,6 +26,7 @@ $i18n.getString( 'remove' ) #end $i18n.getString( 'show_details' ) + $i18n.getString( 'section_management' )$i18n.getString( 'design_data_entry_form' ) === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageSection.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageSection.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageSection.vm 2012-08-24 10:09:45 +0000 @@ -0,0 +1,58 @@ +

$i18n.getString( "program_stage_section" ) $i18n.getString( "for" ) $programStage.name

+ + + +
$i18n.getString( "name" )
+ + + + + + + + +
+
+
+ +
+ + + + + + + + + + + + #set( $mark = false ) + #foreach( $section in $programStage.programStageSections ) + + + + + #set( $mark = !$mark ) + #end + +
$i18n.getString( "name" )$i18n.getString( "operations" )
$encoder.htmlEncode( $section.name ) + $i18n.getString( 'edit' ) + $i18n.getString( 'remove' ) + $i18n.getString( 'show_details' ) +
+
+ +
+ + + === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageSectionSortOder.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageSectionSortOder.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programStageSectionSortOder.vm 2012-08-24 10:09:45 +0000 @@ -0,0 +1,28 @@ +

$i18n.getString( "program_stage_section_sort_order" ) $i18n.getString( "for" ) $programStage.name

+ +
+ + + + + + + + + + + +
+ + +

+

+
+ + +
+
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageSectionForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageSectionForm.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageSectionForm.vm 2012-08-24 10:09:45 +0000 @@ -0,0 +1,84 @@ + + +

$i18n.getString( "update_program_stage_section" )

+ +
+ + + + + + + + + + + + + +
$i18n.getString( "program_stage_details" )
+ + + + + + + + + + + + + + + + + + + + + +
$i18n.getString( "available_data_elements" )$i18n.getString( "selected_data_elements" )
+ + +
+
+
+ +
+ + +

+

+
+

+ + +

+ +
+ + \ No newline at end of file