Skip to content

Commit 210ce0e

Browse files
author
Tobias Machein
committed
968: add Validation Support for Resources
Closes #968 968: add Validation Support for Resources
1 parent 74bb7b4 commit 210ce0e

File tree

38 files changed

+1494
-189
lines changed

38 files changed

+1494
-189
lines changed
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
#!/bin/bash -e
2+
3+
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
4+
. "$SCRIPT_DIR/util.sh"
5+
6+
patient-valid-no-profile() {
7+
cat <<END
8+
{
9+
"resourceType": "Patient"
10+
}
11+
END
12+
}
13+
14+
patient-invalid-with-profile() {
15+
cat <<END
16+
{
17+
"resourceType": "Patient",
18+
"meta": {
19+
"profile": "http://example.org/url-114730"
20+
}
21+
}
22+
END
23+
}
24+
25+
patient-valid-with-profile() {
26+
cat <<END
27+
{
28+
"resourceType": "Patient",
29+
"active": true,
30+
"meta": {
31+
"profile": "http://example.org/url-114730"
32+
}
33+
}
34+
END
35+
}
36+
37+
patient-valid-with-profile-as-bundle() {
38+
cat <<END
39+
{
40+
"resourceType": "Patient",
41+
"active": true,
42+
"meta": {
43+
"profile": "http://example.org/url-114730"
44+
}
45+
}
46+
END
47+
}
48+
49+
bundle-valid-patient-with-profile() {
50+
cat <<END
51+
{
52+
"resourceType": "Bundle",
53+
"type": "transaction",
54+
"entry": [
55+
{
56+
"resource": $(patient-valid-with-profile),
57+
"request": {
58+
"method": "POST",
59+
"url": "/Patient"
60+
}
61+
}
62+
]
63+
}
64+
END
65+
}
66+
67+
structure-definition-patient() {
68+
cat <<END
69+
{
70+
"resourceType": "StructureDefinition",
71+
"name": "Patient-profile-1",
72+
"status": "active",
73+
"kind": "resource",
74+
"abstract": false,
75+
"url": "http://example.org/url-114730",
76+
"type": "Patient",
77+
"baseDefinition": "http://hl7.org/fhir/StructureDefinition/Patient",
78+
"derivation": "constraint",
79+
"differential": {
80+
"element": [
81+
{
82+
"id": "patient-active-rule",
83+
"path": "Patient.active",
84+
"mustSupport": true,
85+
"min": 1
86+
}
87+
]
88+
}
89+
}
90+
END
91+
}
92+
93+
BASE="http://localhost:8080/fhir"
94+
95+
echo "1: testing before Patient profile created"
96+
97+
echo "testing valid patient without profile"
98+
RESULT_NO_PROFILE=$(patient-valid-no-profile | curl -s -H 'Accept: application/fhir+json' -H "Content-Type: application/fhir+json" -d @- "$BASE/Patient")
99+
test "resource type" "$(echo "$RESULT_NO_PROFILE" | jq -r .resourceType)" "Patient"
100+
101+
echo "testing invalid patient with profile"
102+
RESULT_INVALID_WITH_PROFILE=$(patient-invalid-with-profile | curl -s -H 'Accept: application/fhir+json' -H "Content-Type: application/fhir+json" -d @- "$BASE/Patient")
103+
test "resource type" "$(echo "$RESULT_INVALID_WITH_PROFILE" | jq -r .resourceType)" "OperationOutcome"
104+
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"
105+
106+
echo "testing valid patient with profile"
107+
RESULT_VALID_WITH_PROFILE=$(patient-valid-with-profile | curl -s -H 'Accept: application/fhir+json' -H "Content-Type: application/fhir+json" -d @- "$BASE/Patient")
108+
test "resource type" "$(echo "$RESULT_VALID_WITH_PROFILE" | jq -r .resourceType)" "OperationOutcome"
109+
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"
110+
111+
echo "testing valid patient with profile as bundle"
112+
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")
113+
test "resource type" "$(echo "$RESULT_VALID_WITH_PROFILE" | jq -r .resourceType)" "OperationOutcome"
114+
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"
115+
116+
echo "2: creating the patient profile"
117+
RESULT_STRUCTURE_DEFINITION=$(structure-definition-patient | curl -s -H 'Accept: application/fhir+json' -H "Content-Type: application/fhir+json" -d @- "$BASE/StructureDefinition")
118+
test "resource type" "$(echo "$RESULT_STRUCTURE_DEFINITION" | jq -r .resourceType)" "StructureDefinition"
119+
STRUCTURE_DEFINITION_ID=$(echo "$RESULT_STRUCTURE_DEFINITION" | jq -r .id)
120+
121+
sleep 1
122+
echo "3: testing after Patient profile created"
123+
echo "testing valid patient without profile"
124+
RESULT_NO_PROFILE=$(patient-valid-no-profile | curl -s -H 'Accept: application/fhir+json' -H "Content-Type: application/fhir+json" -d @- "$BASE/Patient")
125+
test "resource type" "$(echo "$RESULT_NO_PROFILE" | jq -r .resourceType)" "Patient"
126+
127+
echo "testing invalid patient with profile"
128+
RESULT_INVALID_WITH_PROFILE=$(patient-invalid-with-profile | curl -s -H 'Accept: application/fhir+json' -H "Content-Type: application/fhir+json" -d @- "$BASE/Patient")
129+
test "resource type" "$(echo "$RESULT_INVALID_WITH_PROFILE" | jq -r .resourceType)" "OperationOutcome"
130+
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)"
131+
132+
echo "testing valid patient with profile"
133+
RESULT_VALID_WITH_PROFILE=$(patient-valid-with-profile | curl -s -H 'Accept: application/fhir+json' -H "Content-Type: application/fhir+json" -d @- "$BASE/Patient")
134+
test "resource type" "$(echo "$RESULT_VALID_WITH_PROFILE" | jq -r .resourceType)" "Patient"
135+
136+
echo "testing valid patient with profile as bundle"
137+
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")
138+
echo "$RESULT_BUNDLE_VALID_WITH_PROFILE"
139+
test "resource type" "$(echo "$RESULT_BUNDLE_VALID_WITH_PROFILE" | jq -r .resourceType)" "Bundle"
140+
test "response status" "$(echo "$RESULT_BUNDLE_VALID_WITH_PROFILE" | jq -r .entry[0].response.status)" "201"
141+
142+
sleep 1
143+
echo "4: deleting Patient profile and testing invalid again"
144+
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")
145+
test "delete response is empty" "$RESULT_STRUCTURE_DEFINITION_DELETE" ""
146+
147+
echo "testing invalid patient with profile"
148+
RESULT_INVALID_WITH_PROFILE=$(patient-invalid-with-profile | curl -s -H 'Accept: application/fhir+json' -H "Content-Type: application/fhir+json" -d @- "$BASE/Patient")
149+
test "resource type" "$(echo "$RESULT_INVALID_WITH_PROFILE" | jq -r .resourceType)" "OperationOutcome"
150+
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"

.github/test-data/Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,20 @@ kds-testdata-2024.0.1/tx: kds-testdata-2024.0.1
88
mkdir kds-testdata-2024.0.1/tx
99
cp kds-testdata-2024.0.1/resources/Bundle-mii-exa-test-data-bundle.json kds-testdata-2024.0.1/tx
1010

11+
kds-testdata-2025.0.0.zip:
12+
wget -q https://github.com/medizininformatik-initiative/mii-testdata/releases/download/v2025.0.0-dev.7/kds-testdata-2025.0.0-20251021-124316.zip
13+
14+
kds-testdata-2025.0.0: kds-testdata-2025.0.0.zip
15+
unzip kds-testdata-2025.0.0-20251021-124316.zip
16+
17+
kds-testdata-2025.0.0/tx: kds-testdata-2025.0.0
18+
mkdir kds-testdata-2025.0.0/tx
19+
cp kds-testdata-2025.0.0-20251021-124316/resources/Bundle-mii-exa-test-data-bundle-pat-1.json kds-testdata-2025.0.0/tx
20+
1121
clean:
1222
rm -rf kds-testdata-2024.0.1
1323
rm kds-testdata-2024.0.1.zip
24+
rm -rf kds-testdata-2025.0.0
25+
rm kds-testdata-2025.0.0-20251021-124316.zip
1426

1527
.PHONY: clean

.github/validation/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.github/validation/package-lock.json

Lines changed: 149 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/validation/package.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"dependencies": {
3+
"de.basisprofil.r4": "^1.5.4",
4+
"de.einwilligungsmanagement": "^2.0.1",
5+
"de.gematik.isik-basismodul": "^4.0.3",
6+
"de.medizininformatikinitiative.kerndatensatz.bildgebung": "^2026.0.0-ballot",
7+
"de.medizininformatikinitiative.kerndatensatz.biobank": "^2026.0.0-ballot1",
8+
"de.medizininformatikinitiative.kerndatensatz.consent": "^2025.0.4",
9+
"de.medizininformatikinitiative.kerndatensatz.diagnose": "^2025.0.1",
10+
"de.medizininformatikinitiative.kerndatensatz.fall": "^2025.0.1",
11+
"de.medizininformatikinitiative.kerndatensatz.icu": "^2025.0.4",
12+
"de.medizininformatikinitiative.kerndatensatz.laborbefund": "^2025.0.2",
13+
"de.medizininformatikinitiative.kerndatensatz.medikation": "^2025.0.0",
14+
"de.medizininformatikinitiative.kerndatensatz.meta": "^2025.0.3",
15+
"de.medizininformatikinitiative.kerndatensatz.mikrobiologie": "^2025.0.1",
16+
"de.medizininformatikinitiative.kerndatensatz.molgen": "^2026.0.0-ballot.2",
17+
"de.medizininformatikinitiative.kerndatensatz.patho": "^2026.0.0-ballot",
18+
"de.medizininformatikinitiative.kerndatensatz.person": "^2025.0.1",
19+
"de.medizininformatikinitiative.kerndatensatz.prozedur": "^2025.0.1",
20+
"de.medizininformatikinitiative.kerndatensatz.studie": "^2026.0.0-ballot",
21+
"eu.miabis.r4": "^0.2.0",
22+
"hl7.fhir.r4b.core": "^4.3.0",
23+
"hl7.fhir.uv.extensions": "^5.3.0-ballot-tc1",
24+
"hl7.fhir.uv.genomics-reporting": "^3.0.0",
25+
"hl7.terminology.r5": "^6.5.0"
26+
}
27+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash -e
2+
3+
FILENAME=$1
4+
BASE="http://localhost:8080/fhir"
5+
6+
RESOURCE_TYPE="$(jq -r .resourceType "$FILENAME")"
7+
if [[ "$RESOURCE_TYPE" =~ ValueSet|CodeSystem|StructureDefinition ]]; then
8+
URL="$(jq -r .url "$FILENAME")"
9+
if [[ "$URL" =~ http://unitsofmeasure.org|http://snomed.info/sct|http://loinc.org|urn:ietf:bcp:13 ]]; then
10+
echo "Skip creating the code system or value set $URL which is internal in Blaze"
11+
else
12+
echo "Upload $FILENAME"
13+
curl -sf -H "Content-Type: application/fhir+json" -H "Prefer: return=minimal" -d @"$FILENAME" "$BASE/$RESOURCE_TYPE"
14+
fi
15+
fi
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash -e
2+
3+
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
4+
DIR="$1"
5+
6+
# Upload Resources
7+
find "$DIR" -name "*.json" -and -not -name "package.json" -and -not -name ".package-lock.json" -and -not -name ".index.json" -print0 |\
8+
xargs -0 -P 4 -I {} "$SCRIPT_DIR/upload-definition.sh" {}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash -e
2+
3+
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
4+
DIR="$1"
5+
6+
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 |\
7+
xargs -0 -I {} "$SCRIPT_DIR/upload-testdata.sh" {}

0 commit comments

Comments
 (0)