Package ca.uhn.hl7v2.model

Examples of ca.uhn.hl7v2.model.Segment


     * @return MSH segment for this version returned by the model class factory
     * @throws HL7Exception if no matching segment could be found
   */
  public static Segment makeControlMSH(String version, ModelClassFactory factory)
      throws HL7Exception {
    Segment msh;

    try {
      Class<? extends Message> genericMessageClass;
      genericMessageClass = GenericMessage.getGenericMessageClass(version);
     
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

    }

    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();
      location.setSegmentName(segment.getName());
      location.setFieldIndizes(Terser.getIndices(expression));
      return location;
    }
View Full Code Here

        return ruling;
    }


    private static Transportable makeAcceptAck(Transportable theMessage, String theAckCode, ErrorCode theErrorCode, String theDescription) throws HL7Exception {       
        Segment header = ourParser.getCriticalResponseData(theMessage.getMessage());
        Message dummy = header.getMessage();
        // MSH header refers to dummy, but not the other way round!
        DeepCopy.copy(header, (Segment)dummy.get("MSH"));

        try {
            HL7Exception hl7e = new HL7Exception(theDescription, theErrorCode);
View Full Code Here

        return new String[] {outgoingMessageString, outgoingMessageCharset};
    }

  private String handleProcessMessageException(String incomingMessageString, Map<String, Object> theMetadata, Message incomingMessageObject, Exception e) throws HL7Exception {
    String outgoingMessageString;
    Segment inHeader = incomingMessageObject != null ? (Segment) incomingMessageObject.get("MSH") : null;
    outgoingMessageString = logAndMakeErrorMessage(e, inHeader, myParser, myParser.getEncoding(incomingMessageString));
    if (myExceptionHandler != null) {
      outgoingMessageString = myExceptionHandler.processException(incomingMessageString, theMetadata, outgoingMessageString, e);
    }
    return outgoingMessageString;
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

     * MSH interface.
     * throws HL7Exception if there is a problem, e.g. invalid version, code not available
     *     for given version.
     */
    public static Segment makeControlMSH(String version, ModelClassFactory factory) throws HL7Exception {
        Segment msh = null;
        String className = null;
       
       
        try {
            Message dummy = (Message) GenericMessage.getGenericMessageClass(version)
View Full Code Here

     * message.  This method parses only that required 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

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.