Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring of hurl scripts #1475

Merged
merged 13 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions scripts/hurl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,125 @@
- [CDC Intermediary](./ti/): scripts to send requests to the CDC Intermediary's endpoints
- [Epic/UCSD](./epic/): scripts to send requests to Epic endpoints for UCSD

### ReportStream

#### Usage

```
Usage: ./rs.sh <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/)
-t <CONTENT_TYPE> The content type for the message (e.g. 'application/hl7-v2' or 'application/fhir+ndjson') (Default: application/hl7-v2)
-e [local | staging | production ] 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-sender)
-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

```
./rs.sh waters.hurl -f Test/Orders/003_AL_ORM_O01_NBS_Fully_Populated_0_initial_message.hl7
```

Sending a result to local environment

```
./rs.sh waters.hurl -f Test/Results/002_AL_ORU_R01_NBS_Fully_Populated_0_initial_message.hl7
```

Sending an order to staging

```
./rs.sh waters.hurl -f Test/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 submission id

```
./rs.sh history.hurl -i 100
```

Checking the history in staging for a submission id

```
./rs.sh history.hurl -i 100 -e staging -x /path/to/staging/private/key
```

### CDC Intermediary

#### Usage

```
Usage: ti.rs <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/)
-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:
```
./ti.rs orders.hurl -f Test/Orders/003_AL_ORM_O01_NBS_Fully_Populated_1_hl7_translation.fhir -i 100
```

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

```

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

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

Authenticate to local environment:
```
./ti.rs auth.hurl
```

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

Get Health info from local environment:
```
./ti.rs health.hurl
```

### Epic/UCSD

#### Before running the script

- Add the `client` id to `epic.rs`
- Update the `secret` variable path

#### Usage

`./epic.rs <HL7_FILE_NAME>`

## Local Submission Scripts

- `submit_message.sh`: sends a HL7 message to a locally running RS instance. It also grabs the snapshots of the file in azurite after converting to FHIR, after applying transformations in TI, and after converting back to HL7. It copies these files to the same folder where the submitted file is
Expand Down
2 changes: 1 addition & 1 deletion scripts/hurl/epic/hrl → scripts/hurl/epic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ hurl \
--variable fpath=$fpath \
--file-root $root \
--variable jwt=$(jwt encode --exp='+5min' --jti $(uuidgen) --alg RS256 -k $client -i $client -s $client -a $audience --no-iat -S @$secret) \
results.hurl \
epic/results.hurl \
basiliskus marked this conversation as resolved.
Show resolved Hide resolved
$@
10 changes: 0 additions & 10 deletions scripts/hurl/epic/README.md

This file was deleted.

17 changes: 3 additions & 14 deletions scripts/hurl/message_submission_utils.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/bash

RS_HRL_SCRIPT_PATH="$CDCTI_HOME/scripts/hurl/rs"
TI_HRL_SCRIPT_PATH="$CDCTI_HOME/scripts/hurl/ti"
FILE_NAME_SUFFIX_STEP_0="_0_initial_message"
FILE_NAME_SUFFIX_STEP_1="_1_hl7_translation"
FILE_NAME_SUFFIX_STEP_2="_2_fhir_transformation"
Expand Down Expand Up @@ -40,10 +38,7 @@ check_submission_status() {
start_time=$(date +%s)

while true; do
history_response=$(
cd "$RS_HRL_SCRIPT_PATH" || exit 1
./hrl history.hurl -i "$submission_id"
)
history_response=$(./rs.sh history.hurl -i "$submission_id")
overall_status=$(echo "$history_response" | jq -r '.overallStatus')

echo -n " Status: $overall_status"
Expand Down Expand Up @@ -118,10 +113,7 @@ submit_message() {

echo "Assuming receivers are '$first_leg_receiver' and '$second_leg_receiver' because of MSH-9 value '$msh9'"

waters_response=$(
cd "$RS_HRL_SCRIPT_PATH" || exit 1
./hrl waters.hurl -f "$message_file_name" -r "$message_file_path"
)
waters_response=$(./rs.sh waters.hurl -f "$message_file_name" -r "$message_file_path")
submission_id=$(echo "$waters_response" | jq -r '.id')

echo "[First leg] Checking submission status for ID: $submission_id"
Expand All @@ -135,10 +127,7 @@ submit_message() {
translated_file_path="$message_file_path/$message_base_name$FILE_NAME_SUFFIX_STEP_1.fhir"
download_from_azurite "$translated_blob_name" "$translated_file_path"

metadata_response=$(
cd "$TI_HRL_SCRIPT_PATH" || exit 1
./hrl metadata.hurl -i "$inbound_submission_id"
)
metadata_response=$(./ti.sh metadata.hurl -i "$inbound_submission_id")
outbound_submission_id=$(echo "$metadata_response" | jq -r '.issue[] | select(.details.text == "outbound submission id") | .diagnostics')

transformed_blob_name="receive/flexion.etor-service-sender/$outbound_submission_id.fhir"
Expand Down
4 changes: 2 additions & 2 deletions scripts/hurl/rs/hrl → scripts/hurl/rs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ if [ "$1" = "-h" ]; then
exit 0
fi

hurl_file="$1" # Assign the first argument to hurl_file
shift # Remove the first argument from the list of arguments
hurl_file=rs/"$1" # Assign the first argument to hurl_file
basiliskus marked this conversation as resolved.
Show resolved Hide resolved
shift # Remove the first argument from the list of arguments

while getopts ':f:r:t:e:c:s:x:i:vh' opt; do
case "$opt" in
Expand Down
51 changes: 0 additions & 51 deletions scripts/hurl/rs/README.md

This file was deleted.

4 changes: 2 additions & 2 deletions scripts/hurl/ti/hrl → scripts/hurl/ti.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ if [ "$1" = "-h" ]; then
exit 0
fi

hurl_file="$1" # Assign the first argument to hurl_file
shift # Remove the first argument from the list of arguments
hurl_file=ti/"$1" # Assign the first argument to hurl_file
basiliskus marked this conversation as resolved.
Show resolved Hide resolved
shift # Remove the first argument from the list of arguments

while getopts ':f:r:e:c:j:i:vh' opt; do
case "$opt" in
Expand Down
55 changes: 0 additions & 55 deletions scripts/hurl/ti/README.md

This file was deleted.