Tabnine Logo
Message.get
Code IndexAdd Tabnine to your IDE (free)

How to use
get
method
in
ca.uhn.hl7v2.model.Message

Best Java code snippets using ca.uhn.hl7v2.model.Message.get (Showing top 20 results out of 315)

origin: pentaho/pentaho-kettle

parser.setValidationContext( validationContext );
Message msg = parser.parse( message );
Structure structure = msg.get( "MSH" );
String messageType = null;
String version = msg.getVersion();
origin: ca.uhn.hapi/hapi-base

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 (outgoingMessageString != null && myExceptionHandler != null) {
    outgoingMessageString = myExceptionHandler.processException(incomingMessageString, theMetadata, outgoingMessageString, e);
  }
  return outgoingMessageString;
}
origin: ca.uhn.hapi/hapi-osgi-base

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 (outgoingMessageString != null && myExceptionHandler != null) {
    outgoingMessageString = myExceptionHandler.processException(incomingMessageString, theMetadata, outgoingMessageString, e);
  }
  return outgoingMessageString;
}
origin: ca.uhn.hapi/hapi-examples

/**
 * {@inheritDoc}
 */
public Message processMessage(Message theIn) throws ApplicationException, HL7Exception {
  String encodedMessage = new PipeParser().encode(theIn);
  System.out.println("Received message:\n" + encodedMessage + "\n\n");
  // Now we need to generate a message to return. This will generally be an ACK message.
  MSH msh = (MSH)theIn.get("MSH");
  ACK retVal;
  try {
    // This method takes in the MSH segment of an incoming message, and generates an
    // appropriate ACK
    retVal = (ACK)DefaultApplication.makeACK(msh);
  } catch (IOException e) {
    throw new HL7Exception(e);
  }
  return retVal;
}
origin: ca.uhn.hapi/hapi-base

/**
 * @deprecated use {@link Message#generateACK()}
 */
public static Message makeACK(Segment inboundHeader) throws HL7Exception,
    IOException {
  // Make sure that the referenced message is not just a dummy
  DeepCopy.copy(inboundHeader, (Segment)inboundHeader.getMessage().get("MSH"));
  return inboundHeader.getMessage().generateACK();
}
origin: ca.uhn.hapi/hapi-osgi-base

/**
 * @deprecated use {@link Message#generateACK()}
 */
public static Message makeACK(Segment inboundHeader) throws HL7Exception,
    IOException {
  // Make sure that the referenced message is not just a dummy
  DeepCopy.copy(inboundHeader, (Segment)inboundHeader.getMessage().get("MSH"));
  return inboundHeader.getMessage().generateACK();
}
origin: ca.uhn.hapi/hapi-osgi-base

/**
 * Formats a Message object into an HL7 message string using this parser's
 * default encoding ("VB").
 * 
 * @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");
  char fieldSep = '|';
  if (fieldSepString.length() > 0) fieldSep = fieldSepString.charAt(0);
  EncodingCharacters en = getValidEncodingCharacters(fieldSep, msh);
  // pass down to group encoding method which will operate recursively on
  // children ...
  return encode(source, en, getParserConfiguration(), "");
}
origin: ca.uhn.hapi/hapi-base

/**
 * Formats a Message object into an HL7 message string using this parser's
 * default encoding ("VB").
 * 
 * @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");
  char fieldSep = '|';
  if (fieldSepString.length() > 0) fieldSep = fieldSepString.charAt(0);
  EncodingCharacters en = getValidEncodingCharacters(fieldSep, msh);
  // pass down to group encoding method which will operate recursively on
  // children ...
  return encode(source, en, getParserConfiguration(), "");
}
origin: ca.uhn.hapi/hapi-base

Segment msh = (Segment) source.get("MSH");
String fieldSepString = Terser.get(msh, 1, 0, 1, 1);
origin: ca.uhn.hapi/hapi-osgi-base

Segment msh = (Segment) source.get("MSH");
String fieldSepString = Terser.get(msh, 1, 0, 1, 1);
origin: ca.uhn.hapi/hapi-osgi-base

private Message getInMessage(Segment inHeader) throws HL7Exception, IOException {
  Message in;
  if (inHeader != null) {
    in = inHeader.getMessage();
    // the message may be a dummy message, whose MSH segment is incomplete
    DeepCopy.copy(inHeader, (Segment) in.get("MSH"));
  } else {
    in = Version.highestAvailableVersionOrDefault().newGenericMessage(myParser.getFactory());
    ((GenericMessage) in).initQuickstart("ACK", "", "");
  }
  return in;
}
origin: ca.uhn.hapi/hapi-base

private Message getInMessage(Segment inHeader) throws HL7Exception, IOException {
  Message in;
  if (inHeader != null) {
    in = inHeader.getMessage();
    // the message may be a dummy message, whose MSH segment is incomplete
    DeepCopy.copy(inHeader, (Segment) in.get("MSH"));
  } else {
    in = Version.highestAvailableVersionOrDefault().newGenericMessage(myParser.getFactory());
    ((GenericMessage) in).initQuickstart("ACK", "", "");
  }
  return in;
}
origin: org.openehealth.ipf.commons/ipf-commons-ihe-hl7v2

public Message createNak0(Message originalMessage, HL7Exception e, AcknowledgmentCode ackTypeCode)
  throws HL7Exception {
  AbstractMessage ack = (AbstractMessage) MessageUtils.response(
      originalMessage,
      messageType,
      triggerEvent);
  LOG.info("Creating NAK response event of type {}", ack.getClass().getName());
  e.populateResponse(ack, ackTypeCode, 0);
  Segment msa = (Segment) ack.get("MSA");
  Terser.set(msa, 1, 0, 1, 1, ackTypeCode.name());
  Segment ackQak = (Segment) ack.get("QAK");
  Segment origQpd = (Segment) originalMessage.get("QPD");
  if (origQpd != null) {
    String queryTag = Terser.get(origQpd, 2, 0, 1, 1);
    Terser.set(ackQak, 1, 0, 1, 1, queryTag);
    LOG.debug("Set QAK-1 to {}", queryTag);
  }
  Terser.set(ackQak, 2, 0, 1, 1, "AE");
  // create a dummy QPD segment, it will be replaced with proper contents by
  // org.openehealth.ipf.platform.camel.ihe.hl7v2.intercept.consumer.ConsumerSegmentEchoingInterceptor
  Segment ackQpd = (Segment) ack.get("QPD");
  Terser.set(ackQpd, 1, 0, 1, 1, "dummy");
  return ack;
}
origin: ca.uhn.hapi/hapi-base

/**
 * Fill segments for HL7 versions before 2.5.
 * <p/>
 * HL7 versions before 2.5 require to set MSA-1 and MSA-3. The ERR segment only has one
 * repeatable field (ERR-1) with components containing details about the exception.
 *
 * @param response           the raw response message
 * @param acknowledgmentCode acknowledgment code
 * @param repetition         repetition of the ERR segment that shall be popualted
 * @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()));
  }
  Terser.set(err, 1, repetition, 4, 1, Integer.toString(errorCode.getCode()));
  Terser.set(err, 1, repetition, 4, 2, errorCode.getMessage());
  Terser.set(err, 1, repetition, 4, 3, ErrorCode.codeTable());
  Terser.set(err, 1, repetition, 4, 5, getMessage());
  return response;
}
origin: ca.uhn.hapi/hapi-osgi-base

/**
 * Fill segments for HL7 versions before 2.5.
 * <p/>
 * HL7 versions before 2.5 require to set MSA-1 and MSA-3. The ERR segment only has one
 * repeatable field (ERR-1) with components containing details about the exception.
 *
 * @param response           the raw response message
 * @param acknowledgmentCode acknowledgment code
 * @param repetition         repetition of the ERR segment that shall be popualted
 * @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()));
  }
  Terser.set(err, 1, repetition, 4, 1, Integer.toString(errorCode.getCode()));
  Terser.set(err, 1, repetition, 4, 2, errorCode.getMessage());
  Terser.set(err, 1, repetition, 4, 3, ErrorCode.codeTable());
  Terser.set(err, 1, repetition, 4, 5, getMessage());
  return response;
}
origin: org.openehealth.ipf.commons/ipf-commons-ihe-hl7v2

/**
 * Performs acceptance test of the given message.
 *
 * @param message   HAPI {@link Message} object.
 * @param isRequest <code>true</code> iff the message is a request.
 * @throws Hl7v2AcceptanceException when the message is not acceptable.
 */
public void checkMessageAcceptance(
    Message message,
    boolean isRequest) throws Hl7v2AcceptanceException {
  try {
    Segment msh = (Segment) message.get("MSH");
    checkMessageAcceptance(
        Terser.get(msh, 9, 0, 1, 1),
        Terser.get(msh, 9, 0, 2, 1),
        Terser.get(msh, 9, 0, 3, 1),
        Terser.get(msh, 12, 0, 1, 1),
        isRequest);
  } catch (Hl7v2AcceptanceException e) {
    throw e;
  } catch (HL7Exception e) {
    throw new Hl7v2AcceptanceException("Missing or invalid MSH segment: " + e.getMessage(), ErrorCode.APPLICATION_INTERNAL_ERROR);
  }
}
origin: ca.uhn.hapi/hapi-base

/**
 * Generates an empty response message. This class generates an
 * ACKnowledgement using the code returned by {@link #getSuccessAcknowledgementCode()}.
 * 
 * @param request request message, either a {@link String} or a
 *            {@link Message}
 * @return acknowledgment to the request
 * @throws HL7Exception
 */
protected Message generateResponseMessage(Object request) throws HL7Exception {
  try {
    Message in;
    if (request instanceof String) {
      Segment s = getHapiContext().getGenericParser().getCriticalResponseData(
          (String)request);
      in = s.getMessage();
      DeepCopy.copy(s, (Segment) in.get("MSH"));
    } else if (request instanceof Message) {
      in = (Message) request;
    } else {
      throw new HL7Exception("Validated message must be either Message or String");
    }
    return in.generateACK(getSuccessAcknowledgementCode(), null);
  } catch (IOException e) {
    throw new HL7Exception(e);
  }
}
origin: ca.uhn.hapi/hapi-osgi-base

/**
 * Generates an empty response message. This class generates an
 * ACKnowledgement using the code returned by {@link #getSuccessAcknowledgementCode()}.
 * 
 * @param request request message, either a {@link String} or a
 *            {@link Message}
 * @return acknowledgment to the request
 * @throws HL7Exception
 */
protected Message generateResponseMessage(Object request) throws HL7Exception {
  try {
    Message in;
    if (request instanceof String) {
      Segment s = getHapiContext().getGenericParser().getCriticalResponseData(
          (String)request);
      in = s.getMessage();
      DeepCopy.copy(s, (Segment) in.get("MSH"));
    } else if (request instanceof Message) {
      in = (Message) request;
    } else {
      throw new HL7Exception("Validated message must be either Message or String");
    }
    return in.generateACK(getSuccessAcknowledgementCode(), null);
  } catch (IOException e) {
    throw new HL7Exception(e);
  }
}
origin: ca.uhn.hapi/hapi-base

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);
    AcknowledgmentCode code = theAckCode == null ?
        AcknowledgmentCode.CR :
        AcknowledgmentCode.valueOf(theAckCode);
    Message out = dummy.generateACK(code, hl7e);
    String originalEncoding = ourParser.getEncoding(theMessage.getMessage());
    String ackText = ourParser.encode(out, originalEncoding);
    return new TransportableImpl(ackText);
  } catch (IOException e) {
    throw new HL7Exception(e);
  }
  
}    

origin: ca.uhn.hapi/hapi-osgi-base

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);
    AcknowledgmentCode code = theAckCode == null ?
        AcknowledgmentCode.CR :
        AcknowledgmentCode.valueOf(theAckCode);
    Message out = dummy.generateACK(code, hl7e);
    String originalEncoding = ourParser.getEncoding(theMessage.getMessage());
    String ackText = ourParser.encode(out, originalEncoding);
    return new TransportableImpl(ackText);
  } catch (IOException e) {
    throw new HL7Exception(e);
  }
  
}    

ca.uhn.hl7v2.modelMessageget

Javadoc

Convenience method which retrieves the encoding characters value from the second field of the first segment. Typically, the first segment is MSH, so this method will retrieve the value of MSH-2.

Popular methods of Message

  • getVersion
    Returns the version number of the HL7 version in which this message structure is defined (e.g. "2.4"
  • generateACK
    Generates and returns an ACK message which would be used to acknowledge this message successfully.
  • encode
    Encodes this message using the parser returned by #getParser()
  • getName
  • getParser
    Returns the parser to be used when parse/encode methods are called on this Message, as well as its c
  • addNonstandardSegment
  • getEncodingCharactersValue
    Convenience method which retrieves the encoding characters value from the second field of the first
  • getFieldSeparatorValue
    Convenience method which retrieves the field separator value from the first field of the first segme
  • getNames
  • parse
    Parses the string into this message using the parser returned by #getParser()
  • printStructure
    Prints a summary of the contents and structure of this message. This is useful for debugging purpos
  • setParser
    Sets the parser to be used when parse/encode methods are called on this Message, as well as its chil
  • printStructure,
  • setParser

Popular in Java

  • Reactive rest calls using spring rest template
  • onCreateOptionsMenu (Activity)
  • addToBackStack (FragmentTransaction)
  • getContentResolver (Context)
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Join (org.hibernate.mapping)
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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