From ea97ca9766e2996957772e4368581afc1130000d Mon Sep 17 00:00:00 2001 From: "eugene.koon" Date: Fri, 13 Sep 2024 11:57:35 -0400 Subject: [PATCH 1/4] Add sample allergyintolerance.json and test all samples --- .github/workflows/test.yml | 104 ++++++++------- sample_data/allergyintolerance.json | 124 ++++++++++++++++++ .../{example_patient.json => patient.json} | 0 3 files changed, 184 insertions(+), 44 deletions(-) create mode 100644 sample_data/allergyintolerance.json rename sample_data/{example_patient.json => patient.json} (100%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bd2ec3bd..a0602e76 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,10 +20,8 @@ jobs: steps: - uses: actions/checkout@v4.1.7 - - name: Build - run: | - # Start up the docker in docker - docker compose up -d + - name: Create containers with docker compose + run: docker compose up -d - name: Wait for application to be ready run: | @@ -59,54 +57,72 @@ jobs: # Check if the HTTP status code is 200 if [ "$response" -eq 200 ]; then - echo "Request successful with status code 200." + echo "Request ${filename} successful with status code 200." else - echo "Request failed with status code $response." + echo "Request ${filename} failed with status code $response." exit 1 fi - - name: Test curl request to add new patient + - name: Test curl request to add new service run: | - # Perform PUT request to add a new patient - response=$(curl -s -o /dev/null -w "%{http_code}" -X PUT \ - -T sample_data/example_patient.json \ - -H "Content-Type: application/json" \ - "http://${CONTAINER_IP}:${PORT}/${VERSION}/Patient/example") - - # Check if the HTTP status code is 200 - if [ "$response" -eq 200 ]; then - echo "Request successful with status code 200." - else - echo "Request failed with status code $response." - exit 1 - fi + for filename_with_extension_and_path in sample_data/*.json; do + filename_with_extension="${filename_with_extension_and_path##*/}" + filename="${filename_with_extension%%.*}" + + echo "Perform PUT request to add a new ${filename}" + response=$(curl -s -o /dev/null -w "%{http_code}" -X PUT \ + -T ${filename_with_extension_and_path} \ + -H "Content-Type: application/json" \ + "http://${CONTAINER_IP}:${PORT}/${VERSION}/${filename}/example") + + # Check if the HTTP status code is 200 + if [ "$response" -eq 200 ]; then + echo "Request ${filename} successful with status code 200." + else + echo "Request ${filename} failed with status code $response." + exit 1 + fi + done - - name: Test curl request for existing patient + - name: Test curl request for existing service run: | - # Perform GET request get the newly added patient - response=$(curl -s -o /dev/null -w "%{http_code}" -X GET \ - -H "Content-Type: application/json" \ - "http://${CONTAINER_IP}:${PORT}/${VERSION}/Patient/example") - - # Check if the HTTP status code is 200 - if [ "$response" -eq 200 ]; then - echo "Request successful with status code 200." - else - echo "Request failed with status code $response." - exit 1 - fi + for filename_with_extension_and_path in sample_data/*.json; do + filename_with_extension="${filename_with_extension_and_path##*/}" + filename="${filename_with_extension%%.*}" + + echo "Perform GET request get the newly added ${filename}" + response=$(curl -s -o /dev/null -w "%{http_code}" -X GET \ + -H "Content-Type: application/json" \ + "http://${CONTAINER_IP}:${PORT}/${VERSION}/${filename}/example") + + # Check if the HTTP status code is 200 + if [ "$response" -eq 200 ]; then + echo "Request ${filename} successful with status code 200." + else + echo "Request ${filename} failed with status code $response." + exit 1 + fi + done - name: Test curl request for non-existing patient to fail run: | - # Perform GET request for a non-existing patient - response=$(curl -s -o /dev/null -w "%{http_code}" -X GET \ - -H "Content-Type: application/json" \ - "http://${CONTAINER_IP}:${PORT}/${VERSION}/Patient/no_show") + for filename_with_extension_and_path in sample_data/*.json; do + filename_with_extension="${filename_with_extension_and_path##*/}" + filename="${filename_with_extension%%.*}" + + echo "Perform GET request for a non-existing ${filename}" + response=$(curl -s -o /dev/null -w "%{http_code}" -X GET \ + -H "Content-Type: application/json" \ + "http://${CONTAINER_IP}:${PORT}/${VERSION}/Patient/no_show") + + # Check if the HTTP status code is 200 + if [ "$response" -ne 200 ]; then + echo "Request ${filename} successful with status code $response (non 200)." + else + echo "Request ${filename} failed with undesired status code 200." + exit 1 + fi + done - # Check if the HTTP status code is 200 - if [ "$response" -ne 200 ]; then - echo "Request successful with status code $response (non 200)." - else - echo "Request failed with undesired status code 200." - exit 1 - fi + - name: Shutdown containers with docker compose + run: docker compose down diff --git a/sample_data/allergyintolerance.json b/sample_data/allergyintolerance.json new file mode 100644 index 00000000..c9336c37 --- /dev/null +++ b/sample_data/allergyintolerance.json @@ -0,0 +1,124 @@ +{ + "resourceType": "AllergyIntolerance", + "id": "example", + "identifier": [ + { + "system": "http://acme.com/ids/patients/risks", + "value": "49476534" + } + ], + "clinicalStatus": { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical", + "code": "active", + "display": "Active" + } + ] + }, + "verificationStatus": { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/allergyintolerance-verification", + "code": "confirmed", + "display": "Confirmed" + } + ] + }, + "type": { + "coding": [ + { + "system": "http://hl7.org/fhir/allergy-intolerance-type", + "code": "allergy", + "display": "Allergy" + } + ] + }, + "category": ["food"], + "criticality": "high", + "code": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "227493005", + "display": "Cashew nuts" + } + ] + }, + "patient": { + "reference": "Patient/example" + }, + "onsetDateTime": "2004", + "recordedDate": "2014-10-09T14:58:00+11:00", + "recorder": { + "reference": "Practitioner/example" + }, + "asserter": { + "reference": "Patient/example" + }, + "note": [ + { + "text": "The criticality is high becasue of the observed anaphylactic reaction when challenged with cashew extract." + } + ], + "reaction": [ + { + "substance": { + "coding": [ + { + "system": "http://www.nlm.nih.gov/research/umls/rxnorm", + "code": "1160593", + "display": "cashew nut allergenic extract Injectable Product" + } + ] + }, + "manifestation": [ + { + "concept": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "39579001", + "display": "Anaphylactic reaction" + } + ] + } + } + ], + "description": "Challenge Protocol. Severe reaction to subcutaneous cashew extract. Epinephrine administered", + "onset": "2012-06-12", + "severity": "severe", + "exposureRoute": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "34206005", + "display": "Subcutaneous route" + } + ] + } + }, + { + "manifestation": [ + { + "concept": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "64305001", + "display": "Urticaria" + } + ] + } + } + ], + "onset": "2004", + "severity": "moderate", + "note": [ + { + "text": "The patient reports that the onset of urticaria was within 15 minutes of eating cashews." + } + ] + } + ] +} diff --git a/sample_data/example_patient.json b/sample_data/patient.json similarity index 100% rename from sample_data/example_patient.json rename to sample_data/patient.json From f82df6b6bf19437a90bf0652060cdab4bbff3a88 Mon Sep 17 00:00:00 2001 From: "eugene.koon" Date: Fri, 13 Sep 2024 12:04:13 -0400 Subject: [PATCH 2/4] update example id to make it more clear --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a0602e76..5e42f906 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -73,7 +73,7 @@ jobs: response=$(curl -s -o /dev/null -w "%{http_code}" -X PUT \ -T ${filename_with_extension_and_path} \ -H "Content-Type: application/json" \ - "http://${CONTAINER_IP}:${PORT}/${VERSION}/${filename}/example") + "http://${CONTAINER_IP}:${PORT}/${VERSION}/${filename}/example_${filename}") # Check if the HTTP status code is 200 if [ "$response" -eq 200 ]; then @@ -93,7 +93,7 @@ jobs: echo "Perform GET request get the newly added ${filename}" response=$(curl -s -o /dev/null -w "%{http_code}" -X GET \ -H "Content-Type: application/json" \ - "http://${CONTAINER_IP}:${PORT}/${VERSION}/${filename}/example") + "http://${CONTAINER_IP}:${PORT}/${VERSION}/${filename}/example_${filename}") # Check if the HTTP status code is 200 if [ "$response" -eq 200 ]; then @@ -113,7 +113,7 @@ jobs: echo "Perform GET request for a non-existing ${filename}" response=$(curl -s -o /dev/null -w "%{http_code}" -X GET \ -H "Content-Type: application/json" \ - "http://${CONTAINER_IP}:${PORT}/${VERSION}/Patient/no_show") + "http://${CONTAINER_IP}:${PORT}/${VERSION}/Patient/missing_${filename}") # Check if the HTTP status code is 200 if [ "$response" -ne 200 ]; then From 16d25b4890d1371fc5f46539a8b2f2ae7cf02b9c Mon Sep 17 00:00:00 2001 From: "eugene.koon" Date: Fri, 13 Sep 2024 12:06:17 -0400 Subject: [PATCH 3/4] update examples json id --- sample_data/allergyintolerance.json | 2 +- sample_data/patient.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sample_data/allergyintolerance.json b/sample_data/allergyintolerance.json index c9336c37..17bb6d50 100644 --- a/sample_data/allergyintolerance.json +++ b/sample_data/allergyintolerance.json @@ -1,6 +1,6 @@ { "resourceType": "AllergyIntolerance", - "id": "example", + "id": "example_allergyintolerance", "identifier": [ { "system": "http://acme.com/ids/patients/risks", diff --git a/sample_data/patient.json b/sample_data/patient.json index eb5a7865..d75ca7e7 100644 --- a/sample_data/patient.json +++ b/sample_data/patient.json @@ -1,6 +1,6 @@ { "resourceType": "Patient", - "id": "example", + "id": "example_patient", "text": { "status": "generated", "div": "
\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t
NamePeter James \n Chalmers ("Jim")\n
Address534 Erewhon, Pleasantville, Vic, 3999
ContactsHome: unknown. Work: (03) 5555 6473
IdMRN: 12345 (Acme Healthcare)
\n\t\t
" From 0ca3bbc1875556fd96493bcbb8a3481ac7da0d7f Mon Sep 17 00:00:00 2001 From: "eugene.koon" Date: Fri, 13 Sep 2024 12:09:45 -0400 Subject: [PATCH 4/4] cleanup --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5e42f906..bdcda4d5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -57,9 +57,9 @@ jobs: # Check if the HTTP status code is 200 if [ "$response" -eq 200 ]; then - echo "Request ${filename} successful with status code 200." + echo "Request successful with status code 200." else - echo "Request ${filename} failed with status code $response." + echo "Request failed with status code $response." exit 1 fi