Returns a instance of the hl7.Message that allows indexed access to the data elements.
Note
HL7 usually contains only ASCII, but can use other character sets (HL7 Standards Document, Section 1.7.1). Therefore, python-hl7 works on Python unicode strings. hl7.parse() will accept ASCII-only strings and automatically convert them into unicode. However, if the message contains non-ASCII characters, it is the responsibility of the caller of hl7.parse() to properly convert the message string to unicode first.
>>> h = hl7.parse(message)
Return type: | hl7.Message |
---|
Determines whether a line looks like an HL7 message. This method only does a cursory check and does not fully validate the message.
Return type: | bool |
---|
Abstract root class for the parts of the HL7 message.
Join a the child containers into a single string, separated by the self.separator. This method acts recursively, calling the children’s __unicode__ method. Thus unicode() is the approriate method for turning the python-hl7 representation of HL7 into a standard string.
>>> unicode(h) == message
True
Representation of an HL7 message. It contains a list of hl7.Segment instances.
Index or segment-based 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, __getitem__ acts like a dictionary, returning all segments whose segment_id is key (alias of hl7.Message.segments()).
>>> h['OBX']
[[[u'OBX'], [u'1'], ...]]
Return type: | hl7.Segment or list of hl7.Segment |
---|
Gets the first segment with the segment_id from the parsed message.
>>> h.segment('PID')
[[u'PID'], ...]
Return type: | hl7.Segment |
---|
Returns the requested segments from the parsed message that are identified by the segment_id (e.g. OBR, MSH, ORC, OBX).
>>> h.segments('OBX')
[[[u'OBX'], [u'1'], ...]]
Return type: | list of hl7.Segment |
---|
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.
A basic, blocking, HL7 MLLP client based upon socket.
MLLPClient implements two methods for sending data to the server.
Can be used by the with statement to ensure MLLPClient.close() is called:
with MLLPClient(host, port) as client:
client.send_message('MSH|...')
Release the socket connection
Low-level, direct access to the socket.send (data must be already wrapped in an MLLP container). Blocks until the server returns.
Wraps a str, unicode, or :py:cls:`hl7.Message` in a MLLP container and send the message to the server