dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18735
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7924: Add a function to allow adding commends for each event into SMS Reminder.
------------------------------------------------------------
revno: 7924
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-08-17 13:42:32 +0700
message:
Add a function to allow adding commends for each event into SMS Reminder.
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/comment/
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/comment/Comment.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/comment/CommentService.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/comment/
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/comment/DefaultCommentService.java
dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/comment/
dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/comment/hibernate/
dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/comment/hibernate/Comment.hbm.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/AddCommentAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/RemoveCommentAction.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java
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/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/GetOutboundSmsListAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsReminderList.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsReminderSelect.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css
--
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
=== added directory 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/comment'
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/comment/Comment.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/comment/Comment.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/comment/Comment.java 2012-08-17 06:42:32 +0000
@@ -0,0 +1,107 @@
+/*
+ * 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.comment;
+
+import java.util.Date;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version Comment.java 9:24:52 AM Aug 17, 2012 $
+ */
+public class Comment
+{
+ private int id;
+
+ private String commentText;
+
+ private Date createdDate;
+
+ private String creator;
+
+ // -------------------------------------------------------------------------
+ // Constructor
+ // -------------------------------------------------------------------------
+
+ public Comment()
+ {
+
+ }
+
+ public Comment( String commentText, String creator, Date createdDate )
+ {
+ this.commentText = commentText;
+ this.creator = creator;
+ this.createdDate = createdDate;
+ }
+
+ // -------------------------------------------------------------------------
+ // Getters/Setters
+ // -------------------------------------------------------------------------
+
+ public int getId()
+ {
+ return id;
+ }
+
+ public void setId( int id )
+ {
+ this.id = id;
+ }
+
+ public String getCommentText()
+ {
+ return commentText;
+ }
+
+ public void setCommentText( String commentText )
+ {
+ this.commentText = commentText;
+ }
+
+ public Date getCreatedDate()
+ {
+ return createdDate;
+ }
+
+ public void setCreatedDate( Date createdDate )
+ {
+ this.createdDate = createdDate;
+ }
+
+ public String getCreator()
+ {
+ return creator;
+ }
+
+ public void setCreator( String creator )
+ {
+ this.creator = creator;
+ }
+
+}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/comment/CommentService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/comment/CommentService.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/comment/CommentService.java 2012-08-17 06:42:32 +0000
@@ -0,0 +1,51 @@
+/*
+ * 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.comment;
+
+import java.util.Collection;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version CommentService.java 9:27:31 AM Aug 17, 2012 $
+ */
+public interface CommentService
+{
+ String ID = CommentService.class.getName();
+
+ int addComment( Comment comment );
+
+ void deleteComment( Comment comment );
+
+ void updateComment( Comment comment );
+
+ Comment getComment( int id );
+
+ Collection<Comment> getAllComments();
+
+}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java 2012-08-16 15:47:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java 2012-08-17 06:42:32 +0000
@@ -29,8 +29,10 @@
import java.io.Serializable;
import java.util.Date;
import java.util.List;
+import java.util.Set;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.patient.comment.Comment;
import org.hisp.dhis.sms.outbound.OutboundSms;
/**
@@ -65,6 +67,8 @@
private boolean completed = false;
private List<OutboundSms> outboundSms;
+
+ private Set<Comment> comments;
// -------------------------------------------------------------------------
// Constructors
@@ -241,4 +245,14 @@
{
this.outboundSms = outboundSms;
}
+
+ public Set<Comment> getComments()
+ {
+ return comments;
+ }
+
+ public void setComments( Set<Comment> comments )
+ {
+ this.comments = comments;
+ }
}
=== added directory 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/comment'
=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/comment/DefaultCommentService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/comment/DefaultCommentService.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/comment/DefaultCommentService.java 2012-08-17 06:42:32 +0000
@@ -0,0 +1,87 @@
+/*
+ * 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.comment;
+
+import java.util.Collection;
+
+import org.hisp.dhis.common.GenericIdentifiableObjectStore;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version DefaultCommentService.java 9:45:40 AM Aug 17, 2012 $
+ */
+public class DefaultCommentService
+ implements CommentService
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private GenericIdentifiableObjectStore<Comment> commentStore;
+
+ public void setCommentStore( GenericIdentifiableObjectStore<Comment> commentStore )
+ {
+ this.commentStore = commentStore;
+ }
+
+ // -------------------------------------------------------------------------
+ // Implementation methods
+ // -------------------------------------------------------------------------
+
+ @Override
+ public int addComment( Comment comment )
+ {
+ return commentStore.save( comment );
+ }
+
+ @Override
+ public void deleteComment( Comment comment )
+ {
+ commentStore.delete( comment );
+ }
+
+ @Override
+ public void updateComment( Comment comment )
+ {
+ commentStore.update( comment );
+ }
+
+ @Override
+ public Comment getComment( int id )
+ {
+ return commentStore.get( id );
+ }
+
+ @Override
+ public Collection<Comment> getAllComments()
+ {
+ return commentStore.getAll();
+ }
+
+}
=== 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 2012-07-30 08:32:57 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2012-08-17 06:42:32 +0000
@@ -366,6 +366,19 @@
<property name="jdbcTemplate" ref="jdbcTemplate" />
</bean>
+ <!-- Comment -->
+
+ <bean id="org.hisp.dhis.patient.comment.CommentService"
+ class="org.hisp.dhis.patient.comment.DefaultCommentService">
+ <property name="commentStore" ref="org.hisp.dhis.patient.comment.CommentStore" />
+ </bean>
+
+ <bean id="org.hisp.dhis.patient.comment.CommentStore"
+ class="org.hisp.dhis.hibernate.HibernateGenericStore">
+ <property name="clazz" value="org.hisp.dhis.patient.comment.Comment" />
+ <property name="sessionFactory" ref="sessionFactory" />
+ </bean>
+
<!-- Startup -->
<bean id="org.hisp.dhis.patient.startup.TableAlteror" class="org.hisp.dhis.patient.startup.TableAlteror">
=== added directory 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/comment'
=== added directory 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/comment/hibernate'
=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/comment/hibernate/Comment.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/comment/hibernate/Comment.hbm.xml 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/comment/hibernate/Comment.hbm.xml 2012-08-17 06:42:32 +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.comment.Comment" table="comment">
+
+ <id name="id" column="commentid">
+ <generator class="native" />
+ </id>
+
+ <property name="commentText" column="commenttext"/>
+
+ <property name="createdDate" column="createddate"/>
+
+ <property name="creator" column="creator"/>
+
+ </class>
+</hibernate-mapping>
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml 2012-08-16 15:47:08 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml 2012-08-17 06:42:32 +0000
@@ -30,6 +30,11 @@
<list-index column="sort_order" base="1" />
<many-to-many class="org.hisp.dhis.sms.outbound.OutboundSms" column="outboundsmsid" />
</list>
+
+ <set name="comments" order-by="createdDate desc" >
+ <key column="programstageinstanceid" />
+ <one-to-many class="org.hisp.dhis.patient.comment.Comment" />
+ </set>
</class>
</hibernate-mapping>
=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/AddCommentAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/AddCommentAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/AddCommentAction.java 2012-08-17 06:42:32 +0000
@@ -0,0 +1,109 @@
+/*
+ * 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.caseentry.action.reminder;
+
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.hisp.dhis.patient.comment.Comment;
+import org.hisp.dhis.program.ProgramStageInstance;
+import org.hisp.dhis.program.ProgramStageInstanceService;
+import org.hisp.dhis.user.CurrentUserService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version AddCommentAction.java 9:55:04 AM Aug 17, 2012 $
+ */
+public class AddCommentAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ProgramStageInstanceService programStageInstanceService;
+
+ public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+ {
+ this.programStageInstanceService = programStageInstanceService;
+ }
+
+ private CurrentUserService currentUserService;
+
+ public void setCurrentUserService( CurrentUserService currentUserService )
+ {
+ this.currentUserService = currentUserService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private Integer programStageInstanceId;
+
+ public void setProgramStageInstanceId( Integer programStageInstanceId )
+ {
+ this.programStageInstanceId = programStageInstanceId;
+ }
+
+ private String commentText;
+
+ public void setCommentText( String commentText )
+ {
+ this.commentText = commentText;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ ProgramStageInstance programStageInstance = programStageInstanceService
+ .getProgramStageInstance( programStageInstanceId );
+
+ Set<Comment> comments = programStageInstance.getComments();
+
+ if ( comments == null )
+ {
+ comments = new HashSet<Comment>();
+ }
+
+ Comment comment = new Comment( commentText, currentUserService.getCurrentUsername(), new Date() );
+ comments.add( comment );
+
+ programStageInstanceService.updateProgramStageInstance( programStageInstance );
+
+ return SUCCESS;
+ }
+
+}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/GetOutboundSmsListAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/GetOutboundSmsListAction.java 2012-08-09 10:47:22 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/GetOutboundSmsListAction.java 2012-08-17 06:42:32 +0000
@@ -31,10 +31,12 @@
import java.util.List;
import java.util.Map;
+import org.hisp.dhis.patient.comment.Comment;
import org.hisp.dhis.program.ProgramStageInstance;
import org.hisp.dhis.program.ProgramStageInstanceService;
import org.hisp.dhis.sms.outbound.OutboundSms;
import org.hisp.dhis.sms.outbound.OutboundSmsTransportService;
+import org.hisp.dhis.user.CurrentUserService;
import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.Action;
@@ -52,7 +54,14 @@
// -------------------------------------------------------------------------
private ProgramStageInstanceService programStageInstanceService;
+
+ private CurrentUserService currentUserService;
+ public void setCurrentUserService( CurrentUserService currentUserService )
+ {
+ this.currentUserService = currentUserService;
+ }
+
@Autowired
private OutboundSmsTransportService transportService;
@@ -66,8 +75,12 @@
private List<OutboundSms> outboundSms;
- public Map<String, String> gatewayMap;
+ private Map<String, String> gatewayMap;
+ private List<Comment> comments;
+
+ private String currentUsername;
+
// -------------------------------------------------------------------------
// Getter/Setter
// -------------------------------------------------------------------------
@@ -82,6 +95,16 @@
return programStageInstance;
}
+ public String getCurrentUsername()
+ {
+ return currentUsername;
+ }
+
+ public List<Comment> getComments()
+ {
+ return comments;
+ }
+
public void setProgramStageInstanceId( Integer programStageInstanceId )
{
this.programStageInstanceId = programStageInstanceId;
@@ -111,6 +134,10 @@
gatewayMap = transportService.getGatewayMap();
+ comments = new ArrayList<Comment>( programStageInstance.getComments() );
+
+ currentUsername = currentUserService.getCurrentUsername();
+
return SUCCESS;
}
=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/RemoveCommentAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/RemoveCommentAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/RemoveCommentAction.java 2012-08-17 06:42:32 +0000
@@ -0,0 +1,103 @@
+/*
+ * 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.caseentry.action.reminder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hisp.dhis.patient.comment.Comment;
+import org.hisp.dhis.patient.comment.CommentService;
+import org.hisp.dhis.program.ProgramStageInstance;
+import org.hisp.dhis.program.ProgramStageInstanceService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version RemoveCommentAction.java 10:02:15 AM Aug 17, 2012 $
+ */
+public class RemoveCommentAction
+ implements Action
+{
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ProgramStageInstanceService programStageInstanceService;
+
+ public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+ {
+ this.programStageInstanceService = programStageInstanceService;
+ }
+
+ private CommentService commentService;
+
+ public void setCommentService( CommentService commentService )
+ {
+ this.commentService = commentService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private Integer id;
+
+ public void setId( Integer id )
+ {
+ this.id = id;
+ }
+
+ private Integer programStageInstanceId;
+
+ public void setProgramStageInstanceId( Integer programStageInstanceId )
+ {
+ this.programStageInstanceId = programStageInstanceId;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ Comment comment = commentService.getComment( id );
+
+ ProgramStageInstance programStageInstance = programStageInstanceService
+ .getProgramStageInstance( programStageInstanceId );
+
+ programStageInstance.getComments().remove( comment );
+
+ programStageInstanceService.updateProgramStageInstance( programStageInstance );
+
+ return SUCCESS;
+ }
+
+}
=== 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 2012-08-16 15:47:08 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-08-17 06:42:32 +0000
@@ -983,6 +983,8 @@
scope="prototype">
<property name="programStageInstanceService"
ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+ <property name="currentUserService"
+ ref="org.hisp.dhis.user.CurrentUserService" />
</bean>
<bean id="org.hisp.dhis.caseentry.action.reminder.SendSmsAction"
@@ -1023,5 +1025,25 @@
<property name="programStageInstanceService"
ref="org.hisp.dhis.program.ProgramStageInstanceService" />
</bean>
+
+ <!-- Comment -->
+
+ <bean id="org.hisp.dhis.caseentry.action.reminder.AddCommentAction"
+ class="org.hisp.dhis.caseentry.action.reminder.AddCommentAction"
+ scope="prototype">
+ <property name="programStageInstanceService"
+ ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+ <property name="currentUserService"
+ ref="org.hisp.dhis.user.CurrentUserService" />
+ </bean>
+
+ <bean id="org.hisp.dhis.caseentry.action.reminder.RemoveCommentAction"
+ class="org.hisp.dhis.caseentry.action.reminder.RemoveCommentAction"
+ scope="prototype">
+ <property name="commentService"
+ ref="org.hisp.dhis.patient.comment.CommentService" />
+ <property name="programStageInstanceService"
+ ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+ </bean>
</beans>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-08-16 13:46:23 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-08-17 06:42:32 +0000
@@ -413,4 +413,6 @@
scheduled_in_future = Scheduled in future
sent_message_success = Sent message successfully
please_select_program_stage = Please select program stage
-send_sms_to_list = Send SMS to list
\ No newline at end of file
+send_sms_to_list = Send SMS to list
+post_comment = Post comment
+comments = Comments
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2012-08-16 13:46:23 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2012-08-17 06:42:32 +0000
@@ -840,6 +840,16 @@
<param name="page">/dhis-web-caseentry/patientDashboard.vm</param>
<param name="stylesheets">style/style.css</param>
</action>
-
+
+ <!-- Comment -->
+
+ <action name="addComment" class="org.hisp.dhis.caseentry.action.reminder.AddCommentAction">
+ <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ </action>
+
+ <action name="removeComment" class="org.hisp.dhis.caseentry.action.reminder.RemoveCommentAction">
+ <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ </action>
+
</package>
</struts>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js 2012-08-16 13:46:23 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js 2012-08-17 06:42:32 +0000
@@ -167,3 +167,43 @@
hideLoader();
});
}
+
+function keypress(event, programStageInstanceId )
+{
+ var key = getKeyCode( event );
+ if ( key==13 ){ // Enter
+ addComment( programStageInstanceId );
+ }
+}
+
+function addComment( programStageInstanceId )
+{
+ var commentText = getFieldValue( 'commentText' );
+ if( commentText != '')
+ {
+ jQuery.postUTF8( 'addComment.action',
+ {
+ programStageInstanceId: programStageInstanceId,
+ commentText: commentText
+ }, function ( json )
+ {
+ jQuery('#commentTB').prepend("<tr><td>" + getFieldValue("currentDate") + " - " + getFieldValue('currentUsername') + " - " + commentText + "</td></tr>");
+ setFieldValue( 'commentText','' );
+ showSuccessMessage( i18n_comment_added );
+ } );
+ }
+}
+
+
+function removeComment( programStageInstanceId, commentId )
+{
+ jQuery.postUTF8( 'removeComment.action',
+ {
+ programStageInstanceId:programStageInstanceId,
+ id: commentId
+ }, function ( json )
+ {
+ showSuccessMessage( json.message );
+ hideById( 'comment_' + commentId );
+ } );
+}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsReminderList.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsReminderList.vm 2012-08-16 13:46:23 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsReminderList.vm 2012-08-17 06:42:32 +0000
@@ -8,19 +8,45 @@
</script>
<h4>$i18n.getString( "sms_message_management" )</h4>
-
-<table>
- <tr>
- <td class="bold">$i18n.getString( "full_name" ):</td>
- <td>$encoder.htmlEncode( $programStageInstance.programInstance.patient.getFullName() )<td>
- </tr>
- <tr>
- <td class="bold">$i18n.getString( "gender" ):</td>
- <td>$programStageInstance.programInstance.patient.gender</td>
- </tr>
- <tr>
- <td class="bold">$i18n.getString( "date_of_birth" ):</td>
- <td>$format.formatDate( $programStageInstance.programInstance.patient.birthDate ) $programStageInstance.programInstance.patient.getAge()<td>
+<input type='hidden' id='currentUsername' name='currentUsername' value='$currentUsername'>
+<table class="mainPageTable">
+ <tr>
+ <td>
+ <table>
+ <tr>
+ <td class="bold">$i18n.getString( "full_name" ):</td>
+ <td>$encoder.htmlEncode( $programStageInstance.programInstance.patient.getFullName() )<td>
+ </tr>
+ <tr>
+ <td class="bold">$i18n.getString( "gender" ):</td>
+ <td>$programStageInstance.programInstance.patient.gender</td>
+ </tr>
+ <tr>
+ <td class="bold">$i18n.getString( "date_of_birth" ):</td>
+ <td>$format.formatDate( $programStageInstance.programInstance.patient.birthDate ) $programStageInstance.programInstance.patient.getAge()<td>
+ </tr>
+ </table>
+ </td>
+ <td valign='top' style="width:90px;" class="bold">$i18n.getString('comments'):</td>
+ <td valign='bottom' style="width:360px;">
+ <div class="contentProviderTable">
+ <table id='commentTB' width='100%'>
+ #foreach( $comment in $comments )
+ <tr id="comment_$comment.id">
+ <td>$format.formatDate($comment.createdDate) - $comment.creator - $comment.commentText</td>
+ </tr>
+ #end
+ </table>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td align='right' class="bold">$i18n.getString('post_comment'):</td>
+ <td align='right'>
+ <input type='textbox' id='commentText' name='commentText' style="width:320px;" onkeypress="keypress(event,'$programStageInstance.id')">
+ <input type='button' value="+" class='tiny-button' onclick="addComment('$programStageInstance.id')">
+ </td>
</tr>
</table>
@@ -53,11 +79,12 @@
</tbody>
</table>
</div>
-
-
</div>
<script type="text/javascript">
- var i18n_color_quick_help = '$encoder.jsEscape( $i18n.getString( "color_quick_help" ) , "'")';
- setFieldValue( "programStageInstanceId", "$!programStageInstance.id" );
+ jQuery(document).ready( function(){
+ var i18n_color_quick_help = '$encoder.jsEscape( $i18n.getString( "color_quick_help" ) , "'")';
+ var i18n_comment_added = '$encoder.jsEscape( $i18n.getString( "comment_added" ) , "'")';
+ setFieldValue( "programStageInstanceId", "$!programStageInstance.id" );
+ });
</script>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsReminderSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsReminderSelect.vm 2012-08-16 13:46:23 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsReminderSelect.vm 2012-08-17 06:42:32 +0000
@@ -34,6 +34,13 @@
<div id='smsManagementDiv'></div>
<div id='sendSmsFormDiv'></div>
+<div class='hidden'>
+ <input type='textbox' id='currentDate' name='currentDate'>
+ <script>
+ datePickerValid( 'currentDate', true );
+ </script>
+</div>
+
<script>
unSave = false;
var i18n_sms_message_management = '$encoder.jsEscape( $i18n.getString( "sms_message_management" ) , "'")';
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css 2012-08-16 02:08:22 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css 2012-08-17 06:42:32 +0000
@@ -7,6 +7,12 @@
width: 130px;
}
+input.tiny-button[type="button"]
+{
+ width: 20px;
+ height: 20px;
+}
+
input.small-button[type="button"]
{
width: 30px;