hl7-to-kafka

September 20, 2024 ยท View on GitHub

MegaLinter java docker codecov

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:

VariableDefaultDescription
KAFKA_BOOTSTRAP_SERVERSlocalhost:9092Kafka brokers
KAFKA_SECURITY_PROTOCOLPLAINTEXTKafka communication protocol
KAFKA_SSL_TRUST_STORE_PASSWORDTruststore password (if using SECURITY_PROTOCOL=SSL)
KAFKA_SSL_KEY_STORE_PASSWORDKeystore password (if using SECURITY_PROTOCOL=SSL)
ENDPOINT_KAFKA_TOPIChl7-topicKafka output topic to send HL7 messages to
ENDPOINT_HL7_PORT2575HL7 MLLP listener port
ENDPOINT_HL7_ENCODINGiso-8859-1Default encoding to use if not specified in the message header
ENDPOINT_KAFKA_KEYEXPRESSIONKey selector for the Kafka record
LOG_LEVELinfoLog 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.

License

AGPL-3.0