Returns a instance of the hl7.Message that allows
indexed access to the data elements.
A custom hl7.Factory subclass can be passed in to be used when
constructing the message and it’s components.
Note
HL7 usually contains only ASCII, but can use other character
sets (HL7 Standards Document, Section 1.7.1), however as of v2.8,
UTF-8 is the preferred character set [1].
python-hl7 works on Python unicode strings. hl7.parse()
will accept unicode string or will attempt to convert bytestrings
into unicode strings using the optional encoding parameter.
encoding defaults to UTF-8, so no work is needed for bytestrings
in UTF-8, but for other character sets like ‘cp1252’ or ‘latin1’,
encoding must be set appropriately.
Representation of an HL7 message. It contains a list
of hl7.Segment instances.
__getitem__(key)
Index, segment-based or accessor lookup.
If key is an integer, __getitem__ acts list a list, returning
the hl7.Segment held at that index:
>>> h[1][[u'PID'], ...]
If the key is a string of length 3, __getitem__ acts like a dictionary,
returning all segments whose segment_id is key
(alias of hl7.Message.segments()).
ack_code options are one of AA (accept), AR (reject), AE (error)
(see HL7 Table 0008 - Acknowledgment Code)
message_id control message ID for ACK, defaults to unique generated ID
application name of sending application, defaults to receiving application of message
facility name of sending facility, defaults to receiving facility of message
create_component(seq)
Create a new hl7.Component compatible with this message
create_field(seq)
Create a new hl7.Field compatible with this message
create_message(seq)
Create a new hl7.Message compatible with this message
create_repetition(seq)
Create a new hl7.Repetition compatible with this message
create_segment(seq)
Create a new hl7.Segment compatible with this message
If the parse tree is deeper than the specified path continue
following the first child branch until a leaf of the tree is
encountered and return that value (which could be blank).
Example:
PID.F3.R1.C2 = ‘Sub-Component1’ (assume .SC1)
If the parse tree terminates before the full path is satisfied
check each of the subsequent paths and if every one is specified
at position 1 then the leaf value reached can be returned as the
result.
PID.F4.R1.C1.SC1 = ‘Repeat1’ (ignore .SC1)
segment(segment_id)
Gets the first segment with the segment_id from the parsed
message.
Second level of an HL7 message, which represents an HL7 Segment.
Traditionally this is a line of a message that ends with a carriage
return and is separated by pipes. It contains a list of
hl7.Field instances.
Third level of an HL7 message, that traditionally is surrounded
by pipes and separated by carets. It contains a list of strings
or hl7.Repetition instances.
MLLPClient takes an optional encoding parameter, defaults to UTF-8,
for encoding unicode messages [2].
close()
Release the socket connection
send(data)
Low-level, direct access to the socket.send (data must be already
wrapped in an MLLP container). Blocks until the server returns.
send_message(message)
Wraps a byte string, unicode string, or hl7.Message
in a MLLP container and send the message to the server
If message is a byte string, we assume it is already encoded properly.
If message is unicode or hl7.Message, it will be encoded
according to hl7.client.MLLPClient.encoding