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 #-------------------------------------- 2 2 # USE: 3 3 # The diffs are ordered by datamodel version number. 4 4 #-------------------------------------- … … 1213 1213 call diff_procedure('1.4.0.02'); 1214 1214 1215 1215 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'; 1225 delimiter ; 1226 call diff_procedure('1.4.0.02'); 1227 1216 1228 #----------------------------------- 1217 1229 # Clean up - Keep this section at the very bottom of diff script 1218 1230 #----------------------------------- 1219 1231 1220 DROP PROCEDURE IF EXISTS diff_procedure; 1232 DROP PROCEDURE IF EXISTS diff_procedure; -
D:/Workspace/OpenMRS-trunk/metadata/api/hibernate/org/openmrs/hl7/db/hibernate/HL7InArchive.hbm.xml
old new 24 24 <property name="HL7Data" type="java.lang.String" 25 25 column="hl7_data" not-null="true" length="16777215" /> 26 26 27 <property name="messageState" type="java.lang.Integer" 28 column="message_state" not-null="false" length="4" /> 29 27 30 <property name="dateCreated" type="java.util.Date" 28 31 column="date_created" not-null="true" length="19" /> 29 32 -
D:/Workspace/OpenMRS-trunk/metadata/api/hibernate/org/openmrs/hl7/db/hibernate/HL7InQueue.hbm.xml
old new 26 26 27 27 <property name="dateCreated" type="java.util.Date" 28 28 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" /> 29 35 30 36 </class> 31 37 </hibernate-mapping> -
D:/Workspace/OpenMRS-trunk/src/api/org/openmrs/hl7/db/hibernate/HibernateHL7DAO.java
old new 23 23 import org.hibernate.criterion.Restrictions; 24 24 import org.openmrs.api.context.Context; 25 25 import org.openmrs.api.db.DAOException; 26 import org.openmrs.hl7.HL7Constants; 26 27 import org.openmrs.hl7.HL7InArchive; 27 28 import org.openmrs.hl7.HL7InError; 28 29 import org.openmrs.hl7.HL7InQueue; … … 31 32 32 33 /** 33 34 * OpenMRS HL7 API database default hibernate implementation 34 * 35 * 35 36 * This class shouldn't be instantiated by itself. Use the 36 37 * {@link org.openmrs.api.context.Context} 37 * 38 * 38 39 * @see org.openmrs.hl7.HL7Service 39 40 * @see org.openmrs.hl7.db.HL7DAO 40 41 */ … … 52 53 53 54 /** 54 55 * Set session factory 55 * 56 * 56 57 * @param sessionFactory 57 58 */ 58 59 public void setSessionFactory(SessionFactory sessionFactory) { … … 124 125 @SuppressWarnings("unchecked") 125 126 public List<HL7InQueue> getAllHL7InQueues() throws DAOException { 126 127 return sessionFactory.getCurrentSession() 127 .createQuery("from HL7InQueue order by hL7InQueueId")128 .createQuery("from HL7InQueue order by HL7InQueueId") 128 129 .list(); 129 130 } 130 131 … … 166 167 .get(HL7InArchive.class, 167 168 hl7InArchiveId); 168 169 } 169 170 170 171 /** 171 * @see org.openmrs.hl7.db.HL7DAO#getHL7InArchive s()172 * @see org.openmrs.hl7.db.HL7DAO#getHL7InArchiveByState() 172 173 */ 173 174 @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") 174 184 public List<HL7InArchive> getAllHL7InArchives() throws DAOException { 175 185 return sessionFactory.getCurrentSession() 176 .createQuery("from HL7InArchive order by hL7InArchiveId")186 .createQuery("from HL7InArchive order by HL7InArchiveId") 177 187 .list(); 178 188 } 179 189 … … 207 217 @SuppressWarnings("unchecked") 208 218 public List<HL7InError> getAllHL7InErrors() throws DAOException { 209 219 return sessionFactory.getCurrentSession() 210 .createQuery("from HL7InError order by hL7InErrorId")220 .createQuery("from HL7InError order by HL7InErrorId") 211 221 .list(); 212 222 } 213 223 -
D:/Workspace/OpenMRS-trunk/src/api/org/openmrs/hl7/db/HL7DAO.java
old new 101 101 throws DAOException; 102 102 103 103 /** 104 * @see org.openmrs.hl7.HL7Service#get AllHL7InArchive()104 * @see org.openmrs.hl7.HL7Service#getHL7InArchiveByState() 105 105 */ 106 public List<HL7InArchive> getHL7InArchiveByState() throws DAOException; 107 /** 108 * @see org.openmrs.hl7.HL7Service#getAllHL7InArchives() 109 */ 106 110 public List<HL7InArchive> getAllHL7InArchives() throws DAOException; 107 111 108 112 /** -
D:/Workspace/OpenMRS-trunk/src/api/org/openmrs/hl7/HL7Service.java
old new 226 226 @Transactional(readOnly = true) 227 227 @Authorized(HL7Constants.PRIV_VIEW_HL7_IN_ARCHIVE) 228 228 public HL7InArchive getHL7InArchive(Integer hl7InArchiveId); 229 229 230 230 /** 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 /** 231 240 * Get all archive hl7 queue items from the database 232 241 * 233 242 * @return list of archive items -
D:/Workspace/OpenMRS-trunk/src/api/org/openmrs/hl7/impl/HL7ServiceImpl.java
old new 215 215 public void deleteHL7InQueue(HL7InQueue hl7InQueue) { 216 216 purgeHL7InQueue(hl7InQueue); 217 217 } 218 218 219 219 /** 220 * @see org.openmrs.hl7.HL7Service#getHL7InArchiveByState() 221 */ 222 public List<HL7InArchive> getHL7InArchiveByState() throws APIException { 223 return dao.getHL7InArchiveByState(); 224 } 225 226 /** 220 227 * @see org.openmrs.hl7.HL7Service#getAllHL7InArchives() 221 228 */ 222 229 public List<HL7InArchive> getAllHL7InArchives() throws APIException { -
D:/Workspace/OpenMRS-trunk/src/api/org/openmrs/hl7/HL7InArchive.java
old new 21 21 private HL7Source hl7Source; 22 22 private String hl7SourceKey; 23 23 private String hl7Data; 24 private Integer messageState; 24 25 private Date dateCreated; 25 26 26 27 /** … … 36 37 setHL7Source(hl7InQueue.getHL7Source()); 37 38 setHL7SourceKey(hl7InQueue.getHL7SourceKey()); 38 39 setHL7Data(hl7InQueue.getHL7Data()); 40 setMessageState(HL7Constants.HL7_ARCHIVE_STATUS_DEFAULT); 39 41 } 40 42 41 43 /** … … 112 114 public void setHL7SourceKey(String hl7SourceKey) { 113 115 this.hl7SourceKey = hl7SourceKey; 114 116 } 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 } 115 130 116 131 } -
D:/Workspace/OpenMRS-trunk/src/api/org/openmrs/hl7/HL7InQueue.java
old new 24 24 private HL7Source hl7Source; 25 25 private String hl7SourceKey; 26 26 private String hl7Data; 27 private String errorMessage; 28 private Integer messageState=HL7Constants.HL7_ARCHIVE_STATUS_DEFAULT; 27 29 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 } 28 46 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 29 59 public boolean equals(Object obj) { 30 60 if (obj instanceof HL7InQueue) { 31 61 HL7InQueue hl7InQueue = (HL7InQueue)obj; … … 34 64 } 35 65 return false; 36 66 } 37 67 38 68 public int hashCode() { 39 69 if (this.getHL7InQueueId() == null) 40 70 return super.hashCode(); … … 118 148 this.hl7SourceKey = hl7SourceKey; 119 149 } 120 150 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 } 121 180 } -
D:/Workspace/OpenMRS-trunk/src/api/org/openmrs/hl7/HL7Constants.java
old new 40 40 public static final String PRIV_UPDATE_HL7_IN_EXCEPTION = "Update HL7 Inbound Exception"; 41 41 public static final String PRIV_DELETE_HL7_IN_EXCEPTION = "Delete HL7 Inbound Exception"; 42 42 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 44 47 public static final int HL7_STATUS_PENDING = 0; 45 48 public static final int HL7_STATUS_PROCESSING = 1; 46 49 public static final int HL7_STATUS_PROCESSED = 2; 47 50 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; 49 54 } -
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 15 package org.openmrs.hl7.web.controller; 16 17 import java.util.Collection; 18 import java.util.HashMap; 19 import java.util.List; 20 import java.util.Map; 21 import java.util.Vector; 22 23 import javax.servlet.ServletException; 24 import javax.servlet.http.HttpServletRequest; 25 import javax.servlet.http.HttpServletResponse; 26 import javax.servlet.http.HttpSession; 27 28 import org.apache.commons.logging.Log; 29 import org.apache.commons.logging.LogFactory; 30 import org.openmrs.api.APIException; 31 import org.openmrs.api.context.Context; 32 import org.openmrs.hl7.HL7Service; 33 import org.openmrs.hl7.HL7InQueue; 34 import org.openmrs.hl7.HL7InArchive; 35 import org.openmrs.hl7.HL7Constants; 36 import org.openmrs.web.WebConstants; 37 import org.springframework.beans.propertyeditors.CustomNumberEditor; 38 import org.springframework.context.support.MessageSourceAccessor; 39 import org.springframework.validation.BindException; 40 import org.springframework.validation.Errors; 41 import org.springframework.web.bind.ServletRequestDataBinder; 42 import org.springframework.web.servlet.ModelAndView; 43 import org.springframework.web.servlet.mvc.SimpleFormController; 44 import org.springframework.web.servlet.view.RedirectView; 45 46 public 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 */ 14 package org.openmrs.hl7.web.controller; 15 16 import java.util.Collection; 17 import java.util.HashMap; 18 import java.util.List; 19 import java.util.Map; 20 import java.util.Vector; 21 22 import javax.servlet.ServletException; 23 import javax.servlet.http.HttpServletRequest; 24 import javax.servlet.http.HttpServletResponse; 25 import javax.servlet.http.HttpSession; 26 27 import org.apache.commons.logging.Log; 28 import org.apache.commons.logging.LogFactory; 29 import org.openmrs.api.APIException; 30 import org.openmrs.api.context.Context; 31 import org.openmrs.hl7.HL7Constants; 32 import org.openmrs.hl7.HL7InArchive; 33 import org.openmrs.hl7.HL7InQueue; 34 import org.openmrs.hl7.HL7Service; 35 import org.openmrs.web.WebConstants; 36 import org.springframework.beans.propertyeditors.CustomNumberEditor; 37 import org.springframework.context.support.MessageSourceAccessor; 38 import org.springframework.validation.BindException; 39 import org.springframework.validation.Errors; 40 import org.springframework.web.bind.ServletRequestDataBinder; 41 import org.springframework.web.servlet.ModelAndView; 42 import org.springframework.web.servlet.mvc.SimpleFormController; 43 import org.springframework.web.servlet.view.RedirectView; 44 45 public 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 15 package org.openmrs.hl7.web.controller; 16 17 import java.util.Collection; 18 import java.util.HashMap; 19 import java.util.List; 20 import java.util.Map; 21 import java.util.Vector; 22 23 import javax.servlet.ServletException; 24 import javax.servlet.http.HttpServletRequest; 25 import javax.servlet.http.HttpServletResponse; 26 import javax.servlet.http.HttpSession; 27 28 import org.apache.commons.logging.Log; 29 import org.apache.commons.logging.LogFactory; 30 import org.openmrs.api.APIException; 31 import org.openmrs.api.context.Context; 32 import org.openmrs.hl7.HL7Constants; 33 import org.openmrs.hl7.HL7InQueue; 34 import org.openmrs.hl7.HL7InError; 35 import org.openmrs.hl7.HL7Service; 36 import org.openmrs.web.WebConstants; 37 import org.springframework.beans.propertyeditors.CustomNumberEditor; 38 import org.springframework.context.support.MessageSourceAccessor; 39 import org.springframework.validation.BindException; 40 import org.springframework.validation.Errors; 41 import org.springframework.web.bind.ServletRequestDataBinder; 42 import org.springframework.web.servlet.ModelAndView; 43 import org.springframework.web.servlet.mvc.SimpleFormController; 44 import org.springframework.web.servlet.view.RedirectView; 45 46 public 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 1718 1718 CohortDefinition.title=Cohort Definition 1719 1719 1720 1720 PatientSearch.title=Patient Search 1721 1722 Hl7Messages.header=HL7 Messages 1723 1724 Hl7inError.title=Manage HL7 Errors 1725 Hl7inError.header=HL7 Errors 1726 Hl7inError.errorList.source.header=Source 1727 Hl7inError.errorList.data.header=HL7 Data 1728 Hl7inError.errorList.error.header=Error 1729 Hl7inError.errorList.errorDetails.header=Error Details 1730 Hl7inError.errorList.dateCreated.header=Date of Occurrence 1731 Hl7inError.errorList.title=HL7 in Errors 1732 Hl7inError.errorList.restore=Move Back to Queue 1733 Hl7inError.errorList.restored=Message {0} successfully queued for processing 1734 Hl7inError.errorList.error=Error queuing item {0} for processing 1735 1736 Hl7inQueue.title=Manage Queued Messages 1737 Hl7inQueue.header=HL7 Queue 1738 Hl7inQueue.queueList.source.header=Source 1739 Hl7inQueue.queueList.data.header=HL7 Data 1740 Hl7inQueue.queueList.state.header=State 1741 Hl7inQueue.queueList.errorMessage.header=Error Message 1742 Hl7inQueue.queueList.dateCreated=Date Created 1743 Hl7inQueue.queueList.title=HL7 Queued messages 1744 Hl7inQueue.queueList.delete=Delete Selected Message(s) 1745 Hl7inQueue.queueList.deleted=Queue Item {0} deleted 1746 Hl7inQueue.queueList.restore=Restore Deleted Messages 1747 Hl7inQueue.queueList.error=Error deleting queue item 1748 1749 Hl7inQueue.queueForm.title=HL7 Deleted Messages 1750 Hl7inQueue.queueForm.source.header=Source 1751 Hl7inQueue.queueForm.data.header=HL7 Data 1752 Hl7inQueue.queueForm.dateDeleted=Date Deleted 1753 Hl7inQueue.queueForm.restore=Restore Selected Message(s) 1754 Hl7inQueue.queueForm.restored=Deleted queue item {0} has been restored 1755 Hl7inQueue.queueForm.error=Error restoring deleted queue item 1756 1757 Hl7inQueueRestore.title=Manage Deleted Messages 1758 Hl7inQueue.status.0=pending 1759 Hl7inQueue.status.1=processing 1760 Hl7inQueue.status.2=processed 1761 Hl7inQueue.status.3=error -
D:/Workspace/OpenMRS-trunk/web/WEB-INF/openmrs-servlet.xml
old new 142 142 <prop key="admin/scheduler/scheduler.form">schedulerFormController</prop> 143 143 144 144 <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 146 149 <prop key="admin/programs/program.list">programList</prop> 147 150 <prop key="admin/programs/program.form">programForm</prop> 148 151 <prop key="admin/programs/conversion.list">stateConversionList</prop> … … 222 225 <!-- ** /Scheduler ** --> 223 226 224 227 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 225 256 <!-- ================================ --> 226 257 <!-- ====== Observation Sector ====== --> 227 258 <!-- ================================ --> -
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> 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> 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> 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 113 113 </div> 114 114 </openmrs:hasPrivilege> 115 115 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 116 123 <openmrs:hasPrivilege privilege="Edit Patients,Audit,View Patients"> 117 124 <div class="adminMenuList"> 118 125 <h4><spring:message code="Maintenance.header"/></h4>
Download in other formats:
Powered by Trac 0.10.5
By Edgewall Software.
Visit the Trac open source project at
http://trac.edgewall.com/