Net_HL7
[ class tree: Net_HL7 ] [ index: Net_HL7 ] [ all elements ]

Class: Net_HL7_Message

Source Location: /Net_HL7-0.1.1/Net/HL7/Message.php

Class Overview


Class specifying the HL7 message, both request and response.


Author(s):

Version:

  • $Revision: 1.8 $

Methods


Child classes:

Net_HL7_Messages_ACK
Class specifying the HL7 message, both request and response.

Inherited Variables

Inherited Methods


Class Details

[line 44]
Class specifying the HL7 message, both request and response.

In general one needn't create an instance of the Net_HL7_Message class directly, but use the Net_HL7 factory class to create one. When adding segments, note that the segment index starts at 0, so to get the first segment, do

.

The segment separator defaults to \015. To change this, set the global variable $_Net_HL7_SEGMENT_SEPARATOR.



[ Top ]


Method Detail

Net_HL7_Message (Constructor)   [line 85]

Net_HL7_Message Net_HL7_Message( [ $msgStr = ""], [ $hl7Globals = array()])

Constructor for Net_HL7_Message. Consider using the HL7 factory to obtain a message instead.

The constructor takes an optional string argument that is a string representation of a HL7 message. If the string representation is not a valid HL7 message. according to the specifications, undef is returned instead of a new instance. This means that segments should be separated within the message with the segment separator (defaults to \015) or a newline, and segments should be syntactically correct. When using the string argument constructor, make sure that you have escaped any characters that would have special meaning in PHP.

The control characters and field separator will take the values from the MSH segment, if set. Otherwise defaults will be used. Changing the MSH fields specifying the field separator and control characters after the MSH has been added to the message will result in setting these values for the message.

If the message couldn't be created, for example due to a erroneous HL7 message string, an error is raised.


Parameters:

   $msgStr   — 
   $hl7Globals   — 

[ Top ]

addSegment   [line 212]

boolean addSegment( object An &$segment)

Add a segment.

The segment will be added to the end of the message. The segment should be an instance of Net_HL7_Segment.

  • See: Net_HL7_Segment
  • Access: public

Parameters:

object An   &$segment   —  instance of Net_HL7_Segment

[ Top ]

getSegmentAsString   [line 473]

mixed getSegmentAsString( int $index)

Get the segment identified by index as string, using the messsages separators.
  • Return: String representation of segment
  • See: Net_HL7_Segment
  • Access: public

Parameters:

int   $index   —  Index for segment to get

[ Top ]

getSegmentByIndex   [line 280]

object An &getSegmentByIndex( int $index)

Return the segment specified by $index.

Segment count within the message starts at 0.

  • Return: instance of Net_HL7_Segment
  • See: Net_HL7_Segment
  • Access: public

Parameters:

int   $index   —  Index where segment is inserted

[ Top ]

getSegmentFieldAsString   [line 518]

mixed getSegmentFieldAsString( int $segIndex, int $fldIndex)

Get the field identified by $fldIndex from segment $segIndex.

Returns empty string if field is not set.

  • Return: String representation of field
  • Access: public

Parameters:

int   $segIndex   —  Index for segment to get
int   $fldIndex   —  Index for field to get

[ Top ]

getSegments   [line 403]

array getSegments( )

Return an array containing all segments in the right order.
  • Return: List of all segments
  • Access: public

[ Top ]

getSegmentsByName   [line 297]

array getSegmentsByName( mixed $name)

Return an array of all segments with the given name
  • Return: List of segments identified by name
  • Access: public

Parameters:

mixed   $name   —  Segment name

[ Top ]

insertSegment   [line 240]

boolean insertSegment( object An &$segment, [int $idx = ""])

Insert a segment.

The segment should be an instance of Net_HL7_Segment. If the index is not given, nothing happens.

  • See: Net_HL7_Segment
  • Access: public

Parameters:

object An   &$segment   —  instance of Net_HL7_Segment
int   $idx   —  Index where segment is inserted

[ Top ]

removeSegmentByIndex   [line 322]

boolean removeSegmentByIndex( int $index)

Remove the segment indexed by $index.

If it doesn't exist, nothing happens, if it does, all segments after this one will be moved one index up.

  • Access: public

Parameters:

int   $index   —  Index where segment is removed

[ Top ]

setSegment   [line 346]

boolean setSegment( object An &$segment, int $idx)

Set the segment on index.

If index is out of range, or not provided, do nothing. Setting MSH on index 0 will revalidate field separator, control characters and hl7 version, based on MSH(1), MSH(2) and MSH(12).

  • See: Net_HL7_Segment
  • Access: public

Parameters:

object An   &$segment   —  instance of Net_HL7_Segment
int   $idx   —  Index where segment is set

[ Top ]

toString   [line 421]

mixed toString( [boolean $pretty = False])

Return a string representation of this message.

This can be used to send the message over a socket to an HL7 server. To print to other output, use the $pretty argument as some true value. This will not use the default segment separator, but '\n' instead.

  • Return: String representation of HL7 message
  • Access: public

Parameters:

boolean   $pretty   —  Whether to use \n as separator or default (\r).

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:32:35 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.