Summary Table
| Categories |
Total Count |
| PII |
0 |
| URL |
0 |
| DNS |
0 |
| EKL |
0 |
| IP |
0 |
| PORT |
0 |
| VsID |
0 |
| CF |
0 |
| AI |
0 |
| VPD |
0 |
| PL |
0 |
| Other |
0 |
File Content
#!/bin/bash
usage()
{
echo "Usage:$0 <api-gateway-base> <pgd host:port> <veteran ICN> "
echo "Ex: load-data-clean-all.sh localhost:8089 localhost:7777 1006088937V099668"
echo ""
echo "##############################################################################################"
echo "Script requires API Gateway host:port, PGD FHIR host:port, and veteran ICN to run. <mandatory>"
echo "##############################################################################################"
}
if [[ $# -eq 0 ]]; then
usage
exit 1
fi
BASE_URL=$1
PGD_FHIR_URL=$2
ICN=$3
printf "BASE_URL = $BASE_URL\n"
printf "PGD_FHIR_URL = $PGD_FHIR_URL\n"
printf "ICN = $ICN\n"
printf "\nGenerating JWT\n"
printf "===========================================\n"
JWT=$(curl "$BASE_URL/jwt" -H "va_eauth_icn: $ICN" --insecure)
echo $JWT
printf "\nRetrieving Current QuestionnaireResponses\n"
printf "===========================================\n"
responseResults=$(curl -G --header "X-VAMF-JWT: $JWT" --insecure --header "Content-Type:application/json" "http://${PGD_FHIR_URL}/pgd-fhir-services/v1/fhir/QuestionnaireResponse" --data-urlencode "_count=100" --data-urlencode "_tag=f6879a68-49da-490b-a964-b6899ab4cd6b")
count=$(jq ".total" <<< $responseResults)
printf "\nResults found: $count\n"
# only delete if there are responseResults returned
if [[ $count -ne 0 ]]; then
printf "\nDeleting Current QuestionnaireResponses\n"
printf "===========================================\n"
response_resources_urls=$(jq ".entry[].fullUrl" <<< $responseResults)
printf "responseResults:\n$response_resources_urls"
while read -r line; do
# trim beginning and trailing quotes
len=${#line}-1
line="${line:1:len-1}"
curl -X DELETE ${line} --header "X-VAMF-JWT: $JWT" --insecure --header "Content-Type:application/json"
done <<< "$response_resources_urls"
fi
printf "\nRetrieving Current Questionnaires\n"
printf "===========================================\n"
results=$(curl -G --header "X-VAMF-JWT: $JWT" --insecure --header "Content-Type:application/json" "http://${PGD_FHIR_URL}/pgd-fhir-services/v1/fhir/Questionnaire" --data-urlencode "publisher=MyVAImages" --data-urlencode "_count=100")
count=$(jq ".total" <<< $results)
printf "\nResults found: $count\n"
printf "===========================================\n"
# only delete if there are results returned
if [[ $count -ne 0 ]]; then
printf "\nDeleting Current Questionnaires\n"
printf "===========================================\n"
resources_urls=$(jq ".entry[].fullUrl" <<< $results)
printf "results:\n$resources_urls"
while read -r line; do
# trim beginning and trailing quotes
len=${#line}-1
line="${line:1:len-1}"
curl -X DELETE ${line} --header "X-VAMF-JWT: $JWT" --insecure --header "Content-Type:application/json"
done <<< "$resources_urls"
fi
printf "\nSeeding Questionnaires Start\n"
printf "===========================================\n"
while read -r line || [[ -n $line ]];
do
if [ ${line:0:1} == "[" ]; then
line="${line:1}"
fi
len=${#line}-1
line="${line:0:len}"
curl --data "${line}" --header "X-VAMF-JWT: $JWT" --insecure --header "Content-Type:application/json" "http://${PGD_FHIR_URL}/pgd-fhir-services/v1/fhir/Questionnaire"
done <"questionnaireDataImport.json"
printf "\nSeeding Questionnaires End\n"
printf "===========================================\n"