congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
HL7Message
Code IndexAdd Tabnine to your IDE (free)

How to use
HL7Message
in
org.dcm4che3.hl7

Best Java code snippets using org.dcm4che3.hl7.HL7Message (Showing top 14 results out of 315)

origin: dcm4che/dcm4che

  @Override
  public UnparsedHL7Message onMessage(HL7Application hl7App, Connection conn, Socket s, UnparsedHL7Message msg)
          throws HL7Exception {
    return new UnparsedHL7Message(
        HL7Message.makeACK(msg.msh(), HL7Exception.AA, null).getBytes(null));
  }
}
origin: dcm4che/dcm4che

public byte[] getBytes(String defCharset) {
  try {
    return toString().getBytes(HL7Charset.toCharsetName(get(0).getField(17, defCharset)));
  } catch (UnsupportedEncodingException e) {
    throw new RuntimeException(e);
  }
}
origin: dcm4che/dcm4che

public static HL7Message parse(byte[] b, String defCharset) {
  return parse(b, b.length, defCharset);
}
origin: dcm4che/dcm4che

  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");
  }
}
origin: dcm4che/dcm4che

  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;
  }
}
origin: dcm4che/dcm4che

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;
}
origin: dcm4che/dcm4che

public static HL7Message makePixQuery(String pid, String... domains) {
  HL7Segment msh = HL7Segment.makeMSH();
  msh.setField(8, "QBP^Q23^QBP_Q21");
  HL7Segment qpd = new HL7Segment(5);
  qpd.setField(0, "QPD");
  qpd.setField(1, "IHE PIX Query");
  qpd.setField(2, "QRY" + msh.getField(9, ""));
  qpd.setField(3, pid);
  qpd.setField(4, HL7Segment.concat(domains, '~'));
  HL7Segment rcp = new HL7Segment(8);
  rcp.setField(0, "RCP");
  rcp.setField(1, "I");
  HL7Message qbp = new HL7Message(3);
  qbp.add(msh);
  qbp.add(qpd);
  qbp.add(rcp);
  return qbp;
}
origin: dcm4che/dcm4che

@Override
public String toString() {
  return toString('\r');
}
origin: dcm4che/dcm4che

public String toString(char segdelim) {
  int len = size();
  for (HL7Segment seg : this) {
    int segSize = seg.size();
    len += segSize - 1;
    for (int i = 0; i < segSize; i++) {
      String s = seg.getField(i, null);
      if (s != null)
        len += s.length();
    }
  }
  char[] cs = new char[len];
  int off = 0;
  for (HL7Segment seg : this) {
    char delim = seg.getFieldSeparator();
    int segSize = seg.size();
    for (int i = 0; i < segSize; i++) {
      String s = seg.getField(i, null);
      if (s != null) {
        int l = s.length();
        s.getChars(0, l, cs, off);
        off += l;
      }
      cs[off++] = delim;
    }
    cs[off-1] = segdelim;
  }
  return new String(cs);
}
origin: org.dcm4che.tool/dcm4che-tool-hl7pix

  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");
  }
}
origin: dcm4che/dcm4che

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;
}
origin: dcm4che/dcm4che

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));
}
origin: org.dcm4che.tool/dcm4che-tool-hl7rcv

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));
}
origin: dcm4che/dcm4che

  public void run() {
    try {
      s.setSoTimeout(conn.getIdleTimeout());
      MLLPConnection mllp = new MLLPConnection(s);
      byte[] data;
      while ((data = mllp.readMessage()) != null) {
        HL7ConnectionMonitor monitor = hl7dev.getHL7ConnectionMonitor();
        UnparsedHL7Message msg = new UnparsedHL7Message(data);
        if (monitor != null)
          monitor.onMessageReceived(conn, s, msg);
        UnparsedHL7Message rsp;
        try {
          rsp = hl7dev.onMessage(conn, s, msg);
        if (monitor != null)
          monitor.onMessageProcessed(conn, s, msg, rsp, null);
        } catch (HL7Exception e) {
          rsp = new UnparsedHL7Message(
              HL7Message.makeACK(msg.msh(), e).getBytes(null));
          if (monitor != null)
            monitor.onMessageProcessed(conn, s, msg, rsp, e);
        }
        mllp.writeMessage(rsp.data());
      }
    } catch (IOException e) {
      LOG.warn("Exception on accepted connection {}:", s, e);
    } finally {
      conn.close(s);
    }
  }
}
org.dcm4che3.hl7HL7Message

Most used methods

  • getBytes
  • makeACK
  • get
  • <init>
  • add
  • makePixQuery
  • parse
  • size
  • toString
  • trimToSize

Popular in Java

  • Reading from database using SQL prepared statement
  • getContentResolver (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getSharedPreferences (Context)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • JComboBox (javax.swing)
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Top 25 Plugins for Webstorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now