ca.uhn.hl7v2.parser
Class ParserConfiguration

java.lang.Object
  extended by ca.uhn.hl7v2.parser.ParserConfiguration

public class ParserConfiguration
extends Object


Constructor Summary
ParserConfiguration()
           
 
Method Summary
 void addForcedEncode(String theForcedEncode)
           Forces the parser to encode certain segments/fields, even if they contain no content.
 String getDefaultObx2Type()
          Returns the default datatype ("ST", "NM", etc) for an OBX segment with a missing OBX-2 value
 Set<String> getForcedEncode()
           
 String getInvalidObx2Type()
          Returns the value provides a default datatype ("ST", "NM", etc) for an OBX segment with an invalid OBX-2 value.
 boolean isEncodeEmptyMandatorySegments()
           
 void removeForcedEncode(String theForcedEncode)
          Removes a forced encode entry
 void setDefaultObx2Type(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.
 void setEncodeEmptyMandatoryFirstSegments(boolean theEncodeEmptyMandatorySegments)
           If set to true (default is true), 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.
 void setInvalidObx2Type(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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParserConfiguration

public ParserConfiguration()
Method Detail

addForcedEncode

public void addForcedEncode(String theForcedEncode)

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 Terser paths. 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

Since:
1.3

removeForcedEncode

public void removeForcedEncode(String theForcedEncode)
Removes a forced encode entry

Since:
1.3
See Also:
addForcedEncode(String)

getDefaultObx2Type

public String 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:
setDefaultObx2Type(String)

getForcedEncode

public Set<String> getForcedEncode()
Returns:
Returns the forced encode strings added by addForcedEncode(String)
Since:
1.3
See Also:
addForcedEncode(String)

isEncodeEmptyMandatorySegments

public boolean isEncodeEmptyMandatorySegments()
Returns:
Returns true if empty segments should still be encoded if they are mandatory within their message structure.
See Also:
setEncodeEmptyMandatoryFirstSegments(boolean)

getInvalidObx2Type

public String 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:
setInvalidObx2Type(String)

setDefaultObx2Type

public void setDefaultObx2Type(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. 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 Varies.DEFAULT_OBX2_TYPE_PROP, but any value provided to ParserConfiguration takes 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:
setInvalidObx2Type(String), Varies.INVALID_OBX2_TYPE_PROP

setEncodeEmptyMandatoryFirstSegments

public void setEncodeEmptyMandatoryFirstSegments(boolean theEncodeEmptyMandatorySegments)

If set to true (default is true), 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 Data
 
Previously, 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 to true (default is true), 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

setInvalidObx2Type

public void setInvalidObx2Type(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. 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 Varies.INVALID_OBX2_TYPE_PROP, but any value provided to ParserConfiguration takes 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 an invalid OBX-2 value. This is useful when parsing messages from systems which do not correctly populate OBX-2.
See Also:
setDefaultObx2Type(String), Varies.DEFAULT_OBX2_TYPE_PROP


Copyright © 2001-2012 University Health Network. All Rights Reserved.