← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12814: Remove unused files, user only one class for add new patient.

 

------------------------------------------------------------
revno: 12814
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-10-25 12:00:41 +0700
message:
  Remove unused files, user only one class for add new patient.
removed:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddRelationshipPatientAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddRelationshipPatientAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidateAddRelationshipPatientAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipPatientForm.vm
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientIdentifierAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addPatientForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipForm.vm
  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/javascript/commons.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/relationshipPatient.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/relationshipList.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sectionDataEntryForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowAddProgramFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowUpdateProgramFormAction.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierService.java	2013-09-27 17:04:23 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierService.java	2013-10-25 05:00:41 +0000
@@ -30,10 +30,6 @@
 
 import java.util.Collection;
 
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.program.Program;
-
 /**
  * @author Abyot Asalefew Gizaw
  * @version $Id$
@@ -76,7 +72,5 @@
 
     Collection<PatientIdentifier> getPatientIdentifiers( Collection<PatientIdentifierType> identifierTypes,
         Patient patient );
-
-    boolean checkDuplicateIdentifier( PatientIdentifierType patientIdentifierType, String identifier,
-        Integer patientId, OrganisationUnit organisationUnit, Program program, PeriodType periodType );
+    
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierStore.java	2013-09-27 17:04:23 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientIdentifierStore.java	2013-10-25 05:00:41 +0000
@@ -28,12 +28,10 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.Collection;
+
 import org.hisp.dhis.common.GenericIdentifiableObjectStore;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.program.Program;
-
-import java.util.Collection;
 
 /**
  * @author Abyot Asalefew Gizaw
@@ -74,7 +72,4 @@
 
     Collection<PatientIdentifier> get( Collection<PatientIdentifierType> identifierTypes, Patient patient );
 
-    boolean checkDuplicateIdentifier( PatientIdentifierType patientIdentifierType, String identifier,
-        Integer patientId, OrganisationUnit organisationUnit, Program program, PeriodType periodType );
-
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierService.java	2013-09-27 17:04:23 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierService.java	2013-10-25 05:00:41 +0000
@@ -28,13 +28,10 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.program.Program;
+import java.util.Collection;
+
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.Collection;
-
 /**
  * @author Abyot Asalefew Gizaw
  * @version $Id$
@@ -143,12 +140,5 @@
     {
         return patientIdentifierStore.get( identifierTypes, patient );
     }
-
-    @Override
-    public boolean checkDuplicateIdentifier( PatientIdentifierType patientIdentifierType, String identifier,
-        Integer patientId, OrganisationUnit organisationUnit, Program program, PeriodType periodType )
-    {
-        return patientIdentifierStore.checkDuplicateIdentifier( patientIdentifierType, identifier, patientId, organisationUnit,
-            program, periodType );
-    }
+    
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java	2013-10-14 11:20:58 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java	2013-10-25 05:00:41 +0000
@@ -152,37 +152,4 @@
         return getCriteria( Restrictions.in( "identifierType", identifierTypes ), Restrictions.eq( "patient", patient ) )
             .list();
     }
-
-    public boolean checkDuplicateIdentifier( PatientIdentifierType patientIdentifierType, String identifier,
-        Integer patientId, OrganisationUnit organisationUnit, Program program, PeriodType periodType )
-    {
-        String sql = "select count(*) from patientidentifier pi inner join patient p on pi.patientid=p.patientid "
-            + "inner join programinstance pis on pis.patientid=pi.patientid where pi.patientidentifiertypeid="
-            + patientIdentifierType.getId() + " and pi.identifier='" + identifier + "' ";
-
-        if ( patientId != null )
-        {
-            sql += " and pi.patientid!=" + patientId;
-        }
-
-        if ( patientIdentifierType.getType().equals( PatientIdentifierType.VALUE_TYPE_LOCAL_ID ) && organisationUnit != null )
-        {
-            sql += " and p.organisationunitid=" + organisationUnit.getId();
-        }
-
-        if ( patientIdentifierType.getType().equals( PatientIdentifierType.VALUE_TYPE_LOCAL_ID ) && program != null )
-        {
-            sql += " and pis.programid=" + program.getId();
-        }
-
-        if ( patientIdentifierType.getType().equals( PatientIdentifierType.VALUE_TYPE_LOCAL_ID ) && periodType != null )
-        {
-            Date currentDate = new Date();
-            Period period = periodType.createPeriod( currentDate );
-            sql += " and pis.enrollmentdate >='" + period.getStartDateString() + "' and pis.enrollmentdate <='"
-                + DateUtils.getMediumDateString( period.getEndDate() ) + "'";
-        }
-
-        return jdbcTemplate.queryForObject( sql, Integer.class ) == 0 ? false : true;
-    }
 }

=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddRelationshipPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddRelationshipPatientAction.java	2013-10-24 08:31:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddRelationshipPatientAction.java	1970-01-01 00:00:00 +0000
@@ -1,484 +0,0 @@
-package org.hisp.dhis.caseentry.action.patient;
-
-/*
- * Copyright (c) 2004-2013, 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 java.util.Collection;
-import java.util.Date;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.math.NumberUtils;
-import org.apache.struts2.ServletActionContext;
-import org.hisp.dhis.i18n.I18nFormat;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
-import org.hisp.dhis.patient.Patient;
-import org.hisp.dhis.patient.PatientAttribute;
-import org.hisp.dhis.patient.PatientAttributeOption;
-import org.hisp.dhis.patient.PatientAttributeOptionService;
-import org.hisp.dhis.patient.PatientAttributeService;
-import org.hisp.dhis.patient.PatientIdentifier;
-import org.hisp.dhis.patient.PatientIdentifierService;
-import org.hisp.dhis.patient.PatientIdentifierType;
-import org.hisp.dhis.patient.PatientIdentifierTypeService;
-import org.hisp.dhis.patient.PatientService;
-import org.hisp.dhis.patient.util.PatientIdentifierGenerator;
-import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
-import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
-import org.hisp.dhis.relationship.Relationship;
-import org.hisp.dhis.relationship.RelationshipService;
-import org.hisp.dhis.relationship.RelationshipType;
-import org.hisp.dhis.relationship.RelationshipTypeService;
-import org.hisp.dhis.setting.SystemSettingManager;
-import org.hisp.dhis.user.UserService;
-
-import com.opensymphony.xwork2.Action;
-
-public class AddRelationshipPatientAction
-    implements Action
-{
-    public static final String PREFIX_ATTRIBUTE = "attr";
-
-    public static final String PREFIX_IDENTIFIER = "iden";
-
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private I18nFormat format;
-
-    private PatientService patientService;
-
-    private PatientIdentifierService patientIdentifierService;
-
-    private PatientIdentifierTypeService patientIdentifierTypeService;
-
-    private OrganisationUnitSelectionManager selectionManager;
-
-    private PatientAttributeService patientAttributeService;
-
-    private PatientAttributeValueService patientAttributeValueService;
-
-    private PatientAttributeOptionService patientAttributeOptionService;
-
-    private RelationshipService relationshipService;
-
-    private RelationshipTypeService relationshipTypeService;
-
-    private SystemSettingManager systemSettingManager;
-
-    private UserService userService;
-
-    // -------------------------------------------------------------------------
-    // Input
-    // -------------------------------------------------------------------------
-
-    // -------------------------------------------------------------------------
-    // Input
-    // -------------------------------------------------------------------------
-
-    private String fullName;
-
-    private String birthDate;
-
-    private Integer age;
-
-    private Boolean verified;
-
-    private String gender;
-
-    private String[] phoneNumber;
-
-    private String registrationDate;
-
-    private boolean underAge;
-
-    private Integer healthWorker;
-
-    private boolean isDead;
-
-    private String deathDate;
-
-    private Integer relationshipId;
-
-    private Integer relationshipTypeId;
-
-    private boolean relationshipFromA;
-
-    // -------------------------------------------------------------------------
-    // Output
-    // -------------------------------------------------------------------------
-
-    public void setUserService( UserService userService )
-    {
-        this.userService = userService;
-    }
-
-    private Patient patient;
-
-    public Patient getPatient()
-    {
-        return patient;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    public String execute()
-    {
-        OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit();
-
-        patient = new Patient();
-
-        // ---------------------------------------------------------------------
-        // Set FullName
-        // ---------------------------------------------------------------------
-
-        if ( fullName != null )
-        {
-            fullName = fullName.trim();
-            patient.setName( fullName );
-        }
-
-        // ---------------------------------------------------------------------
-        // Set Other information for patient
-        // ---------------------------------------------------------------------
-
-        String phone = "";
-
-        for ( String _phoneNumber : phoneNumber )
-        {
-            _phoneNumber = (_phoneNumber != null && _phoneNumber.isEmpty() && _phoneNumber.trim().equals(
-                systemSettingManager.getSystemSetting( SystemSettingManager.KEY_PHONE_NUMBER_AREA_CODE ) )) ? null
-                : _phoneNumber;
-            if ( _phoneNumber != null )
-            {
-                phone += _phoneNumber + ";";
-            }
-        }
-
-        phone = (phone.isEmpty()) ? null : phone.substring( 0, phone.length() - 1 );
-
-        patient.setPhoneNumber( phone );
-        patient.setGender( gender );
-        patient.setIsDead( false );
-        patient.setUnderAge( underAge );
-        patient.setOrganisationUnit( organisationUnit );
-        patient.setIsDead( isDead );
-        if ( deathDate != null )
-        {
-            deathDate = deathDate.trim();
-            patient.setDeathDate( format.parseDate( deathDate ) );
-        }
-
-        if ( healthWorker != null )
-        {
-            patient.setHealthWorker( userService.getUser( healthWorker ) );
-        }
-
-        Date _birthDate = new Date();
-        if ( birthDate != null || age != null )
-        {
-            verified = (verified == null) ? false : verified;
-
-            Character dobType = (verified) ? Patient.DOB_TYPE_VERIFIED : Patient.DOB_TYPE_DECLARED;
-
-            if ( !verified && age != null )
-            {
-                dobType = 'A';
-            }
-
-            if ( dobType == Patient.DOB_TYPE_VERIFIED || dobType == Patient.DOB_TYPE_DECLARED )
-            {
-                birthDate = birthDate.trim();
-                patient.setBirthDate( format.parseDate( birthDate ) );
-            }
-            else
-            {
-                patient.setBirthDateFromAge( age.intValue(), Patient.AGE_TYPE_YEAR );
-            }
-
-            _birthDate = patient.getBirthDate();
-            patient.setDobType( dobType );
-        }
-
-        // -----------------------------------------------------------------------------
-        // Registration Date
-        // -----------------------------------------------------------------------------
-
-        if ( registrationDate == null )
-        {
-            patient.setRegistrationDate( new Date() );
-        }
-        else
-        {
-            patient.setRegistrationDate( format.parseDate( registrationDate ) );
-        }
-
-        // ---------------------------------------------------------------------
-        // Generate system id with this format :
-        // (BirthDate)(Gender)(XXXXXX)(checkdigit)
-        // PatientIdentifierType will be null
-        // ---------------------------------------------------------------------
-
-        String identifier = PatientIdentifierGenerator.getNewIdentifier( _birthDate, patient.getGender() );
-
-        PatientIdentifier systemGenerateIdentifier = patientIdentifierService.get( null, identifier );
-        while ( systemGenerateIdentifier != null )
-        {
-            identifier = PatientIdentifierGenerator.getNewIdentifier( patient.getBirthDate(), patient.getGender() );
-            systemGenerateIdentifier = patientIdentifierService.get( null, identifier );
-        }
-
-        systemGenerateIdentifier = new PatientIdentifier();
-        systemGenerateIdentifier.setIdentifier( identifier );
-        systemGenerateIdentifier.setPatient( patient );
-
-        patient.getIdentifiers().add( systemGenerateIdentifier );
-        
-        // ---------------------------------------------------------------------
-        // Save Patient Identifiers
-        // ---------------------------------------------------------------------
-
-        HttpServletRequest request = ServletActionContext.getRequest();
-
-        String value = null;
-
-        Collection<PatientIdentifierType> identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
-
-        PatientIdentifier pIdentifier = null;
-
-        if ( identifierTypes != null && identifierTypes.size() > 0 )
-        {
-            for ( PatientIdentifierType identifierType : identifierTypes )
-            {
-                value = request.getParameter( PREFIX_IDENTIFIER + identifierType.getId() );
-
-                if ( StringUtils.isNotBlank( value ) )
-                {
-                    pIdentifier = new PatientIdentifier();
-                    pIdentifier.setIdentifierType( identifierType );
-                    pIdentifier.setPatient( patient );
-                    pIdentifier.setIdentifier( value.trim() );
-                    patient.getIdentifiers().add( pIdentifier );
-                }
-            }
-        }
-
-        patientService.savePatient( patient );
-
-        // Create relationship
-
-        if ( relationshipId != null && relationshipTypeId != null )
-        {
-            Patient relationship = patientService.getPatient( relationshipId );
-            if ( relationship != null )
-            {
-                if ( underAge )
-                    patient.setRepresentative( relationship );
-
-                Relationship rel = new Relationship();
-                if ( relationshipFromA )
-                {
-                    rel.setPatientA( relationship );
-                    rel.setPatientB( patient );
-                }
-                else
-                {
-                    rel.setPatientA( patient );
-                    rel.setPatientB( relationship );
-                }
-                if ( relationshipTypeId != null )
-                {
-                    RelationshipType relType = relationshipTypeService.getRelationshipType( relationshipTypeId );
-                    if ( relType != null )
-                    {
-                        rel.setRelationshipType( relType );
-                        relationshipService.saveRelationship( rel );
-                    }
-                }
-            }
-        }
-
-        // -----------------------------------------------------------------------------
-        // Save Patient Attributes
-        // -----------------------------------------------------------------------------
-
-        Collection<PatientAttribute> attributes = patientAttributeService.getAllPatientAttributes();
-
-        PatientAttributeValue attributeValue = null;
-
-        if ( attributes != null && attributes.size() > 0 )
-        {
-            for ( PatientAttribute attribute : attributes )
-            {
-                value = request.getParameter( PREFIX_ATTRIBUTE + attribute.getId() );
-                if ( StringUtils.isNotBlank( value ) )
-                {
-                    attributeValue = new PatientAttributeValue();
-                    attributeValue.setPatient( patient );
-                    attributeValue.setPatientAttribute( attribute );
-
-                    if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) )
-                    {
-                        PatientAttributeOption option = patientAttributeOptionService
-                            .get( NumberUtils.toInt( value, 0 ) );
-                        if ( option != null )
-                        {
-                            attributeValue.setPatientAttributeOption( option );
-                            attributeValue.setValue( option.getName() );
-                        }
-                        else
-                        {
-                            // Someone deleted this option ...
-                        }
-                    }
-                    else
-                    {
-                        attributeValue.setValue( value.trim() );
-                    }
-                    patientAttributeValueService.savePatientAttributeValue( attributeValue );
-                }
-            }
-        }
-
-        return SUCCESS;
-    }
-
-    // -----------------------------------------------------------------------------
-    // Getter/Setter
-    // -----------------------------------------------------------------------------
-
-    public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService )
-    {
-        this.patientIdentifierTypeService = patientIdentifierTypeService;
-    }
-
-    public void setRelationshipFromA( boolean relationshipFromA )
-    {
-        this.relationshipFromA = relationshipFromA;
-    }
-
-    public void setBirthDate( String birthDate )
-    {
-        this.birthDate = birthDate;
-    }
-
-    public void setFormat( I18nFormat format )
-    {
-        this.format = format;
-    }
-
-    public void setPatientService( PatientService patientService )
-    {
-        this.patientService = patientService;
-    }
-
-    public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService )
-    {
-        this.patientIdentifierService = patientIdentifierService;
-    }
-
-    public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
-    {
-        this.selectionManager = selectionManager;
-    }
-
-    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
-    {
-        this.patientAttributeService = patientAttributeService;
-    }
-
-    public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService )
-    {
-        this.patientAttributeValueService = patientAttributeValueService;
-    }
-
-    public void setFullName( String fullName )
-    {
-        this.fullName = fullName;
-    }
-
-    public void setAge( Integer age )
-    {
-        this.age = age;
-    }
-
-    public void setGender( String gender )
-    {
-        this.gender = gender;
-    }
-
-    public void setPatientAttributeOptionService( PatientAttributeOptionService patientAttributeOptionService )
-    {
-        this.patientAttributeOptionService = patientAttributeOptionService;
-    }
-
-    public void setRelationshipTypeId( Integer relationshipTypeId )
-    {
-        this.relationshipTypeId = relationshipTypeId;
-    }
-
-    public void setRelationshipService( RelationshipService relationshipService )
-    {
-        this.relationshipService = relationshipService;
-    }
-
-    public void setRelationshipTypeService( RelationshipTypeService relationshipTypeService )
-    {
-        this.relationshipTypeService = relationshipTypeService;
-    }
-
-    public void setUnderAge( boolean underAge )
-    {
-        this.underAge = underAge;
-    }
-
-    public void setRelationshipId( Integer relationshipId )
-    {
-        this.relationshipId = relationshipId;
-    }
-
-    public void setSystemSettingManager( SystemSettingManager systemSettingManager )
-    {
-        this.systemSettingManager = systemSettingManager;
-    }
-
-    public void setRegistrationDate( String registrationDate )
-    {
-        this.registrationDate = registrationDate;
-    }
-
-    public void setPhoneNumber( String[] phoneNumber )
-    {
-        this.phoneNumber = phoneNumber;
-    }
-}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java	2013-10-24 08:31:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java	2013-10-25 05:00:41 +0000
@@ -185,7 +185,7 @@
         // ---------------------------------------------------------------------
         // Update enrollment-date and incident-date
         // ---------------------------------------------------------------------
-
+        
         else
         {
             programInstance.setEnrollmentDate( enrollment );

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java	2013-09-27 17:04:23 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java	2013-10-25 05:00:41 +0000
@@ -51,6 +51,8 @@
 import org.hisp.dhis.patient.comparator.PatientAttributeGroupSortOrderComparator;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.relationship.RelationshipType;
+import org.hisp.dhis.relationship.RelationshipTypeService;
 import org.hisp.dhis.user.User;
 
 import com.opensymphony.xwork2.Action;
@@ -115,6 +117,13 @@
         this.attributeGroupService = attributeGroupService;
     }
 
+    private RelationshipTypeService relationshipTypeService;
+
+    public void setRelationshipTypeService( RelationshipTypeService relationshipTypeService )
+    {
+        this.relationshipTypeService = relationshipTypeService;
+    }
+
     private I18n i18n;
 
     public void setI18n( I18n i18n )
@@ -236,6 +245,20 @@
         return relatedProgram;
     }
 
+    private boolean related;
+
+    public void setRelated( boolean related )
+    {
+        this.related = related;
+    }
+
+    private Collection<RelationshipType> relationshipTypes;
+
+    public Collection<RelationshipType> getRelationshipTypes()
+    {
+        return relationshipTypes;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -244,7 +267,7 @@
     {
         organisationUnit = selectionManager.getSelectedOrganisationUnit();
         healthWorkers = organisationUnit.getUsers();
-
+        
         if ( programId == null )
         {
             patientRegistrationForm = patientRegistrationFormService.getCommonPatientRegistrationForm();
@@ -319,6 +342,11 @@
         {
             relatedProgram = programService.getProgram( relatedProgramId );
         }
+        
+        if(related)
+        {
+            relationshipTypes = relationshipTypeService.getAllRelationshipTypes();
+        }
 
         return SUCCESS;
     }

=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddRelationshipPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddRelationshipPatientAction.java	2013-09-27 11:13:20 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddRelationshipPatientAction.java	1970-01-01 00:00:00 +0000
@@ -1,279 +0,0 @@
-package org.hisp.dhis.caseentry.action.patient;
-
-/*
- * Copyright (c) 2004-2013, 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 java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
-import org.hisp.dhis.patient.Patient;
-import org.hisp.dhis.patient.PatientAttribute;
-import org.hisp.dhis.patient.PatientAttributeGroup;
-import org.hisp.dhis.patient.PatientAttributeService;
-import org.hisp.dhis.patient.PatientIdentifier;
-import org.hisp.dhis.patient.PatientIdentifierType;
-import org.hisp.dhis.patient.PatientIdentifierTypeService;
-import org.hisp.dhis.patient.PatientService;
-import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
-import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
-import org.hisp.dhis.program.Program;
-import org.hisp.dhis.program.ProgramService;
-import org.hisp.dhis.relationship.RelationshipType;
-import org.hisp.dhis.relationship.RelationshipTypeService;
-import org.hisp.dhis.user.User;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Viet
- * 
- * @version $Id$
- */
-public class ShowAddRelationshipPatientAction
-    implements Action
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private PatientService patientService;
-
-    private PatientAttributeService patientAttributeService;
-
-    private PatientIdentifierTypeService patientIdentifierTypeService;
-
-    private RelationshipTypeService relationshipTypeService;
-
-    private PatientAttributeValueService patientAttributeValueService;
-
-    private ProgramService programService;
-
-    private OrganisationUnitSelectionManager selectionManager;
-
-    // -------------------------------------------------------------------------
-    // Input/Output
-    // -------------------------------------------------------------------------
-
-    private Integer id;
-
-    private Collection<PatientAttribute> noGroupAttributes = new HashSet<PatientAttribute>();
-
-    private Collection<PatientIdentifierType> identifierTypes;
-
-    private Collection<RelationshipType> relationshipTypes;
-
-    private Patient patient;
-
-    private Map<Integer, String> identiferMap = new HashMap<Integer, String>();
-
-    private Map<Integer, String> attributeMap = new HashMap<Integer, String>();
-
-    private Map<PatientAttributeGroup, Collection<PatientAttribute>> attributeGroupsMap = new HashMap<PatientAttributeGroup, Collection<PatientAttribute>>();
-
-    private Collection<User> healthWorkers;
-
-    private List<Program> programs;
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    public String execute()
-    {
-        OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit();
-        patient = patientService.getPatient( id );
-
-        identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
-        Collection<PatientAttribute> patientAttributes = patientAttributeService.getAllPatientAttributes();
-
-        programs = new ArrayList<Program>( programService.getProgramsByDisplayOnAllOrgunit( true, null ) );
-        programs.addAll( programService.getProgramsByDisplayOnAllOrgunit( false, organisationUnit ) );
-        programs.retainAll( programService.getProgramsByCurrentUser() );
-        programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) );
-
-        for ( Program program : programs )
-        {
-            identifierTypes.removeAll( program.getPatientIdentifierTypes() );
-            patientAttributes.removeAll( program.getPatientAttributes() );
-        }
-
-        for ( PatientAttribute patientAttribute : patientAttributes )
-        {
-            PatientAttributeGroup attributeGroup = patientAttribute.getPatientAttributeGroup();
-            if ( attributeGroup != null )
-            {
-                if ( attributeGroupsMap.containsKey( attributeGroup ) )
-                {
-                    Collection<PatientAttribute> attributes = attributeGroupsMap.get( attributeGroup );
-                    attributes.add( patientAttribute );
-                }
-                else
-                {
-                    Collection<PatientAttribute> attributes = new HashSet<PatientAttribute>();
-                    attributes.add( patientAttribute );
-                    attributeGroupsMap.put( attributeGroup, attributes );
-                }
-            }
-            else
-            {
-                noGroupAttributes.add( patientAttribute );
-            }
-        }
-
-        relationshipTypes = relationshipTypeService.getAllRelationshipTypes();
-
-        identiferMap = new HashMap<Integer, String>();
-
-        for ( PatientIdentifier identifier : patient.getIdentifiers() )
-        {
-            if ( identifier.getIdentifierType() != null )
-                identiferMap.put( identifier.getIdentifierType().getId(), identifier.getIdentifier() );
-        }
-
-        // -------------------------------------------------------------------------
-        // Get patient-attribute values
-        // -------------------------------------------------------------------------
-
-        Collection<PatientAttributeValue> patientAttributeValues = patientAttributeValueService
-            .getPatientAttributeValues( patient );
-
-        for ( PatientAttributeValue patientAttributeValue : patientAttributeValues )
-        {
-            if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( patientAttributeValue.getPatientAttribute()
-                .getValueType() ) )
-            {
-                attributeMap.put( patientAttributeValue.getPatientAttribute().getId(), patientAttributeValue
-                    .getPatientAttributeOption().getName() );
-            }
-            else
-            {
-                attributeMap
-                    .put( patientAttributeValue.getPatientAttribute().getId(), patientAttributeValue.getValue() );
-            }
-        }
-
-        healthWorkers = organisationUnit.getUsers();
-
-        return SUCCESS;
-    }
-
-    // -------------------------------------------------------------------------
-    // Getter/Setter
-    // -------------------------------------------------------------------------
-
-    public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
-    {
-        this.selectionManager = selectionManager;
-    }
-
-    public List<Program> getPrograms()
-    {
-        return programs;
-    }
-
-    public void setProgramService( ProgramService programService )
-    {
-        this.programService = programService;
-    }
-
-    public Collection<User> getHealthWorkers()
-    {
-        return healthWorkers;
-    }
-
-    public Map<PatientAttributeGroup, Collection<PatientAttribute>> getAttributeGroupsMap()
-    {
-        return attributeGroupsMap;
-    }
-
-    public void setId( Integer id )
-    {
-        this.id = id;
-    }
-
-    public Collection<PatientIdentifierType> getIdentifierTypes()
-    {
-        return identifierTypes;
-    }
-
-    public Collection<PatientAttribute> getNoGroupAttributes()
-    {
-        return noGroupAttributes;
-    }
-
-    public void setRelationshipTypeService( RelationshipTypeService relationshipTypeService )
-    {
-        this.relationshipTypeService = relationshipTypeService;
-    }
-
-    public Collection<RelationshipType> getRelationshipTypes()
-    {
-        return relationshipTypes;
-    }
-
-    public Patient getPatient()
-    {
-        return patient;
-    }
-
-    public Map<Integer, String> getIdentiferMap()
-    {
-        return identiferMap;
-    }
-
-    public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService )
-    {
-        this.patientIdentifierTypeService = patientIdentifierTypeService;
-    }
-
-    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
-    {
-        this.patientAttributeService = patientAttributeService;
-    }
-
-    public void setPatientService( PatientService patientService )
-    {
-        this.patientService = patientService;
-    }
-
-    public Map<Integer, String> getAttributeMap()
-    {
-        return attributeMap;
-    }
-
-    public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService )
-    {
-        this.patientAttributeValueService = patientAttributeValueService;
-    }
-}

=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidateAddRelationshipPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidateAddRelationshipPatientAction.java	2013-09-16 17:07:25 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidateAddRelationshipPatientAction.java	1970-01-01 00:00:00 +0000
@@ -1,358 +0,0 @@
-package org.hisp.dhis.caseentry.action.patient;
-
-/*
- * Copyright (c) 2004-2013, 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 com.opensymphony.xwork2.Action;
-import org.apache.commons.lang.StringUtils;
-import org.apache.struts2.ServletActionContext;
-import org.hisp.dhis.i18n.I18n;
-import org.hisp.dhis.i18n.I18nFormat;
-import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
-import org.hisp.dhis.patient.Patient;
-import org.hisp.dhis.patient.PatientIdentifier;
-import org.hisp.dhis.patient.PatientIdentifierService;
-import org.hisp.dhis.patient.PatientIdentifierType;
-import org.hisp.dhis.patient.PatientIdentifierTypeService;
-import org.hisp.dhis.patient.PatientService;
-import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
-import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-public class ValidateAddRelationshipPatientAction
-    implements Action
-{
-    public static final String PATIENT_DUPLICATE = "duplicate";
-
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private OrganisationUnitSelectionManager selectionManager;
-
-    private I18nFormat format;
-
-    private PatientService patientService;
-
-    private PatientAttributeValueService patientAttributeValueService;
-
-    private PatientIdentifierService patientIdentifierService;
-
-    private PatientIdentifierTypeService identifierTypeService;
-
-    // -------------------------------------------------------------------------
-    // Input
-    // -------------------------------------------------------------------------
-
-    private String fullName;
-
-    private Character dobType;
-
-    private String birthDate;
-
-    private char ageType;
-
-    private Integer age;
-
-    private String gender;
-
-    private Integer id;
-
-    private boolean checkedDuplicate;
-
-    private boolean underAge;
-
-    // -------------------------------------------------------------------------
-    // Output
-    // -------------------------------------------------------------------------
-
-    private String message;
-
-    private I18n i18n;
-
-    private Patient patient;
-
-    private Map<String, String> patientAttributeValueMap = new HashMap<String, String>();
-
-    private PatientIdentifier patientIdentifier;
-
-    private Collection<Patient> patients;
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    public String execute()
-    {
-
-        Date dateOfBirth;
-
-        if ( selectionManager.getSelectedOrganisationUnit() == null )
-        {
-            message = i18n.getString( "please_select_a_registering_unit" );
-
-            return INPUT;
-        }
-
-        if ( age == null && birthDate == null )
-        {
-            message = i18n.getString( "specfiy_birth_date_or_age" );
-
-            return INPUT;
-        }
-
-        if ( dobType == 'V' || dobType == 'D' )
-        {
-            birthDate = birthDate.trim();
-
-            dateOfBirth = format.parseDate( birthDate );
-
-            if ( dateOfBirth == null || dateOfBirth.after( new Date() ) )
-            {
-                message = i18n.getString( "please_enter_a_valid_birth_date" );
-
-                return INPUT;
-            }
-        }
-
-        fullName = fullName.trim();
-
-        if ( fullName.indexOf( ' ' ) == -1 )
-        {
-            message = i18n.getString( "please_enter_a_valid_full_name" );
-
-            return INPUT;
-        }
-
-        // ---------------------------------------------------------------------
-        // Check duplicated patient
-        // ---------------------------------------------------------------------
-
-        if ( !checkedDuplicate )
-        {
-            // Check duplication name, birthdate, gender
-            patients = patientService.getPatients( fullName, format.parseDate( birthDate ), gender );
-
-            if ( patients != null && patients.size() > 0 )
-            {
-                message = i18n.getString( "patient_duplicate" );
-                boolean flagDuplicate = false;
-
-                for ( Patient p : patients )
-                {
-                    if ( id == null || (id != null && p.getId() != id) )
-                    {
-                        flagDuplicate = true;
-                        Collection<PatientAttributeValue> patientAttributeValues = patientAttributeValueService
-                            .getPatientAttributeValues( p );
-
-                        for ( PatientAttributeValue patientAttributeValue : patientAttributeValues )
-                        {
-                            patientAttributeValueMap
-                                .put( p.getId() + "_" + patientAttributeValue.getPatientAttribute().getId(),
-                                    patientAttributeValue.getValue() );
-                        }
-                    }
-                }
-                if ( flagDuplicate )
-                    return PATIENT_DUPLICATE;
-            }
-        }
-
-        // Check Identifiers duplicate
-
-        Patient p = new Patient();
-        if ( dobType == Patient.DOB_TYPE_VERIFIED || dobType == Patient.DOB_TYPE_DECLARED )
-        {
-            birthDate = birthDate.trim();
-            p.setBirthDate( format.parseDate( birthDate ) );
-        }
-        else
-        {
-            p.setBirthDateFromAge( age, ageType );
-        }
-
-        HttpServletRequest request = ServletActionContext.getRequest();
-
-        Collection<PatientIdentifierType> identifiers = identifierTypeService.getAllPatientIdentifierTypes();
-
-        if ( identifiers != null && identifiers.size() > 0 )
-        {
-            String value;
-            String idDuplicate = "";
-
-            for ( PatientIdentifierType idType : identifiers )
-            {
-                // If underAge is TRUE : Only check duplicate on
-                // PatientIdentifierType which related is FALSE
-                if ( !underAge || (underAge && !idType.isRelated()) )
-                {
-                    value = request.getParameter( AddPatientAction.PREFIX_IDENTIFIER + idType.getId() );
-                    if ( StringUtils.isNotBlank( value ) )
-                    {
-                        PatientIdentifier identifier = patientIdentifierService.get( idType, value );
-                        if ( identifier != null
-                            && (id == null || identifier.getPatient().getId() != id) )
-                        {
-                            idDuplicate += idType.getName() + ", ";
-                        }
-                    }
-                }
-            }
-
-            if ( StringUtils.isNotBlank( idDuplicate ) )
-            {
-                idDuplicate = StringUtils.substringBeforeLast( idDuplicate, "," );
-                message = i18n.getString( "identifier_duplicate" ) + ": " + idDuplicate;
-                return INPUT;
-            }
-        }
-
-        // ---------------------------------------------------------------------
-        // Validation success
-        // ---------------------------------------------------------------------
-
-        message = i18n.getString( "everything_is_ok" );
-
-        return SUCCESS;
-    }
-
-    // ---------------------------------------------------------------------
-    // Getter/Setter
-    // ---------------------------------------------------------------------
-
-    public Collection<Patient> getPatients()
-    {
-        return patients;
-    }
-
-    public void setIdentifierTypeService( PatientIdentifierTypeService identifierTypeService )
-    {
-        this.identifierTypeService = identifierTypeService;
-    }
-
-    public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService )
-    {
-        this.patientIdentifierService = patientIdentifierService;
-    }
-
-    public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
-    {
-        this.selectionManager = selectionManager;
-    }
-
-    public void setFormat( I18nFormat format )
-    {
-        this.format = format;
-    }
-
-    public void setPatientService( PatientService patientService )
-    {
-        this.patientService = patientService;
-    }
-
-    public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService )
-    {
-        this.patientAttributeValueService = patientAttributeValueService;
-    }
-
-    public void setFullName( String fullName )
-    {
-        this.fullName = fullName;
-    }
-
-    public void setBirthDate( String birthDate )
-    {
-        this.birthDate = birthDate;
-    }
-
-    public void setAge( Integer age )
-    {
-        this.age = age;
-    }
-
-    public String getMessage()
-    {
-        return message;
-    }
-
-    public void setI18n( I18n i18n )
-    {
-        this.i18n = i18n;
-    }
-
-    public Patient getPatient()
-    {
-        return patient;
-    }
-
-    public Map<String, String> getPatientAttributeValueMap()
-    {
-        return patientAttributeValueMap;
-    }
-
-    public PatientIdentifier getPatientIdentifier()
-    {
-        return patientIdentifier;
-    }
-
-    public void setId( Integer id )
-    {
-        this.id = id;
-    }
-
-    public void setCheckedDuplicate( boolean checkedDuplicate )
-    {
-        this.checkedDuplicate = checkedDuplicate;
-    }
-
-    public void setGender( String gender )
-    {
-        this.gender = gender;
-    }
-
-    public void setUnderAge( boolean underAge )
-    {
-        this.underAge = underAge;
-    }
-
-    public void setAgeType( char ageType )
-    {
-        this.ageType = ageType;
-    }
-
-    public void setDobType( Character dobType )
-    {
-        this.dobType = dobType;
-    }
-}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java	2013-10-24 08:31:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java	2013-10-25 05:00:41 +0000
@@ -180,7 +180,7 @@
 
         int errorCode = patientService.validatePatient( patient, program );
 
-        message = errorCode + " ";
+        message = errorCode + "";
 
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientIdentifierAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientIdentifierAction.java	2013-09-23 04:29:22 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientIdentifierAction.java	2013-10-25 05:00:41 +0000
@@ -30,19 +30,19 @@
 
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.struts2.ServletActionContext;
-import org.hisp.dhis.i18n.I18n;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
+import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patient.PatientIdentifier;
-import org.hisp.dhis.patient.PatientIdentifierService;
 import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.patient.PatientIdentifierTypeService;
+import org.hisp.dhis.patient.PatientService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramService;
 
@@ -54,20 +54,16 @@
 public class ValidatePatientIdentifierAction
     implements Action
 {
-    public static final String PATIENT_DUPLICATE = "duplicate";
-
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
 
-    private PatientIdentifierService patientIdentifierService;
+    private PatientService patientService;
 
     private PatientIdentifierTypeService identifierTypeService;
 
     private ProgramService programService;
 
-    private OrganisationUnitSelectionManager selectionManager;
-
     // -------------------------------------------------------------------------
     // Input
     // -------------------------------------------------------------------------
@@ -82,8 +78,6 @@
 
     private String message;
 
-    private I18n i18n;
-
     private Map<String, String> patientAttributeValueMap = new HashMap<String, String>();
 
     private PatientIdentifier patientIdentifier;
@@ -94,52 +88,44 @@
 
     public String execute()
     {
+        Patient patient = patientService.getPatient( patientId );
+        Program program = programService.getProgram( programId );
+
         HttpServletRequest request = ServletActionContext.getRequest();
 
-        Collection<PatientIdentifierType> identifiers = identifierTypeService.getAllPatientIdentifierTypes();
+        Collection<PatientIdentifierType> identifierTypes = identifierTypeService.getAllPatientIdentifierTypes();
 
-        if ( identifiers != null && identifiers.size() > 0 )
+        if ( identifierTypes != null && identifierTypes.size() > 0 )
         {
             String value = null;
-            String idDuplicate = "";
-
-            for ( PatientIdentifierType idType : identifiers )
+
+            Set<PatientIdentifier> patientIdentifiers = new HashSet<PatientIdentifier>();
+
+            for ( PatientIdentifierType idType : identifierTypes )
             {
 
                 value = request.getParameter( AddPatientAction.PREFIX_IDENTIFIER + idType.getId() );
-
                 if ( StringUtils.isNotBlank( value ) )
                 {
-                    boolean isDuplicate = false;
-
-                     OrganisationUnit orgunit = (idType.getOrgunitScope()) ? selectionManager
-                            .getSelectedOrganisationUnit() : null;
-
-                        Program program = (idType.getProgramScope()) ? programService.getProgram( programId ) : null;
-                        isDuplicate = patientIdentifierService.checkDuplicateIdentifier( idType, value, patientId,  orgunit,
-                            program, idType.getPeriodType() );
-                 
-                    if ( isDuplicate )
-                    {
-                        idDuplicate += idType.getName() + ", ";
-                    }
+                    PatientIdentifier patientIdentifier = new PatientIdentifier();
+                    patientIdentifier.setPatient( patient );
+                    patientIdentifier.setIdentifierType( idType );
+                    patientIdentifier.setIdentifier( value );
+
+                    patientIdentifiers.add( patientIdentifier );
                 }
-
-            }
-
-            if ( StringUtils.isNotBlank( idDuplicate ) )
-            {
-                idDuplicate = StringUtils.substringBeforeLast( idDuplicate, "," );
-                message = i18n.getString( "identifier_duplicate" ) + ": " + idDuplicate;
-                return INPUT;
-            }
+            }
+
+            patient.setIdentifiers( patientIdentifiers );
         }
 
+        int errorCode = patientService.validatePatient( patient, program );
+
         // ---------------------------------------------------------------------
         // Validation success
         // ---------------------------------------------------------------------
 
-        message = i18n.getString( "everything_is_ok" );
+        message = errorCode + "";
 
         return SUCCESS;
     }
@@ -168,26 +154,11 @@
         this.identifierTypeService = identifierTypeService;
     }
 
-    public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService )
-    {
-        this.patientIdentifierService = patientIdentifierService;
-    }
-
-    public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
-    {
-        this.selectionManager = selectionManager;
-    }
-
     public String getMessage()
     {
         return message;
     }
 
-    public void setI18n( I18n i18n )
-    {
-        this.i18n = i18n;
-    }
-
     public Map<String, String> getPatientAttributeValueMap()
     {
         return patientAttributeValueMap;
@@ -198,4 +169,9 @@
         return patientIdentifier;
     }
 
+    public void setPatientService( PatientService patientService )
+    {
+        this.patientService = patientService;
+    }
+
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-10-24 08:31:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-10-25 05:00:41 +0000
@@ -2,7 +2,7 @@
 <beans xmlns="http://www.springframework.org/schema/beans";
 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
 	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd";>
-	
+
 	<!-- Data Entry -->
 
 	<bean id="org.hisp.dhis.caseentry.action.caseentry.ValidateSearchAction"
@@ -525,6 +525,9 @@
 		<property name="attributeGroupService">
 			<ref bean="org.hisp.dhis.patient.PatientAttributeGroupService" />
 		</property>
+		<property name="relationshipTypeService">
+			<ref bean="org.hisp.dhis.relationship.RelationshipTypeService" />
+		</property>
 	</bean>
 
 	<bean id="org.hisp.dhis.caseentry.action.patient.ValidatePatientAction"
@@ -532,7 +535,8 @@
 		scope="prototype">
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
-		<property name="identifierTypeService" ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
+		<property name="identifierTypeService"
+			ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
 		<property name="selectionManager">
 			<ref bean="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
 		</property>
@@ -599,15 +603,10 @@
 		id="org.hisp.dhis.caseentry.action.patient.ValidatePatientIdentifierAction"
 		class="org.hisp.dhis.caseentry.action.patient.ValidatePatientIdentifierAction"
 		scope="prototype">
-		<property name="patientIdentifierService"
-			ref="org.hisp.dhis.patient.PatientIdentifierService" />
-		<property name="identifierTypeService">
-			<ref bean="org.hisp.dhis.patient.PatientIdentifierTypeService" />
-		</property>
+		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
+		<property name="identifierTypeService"
+			ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
-		<property name="selectionManager">
-			<ref bean="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
-		</property>
 	</bean>
 
 
@@ -698,31 +697,6 @@
 
 	<!-- Relationship -->
 
-	<bean
-		id="org.hisp.dhis.caseentry.action.patient.AddRelationshipPatientAction"
-		class="org.hisp.dhis.caseentry.action.patient.AddRelationshipPatientAction"
-		scope="prototype">
-		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
-		<property name="patientIdentifierService"
-			ref="org.hisp.dhis.patient.PatientIdentifierService" />
-		<property name="selectionManager"
-			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
-		<property name="patientAttributeValueService"
-			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
-		<property name="patientAttributeService"
-			ref="org.hisp.dhis.patient.PatientAttributeService" />
-		<property name="patientIdentifierTypeService"
-			ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
-		<property name="patientAttributeOptionService"
-			ref="org.hisp.dhis.patient.PatientAttributeOptionService" />
-		<property name="relationshipService"
-			ref="org.hisp.dhis.relationship.RelationshipService" />
-		<property name="relationshipTypeService"
-			ref="org.hisp.dhis.relationship.RelationshipTypeService" />
-		<property name="systemSettingManager" ref="org.hisp.dhis.setting.SystemSettingManager" />
-		<property name="userService" ref="org.hisp.dhis.user.UserService" />
-	</bean>
-
 	<bean id="org.hisp.dhis.caseentry.action.patient.GetPartnerAction"
 		class="org.hisp.dhis.caseentry.action.patient.GetPartnerAction" scope="prototype">
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
@@ -790,31 +764,6 @@
 	</bean>
 
 	<bean
-		id="org.hisp.dhis.caseentry.action.patient.ShowAddRelationshipPatientAction"
-		class="org.hisp.dhis.caseentry.action.patient.ShowAddRelationshipPatientAction"
-		scope="prototype">
-		<property name="patientService">
-			<ref bean="org.hisp.dhis.patient.PatientService" />
-		</property>
-		<property name="patientAttributeService">
-			<ref bean="org.hisp.dhis.patient.PatientAttributeService" />
-		</property>
-		<property name="patientAttributeValueService">
-			<ref
-				bean="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
-		</property>
-		<property name="patientIdentifierTypeService">
-			<ref bean="org.hisp.dhis.patient.PatientIdentifierTypeService" />
-		</property>
-		<property name="relationshipTypeService">
-			<ref bean="org.hisp.dhis.relationship.RelationshipTypeService" />
-		</property>
-		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
-		<property name="selectionManager"
-			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
-	</bean>
-
-	<bean
 		id="org.hisp.dhis.caseentry.action.patient.ShowRelationshipListAction"
 		class="org.hisp.dhis.caseentry.action.patient.ShowRelationshipListAction"
 		scope="prototype">
@@ -824,25 +773,7 @@
 		<property name="patientAttributeValueService"
 			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
 	</bean>
-
-	<bean
-		id="org.hisp.dhis.caseentry.action.patient.ValidateAddRelationshipPatientAction"
-		class="org.hisp.dhis.caseentry.action.patient.ValidateAddRelationshipPatientAction"
-		scope="prototype">
-		<property name="selectionManager"
-			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
-		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
-		<property name="patientAttributeValueService">
-			<ref
-				bean="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
-		</property>
-		<property name="patientIdentifierService"
-			ref="org.hisp.dhis.patient.PatientIdentifierService" />
-		<property name="identifierTypeService">
-			<ref bean="org.hisp.dhis.patient.PatientIdentifierTypeService" />
-		</property>
-	</bean>
-
+	
 	<bean
 		id="org.hisp.dhis.caseentry.action.patient.ValidateSearchRelationshipAction"
 		class="org.hisp.dhis.caseentry.action.patient.ValidateSearchRelationshipAction"
@@ -850,7 +781,7 @@
 	</bean>
 
 	<!-- Tabular report -->
-	
+
 	<bean
 		id="org.hisp.dhis.caseentry.action.report.GenerateTabularReportAction"
 		class="org.hisp.dhis.caseentry.action.report.GenerateTabularReportAction"

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2013-10-24 08:31:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2013-10-25 05:00:41 +0000
@@ -836,31 +836,6 @@
       <param name="requiredAuthorities">F_PATIENT_ADD, F_RELATIONSHIP_ADD</param>
     </action>
 
-    <action name="validateAddRelationshipPatient"
-      class="org.hisp.dhis.caseentry.action.patient.ValidateAddRelationshipPatientAction">
-      <result name="success" type="velocity-xml">
-        /dhis-web-commons/ajax/xmlResponseSuccess.vm
-      </result>
-      <result name="error" type="velocity-xml">
-        /dhis-web-commons/ajax/xmlResponseError.vm
-      </result>
-      <result name="input" type="velocity-xml">
-        /dhis-web-commons/ajax/xmlResponseInput.vm
-      </result>
-      <result name="duplicate" type="velocity-xml">
-        /dhis-web-caseentry/responseDuplicate.vm
-      </result>
-      <param name="onExceptionReturn">plainTextError</param>
-    </action>
-
-    <action name="addRelationshipPatient"
-      class="org.hisp.dhis.caseentry.action.patient.AddRelationshipPatientAction">
-      <result name="success" type="velocity-json">
-        /dhis-web-commons/ajax/jsonResponseSuccess.vm
-      </result>
-      <param name="requiredAuthorities">F_RELATIONSHIP_ADD</param>
-    </action>
-
     <!-- Tabular report -->
 
     <action name="searchProgramStageInstances"

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addPatientForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addPatientForm.vm	2013-10-24 08:31:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addPatientForm.vm	2013-10-25 05:00:41 +0000
@@ -58,18 +58,34 @@
 </h3>
 
 <form id="patientForm" name="patientForm" method="post" >
-
-#if($relatedProgram)
-	<input type='hidden' name="relationshipTypeId" id="relationshipTypeId" value="$relatedProgram.relationshipType.id">
-	<input type='hidden' name="relationshipFromA" id="relationshipFromA" value="$relatedProgram.relationshipFromA" >
-	<input type='hidden' name="relationshipId" id="relationshipId" value="$patientId">
-	<input type='hidden' name="relatedProgramId" id="relatedProgramId" value="$program.id" >
-#else
-	<input type="hidden" id="representativeId" name="representativeId"/> 
-	<input type="hidden" id="relationshipTypeId" name="relationshipTypeId"/>
-	<input type="hidden" id="addRelationship" name="addRelationship" value="true">
-#end
 <table>
+	#if($relatedProgram)
+		<input type='hidden' name="relationshipTypeId" id="relationshipTypeId" value="$relatedProgram.relationshipType.id">
+		<input type='hidden' name="relationshipFromA" id="relationshipFromA" value="$relatedProgram.relationshipFromA" >
+		<input type='hidden' name="relationshipId" id="relationshipId" value="$patientId">
+		<input type='hidden' name="relatedProgramId" id="relatedProgramId" value="$program.id" >
+	#elseif( $!relationshipTypes)
+	<tr>
+		<td class='text-column'><label for="relationship_type">$i18n.getString("relationship_type")<em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+		<td class="input-column">
+			<select name="relationshipTypeId" id="relationshipTypeId" class="{validate:{required:true}}" >
+				<option value="">[$i18n.getString( "please_select" )]</option>        
+				#foreach ($relationship in $relationshipTypes)
+					<option value="$relationship.id" relationshipFromA='true'>$!encoder.htmlEncode(${relationship.aIsToB}) $i18n.getString("of") $!encoder.htmlEncode($patient.name) ($!encoder.htmlEncode(${relationship.bIsToA}))</option>
+					<option value="$relationship.id" relationshipFromA='false'>$!encoder.htmlEncode(${relationship.bIsToA}) $i18n.getString("of") $!encoder.htmlEncode($patient.name) ($!encoder.htmlEncode(${relationship.aIsToB}))</option>
+				#end
+			</select>
+		</td>
+		<input type="hidden" id="representativeId" name="representativeId"/> 
+		<input type='hidden' name="relationshipId" id="relationshipId">
+		<input type="hidden" id="addRelationship" name="addRelationship" value="true">
+	</tr>
+	#else
+		<input type="hidden" id="representativeId" name="representativeId"/> 
+		<input type="hidden" id="relationshipTypeId" name="relationshipTypeId"/>
+		<input type="hidden" id="addRelationship" name="addRelationship" value="true">
+	#end
+	
 	#parse( "/dhis-web-caseentry/patientForm.vm" )
 	<tr>
 		<td></td>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipForm.vm	2013-09-23 03:15:40 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipForm.vm	2013-10-25 05:00:41 +0000
@@ -18,7 +18,7 @@
 </h5>
 <h3>
 	&raquo; $i18n.getString( 'seach_available_patient' )
-	&#8226; <a href="javascript:showAddRelationshipPatient( '$patient.id',false,'' )" >$i18n.getString( 'add_new_patient' )</a>
+	&#8226; <a href="javascript:showAddPatientForm( '$patient.id','','', true )" >$i18n.getString( 'add_new_patient' )</a>
 </h3>
 
 <form id="relationshipSelectForm" name="relationshipSelectForm" method="post" action="showAddRelationshipForm.action">

=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipPatientForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipPatientForm.vm	2013-09-23 03:15:40 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipPatientForm.vm	1970-01-01 00:00:00 +0000
@@ -1,83 +0,0 @@
-<script>
-	jQuery('#patientForm').ready(	function(){
-
-		addRelationship = true;
-		checkedDuplicate = false;
-		
-		jQuery("#patientForm").validate({
-			 meta:"validate"
-			,errorElement:"span"
-			,submitHandler: function(form)
-				{
-					validateAddRelationshipPatient();
-				}
-			,beforeValidateHandler: function(form)
-				{
-					var birthDate = $('#patientForm [id=birthDate]').val();
-					var age = $('#patientForm [id=age]').val();
-					if(age !=''){
-						$( "#patientForm [id=memberValidator]").val(age);
-					}else{
-						$( "#patientForm [id=memberValidator]").val(birthDate);
-					}
-				}
-		});
-		jQuery('#patientForm [id=fullName]').val("");
-		hideById('underAgeDiv');
-		hideById('representativeFormDiv');
-		jQuery('#patientForm [inherit=false]').val("");
-		jQuery('#patientForm [inherit=]').val("");
-		jQuery('#patientForm [id=healthWorkerId]').val("");
-		jQuery('#patientForm [id^="iden"]').val("");
-		hideById('patientForm [id=age]');
-
-		#if($!customRegistrationForm)
-		#else
-		datePickerValid( 'patientForm [id=birthDate]' );
-		#end
-		
-		addEventForPatientForm('patientForm');
-		jQuery('[name=mainPagelink]').html(i18n_main_form_link);
-	});		
-</script>
-
-<h5>
-	<a name="mainPagelink" href="javascript:onClickBackBtn();">$i18n.getString( 'patient_management' )</a>
-	&#8226; <a href="javascript:showPatientDashboardForm($!patient.id);">$i18n.getString( 'patient_dashboard' )</a>
-	&#8226; <a href="javascript:showRelationshipList( '$patient.id' )">$i18n.getString( "relationship_management" )</a>	
-</h5>
-<h3>
-	&raquo; <a href="javascript:showAddRelationship('$patient.id')" >$i18n.getString( 'seach_available_patient' )</a>
-	&#8226; $i18n.getString( 'add_new_patient' )
-</h3>
-																		
-<form id="patientForm" action="addRelationshipPatient.action" method="get" >
-<input type="hidden" id="relationshipId" name="relationshipId" value="$patient.id"/> 
-<input type="hidden" id="programStageInstanceId" name="programStageInstanceId" value="$!programStageInstanceId"/> 
-<table>	
-	<tr>
-		<td class='text-column'><label for="relationship_type">$i18n.getString("relationship_type")<em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-		<td class="input-column">
-			<select name="relationshipTypeId" id="relationshipTypeId" class="{validate:{required:true}}" >
-				<option value="">[$i18n.getString( "please_select" )]</option>        
-				#foreach ($relationship in $relationshipTypes)
-					<option value="$relationship.id" relationshipFromA='true'>$!encoder.htmlEncode(${relationship.aIsToB}) $i18n.getString("of") $!encoder.htmlEncode($patient.name) ($!encoder.htmlEncode(${relationship.bIsToA}))</option>
-					<option value="$relationship.id" relationshipFromA='false'>$!encoder.htmlEncode(${relationship.bIsToA}) $i18n.getString("of") $!encoder.htmlEncode($patient.name) ($!encoder.htmlEncode(${relationship.aIsToB}))</option>
-				#end
-			</select>
-		</td>
-	</tr>
-	
-	#parse( "/dhis-web-caseentry/patientForm.vm" )
-
-	<tr><td><p></p></td></tr>
-	<tr>
-		<td></td>
-		<td>
-			<input type="submit" class='button' value="$i18n.getString( 'add' )" />
-			<input type="button" class='button' value="$i18n.getString( 'cancel' )" onclick="showRelationshipList($patient.id);">
-		</td>
-	</tr>
-</table>
-</form> 	
-

=== modified 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	2013-10-24 08:31:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultDataEntryForm.vm	2013-10-25 05:00:41 +0000
@@ -74,10 +74,10 @@
 					<table style='width:100%'>
 						<tr>
 							<td>
-					<input id='$id' class='$id' name="$id" options='no' type='radio' optionset='$programStageDataElement.dataElement.optionSet.uid'
-						data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }"
-						#if( $patientDataValue.value == $option) checked #end
-						onclick="saveRadio( '$programStageDataElement.dataElement.uid', '' )" tabindex="$tabIndex" />$i18n.getString("non_value")
+							<input id='$id' class='$id' name="$id" type='radio' options='no' optionset='$programStageDataElement.dataElement.optionSet.uid'
+								data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }"
+								#if( $patientDataValue.value == $option) checked #end
+								onclick="saveRadio( '$programStageDataElement.dataElement.uid', '' )" tabindex="$tabIndex" />$i18n.getString("non_value")
 						</td>
 					#set($index=1)
 					#foreach($option in $programStageDataElement.dataElement.optionSet.options)
@@ -96,8 +96,7 @@
 					</tr>
 					</table>
 				#else
-					<input optionset='$programStageDataElement.dataElement.optionSet.uid' id='$id' name="entryfield" options='$hasOptionSet' data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" class="auto-field optionset" />
-				#end
+					<input options='$hasOptionSet' optionset='$programStageDataElement.dataElement.optionSet.uid' id='$id' name="entryfield" data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" class="auto-field optionset" />				#end
 			#elseif($programStageDataElement.dataElement.type=='username')
 				<input name="entryfield" username='true' class="auto-field optionset" data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" id="$id" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" />
 			#else

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2013-10-24 08:31:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2013-10-25 05:00:41 +0000
@@ -1700,7 +1700,7 @@
 
         if( relationshipText != "")
         {
-            setInnerHTML('patientRelatedStageSpan',"&#8226; <a href='javascript:showAddPatientForm( " + relatedProgramId + "," + patientId + "," + selectedProgram + " );' id='relatedPatient_$!programStageInstance.id' >" + relationshipText + "</a><br>&nbsp;");
+            setInnerHTML('patientRelatedStageSpan',"&#8226; <a href='javascript:showAddPatientForm( " + patientId + "," + relatedProgramId + "," + selectedProgram + " , false );' id='relatedPatient_$!programStageInstance.id' >" + relationshipText + "</a><br>&nbsp;");
         }
         else
         {

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2013-10-24 08:31:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2013-10-25 05:00:41 +0000
@@ -319,12 +319,13 @@
     return false;
 }
 
-function showAddPatientForm( programId, patientId, relatedProgramId )
+function showAddPatientForm( patientId, programId, relatedProgramId, related )
 {
 	hideById('listPatientDiv');
 	hideById('selectDiv');
 	hideById('searchDiv');
 	hideById('migrationPatientDiv');
+	hideById('listRelationshipDiv');
 	setInnerHTML('addRelationshipDiv','');
 	setInnerHTML('patientDashboard','');
 	
@@ -333,42 +334,19 @@
 		{
 			programId: programId,
 			patientId: patientId,
-			relatedProgramId: relatedProgramId
+			relatedProgramId: relatedProgramId,
+			related: related
 		}, function()
 		{
 			showById('editPatientDiv');
+			if(related){
+				setFieldValue('relationshipId',patientId);
+			}
 			jQuery('#loaderDiv').hide();
 		});
 	
 }
 
-function addRelationship()
-{
-	jQuery('#loaderDiv').show();
-	var params = getParamsForDiv('addRelationshipDiv');
-		params += "&relationshipFromA=" + jQuery('#patientForm option:selected').attr("relationshipFromA");
-	$.ajax({
-		type: "POST",
-		url: 'addRelationshipPatient.action',
-		data: params,
-		success: function( json ) {
-			hideById('addRelationshipDiv');
-			showById('selectDiv');
-			showById('searchDiv');
-			showById('listPatientDiv');
-			jQuery('#loaderDiv').hide();
-
-			if( getFieldValue( 'isShowPatientList' ) == 'false' ){
-				showRelationshipList( getFieldValue('relationshipId') );
-			}
-			else{
-				loadPatientList();
-			}
-		}});
-    return false;
-}
-
-
 // ----------------------------------------------------------------
 // Click Back to main form
 // ----------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/relationshipPatient.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/relationshipPatient.js	2013-09-16 17:07:25 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/relationshipPatient.js	2013-10-25 05:00:41 +0000
@@ -22,95 +22,6 @@
 // Add Relationship Patient
 // -----------------------------------------------------------------------------
 
-function showAddRelationshipPatient( patientId, isShowPatientList, programStageInstanceId )
-{
-	hideById( 'selectDiv' );
-	hideById( 'searchDiv' );
-	hideById( 'listPatientDiv' );
-	hideById( 'listRelationshipDiv' );
-	hideById( 'patientDashboard' );
-	hideById( 'enrollmentDiv' );
-	setInnerHTML('editPatientDiv', '');
-	
-	jQuery('#loaderDiv').show();
-	jQuery('#addRelationshipDiv').load('showAddRelationshipPatient.action',
-		{
-			id:patientId,
-			programStageInstanceId: programStageInstanceId
-		}, function()
-		{
-			showById('addRelationshipDiv');
-			setFieldValue( 'isShowPatientList', isShowPatientList );
-			jQuery('#loaderDiv').hide();
-		});
-}
-
-function validateAddRelationshipPatient()
-{	
-	$.ajax({
-	   type: "POST",
-	   url: "validateAddRelationshipPatient.action",
-	   data: getParamsForDiv('addRelationshipDiv'),
-	   dataType: "xml",
-	   success:addRelationshipPatientCompleted
-	});
-	
-    return false;
-}
-
-function addRelationshipPatientCompleted( messageElement )
-{
-	messageElement = messageElement.getElementsByTagName( 'message' )[0];
-    var type = messageElement.getAttribute( 'type' );
-    var message = messageElement.firstChild.nodeValue;
-    
-    if ( type == 'success' )
-    {
-    	removeRelationshipDisabledIdentifier();
-    	addRelationshipPatient();
-    }
-    else if ( type == 'error' )
-    {
-        setHeaderMessage( i18n_adding_patient_failed + ':' + '\n' + message );
-    }
-    else if ( type == 'input' )
-    {
-        setHeaderMessage( message );
-    }
-    else if( type == 'duplicate' )
-    {
-    	if( !checkedDuplicate )
-		{
-    		showListPatientDuplicate(messageElement, true);
-		}
-    }
-}
-
-function addRelationshipPatient()
-{
-	jQuery('#loaderDiv').show();
-	var params = getParamsForDiv('addRelationshipDiv');
-		params += "&relationshipFromA=" + jQuery('#patientForm option:selected').attr("relationshipFromA");
-	$.ajax({
-		type: "POST",
-		url: 'addRelationshipPatient.action',
-		data: params,
-		success: function( json ) {
-			hideById('addRelationshipDiv');
-			showById('selectDiv');
-			showById('searchDiv');
-			showById('listPatientDiv');
-			jQuery('#loaderDiv').hide();
-
-			if( getFieldValue( 'isShowPatientList' ) == 'false' ){
-				showRelationshipList( getFieldValue('relationshipId') );
-			}
-			else{
-				loadPatientList();
-			}
-		}});
-    return false;
-}
 
 //remove value of all the disabled identifier fields
 //an identifier field is disabled when its value is inherited from another person ( underAge is true ) 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm	2013-09-23 09:42:21 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm	2013-10-25 05:00:41 +0000
@@ -219,7 +219,7 @@
 		<p class='header'>
 			$i18n.getString("relationships")
 			
-			#if( $auth.hasAccess( "dhis-web-caseentry", "showAddRelationshipPatient" ) )			
+			#if( $auth.hasAccess( "dhis-web-caseentry", "showRelationshipList" ) )			
 				&#8226; <a href="javascript:showRelationshipList( '$patient.id');">$i18n.getString("add_relative")</a>
 				<span id="patientRelatedStageSpan">&nbsp;<span>
 			#end

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/relationshipList.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/relationshipList.vm	2013-09-23 03:15:40 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/relationshipList.vm	2013-10-25 05:00:41 +0000
@@ -5,7 +5,7 @@
 </h5>
 <h3>	
 	&raquo; <a href="javascript:showAddRelationship('$patient.id')" >$i18n.getString( 'seach_available_patient' )</a>
-	&#8226; <a href="javascript:showAddRelationshipPatient( '$patient.id',false,'' )" >$i18n.getString( 'add_new_patient' )</a>
+	&#8226; <a href="javascript:showAddPatientForm( '$patient.id','','', true )" >$i18n.getString( 'add_new_patient' )</a>
 </h3>
 
 <input type="hidden" id="id" name="id" value="$patient.id">

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm	2013-10-21 07:40:21 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm	2013-10-25 05:00:41 +0000
@@ -12,7 +12,7 @@
 			<input type="text" id='orgunitName' readonly="readonly" #if( $organisationUnit ) value="$encoder.htmlEncode( $organisationUnit.name )" #else value="[$i18n.getString( 'please_select_village' )]" #end >
 		</td>
 		<td valign='bottom' id='criteriaBtnTD'>
-			<input type="button" id='addPatientBtn' name='addPatientBtn' class='large-button' value='$i18n.getString( "add_new" )' onclick="showAddPatientForm(getFieldValue('programIdAddPatient'),'', '');" >
+			<input type="button" id='addPatientBtn' name='addPatientBtn' class='large-button' value='$i18n.getString( "add_new" )' onclick="showAddPatientForm('', getFieldValue('programIdAddPatient'),'', false );" >
 		</td>
 	</tr>
 	<tr id='programAddPatientTR'>

=== modified 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	2013-10-24 08:31:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sectionDataEntryForm.vm	2013-10-25 05:00:41 +0000
@@ -82,15 +82,14 @@
 									</script> 
 								#elseif($hasOptionSet=='true')
 									#if( $programStageDataElement.dataElement.optionSet.options.size() <= 7 && $program.dataEntryMethod =='false' )
-										<input id='$id' name="entryfield" data-optionset="$!programStageDataElement.dataElement.optionSet.uid" options='$hasOptionSet' data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" class="auto-field optionset" />
-									#elseif( $programStageDataElement.dataElement.optionSet.options.size() <= 7 && $program.dataEntryMethod =='true' )
+										<input id='$id' name="entryfield" options='$hasOptionSet' optionset="$programStageDataElement.dataElement.optionSet.uid" data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" class="auto-field optionset" />									#elseif( $programStageDataElement.dataElement.optionSet.options.size() <= 7 && $program.dataEntryMethod =='true' )
 										<table style='width:100%'>
 											<tr>
 												<td>
-										<input id='$id' name="$id" options='no' type='radio'
-											data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" 
-											#if( $patientDataValue.value == $option) checked #end
-											onclick="saveRadio( '$programStageDataElement.dataElement.uid', '$option' )" tabindex="$tabIndex" />$i18n.getString("non_value")
+													<input id='$id' name="$id" type='radio' options='no' optionset="$programStageDataElement.dataElement.optionSet.uid"
+														data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" 
+														#if( $patientDataValue.value == $option) checked #end
+														onclick="saveRadio( '$programStageDataElement.dataElement.uid', '$option' )" tabindex="$tabIndex" />$i18n.getString("non_value")
 											</td>
 										#set($index=1)
 										#foreach($option in $programStageDataElement.dataElement.optionSet.options)
@@ -109,10 +108,10 @@
 										</tr>
 										</table>
 									#else
-										<input id='$id' name="entryfield" options='$hasOptionSet' data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" class="auto-field optionset" />
+										<input id='$id' name="entryfield" options='$hasOptionSet' optionset="$programStageDataElement.dataElement.optionSet.uid" data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" class="auto-field optionset" />
 									#end
 								#elseif($programStageDataElement.dataElement.type=='username')
-									<input name="entryfield" username='true' class="auto-field optionset" data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" id="$id" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" />
+									<input id='$id' name="entryfield" options='$hasOptionSet' optionset="$programStageDataElement.dataElement.optionSet.uid" data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" class="auto-field optionset" />
 								#else
 									<input name="entryfield" 
 										data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" onkeypress="return keyPress(event, this)" tabindex="$tabIndex"

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowAddProgramFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowAddProgramFormAction.java	2013-09-27 17:04:23 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowAddProgramFormAction.java	2013-10-25 05:00:41 +0000
@@ -141,6 +141,7 @@
     {
 
         programs = new ArrayList<Program>( programService.getAllPrograms() );
+        programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) );
         Collections.sort( programs, IdentifiableObjectNameComparator.INSTANCE );
        
       

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowUpdateProgramFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowUpdateProgramFormAction.java	2013-09-27 17:04:23 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/ShowUpdateProgramFormAction.java	2013-10-25 05:00:41 +0000
@@ -207,7 +207,8 @@
         availableAttributes.removeAll( new HashSet<PatientAttribute>( program.getPatientAttributes() ) );
         
         programs = new ArrayList<Program>( programService.getAllPrograms() );
-
+        programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) );
+        
         for ( Program p : programs )
         {
             availableIdentifierTypes