Class Hl7Util
- java.lang.Object
-
- org.apache.camel.component.mllp.internal.Hl7Util
-
public final class Hl7Util extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static Map<Character,String>CHARACTER_REPLACEMENTSstatic StringEMPTY_REPLACEMENT_VALUEstatic StringNULL_REPLACEMENT_VALUEstatic SimpleDateFormatTIMESTAMP_FORMAT
-
Constructor Summary
Constructors Constructor Description Hl7Util(int logPhiMaxBytes, boolean logPhi)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendBytesAsPrintFriendlyString(StringBuilder builder, byte[] phiBytes)voidappendBytesAsPrintFriendlyString(StringBuilder builder, byte[] phiBytes, int startPosition, int endPosition)Append a PHI byte[] to a StringBuilder, replacing specific non-printable characters with readable strings.StringBuilderbytesToPrintFriendlyStringBuilder(byte[] phiBytes)Convert a PHI byte[] to a StringBuilder, replacing specific non-printable characters with readable strings.StringBuilderbytesToPrintFriendlyStringBuilder(byte[] phiBytes, int startPosition, int endPosition)Convert a PHI byte[] to a StringBuilder, replacing specific non-printable characters with readable strings.StringconvertToPrintFriendlyString(byte[] phiBytes)StringconvertToPrintFriendlyString(byte[] phiBytes, int startPosition, int endPosition)Convert a PHI byte[] to a String, replacing specific non-printable characters with readable strings.StringconvertToPrintFriendlyString(String phiString)static List<Integer>findFieldSeparatorIndicesInSegment(byte[] hl7MessageBytes, int startingIndex)Find the field separator indices in the Segment.StringfindMsh18(byte[] hl7Message, Charset charset)Find the String value of MSH-18 (Character set).voidgenerateAcknowledgementPayload(MllpSocketBuffer mllpSocketBuffer, byte[] hl7MessageBytes, String acknowledgementCode)voidgenerateAcknowledgementPayload(MllpSocketBuffer mllpSocketBuffer, byte[] hl7MessageBytes, String acknowledgementCode, String msa3)StringgenerateInvalidPayloadExceptionMessage(byte[] hl7Bytes)static StringgenerateInvalidPayloadExceptionMessage(byte[] hl7Bytes, int length)Verifies that the HL7 payload arraystatic StringgetCharacterAsPrintFriendlyString(char c)intgetLogPhiMaxBytes()
-
-
-
Field Detail
-
NULL_REPLACEMENT_VALUE
public static final String NULL_REPLACEMENT_VALUE
- See Also:
- Constant Field Values
-
EMPTY_REPLACEMENT_VALUE
public static final String EMPTY_REPLACEMENT_VALUE
- See Also:
- Constant Field Values
-
TIMESTAMP_FORMAT
public static final SimpleDateFormat TIMESTAMP_FORMAT
-
-
Method Detail
-
getLogPhiMaxBytes
public int getLogPhiMaxBytes()
-
generateInvalidPayloadExceptionMessage
public String generateInvalidPayloadExceptionMessage(byte[] hl7Bytes)
-
generateInvalidPayloadExceptionMessage
public static String generateInvalidPayloadExceptionMessage(byte[] hl7Bytes, int length)
Verifies that the HL7 payload arrayThe 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 messagestartingIndex- 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
-
generateAcknowledgementPayload
public void generateAcknowledgementPayload(MllpSocketBuffer mllpSocketBuffer, byte[] hl7MessageBytes, String acknowledgementCode, String msa3) throws MllpAcknowledgementGenerationException
-
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 logstartPosition- the starting position/index of the dataendPosition- 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 logstartPosition- the starting position/index of the dataendPosition- 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 logstartPosition- the starting position/index of the dataendPosition- the ending position/index of the data - will not be included in String
-
getCharacterAsPrintFriendlyString
public static String getCharacterAsPrintFriendlyString(char c)
-
-