Skip to content
This repository has been archived by the owner on Feb 7, 2025. It is now read-only.

Commit

Permalink
Add TI hurl scripts (#1053)
Browse files Browse the repository at this point in the history
* Moved RS hurl scripts into rs/ folder

* Added ti hurl scripts

* Removed deprecated demographics script

* Updated scripts and docs
basiliskus authored May 23, 2024
1 parent 3f25d02 commit bd229ac
Showing 13 changed files with 269 additions and 42 deletions.
44 changes: 3 additions & 41 deletions scripts/hurl/readme.md
Original file line number Diff line number Diff line change
@@ -6,46 +6,8 @@

## ReportStream

### Usage
The hurl script to send requests to ReportStream's endpoints is in [rs/](./rs/)

```
Usage: hrl <HURL_FILE> [OPTIONS]
## CDC Intermediary

Options:
-f <REL_PATH> The path to the hl7/fhir file to submit, relative the root path (Required for waters API)
-r <ROOT_PATH> The root path to the hl7/fhir files (Default: $CDCTI_HOME/examples/Test/)
-e [local | staging] The environment to run the test in (Default: local)
-c <CLIENT_ID> The client id to use (Default: flexion)
-s <CLIENT_SENDER> The client sender to use (Default: simulated-lab)
-x <KEY_PATH> The path to the client private key for the environment
-i <SUBMISSION_ID> The submissionId to call the history API with (Required for history API)
-v Verbose mode
-h Display this help and exit
```

### Examples

Sending an order to local environment
```
./hrl waters.hurl -f Orders/003_AL_ORM_O01_NBS_Fully_Populated_0_initial_message.hl7
```

Sending a result to local environment
```
./hrl waters.hurl -f Results/002_AL_ORU_R01_NBS_Fully_Populated_0_initial_message.hl7
```

Sending an order to staging
```
./hrl waters.hurl -f Orders/003_AL_ORM_O01_NBS_Fully_Populated_0_initial_message.hl7 -e staging -x /path/to/staging/private/key
```

Checking the history in local environment for a submision id
```
./hrl history.hurl -i 100
```

Checking the history in staging for a submision id
```
./hrl history.hurl -i 100 -e staging -x /path/to/staging/private/key
```
The hurl script to send requests to the CDC Intermediary's endpoints is in [ti/](./ti/)
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/hurl/hrl → scripts/hurl/rs/hrl
Original file line number Diff line number Diff line change
@@ -116,7 +116,7 @@ hurl \
--variable client-id=$client_id \
--variable client-sender=$client_sender \
--variable jwt=$(jwt encode --exp='+5min' --jti $(uuidgen) --alg RS256 -k $client_id.$client_sender -i $client_id.$client_sender -s $client_id.$client_sender -a $host --no-iat -S @$secret) \
$verbose \
$submission_id \
$verbose \
$hurl_file \
$@
45 changes: 45 additions & 0 deletions scripts/hurl/rs/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# ReportStream Hurl Script

## Usage

```
Usage: ./hrl <HURL_FILE> [OPTIONS]
Options:
-f <REL_PATH> The path to the hl7/fhir file to submit, relative the root path (Required for waters API)
-r <ROOT_PATH> The root path to the hl7/fhir files (Default: $CDCTI_HOME/examples/Test/)
-e [local | staging] The environment to run the test in (Default: local)
-c <CLIENT_ID> The client id to use (Default: flexion)
-s <CLIENT_SENDER> The client sender to use (Default: simulated-lab)
-x <KEY_PATH> The path to the client private key for the environment
-i <SUBMISSION_ID> The submissionId to call the history API with (Required for history API)
-v Verbose mode
-h Display this help and exit
```

## Examples

Sending an order to local environment
```
./hrl waters.hurl -f Orders/003_AL_ORM_O01_NBS_Fully_Populated_0_initial_message.hl7
```

Sending a result to local environment
```
./hrl waters.hurl -f Results/002_AL_ORU_R01_NBS_Fully_Populated_0_initial_message.hl7
```

Sending an order to staging
```
./hrl waters.hurl -f Orders/003_AL_ORM_O01_NBS_Fully_Populated_0_initial_message.hl7 -e staging -x /path/to/staging/private/key
```

Checking the history in local environment for a submision id
```
./hrl history.hurl -i 100
```

Checking the history in staging for a submision id
```
./hrl history.hurl -i 100 -e staging -x /path/to/staging/private/key
```
File renamed without changes.
5 changes: 5 additions & 0 deletions scripts/hurl/ti/auth.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
POST {{url}}/v1/auth/token
Content-Type: application/x-www-form-urlencoded
[FormParams]
scope: {{client}}
client_assertion: {{jwt}}
1 change: 1 addition & 0 deletions scripts/hurl/ti/health.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GET {{url}}/health
115 changes: 115 additions & 0 deletions scripts/hurl/ti/hrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#!/bin/bash

# Check if $CDCTI_HOME is set
if [ -z "$CDCTI_HOME" ]; then
echo "Error: CDCTI_HOME is not set. Please set this environment variable before running the script."
exit 1
fi

# default values
env=local
root=$CDCTI_HOME/examples/Test/
client=report-stream
verbose=""

show_help() {
echo "Usage: $(basename $0) <HURL_FILE> [OPTIONS]"
echo
echo "Options:"
echo " -f <REL_PATH> The path to the hl7/fhir file to submit, relative the root path (Required for orders and results APIs)"
echo " -i <SUBMISSION_ID> The submissionId to call the metadata API with (Required for orders, results and metadata API)"
echo " -r <ROOT_PATH> The root path to the hl7/fhir files (Default: $root)"
echo " -e [local | staging] The environment to run the test in (Default: $env)"
echo " -c <CLIENT> The client id to use (Default: $client)"
echo " -j <JWT> The JWT to use for authentication"
echo " -v Verbose mode"
echo " -h Display this help and exit"
}

# Check if required HURL_FILE is provided
if [ $# -eq 0 ]; then
echo "Error: Missing required argument <HURL_FILE>"
show_help
exit 1
fi

# Check if first argument is -h
if [ "$1" = "-h" ]; then
show_help
exit 0
fi

hurl_file="$1" # Assign the first argument to hurl_file
shift # Remove the first argument from the list of arguments

while getopts ':f:r:e:c:j:i:vh' opt; do
case "$opt" in
f)
fpath="$OPTARG"
;;
i)
submission_id="--variable submissionid=$OPTARG"
;;
r)
root="$OPTARG"
;;
e)
env="$OPTARG"
;;
c)
client="$OPTARG"
;;
j)
jwt="$OPTARG"
;;
v)
verbose="--verbose"
;;
h)
show_help
exit 0
;;
:)
echo -e "Option requires an argument"
show_help
exit 1
;;
?)
echo -e "Invalid command option"
show_help
exit 1
;;
esac
done
shift "$(($OPTIND - 1))"

if [ "$env" = "local" ]; then
host=localhost
url=http://$host:8080
if [ -z "$jwt" ] && [ "$client" = "report-stream" ]; then
jwt=$(cat "$CDCTI_HOME/mock_credentials/report-stream-valid-token.jwt")
fi
elif [ "$env" = "staging" ]; then
host=cdcti-stg-api.azurewebsites.net
url=https://$host:443
else
echo "Error: Invalid environment $env"
show_help
exit 1
fi

if [ -z "$jwt" ]; then
echo "Error: Please provide the JWT for $client"
exit 1
fi

hurl \
--variable fpath=$fpath \
--file-root $root \
--variable url=$url \
--variable client=$client \
--variable jwt=$jwt \
$submission_id \
$verbose \
$hurl_file \
$@
13 changes: 13 additions & 0 deletions scripts/hurl/ti/metadata.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
POST {{url}}/v1/auth/token
Content-Type: application/x-www-form-urlencoded
[FormParams]
scope: {{client}}
client_assertion: {{jwt}}

HTTP 200

[Captures]
token: jsonpath "$['access_token']"

GET {{url}}/v1/etor/metadata/{{submissionid}}
Authorization: Bearer {{token}}
1 change: 1 addition & 0 deletions scripts/hurl/ti/openapi.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GET {{url}}/openapi
15 changes: 15 additions & 0 deletions scripts/hurl/ti/orders.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
POST {{url}}/v1/auth/token
Content-Type: application/x-www-form-urlencoded
[FormParams]
scope: {{client}}
client_assertion: {{jwt}}

HTTP 200

[Captures]
token: jsonpath "$['access_token']"

POST {{url}}/v1/etor/orders
Authorization: Bearer {{token}}
RecordId: {{submissionid}}
file,{{fpath}};
55 changes: 55 additions & 0 deletions scripts/hurl/ti/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# CDC Intermediary Hurl Script

## Usage

```
Usage: hrl <HURL_FILE> [OPTIONS]
Options:
-f <REL_PATH> The path to the hl7/fhir file to submit, relative the root path (Required for orders and results APIs)
-r <ROOT_PATH> The root path to the hl7/fhir files (Default: $CDCTI_HOME/examples/Test/)
-e [local | staging] The environment to run the test in (Default: local)
-c <CLIENT> The client id to use (Default: report-stream)
-j <JWT> The JWT to use for authentication
-i <SUBMISSION_ID> The submissionId to call the metadata API with (Required for metadata API)
-v Verbose mode
-h Display this help and exit
```

## Examples

Submit an order to local environment:
```
./hrl orders.hurl -f Orders/003_AL_ORM_O01_NBS_Fully_Populated_1_hl7_translation.fhir -i 100
```

Submit an order to staging:
```
./hrl orders.hurl -f Orders/003_AL_ORM_O01_NBS_Fully_Populated_0_initial_message.hl7 -e staging -j eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ
```

Submit a result to local environment:
```
./hrl results.hurl -f Results/002_AL_ORU_R01_NBS_Fully_Populated_1_hl7_translation.fhir -i 100
```

Get metadata from local environment:
```
./hrl metadata -i 100
```

Authenticate to local environment:
```
./hrl auth.hurl
```

Get OpenAPI docs from local environment:
```
./hrl openapi.hurl
```

Get Health info from local environment:
```
./hrl health.hurl
```
15 changes: 15 additions & 0 deletions scripts/hurl/ti/results.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
POST {{url}}/v1/auth/token
Content-Type: application/x-www-form-urlencoded
[FormParams]
scope: {{client}}
client_assertion: {{jwt}}

HTTP 200

[Captures]
token: jsonpath "$['access_token']"

POST {{url}}/v1/etor/results
Authorization: Bearer {{token}}
RecordId: {{submissionid}}
file,{{fpath}};

0 comments on commit bd229ac

Please sign in to comment.