java.lang.Object
org.apache.camel.component.mllp.internal.Hl7Util

public final class Hl7Util extends Object
  • Field Details

  • Constructor Details

    • Hl7Util

      public Hl7Util(int logPhiMaxBytes, boolean logPhi)
  • Method Details

    • getLogPhiMaxBytes

      public int getLogPhiMaxBytes()
    • generateInvalidPayloadExceptionMessage

      public String generateInvalidPayloadExceptionMessage(byte[] hl7Bytes)
    • generateInvalidPayloadExceptionMessage

      public static String generateInvalidPayloadExceptionMessage(byte[] hl7Bytes, int length)
      Verifies that the HL7 payload array

      The MLLP protocol does not allow embedded START_OF_BLOCK or END_OF_BLOCK characters. The END_OF_DATA character is allowed (and expected) because it is also the segment delimiter for an HL7 message

      Parameters:
      hl7Bytes - the HL7 payload to validate
      Returns:
      If the payload is invalid, an error message suitable for inclusion in an exception is returned. If the payload is valid, null is returned;
    • findFieldSeparatorIndicesInSegment

      public static List<Integer> findFieldSeparatorIndicesInSegment(byte[] hl7MessageBytes, int startingIndex)
      Find the field separator indices in the Segment. NOTE: The last element of the list will be the index of the end of the segment.
      Parameters:
      hl7MessageBytes - the HL7 binary message
      startingIndex - index of the beginning of the HL7 Segment
      Returns:
      List of the field separator indices, which may be empty.
    • findMsh18

      public String findMsh18(byte[] hl7Message, Charset charset)
      Find the String value of MSH-18 (Character set).
      Parameters:
      hl7Message - the HL7 binary data to search
      Returns:
      the String value of MSH-18, or an empty String if not found.
    • generateAcknowledgementPayload

      public void generateAcknowledgementPayload(MllpSocketBuffer mllpSocketBuffer, byte[] hl7MessageBytes, String acknowledgementCode) throws MllpAcknowledgementGenerationException
      Throws:
      MllpAcknowledgementGenerationException
    • generateAcknowledgementPayload

      public void generateAcknowledgementPayload(MllpSocketBuffer mllpSocketBuffer, byte[] hl7MessageBytes, String acknowledgementCode, String msa3) throws MllpAcknowledgementGenerationException
      Throws:
      MllpAcknowledgementGenerationException
    • convertToPrintFriendlyString

      public String convertToPrintFriendlyString(String phiString)
    • convertToPrintFriendlyString

      public String convertToPrintFriendlyString(byte[] phiBytes)
    • convertToPrintFriendlyString

      public String convertToPrintFriendlyString(byte[] phiBytes, int startPosition, int endPosition)
      Convert a PHI byte[] to a String, replacing specific non-printable characters with readable strings. NOTE: this conversion uses the default character set, so not all characters my convert correctly.
      Parameters:
      phiBytes - the PHI byte[] to log
      startPosition - the starting position/index of the data
      endPosition - the ending position/index of the data - will not be included in String
      Returns:
      a String representation of the byte[]
    • bytesToPrintFriendlyStringBuilder

      public StringBuilder bytesToPrintFriendlyStringBuilder(byte[] phiBytes)
      Convert a PHI byte[] to a StringBuilder, replacing specific non-printable characters with readable strings. NOTE: this conversion uses the default character set, so not all characters my convert correctly.
      Parameters:
      phiBytes - the PHI byte[] to log
      Returns:
    • bytesToPrintFriendlyStringBuilder

      public StringBuilder bytesToPrintFriendlyStringBuilder(byte[] phiBytes, int startPosition, int endPosition)
      Convert a PHI byte[] to a StringBuilder, replacing specific non-printable characters with readable strings. NOTE: this conversion uses the default character set, so not all characters my convert correctly.
      Parameters:
      phiBytes - the PHI byte[] to log
      startPosition - the starting position/index of the data
      endPosition - the ending position/index of the data - will not be included in StringBuilder
      Returns:
      a String representation of the byte[]
    • appendBytesAsPrintFriendlyString

      public void appendBytesAsPrintFriendlyString(StringBuilder builder, byte[] phiBytes)
    • appendBytesAsPrintFriendlyString

      public void appendBytesAsPrintFriendlyString(StringBuilder builder, byte[] phiBytes, int startPosition, int endPosition)
      Append a PHI byte[] to a StringBuilder, replacing specific non-printable characters with readable strings. NOTE: this conversion uses the default character set, so not all characters my convert correctly.
      Parameters:
      phiBytes - the PHI byte[] to log
      startPosition - the starting position/index of the data
      endPosition - the ending position/index of the data - will not be included in String
    • getCharacterAsPrintFriendlyString

      public static String getCharacterAsPrintFriendlyString(char c)