027-FHIRPoweredHealthcare/Student/Resources/heath-architectures/HL7Conversion/deployhl72fhir-hl7converter.bash [47:250]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
declare faresourceid=""
declare fakey=""
declare deployzip="../FHIR/FHIREventProcessor/distribution/publish.zip"
declare deployprefix=""
declare defdeployprefix=""
declare fsurl=""
declare fsclientid=""
declare fssecret=""
declare fstenant=""
declare fsaud=""
declare fsdefaud="https://azurehealthcareapis.com"
declare hl7storename=""
declare hl7rgname=""
declare hl7sbnamespace=""
declare hl7sbqueuename=""
declare hl7storekey=""
declare hl7sbconnection=""
declare hl7convertername="hl7conv"
declare hl7converterrg=""
declare uid=$(uuidgen)
declare hl7convertkey=${uid//-}
declare hl7converterinstance=""
declare stepresult=""
declare fahost=""
# Initialize parameters specified from command line
while getopts ":i:g:n:l:p" arg; do
	case "${arg}" in
		p)
			deployprefix=${OPTARG:0:14}
			deployprefix=${deployprefix,,}
			deployprefix=${deployprefix//[^[:alnum:]]/}
			;;
		i)
			subscriptionId=${OPTARG}
			;;
		g)
			resourceGroupName=${OPTARG}
			;;
		l)
			resourceGroupLocation=${OPTARG}
			;;
		esac
done
shift $((OPTIND-1))
echo "Executing "$0"..."
echo "Checking Azure Authentication..."
#login to azure using your credentials
az account show 1> /dev/null

if [ $? != 0 ];
then
	az login
fi

defsubscriptionId=$(az account show --query "id" --out json | sed 's/"//g') 

#Prompt for parameters is some required parameters are missing
if [[ -z "$subscriptionId" ]]; then
	echo "Enter your subscription ID ["$defsubscriptionId"]:"
	read subscriptionId
	if [ -z "$subscriptionId" ] ; then
		subscriptionId=$defsubscriptionId
	fi
	[[ "${subscriptionId:?}" ]]
fi

if [[ -z "$resourceGroupName" ]]; then
	echo "This script will look for an existing resource group, otherwise a new one will be created "
	echo "You can create new resource groups with the CLI using: az group create "
	echo "Enter a resource group name"
	read resourceGroupName
	[[ "${resourceGroupName:?}" ]]
fi

defdeployprefix=${resourceGroupName:0:14}
defdeployprefix=${defdeployprefix//[^[:alnum:]]/}
defdeployprefix=${defdeployprefix,,}

if [[ -z "$resourceGroupLocation" ]]; then
	echo "If creating a *new* resource group, you need to set a location "
	echo "You can lookup locations with the CLI using: az account list-locations "
	
	echo "Enter resource group location:"
	read resourceGroupLocation
fi
#Prompt for parameters is some required parameters are missing
if [[ -z "$deployprefix" ]]; then
	echo "Enter your deployment prefix ["$defdeployprefix"]:"
	read deployprefix
	if [ -z "$deployprefix" ] ; then
		deployprefix=$defdeployprefix
	fi
	deployprefix=${deployprefix:0:14}
	deployprefix=${deployprefix//[^[:alnum:]]/}
    deployprefix=${deployprefix,,}
	[[ "${deployprefix:?}" ]]
fi
if [ -z "$subscriptionId" ] || [ -z "$resourceGroupName" ]; then
	echo "Either one of subscriptionId, resourceGroupName is empty"
	usage
fi
#Prompt for Converter Resource group to avoid function app conflicts
echo "Enter a resource group name to deploy the converter to ["$deployprefix$hl7convertername"]:"
read hl7converterrg
if [ -z "$hl7converterrg" ] ; then
 	 hl7converterrg=$deployprefix$hl7convertername
fi
if [ "$hl7converterrg" = "$resourceGroupName" ]; then
    echo "The converter resource group cannot be the same as the target resource group"
	exit 1;
fi
if [ -z "$hl7converterrg" ] ; then
 	 hl7converterrg=$deployprefix$hl7convertername
fi
#Prompt for HL7Ingest Storage and Service Bus
echo "Enter the name of the HL7 Ingest Resource Group:"
read hl7rgname
if [ -z "$hl7rgname" ] ; then
	echo "You must provide the name of the resource group that contains the HL7 ingest platform"
	exit 1;
fi
echo "Enter the name of the HL7 Ingest storage account:"
read hl7storename
if [ -z "$hl7storename" ] ; then
	echo "You must provide the name of the storage account of the HL7 ingest platform"
	exit 1;
fi
echo "Enter the name of the HL7 ServiceBus namespace:"
read hl7sbnamespace
if [ -z "$hl7sbnamespace" ] ; then
	echo "You must provide the namespace name of the service bus of the HL7 ingest platform"
	exit 1;
fi
echo "Enter the name of the HL7 ServiceBus destination queue:"
read hl7sbqueuename
if [ -z "$hl7sbqueuename" ] ; then
	echo "You must provide the name of the service bus queue of the HL7 ingest platform"
	exit 1;
fi
#Prompt for FHIR Server Parameters
echo "Enter the destination FHIR Server URL:"
read fsurl
if [ -z "$fsurl" ] ; then
	echo "You must provide a destination FHIR Server URL"
	exit 1;
fi
echo "Enter the FHIR Server Service Client Application ID:"
read fsclientid
if [ -z "$fsclientid" ] ; then
	echo "You must provide a Service Client Application ID"
	exit 1;
fi
echo "Enter the FHIR Server Service Client Secret:"
read fssecret
if [ -z "$fssecret" ] ; then
	echo "You must provide a Service Client Secret"
	exit 1;
fi
echo "Enter the FHIR Server/Service Client Audience/Resource ["$fsdefaud"]:"
	read fsaud
	if [ -z "$fsaud" ] ; then
		fsaud=$fsdefaud
	fi
	[[ "${fsaud:?}" ]]
echo "Enter the FHIR Server/Service Client Tenant ID:"
read fstenant
if [ -z "$fstenant" ] ; then
	echo "You must provide a FHIR Server/Service Client Tenant"
	exit 1;
fi

echo "Setting subscription id and checking resource groups..."
#set the default subscription id
az account set --subscription $subscriptionId

set +e

#Check for existing RG
if [ $(az group exists --name $resourceGroupName) = false ]; then
	echo "Resource group with name" $resourceGroupName "could not be found. Creating new resource group.."
	set -e
	(
		set -x
		az group create --name $resourceGroupName --location $resourceGroupLocation 1> /dev/null
	)
else
	echo "Using existing resource group..."
fi

if [ $(az group exists --name $hl7converterrg) = false ]; then
	echo "Resource group with name" $hl7converterrg "could not be found. Creating new resource group.."
	set -e
	(
		set -x
		az group create --name $hl7converterrg --location $resourceGroupLocation 1> /dev/null
	)
else
	echo "Using existing resource group for converter deployment..."
fi
#Set up variables
faresourceid="/subscriptions/"$subscriptionId"/resourceGroups/"$resourceGroupName"/providers/Microsoft.Web/sites/"$faname
#Start deployment
echo "Starting HL72FHIR Workflow Platform deployment..."
(
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



027-FHIRPoweredHealthcare/Student/Resources/heath-architectures/HL7Conversion/deployhl72fhir.bash [46:249]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
declare faresourceid=""
declare fakey=""
declare deployzip="../FHIR/FHIREventProcessor/distribution/publish.zip"
declare deployprefix=""
declare defdeployprefix=""
declare fsurl=""
declare fsclientid=""
declare fssecret=""
declare fstenant=""
declare fsaud=""
declare fsdefaud="https://azurehealthcareapis.com"
declare hl7storename=""
declare hl7rgname=""
declare hl7sbnamespace=""
declare hl7sbqueuename=""
declare hl7storekey=""
declare hl7sbconnection=""
declare hl7convertername="hl7conv"
declare hl7converterrg=""
declare uid=$(uuidgen)
declare hl7convertkey=${uid//-}
declare hl7converterinstance=""
declare stepresult=""
declare fahost=""
# Initialize parameters specified from command line
while getopts ":i:g:n:l:p" arg; do
	case "${arg}" in
		p)
			deployprefix=${OPTARG:0:14}
			deployprefix=${deployprefix,,}
			deployprefix=${deployprefix//[^[:alnum:]]/}
			;;
		i)
			subscriptionId=${OPTARG}
			;;
		g)
			resourceGroupName=${OPTARG}
			;;
		l)
			resourceGroupLocation=${OPTARG}
			;;
		esac
done
shift $((OPTIND-1))
echo "Executing "$0"..."
echo "Checking Azure Authentication..."
#login to azure using your credentials
az account show 1> /dev/null

if [ $? != 0 ];
then
	az login
fi

defsubscriptionId=$(az account show --query "id" --out json | sed 's/"//g') 

#Prompt for parameters is some required parameters are missing
if [[ -z "$subscriptionId" ]]; then
	echo "Enter your subscription ID ["$defsubscriptionId"]:"
	read subscriptionId
	if [ -z "$subscriptionId" ] ; then
		subscriptionId=$defsubscriptionId
	fi
	[[ "${subscriptionId:?}" ]]
fi

if [[ -z "$resourceGroupName" ]]; then
	echo "This script will look for an existing resource group, otherwise a new one will be created "
	echo "You can create new resource groups with the CLI using: az group create "
	echo "Enter a resource group name"
	read resourceGroupName
	[[ "${resourceGroupName:?}" ]]
fi

defdeployprefix=${resourceGroupName:0:14}
defdeployprefix=${defdeployprefix//[^[:alnum:]]/}
defdeployprefix=${defdeployprefix,,}

if [[ -z "$resourceGroupLocation" ]]; then
	echo "If creating a *new* resource group, you need to set a location "
	echo "You can lookup locations with the CLI using: az account list-locations "
	
	echo "Enter resource group location:"
	read resourceGroupLocation
fi
#Prompt for parameters is some required parameters are missing
if [[ -z "$deployprefix" ]]; then
	echo "Enter your deployment prefix ["$defdeployprefix"]:"
	read deployprefix
	if [ -z "$deployprefix" ] ; then
		deployprefix=$defdeployprefix
	fi
	deployprefix=${deployprefix:0:14}
	deployprefix=${deployprefix//[^[:alnum:]]/}
    deployprefix=${deployprefix,,}
	[[ "${deployprefix:?}" ]]
fi
if [ -z "$subscriptionId" ] || [ -z "$resourceGroupName" ]; then
	echo "Either one of subscriptionId, resourceGroupName is empty"
	usage
fi
#Prompt for Converter Resource group to avoid function app conflicts
echo "Enter a resource group name to deploy the converter to ["$deployprefix$hl7convertername"]:"
read hl7converterrg
if [ -z "$hl7converterrg" ] ; then
 	 hl7converterrg=$deployprefix$hl7convertername
fi
if [ "$hl7converterrg" = "$resourceGroupName" ]; then
    echo "The converter resource group cannot be the same as the target resource group"
	exit 1;
fi
if [ -z "$hl7converterrg" ] ; then
 	 hl7converterrg=$deployprefix$hl7convertername
fi
#Prompt for HL7Ingest Storage and Service Bus
echo "Enter the name of the HL7 Ingest Resource Group:"
read hl7rgname
if [ -z "$hl7rgname" ] ; then
	echo "You must provide the name of the resource group that contains the HL7 ingest platform"
	exit 1;
fi
echo "Enter the name of the HL7 Ingest storage account:"
read hl7storename
if [ -z "$hl7storename" ] ; then
	echo "You must provide the name of the storage account of the HL7 ingest platform"
	exit 1;
fi
echo "Enter the name of the HL7 ServiceBus namespace:"
read hl7sbnamespace
if [ -z "$hl7sbnamespace" ] ; then
	echo "You must provide the namespace name of the service bus of the HL7 ingest platform"
	exit 1;
fi
echo "Enter the name of the HL7 ServiceBus destination queue:"
read hl7sbqueuename
if [ -z "$hl7sbqueuename" ] ; then
	echo "You must provide the name of the service bus queue of the HL7 ingest platform"
	exit 1;
fi
#Prompt for FHIR Server Parameters
echo "Enter the destination FHIR Server URL:"
read fsurl
if [ -z "$fsurl" ] ; then
	echo "You must provide a destination FHIR Server URL"
	exit 1;
fi
echo "Enter the FHIR Server Service Client Application ID:"
read fsclientid
if [ -z "$fsclientid" ] ; then
	echo "You must provide a Service Client Application ID"
	exit 1;
fi
echo "Enter the FHIR Server Service Client Secret:"
read fssecret
if [ -z "$fssecret" ] ; then
	echo "You must provide a Service Client Secret"
	exit 1;
fi
echo "Enter the FHIR Server/Service Client Audience/Resource ["$fsdefaud"]:"
	read fsaud
	if [ -z "$fsaud" ] ; then
		fsaud=$fsdefaud
	fi
	[[ "${fsaud:?}" ]]
echo "Enter the FHIR Server/Service Client Tenant ID:"
read fstenant
if [ -z "$fstenant" ] ; then
	echo "You must provide a FHIR Server/Service Client Tenant"
	exit 1;
fi

echo "Setting subscription id and checking resource groups..."
#set the default subscription id
az account set --subscription $subscriptionId

set +e

#Check for existing RG
if [ $(az group exists --name $resourceGroupName) = false ]; then
	echo "Resource group with name" $resourceGroupName "could not be found. Creating new resource group.."
	set -e
	(
		set -x
		az group create --name $resourceGroupName --location $resourceGroupLocation 1> /dev/null
	)
else
	echo "Using existing resource group..."
fi

if [ $(az group exists --name $hl7converterrg) = false ]; then
	echo "Resource group with name" $hl7converterrg "could not be found. Creating new resource group.."
	set -e
	(
		set -x
		az group create --name $hl7converterrg --location $resourceGroupLocation 1> /dev/null
	)
else
	echo "Using existing resource group for converter deployment..."
fi
#Set up variables
faresourceid="/subscriptions/"$subscriptionId"/resourceGroups/"$resourceGroupName"/providers/Microsoft.Web/sites/"$faname
#Start deployment
echo "Starting HL72FHIR Workflow Platform deployment..."
(
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



