hl7-to-kafka
September 20, 2024 ยท View on GitHub
HL7 v2 to Kafka producer
This project consist of a HL7v2 MLLP listener, which transfers received messages to a Kafka topic.
Messages are passed to a Kafka producer and send to a configured topic without any mapping. The sender receives an acknowledgement message (ACK) of each message sent.
Kafka headers
The resulting Kafka record is produced with a timestamp form the HL7v2
message header, i.e. from the MSH-7 segment.
The key is set to the Message control id (MSH-10) by default. However,
this can be set to an arbitrary message segment value by providing a
Terser
expression with the endpoint.hl7.key-expression application property (e.g.:
ORC-2)
Configuration
The following environment variables can be set:
| Variable | Default | Description |
|---|---|---|
| KAFKA_BOOTSTRAP_SERVERS | localhost:9092 | Kafka brokers |
| KAFKA_SECURITY_PROTOCOL | PLAINTEXT | Kafka communication protocol |
| KAFKA_SSL_TRUST_STORE_PASSWORD | Truststore password (if using SECURITY_PROTOCOL=SSL) | |
| KAFKA_SSL_KEY_STORE_PASSWORD | Keystore password (if using SECURITY_PROTOCOL=SSL) | |
| ENDPOINT_KAFKA_TOPIC | hl7-topic | Kafka output topic to send HL7 messages to |
| ENDPOINT_HL7_PORT | 2575 | HL7 MLLP listener port |
| ENDPOINT_HL7_ENCODING | iso-8859-1 | Default encoding to use if not specified in the message header |
| ENDPOINT_KAFKA_KEYEXPRESSION | Key selector for the Kafka record | |
| LOG_LEVEL | info | Log level (error, warn, info, debug) |
Additional application properties can be set by overriding values form the application.yaml by using environment variables.
Error handling
In general, the service expects incoming messages to conform to the HL7 2.x standard and the MLLP protocol.
In case of errors due to missing mandatory message header fields (id and
timestamp), formatting errors or unavailable Kafka broker connections (after
a timeout), an ACK message with the Application error type (AE) is returned.
Development
A test setup and a script to send an example message is available for development purposes.
Builds
Available image tags can be found at the Container Registry or under Releases.