Skip to content

Commit

Permalink
Updated RS Hurl Script to Replace MSH Header When Not Toggled (#1342)
Browse files Browse the repository at this point in the history
* Updating hurl scripts
* Fixed typo in readme, create temp folder, write scrambled file into temp folder
* Fixed directory creation, resolved issue with sed command not copying rest of file
* updated readme to include toggle in options, add comments to scramble doing, alerted user to scrambling, removed folder creation for individual file
* replaced msh header for oru and orm message types
* added msh header replacement for oml message type
* switched to msh-9.2 as subfield in conditional
* remove temp directory after hurl script runs

---------

Co-authored-by: jcrichlake <jeff.crichlake@agile6.com>
Co-authored-by: Sylvie <sschuresko@flexion.us>
Co-authored-by: jcrichlake <145698165+jcrichlake@users.noreply.github.com>
Co-authored-by: saquino0827 <saquino@flexion.us>
  • Loading branch information
5 people authored Sep 23, 2024
1 parent 5b137e4 commit 81e5fb2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ __pycache__

localfileorder.json

logback.log
logback.log
37 changes: 36 additions & 1 deletion scripts/hurl/rs/hrl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ client_id=flexion
client_sender=simulated-hospital
verbose=""
submission_id=""
allow_outbound=false
msh_header_replacement=""

show_help() {
echo "Usage: $(basename $0) <HURL_FILE> [OPTIONS]"
Expand All @@ -29,6 +31,7 @@ show_help() {
echo " -i <SUBMISSION_ID> The submissionId to call the history API with (Required for history API)"
echo " -v Verbose mode"
echo " -h Display this help and exit"
echo " -p By default, the MSH segment is replaced to contain a Flexion receiver in order to avoid sending messages to partners inadvertently. When using this flag, the MSH segment will not be replaced"
}

# Check if required HURL_FILE is provided
Expand All @@ -47,7 +50,7 @@ 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:t:e:c:s:x:i:vh' opt; do
while getopts ':f:r:t:e:c:s:x:i:vh:p' opt; do
case "$opt" in
f)
fpath="$OPTARG"
Expand Down Expand Up @@ -80,6 +83,9 @@ while getopts ':f:r:t:e:c:s:x:i:vh' opt; do
show_help
exit 0
;;
p)
allow_outbound=true
;;
:)
echo -e "Option requires an argument"
show_help
Expand Down Expand Up @@ -114,6 +120,30 @@ if [ -z "$secret" ]; then
exit 1
fi

if [ "$allow_outbound" = false ]; then
# Grab MSH Header
msh_header=$(head -n1 "$CDCTI_HOME/$fpath")
# Check message type
if [[ "$msh_header" = *"^R01"* ]]; then
msh_header_replacement="MSH|^~\&|Sender Application^sender.test.com^DNS|Sender Facility^0.0.0.0.0.0.0.0^ISO|Receiver Application^0.0.0.0.0.0.0.0^ISO|Receiver Facility^simulated-hospital-id^DNS|20230101010000-0000||ORU^R01^ORU_R01|111111|T|2.5.1||||||||||"
elif [[ "$msh_header" = *"^O01"* ]]; then
msh_header_replacement="MSH|^~\&|Sender Application^sender.test.com^DNS|Sender Facility^0.0.0.0.0.0.0.0^ISO|Receiver Application^0.0.0.0.0.0.0.0^ISO|Receiver Facility^simulated-lab-id^DNS|20230101010000-0000||ORM^O01^ORM_O01|111111|T|2.5.1||||||||||"
elif [[ "$msh_header" = *"^O21"* ]]; then
msh_header_replacement="MSH|^~\&|Sender Application^sender.test.com^DNS|Sender Facility^0.0.0.0.0.0.0.0^ISO|Receiver Application^0.0.0.0.0.0.0.0^ISO|Receiver Facility^simulated-lab-id^DNS|20230101010000-0000||OML^O21^OML_O21|111111|T|2.5.1||||||||||"
else
echo "File does not contain valid message type (MSH-9) values."
exit 1
fi
file_path=$(dirname "$fpath")
substitutedFilePathPrefix="$CDCTI_HOME/substituted_header"
# Make temporary directory to store scrambled file
mkdir -p "$substitutedFilePathPrefix/$file_path" && touch -f "$substitutedFilePathPrefix/$fpath"
# Replace MSH Header and write into temporary directory
sed "1s/.*/$msh_header_replacement/" "$CDCTI_HOME/$fpath" > "$substitutedFilePathPrefix/$fpath"
fpath=$substitutedFilePathPrefix/$fpath
echo "By default, the MSH segment is replaced to contain a Flexion receiver in order to avoid sending messages to partners inadvertently. To toggle this, run with -p."
fi

hurl \
--variable fpath=$fpath \
--file-root $root \
Expand All @@ -126,3 +156,8 @@ hurl \
$verbose \
$hurl_file \
$@

# Remove temporary directory
if [ "$allow_outbound" = false ]; then
rm -r "$substitutedFilePathPrefix"
fi
5 changes: 3 additions & 2 deletions scripts/hurl/rs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Options:
-i <SUBMISSION_ID> The submissionId to call the history API with (Required for history API)
-v Verbose mode
-h Display this help and exit
-p By default, the MSH segment is replaced to contain a Flexion receiver in order to avoid sending messages to partners inadvertently. When using this flag, the MSH segment will not be replaced
```

## Examples
Expand All @@ -35,12 +36,12 @@ Sending an order to staging
./hrl 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 submision id
Checking the history in local environment for a submission id
```
./hrl history.hurl -i 100
```

Checking the history in staging for a submision id
Checking the history in staging for a submission id
```
./hrl history.hurl -i 100 -e staging -x /path/to/staging/private/key
```

0 comments on commit 81e5fb2

Please sign in to comment.