← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9679: Allow to define custom person registration form (WIP).

 

------------------------------------------------------------
revno: 9679
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-02-01 15:40:49 +0700
message:
  Allow to define custom person registration form (WIP).
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationForm.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationFormService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationFormStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientRegistrationFormService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientRegistrationFormStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientRegistrationForm.hbm.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/DelRegistrationFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/GetPatientRegistrationFormListAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/SavePatientRegistrationFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ShowPatientRegistrationFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewPatientRegistrationFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientRegistrationForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewPatientRegistationForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientRegistrationForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewPatientRegistationForm.vm
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.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/UpdatePatientAction.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/webapp/dhis-web-caseentry/patientForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewDataEntryFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/index.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientAttribute.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm


--
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/Patient.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java	2012-12-11 08:03:28 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java	2013-02-01 08:40:49 +0000
@@ -51,6 +51,7 @@
 
     public static final String MALE = "M";
     public static final String FEMALE = "F";
+    public static final String TRANSGENDER = "M";
 
     public static final char DOB_TYPE_VERIFIED = 'V';
     public static final char DOB_TYPE_DECLARED = 'D';

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationForm.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationForm.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationForm.java	2013-02-01 08:40:49 +0000
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.patient;
+
+import org.hisp.dhis.dataentryform.DataEntryForm;
+import org.hisp.dhis.program.Program;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version PatientRegistrationForm.java 9:33:02 AM Jan 31, 2013 $
+ */
+public class PatientRegistrationForm
+{
+    public static String FIXED_ATTRIBUTE_FULLNAME = "fullName";
+    public static String FIXED_ATTRIBUTE_GENDER = "gender";
+    public static String FIXED_ATTRIBUTE_BIRTHDATE = "birthDate";
+    public static String FIXED_ATTRIBUTE_PHONE_NUMBER = "phoneNumber";
+    public static String FIXED_ATTRIBUTE_DEATH_DATE = "deathDate";
+    public static String FIXED_ATTRIBUTE_REGISTRATION_DATE = "registrationDate";
+    public static String FIXED_ATTRIBUTE_IS_DEAD = "isDead";
+    public static String FIXED_ATTRIBUTE_DOB_TYPE = "dobType";
+    public static String FIXED_ATTRIBUTE_HEALTH_WORKER = "healthWorker";
+    
+    private Integer id;
+
+    private Program program;
+
+    private DataEntryForm dataEntryForm;
+
+    // -------------------------------------------------------------------------
+    // Constructors
+    // -------------------------------------------------------------------------
+
+    public PatientRegistrationForm()
+    {
+    }
+
+    public PatientRegistrationForm( Program program, DataEntryForm dataEntryForm )
+    {
+        this.program = program;
+        this.dataEntryForm = dataEntryForm;
+    }
+
+    // -------------------------------------------------------------------------
+    // Getters && Setters
+    // -------------------------------------------------------------------------
+
+    public Integer getId()
+    {
+        return id;
+    }
+
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+
+    public Program getProgram()
+    {
+        return program;
+    }
+
+    public void setProgram( Program program )
+    {
+        this.program = program;
+    }
+
+    public DataEntryForm getDataEntryForm()
+    {
+        return dataEntryForm;
+    }
+
+    public void setDataEntryForm( DataEntryForm dataEntryForm )
+    {
+        this.dataEntryForm = dataEntryForm;
+    }
+
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationFormService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationFormService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationFormService.java	2013-02-01 08:40:49 +0000
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.patient;
+
+import java.util.Collection;
+import java.util.regex.Pattern;
+
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.user.User;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version PatientRegistrationFormService.java 9:35:44 AM Jan 31, 2013 $
+ */
+public interface PatientRegistrationFormService
+{
+ 
+    final Pattern INPUT_PATTERN = Pattern.compile( "(<input.*?/>)", Pattern.DOTALL );
+    final Pattern FIXED_ATTRIBUTE_PATTERN = Pattern.compile( "fixedattributeid=\"(\\w+)\"" );
+    final Pattern IDENTIFIER_PATTERN = Pattern.compile( "identifierid=\"(\\w+)\"" );
+    final Pattern DYNAMIC_ATTRIBUTE_PATTERN = Pattern.compile( "attributeid=\"(\\w+)\"" );
+    final Pattern VALUE_TAG_PATTERN = Pattern.compile( "value=\"(.*?)\"", Pattern.DOTALL );
+    final Pattern TITLE_TAG_PATTERN = Pattern.compile( "title=\"(.*?)\"", Pattern.DOTALL );
+  
+    // --------------------------------------------------------------------------
+    // ProgramDataEntryService
+    // --------------------------------------------------------------------------
+
+    int savePatientRegistrationForm( PatientRegistrationForm registrationForm );
+
+    void deletePatientRegistrationForm( PatientRegistrationForm registrationForm );
+
+    void updatePatientRegistrationForm( PatientRegistrationForm registrationForm );
+
+    PatientRegistrationForm getPatientRegistrationForm( int id );
+    
+    Collection<PatientRegistrationForm> getAllPatientRegistrationForms();
+
+    PatientRegistrationForm getPatientRegistrationForm( Program program );
+    
+    PatientRegistrationForm getCommonPatientRegistrationForm();
+
+    String prepareDataEntryFormForAdd( String htmlCode, Collection<User> healthWorkers, Patient patient,  I18n i18n, I18nFormat format );
+        
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationFormStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationFormStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationFormStore.java	2013-02-01 08:40:49 +0000
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.patient;
+
+import org.hisp.dhis.common.GenericStore;
+import org.hisp.dhis.program.Program;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version PatientRegistrationFormStore.java 9:41:14 AM Jan 31, 2013 $
+ */
+public interface PatientRegistrationFormStore
+    extends GenericStore<PatientRegistrationForm>
+{
+    String ID = PatientRegistrationFormStore.class.getName();
+
+    PatientRegistrationForm get( Program program );
+    
+    PatientRegistrationForm getCommonForm();
+}

=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientRegistrationFormService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientRegistrationFormService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientRegistrationFormService.java	2013-02-01 08:40:49 +0000
@@ -0,0 +1,459 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.patient;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.regex.Matcher;
+
+import org.apache.commons.lang.StringUtils;
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
+import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.user.User;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version DefaultPatientRegistrationFormService.java 9:44:29 AM Jan 31, 2013 $
+ */
+@Transactional
+public class DefaultPatientRegistrationFormService
+    implements PatientRegistrationFormService
+{
+    private static final String TAG_OPEN = "<";
+
+    private static final String TAG_CLOSE = "/>";
+
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private PatientRegistrationFormStore formStore;
+
+    public void setFormStore( PatientRegistrationFormStore formStore )
+    {
+        this.formStore = formStore;
+    }
+
+    private PatientIdentifierTypeService identifierTypeService;
+
+    public void setIdentifierTypeService( PatientIdentifierTypeService identifierTypeService )
+    {
+        this.identifierTypeService = identifierTypeService;
+    }
+
+    private PatientIdentifierService identifierService;
+
+    public void setIdentifierService( PatientIdentifierService identifierService )
+    {
+        this.identifierService = identifierService;
+    }
+
+    private PatientAttributeService attributeService;
+
+    public void setAttributeService( PatientAttributeService attributeService )
+    {
+        this.attributeService = attributeService;
+    }
+
+    private PatientAttributeValueService attributeValueService;
+
+    public void setAttributeValueService( PatientAttributeValueService attributeValueService )
+    {
+        this.attributeValueService = attributeValueService;
+    }
+
+    // -------------------------------------------------------------------------
+    // PatientRegistrationForm implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public int savePatientRegistrationForm( PatientRegistrationForm registrationForm )
+    {
+        return formStore.save( registrationForm );
+    }
+
+    @Override
+    public void deletePatientRegistrationForm( PatientRegistrationForm registrationForm )
+    {
+        formStore.delete( registrationForm );
+    }
+
+    @Override
+    public void updatePatientRegistrationForm( PatientRegistrationForm registrationForm )
+    {
+        formStore.update( registrationForm );
+    }
+
+    @Override
+    public PatientRegistrationForm getPatientRegistrationForm( int id )
+    {
+        return formStore.get( id );
+    }
+
+    @Override
+    public Collection<PatientRegistrationForm> getAllPatientRegistrationForms()
+    {
+        return formStore.getAll();
+    }
+
+    @Override
+    public PatientRegistrationForm getPatientRegistrationForm( Program program )
+    {
+        return formStore.get( program );
+    }
+
+    @Override
+    public PatientRegistrationForm getCommonPatientRegistrationForm()
+    {
+        return formStore.getCommonForm();
+    }
+
+    @Override
+    public String prepareDataEntryFormForAdd( String htmlCode, Collection<User> healthWorkers, Patient patient,
+        I18n i18n, I18nFormat format )
+    {
+        int index = 1;
+
+        StringBuffer sb = new StringBuffer();
+
+        Matcher inputMatcher = INPUT_PATTERN.matcher( htmlCode );
+
+        while ( inputMatcher.find() )
+        {
+            // -----------------------------------------------------------------
+            // Get HTML input field code
+            // -----------------------------------------------------------------
+
+            String inputHtml = inputMatcher.group();
+            Matcher fixedAttrMatcher = FIXED_ATTRIBUTE_PATTERN.matcher( inputHtml );
+            Matcher identifierMatcher = IDENTIFIER_PATTERN.matcher( inputHtml );
+            Matcher dynamicAttrMatcher = DYNAMIC_ATTRIBUTE_PATTERN.matcher( inputHtml );
+            index++;
+
+            if ( fixedAttrMatcher.find() && fixedAttrMatcher.groupCount() > 0 )
+            {
+                String fixedAttr = fixedAttrMatcher.group( 1 );
+
+                // Get value
+                String value = "";
+                if ( patient != null )
+                {
+                    Object object = getValueFromPatient( StringUtils.capitalize( fixedAttr ), patient );
+                    if ( object != null )
+                    {
+                        if ( object instanceof Date )
+                        {
+                            value = format.formatDate( (Date) object );
+                        }
+                        else if ( object instanceof User )
+                        {
+                            value = ((User) object).getId() + "";
+                        }
+                        else
+                        {
+                            value = object.toString();
+                        }
+                    }
+                }
+
+                inputHtml = getFixedAttributeField( inputHtml, fixedAttr, value.toString(), healthWorkers, i18n, index );
+            }
+            else if ( identifierMatcher.find() && identifierMatcher.groupCount() > 0 )
+            {
+                Integer id = Integer.parseInt( identifierMatcher.group( 1 ) );
+                PatientIdentifierType identifierType = identifierTypeService.getPatientIdentifierType( id );
+
+                // Get value
+                String value = "";
+                if ( patient != null )
+                {
+                    PatientIdentifier patientIdentifier = identifierService.getPatientIdentifier( identifierType,
+                        patient );
+                    if ( patientIdentifier != null )
+                    {
+                        value = patientIdentifier.getIdentifier();
+                    }
+                }
+
+                inputHtml = "<input id=\"iden" + id + "\" name=\"iden" + id + "\" tabindex=\"" + index + "\" value=\""
+                    + value + "\" ";
+
+                inputHtml += "class=\"{validate:{required:" + identifierType.isMandatory() + ",";
+                if ( identifierType.getNoChars() != null )
+                {
+                    inputHtml += "maxlength:" + identifierType.getNoChars() + ",";
+                }
+
+                if ( PatientIdentifierType.VALUE_TYPE_NUMBER.equals( identifierType.getType() ) )
+                {
+                    inputHtml += "number:true";
+                }
+                else if ( PatientIdentifierType.VALUE_TYPE_LETTER.equals( identifierType.getType() ) )
+                {
+                    inputHtml += "lettersonly:true";
+                }
+                inputHtml += "}}\" " + TAG_CLOSE;
+            }
+            else if ( dynamicAttrMatcher.find() && dynamicAttrMatcher.groupCount() > 0 )
+            {
+                Integer id = Integer.parseInt( dynamicAttrMatcher.group( 1 ) );
+                PatientAttribute attribute = attributeService.getPatientAttribute( id );
+
+                // Get value
+                String value = "";
+                if ( patient != null )
+                {
+                    PatientAttributeValue attributeValue = attributeValueService.getPatientAttributeValue( patient,
+                        attribute );
+                    if ( attributeValue != null )
+                    {
+                        value = attributeValue.getValue();
+                    }
+                }
+
+                inputHtml = getAttributeField( inputHtml, attribute, value, i18n, index );
+            }
+
+            inputMatcher.appendReplacement( sb, inputHtml );
+        }
+
+        inputMatcher.appendTail( sb );
+
+        return sb.toString();
+    }
+
+    // -------------------------------------------------------------------------
+    // Supportive methods
+    // -------------------------------------------------------------------------
+
+    private String getAttributeField( String inputHtml, PatientAttribute attribute, String value, I18n i18n, int index )
+    {
+        inputHtml = TAG_OPEN + "input id=\"attr" + attribute.getId() + "\" name=\"attr" + attribute.getId()
+            + "\" tabindex=\"" + index + "\" ";
+
+        inputHtml += "\" class=\"{validate:{required:" + attribute.isMandatory();
+        if ( PatientAttribute.TYPE_INT.equals( attribute.getValueType() ) )
+        {
+            inputHtml += ",number:true";
+        }
+        inputHtml += "}}\" ";
+
+        if ( attribute.getValueType().equals( PatientAttribute.TYPE_BOOL ) )
+        {
+            inputHtml = inputHtml.replaceFirst( "input", "select" ) + ">";
+
+            if ( value.equals( "" ) )
+            {
+                inputHtml += "<option value=\"\" selected>" + i18n.getString( "no_value" ) + "</option>";
+                inputHtml += "<option value=\"true\">" + i18n.getString( "yes" ) + "</option>";
+                inputHtml += "<option value=\"false\">" + i18n.getString( "no" ) + "</option>";
+            }
+            else if ( value.equals( "true" ) )
+            {
+                inputHtml += "<option value=\"\">" + i18n.getString( "no_value" ) + "</option>";
+                inputHtml += "<option value=\"true\" selected >" + i18n.getString( "yes" ) + "</option>";
+                inputHtml += "<option value=\"false\">" + i18n.getString( "no" ) + "</option>";
+            }
+            else if ( value.equals( "false" ) )
+            {
+                inputHtml += "<option value=\"\">" + i18n.getString( "no_value" ) + "</option>";
+                inputHtml += "<option value=\"true\">" + i18n.getString( "yes" ) + "</option>";
+                inputHtml += "<option value=\"false\" selected >" + i18n.getString( "no" ) + "</option>";
+            }
+
+            inputHtml += "</select>";
+        }
+        else if ( attribute.getValueType().equals( PatientAttribute.TYPE_COMBO ) )
+        {
+            inputHtml = inputHtml.replaceFirst( "input", "select" ) + ">";
+
+            for ( PatientAttributeOption option : attribute.getAttributeOptions() )
+            {
+                inputHtml += "<option value=\"" + option.getName() + "\" ";
+                if ( option.getName().equals( value ) )
+                {
+                    inputHtml += " selected ";
+                }
+                inputHtml += ">" + option.getName() + "</option>";
+            }
+            inputHtml += "</select>";
+        }
+        else if ( attribute.getValueType().equals( PatientAttribute.TYPE_DATE ) )
+        {
+            String jQueryCalendar = "<script>datePicker(\"attr" + attribute.getId() + "\", false);</script>";
+            inputHtml += " value=\"" + value + "\"" + TAG_CLOSE;
+            inputHtml += jQueryCalendar;
+        }
+        else
+        {
+            inputHtml += TAG_CLOSE;
+        }
+        return inputHtml;
+    }
+
+    private String getFixedAttributeField( String inputHtml, String fixedAttr, String value,
+        Collection<User> healthWorkers, I18n i18n, int index )
+    {
+        inputHtml = TAG_OPEN + "input id=\"" + fixedAttr + "\" name=\"" + fixedAttr + "\" tabindex=\"" + index
+            + "\" value=\"" + value + "\" ";
+
+        // Fullname fields
+        if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_FULLNAME ) )
+        {
+            inputHtml += " class=\"{validate:{required:true, rangelength:[3,50]}}\" " + TAG_CLOSE;
+        }
+
+        // Phone number fields
+        else if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_PHONE_NUMBER ) )
+        {
+            inputHtml += " class=\"{validate:{phone:true}}\" " + TAG_CLOSE;
+        }
+
+        // Gender selector
+        if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_GENDER ) )
+        {
+            inputHtml = inputHtml.replaceFirst( "input", "select" ) + ">";
+
+            if ( value.equals( "" ) || value.equals( Patient.FEMALE ) )
+            {
+                inputHtml += "<option value=\"M\" >" + i18n.getString( "male" ) + "</option>";
+                inputHtml += "<option value=\"F\" selected >" + i18n.getString( "female" ) + "</option>";
+                inputHtml += "<option value=\"T\">" + i18n.getString( "transgender" ) + "</option>";
+            }
+            else if ( value.equals( Patient.MALE ) )
+            {
+                inputHtml += "<option value=\"M\" selected >" + i18n.getString( "male" ) + "</option>";
+                inputHtml += "<option value=\"F\">" + i18n.getString( "female" ) + "</option>";
+                inputHtml += "<option value=\"T\">" + i18n.getString( "transgender" ) + "</option>";
+            }
+            else if ( value.equals( Patient.TRANSGENDER ) )
+            {
+                inputHtml += "<option value=\"M\">" + i18n.getString( "male" ) + "</option>";
+                inputHtml += "<option value=\"F\">" + i18n.getString( "female" ) + "</option>";
+                inputHtml += "<option value=\"T\" selected >" + i18n.getString( "transgender" ) + "</option>";
+            }
+            inputHtml += "</select>";
+        }
+
+        // Date field
+        else if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_BIRTHDATE )
+            || fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_DEATH_DATE )
+            || fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_REGISTRATION_DATE ) )
+        {
+            inputHtml += TAG_CLOSE;
+            if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_BIRTHDATE )
+                || fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_REGISTRATION_DATE ) )
+            {
+                inputHtml += "<script>datePicker(\"" + fixedAttr + "\", true);</script>";
+            }
+            else
+            {
+                inputHtml += "<script>datePicker(\"" + fixedAttr + "\", false);</script>";
+            }
+        }
+
+        // DobType field
+        else if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_DOB_TYPE ) )
+        {
+            inputHtml = inputHtml.replaceFirst( "input", "select" ) + ">";
+
+            if ( value.equals( "" ) || value.equals( Patient.DOB_TYPE_VERIFIED + "" ) )
+            {
+                inputHtml += "<option value=\"V\" selected >" + i18n.getString( "verified" ) + "</option>";
+                inputHtml += "<option value=\"D\">" + i18n.getString( "declared" ) + "</option>";
+                inputHtml += "<option value=\"A\">" + i18n.getString( "approximated" ) + "</option>";
+            }
+            else if ( value.equals( Patient.DOB_TYPE_DECLARED + "" ) )
+            {
+                inputHtml += "<option value=\"V\">" + i18n.getString( "verified" ) + "</option>";
+                inputHtml += "<option value=\"D\" selected >" + i18n.getString( "declared" ) + "</option>";
+                inputHtml += "<option value=\"A\">" + i18n.getString( "approximated" ) + "</option>";
+            }
+            else if ( value.equals( Patient.DOB_TYPE_APPROXIATED + "" ) )
+            {
+                inputHtml += "<option value=\"V\">" + i18n.getString( "verified" ) + "</option>";
+                inputHtml += "<option value=\"D\">" + i18n.getString( "declared" ) + "</option>";
+                inputHtml += "<option value=\"A\" selected >" + i18n.getString( "approximated" ) + "</option>";
+            }
+
+            inputHtml += "</select>";
+        }
+
+        // Health-worker field
+        else if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_HEALTH_WORKER ) )
+        {
+            inputHtml = inputHtml.replaceFirst( "input", "select" ) + ">";
+            inputHtml += "<option value=\"\" selected >" + i18n.getString( "please_select" ) + "</option>";
+
+            for ( User healthWorker : healthWorkers )
+            {
+                inputHtml += "<option value=\"" + healthWorker.getId() + "\" ";
+                if ( value.equals( healthWorker.getId() + "" ) )
+                {
+                    inputHtml += " selected ";
+                }
+                inputHtml += ">" + healthWorker.getName() + "</option>";
+            }
+            inputHtml += "</select>";
+        }
+
+        // IsDead field
+        else if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_IS_DEAD ) )
+        {
+            inputHtml += " type='checkbox' ";
+
+            if ( value.equals( "true" ) )
+            {
+                inputHtml += " checked ";
+            }
+
+            inputHtml += TAG_CLOSE;
+        }
+
+        return inputHtml;
+    }
+
+    private Object getValueFromPatient( String property, Patient patient )
+    {
+        try
+        {
+            return Patient.class.getMethod( "get" + property ).invoke( patient );
+        }
+        catch ( Exception ex )
+        {
+            ex.printStackTrace();
+        }
+        return null;
+    }
+
+}

=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientRegistrationFormStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientRegistrationFormStore.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientRegistrationFormStore.java	2013-02-01 08:40:49 +0000
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.patient.hibernate;
+
+import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.hibernate.HibernateGenericStore;
+import org.hisp.dhis.patient.PatientRegistrationForm;
+import org.hisp.dhis.patient.PatientRegistrationFormStore;
+import org.hisp.dhis.program.Program;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version HibernatePatientRegistrationFormStore.java 10:07:23 AM Jan 31, 2013
+ *          $
+ */
+public class HibernatePatientRegistrationFormStore
+    extends HibernateGenericStore<PatientRegistrationForm>
+    implements PatientRegistrationFormStore
+{
+    @Override
+    public PatientRegistrationForm get( Program program )
+    {
+        return (PatientRegistrationForm) getCriteria( Restrictions.eq( "program", program ) ).uniqueResult();
+    }
+
+    @Override
+    public PatientRegistrationForm getCommonForm()
+    {
+        return (PatientRegistrationForm) getCriteria( Restrictions.isNull( "program" ) ).uniqueResult();
+    }
+}

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2013-01-28 05:28:45 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2013-02-01 08:40:49 +0000
@@ -486,6 +486,27 @@
 		parent="abstractRunCaseAggregateConditionTask">
 	</bean>
 
+	<!-- PatientRegistrationForm -->
+
+	<bean id="org.hisp.dhis.patient.PatientRegistrationFormService"
+		class="org.hisp.dhis.patient.DefaultPatientRegistrationFormService">
+		<property name="formStore"
+			ref="org.hisp.dhis.patient.PatientRegistrationFormStore" />
+		<property name="identifierTypeService"
+			ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
+		<property name="identifierService"
+			ref="org.hisp.dhis.patient.PatientIdentifierService" />
+		<property name="attributeService"
+			ref="org.hisp.dhis.patient.PatientAttributeService" />
+		<property name="attributeValueService"
+			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
+	</bean>
+
+	<bean id="org.hisp.dhis.patient.PatientRegistrationFormStore" class="org.hisp.dhis.patient.hibernate.HibernatePatientRegistrationFormStore">
+		<property name="clazz" value="org.hisp.dhis.patient.PatientRegistrationForm" />
+		<property name="sessionFactory" ref="sessionFactory" />
+	</bean>
+	
 	<!-- Startup -->
 
 	<bean id="org.hisp.dhis.patient.startup.TableAlteror" class="org.hisp.dhis.patient.startup.TableAlteror">

=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientRegistrationForm.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientRegistrationForm.hbm.xml	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientRegistrationForm.hbm.xml	2013-02-01 08:40:49 +0000
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";>
+
+<hibernate-mapping>
+  <class name="org.hisp.dhis.patient.PatientRegistrationForm" table="patientregistrationform">
+
+    <id name="id" column="patientregistrationformid">
+      <generator class="native" />
+    </id>
+
+    <many-to-one name="program" class="org.hisp.dhis.program.Program" column="programid"
+      foreign-key="fk_patientregistrationform_programid" />
+
+    <many-to-one name="dataEntryForm" class="org.hisp.dhis.dataentryform.DataEntryForm"
+      foreign-key="fk_patientregistrationform_dataentryformid" cascade="all" />
+      
+  </class>
+</hibernate-mapping>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java	2012-09-12 04:14:03 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java	2013-02-01 08:40:49 +0000
@@ -113,7 +113,11 @@
 
     private Integer relationshipTypeId;
 
-    private Integer healthWorkerId;
+    private Integer healthWorker;
+
+    private boolean isDead;
+
+    private String deathDate;
 
     private String message;
 
@@ -174,11 +178,18 @@
         patient.setPhoneNumber( phoneNumber );
         patient.setUnderAge( underAge );
         patient.setOrganisationUnit( organisationUnit );
-        if ( healthWorkerId != null )
+        patient.setIsDead( isDead );
+        if ( deathDate != null )
         {
-            patient.setHealthWorker( userService.getUser( healthWorkerId ) );
+            deathDate = deathDate.trim();
+            patient.setDeathDate( format.parseDate( deathDate ) );
         }
         
+        if ( healthWorker != null )
+        {
+            patient.setHealthWorker( userService.getUser( healthWorker ) );
+        }
+
         Character dobType = (verified) ? 'V' : 'D';
 
         if ( !verified && age != null )
@@ -330,9 +341,9 @@
         return message;
     }
 
-    public void setHealthWorkerId( Integer healthWorkerId )
+    public void setHealthWorker( Integer healthWorker )
     {
-        this.healthWorkerId = healthWorkerId;
+        this.healthWorker = healthWorker;
     }
 
     public void setVerified( Boolean verified )

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java	2012-12-12 09:15:45 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java	2013-02-01 08:40:49 +0000
@@ -32,6 +32,8 @@
 import java.util.List;
 import java.util.Map;
 
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patient.PatientAttribute;
 import org.hisp.dhis.patient.PatientAttributeGroup;
@@ -40,6 +42,8 @@
 import org.hisp.dhis.patient.PatientIdentifierService;
 import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.patient.PatientIdentifierTypeService;
+import org.hisp.dhis.patient.PatientRegistrationForm;
+import org.hisp.dhis.patient.PatientRegistrationFormService;
 import org.hisp.dhis.patient.PatientService;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
@@ -66,8 +70,6 @@
 
     private PatientService patientService;
 
-    private PatientIdentifierService patientIdentifierService;
-
     private ProgramService programService;
 
     private PatientAttributeValueService patientAttributeValueService;
@@ -80,6 +82,12 @@
 
     private RelationshipTypeService relationshipTypeService;
 
+    private PatientRegistrationFormService patientRegistrationFormService;
+
+    private I18n i18n;
+
+    private I18nFormat format;
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -114,6 +122,20 @@
 
     private Collection<User> healthWorkers;
 
+    private Integer programId;
+
+    public void setProgramId( Integer programId )
+    {
+        this.programId = programId;
+    }
+
+    private String customRegistrationForm;
+
+    public String getCustomRegistrationForm()
+    {
+        return customRegistrationForm;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -123,135 +145,159 @@
     {
         relationshipTypes = relationshipTypeService.getAllRelationshipTypes();
 
-        // -------------------------------------------------------------------------
-        // Get identifier-types && attributes
-        // -------------------------------------------------------------------------
-
         patient = patientService.getPatient( id );
 
-        programs = programService.getAllPrograms();
-
-        // -------------------------------------------------------------------------
-        // Get identifier-types && attributes
-        // -------------------------------------------------------------------------
-
-        identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
-        Collection<PatientAttribute> patientAttributes = patientAttributeService.getAllPatientAttributes();
-
-        Collection<Program> programs = programService.getAllPrograms();
-        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 );
-            }
-        }
-
-        // -------------------------------------------------------------------------
-        // Get data
-        // -------------------------------------------------------------------------
-
-        identiferMap = new HashMap<Integer, String>();
-
-        PatientIdentifierType idType = null;
-        Patient representative = patient.getRepresentative();
-        relationship = relationshipService.getRelationship( representative, patient );
-
-        if ( patient.isUnderAge() && representative != null )
-        {
-            for ( PatientIdentifier representativeIdentifier : representative.getIdentifiers() )
-            {
-                if ( representativeIdentifier.getIdentifierType() != null
-                    && representativeIdentifier.getIdentifierType().isRelated() )
-                {
-                    identiferMap.put( representativeIdentifier.getIdentifierType().getId(),
-                        representativeIdentifier.getIdentifier() );
-                }
-            }
-        }
-
-        for ( PatientIdentifier identifier : patient.getIdentifiers() )
-        {
-            idType = identifier.getIdentifierType();
-
-            if ( idType != null )
-            {
-                identiferMap.put( identifier.getIdentifierType().getId(), identifier.getIdentifier() );
-            }
-            else
-            {
-                systemIdentifier = identifier.getIdentifier();
-            }
-        }
-
-        // -------------------------------------------------------------------------
-        // Get patient-attribute values
-        // -------------------------------------------------------------------------
-
-        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 );
-            }
-        }
-
-        Collection<PatientAttributeValue> patientAttributeValues = patientAttributeValueService
-            .getPatientAttributeValues( patient );
-
-        for ( PatientAttributeValue patientAttributeValue : patientAttributeValues )
-        {
-            if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( patientAttributeValue.getPatientAttribute()
-                .getValueType() ) )
-            {
-                patientAttributeValueMap.put( patientAttributeValue.getPatientAttribute().getId(),
-                    patientAttributeValue.getPatientAttributeOption().getName() );
-            }
-            else
-            {
-                patientAttributeValueMap.put( patientAttributeValue.getPatientAttribute().getId(),
-                    patientAttributeValue.getValue() );
-            }
-        }
-
         healthWorkers = patient.getOrganisationUnit().getUsers();
 
+        if ( programId == null )
+        {
+            PatientRegistrationForm patientRegistrationForm = patientRegistrationFormService
+                .getCommonPatientRegistrationForm();
+
+            if ( patientRegistrationForm != null )
+            {
+                customRegistrationForm = patientRegistrationFormService.prepareDataEntryFormForAdd(
+                    patientRegistrationForm.getDataEntryForm().getHtmlCode(), healthWorkers, patient, i18n, format );
+            }
+        }
+        else
+        {
+            Program program = programService.getProgram( programId );
+            PatientRegistrationForm patientRegistrationForm = patientRegistrationFormService
+                .getPatientRegistrationForm( program );
+            customRegistrationForm = patientRegistrationFormService.prepareDataEntryFormForAdd( patientRegistrationForm
+                .getDataEntryForm().getHtmlCode(), healthWorkers, patient, i18n, format );
+        }
+
+        if ( customRegistrationForm == null )
+        {
+
+            // -------------------------------------------------------------------------
+            // Get identifier-types && attributes
+            // -------------------------------------------------------------------------
+
+            programs = programService.getAllPrograms();
+
+            // -------------------------------------------------------------------------
+            // Get identifier-types && attributes
+            // -------------------------------------------------------------------------
+
+            identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
+            Collection<PatientAttribute> patientAttributes = patientAttributeService.getAllPatientAttributes();
+
+            Collection<Program> programs = programService.getAllPrograms();
+            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 );
+                }
+            }
+
+            // -------------------------------------------------------------------------
+            // Get data
+            // -------------------------------------------------------------------------
+
+            identiferMap = new HashMap<Integer, String>();
+
+            PatientIdentifierType idType = null;
+            Patient representative = patient.getRepresentative();
+            relationship = relationshipService.getRelationship( representative, patient );
+
+            if ( patient.isUnderAge() && representative != null )
+            {
+                for ( PatientIdentifier representativeIdentifier : representative.getIdentifiers() )
+                {
+                    if ( representativeIdentifier.getIdentifierType() != null
+                        && representativeIdentifier.getIdentifierType().isRelated() )
+                    {
+                        identiferMap.put( representativeIdentifier.getIdentifierType().getId(),
+                            representativeIdentifier.getIdentifier() );
+                    }
+                }
+            }
+
+            for ( PatientIdentifier identifier : patient.getIdentifiers() )
+            {
+                idType = identifier.getIdentifierType();
+
+                if ( idType != null )
+                {
+                    identiferMap.put( identifier.getIdentifierType().getId(), identifier.getIdentifier() );
+                }
+                else
+                {
+                    systemIdentifier = identifier.getIdentifier();
+                }
+            }
+
+            // -------------------------------------------------------------------------
+            // Get patient-attribute values
+            // -------------------------------------------------------------------------
+
+            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 );
+                }
+            }
+
+            Collection<PatientAttributeValue> patientAttributeValues = patientAttributeValueService
+                .getPatientAttributeValues( patient );
+
+            for ( PatientAttributeValue patientAttributeValue : patientAttributeValues )
+            {
+                if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( patientAttributeValue.getPatientAttribute()
+                    .getValueType() ) )
+                {
+                    patientAttributeValueMap.put( patientAttributeValue.getPatientAttribute().getId(),
+                        patientAttributeValue.getPatientAttributeOption().getName() );
+                }
+                else
+                {
+                    patientAttributeValueMap.put( patientAttributeValue.getPatientAttribute().getId(),
+                        patientAttributeValue.getValue() );
+                }
+            }
+        }
+
         return SUCCESS;
 
     }
@@ -260,6 +306,21 @@
     // Getter / Setter
     // -----------------------------------------------------------------------------
 
+    public void setPatientRegistrationFormService( PatientRegistrationFormService patientRegistrationFormService )
+    {
+        this.patientRegistrationFormService = patientRegistrationFormService;
+    }
+
+    public void setI18n( I18n i18n )
+    {
+        this.i18n = i18n;
+    }
+
+    public void setFormat( I18nFormat format )
+    {
+        this.format = format;
+    }
+
     public void setRelationshipTypeService( RelationshipTypeService relationshipTypeService )
     {
         this.relationshipTypeService = relationshipTypeService;
@@ -290,11 +351,6 @@
         return relationship;
     }
 
-    public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService )
-    {
-        this.patientIdentifierService = patientIdentifierService;
-    }
-
     public void setProgramService( ProgramService programService )
     {
         this.programService = programService;

=== 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	2012-09-15 04:18:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java	2013-02-01 08:40:49 +0000
@@ -32,6 +32,8 @@
 import java.util.HashSet;
 import java.util.Map;
 
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
 import org.hisp.dhis.patient.PatientAttribute;
@@ -39,6 +41,8 @@
 import org.hisp.dhis.patient.PatientAttributeService;
 import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.patient.PatientIdentifierTypeService;
+import org.hisp.dhis.patient.PatientRegistrationForm;
+import org.hisp.dhis.patient.PatientRegistrationFormService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.user.User;
@@ -84,17 +88,45 @@
         this.programService = programService;
     }
 
+    private PatientRegistrationFormService patientRegistrationFormService;
+
+    public void setPatientRegistrationFormService( PatientRegistrationFormService patientRegistrationFormService )
+    {
+        this.patientRegistrationFormService = patientRegistrationFormService;
+    }
+
+    private I18n i18n;
+
+    public void setI18n( I18n i18n )
+    {
+        this.i18n = i18n;
+    }
+
+    private I18nFormat format;
+
+    public void setFormat( I18nFormat format )
+    {
+        this.format = format;
+    }
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
 
+    private Integer programId;
+
+    public void setProgramId( Integer programId )
+    {
+        this.programId = programId;
+    }
+
     private Collection<User> healthWorkers;
-    
+
     public Collection<User> getHealthWorkers()
     {
         return healthWorkers;
     }
-    
+
     private Collection<PatientAttribute> noGroupAttributes = new HashSet<PatientAttribute>();
 
     public Collection<PatientAttribute> getNoGroupAttributes()
@@ -123,53 +155,80 @@
         return attributeGroupsMap;
     }
 
+    private String customRegistrationForm;
+
+    public String getCustomRegistrationForm()
+    {
+        return customRegistrationForm;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
 
     public String execute()
     {
-        identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
-        Collection<PatientAttribute> patientAttributes = patientAttributeService.getAllPatientAttributes();
-        Collection<Program> programs = programService.getAllPrograms();
-        for ( Program program : programs )
-        {
-            identifierTypes.removeAll( program.getPatientIdentifierTypes() );
-            patientAttributes.removeAll( program.getPatientAttributes() );
-        }
-
-        attributeGroupsMap = new HashMap<PatientAttributeGroup, Collection<PatientAttribute>>();
-        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 );
-            }
-        }
-
         organisationUnit = selectionManager.getSelectedOrganisationUnit();
         healthWorkers = organisationUnit.getUsers();
-        
+
+        if ( programId == null )
+        {
+            PatientRegistrationForm patientRegistrationForm = patientRegistrationFormService
+                .getCommonPatientRegistrationForm();
+
+            if ( patientRegistrationForm != null )
+            {
+                customRegistrationForm = patientRegistrationFormService.prepareDataEntryFormForAdd( patientRegistrationForm
+                    .getDataEntryForm().getHtmlCode(), healthWorkers, null, i18n, format );
+            }
+        }
+        else
+        {
+            Program program = programService.getProgram( programId );
+            PatientRegistrationForm patientRegistrationForm = patientRegistrationFormService
+                .getPatientRegistrationForm( program );
+            customRegistrationForm = patientRegistrationFormService.prepareDataEntryFormForAdd( patientRegistrationForm
+                .getDataEntryForm().getHtmlCode(), healthWorkers, null, i18n, format );
+        }
+
+        if ( customRegistrationForm == null )
+        {
+            identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
+            Collection<PatientAttribute> patientAttributes = patientAttributeService.getAllPatientAttributes();
+            Collection<Program> programs = programService.getAllPrograms();
+            for ( Program program : programs )
+            {
+                identifierTypes.removeAll( program.getPatientIdentifierTypes() );
+                patientAttributes.removeAll( program.getPatientAttributes() );
+            }
+
+            attributeGroupsMap = new HashMap<PatientAttributeGroup, Collection<PatientAttribute>>();
+            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 );
+                }
+            }
+
+        }
+
         return SUCCESS;
     }
 
-    // -------------------------------------------------------------------------
-    // Getter/Setter
-    // -------------------------------------------------------------------------
-
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java	2012-09-19 07:32:38 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java	2013-02-01 08:40:49 +0000
@@ -111,10 +111,12 @@
 
     private Integer relationshipTypeId;
 
-    private Integer healthWorkerId;
+    private Integer healthWorker;
 
     private Character dobType;
 
+    private String registrationDate;
+
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
@@ -171,9 +173,9 @@
         patient.setGender( gender );
         patient.setIsDead( isDead );
         patient.setPhoneNumber( phoneNumber );
-        if ( healthWorkerId != null )
+        if ( healthWorker != null )
         {
-            patient.setHealthWorker( userService.getUser( healthWorkerId ) );
+            patient.setHealthWorker( userService.getUser( healthWorker ) );
         }
 
         if ( deathDate != null )
@@ -181,7 +183,7 @@
             deathDate = deathDate.trim();
             patient.setDeathDate( format.parseDate( deathDate ) );
         }
-        
+
         patient.setUnderAge( underAge );
         patient.setOrganisationUnit( organisationUnit );
 
@@ -197,6 +199,11 @@
 
         patient.setDobType( dobType );
 
+        if ( registrationDate != null )
+        {
+            patient.setRegistrationDate( format.parseDate( registrationDate ) );
+        }
+
         // -------------------------------------------------------------------------------------
         // Save PatientIdentifier
         // -------------------------------------------------------------------------------------
@@ -333,7 +340,7 @@
     // -----------------------------------------------------------------------------
     // Getter/Setter
     // -----------------------------------------------------------------------------
-    
+
     public void setUserService( UserService userService )
     {
         this.userService = userService;
@@ -341,7 +348,7 @@
 
     public void setHealthWorkerId( Integer healthWorkerId )
     {
-        this.healthWorkerId = healthWorkerId;
+        this.healthWorker = healthWorkerId;
     }
 
     public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService )
@@ -453,4 +460,10 @@
     {
         this.verified = verified;
     }
+
+    public void setRegistrationDate( String registrationDate )
+    {
+        this.registrationDate = registrationDate;
+    }
+
 }

=== 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-01-24 06:30:16 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-02-01 08:40:49 +0000
@@ -417,8 +417,6 @@
 	<bean id="org.hisp.dhis.caseentry.action.patient.GetPatientAction"
 		class="org.hisp.dhis.caseentry.action.patient.GetPatientAction" scope="prototype">
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
-		<property name="patientIdentifierService"
-			ref="org.hisp.dhis.patient.PatientIdentifierService" />
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 		<property name="patientAttributeValueService"
 			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
@@ -431,6 +429,8 @@
 			ref="org.hisp.dhis.relationship.RelationshipService" />
 		<property name="relationshipTypeService"
 			ref="org.hisp.dhis.relationship.RelationshipTypeService" />
+		<property name="patientRegistrationFormService"
+			ref="org.hisp.dhis.patient.PatientRegistrationFormService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.caseentry.action.patient.AddPatientAction"
@@ -492,6 +492,9 @@
 		<property name="programService">
 			<ref bean="org.hisp.dhis.program.ProgramService" />
 		</property>
+		<property name="patientRegistrationFormService">
+			<ref bean="org.hisp.dhis.patient.PatientRegistrationFormService" />
+		</property>
 	</bean>
 
 	<bean id="org.hisp.dhis.caseentry.action.patient.ValidatePatientAction"

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm	2013-01-28 05:28:45 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm	2013-02-01 08:40:49 +0000
@@ -1,223 +1,227 @@
-## Macro for generating the jQuery validation rules 
-#macro( validate $type $require )
-  #if( $type == "NUMBER" )
-  	{validate:{ number:true #if($require), required:true #end }}
-  #elseif( $require )
-  	{validate:{required:true}}
-  #end
-#end
-
-<tr id='registrationDateTR'>
-	<td class='text-column'><label for="registration_date">$i18n.getString( "registration_date" )<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
-	<td class="input-column" colspan='2'>
-		<input type="text" id="registrationDate" name="registrationDate" class="{validate:{required:true}}"/>
-		<script type="text/javascript">
-			datePickerValid( 'registrationDate', true );
-		</script>    
-	</td>		
-</tr>
-
-<tr>
-	<th colspan="2" class="heading-column">$i18n.getString( "demographics" )</th>
-</tr>
-
-<tr>
-	<td class='text-column'><label for="fullName">$i18n.getString( "full_name" )<em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-	<td class="input-column"><input type="text" id="fullName" name="fullName" value="$!patient.getFullName()" class="{validate:{required:true, rangelength:[3,50]}}"></td>
-</tr>
-
-<tr>
-	<td class='text-column'><label for="gender">$i18n.getString( "gender" )<em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-	<td class="input-column">
-		<select id="gender" name="gender">
-			<option value="M" #if( $!patient.gender == 'M' ) selected="selected" #end>$i18n.getString( "male" )</option>
-			<option value="F" #if( $!patient.gender == 'F' ) selected="selected" #end>$i18n.getString( "female" )</option>
-			<option value="T" #if( $!patient.gender == 'T' ) selected="selected" #end>$i18n.getString( "transgender" )</option>
-		</select>
-	</td>					
-</tr>
-
-<tr>
-	<td class='text-column' ><label for="birthDate">$i18n.getString( "date_of_birth" )<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
-	<td class="input-column">
-		<select id='dobType' name="dobType" style='width:120px' onchange='dobTypeOnChange("patientForm")' >
-			<option value="V" #if($patient.dobType=='V') selected #end >$i18n.getString( "verified" )</option>
-			<option value="D" #if($patient.dobType=='D') selected #end >$i18n.getString( "declared" )</option>
-			<option value="A" #if($patient.dobType=='A') selected #end >$i18n.getString( "approximated" )</option>
-		</select>
-		<input type="text" id="birthDate" name="birthDate" value='$!format.formatDate($!patient.birthDate)' style='width:136px;' />
-		<input type="text" id="age" name="age" placeholder="Enter age in years..." value='$!patient.getIntegerValueOfAge()' class="{validate:{number:true}}" style='width:136px;' />
-	</td>
-</tr>
-
-<tr>
-	<td></td>
-	<td class="input-column">
-		<input id="memberValidator" class="hidden {validate:{required:true}}"/>
-	</td>
-</tr>
-
-<tr>
-	<td class='text-column'><label for="phoneNumber">$i18n.getString( "phone_number" )</label></td>
-	<td class="input-column">
-		<input type="text" id="phoneNumber" name="phoneNumber" #if( $!patient.phoneNumber ) value="$!patient.phoneNumber" #else value="$!phoneNumberAreaCode" #end class="{validate:{phone:true}}"/>
-	</td>
-</tr>
-
-<tr>
-	<td class='text-column'><label for="healthWorker">$i18n.getString( "health_worker" )</label></td>
-	<td class="input-column">
-		<select id="healthWorkerId" name="healthWorkerId">
-			<option value="">[$i18n.getString("please_select")]</option>
-			#foreach( $healthWorker in $healthWorkers)
-				<option value="$healthWorker.id" #if($patient.healthWorker.id == $healthWorker.id) selected #end>$healthWorker.name</option>
-			#end
-		</select>
-	</td>
-</tr>
-
-<!-- UNDERAGE -->
-
-#if($!patient.underAge)
-	#set( $representative = $!patient.representative ) 
-	<tr id="representativeFormDiv" name="representativeFormDiv">
-		<td class='text-column'>$i18n.getString("guardian")</td>
-		<td> 
-			$!patient.representative.getFullName() <img src="../images/information.png" alt="$i18n.getString( 'show_details' )" onclick='showRepresentativeInfo()' class='img-button'>
-		</td>
-	</tr>
+#if($!customRegistrationForm)
+	$customRegistrationForm
 #else
-	<tr id="underAgeDiv" name="underAgeDiv">
-		<td class='text-column'>$i18n.getString("has_guardian")</td>
+	## Macro for generating the jQuery validation rules 
+	#macro( validate $type $require )
+	  #if( $type == "NUMBER" )
+		{validate:{ number:true #if($require), required:true #end }}
+	  #elseif( $require )
+		{validate:{required:true}}
+	  #end
+	#end
+
+	<tr id='registrationDateTR'>
+		<td class='text-column'><label for="registration_date">$i18n.getString( "registration_date" )<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+		<td class="input-column" colspan='2'>
+			<input type="text" id="registrationDate" name="registrationDate" class="{validate:{required:true}}"/>
+			<script type="text/javascript">
+				datePickerValid( 'registrationDate', true );
+			</script>    
+		</td>		
+	</tr>
+
+	<tr>
+		<th colspan="2" class="heading-column">$i18n.getString( "demographics" )</th>
+	</tr>
+
+	<tr>
+		<td class='text-column'><label for="fullName">$i18n.getString( "full_name" )<em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+		<td class="input-column"><input type="text" id="fullName" name="fullName" value="$!patient.getFullName()" class="{validate:{required:true, rangelength:[3,50]}}"></td>
+	</tr>
+
+	<tr>
+		<td class='text-column'><label for="gender">$i18n.getString( "gender" )<em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+		<td class="input-column">
+			<select id="gender" name="gender">
+				<option value="M" #if( $!patient.gender == 'M' ) selected="selected" #end>$i18n.getString( "male" )</option>
+				<option value="F" #if( $!patient.gender == 'F' ) selected="selected" #end>$i18n.getString( "female" )</option>
+				<option value="T" #if( $!patient.gender == 'T' ) selected="selected" #end>$i18n.getString( "transgender" )</option>
+			</select>
+		</td>					
+	</tr>
+
+	<tr>
+		<td class='text-column' ><label for="birthDate">$i18n.getString( "date_of_birth" )<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+		<td class="input-column">
+			<select id='dobType' name="dobType" style='width:120px' onchange='dobTypeOnChange("patientForm")' >
+				<option value="V" #if($patient.dobType=='V') selected #end >$i18n.getString( "verified" )</option>
+				<option value="D" #if($patient.dobType=='D') selected #end >$i18n.getString( "declared" )</option>
+				<option value="A" #if($patient.dobType=='A') selected #end >$i18n.getString( "approximated" )</option>
+			</select>
+			<input type="text" id="birthDate" name="birthDate" value='$!format.formatDate($!patient.birthDate)' style='width:136px;' />
+			<input type="text" id="age" name="age" placeholder="Enter age in years..." value='$!patient.getIntegerValueOfAge()' class="{validate:{number:true}}" style='width:136px;' />
+		</td>
+	</tr>
+
+	<tr>
+		<td></td>
+		<td class="input-column">
+			<input id="memberValidator" class="hidden {validate:{required:true}}"/>
+		</td>
+	</tr>
+
+	<tr>
+		<td class='text-column'><label for="phoneNumber">$i18n.getString( "phone_number" )</label></td>
+		<td class="input-column">
+			<input type="text" id="phoneNumber" name="phoneNumber" #if( $!patient.phoneNumber ) value="$!patient.phoneNumber" #else value="$!phoneNumberAreaCode" #end class="{validate:{phone:true}}"/>
+		</td>
+	</tr>
+
+	<tr>
+		<td class='text-column'><label for="healthWorker">$i18n.getString( "health_worker" )</label></td>
+		<td class="input-column">
+			<select id="healthWorkerId" name="healthWorkerId">
+				<option value="">[$i18n.getString("please_select")]</option>
+				#foreach( $healthWorker in $healthWorkers)
+					<option value="$healthWorker.id" #if($patient.healthWorker.id == $healthWorker.id) selected #end>$healthWorker.name</option>
+				#end
+			</select>
+		</td>
+	</tr>
+
+	<!-- UNDERAGE -->
+
+	#if($!patient.underAge)
+		#set( $representative = $!patient.representative ) 
+		<tr id="representativeFormDiv" name="representativeFormDiv">
+			<td class='text-column'>$i18n.getString("guardian")</td>
+			<td> 
+				$!patient.representative.getFullName() <img src="../images/information.png" alt="$i18n.getString( 'show_details' )" onclick='showRepresentativeInfo()' class='img-button'>
+			</td>
+		</tr>
+	#else
+		<tr id="underAgeDiv" name="underAgeDiv">
+			<td class='text-column'>$i18n.getString("has_guardian")</td>
+			<td>
+				<input type="checkbox" name="underAge" id="underAge" onclick="toggleUnderAge(this);" value="true" #if($!patient.underAge == "true") checked="checked" #end/>
+			</td>
+		</tr>
+	#end
+
+	<!-- DEAD -->
+
+	<tr id="deathCheckboxTR">
+		<td class='text-column'>$i18n.getString("is_dead")</td>
 		<td>
-			<input type="checkbox" name="underAge" id="underAge" onclick="toggleUnderAge(this);" value="true" #if($!patient.underAge == "true") checked="checked" #end/>
-		</td>
-	</tr>
-#end
-
-<!-- DEAD -->
-
-<tr id="deathCheckboxTR">
-	<td class='text-column'>$i18n.getString("is_dead")</td>
-	<td>
-		<input type="checkbox" name="isDead" id="isDead" value="true" #if($!patient.isDead) checked="checked" #end onchange='isDeathOnChange();'/>
-	</td>
-</tr>
-
-<tr id='deathDateTR' #if($!patient.isDead) #else class="hidden" #end>
-	<td class='text-column'><label for="deathDate">$i18n.getString("death_date")</label></td>
-	<td class="input-column">
-		<input type="text" name="deathDate" id="deathDate" #if($!patient.deathDate) value="$format.formatDate( $!patient.deathDate )" #end>
-	</td>
-</tr>
-
-<tr>
-	<td></td>
-	<td><input type="button" class='button' id='checkDuplicateBtn' name='checkDuplicateBtn' value="$i18n.getString('check_duplicate')" /></td>
-</tr>
-
-<tr><td>&nbsp;</td></tr>
-
-#if( $identifierTypes.size() > 0)
-	<!--IDENTIFIERS -->
-	<tr><th colspan="2" class="heading-column">$i18n.getString("patient_identifiers")</th></tr>
-	#foreach ($identifierType in $identifierTypes)
-		#if( $identifierType.program )
-		#else
-			#set( $identifier = '' )
-			#set( $identifier = $identiferMap.get( $identifierType.id ) )
-			<tr> 
-				<td class='text-column'><label>$encoder.htmlEncode($identifierType.name) #if($identifierType.mandatory)<em title="$i18n.getString( "required" )" class="required">*</em> #end</label></td>
-				<td class="input-column"><input type="text" id="iden$identifierType.id" name="iden$identifierType.id" value="$!identifier" data="{related:$identifierType.related}" #if($identifierType.related && $!patient.underAge) disabled="disabled" #end class="{validate:{required:$identifierType.mandatory, #if($!identifierType.noChars) maxlength:$identifierType.noChars, #end #if($identifierType.type=='number') number:true #elseif($!identifierType.type=='letter') lettersonly:true #end }}" /></td>	
+			<input type="checkbox" name="isDead" id="isDead" value="true" #if($!patient.isDead) checked="checked" #end onchange='isDeathOnChange();'/>
+		</td>
+	</tr>
+
+	<tr id='deathDateTR' #if($!patient.isDead) #else class="hidden" #end>
+		<td class='text-column'><label for="deathDate">$i18n.getString("death_date")</label></td>
+		<td class="input-column">
+			<input type="text" name="deathDate" id="deathDate" #if($!patient.deathDate) value="$format.formatDate( $!patient.deathDate )" #end>
+		</td>
+	</tr>
+
+	<tr>
+		<td></td>
+		<td><input type="button" class='button' id='checkDuplicateBtn' name='checkDuplicateBtn' value="$i18n.getString('check_duplicate')" /></td>
+	</tr>
+
+	<tr><td>&nbsp;</td></tr>
+
+	#if( $identifierTypes.size() > 0)
+		<!--IDENTIFIERS -->
+		<tr><th colspan="2" class="heading-column">$i18n.getString("patient_identifiers")</th></tr>
+		#foreach ($identifierType in $identifierTypes)
+			#if( $identifierType.program )
+			#else
+				#set( $identifier = '' )
+				#set( $identifier = $identiferMap.get( $identifierType.id ) )
+				<tr> 
+					<td class='text-column'><label>$encoder.htmlEncode($identifierType.name) #if($identifierType.mandatory)<em title="$i18n.getString( "required" )" class="required">*</em> #end</label></td>
+					<td class="input-column"><input type="text" id="iden$identifierType.id" name="iden$identifierType.id" value="$!identifier" data="{related:$identifierType.related}" #if($identifierType.related && $!patient.underAge) disabled="disabled" #end class="{validate:{required:$identifierType.mandatory, #if($!identifierType.noChars) maxlength:$identifierType.noChars, #end #if($identifierType.type=='number') number:true #elseif($!identifierType.type=='letter') lettersonly:true #end }}" /></td>	
+				</tr>
+			#end
+		#end
+	#end
+
+	<!-- ATTRIBUTES IN GROUPS -->
+
+	#foreach ($attributeGroup in $attributeGroupsMap.keySet() )
+		<tr><td>&nbsp;</td></tr>
+		<tr><th colspan="2" class="heading-column">$attributeGroup.name</th></tr>
+		#set($attributes = $attributeGroupsMap.get($attributeGroup))
+		#foreach($attribute in $attributes )
+			#set($value = "")
+			#set($value = $patientAttributeValueMap.get($attribute.id))
+			#if( $attribute.valueType != 'CALCULATED')
+			<tr>
+				<td class='text-column'><label>$encoder.htmlEncode($attribute.displayName) #if($attribute.mandatory)<em title="$i18n.getString( 'required' )" class="required">*</em> #end</label></td>
+				<td class="input-column">
+					#if( $attribute.valueType == "YES/NO" )
+						<select id="attr$attribute.id" name="attr$attribute.id" inherit="$!attribute.inherit"> 
+							<option value="" selected="selected">[$i18n.getString( "please_select" )]</option>
+							<option value="true" #if($value=='true') selected #end>$i18n.getString( "yes" )</option>
+							<option value="false" #if($value=='false') selected #end>$i18n.getString( "no" )</option>
+						</select>                
+					#elseif( $attribute.valueType == "DATE" )
+						<input type="text" id="attr$attribute.id" name="attr$attribute.id" inherit="$!attribute.inherit" value='$value' class=' #validate( "default"  $attribute.mandatory )'/>
+						<script type="text/javascript">
+							datePickerValid( 'attr$attribute.id' );
+						</script>                    
+					#elseif( $attribute.valueType == "COMBO" )  
+						<select  id="attr$attribute.id"  name="attr$attribute.id" inherit="$!attribute.inherit" class='#validate( "default"  $attribute.mandatory )'>
+							<option value="">[$i18n.getString( "please_select" )]</option>
+							#foreach ($option in $attribute.attributeOptions )
+								<option value="$option.id" #if("$value"=="$option.name") selected #end>$option.name</option>
+							#end
+						</select>
+					#else
+						<input type="text" id="attr$attribute.id" name="attr$attribute.id" inherit="$!attribute.inherit" value='$value' class="{validate:{required:$attribute.mandatory #if($attribute.valueType=='NUMBER'),number:true #end }}" />
+					#end
+				</td>		
 			</tr>
+			#end
 		#end
 	#end
-#end
-
-<!-- ATTRIBUTES IN GROUPS -->
-
-#foreach ($attributeGroup in $attributeGroupsMap.keySet() )
+
 	<tr><td>&nbsp;</td></tr>
-	<tr><th colspan="2" class="heading-column">$attributeGroup.name</th></tr>
-	#set($attributes = $attributeGroupsMap.get($attributeGroup))
-	#foreach($attribute in $attributes )
-		#set($value = "")
-		#set($value = $patientAttributeValueMap.get($attribute.id))
-		#if( $attribute.valueType != 'CALCULATED')
-		<tr>
-			<td class='text-column'><label>$encoder.htmlEncode($attribute.displayName) #if($attribute.mandatory)<em title="$i18n.getString( 'required' )" class="required">*</em> #end</label></td>
-			<td class="input-column">
-				#if( $attribute.valueType == "YES/NO" )
-					<select id="attr$attribute.id" name="attr$attribute.id" inherit="$!attribute.inherit"> 
-						<option value="" selected="selected">[$i18n.getString( "please_select" )]</option>
-						<option value="true" #if($value=='true') selected #end>$i18n.getString( "yes" )</option>
-						<option value="false" #if($value=='false') selected #end>$i18n.getString( "no" )</option>
-					</select>                
-				#elseif( $attribute.valueType == "DATE" )
-					<input type="text" id="attr$attribute.id" name="attr$attribute.id" inherit="$!attribute.inherit" value='$value' class=' #validate( "default"  $attribute.mandatory )'/>
-					<script type="text/javascript">
-						datePickerValid( 'attr$attribute.id' );
-					</script>                    
-				#elseif( $attribute.valueType == "COMBO" )  
-					<select  id="attr$attribute.id"  name="attr$attribute.id" inherit="$!attribute.inherit" class='#validate( "default"  $attribute.mandatory )'>
-						<option value="">[$i18n.getString( "please_select" )]</option>
+
+	<!-- ATTRIBUTES NOT IN GROUPS -->
+
+	#if ( $noGroupAttributes && $noGroupAttributes.size() > 0) 	
+		<tr><th colspan="2" class="heading-column">$i18n.getString( "Other details" )</th></tr>
+		#foreach($attribute in $noGroupAttributes )
+		#if( $!attribute && $attribute.program )
+		#elseif( $!attribute )
+			#set( $attributeValue = "" )
+			#set( $attributeValue = $!patientAttributeValueMap.get( $attribute.id ) )
+			#if( $attribute.valueType != 'CALCULATED')
+			<tr>
+				<td class='text-column'><label>$encoder.htmlEncode($attribute.displayName) #if($attribute.mandatory)<em title="$i18n.getString( "required" )" class="required">*</em> #end</label></td>
+				<td class="input-column">
+					#if( $attribute.valueType == "YES/NO" )
+						<select id="attr$attribute.id"  name="attr$attribute.id" inherit="$!attribute.inherit">              
+							<option value="">[$i18n.getString( "please_select" )]</option>
+							<option value="true" #if( $attributeValue ) selected="selected" #end>$i18n.getString( "yes" )</option>
+							<option value="false" #if( !$attributeValue ) selected="selected" #end>$i18n.getString( "no" )</option>
+						</select>                
+					#elseif( $attribute.valueType == "DATE" )
+						<input type="text" id="attr$attribute.id" name="attr$attribute.id" inherit="$!attribute.inherit" value="$!attributeValue" class=' #validate( "default"  $attribute.mandatory )'>
+						<script type="text/javascript">
+							datePickerValid( 'attr$attribute.id' );
+						</script>                    
+					#elseif( $attribute.valueType == "COMBO" )
+						<select  id="attr$attribute.id"  name="attr$attribute.id" inherit="$!attribute.inherit" class=' #validate( "default"  $attribute.mandatory )' >
+							 <option value="">[$i18n.getString( "please_select" )]</option>
 						#foreach ($option in $attribute.attributeOptions )
-							<option value="$option.id" #if("$value"=="$option.name") selected #end>$option.name</option>
+							<option value="$option.id" #if($attributeValue == $option.name) selected="selected" #end>$option.name</option>
 						#end
-					</select>
-				#else
-					<input type="text" id="attr$attribute.id" name="attr$attribute.id" inherit="$!attribute.inherit" value='$value' class="{validate:{required:$attribute.mandatory #if($attribute.valueType=='NUMBER'),number:true #end }}" />
-				#end
-			</td>		
-		</tr>
-		#end
-	#end
-#end
-
-<tr><td>&nbsp;</td></tr>
-
-<!-- ATTRIBUTES NOT IN GROUPS -->
-
-#if ( $noGroupAttributes && $noGroupAttributes.size() > 0) 	
-	<tr><th colspan="2" class="heading-column">$i18n.getString( "Other details" )</th></tr>
-	#foreach($attribute in $noGroupAttributes )
-	#if( $!attribute && $attribute.program )
-	#elseif( $!attribute )
-		#set( $attributeValue = "" )
-		#set( $attributeValue = $!patientAttributeValueMap.get( $attribute.id ) )
-		#if( $attribute.valueType != 'CALCULATED')
-		<tr>
-			<td class='text-column'><label>$encoder.htmlEncode($attribute.displayName) #if($attribute.mandatory)<em title="$i18n.getString( "required" )" class="required">*</em> #end</label></td>
-			<td class="input-column">
-				#if( $attribute.valueType == "YES/NO" )
-					<select id="attr$attribute.id"  name="attr$attribute.id" inherit="$!attribute.inherit">              
-						<option value="">[$i18n.getString( "please_select" )]</option>
-						<option value="true" #if( $attributeValue ) selected="selected" #end>$i18n.getString( "yes" )</option>
-						<option value="false" #if( !$attributeValue ) selected="selected" #end>$i18n.getString( "no" )</option>
-					</select>                
-				#elseif( $attribute.valueType == "DATE" )
-					<input type="text" id="attr$attribute.id" name="attr$attribute.id" inherit="$!attribute.inherit" value="$!attributeValue" class=' #validate( "default"  $attribute.mandatory )'>
-					<script type="text/javascript">
-						datePickerValid( 'attr$attribute.id' );
-					</script>                    
-				#elseif( $attribute.valueType == "COMBO" )
-					<select  id="attr$attribute.id"  name="attr$attribute.id" inherit="$!attribute.inherit" class=' #validate( "default"  $attribute.mandatory )' >
-						 <option value="">[$i18n.getString( "please_select" )]</option>
-					#foreach ($option in $attribute.attributeOptions )
-						<option value="$option.id" #if($attributeValue == $option.name) selected="selected" #end>$option.name</option>
+						</select>
+					#else  
+						<input type="text"  id="attr$attribute.id" name="attr$attribute.id" inherit="$!attribute.inherit" value="$!attributeValue" class="{validate:{required:$attribute.mandatory #if($!attribute.noChars),maxlength:$attribute.noChars #end #if($attribute.valueType=='NUMBER'),number:true #end }}" >
 					#end
-					</select>
-				#else  
-					<input type="text"  id="attr$attribute.id" name="attr$attribute.id" inherit="$!attribute.inherit" value="$!attributeValue" class="{validate:{required:$attribute.mandatory #if($!attribute.noChars),maxlength:$attribute.noChars #end #if($attribute.valueType=='NUMBER'),number:true #end }}" >
-				#end
-			</td>		
-		</tr>
-		#end
+				</td>		
+			</tr>
+			#end
+			#end
 		#end
 	#end
+
 #end
 
-
 <script>
 	#if($!patient.dobType && $!patient.dobType=='A') 
 		showById('age');

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/DelRegistrationFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/DelRegistrationFormAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/DelRegistrationFormAction.java	2013-02-01 08:40:49 +0000
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.patient.action.dataentryform;
+
+import org.hisp.dhis.patient.PatientRegistrationForm;
+import org.hisp.dhis.patient.PatientRegistrationFormService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version DelRegistrationFormAction.java 10:13:10 AM Jan 31, 2013 $
+ */
+public class DelRegistrationFormAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private PatientRegistrationFormService patientRegistrationFormService;
+
+    public void setPatientRegistrationFormService( PatientRegistrationFormService patientRegistrationFormService )
+    {
+        this.patientRegistrationFormService = patientRegistrationFormService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Getters & setters
+    // -------------------------------------------------------------------------
+
+    private Integer id;
+
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+    
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        PatientRegistrationForm registrationForm = patientRegistrationFormService.getPatientRegistrationForm( id );
+
+        patientRegistrationFormService.deletePatientRegistrationForm( registrationForm );
+        
+        return SUCCESS;
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/GetPatientRegistrationFormListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/GetPatientRegistrationFormListAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/GetPatientRegistrationFormListAction.java	2013-02-01 08:40:49 +0000
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.patient.action.dataentryform;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.hisp.dhis.patient.PatientRegistrationForm;
+import org.hisp.dhis.patient.PatientRegistrationFormService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.program.comparator.ProgramDisplayNameComparator;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version GetPatientRegistrationFormListAction.java 11:06:37 AM Jan 31, 2013 $
+ */
+public class GetPatientRegistrationFormListAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependency
+    // -------------------------------------------------------------------------
+
+    private PatientRegistrationFormService patientRegistrationFormService;
+
+    public void setPatientRegistrationFormService( PatientRegistrationFormService patientRegistrationFormService )
+    {
+        this.patientRegistrationFormService = patientRegistrationFormService;
+    }
+
+    private ProgramService programService;
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Getters & Setters
+    // -------------------------------------------------------------------------
+
+    private Collection<PatientRegistrationForm> registrationForms;
+
+    public Collection<PatientRegistrationForm> getRegistrationForms()
+    {
+        return registrationForms;
+    }
+
+    private List<Program> programs;
+
+    public List<Program> getPrograms()
+    {
+        return programs;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        registrationForms = patientRegistrationFormService.getAllPatientRegistrationForms();
+
+        programs = new ArrayList<Program>( programService.getAllPrograms() );
+
+        for ( PatientRegistrationForm registrationForm : registrationForms )
+        {
+            if ( registrationForm.getProgram() != null )
+            {
+                programs.remove( registrationForm.getProgram() );
+            }
+        }
+
+        Collections.sort( programs, new ProgramDisplayNameComparator() );
+
+        return SUCCESS;
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/SavePatientRegistrationFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/SavePatientRegistrationFormAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/SavePatientRegistrationFormAction.java	2013-02-01 08:40:49 +0000
@@ -0,0 +1,149 @@
+package org.hisp.dhis.patient.action.dataentryform;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.dataentryform.DataEntryForm;
+import org.hisp.dhis.dataentryform.DataEntryFormService;
+import org.hisp.dhis.patient.PatientRegistrationForm;
+import org.hisp.dhis.patient.PatientRegistrationFormService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version SavePatientRegistrationFormAction.java 10:26:09 AM Jan 31, 2013 $
+ */
+public class SavePatientRegistrationFormAction
+    implements Action
+{
+    Log logger = LogFactory.getLog( getClass() );
+
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private DataEntryFormService dataEntryFormService;
+
+    public void setDataEntryFormService( DataEntryFormService dataEntryFormService )
+    {
+        this.dataEntryFormService = dataEntryFormService;
+    }
+
+    private ProgramService programService;
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
+    private PatientRegistrationFormService patientRegistrationFormService;
+
+    public void setPatientRegistrationFormService( PatientRegistrationFormService patientRegistrationFormService )
+    {
+        this.patientRegistrationFormService = patientRegistrationFormService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Getters & Setters
+    // -------------------------------------------------------------------------
+
+    private String name;
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+    private String designTextarea;
+
+    public void setDesignTextarea( String designTextarea )
+    {
+        this.designTextarea = designTextarea;
+    }
+
+    private Integer id;
+
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+
+    private Integer programId;
+
+    public void setProgramId( Integer programId )
+    {
+        this.programId = programId;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        PatientRegistrationForm registrationForm = null;
+
+        if ( id != null )
+        {
+            registrationForm = patientRegistrationFormService.getPatientRegistrationForm( id );
+        }
+
+        // ---------------------------------------------------------------------
+        // Save data-entry-form
+        // ---------------------------------------------------------------------
+
+        if ( registrationForm == null )
+        {
+            registrationForm = new PatientRegistrationForm();
+            DataEntryForm dataEntryForm = new DataEntryForm( name, designTextarea );
+            registrationForm.setDataEntryForm( dataEntryForm );
+            if ( programId != null )
+            {
+                Program program = programService.getProgram( programId );
+                registrationForm.setProgram( program );
+            }
+            patientRegistrationFormService.savePatientRegistrationForm( registrationForm );
+        }
+        else
+        {
+            DataEntryForm dataEntryForm = registrationForm.getDataEntryForm();
+            dataEntryForm.setName( name );
+            dataEntryForm.setHtmlCode( designTextarea );
+            dataEntryFormService.updateDataEntryForm( dataEntryForm );
+        }
+
+        return SUCCESS;
+    }
+
+}

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ShowPatientRegistrationFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ShowPatientRegistrationFormAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ShowPatientRegistrationFormAction.java	2013-02-01 08:40:49 +0000
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.patient.action.dataentryform;
+
+import org.hisp.dhis.dataentryform.DataEntryForm;
+import org.hisp.dhis.dataentryform.DataEntryFormService;
+import org.hisp.dhis.patient.PatientRegistrationFormService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version SavePatientRegistrationFormAction.java 10:35:08 AM Jan 31, 2013 $
+ */
+public class ShowPatientRegistrationFormAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependency
+    // -------------------------------------------------------------------------
+
+    private DataEntryFormService dataEntryFormService;
+
+    public void setDataEntryFormService( DataEntryFormService dataEntryFormService )
+    {
+        this.dataEntryFormService = dataEntryFormService;
+    }
+
+    private PatientRegistrationFormService patientRegistrationFormService;
+
+    public void setPatientRegistrationFormService( PatientRegistrationFormService patientRegistrationFormService )
+    {
+        this.patientRegistrationFormService = patientRegistrationFormService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Getters & Setters
+    // -------------------------------------------------------------------------
+
+    private Integer dataEntryFormId;
+
+    public void setDataEntryFormId( Integer dataEntryFormId )
+    {
+        this.dataEntryFormId = dataEntryFormId;
+    }
+
+    private String dataEntryFormCode;
+
+    public String getDataEntryFormCode()
+    {
+        return dataEntryFormCode;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        if ( dataEntryFormId != null )
+        {
+            DataEntryForm dataEntryForm = dataEntryFormService.getDataEntryForm( dataEntryFormId );
+
+            if ( dataEntryForm != null )
+            {
+                dataEntryFormCode = dataEntryForm.getHtmlCode();
+            }
+        }
+
+        return SUCCESS;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewDataEntryFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewDataEntryFormAction.java	2012-01-20 10:38:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewDataEntryFormAction.java	2013-02-01 08:40:49 +0000
@@ -172,8 +172,8 @@
             listAssociationIds.add( ps.getId() );
         }
 
-        existingDataEntryForms = new ArrayList<DataEntryForm>( dataEntryFormService
-            .listDisctinctDataEntryFormByProgramStageIds( listAssociationIds ) );
+        existingDataEntryForms = new ArrayList<DataEntryForm>(
+            dataEntryFormService.listDisctinctDataEntryFormByProgramStageIds( listAssociationIds ) );
 
         existingDataEntryForms.remove( dataEntryForm );
 
@@ -192,9 +192,9 @@
         // ---------------------------------------------------------------------
 
         dataElements = new ArrayList<DataElement>( programStageDataElementService.getListDataElement( programStage ) );
-        
+
         Collections.sort( dataElements, new IdentifiableObjectNameComparator() );
-        
+
         return SUCCESS;
     }
 }

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewPatientRegistrationFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewPatientRegistrationFormAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewPatientRegistrationFormAction.java	2013-02-01 08:40:49 +0000
@@ -0,0 +1,172 @@
+package org.hisp.dhis.patient.action.dataentryform;
+
+/*
+ * Copyright (c) 2004-2012, 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.HashSet;
+import java.util.List;
+
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeService;
+import org.hisp.dhis.patient.PatientIdentifierType;
+import org.hisp.dhis.patient.PatientIdentifierTypeService;
+import org.hisp.dhis.patient.PatientRegistrationForm;
+import org.hisp.dhis.patient.PatientRegistrationFormService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version SavePatientRegistrationFormAction.java 10:35:08 AM Jan 31, 2013 $
+ */
+public class ViewPatientRegistrationFormAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ProgramService programService;
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
+    private PatientAttributeService patientAttributeService;
+
+    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
+    {
+        this.patientAttributeService = patientAttributeService;
+    }
+
+    private PatientIdentifierTypeService patientIdentifierTypeService;
+
+    public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService )
+    {
+        this.patientIdentifierTypeService = patientIdentifierTypeService;
+    }
+
+    private PatientRegistrationFormService patientRegistrationFormService;
+
+    public void setPatientRegistrationFormService( PatientRegistrationFormService patientRegistrationFormService )
+    {
+        this.patientRegistrationFormService = patientRegistrationFormService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Getters & Setters
+    // -------------------------------------------------------------------------
+
+    private Integer id;
+
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+
+    private Integer programId;
+
+    public void setProgramId( Integer programId )
+    {
+        this.programId = programId;
+    }
+
+    private Collection<PatientAttribute> attributes = new HashSet<PatientAttribute>();
+
+    private Collection<PatientIdentifierType> identifierTypes = new HashSet<PatientIdentifierType>();
+
+    public Collection<PatientAttribute> getAttributes()
+    {
+        return attributes;
+    }
+
+    public Collection<PatientIdentifierType> getIdentifierTypes()
+    {
+        return identifierTypes;
+    }
+
+    private PatientRegistrationForm registrationForm;
+
+    public PatientRegistrationForm getRegistrationForm()
+    {
+        return registrationForm;
+    }
+
+    private Program program;
+
+    public Program getProgram()
+    {
+        return program;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        List<Program> programs = new ArrayList<Program>( programService.getAllPrograms() );
+
+        programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) );
+
+        if ( id != null )
+        {
+            registrationForm = patientRegistrationFormService.getPatientRegistrationForm( id );
+        }
+
+        if ( programId != null )
+        {
+            program = programService.getProgram( programId );
+        }
+
+        // ---------------------------------------------------------------------
+        // Get dynamic attributes and identifier-types
+        // ---------------------------------------------------------------------
+
+        identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
+
+        attributes = patientAttributeService.getAllPatientAttributes();
+
+        for ( Program program : programs )
+        {
+            if ( programId == null || program.getId() != programId )
+            {
+                identifierTypes.removeAll( program.getPatientIdentifierTypes() );
+                attributes.removeAll( program.getPatientAttributes() );
+            }
+        }
+
+        return SUCCESS;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2013-01-23 10:27:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2013-02-01 08:40:49 +0000
@@ -151,7 +151,7 @@
 			ref="org.hisp.dhis.patient.PatientAttributeService" />
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 	</bean>
-	
+
 	<bean
 		id="org.hisp.dhis.patient.action.patientattribute.GetCalPatientAttributeParamsAction"
 		class="org.hisp.dhis.patient.action.patientattribute.GetCalPatientAttributeParamsAction"
@@ -466,6 +466,74 @@
 		</property>
 	</bean>
 
+	<!-- PatientRegistrationForm -->
+
+	<bean
+		id="org.hisp.dhis.patient.action.dataentryform.GetPatientRegistrationFormListAction"
+		class="org.hisp.dhis.patient.action.dataentryform.GetPatientRegistrationFormListAction"
+		scope="prototype">
+		<property name="patientRegistrationFormService">
+			<ref bean="org.hisp.dhis.patient.PatientRegistrationFormService" />
+		</property>
+		<property name="programService">
+			<ref bean="org.hisp.dhis.program.ProgramService" />
+		</property>
+	</bean>
+	
+	<bean
+		id="org.hisp.dhis.patient.action.dataentryform.DelRegistrationFormAction"
+		class="org.hisp.dhis.patient.action.dataentryform.DelRegistrationFormAction"
+		scope="prototype">
+		<property name="patientRegistrationFormService">
+			<ref bean="org.hisp.dhis.patient.PatientRegistrationFormService" />
+		</property>
+	</bean>
+
+	<bean
+		id="org.hisp.dhis.patient.action.dataentryform.SavePatientRegistrationFormAction"
+		class="org.hisp.dhis.patient.action.dataentryform.SavePatientRegistrationFormAction"
+		scope="prototype">
+		<property name="dataEntryFormService">
+			<ref bean="org.hisp.dhis.dataentryform.DataEntryFormService" />
+		</property>
+		<property name="programService">
+			<ref bean="org.hisp.dhis.program.ProgramService" />
+		</property>
+		<property name="patientRegistrationFormService">
+			<ref bean="org.hisp.dhis.patient.PatientRegistrationFormService" />
+		</property>
+	</bean>
+
+	<bean
+		id="org.hisp.dhis.patient.action.dataentryform.ShowPatientRegistrationFormAction"
+		class="org.hisp.dhis.patient.action.dataentryform.ShowPatientRegistrationFormAction"
+		scope="prototype">
+		<property name="dataEntryFormService">
+			<ref bean="org.hisp.dhis.dataentryform.DataEntryFormService" />
+		</property>
+		<property name="patientRegistrationFormService">
+			<ref bean="org.hisp.dhis.patient.PatientRegistrationFormService" />
+		</property>
+	</bean>
+
+	<bean
+		id="org.hisp.dhis.patient.action.dataentryform.ViewPatientRegistrationFormAction"
+		class="org.hisp.dhis.patient.action.dataentryform.ViewPatientRegistrationFormAction"
+		scope="prototype">
+		<property name="programService">
+			<ref bean="org.hisp.dhis.program.ProgramService" />
+		</property>
+		<property name="patientAttributeService">
+			<ref bean="org.hisp.dhis.patient.PatientAttributeService" />
+		</property>
+		<property name="patientIdentifierTypeService">
+			<ref bean="org.hisp.dhis.patient.PatientIdentifierTypeService" />
+		</property>
+		<property name="patientRegistrationFormService">
+			<ref bean="org.hisp.dhis.patient.PatientRegistrationFormService" />
+		</property>
+	</bean>
+
 	<!-- Patient Attribute Group -->
 
 	<bean
@@ -907,40 +975,51 @@
 		<property name="programExpressionService"
 			ref="org.hisp.dhis.program.ProgramExpressionService" />
 	</bean>
-	
-	
+
+
 	<!-- Scheduling -->
 
 	<bean id="org.hisp.dhis.patient.action.schedule.GetScheduleParamsAction"
 		class="org.hisp.dhis.patient.action.schedule.GetScheduleParamsAction"
 		scope="prototype">
 		<property name="systemSettingManager" ref="org.hisp.dhis.setting.SystemSettingManager" />
-		<property name="schedulingManager" ref="org.hisp.dhis.patient.scheduling.ProgramSchedulingManager" />
-	</bean>
-	
-	<bean id="org.hisp.dhis.patient.action.schedule.ScheduleSendMessageTasksAction" class="org.hisp.dhis.patient.action.schedule.ScheduleSendMessageTasksAction"  scope="prototype">
- 		 <property name="systemSettingManager" ref="org.hisp.dhis.setting.SystemSettingManager" />
- 		 <property name="schedulingManager" ref="org.hisp.dhis.patient.scheduling.ProgramSchedulingManager" />
- 	</bean>
- 	
- 	<bean id="org.hisp.dhis.patient.action.schedule.ExecuteSendMessageAction"
+		<property name="schedulingManager"
+			ref="org.hisp.dhis.patient.scheduling.ProgramSchedulingManager" />
+	</bean>
+
+	<bean
+		id="org.hisp.dhis.patient.action.schedule.ScheduleSendMessageTasksAction"
+		class="org.hisp.dhis.patient.action.schedule.ScheduleSendMessageTasksAction"
+		scope="prototype">
+		<property name="systemSettingManager" ref="org.hisp.dhis.setting.SystemSettingManager" />
+		<property name="schedulingManager"
+			ref="org.hisp.dhis.patient.scheduling.ProgramSchedulingManager" />
+	</bean>
+
+	<bean id="org.hisp.dhis.patient.action.schedule.ExecuteSendMessageAction"
 		class="org.hisp.dhis.patient.action.schedule.ExecuteSendMessageAction"
 		scope="prototype">
-		<property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+		<property name="programStageInstanceService"
+			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 		<property name="jdbcTemplate" ref="jdbcTemplate" />
-		<property name="outboundSmsService" ref="org.hisp.dhis.sms.outbound.OutboundSmsService" />
+		<property name="outboundSmsService"
+			ref="org.hisp.dhis.sms.outbound.OutboundSmsService" />
 	</bean>
-	
-	<bean id="org.hisp.dhis.patient.action.schedule.GetScheduleAggQueryBuilderParamsAction"
+
+	<bean
+		id="org.hisp.dhis.patient.action.schedule.GetScheduleAggQueryBuilderParamsAction"
 		class="org.hisp.dhis.patient.action.schedule.GetScheduleAggQueryBuilderParamsAction"
 		scope="prototype">
-		<property name="schedulingManager" ref="org.hisp.dhis.patient.scheduling.CaseAggregateConditionSchedulingManager" />
+		<property name="schedulingManager"
+			ref="org.hisp.dhis.patient.scheduling.CaseAggregateConditionSchedulingManager" />
 	</bean>
-	
-	<bean id="org.hisp.dhis.patient.action.schedule.ScheduleCaseAggregateConditionAction"
+
+	<bean
+		id="org.hisp.dhis.patient.action.schedule.ScheduleCaseAggregateConditionAction"
 		class="org.hisp.dhis.patient.action.schedule.ScheduleCaseAggregateConditionAction"
 		scope="prototype">
-		<property name="schedulingManager" ref="org.hisp.dhis.patient.scheduling.CaseAggregateConditionSchedulingManager" />
+		<property name="schedulingManager"
+			ref="org.hisp.dhis.patient.scheduling.CaseAggregateConditionSchedulingManager" />
 	</bean>
 
 </beans>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2013-01-24 06:03:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2013-02-01 08:40:49 +0000
@@ -326,4 +326,21 @@
 code_and_name = Code and Name
 sort_by = Sort by
 block_entry_form_after_completed = Block entry form after completed
-select_operator_number_of_visits_for_this_condition = Please select operator number of visit for this condition
\ No newline at end of file
+select_operator_number_of_visits_for_this_condition = Please select operator number of visit for this condition
+patient_registration_form = Patient Registration Form
+intro_patient_registration_form = Define custom person registration form
+patient_registration_form_management = Patient registration form management
+properties = Properties
+full_name = Full name
+birth_date = Date of birth
+death_date = Date of death
+registration_date = Registration date
+is_dead = Is dead
+health_worker = Health worker
+phone_number = Phone number
+patient_registration_details  = Patient registration details
+design_patient_registration_form = Design patient registration form
+confirm_delete_patient_registration_form = Are you sure you want to delete person registration form?
+fixed_attributes = Fixed attributes
+identifier_types = Identifier types
+attributes = Attributes
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2013-01-07 05:07:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2013-02-01 08:40:49 +0000
@@ -120,7 +120,7 @@
 			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
-		
+
 		<action name="removePatientAttribute"
 			class="org.hisp.dhis.patient.action.patientattribute.RemovePatientAttributeAction">
 			<result name="success" type="velocity-json">
@@ -525,6 +525,49 @@
 			</result>
 		</action>
 
+		<!-- Patient Registration Form -->
+
+		<action name="patientRegistrationForm"
+			class="org.hisp.dhis.patient.action.dataentryform.GetPatientRegistrationFormListAction">
+			<result name="success" type="velocity">/main.vm</result>
+			<param name="page">/dhis-web-maintenance-patient/patientRegistrationForm.vm</param>
+			<param name="menu">/dhis-web-maintenance-patient/menu.vm</param>
+			<param name="javascripts">javascript/patientRegistrationForm.js</param>
+			<param name="requiredAuthorities">F_ADD_PATIENT_REGISTATION_FORM</param>
+		</action>
+
+		<action name="viewPatientRegistrationForm"
+			class="org.hisp.dhis.patient.action.dataentryform.ViewPatientRegistrationFormAction">
+			<result name="success" type="velocity">/main.vm</result>
+			<param name="page">/dhis-web-maintenance-patient/viewPatientRegistationForm.vm</param>
+			<param name="javascripts">
+				../dhis-web-commons/ckeditor/ckeditor.js,
+				../dhis-web-commons/ckeditor/adapters/jquery.js,
+				javascript/viewPatientRegistationForm.js
+			</param>
+			<param name="stylesheets">style/basic.css</param>
+		</action>
+
+		<action name="savePatientRegistrationForm"
+			class="org.hisp.dhis.patient.action.dataentryform.SavePatientRegistrationFormAction">
+			<result name="success" type="redirect">patientRegistrationForm.action
+			</result>
+		</action>
+
+		<action name="delRegistrationFormAction"
+			class="org.hisp.dhis.patient.action.dataentryform.DelRegistrationFormAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
+		</action>
+
+		<action name="showPatientRegistrationForm"
+			class="org.hisp.dhis.patient.action.dataentryform.ShowPatientRegistrationFormAction">
+			<result name="success" type="velocity">
+				/dhis-web-maintenance-patient/dataEntryFormCode.vm
+			</result>
+		</action>
+
 		<!-- Patient Attribute Group -->
 
 		<action name="patientAttributeGroup"
@@ -905,7 +948,7 @@
 			<param name="stylesheets">style/basic.css</param>
 			<param name="requiredAuthorities">F_PROGRAM_VALIDATION</param>
 		</action>
-		
+
 		<action name="addProgramValidation"
 			class="org.hisp.dhis.patient.action.validation.AddProgramValidationAction">
 			<result name="success" type="redirect">

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/index.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/index.vm	2012-11-02 15:59:25 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/index.vm	2013-02-01 08:40:49 +0000
@@ -12,6 +12,7 @@
     #introListImgItem( "patientAttributeGroup.action" "patient_attribute_group" "patient" )
     #introListImgItem( "patientIdentifierType.action" "patient_identifier_type" "patient" )
     #introListImgItem( "relationshipType.action" "relationship_type" "patient" )
+    #introListImgItem( "patientRegistrationForm.action" "patient_registration_form" "pivottable" )
     #introListImgItem( "program.action" "program" "program" )
     #introListImgItem( "caseAggregation.action" "patient_aggregation_query_builder" "caseaggregationmapping" )
 	#introListImgItem( "validationCriteria.action" "validation_criteria" "validationrule" )

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientAttribute.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientAttribute.js	2012-12-21 09:23:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientAttribute.js	2013-02-01 08:40:49 +0000
@@ -22,6 +22,7 @@
 // -----------------------------------------------------------------------------
 // Remove Patient Attribute
 // -----------------------------------------------------------------------------
+
 function removePatientAttribute( patientAttributeId, name )
 {
 	removeItem( patientAttributeId, name, i18n_confirm_delete, 'removePatientAttribute.action' );	

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientRegistrationForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientRegistrationForm.js	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientRegistrationForm.js	2013-02-01 08:40:49 +0000
@@ -0,0 +1,13 @@
+
+function addNewForm(){
+	window.location.href='viewPatientRegistrationForm.action?programId=' + getFieldValue('programId');
+}
+
+function updateNewForm( registrationFormId, programId ){
+	window.location.href='viewPatientRegistrationForm.action?programId=' + programId + '&id=' + registrationFormId;
+}
+
+function removeRegistrationForm( registrationFormId, name )
+{
+	removeItem( registrationFormId, name, i18n_confirm_delete, 'delRegistrationFormAction.action' );	
+}
\ No newline at end of file

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewPatientRegistationForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewPatientRegistationForm.js	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewPatientRegistationForm.js	2013-02-01 08:40:49 +0000
@@ -0,0 +1,73 @@
+
+function openPropertiesSelector()
+{
+	$('#selectionDialog' ).dialog(
+		{
+			title:'fafds',
+			maximize:true, 
+			closable:true,
+			modal:false,
+			overlay:{background:'#000000', opacity:0.1},
+			width:500,
+			height:400
+		});
+	showById('fixedAttrTab');
+}
+
+function fixAttrOnClick()
+{
+	hideById('attributeTab');
+	hideById('identifierTypeTab');
+	hideById('programAttrTab');
+	showById('fixedAttrTab');
+}
+
+function identifierTypeOnClick()
+{
+	hideById('attributeTab');
+	hideById('fixedAttrTab');
+	hideById('programAttrTab');
+	showById('identifierTypeTab');
+}
+
+function attributesOnClick()
+{
+	hideById('identifierTypeTab');
+	hideById('fixedAttrTab');
+	hideById('programAttrTab');
+	showById('attributeTab');
+}
+
+function programAttrOnClick()
+{
+	hideById('attributeTab');
+	hideById('identifierTypeTab');
+	hideById('fixedAttrTab');
+	showById('programAttrTab');
+}
+
+function insertElement( type )
+{
+	var oEditor = jQuery("#designTextarea").ckeditorGet();
+	var id = '';
+	var value = '';
+	if( type == 'fixedAttr' ){
+		var element = jQuery('#fixedAttrSelector option:selected');
+		id = 'fixedattributeid="' + element.attr('value') + '"';
+		value = element.text();
+	}
+	else if( type == 'iden' ){
+		var element = jQuery('#identifiersSelector option:selected');
+		id = 'identifierid="' + element.attr('value') + '"';
+		value = element.text();
+	}
+	else if( type == 'attr' ){
+		var element = jQuery('#attributesSelector option:selected');
+		id = 'attributeid="' + element.attr('value') + '"';
+		value = element.text();
+	}
+	
+	var htmlCode = "<input " + id + " value=\"[" + value + "]\" title=\"" + value + "\">";
+	
+	oEditor.insertHtml( htmlCode );
+}

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm	2012-11-02 15:59:25 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm	2013-02-01 08:40:49 +0000
@@ -4,6 +4,7 @@
 	<li><a href="patientAttributeGroup.action">$i18n.getString( "patient_attribute_group" )</a></li>
 	<li><a href="patientIdentifierType.action">$i18n.getString( "patient_identifier_type" )</a></li>
 	<li><a href="relationshipType.action">$i18n.getString( "relationship_type" )</a></li>
+	<li><a href="patientRegistrationForm.action">$i18n.getString( "patient_registration_form" )</a></li>
 </ul>
 
 <h2>$i18n.getString( "programs" )</h2>

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientRegistrationForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientRegistrationForm.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientRegistrationForm.vm	2013-02-01 08:40:49 +0000
@@ -0,0 +1,53 @@
+<h3>$i18n.getString( "patient_registration_form_management" ) #openHelp( "program" )</h3>
+
+<table class="mainPageTable">
+	#if( $programs.size() > 0 )
+	<tr>
+		<td>
+			<label>$i18n.getString('program')</label>
+			<select name="programId" id="programId" style="width:20em" >
+				<option value=''>[$i18n.getString('please_select')]</option>
+				#foreach($program in $programs)
+					<option value='$program.id'>$encoder.htmlEncode($program.displayName)</option>
+				#end
+			</select>
+		</td>
+		<td align="right">
+			<input type="button" value="$i18n.getString( 'add_new' )" onclick="addNewForm();" style="width:70px">
+		</td>
+	#else
+		<input type='hidden' name="programId" id="programId" value="" />
+	#end
+  </tr>
+  <tr>
+    <td style="vertical-align:top" colspan='2'>
+		
+		<table class="listTable">
+			  <col>          
+			  <col width="40">
+			<thead>			  
+			  <tr>            
+				<th>$i18n.getString( "name" )</th>
+				<th class="{sorter: false}">$i18n.getString( "operations" )</th>
+			  </tr>
+			</thead>
+			  <tbody class="list">
+				#foreach( $registrationForm in $registrationForms )
+				  <tr id="tr${registrationForm.id}">
+					<td>$encoder.htmlEncode( $registrationForm.dataEntryForm.name )</td>                
+					<td style="text-align:center">
+					  <a href="javascript:updateNewForm($registrationForm.id, '$!registrationForm.program.id')" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"></a>
+					  <a href="javascript:removeRegistrationForm( '$registrationForm.id', '$encoder.jsEncode( $registrationForm.dataEntryForm.name )' )" title="$i18n.getString( "remove" )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
+					</td>
+					
+				  </tr>
+				#end
+			  </tbody>
+        </table>
+		</td>
+	</tr>
+</table>
+
+<script type="text/javascript">
+	var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_patient_registration_form" ) , "'" )';
+</script>

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewPatientRegistationForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewPatientRegistationForm.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewPatientRegistationForm.vm	2013-02-01 08:40:49 +0000
@@ -0,0 +1,200 @@
+<script type="text/javascript">
+  
+	jQuery(document).ready(	function()
+	{
+		validation( 'saveDataEntryForm', function( form )
+		{
+			setInnerHTML( 'designTextarea' , jQuery("#designTextarea").ckeditorGet().getData() );
+			form.submit();
+		} );
+
+		jQuery('#designTextarea').ckeditor();
+		#if($!registrationForm)
+			jQuery("#designTextarea").ckeditorGet().setData('$encoder.jsEscape( $!registrationForm.dataEntryForm.htmlCode, "'" )');
+		#end
+		
+		checkValueIsExist( "name", "validateDataEntryForm.action", { dataEntryFormId: '$!registrationForm.dataEntryForm.id' } );
+	});
+
+    var i18n_dataelement_is_inserted = '$encoder.jsEscape( $i18n.getString( "dataelement_is_inserted" ) , "'" )';
+	var i18n_specify_dataelememt = '$encoder.jsEscape( $i18n.getString( "specify_dataelememt" ) , "'" )';
+    var i18n_choose_existing_dataentry ='$encoder.jsEscape( $i18n.getString( "choose_existing_dataentry" ) , "'" )';
+	var i18n_dataelement = "$i18n.getString( 'dataelement' )";
+	var i18n_dataelement_of_orther_program_stage = "$i18n.getString( 'dataelement_of_orther_program_stage' )";
+	
+	var previousName = '';
+</script>
+
+<style type="text/css">
+.ui-state-active2, .ui-widget-content .ui-state-active2, .ui-widget-header .ui-state-active2 {
+	border: 1px solid #79b7e7;
+	background: #f5f8f9;
+	font-weight: bold;
+	color: #e17009;
+}
+
+.ui-dialog .ui-dialog-content {
+	padding: 2px;
+}
+
+#fixedAttrSelector, #identifiersSelector, #attributesSelector,  {
+	padding: 2px;
+}
+</style>
+
+<form id="saveDataEntryForm" name="saveDataEntryForm" action="savePatientRegistrationForm.action" method="post">
+
+<input type="hidden" name="id" id="id" value="$!registrationForm.id"/>
+<input type="hidden" name="programId" id="programId" value="$!programId"/>
+<input type="hidden" name="dataEntryFormId" id="dataEntryFormId" value="$!registrationForm.dataEntryForm.id"/>
+
+<h3>$i18n.getString( "patient_registration_form" )</h3>
+<div class="container" >
+	<table id="detailsList" width="100%">
+		<col/>
+		<tr>
+			<th colspan='3'>$i18n.getString( "patient_registration_details" )</th>
+		</tr>
+		<tr>
+			<td>
+				<label>$i18n.getString( "name" ) <em title="$i18n.getString( "required" )" class="required">*</em></label>
+			</td>
+			<td>
+				<input type="text" id="name" value="$!registrationForm.dataEntryForm.name" name="name" class="{validate:{required:true,rangelength:[4,150],alphanumericwithbasicpuncspaces:true,firstletteralphabet:false}}" style="width:30em;">
+			</td>	
+			<td align="right">
+				<input type="button" value="$i18n.getString( 'properties' )" onclick="openPropertiesSelector()"/><br>
+			</td>			
+		</tr>
+		<tr>
+			<td>&nbsp;</td>
+		</tr>		
+	</table>  
+	
+	<table width="100%">
+		<tr>
+			<th>$i18n.getString( "design_patient_registration_form" )</th>
+		</tr>
+		<tr>
+			<td>
+	        	<div>
+	        		<textarea id="designTextarea" name="designTextarea"></textarea>
+	        	</div>
+			</td>
+		</tr>
+	</table>
+</div>
+
+<table width="100%">	
+    <tr>
+        <td>
+            <input type="submit" name="save" value="$i18n.getString( 'save' )" style="width:120px"/>
+            <input type="button" name="cancel" value="$i18n.getString( 'cancel' )" style="width:120px" onclick="window.location='patientRegistrationForm.action'">            
+			#if( $!registationForm.dataEntryForm )
+			<input type="button" name="delete" value="$i18n.getString( 'delete' )" style="width:120px" onclick="deleteDataEntryForm( $registrationForm.id )" />
+			#end
+        </td>		
+    </tr>
+</table>
+  
+</form>
+
+<div id='selectionDialog' class='hidden'>
+	<table id="fixedAttrTab" class='hidden'>
+		<tr>
+			<td>
+				<input type='text' placeholder="$i18n.getString('filter')" style="width:278px;">
+				<input type='button' value="$i18n.getString('filter')" style="width:80px;">
+				<input type='button' value="$i18n.getString('clear')" style="width:80px;">
+			</td>
+		</tr>
+		<tr>
+			<td>
+				<select id="fixedAttrSelector" multiple="multiple" style="width:450px;height:270px" ondblclick="insertElement( 'fixedAttr' )">
+					<option value="fullName">$i18n.getString('full_name')</option>
+					<option value="gender">$i18n.getString('gender')</option>
+					<option value="birthDate">$i18n.getString('birth_date')</option>
+					<option value="phoneNumber">$i18n.getString('phone_number')</option>
+					<option value="deathDate">$i18n.getString('death_date')</option>
+					<option value="registrationDate">$i18n.getString('registration_date')</option>
+					<option value="isDead">$i18n.getString('is_dead')</option>
+					<option value="dobType">$i18n.getString('dob_type')</option>
+					<option value="healthWorker">$i18n.getString('health_worker')</option>
+				</select>
+			</td>
+		</tr>
+	</table>
+	
+	<table id="identifierTypeTab" class='hidden'>
+		<tr>
+			<td>
+				<input type='text' placeholder="$i18n.getString('filter')" style="width:278px;">
+				<input type='button' value="$i18n.getString('filter')" style="width:80px;">
+				<input type='button' value="$i18n.getString('clear')" style="width:80px;">
+			</td>
+		</tr>
+		<tr>
+			<td>
+				<select id="identifiersSelector" multiple="multiple" style="width:450px;height:270px" ondblclick="insertElement( 'iden' )">
+					#foreach( $identifierType in $identifierTypes )
+						<option value="$identifierType.id">$encoder.htmlEncode($identifierType.displayName)</option>
+					#end
+				</select>
+			</td>
+		</tr>
+	</table>
+	
+	<table id="attributeTab" class='hidden'>
+		<tr>
+			<td>
+				<input type='text' placeholder="$i18n.getString('filter')" style="width:278px;">
+				<input type='button' value="$i18n.getString('filter')" style="width:80px;">
+				<input type='button' value="$i18n.getString('clear')" style="width:80px;">
+			</td>
+		</tr>
+		<tr>
+			<td>
+				<select id="attributesSelector" multiple="multiple" style="width:450px;height:270px" ondblclick="insertElement( 'attr' )">
+				#foreach( $attribute in $attributes )
+					<option value="$attribute.id">$encoder.htmlEncode($attribute.displayName)</option>
+				#end
+				</select>
+			</td>
+		</tr>
+	</table>
+	
+	<table id="programAttrTab" class='hidden'>
+		<tr>
+			<td>
+				<input type='text' placeholder="$i18n.getString('filter')" style="width:278px;">
+				<input type='button' value="$i18n.getString('filter')" style="width:80px;">
+				<input type='button' value="$i18n.getString('clear')" style="width:80px;">
+			</td>
+		</tr>
+		<tr>
+			<td>
+				<select id="programAttrSelector" multiple="multiple" style="width:450px;height:270px" ondblclick="insertElement( 'attr' )">
+					<option value="enrollmentDate">$encoder.htmlEncode($program.dateOfEnrollmentDescription)</option>
+					#if($program.displayIncidentDate=='true')
+					<option value="incidentDate">$encoder.htmlEncode($program.dateOfIncidentDescription)</option>
+					#end
+				</select>
+			</td>
+		</tr>
+	</table>
+	
+	<table>
+		<tr>
+			<td>
+				<button type="button" id="fixAttrButton" onclick="fixAttrOnClick()">$i18n.getString( "fixed_attributes" )</button>
+				<button type="button" id="identifierTypeButton" onclick="identifierTypeOnClick()">$i18n.getString( "identifier_types" )</button>
+				<button type="button" id="attributesButton" onclick="attributesOnClick()">$i18n.getString( "attributes" )</button>
+				<button type="button" id="programAttrButton" onclick="programAttrOnClick()">$i18n.getString( "program" )</button>
+			</td>
+		</tr>
+	</table>
+</div>
+
+<script>
+	var i18n_delete_program_data_entry_confirm = '$encoder.jsEscape( $i18n.getString( "delete_program_data_entry_confirm" ) , "'" )';
+</script>