Skip to content

Commit

Permalink
Merge pull request #54 from medizininformatik-initiative/search-param…
Browse files Browse the repository at this point in the history
…-test

[WIP] Add Test for Search Params
  • Loading branch information
julsas authored Apr 2, 2024
2 parents 05861a2 + 1cd9946 commit f721e82
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,28 @@ jobs:

# The Coding provided (http://fhir.de/CodeSystem/bfarm/icd-10-gm#XX.X) is not in the value set http://fhir.de/ValueSet/bfarm/icd-10-gm, and a code is required from this value set.
EXPECTED_FAILS: VALIDATION_CONFORMANCE_DOTNET VALIDATION_CONFORMANCE_JAVA VALIDATION_EXAMPLES_JAVA

CI_SEARCH_PARAM_TEST:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:

- name: Checkout code
uses: actions/checkout@v2

- name: Create Search Param Bundle
run: .github/workflows/search-param-test/create-search-param-bundle.sh

- name: Run Blaze
run: docker-compose -f .github/workflows/search-param-test/blaze.yml up -d

- name: Wait for Blaze
run: .github/workflows/search-param-test/wait-for-url.sh http://localhost:8080/health

- name: Load Data
run: .github/workflows/search-param-test/load-data.sh

- name: Test Search
run: .github/workflows/search-param-test/test-search.sh
1 change: 1 addition & 0 deletions .github/workflows/search-param-test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
search-params.json
13 changes: 13 additions & 0 deletions .github/workflows/search-param-test/blaze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
services:
blaze:
image: "samply/blaze:0.25"
environment:
DB_SEARCH_PARAM_BUNDLE: "/app/search-params.json"
ENFORCE_REFERENTIAL_INTEGRITY: "false"
ports:
- "8080:8080"
volumes:
- "./search-params.json:/app/search-params.json:ro"
- "blaze-data:/app/data"
volumes:
blaze-data:
14 changes: 14 additions & 0 deletions .github/workflows/search-param-test/create-search-param-bundle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash -e

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

cat "$SCRIPT_DIR"/../../../fsh-generated/resources/SearchParameter-*.json |\
jq -n '{
"resourceType": "Bundle",
"type": "collection",
"entry": [
inputs | {
"resource": .
}
]
}' > "$SCRIPT_DIR/search-params.json"
8 changes: 8 additions & 0 deletions .github/workflows/search-param-test/load-data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash -e

SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
BASE="http://localhost:8080/fhir"

for f in "$SCRIPT_DIR"/../../../fsh-generated/resources/Condition-*.json; do
curl -sH 'Content-Type: application/fhir+json' -d @"$f" "$BASE/Condition"
done
43 changes: 43 additions & 0 deletions .github/workflows/search-param-test/test-search.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash -e

test() {
if [ "$2" = "$3" ]; then
echo "OK 👍: the $1 is $3"
else
echo "Fail 😞: the $1 is $2, expected $3"
exit 1
fi
}

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

search() {
curl -sH 'Prefer: handling=strict' "$BASE/Condition?$1&_summary=count" | jq .total
}

A54_4="http://fhir.de/CodeSystem/bfarm/icd-10-gm|A54.4"
M73_04="http://fhir.de/CodeSystem/bfarm/icd-10-gm|M73.04"
A="https://fhir.kbv.de/CodeSystem/KBV_CS_SFHIR_ICD_DIAGNOSESICHERHEIT|A"
G="https://fhir.kbv.de/CodeSystem/KBV_CS_SFHIR_ICD_DIAGNOSESICHERHEIT|G"
L="https://fhir.kbv.de/CodeSystem/KBV_CS_SFHIR_ICD_SEITENLOKALISATION|L"
R="https://fhir.kbv.de/CodeSystem/KBV_CS_SFHIR_ICD_SEITENLOKALISATION|R"
M="http://fhir.de/CodeSystem/icd-10-gm-mehrfachcodierungs-kennzeichen|*"
E="http://fhir.de/CodeSystem/icd-10-gm-mehrfachcodierungs-kennzeichen|†"

# Suchparameter: code (zu Vergleichszwecken)
test "A54.4 count" "$(search "code=$A54_4")" "1"
test "M73.04 count" "$(search "code=$M73_04")" "1"

# Suchparameter: icd10gm-diagnosesicherheit
test "A54.4/A count" "$(search "code=$A54_4&icd10gm-diagnosesicherheit=$A")" "0"
test "A54.4/G count" "$(search "code=$A54_4&icd10gm-diagnosesicherheit=$G")" "1"

# Suchparameter: icd10gm-seitenlokalisation
test "A54.4/L count" "$(search "code=$A54_4&icd10gm-seitenlokalisation=$L")" "1"
test "A54.4/R count" "$(search "code=$A54_4&icd10gm-seitenlokalisation=$R")" "0"

# Suchparameter: icd10gm-mehrfachcodierung
test "A54.4/M count" "$(search "code=$A54_4&icd10gm-mehrfachcodierung=$M")" "0"
test "A54.4/E count" "$(search "code=$A54_4&icd10gm-mehrfachcodierung=$E")" "1"
test "M73.04/M count" "$(search "code=$M73_04&icd10gm-mehrfachcodierung=$M")" "1"
test "M73.04/E count" "$(search "code=$M73_04&icd10gm-mehrfachcodierung=$E")" "0"
14 changes: 14 additions & 0 deletions .github/workflows/search-param-test/wait-for-url.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash -e

URL=$1
START_EPOCH="$(date +"%s")"

eclipsed() {
EPOCH="$(date +"%s")"
echo $((EPOCH - START_EPOCH))
}

# wait at maximum 120 seconds
while [[ ($(eclipsed) -lt 120) && ("$(curl -s -o /dev/null -w '%{response_code}' "$URL")" != "200") ]]; do
sleep 2
done

0 comments on commit f721e82

Please sign in to comment.