Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Ticket #890: Ticket890-New.patch

File Ticket890-New.patch, 43.6 kB (added by sthaiya, 1 year ago)

A patch implementing comments of the core review

  • D:/Workspace/OpenMRS-trunk/metadata/model/update-to-latest-db.mysqldiff.sql

    old new  
    1 #-------------------------------------- 
     1#-------------------------------------- 
    22# USE: 
    33#  The diffs are ordered by datamodel version number. 
    44#-------------------------------------- 
     
    12131213call diff_procedure('1.4.0.02'); 
    12141214 
    12151215 
     1216#----------------------------------------  
     1217# OpenMRS Datamodel version 1.4.0.02  
     1218# Samuel Mbugua             Sep 19, 2008  
     1219# Adding a column to flag archived Hl7 Messages State 
     1220# Modify state column to message_state in the hl7_inQueue 
     1221#---------------------------------------- 
     1222          
     1223         ALTER TABLE `hl7_in_archive` ADD COLUMN `message_state` tinyint(1) default '0' COMMENT '0=processed 1=deleted';  
     1224         ALTER TABLE `hl7_in_queue` CHANGE `state` `message_state` int(11) NOT NULL default '0' COMMENT '0=pending, 1=processing, 2=processed, 3=error'; 
     1225delimiter ;  
     1226call diff_procedure('1.4.0.02');  
     1227 
    12161228#----------------------------------- 
    12171229# Clean up - Keep this section at the very bottom of diff script 
    12181230#----------------------------------- 
    12191231 
    1220 DROP PROCEDURE IF EXISTS diff_procedure; 
     1232DROP PROCEDURE IF EXISTS diff_procedure; 
  • D:/Workspace/OpenMRS-trunk/metadata/api/hibernate/org/openmrs/hl7/db/hibernate/HL7InArchive.hbm.xml

    old new  
    2424                <property name="HL7Data" type="java.lang.String"  
    2525                        column="hl7_data" not-null="true" length="16777215" /> 
    2626                         
     27                <property name="messageState" type="java.lang.Integer"  
     28                        column="message_state" not-null="false" length="4" /> 
     29                 
    2730                <property name="dateCreated" type="java.util.Date"  
    2831                        column="date_created" not-null="true" length="19" /> 
    2932 
  • D:/Workspace/OpenMRS-trunk/metadata/api/hibernate/org/openmrs/hl7/db/hibernate/HL7InQueue.hbm.xml

    old new  
    2626                         
    2727                <property name="dateCreated" type="java.util.Date"  
    2828                        column="date_created" not-null="true" length="19" /> 
     29                 
     30                <property name="errorMessage" type="java.lang.String"  
     31                        column="error_msg" not-null="false" length="16777215" /> 
     32                         
     33                <property name="messageState" type="java.lang.Integer"  
     34                        column="message_state" not-null="false" length="4" /> 
    2935 
    3036        </class> 
    3137</hibernate-mapping> 
  • D:/Workspace/OpenMRS-trunk/src/api/org/openmrs/hl7/db/hibernate/HibernateHL7DAO.java

    old new  
    2323import org.hibernate.criterion.Restrictions; 
    2424import org.openmrs.api.context.Context; 
    2525import org.openmrs.api.db.DAOException; 
     26import org.openmrs.hl7.HL7Constants; 
    2627import org.openmrs.hl7.HL7InArchive; 
    2728import org.openmrs.hl7.HL7InError; 
    2829import org.openmrs.hl7.HL7InQueue; 
     
    3132 
    3233/** 
    3334 * OpenMRS HL7 API database default hibernate implementation 
    34  *  
     35 * 
    3536 * This class shouldn't be instantiated by itself. Use the 
    3637 * {@link org.openmrs.api.context.Context} 
    37  *  
     38 * 
    3839 * @see org.openmrs.hl7.HL7Service 
    3940 * @see org.openmrs.hl7.db.HL7DAO 
    4041 */ 
     
    5253 
    5354        /** 
    5455         * Set session factory 
    55          *  
     56         * 
    5657         * @param sessionFactory 
    5758         */ 
    5859        public void setSessionFactory(SessionFactory sessionFactory) { 
     
    124125        @SuppressWarnings("unchecked") 
    125126        public List<HL7InQueue> getAllHL7InQueues() throws DAOException { 
    126127                return sessionFactory.getCurrentSession() 
    127                                      .createQuery("from HL7InQueue order by hL7InQueueId") 
     128                                     .createQuery("from HL7InQueue order by HL7InQueueId") 
    128129                                     .list(); 
    129130        } 
    130131 
     
    166167                                                    .get(HL7InArchive.class, 
    167168                                                         hl7InArchiveId); 
    168169        } 
    169  
     170         
    170171        /** 
    171          * @see org.openmrs.hl7.db.HL7DAO#getHL7InArchives() 
     172         * @see org.openmrs.hl7.db.HL7DAO#getHL7InArchiveByState() 
    172173         */ 
    173174        @SuppressWarnings("unchecked") 
     175        public List<HL7InArchive> getHL7InArchiveByState() throws DAOException { 
     176                return sessionFactory.getCurrentSession() 
     177                                     .createQuery("from HL7InArchive where messageState=" + HL7Constants.HL7_ARCHIVE_STATUS_DELETED) 
     178                                     .list(); 
     179        } 
     180        /** 
     181         * @see org.openmrs.hl7.db.HL7DAO#getAllHL7InArchives() 
     182         */ 
     183        @SuppressWarnings("unchecked") 
    174184        public List<HL7InArchive> getAllHL7InArchives() throws DAOException { 
    175185                return sessionFactory.getCurrentSession() 
    176                                      .createQuery("from HL7InArchive order by hL7InArchiveId") 
     186                                     .createQuery("from HL7InArchive order by HL7InArchiveId") 
    177187                                     .list(); 
    178188        } 
    179189 
     
    207217        @SuppressWarnings("unchecked") 
    208218        public List<HL7InError> getAllHL7InErrors() throws DAOException { 
    209219                return sessionFactory.getCurrentSession() 
    210                                      .createQuery("from HL7InError order by hL7InErrorId") 
     220                                     .createQuery("from HL7InError order by HL7InErrorId") 
    211221                                     .list(); 
    212222        } 
    213223 
  • D:/Workspace/OpenMRS-trunk/src/api/org/openmrs/hl7/db/HL7DAO.java

    old new  
    101101                throws DAOException; 
    102102 
    103103        /** 
    104          * @see org.openmrs.hl7.HL7Service#getAllHL7InArchive() 
     104         * @see org.openmrs.hl7.HL7Service#getHL7InArchiveByState() 
    105105         */ 
     106        public List<HL7InArchive> getHL7InArchiveByState() throws DAOException; 
     107        /** 
     108         * @see org.openmrs.hl7.HL7Service#getAllHL7InArchives() 
     109         */ 
    106110        public List<HL7InArchive> getAllHL7InArchives() throws DAOException; 
    107111 
    108112        /** 
  • D:/Workspace/OpenMRS-trunk/src/api/org/openmrs/hl7/HL7Service.java

    old new  
    226226        @Transactional(readOnly = true) 
    227227        @Authorized(HL7Constants.PRIV_VIEW_HL7_IN_ARCHIVE) 
    228228        public HL7InArchive getHL7InArchive(Integer hl7InArchiveId); 
    229  
     229         
    230230        /** 
     231         * Get the archive items that has been deleted 
     232         *  
     233         * @return list of archive item that actually were deleted 
     234         */ 
     235        @Transactional(readOnly = true) 
     236        @Authorized(HL7Constants.PRIV_VIEW_HL7_IN_ARCHIVE) 
     237        public List<HL7InArchive> getHL7InArchiveByState()throws APIException;; 
     238         
     239        /** 
    231240         * Get all archive hl7 queue items from the database 
    232241         *  
    233242         * @return list of archive items 
  • D:/Workspace/OpenMRS-trunk/src/api/org/openmrs/hl7/impl/HL7ServiceImpl.java

    old new  
    215215        public void deleteHL7InQueue(HL7InQueue hl7InQueue) { 
    216216                purgeHL7InQueue(hl7InQueue); 
    217217        } 
    218  
     218         
    219219        /** 
     220         * @see org.openmrs.hl7.HL7Service#getHL7InArchiveByState() 
     221         */ 
     222        public List<HL7InArchive> getHL7InArchiveByState() throws APIException { 
     223                return dao.getHL7InArchiveByState(); 
     224        } 
     225         
     226        /** 
    220227         * @see org.openmrs.hl7.HL7Service#getAllHL7InArchives() 
    221228         */ 
    222229        public List<HL7InArchive> getAllHL7InArchives() throws APIException { 
  • D:/Workspace/OpenMRS-trunk/src/api/org/openmrs/hl7/HL7InArchive.java

    old new  
    2121        private HL7Source hl7Source; 
    2222        private String hl7SourceKey; 
    2323        private String hl7Data; 
     24        private Integer messageState; 
    2425        private Date dateCreated; 
    2526 
    2627        /** 
     
    3637                setHL7Source(hl7InQueue.getHL7Source()); 
    3738                setHL7SourceKey(hl7InQueue.getHL7SourceKey()); 
    3839                setHL7Data(hl7InQueue.getHL7Data()); 
     40                setMessageState(HL7Constants.HL7_ARCHIVE_STATUS_DEFAULT); 
    3941        } 
    4042         
    4143        /** 
     
    112114        public void setHL7SourceKey(String hl7SourceKey) { 
    113115                this.hl7SourceKey = hl7SourceKey; 
    114116        } 
     117        /** 
     118         * @return Returns message state. 
     119         */ 
     120        public Integer getMessageState() { 
     121                return messageState; 
     122        } 
     123        /** 
     124         * @param messageState 
     125         *            The message source to set. 
     126         */ 
     127        public void setMessageState(Integer messageState) { 
     128                this.messageState = messageState; 
     129        } 
    115130 
    116131} 
  • D:/Workspace/OpenMRS-trunk/src/api/org/openmrs/hl7/HL7InQueue.java

    old new  
    2424        private HL7Source hl7Source; 
    2525        private String hl7SourceKey; 
    2626        private String hl7Data; 
     27        private String errorMessage;  
     28        private Integer messageState=HL7Constants.HL7_ARCHIVE_STATUS_DEFAULT;  
    2729        private Date dateCreated; 
     30 
     31        /** 
     32         * Default constructor 
     33         */ 
     34        public HL7InQueue() {} 
     35 
     36        /** 
     37         * Convenience constructor to build queue from a previously deleted queue entry 
     38         * @param hl7InArchive 
     39         *                              deleted entry from which queue entry will be constructed 
     40         */ 
     41        public HL7InQueue(HL7InArchive hl7InArchive) { 
     42                setHL7Source(hl7InArchive.getHL7Source()); 
     43                setHL7SourceKey(hl7InArchive.getHL7SourceKey()); 
     44                setHL7Data(hl7InArchive.getHL7Data()); 
     45        } 
    2846         
     47        /** 
     48         * Convenience constructor to build queue from a previously erred queue entry 
     49         * @param hl7InError 
     50         *                              erred entry from which queue entry will be constructed 
     51         */ 
     52        public HL7InQueue(HL7InError hl7InError) { 
     53                setHL7Source(hl7InError.getHL7Source()); 
     54                setHL7SourceKey(hl7InError.getHL7SourceKey()); 
     55                setHL7Data(hl7InError.getHL7Data()); 
     56 
     57        } 
     58 
    2959        public boolean equals(Object obj) { 
    3060                if (obj instanceof HL7InQueue) { 
    3161                        HL7InQueue hl7InQueue = (HL7InQueue)obj; 
     
    3464                } 
    3565                return false; 
    3666        } 
    37          
     67 
    3868        public int hashCode() { 
    3969                if (this.getHL7InQueueId() == null) 
    4070                        return super.hashCode(); 
     
    118148                this.hl7SourceKey = hl7SourceKey; 
    119149        } 
    120150 
     151        /** 
     152         * @return Returns the errorMessage. 
     153         */ 
     154        public String getErrorMessage() { 
     155                return errorMessage; 
     156        } 
     157 
     158        /** 
     159         * @param errorMessage 
     160         *            The errorMessage to set. 
     161         */ 
     162        public void setErrorMessage(String errorMessage) { 
     163                this.errorMessage = errorMessage; 
     164        } 
     165 
     166        /** 
     167         * @return Returns the message State. 
     168         */ 
     169        public Integer getMessageState() { 
     170                return messageState; 
     171        } 
     172 
     173        /** 
     174         * @param messageState 
     175         *            The message State to set. 
     176         */ 
     177        public void setMessageState(Integer messageState) { 
     178                this.messageState = messageState; 
     179        } 
    121180} 
  • D:/Workspace/OpenMRS-trunk/src/api/org/openmrs/hl7/HL7Constants.java

    old new  
    4040        public static final String PRIV_UPDATE_HL7_IN_EXCEPTION = "Update HL7 Inbound Exception"; 
    4141        public static final String PRIV_DELETE_HL7_IN_EXCEPTION = "Delete HL7 Inbound Exception"; 
    4242        public static final String PRIV_PURGE_HL7_IN_EXCEPTION = "Purge HL7 Inbound Exception"; 
    43  
     43        public static final String PRIV_VIEW_HL7_MESSAGES = "View HL7 Messages"; 
     44        public static final String PRIV_ADD_HL7_MESSAGES = "Add HL7 Messages"; 
     45        public static final String PRIV_DELETE_HL7_MESSAGES = "Delete HL7 Messages"; 
     46         
    4447        public static final int HL7_STATUS_PENDING = 0; 
    4548        public static final int HL7_STATUS_PROCESSING = 1; 
    4649        public static final int HL7_STATUS_PROCESSED = 2; 
    4750        public static final int HL7_STATUS_ERROR = 3; 
    48          
     51        public static final int HL7_ARCHIVE_STATUS_PROCESSED = 0; 
     52        public static final int HL7_ARCHIVE_STATUS_DEFAULT = 0; 
     53        public static final int HL7_ARCHIVE_STATUS_DELETED = 1; 
    4954} 
  • D:/Workspace/OpenMRS-trunk/src/web/org/openmrs/hl7/web/controller/Hl7InQueueListController.java

    old new  
     1/** 
     2 * The contents of this file are subject to the OpenMRS Public License 
     3 * Version 1.0 (the "License"); you may not use this file except in 
     4 * compliance with the License. You may obtain a copy of the License at 
     5 * http://license.openmrs.org 
     6 * 
     7 * Software distributed under the License is distributed on an "AS IS" 
     8 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 
     9 * License for the specific language governing rights and limitations 
     10 * under the License. 
     11 * 
     12 * Copyright (C) OpenMRS, LLC.  All Rights Reserved. 
     13 */ 
     14 
     15package org.openmrs.hl7.web.controller; 
     16 
     17import java.util.Collection; 
     18import java.util.HashMap; 
     19import java.util.List; 
     20import java.util.Map; 
     21import java.util.Vector; 
     22 
     23import javax.servlet.ServletException; 
     24import javax.servlet.http.HttpServletRequest; 
     25import javax.servlet.http.HttpServletResponse; 
     26import javax.servlet.http.HttpSession; 
     27 
     28import org.apache.commons.logging.Log; 
     29import org.apache.commons.logging.LogFactory; 
     30import org.openmrs.api.APIException; 
     31import org.openmrs.api.context.Context; 
     32import org.openmrs.hl7.HL7Service; 
     33import org.openmrs.hl7.HL7InQueue; 
     34import org.openmrs.hl7.HL7InArchive; 
     35import org.openmrs.hl7.HL7Constants; 
     36import org.openmrs.web.WebConstants; 
     37import org.springframework.beans.propertyeditors.CustomNumberEditor; 
     38import org.springframework.context.support.MessageSourceAccessor; 
     39import org.springframework.validation.BindException; 
     40import org.springframework.validation.Errors; 
     41import org.springframework.web.bind.ServletRequestDataBinder; 
     42import org.springframework.web.servlet.ModelAndView; 
     43import org.springframework.web.servlet.mvc.SimpleFormController; 
     44import org.springframework.web.servlet.view.RedirectView; 
     45 
     46public class Hl7InQueueListController extends SimpleFormController { 
     47 
     48        /**  
     49         * Logger for this class and subclasses  
     50         */ 
     51        protected static final Log log = LogFactory.getLog(Hl7InQueueListController.class); 
     52 
     53        /** 
     54         * Allows for Integers to be used as values in input tags. 
     55         */ 
     56        protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { 
     57                super.initBinder(request, binder); 
     58                binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true)); 
     59        } 
     60 
     61         
     62        /** 
     63         * This is called prior to displaying a form  
     64         */ 
     65         protected Object formBackingObject(HttpServletRequest request) throws ServletException { 
     66                List<HL7InQueue> hl7InQueue=new Vector<HL7InQueue>(); 
     67                         
     68                // Get all messages in the HL7 in Queue 
     69                if (Context.isAuthenticated()) { 
     70                        hl7InQueue =Context.getHL7Service().getAllHL7InQueues(); 
     71                } 
     72                return hl7InQueue; 
     73                 
     74        } 
     75          
     76         protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { 
     77                HttpSession httpSession = request.getSession(); 
     78                String view = getFormView(); 
     79                StringBuffer success = new StringBuffer(); 
     80                StringBuffer error = new StringBuffer();                         
     81                MessageSourceAccessor msa = getMessageSourceAccessor(); 
     82                 
     83                String[] queueList = request.getParameterValues("queueId"); 
     84                 
     85                HL7Service hL7Service = Context.getHL7Service(); 
     86                 
     87                if ( queueList != null ){  
     88                        for (String queueId : queueList) { 
     89                                // Argument to pass to the success/error message 
     90                                Object [] args = new Object[] { queueId }; 
     91         
     92                                try { 
     93                                        //Move Selected HL7 inbound queue entry into the archive table 
     94                                        HL7InQueue hl7InQueue = hL7Service.getHL7InQueue(Integer.valueOf(queueId)); 
     95                                        HL7InArchive hl7InArchive = new HL7InArchive(hl7InQueue); 
     96                                        hl7InArchive.setMessageState(HL7Constants.HL7_ARCHIVE_STATUS_DELETED); 
     97                                        hL7Service.createHL7InArchive(hl7InArchive); 
     98                                         
     99                                        //Delete selected Message from the InQueue table 
     100                                        hL7Service.deleteHL7InQueue(hl7InQueue); 
     101                                         
     102                                        //Display a message for the operation 
     103                                        success.append(msa.getMessage("Hl7inQueue.queueList.deleted", args)+ "<br/>"); 
     104                                } 
     105                                catch (APIException e){ 
     106                                        log.warn("Error deleting a queue entry", e); 
     107                                        error.append(msa.getMessage("Hl7inQueue.queueList..error", args)+ "<br/>"); 
     108                                } 
     109                        } 
     110                } 
     111         
     112                view = getSuccessView(); 
     113                 
     114                if (!success.toString().equals("")) {  
     115                        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, success.toString()); 
     116                } 
     117                if (!error.toString().equals("")) { 
     118                                httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, error.toString()); 
     119                        } 
     120                 
     121                return new ModelAndView(new RedirectView(view)); 
     122        }        
     123} 
     124 
  • D:/Workspace/OpenMRS-trunk/src/web/org/openmrs/hl7/web/controller/Hl7DeletedFormController.java

    old new  
     1/** 
     2 * The contents of this file are subject to the OpenMRS Public License 
     3 * Version 1.0 (the "License"); you may not use this file except in 
     4 * compliance with the License. You may obtain a copy of the License at 
     5 * http://license.openmrs.org 
     6 * 
     7 * Software distributed under the License is distributed on an "AS IS" 
     8 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 
     9 * License for the specific language governing rights and limitations 
     10 * under the License. 
     11 * 
     12 * Copyright (C) OpenMRS, LLC.  All Rights Reserved. 
     13 */ 
     14package org.openmrs.hl7.web.controller; 
     15 
     16import java.util.Collection; 
     17import java.util.HashMap; 
     18import java.util.List; 
     19import java.util.Map; 
     20import java.util.Vector; 
     21 
     22import javax.servlet.ServletException; 
     23import javax.servlet.http.HttpServletRequest; 
     24import javax.servlet.http.HttpServletResponse; 
     25import javax.servlet.http.HttpSession; 
     26 
     27import org.apache.commons.logging.Log; 
     28import org.apache.commons.logging.LogFactory; 
     29import org.openmrs.api.APIException; 
     30import org.openmrs.api.context.Context; 
     31import org.openmrs.hl7.HL7Constants; 
     32import org.openmrs.hl7.HL7InArchive; 
     33import org.openmrs.hl7.HL7InQueue; 
     34import org.openmrs.hl7.HL7Service; 
     35import org.openmrs.web.WebConstants; 
     36import org.springframework.beans.propertyeditors.CustomNumberEditor; 
     37import org.springframework.context.support.MessageSourceAccessor; 
     38import org.springframework.validation.BindException; 
     39import org.springframework.validation.Errors; 
     40import org.springframework.web.bind.ServletRequestDataBinder; 
     41import org.springframework.web.servlet.ModelAndView; 
     42import org.springframework.web.servlet.mvc.SimpleFormController; 
     43import org.springframework.web.servlet.view.RedirectView; 
     44 
     45public class Hl7DeletedFormController extends SimpleFormController { 
     46 
     47        /**  
     48         * Logger for this class and subclasses  
     49         */ 
     50        protected static final Log log = LogFactory.getLog(Hl7DeletedFormController.class); 
     51 
     52        /** 
     53         * Allows for Integers to be used as values in input tags. 
     54         */ 
     55        protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { 
     56                super.initBinder(request, binder); 
     57                binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true)); 
     58        } 
     59 
     60         
     61        /** 
     62         * This is called prior to displaying a form  
     63         */ 
     64         protected List<HL7InArchive> formBackingObject(HttpServletRequest request) throws ServletException { 
     65                 List<HL7InArchive> hl7InArchive=new Vector<HL7InArchive>(); 
     66                 
     67                 // Get all admin deleted messages in the Hl7_in_Archive 
     68                        if (Context.isAuthenticated()) { 
     69                                hl7InArchive =Context.getHL7Service().getHL7InArchiveByState(); 
     70                        } 
     71                        return hl7InArchive; 
     72        } 
     73         
     74         /** 
     75          * This method pushes a message that had been deleted previously back into the queue 
     76          * to be processed 
     77          */ 
     78         protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { 
     79                HttpSession httpSession = request.getSession(); 
     80                String view = getFormView(); 
     81                StringBuffer success = new StringBuffer(); 
     82                StringBuffer error = new StringBuffer();                         
     83                MessageSourceAccessor msa = getMessageSourceAccessor(); 
     84                 
     85                String[] queueForm = request.getParameterValues("queueId"); 
     86                 
     87                HL7Service hL7Service = Context.getHL7Service(); 
     88                 
     89                if ( queueForm != null ) {  
     90                        for (String queueId : queueForm) { 
     91                                // Argument to pass to the success/error message 
     92                                Object [] args = new Object[] { queueId }; 
     93         
     94                                try { 
     95                                        //Restore Selected Message to the in queue table 
     96                                        HL7InArchive hl7InArchive = hL7Service.getHL7InArchive(Integer.valueOf(queueId)); 
     97                                        HL7InQueue hl7InQueue = new HL7InQueue(hl7InArchive); 
     98                                        hL7Service.createHL7InQueue(hl7InQueue); 
     99                                         
     100                                        //Delete selected Message from the archives table 
     101                                        hL7Service.deleteHL7InArchive(hl7InArchive); 
     102                                         
     103                                        //Display a message for the operation 
     104                                        success.append(msa.getMessage("Hl7inQueue.queueForm.restored", args)+ "<br/>"); 
     105                                } 
     106                                catch (APIException e){ 
     107                                        log.warn("Error restoring deleted queue item", e); 
     108                                        error.append(msa.getMessage("Hl7inQueue.queueForm.error", args)+ "<br/>"); 
     109                                } 
     110                        } 
     111                } 
     112         
     113                view = getSuccessView(); 
     114                 
     115                if (!success.toString().equals("")) {  
     116                        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, success.toString()); 
     117                } 
     118                if (!error.toString().equals("")) { 
     119                                httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, error.toString()); 
     120                        } 
     121                 
     122                return new ModelAndView(new RedirectView(view)); 
     123        } 
     124} 
     125          
     126 
  • D:/Workspace/OpenMRS-trunk/src/web/org/openmrs/hl7/web/controller/Hl7InErrorListController.java

    old new  
     1/** 
     2 * The contents of this file are subject to the OpenMRS Public License 
     3 * Version 1.0 (the "License"); you may not use this file except in 
     4 * compliance with the License. You may obtain a copy of the License at 
     5 * http://license.openmrs.org 
     6 * 
     7 * Software distributed under the License is distributed on an "AS IS" 
     8 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 
     9 * License for the specific language governing rights and limitations 
     10 * under the License. 
     11 * 
     12 * Copyright (C) OpenMRS, LLC.  All Rights Reserved. 
     13 */ 
     14 
     15package org.openmrs.hl7.web.controller; 
     16 
     17import java.util.Collection; 
     18import java.util.HashMap; 
     19import java.util.List; 
     20import java.util.Map; 
     21import java.util.Vector; 
     22 
     23import javax.servlet.ServletException; 
     24import javax.servlet.http.HttpServletRequest; 
     25import javax.servlet.http.HttpServletResponse; 
     26import javax.servlet.http.HttpSession; 
     27 
     28import org.apache.commons.logging.Log; 
     29import org.apache.commons.logging.LogFactory; 
     30import org.openmrs.api.APIException; 
     31import org.openmrs.api.context.Context; 
     32import org.openmrs.hl7.HL7Constants; 
     33import org.openmrs.hl7.HL7InQueue; 
     34import org.openmrs.hl7.HL7InError; 
     35import org.openmrs.hl7.HL7Service; 
     36import org.openmrs.web.WebConstants; 
     37import org.springframework.beans.propertyeditors.CustomNumberEditor; 
     38import org.springframework.context.support.MessageSourceAccessor; 
     39import org.springframework.validation.BindException; 
     40import org.springframework.validation.Errors; 
     41import org.springframework.web.bind.ServletRequestDataBinder; 
     42import org.springframework.web.servlet.ModelAndView; 
     43import org.springframework.web.servlet.mvc.SimpleFormController; 
     44import org.springframework.web.servlet.view.RedirectView; 
     45 
     46public class Hl7InErrorListController extends SimpleFormController { 
     47 
     48        /**  
     49         * Logger for this class and subclasses  
     50         */ 
     51        protected static final Log log = LogFactory.getLog(Hl7InErrorListController.class); 
     52 
     53        /** 
     54         * Allows for Integers to be used as values in input tags. 
     55         *   Normally, only strings and lists are expected  
     56         */ 
     57        protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { 
     58                super.initBinder(request, binder); 
     59                binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true)); 
     60        } 
     61 
     62         
     63        /** 
     64         * This is called prior to displaying a form  
     65         */ 
     66         protected Object formBackingObject(HttpServletRequest request) throws ServletException { 
     67                 List<HL7InError> hl7InError=new Vector<HL7InError>(); 
     68                 
     69                // Get all errors posted to the database 
     70                if (Context.isAuthenticated()) { 
     71                        hl7InError =Context.getHL7Service().getAllHL7InErrors(); 
     72                } 
     73                return hl7InError; 
     74        } 
     75         
     76          
     77         /** 
     78                * This method creates a map to display the long data entry 
     79                * 
     80          
     81        @SuppressWarnings("unchecked") 
     82        @Override 
     83        protected Map referenceData(HttpServletRequest request, Object command, Errors errors) throws Exception { 
     84                Map<String, Object> map = new HashMap<String, Object>(); 
     85 
     86                Collection<HL7InError> queues = (Collection<HL7InError>)command; 
     87                Map<HL7InError, String> hl7Data = new HashMap<HL7InError, String>(); 
     88                String CR =System.getProperty("line.separator"); 
     89                String formatedHl7Data; 
     90                 
     91                //Break the Hl7Data into a block rather than a long string 
     92                for (HL7InError queue : queues){ 
     93                        String theHl7Data = queue.getHL7Data(); 
     94                        formatedHl7Data=""; 
     95                        int loopCount=HL7Constants.CHARACTERS_PER_LINE; 
     96                        if (theHl7Data.length()<=loopCount){ 
     97                                formatedHl7Data=theHl7Data; 
     98                        } 
     99                        else { 
     100                                formatedHl7Data=theHl7Data.substring(0,loopCount); 
     101                                for (int innerLoopCount=loopCount;innerLoopCount<theHl7Data.length();innerLoopCount=innerLoopCount+HL7Constants.CHARACTERS_PER_LINE) { 
     102                                        loopCount=loopCount+HL7Constants.CHARACTERS_PER_LINE; 
     103                                        if (loopCount>=theHl7Data.length())     loopCount=theHl7Data.length(); 
     104                                        formatedHl7Data=formatedHl7Data + CR + theHl7Data.substring(innerLoopCount,loopCount); 
     105                                } 
     106                        } 
     107 
     108                        hl7Data.put(queue, formatedHl7Data); 
     109                } 
     110                map.put("hl7Data", hl7Data); 
     111 
     112                return map; 
     113        } 
     114         /** 
     115          * This method pushes a message that had erred previously back into the queue 
     116          * to be processed 
     117          */ 
     118         protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { 
     119                HttpSession httpSession = request.getSession(); 
     120                String view = getFormView(); 
     121                StringBuffer success = new StringBuffer(); 
     122                StringBuffer error = new StringBuffer();                         
     123                MessageSourceAccessor msa = getMessageSourceAccessor(); 
     124                 
     125                String[] queueForm = request.getParameterValues("errorId"); 
     126                 
     127                HL7Service hL7Service = Context.getHL7Service(); 
     128                 
     129                if ( queueForm != null ){  
     130                        for (String queueId : queueForm){ 
     131                                // Argument to pass to the success/error message 
     132                                Object [] args = new Object[] { queueId }; 
     133         
     134                                try { 
     135                                        //Restore Selected Message to the in queue table 
     136                                        HL7InError hl7InError = hL7Service.getHL7InError(Integer.valueOf(queueId)); 
     137                                        HL7InQueue hl7InQueue = new HL7InQueue(hl7InError); 
     138                                        hL7Service.createHL7InQueue(hl7InQueue); 
     139                                         
     140                                        //Remove selected Message from the error table 
     141                                        hL7Service.deleteHL7InError(hl7InError); 
     142                                         
     143                                        //Display a message for the operation 
     144                                        success.append(msa.getMessage("Hl7inError.errorList.restored", args)+ "<br/>"); 
     145                                } 
     146                                catch (APIException e) { 
     147                                        log.warn("Error Processing erred message", e); 
     148                                        error.append(msa.getMessage("Hl7inError.errorList.error", args)+ "<br/>"); 
     149                                } 
     150                        } 
     151                } 
     152         
     153                view = getSuccessView(); 
     154                 
     155                if (!success.toString().equals("")) {  
     156                        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, success.toString()); 
     157                } 
     158                if (!error.toString().equals("")) { 
     159                                httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, error.toString()); 
     160                        } 
     161                 
     162                return new ModelAndView(new RedirectView(view)); 
     163        } 
     164} 
     165 
  • D:/Workspace/OpenMRS-trunk/web/WEB-INF/messages.properties

    old new  
    17181718CohortDefinition.title=Cohort Definition 
    17191719 
    17201720PatientSearch.title=Patient Search 
     1721 
     1722Hl7Messages.header=HL7 Messages 
     1723 
     1724Hl7inError.title=Manage HL7 Errors 
     1725Hl7inError.header=HL7 Errors 
     1726Hl7inError.errorList.source.header=Source 
     1727Hl7inError.errorList.data.header=HL7 Data 
     1728Hl7inError.errorList.error.header=Error 
     1729Hl7inError.errorList.errorDetails.header=Error Details 
     1730Hl7inError.errorList.dateCreated.header=Date of Occurrence 
     1731Hl7inError.errorList.title=HL7 in Errors 
     1732Hl7inError.errorList.restore=Move Back to Queue 
     1733Hl7inError.errorList.restored=Message {0} successfully queued for processing 
     1734Hl7inError.errorList.error=Error queuing item {0} for processing 
     1735 
     1736Hl7inQueue.title=Manage Queued Messages 
     1737Hl7inQueue.header=HL7 Queue 
     1738Hl7inQueue.queueList.source.header=Source 
     1739Hl7inQueue.queueList.data.header=HL7 Data 
     1740Hl7inQueue.queueList.state.header=State 
     1741Hl7inQueue.queueList.errorMessage.header=Error Message 
     1742Hl7inQueue.queueList.dateCreated=Date Created 
     1743Hl7inQueue.queueList.title=HL7 Queued messages 
     1744Hl7inQueue.queueList.delete=Delete Selected Message(s) 
     1745Hl7inQueue.queueList.deleted=Queue Item {0} deleted 
     1746Hl7inQueue.queueList.restore=Restore Deleted Messages 
     1747Hl7inQueue.queueList.error=Error deleting queue item 
     1748 
     1749Hl7inQueue.queueForm.title=HL7 Deleted Messages 
     1750Hl7inQueue.queueForm.source.header=Source 
     1751Hl7inQueue.queueForm.data.header=HL7 Data 
     1752Hl7inQueue.queueForm.dateDeleted=Date Deleted 
     1753Hl7inQueue.queueForm.restore=Restore Selected Message(s) 
     1754Hl7inQueue.queueForm.restored=Deleted queue item {0} has been restored 
     1755Hl7inQueue.queueForm.error=Error restoring deleted queue item 
     1756 
     1757Hl7inQueueRestore.title=Manage Deleted Messages 
     1758Hl7inQueue.status.0=pending 
     1759Hl7inQueue.status.1=processing 
     1760Hl7inQueue.status.2=processed 
     1761Hl7inQueue.status.3=error 
  • D:/Workspace/OpenMRS-trunk/web/WEB-INF/openmrs-servlet.xml

    old new  
    142142                                <prop key="admin/scheduler/scheduler.form">schedulerFormController</prop> 
    143143 
    144144                                <prop key="remotecommunication/postHl7.form">postHl7FormController</prop> 
    145  
     145                                <prop key="admin/hl7/hl7InError.list">hl7InErrorListController</prop> 
     146                                <prop key="admin/hl7/hl7InQueue.list">hl7InQueueListController</prop> 
     147                                <prop key="admin/hl7/hl7Deleted.form">hl7DeletedFormController</prop> 
     148                                 
    146149                                <prop key="admin/programs/program.list">programList</prop> 
    147150                                <prop key="admin/programs/program.form">programForm</prop> 
    148151                                <prop key="admin/programs/conversion.list">stateConversionList</prop> 
     
    222225        <!-- ** /Scheduler ** --> 
    223226 
    224227 
     228        <!-- =============================== --> 
     229                <!-- =====      HL7 Messages Section     ===== --> 
     230                <!-- =============================== --> 
     231         
     232                <!-- ** HL7 in Error List Controller ** --> 
     233                <bean id="hl7InErrorListController" 
     234                        class="org.openmrs.hl7.web.controller.Hl7InErrorListController"> 
     235                        <property name="commandName"><value>errorList</value></property> 
     236                        <property name="formView"><value>/admin/hl7/hl7InErrorList</value></property> 
     237                        <property name="successView"><value>hl7InError.list</value></property> 
     238                </bean> 
     239                 
     240                <!-- ** HL7 in Queue List Controller ** --> 
     241                <bean id="hl7InQueueListController" 
     242                        class="org.openmrs.hl7.web.controller.Hl7InQueueListController"> 
     243                        <property name="commandName"><value>queueList</value></property> 
     244                        <property name="formView"><value>/admin/hl7/hl7InQueueList</value></property> 
     245                        <property name="successView"><value>hl7InQueue.list</value></property> 
     246                </bean> 
     247                 
     248                <bean id="hl7DeletedFormController" 
     249                        class="org.openmrs.hl7.web.controller.Hl7DeletedFormController"> 
     250                        <property name="commandName"><value>queueForm</value></property> 
     251                        <property name="formView"><value>/admin/hl7/hl7DeletedForm</value></property> 
     252                        <property name="successView"><value>hl7Deleted.form</value></property> 
     253                </bean> 
     254                <!-- ** /HL7 Messages Section** --> 
     255 
    225256        <!-- ================================ --> 
    226257        <!-- ====== Observation Sector ====== --> 
    227258        <!-- ================================ --> 
  • D:/Workspace/OpenMRS-trunk/web/WEB-INF/view/admin/hl7/hl7DeletedForm.jsp

    old new  
     1<%@ include file="/WEB-INF/template/include.jsp" %> 
     2 
     3<openmrs:require privilege="Manage HL7Messages" otherwise="/login.htm" redirect="/admin/hl7/hl7Deleted.form" /> 
     4         
     5<%@ include file="/WEB-INF/template/header.jsp" %> 
     6<%@ include file="localHeader.jsp" %> 
     7 
     8 
     9<script type="text/javascript"> 
     10 
     11</script> 
     12 
     13<h2><spring:message code="Hl7inQueue.header" /></h2>     
     14 
     15<div class="hl7DeletedForm" style="overflow:xscroll"> 
     16        <b class="boxHeader"><spring:message code="Hl7inQueue.queueForm.title" /></b> 
     17        <div class="box"> 
     18                <form id="hl7DeletedForm" method="post"> 
     19                        <div id="hl7DeletedListing"> 
     20                                <c:if test="${fn:length(queueForm) == 0}"> 
     21                                        <i> &nbsp; There are no deleted messages</i><br/> 
     22                                </c:if> 
     23                                <c:if test="${fn:length(queueForm) > 0}"> 
     24                                <table cellpadding="5" cellspacing="0"> 
     25                                        <tr> 
     26                                                <th></th> 
     27                                                <th><spring:message code="Hl7inQueue.queueForm.source.header" /></th> 
     28                                                <th><spring:message code="Hl7inQueue.queueForm.data.header" /></th> 
     29                                                <th><spring:message code="Hl7inQueue.queueForm.dateDeleted" /></th> 
     30                                        </tr> 
     31                                        <c:forEach var="queue" items="${queueForm}"> 
     32                                                <tr> 
     33                                                        <td valign="top"><input type="checkbox" name="queueId" value="${queue.HL7InArchiveId}"></td>     
     34                                                        <td valign="top">${queue.HL7Source.name}</td> 
     35                                                        <td valign="top"> 
     36                                                                <div style="overflow:auto"> 
     37                                                                        <pre>${queue.HL7Data}</pre> 
     38                                                                </div>                                                   
     39                                                        </td> 
     40                                                        <td valign="top">${queue.dateCreated }</td>      
     41                                                </tr> 
     42                                        </c:forEach> 
     43                                        <tr> 
     44                                                <td colspan="6"> 
     45                                                        <input type="submit" value="<spring:message code="Hl7inQueue.queueForm.restore"/>" name="restore"> 
     46                                                </td> 
     47                                        </tr> 
     48                                </table> 
     49                                </c:if> 
     50                        </div> 
     51                </form> 
     52        </div> 
     53</div> 
     54 
     55 
     56<%@ include file="/WEB-INF/template/footer.jsp" %> 
  • D:/Workspace/OpenMRS-trunk/web/WEB-INF/view/admin/hl7/hl7InErrorList.jsp

    old new  
     1<%@ include file="/WEB-INF/template/include.jsp" %> 
     2 
     3<openmrs:require privilege="View HL7Messages" otherwise="/login.htm" redirect="/admin/hl7/hl7InError.list" /> 
     4         
     5<%@ include file="/WEB-INF/template/header.jsp" %> 
     6<%@ include file="localHeader.jsp" %> 
     7 
     8<h2><spring:message code="Hl7inError.header" /></h2>     
     9 
     10<div class="hl7inErrorList" style="overflow:xscroll"> 
     11        <b class="boxHeader"><spring:message code="Hl7inError.errorList.title" /></b> 
     12        <div class="box"> 
     13                <form id="hl7inErrorListForm" method="post"> 
     14                        <div id="hl7ErrorListing"> 
     15                                <c:if test="${fn:length(errorList) == 0}"> 
     16                                        <i> &nbsp; There are no erred messages</i><br/> 
     17                                </c:if> 
     18                                <c:if test="${fn:length(errorList) > 0}"> 
     19                                <table cellpadding="5" cellspacing="0"> 
     20                                        <tr> 
     21                                                <th></th> 
     22                                                <th><spring:message code="Hl7inError.errorList.source.header" /></th> 
     23                                                <th><spring:message code="Hl7inError.errorList.data.header" /></th> 
     24                                                <th><spring:message code="Hl7inError.errorList.error.header" /></th> 
     25                                                <th><spring:message code="Hl7inError.errorList.errorDetails.header" /></th> 
     26                                                <th><spring:message code="Hl7inError.errorList.dateCreated.header" /></th> 
     27                                        </tr> 
     28                                        <c:forEach var="error" items="${errorList}"> 
     29                                                <tr> 
     30                                                        <td valign="top"><input type="checkbox" name="errorId" value="${error.HL7InErrorId}"></td> 
     31                                                        <td valign="top">${error.HL7Source.name}</td> 
     32                                                        <td valign="top"> 
     33                                                                <div style="overflow:auto"> 
     34                                                                        <pre>${error.HL7Data}</pre> 
     35                                                                </div>                                                   
     36                                                        </td> 
     37                                                        <td valign="top">${error.error}</td> 
     38                                                        <td valign="top">${error.errorDetails}</td>      
     39                                                        <td valign="top">${error.dateCreated }</td>      
     40                                                </tr> 
     41                                        </c:forEach> 
     42                                        <tr> 
     43                                                <td colspan="6"> 
     44                                                        <input type="submit" value="<spring:message code="Hl7inError.errorList.restore"/>" name="restore"> 
     45                                                </td> 
     46                                        </tr> 
     47                                </table> 
     48                                </c:if> 
     49                        </div> 
     50                </form> 
     51        </div> 
     52</div> 
     53 
     54 
     55<%@ include file="/WEB-INF/template/footer.jsp" %> 
  • D:/Workspace/OpenMRS-trunk/web/WEB-INF/view/admin/hl7/hl7InQueueList.jsp

    old new  
     1<%@ include file="/WEB-INF/template/include.jsp" %> 
     2 
     3<openmrs:require privilege="View HL7Messages" otherwise="/login.htm" redirect="/admin/hl7/hl7InQueue.list" /> 
     4         
     5<%@ include file="/WEB-INF/template/header.jsp" %> 
     6<%@ include file="localHeader.jsp" %> 
     7 
     8<h2><spring:message code="Hl7inQueue.header" /></h2>     
     9 
     10<div class="hl7inQueueList" style="overflow:xscroll"> 
     11        <b class="boxHeader"><spring:message code="Hl7inQueue.queueList.title" /></b> 
     12        <div class="box"> 
     13                <form id="hl7inQueueListForm" method="post"> 
     14                        <div id="hl7QueueListing"> 
     15                                <c:if test="${fn:length(queueList) == 0}"> 
     16                                        <i> &nbsp; There are no queued messages</i><br/> 
     17                                </c:if> 
     18                                <c:if test="${fn:length(queueList) > 0}"> 
     19                                <table cellpadding="5" cellspacing="0"> 
     20                                        <tr> 
     21                                                <th></th> 
     22                                                <th><spring:message code="Hl7inQueue.queueList.source.header" /></th> 
     23                                                <th><spring:message code="Hl7inQueue.queueList.data.header" /></th> 
     24                                                <th><spring:message code="Hl7inQueue.queueList.state.header" /></th> 
     25                                                <th><spring:message code="Hl7inQueue.queueList.errorMessage.header" /></th> 
     26                                                <th><spring:message code="Hl7inQueue.queueList.dateCreated" /></th> 
     27                                        </tr> 
     28                                        <c:forEach var="queue" items="${queueList}"> 
     29                                                <tr> 
     30                                                        <td valign="top"><input type="checkbox" name="queueId" value="${queue.HL7InQueueId}"></td>       
     31                                                        <td valign="top">${queue.HL7Source.name}</td> 
     32                                                        <td valign="top"> 
     33                                                                <div style="overflow:auto"> 
     34                                                                        <pre>${queue.HL7Data}</pre> 
     35                                                                </div>                                                   
     36                                                        </td> 
     37                                                        <td valign="top"><spring:message code="Hl7inQueue.status.${queue.messageState}" /></td> 
     38                                                        <td valign="top">${queue.errorMessage}</td> 
     39                                                        <td valign="top">${queue.dateCreated }</td>      
     40                                                </tr> 
     41                                        </c:forEach> 
     42                                        <tr> 
     43                                                <td colspan="6"> 
     44                                                        <input type="submit" value="<spring:message code="Hl7inQueue.queueList.delete"/>" name="delete"> 
     45                                                </td> 
     46                                        </tr> 
     47                                </table> 
     48                                </c:if> 
     49                        </div> 
     50                </form> 
     51        </div> 
     52</div> 
     53 
     54 
     55<%@ include file="/WEB-INF/template/footer.jsp" %> 
  • D:/Workspace/OpenMRS-trunk/web/WEB-INF/view/admin/hl7/localHeader.jsp

    old new  
     1<ul id="menu"> 
     2        <li class="first"> 
     3                <a href="${pageContext.request.contextPath}/admin"><spring:message code="admin.title.short"/></a> 
     4        </li> 
     5        <openmrs:hasPrivilege privilege="View HL7Messages"> 
     6                <li <c:if test='<%= request.getRequestURI().contains("hl7InQueue") %>'>class="active"</c:if>> 
     7                        <a href="${pageContext.request.contextPath}/admin/hl7/hl7InQueue.list" class="retired"> 
     8                                <spring:message code="Hl7inQueue.title"/> 
     9                        </a> 
     10                </li> 
     11        </openmrs:hasPrivilege> 
     12        <openmrs:hasPrivilege privilege="View HL7Messages"> 
     13                <li <c:if test='<%= request.getRequestURI().contains("hl7Deleted") %>'>class="active"</c:if>> 
     14                        <a href="${pageContext.request.contextPath}/admin/hl7/hl7Deleted.form" class="retired"> 
     15                                <spring:message code="Hl7inQueueRestore.title"/> 
     16                        </a> 
     17                </li> 
     18        </openmrs:hasPrivilege> 
     19        <openmrs:hasPrivilege privilege="View HL7Messages"> 
     20                <li <c:if test='<%= request.getRequestURI().contains("hl7InError") %>'>class="active"</c:if>> 
     21                        <a href="${pageContext.request.contextPath}/admin/hl7/hl7InError.list" class="retired"> 
     22                                <spring:message code="Hl7inError.title"/> 
     23                        </a> 
     24                </li> 
     25        </openmrs:hasPrivilege> 
     26        <openmrs:extensionPoint pointId="org.openmrs.admin.hl7.localHeader" type="html"> 
     27                        <c:forEach items="${extension.links}" var="link"> 
     28                                <li <c:if test='${fn:endsWith(pageContext.request.requestURI, link.key)}'>class="active"</c:if> > 
     29                                        <a href="${pageContext.request.contextPath}/${link.key}"> 
     30                                                <spring:message code="${link.value}"/> 
     31                                        </a> 
     32                                </li> 
     33                        </c:forEach> 
     34        </openmrs:extensionPoint> 
     35</ul> 
  • D:/Workspace/OpenMRS-trunk/web/WEB-INF/view/admin/index.jsp

    old new  
    113113                                </div> 
    114114                        </openmrs:hasPrivilege> 
    115115                         
     116                        <openmrs:hasPrivilege privilege="View HL7Messages"> 
     117                                <div class="adminMenuList"> 
     118                                        <h4><spring:message code="Hl7Messages.header"/></h4> 
     119                                                <%@ include file="hl7/localHeader.jsp" %> 
     120                                </div> 
     121                        </openmrs:hasPrivilege> 
     122                         
    116123                        <openmrs:hasPrivilege privilege="Edit Patients,Audit,View Patients"> 
    117124                                <div class="adminMenuList"> 
    118125                                        <h4><spring:message code="Maintenance.header"/></h4>