Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
.vscode/launch.json
input-cache/
output/
output2/
temp/
template/
fsh-generated/**
ig-template/**/*.db
ig-template/**/*index.json
publisher.jar
translations/**

subigs/**
2 changes: 2 additions & 0 deletions CrossVersion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
https://hl7.org/fhir/uv/xver-r5.r4/0.0.1-snapshot-2/StructureDefinition-ext-R5-ValueSet.ex.co.property.html

80 changes: 76 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,79 @@
# HL7 EU Imaging Studies and Reports Implementation Guide.
# README

This github repository contains the source material for the HL7 EU Imaging Studies and Reports Implementation Guide.
This repository contains the source files to build and deploy a multi-FHIR version of the HL7 EU Imaging Studies EHDS Implementation Guide.

* Current Web-build: https://build.fhir.org/ig/hl7-eu/imaging/index.html
* Issues: https://github.com/hl7-eu/imaging/issues
```text
┌───────────────────────────┐
│ │ ┌──────────────────────────────┐
│ github.com/hl7eu/imaging ┼─────► github.com/hl7eu/imaging-r4 │
│ │ └──────────────────────────────┘ │ │
└────────────┬──────────────┘
│ ┌──────────────────────────────┐
└────────────────────► github.com/hl7eu/imaging-r5 │
└──────────────────────────────┘
```

The content of this repository is processed and generates the content of the imaging-r4 and imaging-r5 repositories. The content of these repositories is not edited directly but generated based on the content of this repository.

This approach has been chosen as it allows both versions of the specification to be generated from a single codebase and still allows the R4 and R5 versions to be build using the FHIR autobuilder.

Structure of this repository
- The IG source files are located in the `ig-src` directory.
- Run `./_preprocessgenerate.sh` to generate FHIR-version-specific IGs under the `igs/imaging-<rx>` directory, where the <rx> will be replaced with FHIR version.
- The `./_preprocessgenerate.sh` process uses **Liquid tags** to insert version-specific content from the source files into the appropriate folders.
- The repository also has a mock FHIR-IG that contains one page that forwards to the imaging-r5 version of the specification. This ensures that people that have older versions of the IG are still seeing the current build.

The versions in the igs/imaging-r4 and igs/imaging-r5 directory can be used to check the R4 and R5 versions during editing.

Once the changes have checked and results can be committed, the script `_commitToMainRepos.sh` should be run. This will checkout the corresponding branch on the imaging-r4 and imaging-r5 repositories, copy the contents of the igs/imaging-r4 and igs/imaging-r5 directories and check in the changes.

## Multi-version process

Each target version is specified in the `_preprocessgenerate.sh` script in the `versions` variable. For each element in the array the script will:

1. Clean the target directory of existing content.
2. Copy relevant content from the `ig-src` directory to the target directory
3. Run liquid on each file in the target directory which is named `*.liquid.*`. The liquid file will be removed and replaced with a file that does not have liquid in its name.
4. The variables used in the liquid process are defined in the `context-<Rx>.json` files.

The main files on which this process is typically used are `sushi-config.yaml`, `ig.ini` and `fsh` files. FHIR release specific pages are generated using the standard variables made available by the IG-publisher, mainly `site.data.fhir.version`.

## Multi-FHIR shorthand files

Using the variables defined in the context files FHIR version variations can be added in multiple ways. The two main approaches are shown below.

The first pattern uses the `{% if isR4 % }` and `{% endif}` statements as is depicted in the example below.

```text
* status = #final
{% if isR5 % }
* version = "1.0.0" // invented - not there in the report
{% endif}
{% if isR4 % }
* extension[version].valueString = "1.0.0"
{% endif}
```

In the R4 version of the shorthand file on the R4 part will be present, the R5 version will only hand the R5 alternative.

This approach has the advantage that the identation remains in place but the disadvantage that the line numbers change. An alternative approach is illustrated below.

```text
* status = #final
{%R5%}* version = "1.0.0" // invented - not there in the report
{%R4%}* extension[version].valueString = "1.0.0"
{% endif}
```

In the R4 version, `{%R4%}` will be replaced by "" and `{%R4%}` by "//R5". In the R5 version `{%R4%}` will be replaced by "//R4" and `{%R4%}` by "".
The different sections are clearly marked and the line numbering is not compromised at the expense of loosing indent alignment.

## Compiling Content

1. From the root directory, run:
```sh
./_preprocessMultiVersion.sh
```
2. The compiled IGs will be found in the `igs/r4` and `igs/r5` directories.
3. Run `./_updatePublisher.sh` and then `./_genonce.sh` to build each IG.

80 changes: 80 additions & 0 deletions _commitToMainRepos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/bash

# Check if we're inside a git repository
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
echo "Not inside a git repository."
exit 1
fi

# Get and print the current branch name
current_branch=$(git rev-parse --abbrev-ref HEAD)
echo "Current branch: $current_branch"

src_dir="igs/"
subrepo_dir="subigs/"

versions=("r4" "r5" )

if [ ! -d "${src_dir}" ]; then
mkdir -p "${src_dir}"
echo "Created directory ${src_dir}aa."
fi

for version in "${versions[@]}"; do

full_src_dir=${src_dir}imaging-${version}
full_tgt_dir=${subrepo_dir}imaging-${version}

if [ ! -d "$full_src_dir" ]; then
mkdir -p "$full_src_dir"
echo "Created directory $full_src_dir."
fi

echo Ensure $full_tgt_dir is a git repo and on the same branch
if [ -d "$full_tgt_dir/.git" ]; then
pushd "$full_tgt_dir" > /dev/null

if git show-ref --verify --quiet "refs/heads/$current_branch"; then
git checkout "$current_branch"
git pull origin "$current_branch" || true
else
git checkout -b "$current_branch"
fi

popd > /dev/null
else
echo "Directory $full_tgt_dir is not a git repository."
# git clone https://github.com/hl7-eu/imaging-r4 "$subrepo_dir$version"
git clone [email protected]:hl7-eu/imaging-$version.git "$full_tgt_dir"
fi

# Copy contents from igs/r4 to the current directory
if [ -d "$full_src_dir" ]; then
rm -Rf $full_tgt_dir/ig-template
rm -Rf $full_tgt_dir/input
cp -r "$full_src_dir"/. $full_tgt_dir
echo "Copied contents from $full_src_dir to $full_tgt_dir."
else
echo "Source directory $full_src_dir does not exist."
exit 1
fi

# Get the current commit hash of the main repo
main_repo_commit=$(git rev-parse HEAD)
echo "Current commit hash of main repo: $main_repo_commit"

main_repo_url=$(git config --get remote.origin.url)
echo "Main repo URL: $main_repo_url"

# Commit content
pushd "$full_tgt_dir" > /dev/null
git add .
if git diff --cached --quiet; then
echo "No changes to commit in $full_tgt_dir."
else
git commit -m "Sync from https://github.com/hl7-eu/imaging for commit $main_repo_commit from $main_repo_url."
git push origin "$current_branch"
echo "Committed and pushed changes in $full_tgt_dir."
fi
popd > /dev/null
done
39 changes: 39 additions & 0 deletions _preprocessMultiVersion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

versions=("4.0.1" "5.0.0" )

for version in "${versions[@]}"; do
if [ "$version" = "4.0.1" ]; then
context_version="R4"
build_dir="igs/imaging-r4"
elif [ "$version" = "5.0.0" ]; then
context_version="R5"
build_dir="igs/imaging-r5"
fi

echo remove all files from $build_dir
# rm -Rf $build_dir/*
find $build_dir -maxdepth 1 -type f -exec rm -f {} +
rm -Rf $build_dir/input
rm -Rf $build_dir/ig-template

echo copy all files to $build_dir
find ig-src/ -maxdepth 1 -type f -exec cp {} $build_dir \;
cp -R ig-src/input $build_dir
cp -R ig-src/ig-template $build_dir

# Process all liquid files
echo Processing liquid files
find $build_dir -type f -name "*.liquid.*" | while read file; do
if [ -f "$file" ]; then
file_path=${file}
clean_file_path=${file_path/\.liquid\./\.}
echo "- $file_path --> $clean_file_path"

# Process liquid template and inline version tags
content=$(npx --yes liquidjs -t @"$file" --context @"context-${context_version}.json")
echo "$content" > "$clean_file_path"
rm -f $file
fi
done
done
Loading