Here are some short cut APIs for Open Liberty API and IBM FHIR Server’s batch feature.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
############################################################################### | |
# (C) Copyright IBM Corp. 2021 | |
# | |
# SPDX-License-Identifier: Apache-2.0 | |
############################################################################### | |
set -ex | |
# Check the metadata | |
curl -k -v -u fhiruser:change-password https://localhost:9443/fhir-server/api/v4/metadata -o output.json 2> /dev/null | |
# Get the System Wide Operations | |
echo "CapabilitiesStatements - REST - Operation: " | |
jq -r '.rest[].operation[] | .name ' output.json | |
# List the Jobs | |
curl -k -v -u fhiradmin:change-password https://localhost:9443/ibm/api/batch/jobinstances -o jobs.json 2> /dev/null | |
# Output the list of Jobs | |
echo "List of Jobs: " | |
jq -r '.[] | "\(.jobName),\(.instanceId),\(.batchStatus),\(.instanceState)" ' jobs.json | |
# Create Export | |
curl --location --request GET 'https://localhost:9443/fhir-server/api/v4/$export?_outputFormat=application/fhir+ndjson' \ | |
-u fhiruser:change-password \ | |
--header 'X-FHIR-TENANT-ID: default' \ | |
--header 'Content-Type: application/fhir+json' \ | |
--header 'X-FHIR-BULKDATA-PROVIDER: default' \ | |
--header 'X-FHIR-BULKDATA-PROVIDER-OUTCOME: default' -k -I | awk -v FS=": " '/^content-location/{print $2}' 2> /dev/null > header_location | |
# Extract the JOB_ID | |
JOB_ID=$(cat header_location | sed 's|=| |' | awk '{print $2}' | tr -d '\r') | |
echo "JOB_ID: ${JOB_ID}" | |
# STOP | |
curl -k -X PUT -u fhiradmin:change-password "https://localhost:9443/ibm/api/batch/v4/jobinstances/"$JOB_ID"?action=stop" -o job.json -v 2> /dev/null | |
# STATUS | |
curl -k -X GET -u fhiradmin:change-password "https://localhost:9443/ibm/api/batch/v4/jobinstances/"$JOB_ID"" -o job.json -v 2> /dev/null | |
# RESTART | |
curl -k -X PUT -u fhiradmin:change-password "https://localhost:9443/ibm/api/batch/v4/jobinstances/"$JOB_ID"?action=restart" -o job.json -v 2> /dev/null | |
# DELETE | |
curl -k "https://localhost:9443/fhir-server/api/v4/\$bulkdata-status?job=${JOB_ID}" \ | |
-u fhiruser:change-password -X DELETE \ | |
--header 'X-FHIR-TENANT-ID: default' \ | |
--header 'Content-Type: application/fhir+json' \ | |
--header 'X-FHIR-BULKDATA-PROVIDER: default' \ | |
--header 'X-FHIR-BULKDATA-PROVIDER-OUTCOME: default' |