org.urhl7.igor
Class HL7Structure

java.lang.Object
  extended by org.urhl7.igor.HL7Structure
All Implemented Interfaces:
DelimitedStructure, GenericStructure

public class HL7Structure
extends Object
implements GenericStructure, DelimitedStructure

This data object is a representation of an HL7 message.


Constructor Summary
HL7Structure(char[] delims)
          Constructor for creating a HL7Structure object.
 
Method Summary
 boolean addSegment(HL7Segment seg)
          Adds a segment to the end of the HL7Structure
 void addSegment(int index, HL7Segment seg)
          Adds a segment to a particular position in the HL7Structure
 void changeDelims(char[] chars)
          Changes the delimiter set for this HL7Structure.
 void changeDelims(char[] chars, boolean changeMSHDelims)
          Changes the delimiter set for this HL7Strucutre.
 HL7Structure copy()
          Makes an exact copy of this HL7Structure and returns it.
 HL7Structure copy(boolean retainData)
          Makes an exact copy of this HL7Structure and returns it.
 char[] getDelims()
          Returns the delimiter set for this data object.
 HL7Segment getSegment(int pos)
          Returns the segment at a specific position from the HL7Structure
 int getSegmentPosition(HL7Segment seg)
          Returns the segment position in the HL7Structure
 List<HL7Segment> getSegments()
          Returns an List of the HL7Segment objects that are maintained in this data structure.
 HL7StructureHelper helper()
          Returns a HL7StructureHelper for accessing fields that may be needed.
 String marshal()
          Returns a string representation of this and the underlying data structures
 boolean removeSegment(HL7Segment seg)
          Removes a particular segment from the HL7Structure
 HL7Segment removeSegment(int pos)
          Removes the segment at a specific position from the HL7Structure
 boolean rulesTest(List<HL7Rule> rules)
          Tests if the current structure meets the requirements specified by the list of HL7Rules.
 boolean ruleTest(HL7Rule rule)
          Tests if the current structure meets the requirements specified by the HL7Rule.
 String toString()
          Returns a String representation of this structure
 void unmarshal(String data)
          Unmarshals an arbitrary String representation of a structure into this data structure
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HL7Structure

public HL7Structure(char[] delims)
Constructor for creating a HL7Structure object. Passing in the delmiting characters provided by the HL7 message will set how this object structure works.

Parameters:
delims - Usually an array of these chars: |^~\&
Method Detail

helper

public HL7StructureHelper helper()
Returns a HL7StructureHelper for accessing fields that may be needed. This is created once, then reused for this particular structure.

Returns:
a HL7StructureHelper object bound to this structure

copy

public HL7Structure copy()
Makes an exact copy of this HL7Structure and returns it. Functionally equivalent as .copy(true)

Returns:
a copy of this structure
See Also:
copy(boolean)

copy

public HL7Structure copy(boolean retainData)
Makes an exact copy of this HL7Structure and returns it. If retainData is false, it will also remove the data, but leave the structure intact.

Parameters:
retainData - flag to retain the data inside the structure
Returns:
a copy of this structure

rulesTest

public boolean rulesTest(List<HL7Rule> rules)
Tests if the current structure meets the requirements specified by the list of HL7Rules.

Parameters:
rules - list of rules
Returns:
true if it meets the requirements, false if it does not.

ruleTest

public boolean ruleTest(HL7Rule rule)
Tests if the current structure meets the requirements specified by the HL7Rule.

Parameters:
rule - the rule to test
Returns:
true if it meets the requirements, false if it does not.

addSegment

public void addSegment(int index,
                       HL7Segment seg)
Adds a segment to a particular position in the HL7Structure

Parameters:
index - the position to place the segment
seg - the segment to add

addSegment

public boolean addSegment(HL7Segment seg)
Adds a segment to the end of the HL7Structure

Parameters:
seg - the segment to add
Returns:
success of adding the segment

removeSegment

public boolean removeSegment(HL7Segment seg)
Removes a particular segment from the HL7Structure

Parameters:
seg - the segment to remove
Returns:
the success of removing the segment

removeSegment

public HL7Segment removeSegment(int pos)
Removes the segment at a specific position from the HL7Structure

Parameters:
pos - the position to remove the segment
Returns:
the segment that was removed

getSegment

public HL7Segment getSegment(int pos)
Returns the segment at a specific position from the HL7Structure

Parameters:
pos - the position
Returns:
the HL7Segment retrieved

getSegmentPosition

public int getSegmentPosition(HL7Segment seg)
Returns the segment position in the HL7Structure

Parameters:
seg - segment reference
Returns:
segment position

marshal

public String marshal()
Returns a string representation of this and the underlying data structures

Specified by:
marshal in interface GenericStructure
Returns:
a String representation of this structure

unmarshal

public void unmarshal(String data)
Unmarshals an arbitrary String representation of a structure into this data structure

Specified by:
unmarshal in interface GenericStructure
Parameters:
data - a String representation of data

getSegments

public List<HL7Segment> getSegments()
Returns an List of the HL7Segment objects that are maintained in this data structure. This value can be null if no data was unmarshalled.

Returns:
A list of HL7Segments

getDelims

public char[] getDelims()
Returns the delimiter set for this data object.

Specified by:
getDelims in interface DelimitedStructure
Returns:
delimiter array

changeDelims

public void changeDelims(char[] chars)
Changes the delimiter set for this HL7Structure. By default this will also change the MSH field that states what the delimiters are. If you do not want to do this, call changeDelims(charDelims, false);

Specified by:
changeDelims in interface DelimitedStructure
Parameters:
chars - the characters (including field delimiter, ie '|') to set

changeDelims

public void changeDelims(char[] chars,
                         boolean changeMSHDelims)
Changes the delimiter set for this HL7Strucutre. Depending on the changeMSHDelims flag, will either automatically change the data in the MSH segment that specifies the chars, or will not.

Parameters:
chars - the characters (including field delimiter, ie '|') to set.
changeMSHDelims - automatically set the MSH field to the new delimiters

toString

public String toString()
Returns a String representation of this structure

Overrides:
toString in class Object
Returns:
a String representation