MLLP Classes¶
-
class
hl7apy.mllp.
MLLPServer
(host, port, handlers, timeout=10)¶ A
TCPServer
subclass that implements an MLLP server. It receives MLLP-encoded HL7 and redirects them to the correct handler, according to thehandlers
dictionary passed in.The
handlers
dictionary is structured as follows. Every key represents a message type (i.e., the MSH.9) to handle, and the associated value is a tuple containing a subclass ofAbstractHandler
for that message type and additional arguments to pass to its constructor.It is possible to specify a special handler for errors using the
ERR
key. In this case the handler should subclassAbstractErrorHandler
, which receives, in addition to other parameters, the raised exception as the first argument. If the special handler is not specified the server will just close the connection.The class allows to specify the timeout to wait before closing the connection.
Parameters: - host – the address of the listener
- port – the port of the listener
- handlers – the dictionary that specifies the handler classes for every kind of supported message.
- timeout – the timeout for the requests
-
class
hl7apy.mllp.
AbstractHandler
(message)¶ Abstract transaction handler. Handlers should implement the
reply()
method which handle the incoming message. The incoming message is accessible using the attributeincoming_message
Parameters: message – the ER7-formatted HL7 message to handle -
reply
()¶ Abstract method. It should implement the handling of the request message and return the response.
-
-
class
hl7apy.mllp.
AbstractErrorHandler
(exc, message)¶ Abstract transaction handler for errors. It receives also the instance of the exception occurred, which will be accessible through the
exc
attribute. Specific exceptions that can be handled areUnsupportedMessageType
andInvalidHL7Message
Parameters: exc – the Exception
occurred-
reply
()¶ Abstract method. It should implement the handling of the request message and return the response.
-