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 all commits
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
151 changes: 142 additions & 9 deletions scripts/hurl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,157 @@
- [hurl](https://hurl.dev/)
- [jq](https://jqlang.github.io/jq/)
- [azure-cli](https://learn.microsoft.com/en-us/cli/azure/)
- [jwt-cli](https://github.com/mike-engel/jwt-cli)
- `CDCTI_HOME` environment variable ([see here](../README.md))

## Available Hurl Scripts

- [ReportStream](./rs/): scripts to send requests to ReportStream's endpoints
- [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

## Local Submission Scripts
#### Usage

- `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
```
Usage: ./rs.sh <ENDPOINT_NAME> [OPTIONS]

ENDPOINT_NAME:
The name of the endpoint to call (required)

Options:
-f <REL_PATH> Path to the hl7/fhir file to submit (Required for waters API)
-r <ROOT_PATH> Root path to the hl7/fhir files (Default: /Users/bbogado/Code/Flexion/CDC-TI/trusted-intermediary/examples/)
-t <CONTENT_TYPE> Content type for the message (Default: application/hl7-v2)
-e <ENVIRONMENT> Environment: local|staging|production (Default: local)
-c <CLIENT_ID> Client ID (Default: flexion)
-s <CLIENT_SENDER> Client sender (Default: simulated-sender)
-k <KEY_PATH> Path to the client private key (Required for non-local environments)
-i <SUBMISSION_ID> Submission ID for history API (Required for history API)
-v Verbose mode
-h Display this help and exit

Environment Variables:
CDCTI_HOME Base directory for CDC TI repository (Required)
```

#### Examples

Sending an order to local environment

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

Sending a result to local environment

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

Sending an order to staging

```
./rs.sh waters -f Test/Orders/003_AL_ORM_O01_NBS_Fully_Populated_0_initial_message.hl7 -e staging -k /path/to/client/staging/private/key
```

Checking the history in local environment for a submission id

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

Checking the history in staging for a submission id

```
./rs.sh history -i 100 -e staging -k /path/to/client/staging/private/key
```

### CDC Intermediary

#### Usage

```
Usage: ./ti.sh <ENDPOINT_NAME> [OPTIONS]

ENDPOINT_NAME:
The name of the endpoint to call (required)

Options:
-f <REL_PATH> Path to the hl7/fhir file to submit (Required for orders and results APIs)
-r <ROOT_PATH> Root path to the hl7/fhir files (Default: /Users/bbogado/Code/Flexion/CDC-TI/trusted-intermediary/examples/)
-e <ENVIRONMENT> Environment: local|staging (Default: local)
-c <CLIENT> Client ID to create JWT with (Default: report-stream)
-k <KEY_PATH> Path to the client private key (Required for non-local environments)
-i <SUBMISSION_ID> Submission ID for metadata API (Required for orders, results and metadata API)
-v Verbose mode
-h Display this help and exit

Environment Variables:
CDCTI_HOME Base directory for CDC TI repository (Required)
```

#### Examples

Submit an order to local environment:
```
./ti.sh orders -f Test/Orders/003_AL_ORM_O01_NBS_Fully_Populated_1_hl7_translation.fhir -i 100
```

Submit an order to staging:
```
./ti.sh orders -f Test/Orders/003_AL_ORM_O01_NBS_Fully_Populated_0_initial_message.hl7 -e staging -k /path/to/client/staging/private/key

```

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

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

Authenticate to local environment:
```
./ti.sh auth
```

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

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

### Epic/UCSD

#### Before running the script

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

#### Usage

`./epic.sh results`

## High Level Scripts

- `submit_message.sh`: sends a HL7 message to RS and tracks its status throughout the flow until final delivery. When running locally, it grabs the snapshots of the file in azurite after converting to FHIR, after applying transformations in TI, and after converting back to HL7; and it copies those files to the same folder where the submitted file is. If running in a deployed environment we currently don't have a way to download the files from Azure, but the script will print the relative path for the files in the blob storage container.
```
./submit_message.sh /path/to/message.hl7
Usage: submit_message.sh -f <message_file.hl7> [-e <environment>]

Options:
-f <FILE> Message file path (Required)
-e <ENVIRONMENT> Environment: local|staging|production (Default: )
-x <RS_CLIENT_PRIVATE_KEY> Path to the client private key for authentication with RS API (Required for non-local environments)
-z <TI_CLIENT_PRIVATE_KEY> Path to the client private key for authentication with TI API (Optional for all environments)
-h Display this help and exit
```
- `update_examples.sh`: sends all the HL7 files with `_0_initial_message.hl7` suffix in the `/examples` folder to a locally running RS instance. As the previous script, it copies the snapshots at each stage
```
./update_examples.sh
```
- `message_submission_utils.sh`: utility functions for the previous scripts. It has functions to submit requests to RS, check the submission status throughout the whole flow, and downloading snapshots from azurite

**Note**: these scripts require both RS and TI to be running locally
- `utils.sh`: utility functions for the previous scripts. It has functions to submit requests to RS, check the submission status throughout the whole flow, and downloading snapshots from azurite
19 changes: 19 additions & 0 deletions scripts/hurl/epic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

source ./utils.sh

client=
audience=https://epicproxy-np.et0502.epichosted.com/FhirProxy/oauth2/token
secret=/path/to/ucsd-epic-private-key.pem
root=$CDCTI_HOME/examples/CA/
fpath="$1"
shift

jwt_token=$(generate_jwt "$client" "$audience" "$secret") || fail "Failed to generate JWT token"

hurl \
--variable "fpath=$fpath" \
--file-root "$root" \
--variable "jwt=$jwt_token" \
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.

13 changes: 0 additions & 13 deletions scripts/hurl/epic/hrl

This file was deleted.

158 changes: 0 additions & 158 deletions scripts/hurl/message_submission_utils.sh

This file was deleted.

Loading