Ticket #890: Ticket890.patch
| File Ticket890.patch, 46.3 kB (added by bwolfe, 1 year ago) |
|---|
-
/home/ben/workspace/openmrs-trunk-clean/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="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 -
/home/ben/workspace/openmrs-trunk-clean/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="state" not-null="false" length="4" /> 29 35 30 36 </class> 31 37 </hibernate-mapping> -
/home/ben/workspace/openmrs-trunk-clean/metadata/model/update-to-latest-db.mysqldiff.sql
old new 1882 1882 delimiter ; 1883 1883 call diff_procedure('1.4.0.20'); 1884 1884 1885 #---------------------------------------- 1886 # OpenMRS Datamodel version 1.4.0.21 1887 # Samuel Mbugua Sep 19, 2008 1888 # Adding a column to flag archived HL7 Messages State 1889 #---------------------------------------- 1890 1891 ALTER TABLE `hl7_in_archive` ADD COLUMN `state` tinyint(1) default '0' COMMENT '0=processed 1=deleted'; 1892 1893 delimiter ; 1894 call diff_procedure('1.4.0.21'); 1895 1885 1896 #----------------------------------- 1886 1897 # Clean up - Keep this section at the very bottom of diff script 1887 1898 #----------------------------------- -
/home/ben/workspace/openmrs-trunk-clean/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 171 /** 172 * @see org.openmrs.hl7.db.HL7DAO#getHL7InArchiveDeleted() 173 */ 174 @SuppressWarnings("unchecked") 175 public List<HL7InArchive> getAllHL7InArchiveDeleted() throws DAOException { 176 return sessionFactory.getCurrentSession() 177 .createQuery("from HL7InArchive where messageState=" + HL7Constants.HL7_ARCHIVE_STATUS_DELETED) 178 .list(); 179 } 170 180 /** 171 * @see org.openmrs.hl7.db.HL7DAO#get HL7InArchives()181 * @see org.openmrs.hl7.db.HL7DAO#getAllHL7InArchives() 172 182 */ 173 183 @SuppressWarnings("unchecked") 174 184 public List<HL7InArchive> getAllHL7InArchives() throws DAOException { … … 173 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 -
/home/ben/workspace/openmrs-trunk-clean/src/api/org/openmrs/hl7/db/HL7DAO.java
old new 101 101 throws DAOException; 102 102 103 103 /** 104 * @see org.openmrs.hl7.HL7Service#getAllHL7InArchive() 104 * @see org.openmrs.hl7.HL7Service#getAllHL7InArchiveDeleted() 105 */ 106 public List<HL7InArchive> getAllHL7InArchiveDeleted() throws DAOException; 107 /** 108 * @see org.openmrs.hl7.HL7Service#getAllHL7InArchives() 105 109 */ 106 110 public List<HL7InArchive> getAllHL7InArchives() throws DAOException; 107 111 -
/home/ben/workspace/openmrs-trunk-clean/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_MANAGE_HL7_MESSAGES = "Manage HL7 Messages"; 44 45 public static final int CHARACTERS_PER_LINE = 70; 44 46 public static final int HL7_STATUS_PENDING = 0; 45 47 public static final int HL7_STATUS_PROCESSING = 1; 46 48 public static final int HL7_STATUS_PROCESSED = 2; … … 45 47 public static final int HL7_STATUS_PROCESSING = 1; 46 48 public static final int HL7_STATUS_PROCESSED = 2; 47 49 public static final int HL7_STATUS_ERROR = 3; 48 50 public static final int HL7_ARCHIVE_STATUS_PROCESSED = 0; 51 public static final int HL7_ARCHIVE_STATUS_DEFAULT = 0; 52 public static final int HL7_ARCHIVE_STATUS_DELETED = 1; 49 53 } -
/home/ben/workspace/openmrs-trunk-clean/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 } -
/home/ben/workspace/openmrs-trunk-clean/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=0; 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 } -
/home/ben/workspace/openmrs-trunk-clean/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 /** 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> getAllHL7InArchiveDeleted()throws APIException;; 238 230 239 /** 231 240 * Get all archive hl7 queue items from the database 232 241 * -
/home/ben/workspace/openmrs-trunk-clean/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 /** 220 * @see org.openmrs.hl7.HL7Service#getAllHL7InArchiveDeleted() 221 */ 222 public List<HL7InArchive> getAllHL7InArchiveDeleted() throws APIException { 223 return dao.getAllHL7InArchiveDeleted(); 224 } 225 219 226 /** 220 227 * @see org.openmrs.hl7.HL7Service#getAllHL7InArchives() 221 228 */ -
/home/ben/workspace/openmrs-trunk-clean/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> hl7InArchives = new Vector<HL7InArchive>(); 66 67 // Get all admin deleted messages in the HL7 in Archive 68 if (Context.isAuthenticated()) { 69 hl7InArchives = Context.getHL7Service().getAllHL7InArchiveDeleted(); 70 } 71 return hl7InArchives; 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)); 105 } 106 catch (APIException e){ 107 log.warn("Error restoring deleted queue item", e); 108 error.append(msa.getMessage("Hl7inQueue.queueForm..error", args)); 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 * This method creates a map to display the long data entry 127 */ 128 @SuppressWarnings("unchecked") 129 @Override 130 protected Map referenceData(HttpServletRequest request, Object command, Errors errors) throws Exception { 131 Map<String, Object> map = new HashMap<String, Object>(); 132 133 Collection<HL7InArchive> queues = (Collection<HL7InArchive>)command; 134 Map<HL7InArchive, String> hl7DataMap = new HashMap<HL7InArchive, String>(); 135 String CR = System.getProperty("line.separator"); 136 String formatedHl7Data; 137 138 //Break the Hl7Data into a block rather than a long string 139 for (HL7InArchive queue : queues){ 140 String theHl7Data = queue.getHL7Data(); 141 formatedHl7Data=""; 142 int loopCount=HL7Constants.CHARACTERS_PER_LINE; 143 if (theHl7Data.length() <= loopCount){ 144 formatedHl7Data=theHl7Data; 145 } 146 else { 147 formatedHl7Data=theHl7Data.substring(0,loopCount); 148 for (int innerLoopCount=loopCount;innerLoopCount<theHl7Data.length();innerLoopCount=innerLoopCount+HL7Constants.CHARACTERS_PER_LINE) { 149 loopCount=loopCount+HL7Constants.CHARACTERS_PER_LINE; 150 if (loopCount>=theHl7Data.length()) loopCount=theHl7Data.length(); 151 formatedHl7Data=formatedHl7Data + CR + theHl7Data.substring(innerLoopCount,loopCount); 152 } 153 } 154 155 hl7DataMap.put(queue, formatedHl7Data); 156 } 157 map.put("hl7Data", hl7DataMap); 158 159 return map; 160 } 161 } 162 163 -
/home/ben/workspace/openmrs-trunk-clean/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)); 145 } 146 catch (APIException e) { 147 log.warn("Error Processing erred message", e); 148 error.append(msa.getMessage("Hl7inError.errorList.error", args)); 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 -
/home/ben/workspace/openmrs-trunk-clean/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)); 104 } 105 catch (APIException e){ 106 log.warn("Error deleting a queue entry", e); 107 error.append(msa.getMessage("Hl7inQueue.queueList..error", args)); 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 * This method creates a map to display the long data entry 125 */ 126 127 @SuppressWarnings("unchecked") 128 @Override 129 protected Map referenceData(HttpServletRequest request, Object command, Errors errors) throws Exception { 130 Map<String, Object> map = new HashMap<String, Object>(); 131 132 Collection<HL7InQueue> queues = (Collection<HL7InQueue>)command; 133 Map<HL7InQueue, String> hl7Data = new HashMap<HL7InQueue, String>(); 134 String CR =System.getProperty("line.separator"); 135 String formatedHl7Data; 136 137 //Break the Hl7Data into a block rather than a long string 138 for (HL7InQueue queue : queues){ 139 String theHl7Data = queue.getHL7Data(); 140 formatedHl7Data=""; 141 int loopCount=HL7Constants.CHARACTERS_PER_LINE; 142 if (theHl7Data.length()<=loopCount){ 143 formatedHl7Data=theHl7Data; 144 } 145 else { 146 formatedHl7Data=theHl7Data.substring(0,loopCount); 147 for (int innerLoopCount=loopCount;innerLoopCount<theHl7Data.length();innerLoopCount=innerLoopCount+HL7Constants.CHARACTERS_PER_LINE) { 148 loopCount=loopCount+HL7Constants.CHARACTERS_PER_LINE; 149 if (loopCount>=theHl7Data.length()) loopCount=theHl7Data.length(); 150 formatedHl7Data=formatedHl7Data + CR + theHl7Data.substring(innerLoopCount,loopCount); 151 } 152 } 153 154 hl7Data.put(queue, formatedHl7Data); 155 } 156 map.put("hl7Data", hl7Data); 157 158 return map; 159 } 160 } 161 -
/home/ben/workspace/openmrs-trunk-clean/web/WEB-INF/messages.properties
old new 1762 1762 CohortDefinition.title=Cohort Definition 1763 1763 1764 1764 PatientSearch.title=Patient Search 1765 1766 Hl7Messages.header=HL7 Messages 1767 1768 Hl7inError.title=Manage HL7 Errors 1769 Hl7inError.header=HL7 Errors 1770 Hl7inError.errorList.source.header=Source 1771 Hl7inError.errorList.data.header=HL7 Data 1772 Hl7inError.errorList.error.header=Error 1773 Hl7inError.errorList.errorDetails.header=Error Details 1774 Hl7inError.errorList.dateCreated.header=Date Created 1775 Hl7inError.errorList.title=HL7 in Errors 1776 Hl7inError.errorList.restore=Process Selected Message(s) 1777 Hl7inError.errorList.restored=Message {0} successfully queued for processing<br/> 1778 Hl7inError.errorList.error=Error queuing item {0} for processing<br/> 1779 1780 Hl7inQueue.title=Manage Queued Messages 1781 Hl7inQueue.header=HL7 Queue 1782 Hl7inQueue.queueList.source.header=Source 1783 Hl7inQueue.queueList.data.header=HL7 Data 1784 Hl7inQueue.queueList.state.header=State 1785 Hl7inQueue.queueList.errorMessage.header=Error Message 1786 Hl7inQueue.queueList.dateCreated.header=Date Created 1787 Hl7inQueue.queueList.title=HL7 Queued messages 1788 Hl7inQueue.queueList.delete=Delete Selected Message(s) 1789 Hl7inQueue.queueList.deleted=Queue Item {0} deleted<br/> 1790 Hl7inQueue.queueList.restore=Restore Deleted Messages 1791 Hl7inQueue.queueList.error=Error deleting queue item<br/> 1792 1793 Hl7inQueue.queueForm.title=HL7 Deleted Messages 1794 Hl7inQueue.queueForm.source.header=Source 1795 Hl7inQueue.queueForm.data.header=HL7 Data 1796 Hl7inQueue.queueForm.dateCreated.header=Date Created 1797 Hl7inQueue.queueForm.restore=Restore Selected Message(s) 1798 Hl7inQueue.queueForm.restored=Deleted queue item {0} has been restored<br/> 1799 Hl7inQueue.queueForm.error=Error restoring deleted queue item<br/> 1800 1801 Hl7inQueue.status.pending=pending 1802 Hl7inQueue.status.processing=processing 1803 Hl7inQueue.status.processed=processed 1804 Hl7inQueue.status.error=error 1805 1806 Hl7inQueueRestore.title=Restore Deleted Messages 1807 1808 Hl7Messages.header=HL7 Messages 1809 1810 Hl7inError.title=Manage HL7 Errors 1811 Hl7inError.header=HL7 Errors 1812 Hl7inError.errorList.title=HL7 in Errors 1813 Hl7inError.errorList.restore=Process Selected Message(s) 1814 Hl7inError.errorList.restored=Message {0} successfully queued for processing<br/> 1815 Hl7inError.errorList.error=Error queuing item {0} for processing<br/> 1816 1817 Hl7inQueue.title=Manage Queued Messages 1818 Hl7inQueue.header=HL7 Queue 1819 Hl7inQueue.queueList.title=HL7 Queued messages 1820 Hl7inQueue.queueList.delete=Delete Selected Message(s) 1821 Hl7inQueue.queueList.deleted=Queue Item {0} deleted<br/> 1822 Hl7inQueue.queueList.restore=Restore Deleted Messages 1823 Hl7inQueue.queueList.error=Error deleting queue item<br/> 1824 Hl7inQueue.queueForm.title=HL7 Deleted Messages 1825 Hl7inQueue.queueForm.restore=Restore Selected Message(s) 1826 Hl7inQueue.queueForm.restored=The deleted queue item {0} has been restored<br/> 1827 Hl7inQueue.queueForm.error=Error restoring deleted queue item<br/> 1828 Hl7inQueue.status.0=pending 1829 Hl7inQueue.status.1=processing 1830 Hl7inQueue.status.2=processed 1831 Hl7inQueue.status.3=error 1832 1833 Hl7inQueueRestore.title=Restore Deleted Messages -
/home/ben/workspace/openmrs-trunk-clean/web/WEB-INF/openmrs-servlet.xml
old new 144 144 <prop key="admin/scheduler/scheduler.form">schedulerFormController</prop> 145 145 146 146 <prop key="remotecommunication/postHl7.form">postHl7FormController</prop> 147 147 <prop key="admin/hl7/hl7InError.list">hl7InErrorListController</prop> 148 <prop key="admin/hl7/hl7InQueue.list">hl7InQueueListController</prop> 149 <prop key="admin/hl7/hl7Deleted.form">hl7DeletedFormController</prop> 150 148 151 <prop key="admin/programs/program.list">programList</prop> 149 152 <prop key="admin/programs/program.form">programForm</prop> 150 153 <prop key="admin/programs/conversion.list">stateConversionList</prop> … … 225 228 </bean> 226 229 <!-- ** /Scheduler ** --> 227 230 231 <!-- =============================== --> 232 <!-- ===== HL7 Messages Section ===== --> 233 <!-- =============================== --> 234 235 <!-- ** HL7 in Error List Controller ** --> 236 <bean id="hl7InErrorListController" 237 class="org.openmrs.hl7.web.controller.Hl7InErrorListController"> 238 <property name="commandName"><value>errorList</value></property> 239 <property name="formView"><value>/admin/hl7/hl7InErrorList</value></property> 240 <property name="successView"><value>hl7InError.list</value></property> 241 </bean> 242 243 <!-- ** HL7 in Queue List Controller ** --> 244 <bean id="hl7InQueueListController" 245 class="org.openmrs.hl7.web.controller.Hl7InQueueListController"> 246 <property name="commandName"><value>queueList</value></property> 247 <property name="formView"><value>/admin/hl7/hl7InQueueList</value></property> 248 <property name="successView"><value>hl7InQueue.list</value></property> 249 </bean> 250 251 <bean id="hl7DeletedFormController" 252 class="org.openmrs.hl7.web.controller.Hl7DeletedFormController"> 253 <property name="commandName"><value>queueForm</value></property> 254 <property name="formView"><value>/admin/hl7/hl7DeletedForm</value></property> 255 <property name="successView"><value>hl7Deleted.form</value></property> 256 </bean> 257 <!-- ** /HL7 Messages Section** --> 228 258 229 259 <!-- ================================ --> 230 260 <!-- ====== Observation Sector ====== --> -
/home/ben/workspace/openmrs-trunk-clean/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"> 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 <table cellpadding="5" cellspacing="0"> 21 <tr> 22 <th></th> 23 <th><spring:message code="Hl7inQueue.queueForm.source.header" /></th> 24 <th><spring:message code="Hl7inQueue.queueForm.data.header" /></th> 25 <th><spring:message code="Hl7inQueue.queueForm.dateCreated.header" /></th> 26 </tr> 27 <c:forEach var="queue" items="${queueForm}"> 28 <tr> 29 <td valign="top"><input type="checkbox" name="queueId" value="${queue.HL7InArchiveId}"></td> 30 <td valign="top">${queue.HL7Source.name}</td> 31 <td valign="top">${hl7Data[queue]}</td> 32 <td valign="top">${queue.dateCreated }</td> 33 </tr> 34 </c:forEach> 35 <tr> 36 <td colspan="6"> 37 <input type="submit" value="<spring:message code="Hl7inQueue.queueForm.restore"/>" name="restore"> 38 </td> 39 </tr> 40 </table> 41 </div> 42 </form> 43 </div> 44 </div> 45 46 47 <%@ include file="/WEB-INF/template/footer.jsp" %> -
/home/ben/workspace/openmrs-trunk-clean/web/WEB-INF/view/admin/hl7/hl7InErrorList.jsp
old new 1 <%@ include file="/WEB-INF/template/include.jsp" %> 2 3 <openmrs:require privilege="Manage 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 9 <script type="text/javascript"> 10 11 </script> 12 13 <h2><spring:message code="Hl7inError.header" /></h2> 14 15 <div class="hl7inErrorList"> 16 <b class="boxHeader"><spring:message code="Hl7inError.errorList.title" /></b> 17 <div class="box"> 18 <form id="hl7inErrorListForm" method="post"> 19 <div id="hl7ErrorListing"> 20 <table cellpadding="5" cellspacing="0"> 21 <tr> 22 <th></th> 23 <th><spring:message code="Hl7inError.errorList.source.header" /></th> 24 <th><spring:message code="Hl7inError.errorList.data.header" /></th> 25 <th><spring:message code="Hl7inError.errorList.error.header" /></th> 26 <th><spring:message code="Hl7inError.errorList.errorDetails.header" /></th> 27 <th><spring:message code="Hl7inError.errorList.dateCreated.header" /></th> 28 </tr> 29 <c:forEach var="error" items="${errorList}"> 30 <tr> 31 <td valign="top"><input type="checkbox" name="errorId" value="${error.HL7InErrorId}"></td> 32 <td valign="top">${error.HL7Source.name}</td> 33 <td valign="top">${hl7Data[error]}</td> 34 <td valign="top">${error.error}</td> 35 <td valign="top">${error.errorDetails}</td> 36 <td valign="top">${error.dateCreated }</td> 37 </tr> 38 </c:forEach> 39 <tr> 40 <td colspan="6"> 41 <input type="submit" value="<spring:message code="Hl7inError.errorList.restore"/>" name="restore"> 42 </td> 43 </tr> 44 </table> 45 </div> 46 </form> 47 </div> 48 </div> 49 50 51 <%@ include file="/WEB-INF/template/footer.jsp" %> -
/home/ben/workspace/openmrs-trunk-clean/web/WEB-INF/view/admin/hl7/hl7InQueueList.jsp
old new 1 <%@ include file="/WEB-INF/template/include.jsp" %> 2 3 <openmrs:require privilege="Manage 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 9 <script type="text/javascript"> 10 11 </script> 12 13 <h2><spring:message code="Hl7inQueue.header" /></h2> 14 15 <a href="hl7Deleted.form"><spring:message code="Hl7inQueue.queueList.restore" /></a> 16 <br/><br/> 17 18 <div class="hl7inQueueList"> 19 <b class="boxHeader"><spring:message code="Hl7inQueue.queueList.title" /></b> 20 <div class="box"> 21 <form id="hl7inQueueListForm" method="post"> 22 <div id="hl7QueueListing"> 23 <table cellpadding="5" cellspacing="0"> 24 <tr> 25 <th></th> 26 <th><spring:message code="Hl7inQueue.queueList.source.header" /></th> 27 <th><spring:message code="Hl7inQueue.queueList.data.header" /></th> 28 <th><spring:message code="Hl7inQueue.queueList.state.header" /></th> 29 <th><spring:message code="Hl7inQueue.queueList.errorMessage.header" /></th> 30 <th><spring:message code="Hl7inQueue.queueList.dateCreated.header" /></th> 31 </tr> 32 <c:forEach var="queue" items="${queueList}"> 33 <tr> 34 <td valign="top"><input type="checkbox" name="queueId" value="${queue.HL7InQueueId}"></td> 35 <td valign="top">${queue.HL7Source.name}</td> 36 <td valign="top">${hl7Data[queue]}</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 </div> 49 </form> 50 </div> 51 </div> 52 53 54 <%@ include file="/WEB-INF/template/footer.jsp" %> -
/home/ben/workspace/openmrs-trunk-clean/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="Manage 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="Manage 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="Manage 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> -
/home/ben/workspace/openmrs-trunk-clean/web/WEB-INF/view/admin/index.jsp
old new 113 113 </div> 114 114 </openmrs:hasPrivilege> 115 115 116 <openmrs:hasPrivilege privilege="Manage 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/