MLLPServer(host, port, handlers, timeout=10)¶
TCPServersubclass that implements an MLLP server. It receives MLLP-encoded HL7 and redirects them to the correct handler, according to the
handlersdictionary passed in.
handlersdictionary 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 of
AbstractHandlerfor that message type and additional arguments to pass to its constructor.
It is possible to specify a special handler for errors using the
ERRkey. In this case the handler should subclass
AbstractErrorHandler, 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.
- 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
Abstract transaction handler. Handlers should implement the
reply()method which handle the incoming message. The incoming message is accessible using the attribute
Parameters: message – the ER7-formatted HL7 message to handle
Abstract method. It should implement the handling of the request message and return the response.
Abstract transaction handler for errors. It receives also the instance of the exception occurred, which will be accessible through the
excattribute. Specific exceptions that can be handled are
Parameters: exc – the