Skip to content

BAL-DMU/LOOP_FHIR2SPHN

Repository files navigation

LOOP BMIP FHIR to SPHN Mapping

FHIR to SPHN mappings for LOOP BMIP using FHIR Mapping Language (FML)

StructureDefinitions for the target LOOP schema is defined using FHIR Shorthand (FSH)

Install

An FML engine is required like HAPI-FHIR Validator Cli or Matchbox (recommended)

Recommended versions: Use at least 6.5.0 for HAPI-FHIR Validator Cli and 4.0.1 for Matchbox or later. These releases contain critical performance improvements required to transform large amount of data (see hapifhir/org.hl7.fhir.core#1704 / ahdis/matchbox#362) and corresponding issues #1703 / #1699

HAPI-FHIR Validator Cli

  • Download validator:
    • wget https://github.com/hapifhir/org.hl7.fhir.core/releases/latest/download/validator_cli.jar

Matchbox

  • Requires JDK 21 and maven
    • sudo apt install openjdk-21-jdk
    • sudo apt install maven
  • Clone matchbox
cd ${HOME}
git clone https://github.com/ahdis/matchbox.git

StructureDefinitions

Generate StructureDefinitions (unshorten FSH):

sushi build

Build Implementation Guide (IG)

./_updatePublisher.sh
./_genonce.sh

Running transformations using Validator Cli

Compile maps

OUT_DIR="temp/map"
mkdir -p ${OUT_DIR}
for f in $(ls maps/*.map) ; do
    BASE=$(basename ${f} .map)
    java -jar validator_cli.jar -ig ${f} \
        -compile http://research.balgrist.ch/fhir2sphn/StructureMap/${BASE} \
        -version 4.0 -output ${OUT_DIR}/${BASE}.xml
done

Execute a transformation

Transform input data testdata/pat.json:

java -jar validator_cli.jar testdata/pat.json \
    -transform http://research.balgrist.ch/fhir2sphn/StructureMap/BundleToLoopSphn \
    -version 4.0 -ig ${OUT_DIR}/ -ig ./fsh-generated/resources \
    -output temp/result.json

Validate the result

Validate the resulting temp/result.json against the LogicalModel:

java -jar validator_cli.jar temp/result.json \
    -version 4.0 -ig ./fsh-generated/resources

Running transformations using Matchbox

Run local matchbox server:

cd matchbox/matchbox-server
mvn clean install -DskipTests spring-boot:run -Dspring-boot.run.jvmArguments="-Xmx4g" \
	-Dspring-boot.run.directories=../../LOOP_FHIR2SPHN/output \
	-Dspring-boot.run.arguments=--spring.config.additional-location=file:../../LOOP_FHIR2SPHN/with-preload/application.yaml

Note: After updating the StructureDefinitions, the database needs to be cleared to force re-loading of the IG package (output/package.tgz):

rm -rf matchbox/matchbox-server/database

Compile maps / execute transformation

  • POST maps and execture transformation using REST against local matchbox server:

Postprocessing

cat temp/result.json  | jq 'walk(if type == "object" then with_entries(.key = (if .key == "reference" then "id" else .key end)) else . end)' | jq 'walk(if type == "object" then with_entries(.key = (if .key != "id" and .key != "iri" and .key != "termid" and .key != "content" and .key != "target_concept" then "sphn:" else "" end ) + .key) else . end)'

About

LOOP BMIP FHIR to SPHN

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •