=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java 2011-02-15 13:45:11 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java 2011-02-16 02:55:58 +0000 @@ -91,6 +91,8 @@ private transient String type; + private Boolean registered; + // ------------------------------------------------------------------------- // Constructors // ------------------------------------------------------------------------- @@ -521,6 +523,16 @@ this.phoneNumber = phoneNumber; } + public Boolean getRegistered() + { + return registered; + } + + public void setRegistered( Boolean registered ) + { + this.registered = registered; + } + public int getLevel() { return level; @@ -550,4 +562,5 @@ { this.type = type; } + } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java 2011-02-02 17:56:01 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java 2011-02-16 02:55:58 +0000 @@ -306,4 +306,8 @@ int getNumberOfOrganisationUnits(); int getMaxOfOrganisationUnitLevels(); + + void updateOrganisationUnits( Collection units ); + + Collection getOrganisationUnits( Boolean registered ); } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitStore.java 2011-02-02 17:56:01 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitStore.java 2011-02-16 02:55:58 +0000 @@ -179,4 +179,8 @@ * @return the maximum number of level. */ int getMaxOfOrganisationUnitLevels(); + + void update( Collection units ); + + Collection get( Boolean registered ); } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java 2011-02-02 17:56:01 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java 2011-02-16 02:55:58 +0000 @@ -593,4 +593,16 @@ { return organisationUnitStore.getMaxOfOrganisationUnitLevels(); } + + @Override + public void updateOrganisationUnits( Collection units ) + { + organisationUnitStore.update( units ); + } + + @Override + public Collection getOrganisationUnits( Boolean registered ) + { + return organisationUnitStore.get(registered); + } } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java 2011-02-02 17:56:01 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java 2011-02-16 02:55:58 +0000 @@ -264,4 +264,32 @@ return jdbcTemplate.queryForInt( sql ); } + + @Override + public void update( Collection units ) + { + String ids = ""; + for ( OrganisationUnit orgunit : units ) + { + ids += orgunit.getId()+", "; + } + ids += "0"; + + final String sqlUpdateTrue = "UPDATE organisationunit SET registered=true WHERE organisationunitid in ( " + ids +" );"; + + jdbcTemplate.execute( sqlUpdateTrue ); + + final String sqlUpdateFalse = "UPDATE organisationunit SET registered=false WHERE organisationunitid not in ( " + ids +" );"; + + jdbcTemplate.execute( sqlUpdateFalse ); + } + + + @SuppressWarnings("unchecked") + public Collection get( Boolean registered ) + { + Criteria criteria = sessionFactory.getCurrentSession().createCriteria( OrganisationUnit.class ); + + return criteria.add( Restrictions.eq( "registered", registered ) ).list(); + } } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnit.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnit.hbm.xml 2011-02-15 13:45:11 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnit.hbm.xml 2011-02-16 02:55:58 +0000 @@ -66,5 +66,9 @@ + + + + === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/DefinePatientOrgnunitRegistrationAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/DefinePatientOrgnunitRegistrationAction.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/patient/DefinePatientOrgnunitRegistrationAction.java 2011-02-16 02:55:58 +0000 @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2004-2010, 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.patient; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.oust.manager.SelectionTreeManager; +import org.hisp.dhis.program.Program; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * @version $Id DefinePatientOrgnunitRegistrationAction.java Jan 7, 2011 + * 11:04:43 AM $ + */ +public class DefinePatientOrgnunitRegistrationAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private SelectionTreeManager selectionTreeManager; + + public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager ) + { + this.selectionTreeManager = selectionTreeManager; + } + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + // ------------------------------------------------------------------------- + // Action + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + Collection orgunits = selectionTreeManager.getReloadedSelectedOrganisationUnits(); + + organisationUnitService.updateOrganisationUnits( orgunits ); + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/GetPatientOrgnunitRegistrationAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/GetPatientOrgnunitRegistrationAction.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/patient/GetPatientOrgnunitRegistrationAction.java 2011-02-16 02:55:58 +0000 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2004-2010, 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.patient; + +import java.util.Collection; + +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.oust.manager.SelectionTreeManager; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * @version $Id GetPatientOrgnunitRegistrationAction.java Jan 7, 2011 12:53:46 + * PM $ + */ +public class GetPatientOrgnunitRegistrationAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private SelectionTreeManager selectionTreeManager; + + public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager ) + { + this.selectionTreeManager = selectionTreeManager; + } + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + // ------------------------------------------------------------------------- + // Action + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + Collection orgunits = organisationUnitService.getOrganisationUnits( true ); + + selectionTreeManager.setSelectedOrganisationUnits( orgunits ); + + return SUCCESS; + } +} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SelectAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SelectAction.java 2009-10-24 11:59:38 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SelectAction.java 2011-02-16 02:55:58 +0000 @@ -27,7 +27,10 @@ package org.hisp.dhis.patient.action.patient; +import java.util.Collection; + import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; import com.opensymphony.xwork2.Action; @@ -52,6 +55,13 @@ this.selectionManager = selectionManager; } + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + // ------------------------------------------------------------------------- // Input/output // ------------------------------------------------------------------------- @@ -63,6 +73,13 @@ return organisationUnit; } + private String message; + + public String getMessage() + { + return message; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -70,10 +87,12 @@ public String execute() throws Exception { + message = ""; + // --------------------------------------------------------------------- // Validate selected OrganisationUnit // --------------------------------------------------------------------- - + organisationUnit = selectionManager.getSelectedOrganisationUnit(); if ( organisationUnit == null ) @@ -81,6 +100,14 @@ return SUCCESS; } + Collection orgunits = organisationUnitService.getOrganisationUnits( true ); + + if ( !orgunits.contains( organisationUnit ) ) + { + message = "can_not_register_patient_for_orgunit"; + return SUCCESS; + } + return PATIENT_FORM; } } === 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 2011-01-25 23:29:58 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2011-02-16 02:55:58 +0000 @@ -360,6 +360,8 @@ class="org.hisp.dhis.patient.action.patient.SelectAction" scope="prototype"> + + + + + + + + + + + 285 ../dhis-web-commons/ouwt/ouwt.js,javascript/patient.js + style/basic.css 285 ../dhis-web-commons/ouwt/ouwt.js,javascript/patient.js + style/basic.css F_PATIENT_ADD + + /main.vm + /dhis-web-maintenance-patient/orgunitRegistration.vm + F_PROGRAM_UPDATE + + + + index.action + F_ORGANISATION_REGISTRATION + + $i18n.getString( "patient_attribute_group" )
  • $i18n.getString( "patient_identifier_type" )
  • $i18n.getString( "relationship_type" )
  • +
  • $i18n.getString( "patient_orgunit_registration" )
  • $i18n.getString( "program" )
  • $i18n.getString( "program_attribute" )
  • $i18n.getString( "case_aggregation_mapping" )
  • === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/orgunitRegistration.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/orgunitRegistration.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/orgunitRegistration.vm 2011-02-16 02:55:58 +0000 @@ -0,0 +1,19 @@ + +

    $i18n.getString( "define_program_associations" )

    + +
    + + + + + + + + + +
    + #organisationUnitSelectionTree( false, true, false ) +
    + + +
    \ 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/patientAndProgramMenu.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAndProgramMenu.vm 2010-12-09 08:20:18 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAndProgramMenu.vm 2011-02-16 02:55:58 +0000 @@ -4,6 +4,7 @@
  • $i18n.getString( "patient_attribute" )
  • $i18n.getString( "patient_attribute_group" )
  • $i18n.getString( "patient_identifier_type" )
  • +
  • $i18n.getString( "patient_orgunit_registration" )
  • $i18n.getString( "relationship_type" )
  • $i18n.getString( "program" )
  • $i18n.getString( "program_attribute" )
  • === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/selectPatient.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/selectPatient.vm 2009-10-16 17:11:16 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/selectPatient.vm 2011-02-16 02:55:58 +0000 @@ -6,9 +6,14 @@ - - - + + + + + + $i18n.getString( $!message ) + +
    === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/style/basic.css' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/style/basic.css 2011-01-11 01:56:03 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/style/basic.css 2011-02-16 02:55:58 +0000 @@ -15,4 +15,9 @@ .heading-column { width : 30.5em;} td.input-column { width : 30.5em;} td.input-column input, td.input-column select { width: 28.5em;} -td.error {padding-left:1em} \ No newline at end of file +td.error {padding-left:1em} + +.warnmessage { + color: red; + font-style: italic; +} \ 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/updatePatientForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientForm.vm 2011-01-20 15:25:13 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientForm.vm 2011-02-16 02:55:58 +0000 @@ -61,9 +61,6 @@ $systemIdentifier   - $i18n.getString( "name" ) * - - @@ -141,7 +138,7 @@ $i18n.getString("is_underage") - +