← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9688: Allow to add program enrollment-date and incident-date into person custom entry form. Person will...

 

------------------------------------------------------------
revno: 9688
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2013-02-02 17:34:22 +0700
message:
  Allow to add program enrollment-date and incident-date into person custom entry form. Person will be enrolled into the progam based these dates.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationFormService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientRegistrationFormService.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/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/multiDataEntrySelect.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingSelect.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/singleEventSelect.vm
  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/resources/org/hisp/dhis/patient/i18n_module.properties
  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


--
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/PatientRegistrationFormService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationFormService.java	2013-02-01 08:40:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationFormService.java	2013-02-02 10:34:22 +0000
@@ -33,6 +33,7 @@
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.user.User;
 
 /**
@@ -42,14 +43,21 @@
  */
 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 PROGRAM_PATTERN = Pattern.compile( "programid=\"(\\w+)\"" );
+
     final Pattern VALUE_TAG_PATTERN = Pattern.compile( "value=\"(.*?)\"", Pattern.DOTALL );
+
     final Pattern TITLE_TAG_PATTERN = Pattern.compile( "title=\"(.*?)\"", Pattern.DOTALL );
-  
+
     // --------------------------------------------------------------------------
     // ProgramDataEntryService
     // --------------------------------------------------------------------------
@@ -61,13 +69,14 @@
     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 );
-        
+    String prepareDataEntryFormForAdd( String htmlCode, Collection<User> healthWorkers, Patient patient,
+        ProgramInstance programInstance, I18n i18n, I18nFormat format );
+
 }

=== modified 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	2013-02-01 08:40:49 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientRegistrationFormService.java	2013-02-02 10:34:22 +0000
@@ -36,7 +36,11 @@
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
+import org.hisp.dhis.patientdatavalue.PatientDataValue;
+import org.hisp.dhis.patientdatavalue.PatientDataValueService;
 import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramInstance;
+import org.hisp.dhis.program.ProgramStageInstance;
 import org.hisp.dhis.user.User;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -140,7 +144,7 @@
 
     @Override
     public String prepareDataEntryFormForAdd( String htmlCode, Collection<User> healthWorkers, Patient patient,
-        I18n i18n, I18nFormat format )
+        ProgramInstance programInstance, I18n i18n, I18nFormat format )
     {
         int index = 1;
 
@@ -158,6 +162,7 @@
             Matcher fixedAttrMatcher = FIXED_ATTRIBUTE_PATTERN.matcher( inputHtml );
             Matcher identifierMatcher = IDENTIFIER_PATTERN.matcher( inputHtml );
             Matcher dynamicAttrMatcher = DYNAMIC_ATTRIBUTE_PATTERN.matcher( inputHtml );
+            Matcher programMatcher = PROGRAM_PATTERN.matcher( inputHtml );
             index++;
 
             if ( fixedAttrMatcher.find() && fixedAttrMatcher.groupCount() > 0 )
@@ -243,6 +248,21 @@
 
                 inputHtml = getAttributeField( inputHtml, attribute, value, i18n, index );
             }
+            else if ( programMatcher.find() && programMatcher.groupCount() > 0 )
+            {
+                String property = programMatcher.group( 1 );
+
+                // Get value
+                String value = "";
+                if ( programInstance != null )
+                {
+                    value = format.formatDate( ((Date) getValueFromProgram( property, programInstance )) );
+                }
+
+                inputHtml = "<input id=\"" + property + "\" name=\"" + property + "\" tabindex=\"" + index
+                    + "\" value=\"" + value + "\" " + TAG_CLOSE;
+                inputHtml += "<script>datePicker(\"" + property + "\", true);</script>";
+            }
 
             inputMatcher.appendReplacement( sb, inputHtml );
         }
@@ -456,4 +476,17 @@
         return null;
     }
 
+    private Object getValueFromProgram( String property, ProgramInstance programInstance )
+    {
+        try
+        {
+            return Patient.class.getMethod( "get" + property ).invoke( programInstance );
+        }
+        catch ( Exception ex )
+        {
+            ex.printStackTrace();
+        }
+        return null;
+    }
+
 }

=== 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	2013-02-01 08:40:49 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java	2013-02-02 10:34:22 +0000
@@ -39,7 +39,6 @@
 import org.hisp.dhis.patient.PatientAttributeGroup;
 import org.hisp.dhis.patient.PatientAttributeService;
 import org.hisp.dhis.patient.PatientIdentifier;
-import org.hisp.dhis.patient.PatientIdentifierService;
 import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.patient.PatientIdentifierTypeService;
 import org.hisp.dhis.patient.PatientRegistrationForm;
@@ -48,6 +47,8 @@
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
 import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramInstance;
+import org.hisp.dhis.program.ProgramInstanceService;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.relationship.Relationship;
 import org.hisp.dhis.relationship.RelationshipService;
@@ -83,6 +84,8 @@
     private RelationshipTypeService relationshipTypeService;
 
     private PatientRegistrationFormService patientRegistrationFormService;
+    
+    private ProgramInstanceService programInstanceService;
 
     private I18n i18n;
 
@@ -157,16 +160,25 @@
             if ( patientRegistrationForm != null )
             {
                 customRegistrationForm = patientRegistrationFormService.prepareDataEntryFormForAdd(
-                    patientRegistrationForm.getDataEntryForm().getHtmlCode(), healthWorkers, patient, i18n, format );
+                    patientRegistrationForm.getDataEntryForm().getHtmlCode(), healthWorkers, patient, null, i18n, format );
             }
         }
         else
         {
             Program program = programService.getProgram( programId );
+            Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstances( patient, program,
+                false );
+
+            ProgramInstance programInstance = null;
+            if ( programInstances.iterator().hasNext() )
+            {
+                programInstance = programInstances.iterator().next();
+            }
+            
             PatientRegistrationForm patientRegistrationForm = patientRegistrationFormService
                 .getPatientRegistrationForm( program );
             customRegistrationForm = patientRegistrationFormService.prepareDataEntryFormForAdd( patientRegistrationForm
-                .getDataEntryForm().getHtmlCode(), healthWorkers, patient, i18n, format );
+                .getDataEntryForm().getHtmlCode(), healthWorkers, patient, programInstance, i18n, format );
         }
 
         if ( customRegistrationForm == null )
@@ -356,6 +368,11 @@
         this.programService = programService;
     }
 
+    public void setProgramInstanceService( ProgramInstanceService programInstanceService )
+    {
+        this.programInstanceService = programInstanceService;
+    }
+
     public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService )
     {
         this.patientAttributeValueService = patientAttributeValueService;

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java	2013-02-01 08:40:49 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ShowAddPatientFormAction.java	2013-02-02 10:34:22 +0000
@@ -179,7 +179,7 @@
             if ( patientRegistrationForm != null )
             {
                 customRegistrationForm = patientRegistrationFormService.prepareDataEntryFormForAdd( patientRegistrationForm
-                    .getDataEntryForm().getHtmlCode(), healthWorkers, null, i18n, format );
+                    .getDataEntryForm().getHtmlCode(), healthWorkers, null, null, i18n, format );
             }
         }
         else
@@ -188,7 +188,7 @@
             PatientRegistrationForm patientRegistrationForm = patientRegistrationFormService
                 .getPatientRegistrationForm( program );
             customRegistrationForm = patientRegistrationFormService.prepareDataEntryFormForAdd( patientRegistrationForm
-                .getDataEntryForm().getHtmlCode(), healthWorkers, null, i18n, format );
+                .getDataEntryForm().getHtmlCode(), healthWorkers, null, null, i18n, format );
         }
 
         if ( customRegistrationForm == null )

=== 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-02-01 08:40:49 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-02-02 10:34:22 +0000
@@ -431,6 +431,8 @@
 			ref="org.hisp.dhis.relationship.RelationshipTypeService" />
 		<property name="patientRegistrationFormService"
 			ref="org.hisp.dhis.patient.PatientRegistrationFormService" />
+		<property name="programInstanceService"
+			ref="org.hisp.dhis.program.ProgramInstanceService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.caseentry.action.patient.AddPatientAction"

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2013-01-29 06:44:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2013-02-02 10:34:22 +0000
@@ -475,7 +475,6 @@
 	var programIdAddPatient = getFieldValue('programIdAddPatient');
 	if( programIdAddPatient!='' ){
 		enable('listPatientBtn');
-		enable('addPatientBtn');
 		enable('advancedSearchBtn');
 		jQuery('#advanced-search :input').each( function( idx, item ){
 			enable(this.id);
@@ -484,7 +483,6 @@
 	else
 	{
 		disable('listPatientBtn');
-		disable('addPatientBtn');
 		disable('advancedSearchBtn');
 		jQuery('#advanced-search :input').each( function( idx, item ){
 			disable(this.id);
@@ -961,7 +959,8 @@
 	jQuery('#loaderDiv').show();
 	jQuery('#editPatientDiv').load('showUpdatePatientForm.action',
 		{
-			id:patientId
+			id:patientId,
+			programId: getFieldValue('programIdAddPatient')
 		}, function()
 		{
 			jQuery('#searchPatientsDiv').dialog('close');
@@ -1014,12 +1013,32 @@
 
 function updatePatient()
 {
+	var params = 'programId=' + getFieldValue('programIdAddPatient') 
+		+ '&' + getParamsForDiv('editPatientDiv');
+
 	$.ajax({
       type: "POST",
       url: 'updatePatient.action',
-      data: getParamsForDiv('editPatientDiv'),
+      data: params,
       success: function( json ) {
-		showPatientDashboardForm( getFieldValue('id') );
+			if( getFieldValue('programIdAddPatient')!='')
+			{
+				jQuery.postJSON( "saveProgramEnrollment.action",
+				{
+					patientId: getFieldValue('id'),
+					programId: getFieldValue('programIdAddPatient'),
+					dateOfIncident: jQuery('#patientForm [id=dateOfIncident]').val(),
+					enrollmentDate: jQuery('#patientForm [id=enrollmentDate]').val()
+				}, 
+				function( json ) 
+				{ 
+					showPatientDashboardForm( getFieldValue('id') );
+				});
+			}
+			else
+			{
+				showPatientDashboardForm( getFieldValue('id') );
+			}
       }
      });
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2012-12-18 06:17:04 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2013-02-02 10:34:22 +0000
@@ -82,7 +82,7 @@
 	hideById('migrationPatientDiv');
 	
 	jQuery('#loaderDiv').show();
-	jQuery('#editPatientDiv').load('showAddPatientForm.action'
+	jQuery('#editPatientDiv').load('showAddPatientForm.action?programId=' + getFieldValue('programIdAddPatient')
 		, function()
 		{
 			showById('editPatientDiv');
@@ -136,27 +136,48 @@
 }
 
 function addPatient( isContinue )
-{
+{		
+	var params = 'programId=' + getFieldValue('programIdAddPatient') + '&' + getParamsForDiv('patientForm');
 	$.ajax({
       type: "POST",
       url: 'addPatient.action',
-      data: getParamsForDiv('patientForm'),
+      data: params,
       success: function(json) {
-		var patientId = json.message.split('_')[0];
-		if(isContinue){
-			jQuery("#patientForm :input").each( function(){
-				if( $(this).attr('id') != "registrationDate" 
-					&& $(this).attr('type') != 'button'
-					&& $(this).attr('type') != 'submit' )
+		if(json.response=='success')
+		{
+			var patientId = json.message.split('_')[0];
+			var programId = getFieldValue('programIdAddPatient');
+			var	dateOfIncident = jQuery('#patientForm [id=dateOfIncident]').val();
+			var enrollmentDate = jQuery('#patientForm [id=enrollmentDate]').val();
+					
+			if( getFieldValue('programIdAddPatient')!='' && enrollmentDate != '')
+			{
+				jQuery.postJSON( "saveProgramEnrollment.action",
 				{
-					$(this).val("");
-				}
-			});
-			$("#patientForm :input").attr("disabled", false);
-			$("#patientForm").find("select").attr("disabled", false);
-		}
-		else{
-			showPatientDashboardForm( patientId );
+					patientId: patientId,
+					programId: programId,
+					dateOfIncident: dateOfIncident,
+					enrollmentDate: enrollmentDate
+				}, 
+				function( json ) 
+				{    
+					if(isContinue){
+						jQuery("#patientForm :input").each( function(){
+							if( $(this).attr('id') != "registrationDate" 
+								&& $(this).attr('type') != 'button'
+								&& $(this).attr('type') != 'submit' )
+							{
+								$(this).val("");
+							}
+						});
+						$("#patientForm :input").attr("disabled", false);
+						$("#patientForm").find("select").attr("disabled", false);
+					}
+					else{
+						showPatientDashboardForm( patientId );
+					}
+				});
+			}
 		}
       }
      });

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/multiDataEntrySelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/multiDataEntrySelect.vm	2012-12-18 05:57:32 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/multiDataEntrySelect.vm	2013-02-02 10:34:22 +0000
@@ -1,6 +1,5 @@
 <script>
 	jQuery(document).ready(	function(){
-		showById('programAddPatientTR');
 		jQuery("#programIdAddPatient option").each(function(){
 			var item = jQuery(this);
 			if( item.attr('type')!=1 && item.val()!='' ){

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingSelect.vm	2012-12-10 12:54:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingSelect.vm	2013-02-02 10:34:22 +0000
@@ -1,6 +1,5 @@
 <script>
 	jQuery(document).ready(	function(){
-		showById('programAddPatientTR');
 		showById('programStageAddPatientTR');
 		showById('sendSmsToListBtn');
 		jQuery("#programIdAddPatient option").each(function(){

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm	2013-01-28 05:28:45 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm	2013-02-02 10:34:22 +0000
@@ -17,7 +17,7 @@
 			<input type="button" class='large-button' id='advancedSearchBtn' value='$i18n.getString( "search" )' onclick="jQuery('#advanced-search').toggle();" disabled>
 		</td>
 	</tr> 
-	<tr id='programAddPatientTR' class='hidden'>
+	<tr id='programAddPatientTR'>
 		<td>$i18n.getString('program')</td>
 		<td>
 			<select id='programIdAddPatient' name='programIdAddPatient' onchange='enableBtn();'>
@@ -137,5 +137,4 @@
 		programComboBox += '<option value="$program.id">$program.displayName</option>';
 	#end
 	programComboBox += '</select>';
-	
 </script>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/singleEventSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/singleEventSelect.vm	2012-12-10 12:54:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/singleEventSelect.vm	2013-02-02 10:34:22 +0000
@@ -1,6 +1,5 @@
 <script>
 	jQuery(document).ready(	function(){
-		showById('programAddPatientTR');
 		jQuery("#programIdAddPatient option").each(function(){
 			var item = jQuery(this);
 			if(item.attr('type')!=2){

=== modified 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	2013-02-01 08:40:49 +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-02 10:34:22 +0000
@@ -95,6 +95,8 @@
 
         programs = new ArrayList<Program>( programService.getAllPrograms() );
 
+        programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) );
+
         for ( PatientRegistrationForm registrationForm : registrationForms )
         {
             if ( registrationForm.getProgram() != null )

=== 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-02-01 08:40:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2013-02-02 10:34:22 +0000
@@ -194,7 +194,7 @@
 test_condition=Test condition
 run_success=Run successful
 run_fail=Run failed
-total_of_patient_registration=Total of patient registration
+total_of_patient_registration=Total of person registration
 repeatable=Repeatable
 date_of_birth=Date of Birth
 anonymous=Anonymous
@@ -327,9 +327,9 @@
 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
-patient_registration_form = Patient Registration Form
+patient_registration_form = Person Registration Form
 intro_patient_registration_form = Define custom person registration form
-patient_registration_form_management = Patient registration form management
+patient_registration_form_management = Person registration form management
 properties = Properties
 full_name = Full name
 birth_date = Date of birth
@@ -338,8 +338,8 @@
 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
+patient_registration_details  = Person registration details
+design_patient_registration_form = Design person 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

=== modified 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	2013-02-01 08:40:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewPatientRegistationForm.js	2013-02-02 10:34:22 +0000
@@ -66,6 +66,11 @@
 		id = 'attributeid="' + element.attr('value') + '"';
 		value = element.text();
 	}
+	else if( type == 'prg' ){
+		var element = jQuery('#programAttrSelector option:selected');
+		id = 'programid="' + element.attr('value') + '"';
+		value = element.text();
+	}
 	
 	var htmlCode = "<input " + id + " value=\"[" + value + "]\" title=\"" + value + "\">";
 	

=== modified 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	2013-02-01 08:40:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientRegistrationForm.vm	2013-02-02 10:34:22 +0000
@@ -1,8 +1,9 @@
 <h3>$i18n.getString( "patient_registration_form_management" ) #openHelp( "program" )</h3>
 
 <table class="mainPageTable">
-	#if( $programs.size() > 0 )
+	
 	<tr>
+		#if( $programs.size() > 0 )
 		<td>
 			<label>$i18n.getString('program')</label>
 			<select name="programId" id="programId" style="width:20em" >
@@ -12,10 +13,21 @@
 				#end
 			</select>
 		</td>
+		#end
+		
+		#set($display = 'block')
+		#if( $programs.size() == 0 )
+			#foreach( $registrationForm in $registrationForms )
+				#if( $registrationForm.progam )
+				#else
+					#set($hidden = 'none')
+				#end
+			#end
+		#end
 		<td align="right">
-			<input type="button" value="$i18n.getString( 'add_new' )" onclick="addNewForm();" style="width:70px">
+			<input type="button" value="$i18n.getString( 'add_new' )" onclick="addNewForm();" style="width:70px;display:$display">
 		</td>
-	#else
+	#if( $programs.size() == 0 )
 		<input type='hidden' name="programId" id="programId" value="" />
 	#end
   </tr>
@@ -23,18 +35,27 @@
     <td style="vertical-align:top" colspan='2'>
 		
 		<table class="listTable">
-			  <col>          
+			  <col>   
+			  <col>  			  
 			  <col width="40">
 			<thead>			  
 			  <tr>            
 				<th>$i18n.getString( "name" )</th>
+				<th>$i18n.getString( "program" )</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>$encoder.htmlEncode( $registrationForm.dataEntryForm.name )</td>  
+					<td>
+						#if($registrationForm.program)
+							$encoder.htmlEncode( $registrationForm.program.name )
+						#else
+							$i18n.getString('all')
+						#end	
+					</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>

=== modified 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	2013-02-01 08:40:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewPatientRegistationForm.vm	2013-02-02 10:34:22 +0000
@@ -1,4 +1,4 @@
-<script type="text/javascript">
+hh<script type="text/javascript">
   
 	jQuery(document).ready(	function()
 	{
@@ -173,10 +173,10 @@
 		</tr>
 		<tr>
 			<td>
-				<select id="programAttrSelector" multiple="multiple" style="width:450px;height:270px" ondblclick="insertElement( 'attr' )">
+				<select id="programAttrSelector" multiple="multiple" style="width:450px;height:270px" ondblclick="insertElement( 'prg' )">
 					<option value="enrollmentDate">$encoder.htmlEncode($program.dateOfEnrollmentDescription)</option>
 					#if($program.displayIncidentDate=='true')
-					<option value="incidentDate">$encoder.htmlEncode($program.dateOfIncidentDescription)</option>
+					<option value="dateOfIncident">$encoder.htmlEncode($program.dateOfIncidentDescription)</option>
 					#end
 				</select>
 			</td>