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


           
            /* Some earlier ACKs don't have ERRs, but I think we'll change this within HAPI
               so that there is a single ACK for each version (with 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

  private void testPrimitiveRules(Message message, ValidationExceptionHandler<R> handler)
      throws HL7Exception {
    LOG.debug("Validating message against primitive type rules");
    for (Iterator<Structure> iter = ReadOnlyMessageIterator
        .createPopulatedSegmentIterator(message); iter.hasNext();) {
      Segment s = (Segment) iter.next();
      for (int field = 1; field <= s.numFields(); field++) {
        Type[] t = s.getField(field);
        for (int rep = 0; rep < t.length; rep++) {
          Location location = new Location();
          location
              .withSegmentName(s.getName())
              .withField(field)
              .withFieldRepetition(rep);
          testType(t[rep], handler, location);
        }
      }
View Full Code Here

   * information, hopefully avoiding the condition that caused the original error.
   * </p>
   */
  public Segment getCriticalResponseData(String message) throws HL7Exception {
    String version = getVersion(message);
    Segment criticalData = Parser.makeControlMSH(version, getFactory());

    Terser.set(criticalData, 1, 0, 1, 1, parseLeaf(message, "MSH.1", 0));
    Terser.set(criticalData, 2, 0, 1, 1, parseLeaf(message, "MSH.2", 0));
    Terser.set(criticalData, 10, 0, 1, 1, parseLeaf(message, "MSH.10", 0));
    String procID = parseLeaf(message, "MSH.11", 0);
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

      if (version == null) {
        Version availableVersion = Version.highestAvailableVersionOrDefault();
        version = availableVersion.getVersion();
      }

      Segment msh = Parser.makeControlMSH(version, getFactory());
      Terser.set(msh, 1, 0, 1, 1, String.valueOf(fieldSep));
      Terser.set(msh, 2, 0, 1, 1, encChars);
      Terser.set(msh, 10, 0, 1, 1, messControlID);
      Terser.set(msh, 11, 0, 1, 1, procIDComps[0]);
      Terser.set(msh, 12, 0, 1, 1, version);
View Full Code Here

        messageIter.setDirection(name);

        try {
          if (messageIter.hasNext()) {
            Segment next = (Segment) messageIter.next();
            parse(next, segments[i], getEncodingChars(string), repNum);
          }
        } catch (Error e) {
          if (e.getCause() instanceof HL7Exception) {
            throw (HL7Exception)e.getCause();
View Full Code Here

    }

    public Location getLocation(Message msg) throws HL7Exception {
      Terser t = new Terser(msg);
      StringTokenizer tok = new StringTokenizer(expression, "-", false);
      Segment segment = t.getSegment(tok.nextToken());
      Location location = new Location()
          .withSegmentName(segment.getName())
          .withFieldIndizes(Terser.getIndices(expression));
      return location;
    }
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.