public byte[] readMessage() throws IOException { byte[] b = mllpIn.readMessage(); if (b != null) log("{} >> {}", b, 0, b.length); return b; }
public static HL7Message makeACK(HL7Segment msh, HL7Exception e) { HL7Message ack = makeACK(msh, e.getAcknowledgmentCode(), e.getErrorMessage()); HL7Segment err = e.getErrorSegment(); if (err != null) ack.add(err); return ack; } }
public void query(String pid, String[] domains) throws IOException { HL7Message qbp = HL7Message.makePixQuery(pid, domains); HL7Segment msh = qbp.get(0); msh.setSendingApplicationWithFacility(sendingApplication); msh.setReceivingApplicationWithFacility(receivingApplication); msh.setField(17, charset); mllp.writeMessage(qbp.getBytes(charset)); if (mllp.readMessage() == null) throw new IOException("Connection closed by receiver"); } }
public static HL7Message parse(byte[] b, int size, String defCharset) { ParsePosition pos = new ParsePosition(0); HL7Message msg = new HL7Message(); HL7Segment seg = HL7Segment.parseMSH(b, size, pos); char fieldSeparator = seg.getFieldSeparator(); String encodingCharacters = seg.getEncodingCharacters(); String charsetName = HL7Charset.toCharsetName(seg.getField(17, defCharset)); msg.add(seg); while ((seg = HL7Segment.parse( b, size, pos, fieldSeparator, encodingCharacters, charsetName)) != null) msg.add(seg); msg.trimToSize(); return msg; }
public byte[] getBytes(String defCharset) { try { return toString().getBytes(HL7Charset.toCharsetName(get(0).getField(17, defCharset))); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
public ERRSegment(char fieldSeparator, String encodingCharacters) { super(9, fieldSeparator, encodingCharacters); setField(0, "ERR"); setHL7ErrorCode(ApplicationInternalError); setSeverity("E"); }
private void endElement(Delimiter delimiter) throws SAXException { Delimiter d = Delimiter.escape; do if (open.remove(d = d.parent())) endElement(d.name()); while (d != delimiter); }
private void setDelimiters(String delimiters) { Delimiter[] a = Delimiter.values(); for (int i = 0; i < a.length; i++) addAttribute(a[i].attribute(), delimiters.substring(i,i+1)); this.delimiters = delimiters; }
public void writeMessage(byte[] b, int off, int len) throws IOException { log("{} << {}", b, off, len); mllpOut.writeMessage(b, off, len); }
static HL7Segment parse(byte[] b, int size, ParsePosition pos, char fieldSeparator, String encodingCharacters, String charsetName) { String s = parse(b, size, pos, charsetName); return s != null ? new HL7Segment(s, fieldSeparator, encodingCharacters) : null; }
public HL7Segment(String s, char fieldSeparator, String encodingCharacters) { this.fieldSeparator = fieldSeparator; this.encodingCharacters = encodingCharacters; this.fields = split(s, fieldSeparator); }
public MLLPConnection(Socket sock) throws IOException { this.sock = sock; mllpIn = new MLLPInputStream(sock.getInputStream()); mllpOut = new MLLPOutputStream(sock.getOutputStream()); }
public ERRSegment setUserMessage(String userMessage) { setField(8, userMessage); return this; } }
@Override public void close() throws IOException { mllpConnection.close(); } }
public void query(String pid, String[] domains) throws IOException { HL7Message qbp = HL7Message.makePixQuery(pid, domains); HL7Segment msh = qbp.get(0); msh.setSendingApplicationWithFacility(sendingApplication); msh.setReceivingApplicationWithFacility(receivingApplication); msh.setField(17, charset); mllp.writeMessage(qbp.getBytes(charset)); if (mllp.readMessage() == null) throw new IOException("Connection closed by receiver"); } }
public ERRSegment setHL7ErrorCode(String hl7ErrorCode) { setField(3, hl7ErrorCode); return this; }