/** * @see org.openmrs.hl7.HL7Service#parseHL7String(String) */ @Override public Message parseHL7String(String hl7Message) throws HL7Exception { // Any pre-parsing for HL7 messages would go here // or a module can use AOP to pre-parse the message // First, try and parse the message Message message; try { message = parser.parse(hl7Message); } catch (EncodingNotSupportedException e) { throw new HL7Exception("HL7 encoding not supported", e); } catch (HL7Exception e) { throw new HL7Exception("Error parsing message", e); } return message; }
throw new HL7Exception("hl7InQueue argument cannot be null"); throw new HL7Exception("The hl7InQueue message with id: " + hl7InQueue.getHL7InQueueId() + " is already processing. " + ",key=" + hl7InQueue.getHL7SourceKey() + ")"); } else { + Context.getAdministrationService().getGlobalProperty( OpenmrsConstants.GLOBAL_PROPERTY_IGNORE_MISSING_NONLOCAL_PATIENTS, "false")); if (e.getCause() != null && "Could not resolve patient".equals(e.getCause().getMessage()) && !"local".equals(hl7InQueue.getHL7Source().getName()) && "true".equals(Context.getAdministrationService().getGlobalProperty(
private <R> void handleException(ValidationExceptionHandler<R> handler, R result) throws HL7Exception { if (handler.hasFailed()) { HL7Exception e = new HL7Exception("Validation has failed"); e.setDetail(result); if (result instanceof Message) e.setResponseMessage((Message)result); throw e; } }
/** * Provides an overview of the type and structure of this message */ @Override public String toString() { try { return encode(); } catch (HL7Exception e) { return (getClass().getName() + " - Failed to create toString(): " + e.getMessage()); } }
public static ValidationException fromHL7Exception(HL7Exception e) { ValidationException ve = new ValidationException(e.getMessageWithoutLocation(), e); ve.setErrorCode(e.getErrorCode()); ve.setLocation(e.getLocation()); ve.setSeverity(e.getSeverity()); return ve; }
+ e.getMessage()); e.printStackTrace();
inMessage = parser.parse(messageString); } catch (HL7Exception e) { e.printStackTrace();
/** * {@inheritDoc } */ public Message generateACK(AcknowledgmentCode theAcknowledgementCode, HL7Exception theException) throws HL7Exception, IOException { if (theException != null && theException.getResponseMessage() != null) { return theException.getResponseMessage(); } Message out = instantiateACK(); out.setParser(getParser()); fillResponseHeader(out, theAcknowledgementCode); if (theException != null) { theException.populateResponse(out, theAcknowledgementCode, 0); } return out; }
public Message createNak0(Message originalMessage, HL7Exception e, AcknowledgmentCode ackTypeCode) throws HL7Exception { AbstractMessage ack = (AbstractMessage) MessageUtils.response( originalMessage, messageType, triggerEvent); LOG.info("Creating NAK response event of type {}", ack.getClass().getName()); e.populateResponse(ack, ackTypeCode, 0); Segment msa = (Segment) ack.get("MSA"); Terser.set(msa, 1, 0, 1, 1, ackTypeCode.name()); Segment ackQak = (Segment) ack.get("QAK"); Segment origQpd = (Segment) originalMessage.get("QPD"); if (origQpd != null) { String queryTag = Terser.get(origQpd, 2, 0, 1, 1); Terser.set(ackQak, 1, 0, 1, 1, queryTag); LOG.debug("Set QAK-1 to {}", queryTag); } Terser.set(ackQak, 2, 0, 1, 1, "AE"); // create a dummy QPD segment, it will be replaced with proper contents by // org.openehealth.ipf.platform.camel.ihe.hl7v2.intercept.consumer.ConsumerSegmentEchoingInterceptor Segment ackQpd = (Segment) ack.get("QPD"); Terser.set(ackQpd, 1, 0, 1, 1, "dummy"); return ack; }
/** * Provides an overview of the type and structure of this message */ @Override public String toString() { try { return encode(); } catch (HL7Exception e) { return (getClass().getName() + " - Failed to create toString(): " + e.getMessage()); } }
private <R> void handleException(ValidationExceptionHandler<R> handler, R result) throws HL7Exception { if (handler.hasFailed()) { HL7Exception e = new HL7Exception("Validation has failed"); e.setDetail(result); if (result instanceof Message) e.setResponseMessage((Message)result); throw e; } }
public static ValidationException fromHL7Exception(HL7Exception e) { ValidationException ve = new ValidationException(e.getMessageWithoutLocation(), e); ve.setErrorCode(e.getErrorCode()); ve.setLocation(e.getLocation()); ve.setSeverity(e.getSeverity()); return ve; }
inMessage = parser.parse(messageString); } catch (HL7Exception e) { e.printStackTrace();
/** * {@inheritDoc } */ public Message generateACK(AcknowledgmentCode theAcknowledgementCode, HL7Exception theException) throws HL7Exception, IOException { if (theException != null && theException.getResponseMessage() != null) { return theException.getResponseMessage(); } Message out = instantiateACK(); out.setParser(getParser()); fillResponseHeader(out, theAcknowledgementCode); if (theException != null) { theException.populateResponse(out, theAcknowledgementCode, 0); } return out; }
throw new HL7Exception("Invalid time format '" + s + "'"); throw new HL7Exception("Invalid time format '" + s + "'"); } else { timeString.append("."); throw new HL7Exception("Invalid time format: '" + s + "' [" + timeString + "]", e);
/** * Returns the index of the given structure as a child of the * given parent. Returns null if the child isn't found. */ public static Index getIndex(Group parent, Structure child) { Index index = null; String[] names = parent.getNames(); findChild : for (int i = 0; i < names.length; i++) { if (names[i].startsWith(child.getName())) { try { Structure[] reps = parent.getAll(names[i]); for (int j = 0; j < reps.length; j++) { if (child.equals(reps[j])) { index = new Index(names[i], j); break findChild; } } } catch (HL7Exception e) { log.error(e.getMessage(), e); throw new Error("Internal HL7Exception finding structure index: " + e.getMessage()); } } } return index; }
/** * Test harness. */ public static void main(String args[]) { try { //FileCodeMapper mapper = new FileCodeMapper(); CodeMapper.getInstance().throwExceptionIfNoMatch(true); System.out.println("Local code for M is " + CodeMapper.getLocal("test", 1, "M")); System.out.println("Interface code for female is " + CodeMapper.getInt("test", 1, "female")); } catch (HL7Exception e) { e.printStackTrace(); } }
/** * @see org.openmrs.hl7.HL7Service#processHL7Message(ca.uhn.hl7v2.model.Message) */ @Override public Message processHL7Message(Message message) throws HL7Exception { // Any post-parsing (pre-routing) processing would go here // or a module can use AOP to do the post-parsing Message response; try { if (!router.canProcess(message)) { throw new HL7Exception("No route for hl7 message: " + message.getName() + ". Make sure you have a module installed that registers a hl7handler for this type"); } response = router.processMessage(message); } catch (ApplicationException e) { throw new HL7Exception("Error while processing HL7 message: " + message.getName(), e); } return response; }
/** * Returns the index of the given structure as a child of the * given parent. Returns null if the child isn't found. */ public static Index getIndex(Group parent, Structure child) { Index index = null; String[] names = parent.getNames(); findChild : for (int i = 0; i < names.length; i++) { if (names[i].startsWith(child.getName())) { try { Structure[] reps = parent.getAll(names[i]); for (int j = 0; j < reps.length; j++) { if (child.equals(reps[j])) { index = new Index(names[i], j); break findChild; } } } catch (HL7Exception e) { log.error(e.getMessage(), e); throw new Error("Internal HL7Exception finding structure index: " + e.getMessage()); } } } return index; }