FHIR to SPHN mappings for LOOP BMIP using FHIR Mapping Language (FML)
- Mappings: maps
StructureDefinitions for the target LOOP schema is defined using FHIR Shorthand (FSH)
- Install SUSHI from https://github.com/FHIR/sushi
- For building the IG, jekyll is required:
sudo apt install jekyll
- Optional VS Code extensions for development:
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
- Download validator:
wget https://github.com/hapifhir/org.hl7.fhir.core/releases/latest/download/validator_cli.jar
- 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
Generate StructureDefinitions (unshorten FSH):
sushi build
./_updatePublisher.sh
./_genonce.sh
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
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 resulting temp/result.json
against the LogicalModel:
java -jar validator_cli.jar temp/result.json \
-version 4.0 -ig ./fsh-generated/resources
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
- POST maps and execture transformation using REST against local matchbox server:
- See transform.http
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)'