parser.setValidationContext( validationContext ); Message msg = parser.parse( message ); Structure structure = msg.get( "MSH" ); String messageType = null; String version = msg.getVersion();
/** * Generates an HL7v2 NAK response message on the basis * of the thrown exception and the original HAPI request message. * * @param exception thrown exception. * @param originalMessage original HAPI request message. * @param ackTypeCode HL7v2 acknowledgement type code. */ public Message createNak(Message originalMessage, HL7Exception exception, AcknowledgmentCode ackTypeCode) throws HL7Exception, IOException { return originalMessage.generateACK(ackTypeCode, exception); }
parser.setValidationContext( validationContext ); Message msg = parser.parse( message ); Message ack = msg.generateACK(); String ackMessage = ack.encode();
new HL7Value( message.getVersion(), rootGroup.getName(), group.getName(), structure.getName(), structureNumber, names[n - 1], coordinates, types[t].getName(), description, string ); values.add( value );
/** * @deprecated use {@link Message#generateACK()} */ public static Message makeACK(Segment inboundHeader) throws HL7Exception, IOException { // Make sure that the referenced message is not just a dummy DeepCopy.copy(inboundHeader, (Segment)inboundHeader.getMessage().get("MSH")); return inboundHeader.getMessage().generateACK(); }
private String handleProcessMessageException(String incomingMessageString, Map<String, Object> theMetadata, Message incomingMessageObject, Exception e) throws HL7Exception { String outgoingMessageString; Segment inHeader = incomingMessageObject != null ? (Segment) incomingMessageObject.get("MSH") : null; outgoingMessageString = logAndMakeErrorMessage(e, inHeader, myParser, myParser.getEncoding(incomingMessageString)); if (outgoingMessageString != null && myExceptionHandler != null) { outgoingMessageString = myExceptionHandler.processException(incomingMessageString, theMetadata, outgoingMessageString, e); } return outgoingMessageString; }
public Parser getParser() { return getDelegate().getParser(); }
/** * Always returns true, assuming that the router calling this handler will only call this * handler with ADT_A28 messages. * * @return true */ @Override public boolean canProcess(Message message) { return message != null && "ADT_A28".equals(message.getName()); }
/** * Returns an instance using the MSH-1 and MSH-2 values of the given message * * @param message the message * @return the encoding characters for this message * @throws HL7Exception If either MSH-1 or MSH-2 are not populated * @since 1.0 */ public static EncodingCharacters getInstance(Message message) throws HL7Exception { final String encodingCharactersValue = message.getEncodingCharactersValue(); if (encodingCharactersValue == null || encodingCharactersValue.length() == 0) { throw new HL7Exception("encoding characters not populated"); } final Character fieldSeparatorValue = message.getFieldSeparatorValue(); if (fieldSeparatorValue == null) { throw new HL7Exception("Field separator not populated"); } return new EncodingCharacters(fieldSeparatorValue, encodingCharactersValue); }
private Message instantiateACK() throws HL7Exception { ModelClassFactory mcf = getParser() != null ? getParser().getFactory() : new DefaultModelClassFactory(); Version version = Version.versionOf(getVersion()); Message out = null; if (version != null && version.available()) { Class<? extends Message> clazz = mcf.getMessageClass("ACK", version.getVersion(), false); if (clazz != null) { out = ReflectionUtil.instantiateMessage(clazz, mcf); } } if (out == null) { out = new GenericMessage.UnknownVersion(mcf); } if (out instanceof GenericMessage) { if (!ArrayUtil.contains(out.getNames(), "MSA")) { out.addNonstandardSegment("MSA"); } if (!ArrayUtil.contains(out.getNames(), "ERR")) { out.addNonstandardSegment("ERR"); } } return out; }
public String encode() throws HL7Exception { return originalMessage != null ? originalMessage : getDelegate().encode(); }
public Character getFieldSeparatorValue() throws HL7Exception { return getDelegate().getFieldSeparatorValue(); }
public String getEncodingCharactersValue() throws HL7Exception { return getDelegate().getEncodingCharactersValue(); }
private void validate(Message message) throws HL7Exception { message.getVersion(); }
/** * @deprecated use {@link Message#generateACK()} */ public static Message makeACK(Segment inboundHeader) throws HL7Exception, IOException { // Make sure that the referenced message is not just a dummy DeepCopy.copy(inboundHeader, (Segment)inboundHeader.getMessage().get("MSH")); return inboundHeader.getMessage().generateACK(); }
private String handleProcessMessageException(String incomingMessageString, Map<String, Object> theMetadata, Message incomingMessageObject, Exception e) throws HL7Exception { String outgoingMessageString; Segment inHeader = incomingMessageObject != null ? (Segment) incomingMessageObject.get("MSH") : null; outgoingMessageString = logAndMakeErrorMessage(e, inHeader, myParser, myParser.getEncoding(incomingMessageString)); if (outgoingMessageString != null && myExceptionHandler != null) { outgoingMessageString = myExceptionHandler.processException(incomingMessageString, theMetadata, outgoingMessageString, e); } return outgoingMessageString; }
public Parser getParser() { return getDelegate().getParser(); }
/** * Always returns true, assuming that the router calling this handler will only call this * handler with ORU_R01 messages. * * @return true */ @Override public boolean canProcess(Message message) { return message != null && "ORU_R01".equals(message.getName()); }
/** * Returns an instance using the MSH-1 and MSH-2 values of the given message * * @param message the message * @return the encoding characters for this message * @throws HL7Exception If either MSH-1 or MSH-2 are not populated * @since 1.0 */ public static EncodingCharacters getInstance(Message message) throws HL7Exception { final String encodingCharactersValue = message.getEncodingCharactersValue(); if (encodingCharactersValue == null || encodingCharactersValue.length() == 0) { throw new HL7Exception("encoding characters not populated"); } final Character fieldSeparatorValue = message.getFieldSeparatorValue(); if (fieldSeparatorValue == null) { throw new HL7Exception("Field separator not populated"); } return new EncodingCharacters(fieldSeparatorValue, encodingCharactersValue); }
private Message instantiateACK() throws HL7Exception { ModelClassFactory mcf = getParser() != null ? getParser().getFactory() : new DefaultModelClassFactory(); Version version = Version.versionOf(getVersion()); Message out = null; if (version != null && version.available()) { Class<? extends Message> clazz = mcf.getMessageClass("ACK", version.getVersion(), false); if (clazz != null) { out = ReflectionUtil.instantiateMessage(clazz, mcf); } } if (out == null) { out = new GenericMessage.UnknownVersion(mcf); } if (out instanceof GenericMessage) { if (!ArrayUtil.contains(out.getNames(), "MSA")) { out.addNonstandardSegment("MSA"); } if (!ArrayUtil.contains(out.getNames(), "ERR")) { out.addNonstandardSegment("ERR"); } } return out; }