@Override public UnparsedHL7Message onMessage(HL7Application hl7App, Connection conn, Socket s, UnparsedHL7Message msg) throws HL7Exception { HL7MessageListener listener = listeners.get(msg.msh().getMessageType()); if (listener == null) { listener = listeners.get("*"); if (listener == null) return super.onMessage(hl7App, conn, s, msg); } return listener.onMessage(hl7App, conn, s, msg); }
private UnparsedHL7Message onMessage(UnparsedHL7Message msg) throws Exception { if (storageDir != null) storeToFile(msg.data(), new File( new File(storageDir, msg.msh().getMessageType()), msg.msh().getField(9, "_NULL_"))); return new UnparsedHL7Message(tpls == null ? HL7Message.makeACK(msg.msh(), HL7Exception.AA, null).getBytes(null) : xslt(msg)); }
private UnparsedHL7Message onMessage(UnparsedHL7Message msg) throws Exception { if (storageDir != null) storeToFile(msg.data(), new File( new File(storageDir, msg.msh().getMessageType()), msg.msh().getField(9, "_NULL_"))); return new UnparsedHL7Message(tpls == null ? HL7Message.makeACK(msg.msh(), HL7Exception.AA, null).getBytes(null) : xslt(msg)); }
UnparsedHL7Message onMessage(Connection conn, Socket s, UnparsedHL7Message msg) throws HL7Exception { HL7Segment msh = msg.msh(); if (!(isInstalled() && conns.contains(conn))) throw new HL7Exception( new ERRSegment(msh) .setHL7ErrorCode(ERRSegment.TableValueNotFound) .setErrorLocation(ERRSegment.UnknownReceivingApplication) .setUserMessage("Receiving Application not recognized")); if (!(acceptedSendingApplications.isEmpty() || acceptedSendingApplications.contains(msh.getSendingApplicationWithFacility()))) throw new HL7Exception( new ERRSegment(msh) .setHL7ErrorCode(ERRSegment.TableValueNotFound) .setErrorLocation(ERRSegment.UnknownSendingApplication) .setUserMessage("Sending Application not recognized")); String messageType = msh.getMessageType(); if (!(acceptedMessageTypes.contains("*") || acceptedMessageTypes.contains(messageType))) throw new HL7Exception( new ERRSegment(msh) .setHL7ErrorCode(unsupportedMessageTypeOrEventCode(messageType.substring(0,3))) .setUserMessage("Message Type not supported")); HL7MessageListener listener = getHL7MessageListener(); if (listener == null) throw new HL7Exception(new ERRSegment(msh) .setHL7ErrorCode(ERRSegment.ApplicationInternalError) .setUserMessage("No HL7 Message Listener configured")); return listener.onMessage(this, conn, s, msg); }
public static HL7Message makeACK(HL7Segment msh, String ackCode, String text) { int size = msh.size(); HL7Segment ackmsh = HL7Segment.makeMSH(size, msh.getFieldSeparator(), msh.getEncodingCharacters()); ackmsh.setField(2, msh.getField(4, null)); ackmsh.setField(3, msh.getField(5, null)); ackmsh.setField(4, msh.getField(2, null)); ackmsh.setField(5, msh.getField(3, null)); ackmsh.setField(8, "ACK^" + msh.getMessageType().substring(4,7) + "^ACK"); for (int i = 10; i < size; i++) ackmsh.setField(i, msh.getField(i, null)); HL7Segment msa = new HL7Segment(4, msh.getFieldSeparator(), msh.getEncodingCharacters()); msa.setField(0, "MSA"); msa.setField(1, ackCode); msa.setField(2, msh.getMessageControlID()); msa.setField(3, text != null && text.length() > 80 ? text.substring(0, 80) : text); HL7Message ack = new HL7Message(2); ack.add(ackmsh); ack.add(msa); return ack; }