Skip to content
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 150 additions & 0 deletions .github/scripts/validation-patient.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
#!/bin/bash -e

SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
. "$SCRIPT_DIR/util.sh"

patient-valid-no-profile() {
cat <<END
{
"resourceType": "Patient"
}
END
}

patient-invalid-with-profile() {
cat <<END
{
"resourceType": "Patient",
"meta": {
"profile": "http://example.org/url-114730"
}
}
END
}

patient-valid-with-profile() {
cat <<END
{
"resourceType": "Patient",
"active": true,
"meta": {
"profile": "http://example.org/url-114730"
}
}
END
}

patient-valid-with-profile-as-bundle() {
cat <<END
{
"resourceType": "Patient",
"active": true,
"meta": {
"profile": "http://example.org/url-114730"
}
}
END
}

bundle-valid-patient-with-profile() {
cat <<END
{
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"resource": $(patient-valid-with-profile),
"request": {
"method": "POST",
"url": "/Patient"
}
}
]
}
END
}

structure-definition-patient() {
cat <<END
{
"resourceType": "StructureDefinition",
"name": "Patient-profile-1",
"status": "active",
"kind": "resource",
"abstract": false,
"url": "http://example.org/url-114730",
"type": "Patient",
"baseDefinition": "http://hl7.org/fhir/StructureDefinition/Patient",
"derivation": "constraint",
"differential": {
"element": [
{
"id": "patient-active-rule",
"path": "Patient.active",
"mustSupport": true,
"min": 1
}
]
}
}
END
}

BASE="http://localhost:8080/fhir"

echo "1: testing before Patient profile created"

echo "testing valid patient without profile"
RESULT_NO_PROFILE=$(patient-valid-no-profile | curl -s -H 'Accept: application/fhir+json' -H "Content-Type: application/fhir+json" -d @- "$BASE/Patient")
test "resource type" "$(echo "$RESULT_NO_PROFILE" | jq -r .resourceType)" "Patient"

echo "testing invalid patient with profile"
RESULT_INVALID_WITH_PROFILE=$(patient-invalid-with-profile | curl -s -H 'Accept: application/fhir+json' -H "Content-Type: application/fhir+json" -d @- "$BASE/Patient")
test "resource type" "$(echo "$RESULT_INVALID_WITH_PROFILE" | jq -r .resourceType)" "OperationOutcome"
test "issue diagnostics" "$(echo "$RESULT_INVALID_WITH_PROFILE" | jq -r .issue[0].diagnostics)" "Profile reference 'http://example.org/url-114730' has not been checked because it could not be found"

echo "testing valid patient with profile"
RESULT_VALID_WITH_PROFILE=$(patient-valid-with-profile | curl -s -H 'Accept: application/fhir+json' -H "Content-Type: application/fhir+json" -d @- "$BASE/Patient")
test "resource type" "$(echo "$RESULT_VALID_WITH_PROFILE" | jq -r .resourceType)" "OperationOutcome"
test "issue diagnostics" "$(echo "$RESULT_VALID_WITH_PROFILE" | jq -r .issue[0].diagnostics)" "Profile reference 'http://example.org/url-114730' has not been checked because it could not be found"

echo "testing valid patient with profile as bundle"
RESULT_BUNDLE_VALID_WITH_PROFILE=$(bundle-valid-patient-with-profile | curl -s -H 'Accept: application/fhir+json' -H "Content-Type: application/fhir+json" -d @- "$BASE")
test "resource type" "$(echo "$RESULT_VALID_WITH_PROFILE" | jq -r .resourceType)" "OperationOutcome"
test "issue diagnostics" "$(echo "$RESULT_VALID_WITH_PROFILE" | jq -r .issue[0].diagnostics)" "Profile reference 'http://example.org/url-114730' has not been checked because it could not be found"

echo "2: creating the patient profile"
RESULT_STRUCTURE_DEFINITION=$(structure-definition-patient | curl -s -H 'Accept: application/fhir+json' -H "Content-Type: application/fhir+json" -d @- "$BASE/StructureDefinition")
test "resource type" "$(echo "$RESULT_STRUCTURE_DEFINITION" | jq -r .resourceType)" "StructureDefinition"
STRUCTURE_DEFINITION_ID=$(echo "$RESULT_STRUCTURE_DEFINITION" | jq -r .id)

sleep 1
echo "3: testing after Patient profile created"
echo "testing valid patient without profile"
RESULT_NO_PROFILE=$(patient-valid-no-profile | curl -s -H 'Accept: application/fhir+json' -H "Content-Type: application/fhir+json" -d @- "$BASE/Patient")
test "resource type" "$(echo "$RESULT_NO_PROFILE" | jq -r .resourceType)" "Patient"

echo "testing invalid patient with profile"
RESULT_INVALID_WITH_PROFILE=$(patient-invalid-with-profile | curl -s -H 'Accept: application/fhir+json' -H "Content-Type: application/fhir+json" -d @- "$BASE/Patient")
test "resource type" "$(echo "$RESULT_INVALID_WITH_PROFILE" | jq -r .resourceType)" "OperationOutcome"
test "issue diagnostics" "$(echo "$RESULT_INVALID_WITH_PROFILE" | jq -r .issue[0].diagnostics)" "Patient.active: minimum required = 1, but only found 0 (from http://example.org/url-114730)"

echo "testing valid patient with profile"
RESULT_VALID_WITH_PROFILE=$(patient-valid-with-profile | curl -s -H 'Accept: application/fhir+json' -H "Content-Type: application/fhir+json" -d @- "$BASE/Patient")
test "resource type" "$(echo "$RESULT_VALID_WITH_PROFILE" | jq -r .resourceType)" "Patient"

echo "testing valid patient with profile as bundle"
RESULT_BUNDLE_VALID_WITH_PROFILE=$(bundle-valid-patient-with-profile | curl -s -H 'Accept: application/fhir+json' -H "Content-Type: application/fhir+json" -d @- "$BASE")
echo "$RESULT_BUNDLE_VALID_WITH_PROFILE"
test "resource type" "$(echo "$RESULT_BUNDLE_VALID_WITH_PROFILE" | jq -r .resourceType)" "Bundle"
test "response status" "$(echo "$RESULT_BUNDLE_VALID_WITH_PROFILE" | jq -r .entry[0].response.status)" "201"

sleep 1
echo "4: deleting Patient profile and testing invalid again"
RESULT_STRUCTURE_DEFINITION_DELETE=$(structure-definition-patient | curl -s -X DELETE -H 'Accept: application/fhir+json' -H "Content-Type: application/fhir+json" -d @- "$BASE/StructureDefinition/$STRUCTURE_DEFINITION_ID")
test "delete response is empty" "$RESULT_STRUCTURE_DEFINITION_DELETE" ""

echo "testing invalid patient with profile"
RESULT_INVALID_WITH_PROFILE=$(patient-invalid-with-profile | curl -s -H 'Accept: application/fhir+json' -H "Content-Type: application/fhir+json" -d @- "$BASE/Patient")
test "resource type" "$(echo "$RESULT_INVALID_WITH_PROFILE" | jq -r .resourceType)" "OperationOutcome"
test "issue diagnostics" "$(echo "$RESULT_INVALID_WITH_PROFILE" | jq -r .issue[0].diagnostics)" "Profile reference 'http://example.org/url-114730' has not been checked because it could not be found"
12 changes: 12 additions & 0 deletions .github/test-data/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,20 @@ kds-testdata-2024.0.1/tx: kds-testdata-2024.0.1
mkdir kds-testdata-2024.0.1/tx
cp kds-testdata-2024.0.1/resources/Bundle-mii-exa-test-data-bundle.json kds-testdata-2024.0.1/tx

kds-testdata-2025.0.0.zip:
wget -q https://github.com/medizininformatik-initiative/mii-testdata/releases/download/v2025.0.0-dev.7/kds-testdata-2025.0.0-20251021-124316.zip

kds-testdata-2025.0.0: kds-testdata-2025.0.0.zip
unzip kds-testdata-2025.0.0-20251021-124316.zip

kds-testdata-2025.0.0/tx: kds-testdata-2025.0.0
mkdir kds-testdata-2025.0.0/tx
cp kds-testdata-2025.0.0-20251021-124316/resources/Bundle-mii-exa-test-data-bundle-pat-1.json kds-testdata-2025.0.0/tx

clean:
rm -rf kds-testdata-2024.0.1
rm kds-testdata-2024.0.1.zip
rm -rf kds-testdata-2025.0.0
rm kds-testdata-2025.0.0-20251021-124316.zip

.PHONY: clean
1 change: 1 addition & 0 deletions .github/validation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
149 changes: 149 additions & 0 deletions .github/validation/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions .github/validation/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"dependencies": {
"de.basisprofil.r4": "^1.5.4",
"de.einwilligungsmanagement": "^2.0.1",
"de.gematik.isik-basismodul": "^4.0.3",
"de.medizininformatikinitiative.kerndatensatz.bildgebung": "^2026.0.0-ballot",
"de.medizininformatikinitiative.kerndatensatz.biobank": "^2026.0.0-ballot1",
"de.medizininformatikinitiative.kerndatensatz.consent": "^2025.0.4",
"de.medizininformatikinitiative.kerndatensatz.diagnose": "^2025.0.1",
"de.medizininformatikinitiative.kerndatensatz.fall": "^2025.0.1",
"de.medizininformatikinitiative.kerndatensatz.icu": "^2025.0.4",
"de.medizininformatikinitiative.kerndatensatz.laborbefund": "^2025.0.2",
"de.medizininformatikinitiative.kerndatensatz.medikation": "^2025.0.0",
"de.medizininformatikinitiative.kerndatensatz.meta": "^2025.0.3",
"de.medizininformatikinitiative.kerndatensatz.mikrobiologie": "^2025.0.1",
"de.medizininformatikinitiative.kerndatensatz.molgen": "^2026.0.0-ballot.2",
"de.medizininformatikinitiative.kerndatensatz.patho": "^2026.0.0-ballot",
"de.medizininformatikinitiative.kerndatensatz.person": "^2025.0.1",
"de.medizininformatikinitiative.kerndatensatz.prozedur": "^2025.0.1",
"de.medizininformatikinitiative.kerndatensatz.studie": "^2026.0.0-ballot",
"eu.miabis.r4": "^0.2.0",
"hl7.fhir.r4b.core": "^4.3.0",
"hl7.fhir.uv.extensions": "^5.3.0-ballot-tc1",
"hl7.fhir.uv.genomics-reporting": "^3.0.0",
"hl7.terminology.r5": "^6.5.0"
}
}
15 changes: 15 additions & 0 deletions .github/validation/upload-definition.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash -e

FILENAME=$1
BASE="http://localhost:8080/fhir"

RESOURCE_TYPE="$(jq -r .resourceType "$FILENAME")"
if [[ "$RESOURCE_TYPE" =~ ValueSet|CodeSystem|StructureDefinition ]]; then
URL="$(jq -r .url "$FILENAME")"
if [[ "$URL" =~ http://unitsofmeasure.org|http://snomed.info/sct|http://loinc.org|urn:ietf:bcp:13 ]]; then
echo "Skip creating the code system or value set $URL which is internal in Blaze"
else
echo "Upload $FILENAME"
curl -sf -H "Content-Type: application/fhir+json" -H "Prefer: return=minimal" -d @"$FILENAME" "$BASE/$RESOURCE_TYPE"
fi
fi
8 changes: 8 additions & 0 deletions .github/validation/upload-definitions-from-dir.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash -e

SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
DIR="$1"

# Upload Resources
find "$DIR" -name "*.json" -and -not -name "package.json" -and -not -name ".package-lock.json" -and -not -name ".index.json" -print0 |\
xargs -0 -P 4 -I {} "$SCRIPT_DIR/upload-definition.sh" {}
7 changes: 7 additions & 0 deletions .github/validation/upload-testdata-from-dir.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash -e

SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
DIR="$1"

find "$DIR" -name "*.json" -and -not -name "Bundle*.json" -and -not -name "package.json" -and -not -name ".package-lock.json" -and -not -name ".index.json" -print0 |\
xargs -0 -I {} "$SCRIPT_DIR/upload-testdata.sh" {}
Loading