Skip to content

Commit

Permalink
Merge pull request #34 from gematik/feature/example-validation
Browse files Browse the repository at this point in the history
Validieren von neuen Beispielen mit HAPI Validator
  • Loading branch information
florianschoffke authored Feb 19, 2024
2 parents 668a923 + a3a0bba commit 994c4a1
Show file tree
Hide file tree
Showing 3 changed files with 513 additions and 0 deletions.
97 changes: 97 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Validate Examples

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ main ]
pull_request:
branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
REFERENZVALIDATOR_VERSION: 2.0.2
PATH_TO_EXAMPLES: './temp_folder/'
FHIR_VERSION: "4.0"
INPUT_JAVA_VALIDATION_OPTIONS: "-tx http://tx.fhir.org -debug -allow-example-urls true"
IG_DEPENDENCIES: "-ig de.basisprofil.r4#1.4.0 -ig hl7.fhir.r4.core#4.0.1 -ig kbv.ita.for#1.1.0 -ig kbv.ita.erp#1.1.x -ig de.gematik.erezept-workflow.r4"

jobs:
CI_EXAMPLES_VALIDATION:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: '20'

# Identify and Copy Changed .json and .xml Files
- name: Identify and Copy Changed .json and .xml Files
run: |
mkdir -p $PATH_TO_EXAMPLES # Create a temp folder
git fetch origin main:main
git diff --name-only main | grep -E '\.(json|xml)$' | xargs -I {} cp {} $PATH_TO_EXAMPLES/
echo "Number of changed files to validate: " && ls -1 $PATH_TO_EXAMPLES | wc -l
# Install Java runtime (only needed if you want to run the offical HL7 Java validator)
- name: Setup Java JDK
uses: actions/setup-java@v3
with:
distribution: 'microsoft'
java-version: '17'


# --------------------------------------------------------------------------------------------------- #
# JAVA Validator #
# --------------------------------------------------------------------------------------------------- #

- name: Check if Java is installed
run: |
if ! command -v java &> /dev/null
then
echo "java could not be found. Please see actions/setup-java to set it up before running this action."
exit 1
fi
shell: bash

- name: Download Java Validator
run: |
CHECK_JAVA_VERSION=$(java -version 2>&1 | head -1 | cut -d'"' -f2)
echo "JAVA_VERSION: $CHECK_JAVA_VERSION"
wget -q https://github.com/gematik/app-referencevalidator/releases/download/$REFERENZVALIDATOR_VERSION/referencevalidator-cli-$REFERENZVALIDATOR_VERSION.jar
echo "REFERENZVALIDATOR_VERSION: $REFERENZVALIDATOR_VERSION"
shell: bash

- name: Install jq
run: |
sudo apt-get update > /dev/null
sudo apt-get install --no-install-recommends -y jq findutils curl ca-certificates > /dev/null
shell: bash

- name: Validate all example resources in scope of the repository
run: |
for p in $PATH_TO_EXAMPLES;
do
# Ensure directory ends with "/"
if [[ ! "$p" =~ .*/$ ]]; then
p="$p/"
fi
for f in $p*;
do
java -jar referencevalidator-cli-$REFERENZVALIDATOR_VERSION.jar erp $f --accepted-encodings xml --accepted-encodings json --no-profile-validity-period-check
done
done
- name: Cleanup
if: always()
run: rm -rf temp_folder
31 changes: 31 additions & 0 deletions 008_Request_Communication_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"resourceType" : "Communication",
"id" : "39004dfc-6e44-471a-942d-86c73293eb94",
"meta" : {
"profile" : [ "https://gematik.de/fhir/erp/StructureDefinition/GEM_ERP_PR_Communication_Representative|1.2" ]
},
"basedOn" : [ {
"reference" : "Task/160.000.226.119.771.59/$accept?ac=2c8be8db04cad4eb3a7fb5f74950cfe82b057d1f83ef87e6c4bbf7347099b7e2"
} ],
"status" : "unknown",
"recipient" : [ {
"identifier" : {
"system" : "http://fhir.de/sid/gkv/kvid-10",
"value" : "X110465770"
}
} ],
"payload" : [ {
"extension" : [ {
"url" : "https://gematik.de/fhir/erp/StructureDefinition/GEM_ERP_EX_SubstitutionAllowedType",
"valueBoolean" : true
}, {
"url" : "https://gematik.de/fhir/erp/StructureDefinition/GEM_ERP_EX_PrescriptionType",
"valueCoding" : {
"system" : "https://gematik.de/fhir/erp/CodeSystem/GEM_ERP_CS_FlowType",
"code" : "160",
"display" : "Muster 16 (Apothekenpflichtige Arzneimittel)"
}
} ],
"contentString" : "Wenn Chuck Norris Wäsche wäscht, werden sogar schwarze Hemden strahlend weiß."
} ]
}
Loading

0 comments on commit 994c4a1

Please sign in to comment.