public class Varies extends Object implements Variable
Varies is a Type used as a placeholder for another Type in cases where the appropriate Type is not known until run-time (e.g. OBX-5). Parsers and validators may have logic that enforces restrictions on the Type based on other features of a segment.
If you want to set both the type and the values of a Varies object, you should set the type first by calling setData(Type t), keeping a reference to your Type, and then set values by calling methods on the Type. Here is an example:
CN cn = new CN();
variesObject.setData(cn);
cn.getIDNumber().setValue("foo");
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_OBX2_TYPE_PROP
Deprecated.
use FixOBX5#DEFAULT_OBX2_TYPE_PROP
|
static String |
ESCAPE_SUBCOMPONENT_DELIM_IN_PRIMITIVE
Deprecated.
use FixOBX5#ESCAPE_SUBCOMPONENT_DELIM_IN_PRIMITIVE
|
static String |
INVALID_OBX2_TYPE_PROP
Deprecated.
use FixOBX5#INVALID_OBX2_TYPE_PROP
|
Constructor and Description |
---|
Varies(Message message)
Creates new Varies.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(MessageVisitor visitor,
Location currentLocation)
Callback method for the visitor.
|
void |
clear()
Clears all data from this type
|
String |
encode()
Encodes this type using HL7 encoding.
|
static void |
fixOBX5(Segment segment,
ModelClassFactory factory)
Deprecated.
use FixOBX5#fixOBX5
|
static void |
fixOBX5(Segment segment,
ModelClassFactory factory,
ParserConfiguration parserConfiguration)
Deprecated.
use FixOBX5#fixOBX5
|
Type |
getData()
Returns the data contained by this instance of Varies.
|
ExtraComponents |
getExtraComponents()
Returns an object containing any extra (non-standard) components that
have been added to this type at run-time.
|
Message |
getMessage() |
String |
getName()
Returns the name of the type (used in XML encoding and profile checking)
|
boolean |
isEmpty()
Returns true if this Visitable has actual content
|
void |
parse(String string)
Parses the string into this type and replaces the current contents with
the parsed value.
|
Location |
provideLocation(Location location,
int index,
int repetition)
Reusing the location of this object's parent, this method returns its own
location within the message.
|
void |
setData(Type data)
Sets the data contained by this instance of Varies.
|
String |
toString() |
public static final String DEFAULT_OBX2_TYPE_PROP
public static final String INVALID_OBX2_TYPE_PROP
public static final String ESCAPE_SUBCOMPONENT_DELIM_IN_PRIMITIVE
System property key: If this is not set, or set to "true", and a subcomponent delimiter is found within the value of a Varies of a primitive type, this subcomponent delimiter will be treated as a literal character instead of a subcomponent delimiter, and will therefore be escaped if the message is re-encoded. This is handy when dealing with non-conformant sending systems which do not correctly escape ampersands in OBX-5 values.
For example, consider the following OBX-5 segment:
OBX||ST|||Apples, Pears & Bananas|||In this example, the data type is a primitive ST and does not support subcomponents, and the ampersand is obviously not intended to represent a subcomponent delimiter. If this property is set to
true
, the entire string will be treated as the
value of OBX-5, and if the message is re-encoded the string will appear
as "Apples, Pears \T\ Bananas".
If this property is set to anything other than "true", the subcomponent delimiter is treated as a component delimiter,
so the value after the ampersand is placed into an extra component
.
public Type getData()
public String getName()
Type
public void setData(Type data) throws DataTypeException
setData
in interface Variable
data
- the data to be set for this Varies instanceDataTypeException
- if the data could not be setpublic ExtraComponents getExtraComponents()
Type
getExtraComponents
in interface Type
public Message getMessage()
getMessage
in interface Type
public static void fixOBX5(Segment segment, ModelClassFactory factory) throws HL7Exception
Sets the data type of field 5 in the given OBX segment to the value of OBX-2. The argument is a Segment as opposed to a particular OBX because it is meant to work with any version.
Note that if no value is present in OBX-2, or an invalid value is present in
OBX-2, this method will throw an error. This behaviour can be corrected by using the
following system properties: DEFAULT_OBX2_TYPE_PROP
and INVALID_OBX2_TYPE_PROP
,
or by using configuration in ParserConfiguration
segment
- OBX segment instance to be modifiedfactory
- ModelClassFactory to be usedHL7Exception
- if the operation failspublic static void fixOBX5(Segment segment, ModelClassFactory factory, ParserConfiguration parserConfiguration) throws HL7Exception
Sets the data type of field 5 in the given OBX segment to the value of OBX-2. The argument is a Segment as opposed to a particular OBX because it is meant to work with any version.
Note that if no value is present in OBX-2, or an invalid value is present in
OBX-2, this method will throw an error. This behaviour can be corrected by using the
following system properties: DEFAULT_OBX2_TYPE_PROP
and INVALID_OBX2_TYPE_PROP
or by using configuration in ParserConfiguration
segment
- OBX segment instance to be modifiedfactory
- ModelClassFactory to be usedparserConfiguration
- configuration that influences setting OBX-5HL7Exception
- if the operation failspublic void parse(String string) throws HL7Exception
Parses the string into this type and replaces the current contents with the parsed value. This method accepts HL7 encoded text and treats its input as such.
Note that this method is subtly different from calling Primitive.setValue(String)
, but
can be quite powerful. For example, using the argument of "milk&cookies" on an ST datatype:
Primitive.setValue(String)
, the ampersand is treated as an actual ampersand
in the text, and the field will be treated as a single field which is encoded as "milk\T\cookies" (\T\ is the
escape sequence for the subcomponent delimiter).
This method makes use of the parser which is stored within the enclosing Message
.
At this time, only PipeParsers are supported.
parse
in interface Type
string
- the message to be parsedHL7Exception
- if errors occurred while parsingpublic String encode() throws HL7Exception
encode
in interface Type
HL7Exception
- if errors occurred while encodingpublic boolean isEmpty() throws HL7Exception
isEmpty
in interface Visitable
HL7Exception
- if an error occurred while determining emptinesspublic boolean accept(MessageVisitor visitor, Location currentLocation) throws HL7Exception
Visitable
this
as parameter, or
traverse through a hierarchical substructure and call accept(MessageVisitor)
for each visited element.accept
in interface Visitable
visitor
- MessageVisitor instance to be called backcurrentLocation
- location of this objecttrue
if the visit process shall continueHL7Exception
- if a problem occurred during visitingpublic Location provideLocation(Location location, int index, int repetition)
Visitable
provideLocation
in interface Visitable
location
- the parents locationindex
- index of this objectrepetition
- repetition of this objectCopyright © 2001–2017 University Health Network. All rights reserved.