com.merge.HL7
Class HL7Field

java.lang.Object
  extended by com.merge.HL7.HL7Field
Direct Known Subclasses:
HL7FieldAD, HL7FieldAD, HL7FieldAD, HL7FieldAD, HL7FieldAUI, HL7FieldAUI, HL7FieldCCD, HL7FieldCCD, HL7FieldCCP, HL7FieldCCP, HL7FieldCD, HL7FieldCD, HL7FieldCD, HL7FieldCD, HL7FieldCE, HL7FieldCE, HL7FieldCE, HL7FieldCF, HL7FieldCF, HL7FieldCF, HL7FieldCF, HL7FieldCK, HL7FieldCK, HL7FieldCN, HL7FieldCN, HL7FieldCNE, HL7FieldCNE, HL7FieldCNE, HL7FieldCNE, HL7FieldCNN, HL7FieldCNN, HL7FieldCP, HL7FieldCP, HL7FieldCP, HL7FieldCP, HL7FieldCQ, HL7FieldCQ, HL7FieldCQ, HL7FieldCQ, HL7FieldCSU, HL7FieldCSU, HL7FieldCWE, HL7FieldCWE, HL7FieldCWE, HL7FieldCWE, HL7FieldCX, HL7FieldCX, HL7FieldCX, HL7FieldCX, HL7FieldDDI, HL7FieldDDI, HL7FieldDIN, HL7FieldDIN, HL7FieldDLD, HL7FieldDLD, HL7FieldDLN, HL7FieldDLN, HL7FieldDLN, HL7FieldDLN, HL7FieldDLT, HL7FieldDLT, HL7FieldDR, HL7FieldDR, HL7FieldDR, HL7FieldDR, HL7FieldDT, HL7FieldDT, HL7FieldDT, HL7FieldDT, HL7FieldDTM, HL7FieldDTM, HL7FieldDTN, HL7FieldDTN, HL7FieldED, HL7FieldED, HL7FieldED, HL7FieldED, HL7FieldEI, HL7FieldEI, HL7FieldEI, HL7FieldEI, HL7FieldEIP, HL7FieldEIP, HL7FieldELD, HL7FieldELD, HL7FieldERL, HL7FieldERL, HL7FieldFC, HL7FieldFC, HL7FieldFC, HL7FieldFC, HL7FieldFN, HL7FieldFN, HL7FieldFN, HL7FieldFT, HL7FieldFT, HL7FieldFT, HL7FieldFT, HL7FieldGTS, HL7FieldGTS, HL7FieldHD, HL7FieldHD, HL7FieldHD, HL7FieldHD, HL7FieldICD, HL7FieldICD, HL7FieldID, HL7FieldID, HL7FieldID, HL7FieldID, HL7FieldIS, HL7FieldIS, HL7FieldIS, HL7FieldIS, HL7FieldJCC, HL7FieldJCC, HL7FieldJCC, HL7FieldJCC, HL7FieldLA1, HL7FieldLA1, HL7FieldLA2, HL7FieldLA2, HL7FieldMA, HL7FieldMA, HL7FieldMA, HL7FieldMA, HL7FieldMO, HL7FieldMO, HL7FieldMO, HL7FieldMO, HL7FieldMOC, HL7FieldMOC, HL7FieldMOP, HL7FieldMOP, HL7FieldMSG, HL7FieldMSG, HL7FieldNA, HL7FieldNA, HL7FieldNA, HL7FieldNA, HL7FieldNDL, HL7FieldNDL, HL7FieldNM, HL7FieldNM, HL7FieldNM, HL7FieldNM, HL7FieldNR, HL7FieldNR, HL7FieldOCD, HL7FieldOCD, HL7FieldOSD, HL7FieldOSD, HL7FieldOSP, HL7FieldOSP, HL7FieldPIP, HL7FieldPIP, HL7FieldPL, HL7FieldPL, HL7FieldPL, HL7FieldPL, HL7FieldPLN, HL7FieldPLN, HL7FieldPN, HL7FieldPN, HL7FieldPPN, HL7FieldPPN, HL7FieldPPN, HL7FieldPPN, HL7FieldPRL, HL7FieldPRL, HL7FieldPT, HL7FieldPT, HL7FieldPT, HL7FieldPT, HL7FieldPTA, HL7FieldPTA, HL7FieldQIP, HL7FieldQIP, HL7FieldQIP, HL7FieldQIP, HL7FieldQSC, HL7FieldQSC, HL7FieldQSC, HL7FieldQSC, HL7FieldRCD, HL7FieldRCD, HL7FieldRCD, HL7FieldRCD, HL7FieldRFR, HL7FieldRFR, HL7FieldRI, HL7FieldRI, HL7FieldRI, HL7FieldRI, HL7FieldRMC, HL7FieldRMC, HL7FieldRP, HL7FieldRP, HL7FieldRP, HL7FieldRP, HL7FieldRPT, HL7FieldRPT, HL7FieldSAD, HL7FieldSAD, HL7FieldSAD, HL7FieldSCV, HL7FieldSCV, HL7FieldSCV, HL7FieldSCV, HL7FieldSI, HL7FieldSI, HL7FieldSI, HL7FieldSI, HL7FieldSN, HL7FieldSN, HL7FieldSN, HL7FieldSN, HL7FieldSPD, HL7FieldSPD, HL7FieldSPS, HL7FieldSPS, HL7FieldSRT, HL7FieldSRT, HL7FieldSRT, HL7FieldST, HL7FieldST, HL7FieldST, HL7FieldST, HL7FieldTM, HL7FieldTM, HL7FieldTM, HL7FieldTM, HL7FieldTN, HL7FieldTN, HL7FieldTQ, HL7FieldTQ, HL7FieldTQ, HL7FieldTQ, HL7FieldTS, HL7FieldTS, HL7FieldTS, HL7FieldTS, HL7FieldTX, HL7FieldTX, HL7FieldTX, HL7FieldTX, HL7FieldUVC, HL7FieldUVC, HL7FieldVH, HL7FieldVH, HL7FieldVH, HL7FieldVH, HL7FieldVID, HL7FieldVID, HL7FieldVID, HL7FieldVID, HL7FieldVR, HL7FieldVR, HL7FieldWVI, HL7FieldWVI, HL7FieldWVS, HL7FieldWVS, HL7FieldXAD, HL7FieldXAD, HL7FieldXAD, HL7FieldXAD, HL7FieldXCN, HL7FieldXCN, HL7FieldXCN, HL7FieldXCN, HL7FieldXON, HL7FieldXON, HL7FieldXON, HL7FieldXON, HL7FieldXPN, HL7FieldXPN, HL7FieldXPN, HL7FieldXPN, HL7FieldXTN, HL7FieldXTN, HL7FieldXTN, HL7FieldXTN

public class HL7Field
extends java.lang.Object

The HL7Field class represents a generic field in a segment. The toolkit provides specialized classes for each HL7 defined data type to allow setting/reading components by name. This class provides the base functionality for managing the components of the field.

The components of the field are HL7Field objects as well and are referenced by the methods of this class by the component's index number. The first component has the index = 1. Components that are not set, are considered empty and retrieving such component's value results in empty value. For simple data types, fields that do not have components, the value of the field is a string.

Instances of this class should be created through the createField(String) method or using one of the specialized classes defined in the com.merge.HL7.fields package.

Methods of this class are synchronized.


Nested Class Summary
static interface HL7Field.FieldFormatter
          Defines the interface for formatting simple field values before sending and after receiving.
 
Field Summary
static java.lang.String EMPTY_VALUE
          Represents an Empty field value as defined by HL7, which is a zero length string.
static java.lang.String NULL_VALUE
          Represents a Null field value as defined by HL7, which is a string containing two double quote characters.
 
Method Summary
 HL7Field clone()
          Creates a copy of this field.
static HL7Field createField(java.lang.String fieldType)
          Creates a specific type of field object.
static HL7Field createField(java.lang.String fieldType, HL7Toolkit.HL7Version version)
          Creates a specific type of field object.
 boolean getBoolValue()
          Gets the value of this field as a boolean.
 HL7Field getComponent(int index)
          Gets a component of this field.
 java.lang.String getComponentDescription(int index)
          Gets the description of a component in this field.
 int getComponentLength(int index)
          Gets the maximum number of characters for a component in this field.
 java.lang.String getComponentType(int index)
          Gets the HL7 data type of a component in this field.
 java.lang.String getContent()
          Provides the HL7 encoded representation of the value in this field using the default separators.
 java.lang.String getContent(boolean subcomponent)
          Provides the HL7 encoded representation of the value in this field using the default separators.
 java.lang.String getContent(HL7MessageConfiguration config, boolean subcomponent)
          Provides the HL7 encoded representation of the value in this field using the default separators.
 java.lang.String getDataType()
          Gets the HL7 data type of this field.
 java.util.Calendar getDateValue()
          Gets the value of TM, DTM and DT type fields.
 java.lang.Double getDoubleValue()
          Gets the value of double type fields.
static HL7Field.FieldFormatter getFieldFormatter()
          Gets the current field formatter used by the toolkit.
 java.lang.String getFieldName()
          Gets the name of this HL7 data type.
 HL7Toolkit.HL7Version getHL7Version()
           
 int getIntValue()
          Gets the value of integer type fields.
 int getMaxSize()
          Gets the number of components defined for this field.
 int getMinSize()
          Gets the minimum number of components this field must have.
 java.lang.String getTableNo(int index)
          Gets the table identifier of a component in this field.
 java.lang.String getValue()
          Gets the value of this field.
 java.lang.String getValue(int index)
          Gets the value of a component in this field.
 boolean isBasicType()
          Tells whether the HL7 data type of this field is a basic type that, i.e.
 boolean isComponentMandatory(int index)
          Tells whether a component is mandatory.
 boolean isEmpty()
          Tells whether this field is empty, i.e.
 boolean isNull()
          Tells whether this field has Null value, i.e.
 void setComponent(int index, HL7Field val)
          Sets a component of this field.
 void setContent(java.lang.String content)
          Sets the value of this field from an HL7 encoded representation using the default separators.
 void setContent(java.lang.String content, HL7MessageConfiguration config, boolean subcomponent)
          Sets the value of this field from an HL7 encoded representation.
static void setFieldClass(java.lang.String fieldType, java.lang.Class<? extends HL7Field> fieldClass)
          Registers an HL7Field derived class as the handler for the specified HL7 data type.
static void setFormatter(HL7Field.FieldFormatter formatter)
          Sets the field formatter that will be used by the toolkit.
 void setValue(boolean val)
          Sets the value of this field to "Y" or "N" as specified by the Yes/No table indicator (0136) in section 2.24.23.1.
 void setValue(java.util.Calendar val)
          Sets the value for TM, TS and DT type fields.
 void setValue(java.util.Calendar val, int precision)
          Sets the value for TM, DTM and DT type fields.
 void setValue(double val)
          Sets the value of this field.
 void setValue(int val)
          Sets the value of this field.
 void setValue(int index, double val)
          Sets the value of a component of this field.
 void setValue(int index, int val)
          Sets the value of a component of this field.
 void setValue(int index, java.lang.String val)
          Sets the value of a component of this field.
 void setValue(java.lang.String val)
          Sets the value of this field.
 int size()
          Gets the actual number of components of this field.
 java.lang.String toAnnotatedString()
          Provides an easy readable representation of this field.
 java.lang.String toAnnotatedString(int verbosityLevel, int indentLevel)
          Provides an easy readable representation of this field.
 java.lang.String toString()
          Returns a string description of this instance.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL_VALUE

public static final java.lang.String NULL_VALUE
Represents a Null field value as defined by HL7, which is a string containing two double quote characters.

See Also:
Constant Field Values

EMPTY_VALUE

public static final java.lang.String EMPTY_VALUE
Represents an Empty field value as defined by HL7, which is a zero length string.

See Also:
Constant Field Values
Method Detail

getHL7Version

public HL7Toolkit.HL7Version getHL7Version()

createField

public static HL7Field createField(java.lang.String fieldType,
                                   HL7Toolkit.HL7Version version)
Creates a specific type of field object. If there is no class registered for the specified data type this method creates a HL7Field, base type object.

Parameters:
fieldType - The HL7 data type of the field.
version - The HL7 version of the desired field.
Returns:
An empty HL7Field or HL7Field derived object.

createField

public static HL7Field createField(java.lang.String fieldType)
Creates a specific type of field object. If there is no class registered for the specified data type this method creates a HL7Field, base type object. The version of the field is determined by the default HL7 version specified by the configuration option DEFAULT_HL7_VERSION.

Parameters:
fieldType - The HL7 data type of the field.
Returns:
An empty HL7Field or HL7Field derived object.

setFieldClass

public static void setFieldClass(java.lang.String fieldType,
                                 java.lang.Class<? extends HL7Field> fieldClass)
Registers an HL7Field derived class as the handler for the specified HL7 data type.

Parameters:
fieldType - The HL7 data type the class will handle.
fieldClass - The class associated with the data type or null to revert to the default field handler class.

setFormatter

public static void setFormatter(HL7Field.FieldFormatter formatter)
Sets the field formatter that will be used by the toolkit.

Parameters:
formatter - An object implementing the HL7Field.FieldFormatter interface.

getFieldFormatter

public static HL7Field.FieldFormatter getFieldFormatter()
Gets the current field formatter used by the toolkit. The default field formatter implements escaping and un-escaping of the separator characters in FT,TX and CF field values.

Returns:
The currently registered HL7Field.FieldFormatter object.

getDataType

public java.lang.String getDataType()
Gets the HL7 data type of this field.

Returns:
A string representing the field's data type.

getFieldName

public java.lang.String getFieldName()
Gets the name of this HL7 data type.

Returns:
A string representing the field's name.

getMinSize

public int getMinSize()
Gets the minimum number of components this field must have.

Returns:
The minimum number of components.

getMaxSize

public int getMaxSize()
Gets the number of components defined for this field.

Returns:
The maximum number of components.

getComponentType

public java.lang.String getComponentType(int index)
Gets the HL7 data type of a component in this field.

Parameters:
index - The one based index of the component.
Returns:
A string representing the component's data type.

getComponentDescription

public java.lang.String getComponentDescription(int index)
Gets the description of a component in this field.

Parameters:
index - The one based index of the component.
Returns:
A string representing the component's description.

getComponentLength

public int getComponentLength(int index)
Gets the maximum number of characters for a component in this field.

Parameters:
index - The one based index of the component.
Returns:
The maximum length of the component as defined by HL7.

getTableNo

public java.lang.String getTableNo(int index)
Gets the table identifier of a component in this field.

Parameters:
index - The one based index of the component.
Returns:
A string representing the table number as defined by HL7 or an empty string if a table number is not defined.

isComponentMandatory

public boolean isComponentMandatory(int index)
Tells whether a component is mandatory.

Parameters:
index - The one based index of the component.
Returns:
true if the specified component is mandatory.

setContent

public void setContent(java.lang.String content)
Sets the value of this field from an HL7 encoded representation using the default separators.

Parameters:
content - The encoded value.

setContent

public void setContent(java.lang.String content,
                       HL7MessageConfiguration config,
                       boolean subcomponent)
Sets the value of this field from an HL7 encoded representation.

Parameters:
content - The encoded value.
config - The configuration object containing the encoding separators.
subcomponent - Flag indicating whether this field is a subcomponent of another field.

getContent

public java.lang.String getContent()
Provides the HL7 encoded representation of the value in this field using the default separators.

Returns:
A string representing the encoded value of this field.

getContent

public java.lang.String getContent(boolean subcomponent)
Provides the HL7 encoded representation of the value in this field using the default separators.

Parameters:
subcomponent - Flag indicating whether this field is a subcomponent of another field.
Returns:
A string representing the encoded value of this field.

getContent

public java.lang.String getContent(HL7MessageConfiguration config,
                                   boolean subcomponent)
Provides the HL7 encoded representation of the value in this field using the default separators.

Parameters:
config - The configuration object containing the encoding separators.
subcomponent - Flag indicating whether this field is a subcomponent of another field.
Returns:
A string representing the encoded value of this field.

getValue

public java.lang.String getValue()
Gets the value of this field. If the field has components, this method returns the value of the first component.

Returns:
The value stored in this field.

getValue

public java.lang.String getValue(int index)
Gets the value of a component in this field. If this field does not have components and the index is 1, this method return the value of the field.

Parameters:
index - The one based index of the component.
Returns:
The value of the requested component.

getComponent

public HL7Field getComponent(int index)
Gets a component of this field.

Parameters:
index - The one based index of the component to return.
Returns:
An HL7Field object representing the requested component. If this field does not have components and the index is 1, the current instance is returned ( this ).

isEmpty

public boolean isEmpty()
Tells whether this field is empty, i.e. the value is a zero length string. If this field has more than one component this method returns true if all components are empty.

Returns:
true if this field is empty.

isNull

public boolean isNull()
Tells whether this field has Null value, i.e. the value is a string containing two double quote characters. If this field has more than one component this method returns true if all components have Null values.

Returns:
true if this field has Null value.

clone

public HL7Field clone()
Creates a copy of this field. If this field has components each component is cloned separately. The class of the returned object is determined by the createField(String, HL7Toolkit.HL7Version) method.

Overrides:
clone in class java.lang.Object
Returns:
A field instance containing the same data as the current field.

size

public int size()
Gets the actual number of components of this field.

Returns:
The number of components of this field or 1 if this field is a base type.

getIntValue

public int getIntValue()
Gets the value of integer type fields.

Returns:
An integer value of current field

getDoubleValue

public java.lang.Double getDoubleValue()
Gets the value of double type fields.

Returns:
A double value of current field

getDateValue

public java.util.Calendar getDateValue()
Gets the value of TM, DTM and DT type fields.

Returns:
A Calendar object representing the value of this field.

getBoolValue

public boolean getBoolValue()
Gets the value of this field as a boolean. If this field has components the value of the first component is returned.

Returns:
true if the value starts with "Y" or "y".

setValue

public void setValue(int val)
Sets the value of this field. If this field has more than one component, this method sets the value of the first component.

Parameters:
val - The value to set.

setValue

public void setValue(int index,
                     int val)
Sets the value of a component of this field.

Parameters:
index - The one based index of the component to set.
val - The value to set.

setValue

public void setValue(double val)
Sets the value of this field. If this field has more than one component, this method sets the value of the first component.

Parameters:
val - The value to set.

setValue

public void setValue(int index,
                     double val)
Sets the value of a component of this field.

Parameters:
index - The one based index of the component to set.
val - The value to set.

setValue

public void setValue(java.lang.String val)
Sets the value of this field. If this field has more than one component, this method sets the value of the first component.

Parameters:
val - The value to set.

setValue

public void setValue(int index,
                     java.lang.String val)
Sets the value of a component of this field.

Parameters:
index - The one based index of the component to set.
val - The value to set.

setComponent

public void setComponent(int index,
                         HL7Field val)
Sets a component of this field.

Parameters:
index - The one based index of the component to set.
val - The component to set.

setValue

public void setValue(java.util.Calendar val)
Sets the value for TM, TS and DT type fields.

Parameters:
val - A Calendar object representing the value to set.

setValue

public void setValue(boolean val)
Sets the value of this field to "Y" or "N" as specified by the Yes/No table indicator (0136) in section 2.24.23.1.

Parameters:
val - The value to set.

setValue

public void setValue(java.util.Calendar val,
                     int precision)
Sets the value for TM, DTM and DT type fields.

Parameters:
val - A Calendar object representing the value to set.
precision - The maximum number of characters in the value.

toAnnotatedString

public java.lang.String toAnnotatedString()
Provides an easy readable representation of this field.

Returns:
A string describing the content of this field.

toAnnotatedString

public java.lang.String toAnnotatedString(int verbosityLevel,
                                          int indentLevel)
Provides an easy readable representation of this field.

Parameters:
verbosityLevel - The detail level to include in the returned string. Accepted values are HL7Toolkit.EXPAND_NONE, HL7Toolkit.EXPAND_SEGMENT, HL7Toolkit.EXPAND_FIELD and HL7Toolkit.EXPAND_NONEMPTY_FIELD.
indentLevel - The number of white spaces to insert before each line.
Returns:
A string describing the content of this field.

isBasicType

public boolean isBasicType()
Tells whether the HL7 data type of this field is a basic type that, i.e. no components are defined for this field.

Returns:
true if this field is of a basic type.

toString

public java.lang.String toString()
Returns a string description of this instance.

Overrides:
toString in class java.lang.Object
Returns:
A string containing the class name, data type and ID of this field.

Copyright © 2010 Merge Healthcare Inc. All Rights Reserved.