The LinuxForHealth HL7 to FHIR converter is a Java based library that enables converting HL7v2 messages to FHIR resources in a declarative and configuration based manner.
Message parsing and modeling is supported using the "HAPI" libraries for HL7 and FHIR respectively.
The converter supports the following message types/events:
The converter supports the following message segments:
The converter partially supports the following message types/events:
If you need another message type/event . . . contributions are welcome! See CONTRIBUTING.md!
The FHIR Converter has the following dependencies:
Note: The FHIR Converter includes a Gradle Wrapper, so a local Gradle install is not required.
Clone and build the project:
git clone git@github.com:LinuxForHealth/hl7v2-fhir-converter.git
cd hl7v2-fhir-converter
./gradlew build
The HL7 to FHIR converter library is available as a maven dependency.
Library Coordinates
groupId = io.github.linuxforhealth
artifactId = hl7v2-fhir-converter
version = 1.0.10
Maven dependency
<dependency>
<groupId>io.github.linuxforhealth</groupId>
<artifactId>hl7v2-fhir-converter</artifactId>
<version>1.0.10</version>
</dependency>
Gradle dependency:
implementation 'io.github.linuxforhealth:hl7v2-fhir-converter:1.0.10'
Instantiate and execute the converter
HL7ToFHIRConverter ftv = new HL7ToFHIRConverter();
String output= ftv.convert(hl7message); // generated a FHIR output
The converter configuration file, config.properties, supports the following settings
Property Name | Description | Example Value |
---|---|---|
base.path.resource | Path to resource templates (optional). If not specified the library's default resources under src/resources are used. | /opt/converter/resources |
supported.hl7.messages | Comma delimited list of hl7 message/event types. An asterisk * may be used to indicate all messages found in sub-directory /hl7/messages under the base.path.resource and sub-directory /hl7/messages under additional.resources.location are supported. If not specified, defaults to * . |
ADT_A01, ORU_R01, PPR_PC1 |
default.zoneid | ISO 8601 timezone offset (optional). The zoneid is converted to java.time.ZoneId and applied to translations when the target FHIR resource field requires a timezone, but the source HL7 field does not include it. Requires a valid string value for java.time.ZoneId. | +08:00 |
additional.conceptmap | Path to additional concept map configuration. Concept maps are used for mapping one code system to another. | /opt/converter/concept-map.yaml |
additional.resources.location | Path to additional resources. These supplement those base.path.resource . |
/opt/supplemental/resources |
The config.properties file location is searched in the following order:
HL7CONVERTER_CONFIG_HOME environment variable is checked first
hl7converter.config.home system property is checked next
-Dhl7converter.config.home=/opt/converter/config_home_folder/
Lastly, the local classpath resource folder will be searched for config.properties
The converter allows passing of certain parameters at run time through the options.
Parameter Name | Description | Example Call on Options Creation |
---|---|---|
ZoneIdText | ZoneId override for the ISO 8601 timezone offset. Overrides default.zoneid in config.properties. Requires a valid ZoneId text value, which is converted to a java.time.ZoneId. | options.withZoneIdText("+07:00") options.withZoneIdText("America/Chicago") |
Property (Key/Value) | A string property expressed as a key / value pair. Properties become available as variables to the templates. A property TENANT with value myTenantId is utilized in templates as $TENANT . |
options.withProperty("TENANT","myTenantId") |
Since this converter is used in production environments using real patient data it can not log or print out anything that may contain PHI data. We will be stripping out all debug log statements as part of the build. This allows developers to use these debug statements to debug issues with santized unit test data.
Before the gradle build step where the compile happens the gradle build copies the src directory to the target directoy and sets the gradle build sourcesets to the target directory. Then it strips out all LOGGER.debug statements. This means the compile/build runs off the target directory where the debug statements have been stripped. However if you are running locally you still want the build to run off the src directory or otherwise you must build after each change to get it copied to the target directory. There is a flag in the gradle.properties named localDevEnv which should always be set to false in GIT but a developer can override this flag to true and the local build will keep the sourcesets tied to the src directory.