From a7b26069b231bee111e18b6b26c32e155ecdc5e7 Mon Sep 17 00:00:00 2001 From: rob-reynolds Date: Wed, 27 Apr 2022 16:20:39 -0600 Subject: [PATCH] Add publish scripts --- _publish.bat | 46 +++++++++++++++++++++++++++++++ _publish.sh | 41 ++++++++++++++++++++++++++++ _refresh.bat | 77 ++++++++++++++++++++++++++++++++++++++++++---------- _refresh.sh | 60 +++++++++++++++++++++++++++++----------- 4 files changed, 193 insertions(+), 31 deletions(-) create mode 100644 _publish.bat create mode 100644 _publish.sh diff --git a/_publish.bat b/_publish.bat new file mode 100644 index 0000000..e1debaa --- /dev/null +++ b/_publish.bat @@ -0,0 +1,46 @@ +@ECHO OFF +SET server_url="http://localhost:8080/fhir/" + +IF "%1%"=="-h" GOTO printUsage +GOTO publish + +:printUsage +ECHO Usage: %0 [-s fhir_base_url] [-u] +ECHO. +ECHO Runs Refresh and loads resources to a FHIR server. Defaults to %server_url%. +ECHO -h Print this help +ECHO -s Use specificed fhir base url like http://localhost:8080/fhir/ +ECHO -u Unattended mode. Defaults to false. +GOTO exit0 + +:publish +SET refresh_script=_refresh.bat +SET unattended= + +IF "%1%"=="-u" ( + SET unattended=-u +) ELSE IF "%2%"=="-u" ( + SET unattended=-u +) + +IF "%1%"=="-s" ( + SET server_url=%1% +) ELSE IF "%2%"=="-s" ( + SET server_url=%2% +) + +SET fsoption=-s %server_url% + +IF EXIST "%refresh_script%" ( + ECHO running: %refresh_script% %fsoption% %unattended% + CALL _refresh.bat %fsoption% %unattended% +) ELSE ( + ECHO Refresh script NOT FOUND. Please install _refresh.bat. Aborting... + GOTO exit1 +) + +:exit0 +EXIT /b 0 + +:exit1 +EXIT /b 1 diff --git a/_publish.sh b/_publish.sh new file mode 100644 index 0000000..b348599 --- /dev/null +++ b/_publish.sh @@ -0,0 +1,41 @@ +#!/bin/bash +#DO NOT EDIT WITH WINDOWS + +server_url="http://localhost:8080/fhir/" + +usage () { + cat <] [-u] + + Runs Refresh and loads resources to a FHIR server. Defaults to $server_url. + + -h Print this help + -s Use specificed fhir base url like http://localhost:8080/fhir/ + -u Unattended mode. Defaults to false. +HELP_USAGE + exit 0 +} + +refresh_script="_refresh.sh" +unattended="" + +while getopts hs:u flag +do + case "${flag}" in + h) usage;; + s) server_url=${OPTARG};; + u) unattended="-u";; + esac +done + +fsoption="-s $server_url" + +set -e + +if test -f "$refresh_script"; then + echo "running: ./_refresh.sh $fsoption $unattended" + ./_refresh.sh "$fsoption" "$unattended" +else + echo Publish script NOT FOUND. Please install _publish.sh. Aborting... +fi diff --git a/_refresh.bat b/_refresh.bat index ec78ce9..58217c8 100644 --- a/_refresh.bat +++ b/_refresh.bat @@ -1,32 +1,79 @@ @ECHO OFF -SET tooling_jar=tooling-1.4.0-jar-with-dependencies.jar +IF "%1%"=="-h" GOTO printUsage +GOTO refresh + +:printUsage +ECHO Usage: %0 [-d] [-s fhir_base_url] [-u] +ECHO. +ECHO Refreshes FHIR documents in place. Optionally loads resources to a FHIR server. +ECHO -h Print this help +ECHO -d Use default Alphora FHIR sandbox. Mutually exclusive with -s. +ECHO -s Use specificed fhir base url like http://localhost:8080/fhir/. Mutually exclusive with -d. +ECHO -u Unattended mode. Defaults to false. +GOTO exit0 + +:refresh +SET tooling_jar=tooling-1.4.1-SNAPSHOT-jar-with-dependencies.jar SET input_cache_path=%~dp0input-cache SET ig_resource_path=%~dp0input\ecqm-content-r4.xml +SET unattended=false +SET server_url= -ECHO Checking internet connection... -PING tx.fhir.org -n 1 -w 1000 | FINDSTR TTL && GOTO isonline -ECHO We're offline... -SET fsoption= -GOTO igpublish +IF "%1%"=="-u" ( + SET unattended=true +) ELSE IF "%2%"=="-u" ( + SET unattended=true +) ELSE IF "%3%"=="-u" ( + SET unattended=true +) + +IF "%1%"=="-d" ( + SET server_url=https://cloud.alphora.com/sandbox/r4/cqm/fhir/ + GOTO igpublish +) ELSE IF "%2%"=="-d" ( + SET server_url=https://cloud.alphora.com/sandbox/r4/cqm/fhir/ + GOTO igpublish +) +IF "%1%"=="-s" ( + SET server_url=%2% + GOTO igpublish +) ELSE IF "%2%"=="-s" ( + SET server_url=%3% + GOTO igpublish +) -:isonline -ECHO We're online, setting publish to the Connectathon sandbox FHIR server (DISABLED TEMPORARILY) SET fsoption= -REM Disabled temporarily due to an error in the CQF Tooling upload -REM -fs http://cqm-sandbox.alphora.com/cqf-ruler-r4/fhir/ :igpublish - SET JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8 +IF NOT "%server_url%"=="" ( + SET fsoption=-fs=%server_url% +) + +IF "%server_url%"=="" ( + ECHO No FHIR server specified. Resources will not be loaded. +) ELSE ( + ECHO Resources will be loaded to FHIR server: %server_url% +) + IF EXIST "%input_cache_path%\%tooling_jar%" ( - ECHO running: JAVA -jar "%input_cache_path%\%tooling_jar%" -RefreshIG -ini=%~dp0ig.ini -t -d -p - JAVA -jar "%input_cache_path%\%tooling_jar%" -RefreshIG -ini=%~dp0ig.ini -t -d -p %fsoption% -) ELSE If exist "..\%tooling_jar%" ( - ECHO running: JAVA -jar "..\%tooling_jar%" -RefreshIG -ini=%~dp0ig.ini -t -d -p + ECHO running: JAVA -jar "%input_cache_path%\%tooling_jar%" -RefreshIG -ini=%~dp0ig.ini -t -d -p %fsoption% -rp input\cql + JAVA -jar "%input_cache_path%\%tooling_jar%" -RefreshIG -ini=%~dp0ig.ini -t -d -p %fsoption% -rp input\cql +) ELSE IF EXIST "..\%tooling_jar%" ( + ECHO running: JAVA -jar "..\%tooling_jar%" -RefreshIG -ini=%~dp0ig.ini -t -d -p %fsoption% JAVA -jar "..\%tooling_jar%" -RefreshIG -ini=%~dp0ig.ini -t -d -p %fsoption% ) ELSE ( ECHO IG Refresh NOT FOUND in input-cache or parent folder. Please run _updateCQFTooling. Aborting... + GOTO exit1 ) +IF "%unattended%"=="true" GOTO exit0 + PAUSE + +:exit0 +EXIT /b 0 + +:exit1 +EXIT /b 1 diff --git a/_refresh.sh b/_refresh.sh index 626bf03..32d8327 100755 --- a/_refresh.sh +++ b/_refresh.sh @@ -1,36 +1,64 @@ #!/bin/bash #DO NOT EDIT WITH WINDOWS -tooling_jar=tooling-1.4.0-jar-with-dependencies.jar + +usage () { + cat <] [-u] + + Refreshes FHIR documents in place. Optionally loads resources to a FHIR server. + + -h Print this help + -d Use default Alphora FHIR sandbox. Mutually exclusive with -s. + -s Use specificed fhir base url like http://localhost:8080/fhir/. Mutually exclusive with -d. + -u Unattended mode. Defaults to false. +HELP_USAGE + exit 0 +} + +tooling_jar=tooling-1.4.1-SNAPSHOT-jar-with-dependencies.jar input_cache_path=./input-cache ig_resource_path=./input/ecqm-content-r4.xml +unattended=false + +while getopts hds:u flag +do + case "${flag}" in + d) server_url="https://cloud.alphora.com/sandbox/r4/cqm/fhir/";; + h) usage;; + s) server_url=${OPTARG};; + u) unattended=true;; + esac +done + +fsoption="" +if [ ! -z "${server_url}" ]; then + fsoption="-fs ${server_url}" +fi set -e -echo Checking internet connection... -#wget -q --spider tx.fhir.org - -if [ $? -eq 0 ]; then - echo "Online" - #fsoption="" - #Disabled temporarily due to error in CQF Tooling upload - fsoption="-fs https://cqm-sandbox.alphora.com/cqf-ruler-r4/fhir/" + +if [ -z "${server_url}" ]; then + echo "No FHIR server specified. Resources will not be loaded." else - echo "Offline" - fsoption="" + echo "Resources will be loaded to FHIR server: ${server_url}." fi -echo "$fsoption" -fsoption="" - tooling=$input_cache_path/$tooling_jar if test -f "$tooling"; then + echo "running: java -jar $tooling -RefreshIG -ini=$PWD/ig.ini -t -d -p $fsoption" java -jar $tooling -RefreshIG -ini="$PWD"/ig.ini -t -d -p $fsoption - else tooling=../$tooling_jar echo $tooling if test -f "$tooling"; then - java -jar $tooling -RefreshIG -ini="$PWD"/ig.ini -t -d -p $fsoption + echo "running: java -jar $tooling -RefreshIG -ini=$PWD/ig.ini -t -d -p $fsoption -rp input/cql" + java -jar $tooling -RefreshIG -ini="$PWD"/ig.ini -t -d -p $fsoption -rp input/cql else echo IG Refresh NOT FOUND in input-cache or parent folder. Please run _updateCQFTooling. Aborting... fi fi + +if [ "$unattended" = false ] ; then + read -p "Press any key to resume ..." +fi