dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #27324
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13586: Add dynamic attributes as parametters of prorgam-stage template message.
------------------------------------------------------------
revno: 13586
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-01-06 20:23:58 +0700
message:
Add dynamic attributes as parametters of prorgam-stage template message.
added:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientreminder/ShowAddProgramPatientReminderAction.java
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientreminder/GetPatientReminderAction.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/struts.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.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/javascript/programStage.js
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/updateProgramStageForm.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/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2014-01-05 14:04:13 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2014-01-06 13:23:58 +0000
@@ -734,7 +734,9 @@
+ CaseAggregationCondition.SEPARATOR_OBJECT + max + ".age]";
updateFixedAttributeInCaseAggregate( source, target );
+ // -------------------------------------------------------------
// Patient full name
+ // -------------------------------------------------------------
uid = CodeGenerator.generateCode();
executeSql( "INSERT INTO patientattribute (patientattributeid, uid, lastUpdated, name, description, valueType, mandatory, inherit, displayOnVisitSchedule ) VALUES ("
@@ -752,7 +754,7 @@
removeFixedAttributeInCustomRegistrationForm( "fullName", uid );
// update template messsages
- updateFixedAttributeInTemplateMessage();
+ updateFixedAttributeInTemplateMessage(uid);
executeSql( "ALTER TABLE patient DROP COLUMN gender" );
executeSql( "ALTER TABLE patient DROP COLUMN deathDate" );
@@ -802,24 +804,22 @@
}
}
- private void updateFixedAttributeInTemplateMessage()
+ private void updateFixedAttributeInTemplateMessage( String uid )
{
StatementHolder holder = statementManager.getHolder();
try
{
Statement statement = holder.getStatement();
- ResultSet resultSet = statement.executeQuery( "" );
+ ResultSet resultSet = statement
+ .executeQuery( "SELECT patientreminderid, templatemessage FROM patientreminder where templatemessage like '%{patient-name}%'" );
while ( resultSet.next() )
{
String id = resultSet.getString( "patientreminderid" );
String expression = resultSet.getString( "templatemessage" );
- expression = expression
- .replaceAll(
- "SELECT patientreminderid, templatemessage FROM patientreminder where templatemessage like '%{patient-name}%'",
- "Sir/Madam" );
+ expression = expression.replaceAll( "{patient-name}", "{attributeid=" + uid + "}" );
executeSql( "UPDATE patientreminder SET templatemessage='" + expression + "' WHERE patientreminderid="
+ id );
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientreminder/GetPatientReminderAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientreminder/GetPatientReminderAction.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/GetPatientReminderAction.java 2014-01-06 13:23:58 +0000
@@ -27,10 +27,15 @@
package org.hisp.dhis.patient.action.patientreminder;
+import java.util.ArrayList;
+import java.util.List;
+
import org.hisp.dhis.patient.PatientReminder;
import org.hisp.dhis.patient.PatientReminderService;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.user.UserGroup;
+import org.hisp.dhis.user.UserGroupService;
import com.opensymphony.xwork2.Action;
@@ -60,6 +65,13 @@
this.patientReminderService = patientReminderService;
}
+ private UserGroupService userGroupService;
+
+ public void setUserGroupService( UserGroupService userGroupService )
+ {
+ this.userGroupService = userGroupService;
+ }
+
// -------------------------------------------------------------------------
// Input && Output
// -------------------------------------------------------------------------
@@ -92,6 +104,13 @@
return reminder;
}
+ private List<UserGroup> userGroups;
+
+ public List<UserGroup> getUserGroups()
+ {
+ return userGroups;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -103,7 +122,9 @@
reminder = patientReminderService.getPatientReminder( id );
program = programService.getProgram( programId );
-
+
+ userGroups = new ArrayList<UserGroup>( userGroupService.getAllUserGroups() );
+
return SUCCESS;
}
}
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientreminder/ShowAddProgramPatientReminderAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientreminder/ShowAddProgramPatientReminderAction.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/patientreminder/ShowAddProgramPatientReminderAction.java 2014-01-06 13:23:58 +0000
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.patient.action.patientreminder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.user.UserGroup;
+import org.hisp.dhis.user.UserGroupService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version $ ShowAddProgramPatientReminderAction.java Jan 6, 2014 7:51:48 PM $
+ */
+public class ShowAddProgramPatientReminderAction
+ implements Action
+{
+ private ProgramService programService;
+
+ public void setProgramService( ProgramService programService )
+ {
+ this.programService = programService;
+ }
+
+ private UserGroupService userGroupService;
+
+ public void setUserGroupService( UserGroupService userGroupService )
+ {
+ this.userGroupService = userGroupService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input/Output
+ // -------------------------------------------------------------------------
+
+ private int id;
+
+ public void setId( int id )
+ {
+ this.id = id;
+ }
+
+ private Program program;
+
+ public Program getProgram()
+ {
+ return program;
+ }
+
+ private List<UserGroup> userGroups;
+
+ public List<UserGroup> getUserGroups()
+ {
+ return userGroups;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ program = programService.getProgram( id );
+
+ userGroups = new ArrayList<UserGroup>( userGroupService.getAllUserGroups() );
+
+ 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 2014-01-06 06:29:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2014-01-06 13:23:58 +0000
@@ -1180,8 +1180,9 @@
scope="prototype">
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
<property name="patientReminderService" ref="org.hisp.dhis.patient.PatientReminderService" />
+ <property name="userGroupService" ref="org.hisp.dhis.user.UserGroupService" />
</bean>
-
+
<bean
id="org.hisp.dhis.patient.action.patientreminder.ValidateProgramPatientReminderAction"
class="org.hisp.dhis.patient.action.patientreminder.ValidateProgramPatientReminderAction"
@@ -1189,4 +1190,11 @@
<property name="patientReminderService" ref="org.hisp.dhis.patient.PatientReminderService" />
</bean>
+ <bean
+ id="org.hisp.dhis.patient.action.patientreminder.ShowAddProgramPatientReminderAction"
+ class="org.hisp.dhis.patient.action.patientreminder.ShowAddProgramPatientReminderAction"
+ scope="prototype">
+ <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+ <property name="userGroupService" ref="org.hisp.dhis.user.UserGroupService" />
+ </bean>
</beans>
\ 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 2014-01-06 11:40:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml 2014-01-06 13:23:58 +0000
@@ -1180,7 +1180,7 @@
</action>
<action name="showAddProgramPatientReminder"
- class="org.hisp.dhis.patient.action.program.GetProgramAction">
+ class="org.hisp.dhis.patient.action.patientreminder.ShowAddProgramPatientReminderAction">
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-maintenance-patient/addProgramPatientReminder.vm</param>
<param name="javascripts">javascript/commons.js,javascript/programPatientReminder.js</param>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm 2013-12-31 03:05:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm 2014-01-06 13:23:58 +0000
@@ -275,4 +275,12 @@
#foreach($programStage in $program.programStages)
programStageList.push("$programStage.displayName");
#end
+
+ var idenAttrOptions = "";
+ #foreach($identifierType in $program.patientIdentifierTypes)
+ idenAttrOptions+="<option value={identifierid=$identifierType.uid}>$identifierType.displayName</option>";
+ #end
+ #foreach($patientAttribute in $program.patientAttributes)
+ idenAttrOptions+="<option value={attributeid=$patientAttribute.uid}>$patientAttribute.displayName</option>";
+ #end
</script>
\ 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/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 08:56:57 +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 13:23:58 +0000
@@ -159,4 +159,11 @@
else {
enable('messageType');
}
+
+ if( value == "5" ){
+ enable('userGroup');
+ }
+ else{
+ disable('userGroup');
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js 2013-12-17 01:29:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js 2014-01-06 13:23:58 +0000
@@ -378,12 +378,12 @@
+ '<td>' + i18n_params + '</td>'
+ '<td>'
+ '<select multiple size="4" id="params' + rowId +'" name="params" ondblclick="insertParams(this.value, ' + rowId + ');">'
- + '<option value="{patient-name}">' + i18n_patient_name + '</option>'
+ '<option value="{program-name}">' + i18n_program_name + '</option>'
+ '<option value="{program-stage-name}">' + i18n_program_stage_name + '</option>'
+ '<option value="{due-date}">' + i18n_due_date + '</option>'
+ '<option value="{days-since-due-date}">' + i18n_days_since_due_date + '</option>'
+ '<option value="{orgunit-name}">' + i18n_orgunit_name + '</option>'
+ + idenAttrOptions
+ '</select>'
+ '</td>'
+ '</tr>'
=== 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 08:56:57 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramPatientReminder.vm 2014-01-06 13:23:58 +0000
@@ -122,7 +122,7 @@
<tr>
<td><label>$i18n.getString( "user_group" )</label></td>
<td>
- <select type="text" id="userGroup" name="userGroup" class="userGroup">
+ <select type="text" id="userGroup" name="userGroup" class="userGroup" #if($!reminder.sendTo!=5) disabled #end >
<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>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm 2013-12-31 03:05:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm 2014-01-06 13:23:58 +0000
@@ -316,12 +316,17 @@
<td>$i18n.getString( "params" )</td>
<td>
<select multiple size='4' ondblclick="insertParams(this.value, $index);">
- <option value="{patient-name}">$i18n.getString("patient_name")</option>
<option value="{program-name}">$i18n.getString("program_name")</option>
<option value="{program-stage-name}">$i18n.getString("program_stage_name")</option>
<option value="{due-date}">$i18n.getString("due_date")</option>
<option value="{days-since-due-date}">$i18n.getString("days_since_due_date")</option>
<option value="{orgunit-name}">$i18n.getString("orgunit_name")</option>
+ #foreach($identifierType in $program.patientIdentifierTypes)
+ <option value={identifierid=$identifierType.uid}>$identifierType.displayName</option>
+ #end
+ #foreach($patientAttribute in $program.patientAttributes)
+ <option value={attributeid=$patientAttribute.uid}>$patientAttribute.displayName</option>
+ #end
</select>
</td>
</tr>
@@ -387,4 +392,13 @@
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" ) , "'")';
+
+ var idenAttrOptions = "";
+ #foreach($identifierType in $programStage.program.patientIdentifierTypes)
+ idenAttrOptions+="<option value={identifierid=$identifierType.uid}>$identifierType.displayName</option>";
+ #end
+ #foreach($patientAttribute in $programStage.program.patientAttributes)
+ idenAttrOptions+="<option value={attributeid=$patientAttribute.uid}>$patientAttribute.displayName</option>";
+ #end
+
</script>
\ No newline at end of file