← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13578: Add functionality to add dynamic attributes as parametters in a program template message(DONE).

 

------------------------------------------------------------
revno: 13578
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-01-06 15:56:57 +0700
message:
  Add functionality to add dynamic attributes as parametters in a program template message(DONE).
added:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonPatientReminder.vm
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientReminderService.java
  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/UpdatePatientAction.java
  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/patientForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientreminder/UpdateProgramPatientReminderAction.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/addProgramForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramPatientReminder.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programPatientReminder.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programPatientReminder.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramPatientReminder.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-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientReminderService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientReminderService.java	2014-01-06 06:29:46 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientReminderService.java	2014-01-06 08:56:57 +0000
@@ -52,9 +52,9 @@
     implements PatientReminderService
 {
 
-    private final String ATTRIBUTE = "identifierid";
+    private final String IDENTIFIER = "identifierid";
 
-    private final String IDENTIFIER = "attributeid";
+    private final String ATTRIBUTE = "attributeid";
 
     private final Pattern ATTRIBUTE_PATTERN = Pattern.compile( "\\{(" + IDENTIFIER + "|" + ATTRIBUTE + ")=(\\w+)\\}" );
 
@@ -91,7 +91,8 @@
     {
         Patient patient = programInstance.getPatient();
         String templateMessage = patientReminder.getTemplateMessage();
-
+        String template = templateMessage;
+        
         String organisationunitName = patient.getOrganisationUnit().getName();
         String programName = programInstance.getProgram().getName();
         String daysSinceEnrollementDate = DateUtils.daysBetween( new Date(), programInstance.getEnrollmentDate() ) + "";
@@ -109,11 +110,12 @@
         templateMessage = templateMessage.replace( PatientReminder.TEMPLATE_MESSSAGE_DAYS_SINCE_INCIDENT_DATE,
             daysSinceIncidentDate );
 
-        Matcher matcher = ATTRIBUTE_PATTERN.matcher( templateMessage );
+        Matcher matcher = ATTRIBUTE_PATTERN.matcher( template );
 
         while ( matcher.find() )
         {
             String match = matcher.group();
+            String value = "";
 
             if ( matcher.group( 1 ).equals( IDENTIFIER ) )
             {
@@ -122,10 +124,10 @@
                 {
                     if ( identifier.getIdentifierType() != null && identifier.getIdentifierType().getUid().equals( uid ) )
                     {
-                        templateMessage = templateMessage.replace( match, identifier.getIdentifier() );
-                        break;
+                        value = identifier.getIdentifier();
                     }
                 }
+
             }
             else if ( matcher.group( 1 ).equals( ATTRIBUTE ) )
             {
@@ -134,11 +136,13 @@
                 {
                     if ( attributeValue.getPatientAttribute().getUid().equals( uid ) )
                     {
-                        templateMessage = templateMessage.replace( match, attributeValue.getValue() );
-                        break;
+                        value = attributeValue.getValue();
                     }
                 }
+
             }
+
+            templateMessage = templateMessage.replace( match, value );
         }
 
         return templateMessage;

=== 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	2014-01-05 14:04:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java	2014-01-06 08:56:57 +0000
@@ -29,7 +29,6 @@
  */
 
 import java.util.Collection;
-import java.util.Date;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -50,7 +49,6 @@
 import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.patient.PatientIdentifierTypeService;
 import org.hisp.dhis.patient.PatientService;
-import org.hisp.dhis.patient.util.PatientIdentifierGenerator;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.relationship.Relationship;
 import org.hisp.dhis.relationship.RelationshipService;
@@ -136,60 +134,12 @@
             patient.setAssociate( userService.getUser( healthWorker ) );
         }
 
-        // -----------------------------------------------------------------------------
-        // Prepare Patient Identifiers
-        // -----------------------------------------------------------------------------
-
+        // ---------------------------------------------------------------------
+        // Prepare Patient Attributes
+        // ---------------------------------------------------------------------
+        
         HttpServletRequest request = ServletActionContext.getRequest();
 
-        Collection<PatientIdentifierType> identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
-
-        String value = null;
-
-        PatientIdentifier pIdentifier = null;
-
-        if ( identifierTypes != null && identifierTypes.size() > 0 )
-        {
-            for ( PatientIdentifierType identifierType : identifierTypes )
-            {
-                value = request.getParameter( PREFIX_IDENTIFIER + identifierType.getId() );
-
-                if ( StringUtils.isNotBlank( value ) )
-                {
-                    pIdentifier = new PatientIdentifier();
-                    pIdentifier.setIdentifierType( identifierType );
-                    pIdentifier.setPatient( patient );
-                    pIdentifier.setIdentifier( value.trim() );
-                    patient.getIdentifiers().add( pIdentifier );
-                }
-            }
-        }
-
-        // --------------------------------------------------------------------------------
-        // Generate system id with this format :
-        // (BirthDate)(Gender)(XXXXXX)(checkdigit)
-        // PatientIdentifierType will be null
-        // --------------------------------------------------------------------------------
-
-        String identifier = PatientIdentifierGenerator.getNewIdentifier( new Date(), "F" );
-
-        PatientIdentifier systemGenerateIdentifier = patientIdentifierService.get( null, identifier );
-        while ( systemGenerateIdentifier != null )
-        {
-            identifier = PatientIdentifierGenerator.getNewIdentifier( new Date(), "F" );
-            systemGenerateIdentifier = patientIdentifierService.get( null, identifier );
-        }
-
-        systemGenerateIdentifier = new PatientIdentifier();
-        systemGenerateIdentifier.setIdentifier( identifier );
-        systemGenerateIdentifier.setPatient( patient );
-
-        patient.getIdentifiers().add( systemGenerateIdentifier );
-
-        // -----------------------------------------------------------------------------
-        // Prepare Patient Attributes
-        // -----------------------------------------------------------------------------
-
         Collection<PatientAttribute> attributes = patientAttributeService.getAllPatientAttributes();
 
         Set<PatientAttributeValue> patientAttributeValues = new HashSet<PatientAttributeValue>();
@@ -200,7 +150,7 @@
         {
             for ( PatientAttribute attribute : attributes )
             {
-                value = request.getParameter( PREFIX_ATTRIBUTE + attribute.getId() );
+                String value = request.getParameter( PREFIX_ATTRIBUTE + attribute.getId() );
                 if ( StringUtils.isNotBlank( value ) )
                 {
                     attributeValue = new PatientAttributeValue();
@@ -231,7 +181,39 @@
         // Save patient
         // -------------------------------------------------------------------------
 
-        patientService.createPatient( patient, representativeId, relationshipTypeId, patientAttributeValues );
+        int patientId = patientService.createPatient( patient, representativeId, relationshipTypeId,
+            patientAttributeValues );
+
+        // -----------------------------------------------------------------------------
+        // Prepare Patient Identifiers
+        // -----------------------------------------------------------------------------
+
+        Collection<PatientIdentifierType> identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
+
+        String value = null;
+
+        PatientIdentifier pIdentifier = null;
+
+        if ( identifierTypes != null && identifierTypes.size() > 0 )
+        {
+            for ( PatientIdentifierType identifierType : identifierTypes )
+            {
+                value = request.getParameter( PREFIX_IDENTIFIER + identifierType.getId() );
+
+                if ( StringUtils.isNotBlank( value ) )
+                {
+                    pIdentifier = new PatientIdentifier();
+                    pIdentifier.setIdentifierType( identifierType );
+                    pIdentifier.setPatient( patient );
+                    pIdentifier.setIdentifier( value.trim() );
+                    patientIdentifierService.savePatientIdentifier( pIdentifier );
+
+                    patient.getIdentifiers().add( pIdentifier );
+                }
+            }
+        }
+
+        patientService.updatePatient( patient );
 
         // -------------------------------------------------------------------------
         // Create relationship
@@ -265,7 +247,7 @@
             }
         }
 
-        message = patient.getUid() + "_" + systemGenerateIdentifier.getIdentifier();
+        message = patient.getUid() + "_" + patientId;
 
         return SUCCESS;
     }

=== 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	2014-01-05 14:04:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java	2014-01-06 08:56:57 +0000
@@ -129,55 +129,12 @@
             patient.setAssociate( userService.getUser( healthWorker ) );
         }
 
-        // -------------------------------------------------------------------------------------
-        // Save PatientIdentifier
-        // -------------------------------------------------------------------------------------
-
+        // ---------------------------------------------------------------------
+        // Save Patient Attributes
+        // ---------------------------------------------------------------------
+        
         HttpServletRequest request = ServletActionContext.getRequest();
 
-        String value = null;
-
-        Collection<PatientIdentifierType> identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
-
-        PatientIdentifier identifier = null;
-
-        if ( identifierTypes != null && identifierTypes.size() > 0 )
-        {
-            for ( PatientIdentifierType identifierType : identifierTypes )
-            {
-                value = request.getParameter( AddPatientAction.PREFIX_IDENTIFIER + identifierType.getId() );
-
-                identifier = patientIdentifierService.getPatientIdentifier( identifierType, patient );
-
-                if ( StringUtils.isNotBlank( value ) )
-                {
-                    value = value.trim();
-
-                    if ( identifier == null )
-                    {
-                        identifier = new PatientIdentifier();
-                        identifier.setIdentifierType( identifierType );
-                        identifier.setPatient( patient );
-                        identifier.setIdentifier( value );
-                        patient.getIdentifiers().add( identifier );
-                    }
-                    else
-                    {
-                        identifier.setIdentifier( value );
-                        patient.getIdentifiers().add( identifier );
-                    }
-                }
-                else if ( identifier != null )
-                {
-                    patient.getIdentifiers().remove( identifier );
-                }
-            }
-        }
-
-        // --------------------------------------------------------------------------------------------------------
-        // Save Patient Attributes
-        // -----------------------------------------------------------------------------------------------------
-
         Collection<PatientAttribute> attributes = patientAttributeService.getAllPatientAttributes();
 
         List<PatientAttributeValue> valuesForSave = new ArrayList<PatientAttributeValue>();
@@ -192,7 +149,7 @@
 
             for ( PatientAttribute attribute : attributes )
             {
-                value = request.getParameter( AddPatientAction.PREFIX_ATTRIBUTE + attribute.getId() );
+                String value = request.getParameter( AddPatientAction.PREFIX_ATTRIBUTE + attribute.getId() );
 
                 if ( StringUtils.isNotBlank( value ) )
                 {
@@ -248,12 +205,62 @@
         patientService.updatePatient( patient, representativeId, relationshipTypeId, valuesForSave, valuesForUpdate,
             valuesForDelete );
 
+        // ---------------------------------------------------------------------
+        // Save PatientIdentifier
+        // ---------------------------------------------------------------------
+
+        String value = null;
+
+        Collection<PatientIdentifierType> identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
+
+        PatientIdentifier identifier = null;
+
+        if ( identifierTypes != null && identifierTypes.size() > 0 )
+        {
+            for ( PatientIdentifierType identifierType : identifierTypes )
+            {
+                value = request.getParameter( AddPatientAction.PREFIX_IDENTIFIER + identifierType.getId() );
+
+                identifier = patientIdentifierService.getPatientIdentifier( identifierType, patient );
+
+                if ( StringUtils.isNotBlank( value ) )
+                {
+                    value = value.trim();
+
+                    if ( identifier == null )
+                    {
+                        identifier = new PatientIdentifier();
+                        identifier.setIdentifierType( identifierType );
+                        identifier.setPatient( patient );
+                        identifier.setIdentifier( value );
+                        patientIdentifierService.savePatientIdentifier( identifier );
+
+                        patient.getIdentifiers().add( identifier );
+                    }
+                    else
+                    {
+                        identifier.setIdentifier( value );
+                        patientIdentifierService.updatePatientIdentifier( identifier );
+
+                        patient.getIdentifiers().add( identifier );
+                    }
+                }
+                else if ( identifier != null )
+                {
+                    patient.getIdentifiers().remove( identifier );
+                    patientIdentifierService.deletePatientIdentifier( identifier );
+                }
+            }
+        }
+
+        patientService.updatePatient( patient );
+
         return SUCCESS;
     }
 
-    // -----------------------------------------------------------------------------
+    // -------------------------------------------------------------------------
     // Getter/Setter
-    // -----------------------------------------------------------------------------
+    // -------------------------------------------------------------------------
 
     public void setUserService( UserService userService )
     {

=== 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	2014-01-05 14:04:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2014-01-06 08:56:57 +0000
@@ -160,7 +160,8 @@
 		  success: function(json) {
 			if(json.response=='success')
 			{
-				var patientId = json.message.split('_')[0];
+				var patientUid = json.message.split('_')[0];
+				var patientId = json.message.split('_')[1];
 				var	dateOfIncident = jQuery('#patientForm [id=dateOfIncident]').val();
 				var enrollmentDate = jQuery('#patientForm [id=enrollmentDate]').val();
 				
@@ -187,7 +188,7 @@
 							});
 						}
 						else{
-							showPatientDashboardForm( patientId );
+							showPatientDashboardForm( patientUid );
 						}
 					});
 				}

=== 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	2014-01-05 14:04:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm	2014-01-06 08:56:57 +0000
@@ -55,61 +55,7 @@
 	#end
 #end
 
-	<!-- ATTRIBUTES IN GROUPS -->
-	
-	#foreach ($attributeGroup in $attributeGroups )
-		#set($attributes = $attributesMap.get($attributeGroup.displayName))
-		#if( $attributes && $attributes.size() > 0 )
-			<tr><td>&nbsp;</td></tr>
-			<tr><th colspan="2" class="heading-column">$attributeGroup.displayName</th></tr>
-			#foreach($attribute in $attributes )
-				#if( $attribute )
-					#set($value = "")
-					#set($value = $patientAttributeValueMap.get($attribute.id))
-					<tr name='attributesFields'>
-						<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 == "bool" )
-								<select id="attr$attribute.id" name="attr$attribute.id" inherit="$!attribute.inherit" class="{validate:{required:$attribute.mandatory}" > 
-									<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 == "trueOnly" )
-								<input type='checkbox' value="true" id="attr$attribute.id" name="attr$attribute.id" inherit="$!attribute.inherit" #if($value=='true') checked #end class="{validate:{required:$attribute.mandatory}" > 
-							#elseif( $attribute.valueType == "date" )
-								<input type="text" id="attr$attribute.id" name="attr$attribute.id" inherit="$!attribute.inherit" value='$value' class="{validate:{required:$attribute.mandatory}" />
-								<script type="text/javascript">
-									datePickerValid( 'attr$attribute.id', false, false );
-								</script>                    
-							#elseif( $attribute.valueType == "combo" )  
-								<select id="attr$attribute.id" name="attr$attribute.id" inherit="$!attribute.inherit" class="{validate:{required:$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>
-							#elseif( $attribute.valueType == "phoneNumber" ) 
-								<input type='text' id="attr$attribute.id" name="attr$attribute.id" inherit="$!attribute.inherit" class="{validate:{phone:true,required:$attribute.mandatory}}}"/>
-							#elseif( $attribute.valueType == "trackerAssociate" ) 
-								<input type="checkbox" value='true' id="attr$attribute.id" name="attr$attribute.id" 
-									inherit="$!attribute.inherit" #if($value=='true') checked #end
-									onclick="toggleUnderAge(this);" class='underAge' />
-							#elseif( $attribute.valueType == "age" || $attribute.valueType == "number" ) 
-								<input type='text' id="attr$attribute.id" name="attr$attribute.id" inherit="$!attribute.inherit" class="{validate:{required:$attribute.mandatory,number:true}}"/>
-							#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
-
-	<tr><td>&nbsp;</td></tr>
-
-	<!-- ATTRIBUTES NOT IN GROUPS -->
+	<!-- ATTRIBUTES -->
 	#set($attributes = $attributesMap.get(""))
 	#if ($!attributes) 
 		<tr><th colspan="2" class="heading-column">$i18n.getString( "other_details" )</th></tr>

=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonPatientReminder.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonPatientReminder.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonPatientReminder.vm	2014-01-06 08:56:57 +0000
@@ -0,0 +1,13 @@
+{ "patientReminder": 
+  {
+    "id": $!{reminder.id},
+    "name": "$!encoder.jsonEncode( ${reminder.displayName} )",
+    "daysAllowedSendMessage": "$!{reminder.daysAllowedSendMessage}",
+    "templateMessage": "$!encoder.jsonEncode( ${reminder.templateMessage} )",
+    "dateToCompare": "$!{reminder.dateToCompare}",
+    "sendTo": "$!reminder.sendTo",
+    "whenToSend": "$!{reminder.whenToSend}",
+    "messageType": "$!{reminder.messageType}",
+	"userGroup": "$!encoder.jsonEncode( ${reminder.userGroup.name} )"
+  } 
+}

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientreminder/UpdateProgramPatientReminderAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientreminder/UpdateProgramPatientReminderAction.java	2014-01-06 06:29:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientreminder/UpdateProgramPatientReminderAction.java	2014-01-06 08:56:57 +0000
@@ -176,7 +176,6 @@
             reminder.setUserGroup( null );
         }
 
-        program.getPatientReminders().add( reminder );
         programService.updateProgram( program );
 
         return SUCCESS;

=== 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	2014-01-06 06:29:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2014-01-06 08:56:57 +0000
@@ -487,4 +487,5 @@
 template_reminder_message_details = Template reminder message details
 edit_template_reminder_message = Edit template reminder message
 create_new_template_reminder_message = Create new template reminder message
-confirm_delete_template_reminder_message=Are you sure you want to delete template reminder message?
\ No newline at end of file
+confirm_delete_template_reminder_message=Are you sure you want to delete template reminder message?
+days_before = day(s) before
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm	2014-01-06 06:29:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm	2014-01-06 08:56:57 +0000
@@ -39,7 +39,7 @@
 
 <h3>$i18n.getString( "create_new_program" )</h3>
 									
-<form id="addProgramForm" name="addProgramForm" action="addProgram.action" method="get" class="inputForm">
+<form id="addProgramForm" name="addProgramForm" action="addProgram.action" method="post" class="inputForm">
 	
 <table>
 	<thead>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramPatientReminder.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramPatientReminder.vm	2014-01-06 06:29:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramPatientReminder.vm	2014-01-06 08:56:57 +0000
@@ -5,6 +5,8 @@
 		
 		validation( 'addPatientReminderForm', function( form ){
 			form.submit();
+		}, function(){
+			enable('messageType');
 		});
 		checkValueIsExist( "name", "validateProgramPatientReminder.action" );
 	});
@@ -12,6 +14,7 @@
 </script>
 
 <h3>$i18n.getString( "create_new_template_reminder_message" )</h3>
+<h5>$program.displayName</h5>
 
 <form id="addPatientReminderForm" name="addPatientReminderForm" action="addProgramPatientReminder.action" method="post" onsubmit="selectAllById('selectedPropertyIds');" class="inputForm">
   
@@ -41,7 +44,7 @@
 		<tr>
 			<td><label>$i18n.getString( "date_to_compare")</label></td>
 			<td>
-				<select id='dateToCompare' name='dateToCompare'/>
+				<select id='datesToCompare' name='datesToCompare'/>
 					<option value="enrollmentdate">$i18n.getString( "enrollment_date" )</option>
 					<option value="dateofincident">$i18n.getString( "incident_date" )</option>
 				</select>
@@ -76,10 +79,11 @@
 		<tr>
 			<td><label>$i18n.getString( "user_group" )</label></td>
 			<td>
-				<select type="text" id="userGroup" name="userGroup" class="userGroup">
-				#foreach($eachGroup in $userGroups)
-					<option value="$eachGroup.id">$i18n.getString($eachGroup.name)</option>
-				#end	
+				<select type="text" id="userGroup" name="userGroup" class="userGroup" disabled>
+					<option value="">[$i18n.getString("please_select")]</option>
+					#foreach($eachGroup in $userGroups)
+						<option value="$eachGroup.id">$i18n.getString($eachGroup.name)</option>
+					#end	
 				</select>
 			</td>
 		</tr>
@@ -127,7 +131,7 @@
 		<td></td>
       	<td>
 			<input type="submit" value="$i18n.getString( 'add' )">
-			<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='program.action'">
+			<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='programPatientReminder.action?id=$program.id'">
 		</td>
       </tr>
   </table>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programPatientReminder.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programPatientReminder.js	2014-01-06 06:29:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programPatientReminder.js	2014-01-06 08:56:57 +0000
@@ -52,14 +52,44 @@
     setInnerHTML('daysAllowedSendMessageField', json.patientReminder.daysAllowedSendMessage);
     setInnerHTML('templateMessageField', json.patientReminder.templateMessage);
     setInnerHTML('dateToCompareField', json.patientReminder.dateToCompare);
-    setInnerHTML('sendToField', json.patientReminder.sendTo);
-    setInnerHTML('whenToSendField', json.patientReminder.whenToSend);
+	
+	var map = sendToMap();
+	setInnerHTML( 'sendToField', map[json.patientReminder.sendTo] ); 
+	
+	var whenToSend = i18n_days_scheduled;
+	if( json.patientReminder.whenToSend=='3'){
+		whenToSend = i18n_complete_program;
+	}
+	else if( json.patientReminder.whenToSend=='1'){
+		whenToSend = i18n_program_enrollment;
+	}
+	setInnerHTML('whenToSendField', whenToSend);
+    
+	var type = i18n_direct_sms;
+	if( json.patientReminder.messageType=='2'){
+		whenToSend = i18n_message;
+	}
+	else if( json.patientReminder.whenToSend=='3'){
+		whenToSend = i18n_both;
+	}
     setInnerHTML('messageTypeField', json.patientReminder.messageType);
+	
     setInnerHTML('userGroupField', json.patientReminder.userGroup);
     showDetails();
   });
 }
 
+function sendToMap()
+{
+	var typeMap = [];
+	typeMap['1'] = i18n_patient_sms_only;
+	typeMap['2'] = i18n_orgunit_phone_number_sms_only;
+	typeMap['3'] = i18n_health_worker_assigned_to_person;
+	typeMap['4'] = i18n_all_users_in_orgunit_registered;
+	typeMap['5'] = i18n_user_group;
+	return typeMap;
+}
+
 function showHideUserGroup() {
   jQuery(".sendTo").each(function( i, item ) {
     var numb = i + 1;

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programPatientReminder.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programPatientReminder.vm	2014-01-06 06:29:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programPatientReminder.vm	2014-01-06 08:56:57 +0000
@@ -6,7 +6,7 @@
   <ul id="contextMenuItems" class="contextMenuItems">
     <li><a data-target-fn="showUpdateProgramPatientReminder"><i class="fa fa-edit"></i>&nbsp;&nbsp;$i18n.getString( "edit" )</a></li>
     <li><a data-target-fn="removeProgramPatientReminder"><i class="fa fa-trash-o"></i>&nbsp;&nbsp;$i18n.getString( "remove" )</a></li>
-    <!-- li><a data-target-fn="showPatientReminderDetails"><i class="fa fa-info-circle"></i>&nbsp;&nbsp;$i18n.getString( "show_details" )</a></li -->
+    <li><a data-target-fn="showPatientReminderDetails"><i class="fa fa-info-circle"></i>&nbsp;&nbsp;$i18n.getString( "show_details" )</a></li>
   </ul>
 </div>
 
@@ -48,13 +48,13 @@
           <a href="javascript:hideDetails()" title="$i18n.getString( 'hide_details' )"><img src="../images/hide.png" alt="$i18n.getString( 'hide_details' )"></a>
 				</div>
         <p><label class="bold">$i18n.getString( "name" ):</label><br><span id="nameField"></span></p>
-        <p><label class="bold">$i18n.getString( "daysAllowedSendMessage" ):</label><br><span id="daysAllowedSendMessageField"></span></p>
-        <p><label class="bold">$i18n.getString( "templateMessage" ):</label><br><span id="templateMessageField"></span></p>
-        <p><label class="bold">$i18n.getString( "dateToCompare" ):</label><br><span id="dateToCompareField"></span></p>
-		<p><label class="bold">$i18n.getString( "sendTo" ):</label><br><span id="sendToField"></span></p>
-		<p><label class="bold">$i18n.getString( "whenToSend" ):</label><br><span id="whenToSendField"></span></p>
-		<p><label class="bold">$i18n.getString( "messageType" ):</label><br><span id="messageTypeField"></span></p>
-		<p><label class="bold">$i18n.getString( "userGroup" ):</label><br><span id="userGroupField"></span></p>
+        <p><label class="bold">$i18n.getString( "send_message" ):</label><br><span id="daysAllowedSendMessageField"></span> $i18n.getString("days_before")</p>
+        <p><label class="bold">$i18n.getString( "message" ):</label><br><span id="templateMessageField"></span></p>
+        <p><label class="bold">$i18n.getString( "date_to_compare" ):</label><br><span id="dateToCompareField"></span></p>
+		<p><label class="bold">$i18n.getString( "recipients" ):</label><br><span id="sendToField"></span></p>
+		<p><label class="bold">$i18n.getString( "send_message" ):</label><br><span id="whenToSendField"></span></p>
+		<p><label class="bold">$i18n.getString( "message_type" ):</label><br><span id="messageTypeField"></span></p>
+		<p><label class="bold">$i18n.getString( "user_group" ):</label><br><span id="userGroupField"></span></p>
 		</div>
 
 		</td>
@@ -75,4 +75,15 @@
 	var i18n_done = '$encoder.jsEscape( $i18n.getString( "done" ) , "'")';
 	var i18n_all = '$encoder.jsEscape( $i18n.getString( "all" ) , "'")';
 	var i18n_yes_only = '$encoder.jsEscape( $i18n.getString( "yes_only" ) , "'")';
+	var i18n_patient_sms_only = '$encoder.jsEscape( $i18n.getString( "patient_sms_only" ) , "'")';
+	var i18n_orgunit_phone_number_sms_only = '$encoder.jsEscape( $i18n.getString( "orgunit_phone_number_sms_only" ) , "'")';
+	var i18n_health_worker_assigned_to_person = '$encoder.jsEscape( $i18n.getString( "health_worker_assigned_to_person" ) , "'")';
+	var i18n_all_users_in_orgunit_registered = '$encoder.jsEscape( $i18n.getString( "all_users_in_orgunit_registered" ) , "'")';
+	var i18n_user_group = '$encoder.jsEscape( $i18n.getString( "user_group" ) , "'")';
+	var i18n_days_scheduled = '$encoder.jsEscape( $i18n.getString( "days_scheduled" ) , "'")';
+	var i18n_complete_program = '$encoder.jsEscape( $i18n.getString( "complete_program" ) , "'")';
+	var i18n_program_enrollment = '$encoder.jsEscape( $i18n.getString( "program_enrollment" ) , "'")';
+	var i18n_direct_sms = '$encoder.jsEscape( $i18n.getString( "direct_sms" ) , "'")';
+	var i18n_message = '$encoder.jsEscape( $i18n.getString( "message" ) , "'")';
+	var i18n_both = '$encoder.jsEscape( $i18n.getString( "both" ) , "'")';
 </script>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramPatientReminder.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramPatientReminder.vm	2014-01-06 06:29:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramPatientReminder.vm	2014-01-06 08:56:57 +0000
@@ -39,6 +39,8 @@
 		
 		validation( 'updatePatientReminderForm', function( form ){
 			form.submit();
+		}, function(){
+			enable('messageType');
 		});
 		checkValueIsExist( "name", "validateProgramPatientReminder.action",{id:getFieldValue('id')} );
 	});
@@ -46,8 +48,9 @@
 </script>
 
 <h3>$i18n.getString( "edit_template_reminder_message" )</h3>
+<h5>$program.displayName</h5>
 
-<form id="updatePatientReminderForm" name="updatePatientReminderForm" action="updateProgramPatientReminder.action" method="post" onsubmit="selectAllById('selectedPropertyIds');" class="inputForm">
+<form id="updatePatientReminderForm" name="updatePatientReminderForm" action="updateProgramPatientReminder.action" method="get" onsubmit="selectAllById('selectedPropertyIds');" class="inputForm">
 
   <input type="hidden" id="programId" name="programId" value="$program.id">
   <input type="hidden" id="id" name="id" value="$reminder.id">
@@ -76,7 +79,7 @@
 		<tr>
 			<td><label>$i18n.getString( "date_to_compare")</label></td>
 			<td>
-				<select id='dateToCompare' name='dateToCompare' #if($!reminder.whenToSend==3) disabled #end />
+				<select id='datesToCompare' name='datesToCompare' #if($!reminder.whenToSend==3) disabled #end />
 					<option value="enrollmentdate" #if($!reminder.dateToCompare=='enrollmentdate') selected #end>$i18n.getString( "enrollment_date" )</option>
 					<option value="dateofincident" #if($!reminder.dateToCompare=='dateofincident') selected #end>$i18n.getString( "incident_date" )</option>
 				</select>
@@ -120,9 +123,10 @@
 			<td><label>$i18n.getString( "user_group" )</label></td>
 			<td>
 				<select type="text" id="userGroup" name="userGroup" class="userGroup">
-				#foreach($eachGroup in $userGroups)
+					<option value="">[$i18n.getString("please_select")]</option>
+					#foreach($eachGroup in $userGroups)
 					<option value="$eachGroup.id" #if($!reminder.userGroup.id==$eachGroup.id) selected #end>$i18n.getString($eachGroup.name)</option>
-				#end	
+					#end	
 				</select>
 			</td>
 		</tr>
@@ -168,7 +172,7 @@
 			<td></td>
 			<td>
 				<input type="submit" value="$i18n.getString( 'update' )">
-				<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='program.action'">
+				<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='programPatientReminder.action?id=$program.id'">
 			</td>
 		 </tr>
   </table>