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.
Returns a instance of a hl7.Batch
that allows indexed access to the messages.
A custom hl7.Factory subclass can be passed in to be used when
constructing the batch 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 [2].
python-hl7 works on Python unicode strings. hl7.parse_batch()
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.
Returns a instance of the hl7.File that allows
indexed access to the batches.
A custom hl7.Factory subclass can be passed in to be used when
constructing the file 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 [3].
python-hl7 works on Python unicode strings. hl7.parse_file()
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.
Returns a instance of the hl7.Message, hl7.Batch
or hl7.File that allows indexed access to the data elements or
messages or batches respectively.
A custom hl7.Factory subclass can be passed in to be used when
constructing the message/batch/file 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 [4].
python-hl7 works on Python unicode strings. hl7.parse_hl7()
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.
Join a the child messages 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.
If this batch has BHS/BTS segments, they will be added to the
beginning/end of the returned string.
Join a the child batches 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.
If this batch has FHS/FTS segments, they will be added to the
beginning/end of the returned string.
If key is an integer, __getitem__ acts list a list, returning
the hl7.Segment held at that index:
>>> h[1][['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()).
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.
ack_code options are one of AA (Application Accept), AR (Application Reject),
AE (Application Error), CA (Commit Accept - Enhanced Mode),
CR (Commit Reject - Enhanced Mode), or CE (Commit Error - Enhanced Mode)
(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
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.
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
The arguments are all the usual arguments to create_connection()
except protocol_factory; most common are positional host and port,
with various optional keyword arguments following.
Start a socket server, call back for each client connected.
The first parameter, client_connected_cb, takes two parameters:
client_reader, client_writer. client_reader is a
hl7.mllp.HL7StreamReader object, while client_writer
is a hl7.mllp.HL7StreamWriter object. This
parameter can either be a plain callback function or a coroutine;
if it is a coroutine, it will be automatically converted into a
Task.
The rest of the arguments are all the usual arguments to
loop.create_server() except protocol_factory; most common are
positional host and port, with various optional keyword arguments
following.
The return value is the same as loop.create_server().
Additional optional keyword arguments are loop (to set the event loop
instance to use) and limit (to set the buffer limit passed to the
StreamReader).
The return value is the same as loop.create_server(), i.e. a
Server object which can be used to stop the service.
If limit is reached, ValueError will be raised. In that case, if
block termination separator was found, complete line including separator
will be removed from internal buffer. Else, internal buffer will be cleared. Limit is
compared against part of the line without separator.