Class ParserConfiguration
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddForcedEncode(String theForcedEncode) Forces the parser to encode certain segments/fields, even if they contain no content.Returns the default datatype ("ST", "NM", etc) for an MFE segment with a missing MFE-5 valueReturns the default datatype ("ST", "NM", etc) for an OBX segment with a missing OBX-2 valueReturns the value provides a default datatype ("ST", "NM", etc) for an MFE segment with an invalid MFE-5 value.Returns the value provides a default datatype ("ST", "NM", etc) for an OBX segment with an invalid OBX-2 value.Returns the behaviour to use when parsing a message and a nonstandard segment is found.booleanIf set totrue(default isfalse) the parser will allow messages to parse, even if they contain a version which is not known to the parser.booleanReturnstrueif empty segments should still be encoded if they are mandatory within their message structure.booleanReturns code>true if subcomponent delimiters in OBX-5 shall be ignored.booleanReturnstrueif the parser should parse in non-greedy mode.booleanIf set totrue(which is the default),XML Parserswill attempt to pretty-print the XML they generate.booleanReturnstrueif the parser validates using a configuredValidationContext.booleanvoidremoveForcedEncode(String theForcedEncode) Removes a forced encode entryvoidsetAllowUnknownVersions(boolean theAllowUnknownVersions) If set totrue(default isfalse) the parser will allow messages to parse, even if they contain a version which is not known to the parser.voidsetDefaultMfe5Type(String theDefaultMfe5Type) If this property is set, the value provides a default datatype ("ST", "NM", etc) for an MFE segment with a missing MFE-5 value.voidsetDefaultObx2Type(String theDefaultObx2Type) If this property is set, the value provides a default datatype ("ST", "NM", etc) for an OBX segment with a missing OBX-2 value.voidsetEncodeEmptyMandatoryFirstSegments(boolean theEncodeEmptyMandatorySegments) If set totrue(default istrue), when encoding a group using the PipeParser where the first segment is required, but no data has been populated in that segment, the empty segment is now still encoded if needed as a blank segment in order to give parsers a hint about which group subsequent segments are in.voidsetEscapeSubcomponentDelimiterInPrimitive(boolean escapeSubcomponentDelimiterInPrimitive) Set totrueif subcomponent delimiters in OBX-5 shall be ignoredvoidsetEscaping(Escaping escaping) Sets an escaping strategyvoidsetIdGenerator(IDGenerator idGenerator) voidsetInvalidMfe5Type(String theInvalidMfe5Type) If this property is set, the value provides a default datatype ("ST", "NM", etc) for an MFE segment with an invalid MFE-5 value.voidsetInvalidObx2Type(String theInvalidObx2Type) If this property is set, the value provides a default datatype ("ST", "NM", etc) for an OBX segment with an invalid OBX-2 value.voidsetNonGreedyMode(boolean theNonGreedyMode) If set totrue(default isfalse), pipe parser will be put in non-greedy mode.voidsetPrettyPrintWhenEncodingXml(boolean thePrettyPrintWhenEncodingXml) If set totrue(which is the default),XML Parserswill attempt to pretty-print the XML they generate.voidsetUnexpectedSegmentBehaviour(UnexpectedSegmentBehaviourEnum theUnexpectedSegmentBehaviour) Sets the behaviour to use when parsing a message and a nonstandard segment is foundvoidsetValidating(boolean validating) Determines whether the parser validates using a configuredValidationContextor not.voidsetXmlDisableWhitespaceTrimmingOnAllNodes(boolean theXmlDisableWhitespaceTrimmingOnAllNodes) Configures the XML Parser to treat all whitespace within text nodes as literal, meaning that line breaks, tabs, multiple spaces, etc.voidsetXmlDisableWhitespaceTrimmingOnNodeNames(String... theKeepAsOriginalNodes) Configures the XML Parser to treat all whitespace within the given nodes as literal, meaning that line breaks, tabs, multiple spaces, etc.voidsetXmlDisableWhitespaceTrimmingOnNodeNames(Set<String> theXmlDisableWhitespaceTrimmingOnNodeNames) Configures the XML Parser to treat all whitespace within the given nodes as literal, meaning that line breaks, tabs, multiple spaces, etc.
-
Field Details
-
DEFAULT_UNEXPECTED_SEGMENT_BEHAVIOUR
-
-
Constructor Details
-
ParserConfiguration
public ParserConfiguration()
-
-
Method Details
-
addForcedEncode
Forces the parser to encode certain segments/fields, even if they contain no content. This method may be called multiple times with multiple path definitions, and each path definition contains the path to the segment or field which needs to be forced.
Path definitions are similar in format to
Terserpaths. They contain a slash-separated lookup path to reach a given segment, and optionally a field number. The following are examples of paths which could be added here, as well as the sample output for an otherwise empty ORU^R01 message:Forced Encode Path Encode Output None (for illustration purposes) MSH|^~\&|||||||ORU^R01^ORU_R01||T|2.4 PATIENT_RESULT/ORDER_OBSERVATION/ORC MSH|^~\&|||||||ORU^R01^ORU_R01||T|2.4
ORC|PATIENT_RESULT/ORDER_OBSERVATION/ORC-4 MSH|^~\&|||||||ORU^R01^ORU_R01||T|2.4
ORC||||PATIENT_RESULT/ORDER_OBSERVATION/ORC-4-2 MSH|^~\&|||||||ORU^R01^ORU_R01||T|2.4
ORC||||^While empty segments do not generally have any meaning according to HL7, this may be useful when transmitting to systems which rely on segments being received even if they have no content.
Note that this configuration item currently only applies to
PipeParser- Parameters:
theForcedEncode- path definition- Since:
- 2.0
-
getDefaultObx2Type
Returns the default datatype ("ST", "NM", etc) for an OBX segment with a missing OBX-2 value- Returns:
- Returns the default datatype ("ST", "NM", etc) for an OBX segment with a missing OBX-2 value
- See Also:
-
getDefaultMfe5Type
Returns the default datatype ("ST", "NM", etc) for an MFE segment with a missing MFE-5 value- Returns:
- Returns the default datatype ("ST", "NM", etc) for an OBX segment with a missing MFE-5 value
- See Also:
-
getForcedEncode
- Returns:
- Returns the forced encode strings added by
addForcedEncode(String) - Since:
- 1.3
- See Also:
-
getIdGenerator
- Returns:
- the ID Generator to be used for generating IDs for new messages
-
getInvalidObx2Type
Returns the value provides a default datatype ("ST", "NM", etc) for an OBX segment with an invalid OBX-2 value.- Returns:
- Returns the value provides a default datatype ("ST", "NM", etc) for an OBX segment with an invalid OBX-2 value.
- See Also:
-
getInvalidMfe5Type
Returns the value provides a default datatype ("ST", "NM", etc) for an MFE segment with an invalid MFE-5 value.- Returns:
- Returns the value provides a default datatype ("ST", "NM", etc) for an MFE segment with an invalid MFE-5 value.
- See Also:
-
getUnexpectedSegmentBehaviour
Returns the behaviour to use when parsing a message and a nonstandard segment is found. Default isDEFAULT_UNEXPECTED_SEGMENT_BEHAVIOUR- Returns:
- the behaviour to use when a nonstandard egment is found
-
getXmlDisableWhitespaceTrimmingOnNodeNames
-
isAllowUnknownVersions
If set totrue(default isfalse) the parser will allow messages to parse, even if they contain a version which is not known to the parser. When operating in this mode, if a message arrives with an unknown version string, the parser will attempt to parse it using aGeneric Messageclass instead of a specific HAPI structure class. Default isfalse.- Returns:
- true if parsing messages with unknown versions is allowed
-
isEncodeEmptyMandatorySegments
Returnstrueif empty segments should still be encoded if they are mandatory within their message structure. Default isfalse.- Returns:
trueif empty segments should still be encoded- See Also:
-
isEscapeSubcomponentDelimiterInPrimitive
Returns code>true if subcomponent delimiters in OBX-5 shall be ignored. Default isfalse.- Returns:
trueif subcomponent delimiters in OBX-5 shall be ignored
-
isNonGreedyMode
Returnstrueif the parser should parse in non-greedy mode. Default isfalse- See Also:
-
isPrettyPrintWhenEncodingXml
If set totrue(which is the default),XML Parserswill attempt to pretty-print the XML they generate. This means the messages will look nicer to humans, but may take up slightly more space/bandwidth. -
isValidating
- Returns:
trueif the parser validates using a configuredValidationContext
-
isXmlDisableWhitespaceTrimmingOnAllNodes
-
removeForcedEncode
Removes a forced encode entry- Parameters:
theForcedEncode- path definition to be removed- Since:
- 1.3
- See Also:
-
setAllowUnknownVersions
If set totrue(default isfalse) the parser will allow messages to parse, even if they contain a version which is not known to the parser. When operating in this mode, if a message arrives with an unknown version string, the parser will attempt to parse it using aGeneric Messageclass instead of a specific HAPI structure class.- Parameters:
theAllowUnknownVersions- true if parsing unknown versions shall be allowed
-
setDefaultObx2Type
If this property is set, the value provides a default datatype ("ST", "NM", etc) for an OBX segment with a missing OBX-2 value. This is useful when parsing messages from systems which do not correctly populate OBX-2.
For example, if this property is set to "ST", and the following OBX segment is encountered:
OBX|||||This is a value
It will be parsed as though it had read:OBX||ST|||This is a value
Note that this configuration can also be set globally using the system property
FixFieldDataType.DEFAULT_OBX2_TYPE_PROP, but any value provided toParserConfigurationtakes priority over the system property.- Parameters:
theDefaultObx2Type- If this property is set, the value provides a default datatype ("ST", "NM", etc) for an OBX segment with a missing OBX-2 value- See Also:
-
setDefaultMfe5Type
If this property is set, the value provides a default datatype ("ST", "NM", etc) for an MFE segment with a missing MFE-5 value. This is useful when parsing messages from systems which do not correctly populate MFE-5.
For example, if this property is set to "ST", and the following MFE segment is encountered:
MFE||||This is a value
It will be parsed as though it had read:MFE||||This is a value|ST
Note that this configuration can also be set globally using the system property
FixFieldDataType.DEFAULT_MFE5_TYPE_PROP, but any value provided toParserConfigurationtakes priority over the system property.- Parameters:
theDefaultMfe5Type- If this property is set, the value provides a default datatype ("ST", "NM", etc) for an MFE segment with a missing MFE-5 value- See Also:
-
setEncodeEmptyMandatoryFirstSegments
If set to
true(default istrue), when encoding a group using the PipeParser where the first segment is required, but no data has been populated in that segment, the empty segment is now still encoded if needed as a blank segment in order to give parsers a hint about which group subsequent segments are in. This helps to ensure that messages can be "round tripped", meaning that a message which is parsed, encoded, and then re-parsed should contain exactly the same structure from beginning to end.
For example, in an ORU^R01 message with a populated OBX segment, but no data in the mandatory OBR segment which begins the ORDER_OBSERVATION group the message would still contain an empty OBR segment when encoded:MSH|^~\&|REG|W|||201103230042||ORU^R01|32153168|P|2.5 OBR| OBX||ST|||Value DataPreviously, the following encoding would have occurred, which would have incorrectly been parsed as having a custom OBX segment instead of having a normal ORDER_OBSERVATION group:MSH|^~\&|REG|W|||201103230042||ORU^R01|32153168|P|2.5 OBX||ST|||Value Data- Parameters:
theEncodeEmptyMandatorySegments- If set totrue(default istrue), when encoding a group using the PipeParser where the first segment is required, but no data has been populated in that segment, the empty segment is now still encoded if needed as a blank segment in order to give parsers a hint about which group subsequent segments are in
-
setEscapeSubcomponentDelimiterInPrimitive
public void setEscapeSubcomponentDelimiterInPrimitive(boolean escapeSubcomponentDelimiterInPrimitive) Set totrueif subcomponent delimiters in OBX-5 shall be ignored- Parameters:
escapeSubcomponentDelimiterInPrimitive- boolean flag to enable or disable this behavior
-
setIdGenerator
- Parameters:
idGenerator- theIDGeneratorto be used for generating IDs for new messages, preferable initialized using the methods described in IDGeneratorFactory.- See Also:
-
setInvalidObx2Type
If this property is set, the value provides a default datatype ("ST", "NM", etc) for an OBX segment with an invalid OBX-2 value. This is useful when parsing messages from systems which do not correctly populate OBX-2.
For example, if this property is set to "ST", and the following OBX segment is encountered:
OBX||INVALID|||This is a value
It will be parsed as though it had read:OBX||ST|||This is a value
Note that this configuration can also be set globally using the system property
FixFieldDataType.INVALID_OBX2_TYPE_PROP, but any value provided toParserConfigurationtakes priority over the system property.- Parameters:
theInvalidObx2Type- If this property is set, the value provides a default datatype ("ST", "NM", etc) for an OBX segment with an invalid OBX-2 value. This is useful when parsing messages from systems which do not correctly populate OBX-2.- See Also:
-
setInvalidMfe5Type
If this property is set, the value provides a default datatype ("ST", "NM", etc) for an MFE segment with an invalid MFE-5 value. This is useful when parsing messages from systems which do not correctly populate MFE-5.
For example, if this property is set to "ST", and the following MFE segment is encountered:
MFE||||This is a value|INVALID
It will be parsed as though it had read:MFE||||This is a value|ST
Note that this configuration can also be set globally using the system property
FixFieldDataType.INVALID_MFE5_TYPE_PROP, but any value provided toParserConfigurationtakes priority over the system property.- Parameters:
theInvalidMfe5Type- If this property is set, the value provides a default datatype ("ST", "NM", etc) for an MFE segment with an invalid MFE-5 value. This is useful when parsing messages from systems which do not correctly populate MFE-5.- See Also:
-
setNonGreedyMode
If set totrue(default isfalse), pipe parser will be put in non-greedy mode. This setting applies only toPipe Parsersand will have no effect onXML Parsers.In non-greedy mode, if the message structure being parsed has an ambiguous choice of where to put a segment because there is a segment matching the current segment name in both a later position in the message, and in an earlier position as a part of a repeating group, the earlier position will be chosen.
This is perhaps best explained with an example. Consider the following structure:
MSH GROUP_1 (start) { AAA BBB GROUP_2 (start) { AAA } GROUP_2 (end) } GROUP_1 (end)
For the above example, consider a message containing the following segments:
MSH
AAA
BBB
AAAIn this example, when the second AAA segment is encountered, there are two possible choices. It would be placed in GROUP_2, or it could be placed in a second repetition of GROUP_1. By default it will be placed in GROUP_2, but in non-greedy mode it will be put in a new repetition of GROUP_1.
This mode is useful for example when parsing OML^O21 messages containing multiple orders.
-
setPrettyPrintWhenEncodingXml
If set totrue(which is the default),XML Parserswill attempt to pretty-print the XML they generate. This means the messages will look nicer to humans, but may take up slightly more space/bandwidth. -
setUnexpectedSegmentBehaviour
public void setUnexpectedSegmentBehaviour(UnexpectedSegmentBehaviourEnum theUnexpectedSegmentBehaviour) Sets the behaviour to use when parsing a message and a nonstandard segment is found- Parameters:
theUnexpectedSegmentBehaviour- behaviour to use when a nonstandard segment is found
-
setValidating
Determines whether the parser validates using a configuredValidationContextor not. This allows to disable message validation although a validation context is defined.- Parameters:
validating-trueif parser shall validate,falseif not
-
getEscaping
-
setEscaping
Sets an escaping strategy- Parameters:
escaping- escaping strategy instance
-
setXmlDisableWhitespaceTrimmingOnAllNodes
public void setXmlDisableWhitespaceTrimmingOnAllNodes(boolean theXmlDisableWhitespaceTrimmingOnAllNodes) Configures the XML Parser to treat all whitespace within text nodes as literal, meaning that line breaks, tabs, multiple spaces, etc. will be preserved. If set totrue, any values passed tosetXmlDisableWhitespaceTrimmingOnNodeNames(Set)will be superceded since all whitespace will be treated as literal.Default is false
-
setXmlDisableWhitespaceTrimmingOnNodeNames
public void setXmlDisableWhitespaceTrimmingOnNodeNames(Set<String> theXmlDisableWhitespaceTrimmingOnNodeNames) Configures the XML Parser to treat all whitespace within the given nodes as literal, meaning that line breaks, tabs, multiple spaces, etc. will be preserved. This method takes individual XML node names as arguments (e.g. "HD.2", or "TX.1").Default is none
-
setXmlDisableWhitespaceTrimmingOnNodeNames
Configures the XML Parser to treat all whitespace within the given nodes as literal, meaning that line breaks, tabs, multiple spaces, etc. will be preserved. This method takes individual XML node names as arguments (e.g. "HD.2", or "TX.1").Default is none
-