Package ca.uhn.hl7v2.model

Examples of ca.uhn.hl7v2.model.Segment


        char fieldSep = mshString.charAt(3);

        // get field array
        String[] fields = split(mshString, String.valueOf(fieldSep));

        Segment msh = null;
        try {
            // parse required fields
            String encChars = fields[1];
            char compSep = encChars.charAt(0);
            String messControlID = fields[9];
View Full Code Here


                log.debug("Parsing segment {}", name);

                messageIter.setDirection(name);

                if (messageIter.hasNext()) {
                    Segment next = (Segment) messageIter.next();
                    int nextIndexWithinParent = messageIter.getNextIndexWithinParent();
                    parse(next, segments[i], getEncodingChars(string), nextIndexWithinParent);
                }
            }
        }
View Full Code Here

     * @throws HL7Exception if the data fields in the message do not permit encoding
     *      (e.g. required fields are null)
     */
    protected String doEncode(Message source) throws HL7Exception {
        //get encoding characters ...
        Segment msh = (Segment) source.get("MSH");
        String fieldSepString = Terser.get(msh, 1, 0, 1, 1);
       
        if (fieldSepString == null)
            throw new HL7Exception("Can't encode message: MSH-1 (field separator) is missing");
       
View Full Code Here

        char fieldSep = mshString.charAt(3);
       
        //get field array
        String[] fields = split(mshString, String.valueOf(fieldSep));
       
        Segment msh = null;
        try {
            //parse required fields
            String encChars = fields[1];
            char compSep = encChars.charAt(0);
            String messControlID = fields[9];
View Full Code Here

       * an ERR).
       */
      // see if it's an HL7Exception (so we can get specific information)
      // ...
      if (e.getClass().equals(HL7Exception.class)) {
        Segment err = (Segment) out.get("ERR");
        // ((HL7Exception) e).populate(err); // FIXME: this is broken,
        // it relies on the database in a place where it's not available
      } else {
        t.set("/ERR-1-4-1", "207");
        t.set("/ERR-1-4-2", "Application Internal Error");
View Full Code Here

     * to respond differently. 
     */
    public void fillDetails(Message ack) throws ApplicationException {
        try {
            //populate MSA and ERR with generic error ...
            Segment msa = (Segment) ack.get("MSA");
            Terser.set(msa, 1, 0, 1, 1, "AR");
            Terser.set(
                msa,
                3,
                0,
                1,
                1,
                "No appropriate destination could be found to which this message could be routed.");
            //this is max length

            //populate ERR segment if it exists (may not depending on version)
            Structure s = ack.get("ERR");
            if (s != null) {
                Segment err = (Segment) s;
                Terser.set(err, 1, 0, 4, 1, "207");
                Terser.set(err, 1, 0, 4, 2, "Application Internal Error");
                Terser.set(err, 1, 0, 4, 3, "HL70357");
            }

View Full Code Here

            throw new HL7Exception("Can't instantiate ACK of class " + ackClassName + ": " + e.getClass().getName());
        }
        Terser terser = new Terser(out);

        //populate outbound MSH using data from inbound message ...            
        Segment outHeader = (Segment) out.get("MSH");
        fillResponseHeader(inboundHeader, outHeader);

        terser.set("/MSH-9", "ACK");
        terser.set("/MSH-12", version);
        terser.set("/MSA-1", "AA");
View Full Code Here

     * @throws HL7Exception
     */
    private Message populateResponseAsOf25(Message response, AcknowledgmentCode acknowledgmentCode,
                                           int repetition) throws HL7Exception {
        // TODO define what should happen if there is no MSA or ERR
        Segment msa = (Segment) response.get("MSA");
        Terser.set(msa, 1, 0, 1, 1, acknowledgmentCode.name());
        Segment err = (Segment) response.get("ERR", repetition);
        if (location != null) {
            if (location.getSegmentName() != null)
                Terser.set(err, 2, 0, 1, 1, location.getSegmentName());
            if (location.getField() > 0)
                Terser.set(err, 2, 0, 3, 1, Integer.toString(location.getField()));
View Full Code Here

     * @throws HL7Exception
     */
    private Message populateResponseBefore25(Message response, AcknowledgmentCode acknowledgmentCode,
                                             int repetition) throws HL7Exception {
        // TODO define what should happen if there is no MSA or ERR
        Segment msa = (Segment) response.get("MSA");
        Terser.set(msa, 1, 0, 1, 1, acknowledgmentCode.name());
        Terser.set(msa, 3, 0, 1, 1, errorCode.getMessage());
        Segment err = (Segment) response.get("ERR");
        if (location != null) {
            if (location.getSegmentName() != null)
                Terser.set(err, 1, repetition, 1, 1, location.getSegmentName());
            if (location.getField() > 0)
                Terser.set(err, 1, repetition, 3, 1, Integer.toString(location.getField()));
View Full Code Here

   *             if the data fields in the message do not permit encoding
   *             (e.g. required fields are null)
   */
  protected String doEncode(Message source) throws HL7Exception {
    // get encoding characters ...
    Segment msh = (Segment) source.get("MSH");
    String fieldSepString = Terser.get(msh, 1, 0, 1, 1);

    if (fieldSepString == null)
      throw new HL7Exception("Can't encode message: MSH-1 (field separator) is missing");

View Full Code Here

TOP

Related Classes of ca.uhn.hl7v2.model.Segment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.