Skip to main content

Translate between MLLP and HTTP/HTTPS

Project description

MLLP/HTTP(S)

PyPI

Project addapted by: Tiago Rodrigues, SECTRA Iberia, 2022

This project results of an enhanced package supporting HTTPS of the original project, whose original credits are given to Rivet Health

Overview

Convert MLLP to HTTP(S) and vice versa.

http2mllp is a HTTP server that translates to MLLP.

mllp2http is a MLLP server that translates to HTTP.

https2mllp is a HTTPS server that translates to MLLP.

mllp2https is a MLLP server that translates to HTTPS.

Keywords: MLLP, HTTP, HTTPS, SSL/TLS, HL7

Description

MLLP (Minimum Lower Layer Protocol) is the traditional session protocol for HL7 messages.

Many modern tools (load balancers, application frameworks, API monitoring) are designed around HTTP(S). This observation is the foundation for the HL7 over HTTP specification.

This project, MLLP/HTTP(S), bridges these two protocols, allowing network engineers and application developers to work with familiar HTTP(S) technology while interfacing with MLLP-based programs.

Implements MLLP release 1, HTTP/1.1, and SSL/TLS (optional). Each MLLP message is assumed to have a corresponding response message (e.g. HL7 acknoledgment).

Note that this project deals only with the MLLP layer; it does not process HL7 messages themselves. Notably, the HTTP participant must be able to intepret HL7 messages and generate acknowledgements. This separation imposes no requirements for HL7 usage and leaves application developers with full access to the features of the HL7 protocol.

Install

By Pip

pip install mllp-https

By Command Line

On the project folder, run the command:

python setup.py install

Run as

http2mllp localhost --mllp_port 2575

mllp2http http://localhost:8000

https2mllp localhost --mllp_port 2575

mllp2https https://localhost:8000

Docker

docker pull tiagoepr/mllp-https

Run as

docker run -it -p 2575:2575 --rm tiagoepr/mllp-https http2mllp localhost --mllp_port 2575

docker run -it -p 2575:2575 --rm tiagoepr/mllp-https mllp2http http://localhost:8000

docker run -it -p 2575:2575 --rm tiagoepr/mllp-https https2mllp localhost --mllp_port 2575 

docker run -it -p 2575:2575 --rm tiagoepr/mllp-https mllp2https http://localhost:8000

Usage

http2mllp

usage: http2mllp [-h] [-H HOST] [-p PORT] [--keep-alive KEEP_ALIVE] [--log-level {error,warn,info}]
                 [--mllp-keep-alive MLLP_KEEP_ALIVE] [--mllp-max-messages MLLP_MAX_MESSAGES] [--mllp-release {1}]
                 [--timeout TIMEOUT] [--content-type CONTENT_TYPE] [-v] [--mllp_port MLLP_PORT]
                 mllp_url

            HTTP server that proxies an MLLP server.
            Expects an MLLP response message and uses it as the HTTP response.


positional arguments:
  mllp_url              MLLP URL, Defaulf: hostname

optional arguments:
  -h, --help            show this help message and exit
  -H HOST, --host HOST  HTTP host (default: 0.0.0.0)
  -p PORT, --port PORT  HTTP port (default: 8000)
  --keep-alive KEEP_ALIVE
                        keep-alive in milliseconds, or unlimited if -1. (default: -1)
  --log-level {error,warn,info}
  --mllp-keep-alive MLLP_KEEP_ALIVE
                        keep-alive in milliseconds, or unlimited if -1. (default: -1)
  --mllp-max-messages MLLP_MAX_MESSAGES
                        maximum number of messages per connection, or unlimited if -1. (default: -1)
  --mllp-release {1}    MLLP release version (default: 1)
  --timeout TIMEOUT     socket timeout, in milliseconds, or unlimited if 0. (default: 0)
  --content-type CONTENT_TYPE
                        HTTP Content-Type header (default: x-application/hl7-v2+er7)
  -v, --version         show program's version number and exit
  --mllp_port MLLP_PORT
                        MLLP PORT (default: 2575)

mllp2http

usage: mllp2http [-h] [-H HOST] [-p PORT] [--content-type CONTENT_TYPE] [--log-level {error,warn,info}] [--mllp-release {1}]
                 [--timeout TIMEOUT] [-v]
                 http_url

MLLP server that proxies an HTTP server. Sends back the HTTP response.

positional arguments:
  http_url              HTTP URL

optional arguments:
  -h, --help            show this help message and exit
  -H HOST, --host HOST  MLLP host (default: 0.0.0.0)
  -p PORT, --port PORT  MLLP port (default: 2575)
  --content-type CONTENT_TYPE
                        HTTP Content-Type header (default: x-application/hl7-v2+er7)
  --log-level {error,warn,info}
  --mllp-release {1}    MLLP release version (default: 1)
  --timeout TIMEOUT     timeout in milliseconds (default: 0)
  -v, --version         show program's version number and exit

environment variables:
    HTTP_AUTHORIZATION - HTTP Authorization header
    API_KEY - HTTP X-API-KEY header

https2mllp

usage: https2mllp [-h] [-H HOST] [-p PORT] [--keep-alive KEEP_ALIVE] [--log-level {error,warn,info}]
                  [--mllp-keep-alive MLLP_KEEP_ALIVE] [--mllp-max-messages MLLP_MAX_MESSAGES] [--mllp-release {1}]
                  [--timeout TIMEOUT] [--content-type CONTENT_TYPE] [--mllp_port MLLP_PORT] [--certfile CERTFILE]
                  [--keyfile KEYFILE] [-v]
                  mllp_url

            HTTPS server that proxies an MLLP server.
            Expects an MLLP response message and uses it as the HTTPS response.


positional arguments:
  mllp_url              MLLP URL, Defaulf: hostname

optional arguments:
  -h, --help            show this help message and exit
  -H HOST, --host HOST  HTTPS host (default: 0.0.0.0)
  -p PORT, --port PORT  HTTPS port (default: 8000)
  --keep-alive KEEP_ALIVE
                        keep-alive in milliseconds, or unlimited if -1. (default: -1)
  --log-level {error,warn,info}
  --mllp-keep-alive MLLP_KEEP_ALIVE
                        keep-alive in milliseconds, or unlimited if -1. (default: -1)
  --mllp-max-messages MLLP_MAX_MESSAGES
                        maximum number of messages per connection, or unlimited if -1. (default: -1)
  --mllp-release {1}    MLLP release version (default: 1)
  --timeout TIMEOUT     socket timeout, in milliseconds, or unlimited if 0. (default: 0)
  --content-type CONTENT_TYPE
                        HTTPS Content-Type header (default: x-application/hl7-v2+er7)
  --mllp_port MLLP_PORT
                        MLLP PORT (default: 2575)
  --certfile CERTFILE   Path for HTTPS Server's SSL/TLS Certificate. Default: C:/ssl/certfile.crt (default:
                        C:/ssl/certfile.crt)
  --keyfile KEYFILE     Path for HTTPS Server's SSL/TLS Private Key. Default: C:/ssl/keyfile.key (default:
                        C:/ssl/keyfile.key)
  -v, --version         show program's version number and exit

mllp2https

usage: mllp2https [-h] [-H HOST] [-p PORT] [--content-type CONTENT_TYPE] [--log-level {error,warn,info}]
                  [--mllp-release {1}] [--timeout TIMEOUT] [--verify {False,True}] [-v]
                  https_url

MLLP server that proxies an HTTPS server. Sends back the HTTPS response.

positional arguments:
  https_url             HTTPS URL

optional arguments:
  -h, --help            show this help message and exit
  -H HOST, --host HOST  MLLP host (default: 0.0.0.0)
  -p PORT, --port PORT  MLLP port (default: 2575)
  --content-type CONTENT_TYPE
                        HTTPS Content-Type header (default: x-application/hl7-v2+er7)
  --log-level {error,warn,info}
  --mllp-release {1}    MLLP release version (default: 1)
  --timeout TIMEOUT     timeout in milliseconds (default: 0)
  --verify {False,True}
                        Verify SSL certificate on server side. True as default (default: True)
  -v, --version         show program's version number and exit

environment variables:
    HTTP_AUTHORIZATION - HTTP Authorization header
    X-API-KEY - HTTP X-API-KEY header

Examples

mllp2http

Run an HTTP debugging server:

docker run -p 8000:80 --rm kennethreitz/httpbin

Run the MLLP connector:

mllp2http http://localhost:8000

Send an MLLP message:

printf '\x0bMESSAGE\x1c\x0d' | socat - TCP:localhost:2575

and see the HTTP server's response (which describes the HTTP request that the connector made):

{
  "args": {},
  "data": "MESSAGE",
  "files": {},
  "form": {},
  "headers": {
    "Accept": "*/*",
    "Accept-Encoding": "gzip, deflate",
    "Connection": "keep-alive",
    "Content-Length": "7",
    "Content-Type": "x-application/hl7-v2+er7",
    "Forwarded": "by=127.0.0.1:2575;for=127.0.0.1:54572;proto=mllp",
    "Host": "localhost:8000",
    "User-Agent": "mllp2http/1.0.2"
  },
  "json": null,
  "origin": "127.0.0.1:54572",
  "url": "mllp://localhost:8000/post"
}

Developing

To install:

make install

Before committing, format:

make format

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mllp-https-1.2.16.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mllp_https-1.2.16-py2.py3-none-any.whl (15.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file mllp-https-1.2.16.tar.gz.

File metadata

  • Download URL: mllp-https-1.2.16.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for mllp-https-1.2.16.tar.gz
Algorithm Hash digest
SHA256 dbfe36b14baa6bca6921c9ac0c111daca27c7ea8153f2af211abadbb771d9073
MD5 5ae3e012d47347fbc432831d3fd5918d
BLAKE2b-256 f9ca010b4b7291538718a8e07ccc377809d636b90f2bd324dbf68cffba069b1c

See more details on using hashes here.

File details

Details for the file mllp_https-1.2.16-py2.py3-none-any.whl.

File metadata

  • Download URL: mllp_https-1.2.16-py2.py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for mllp_https-1.2.16-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9ae2db30daf4053e545aa2264951165dc5a544e5d8c66c1d923093a825a70769
MD5 d502ba3062f393c2451f1f0f6f11861d
BLAKE2b-256 db4ccc60a01303d273f4ace93ed199ef758b2252d52167115d7b57aee10d3e99

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page