From 7a9e403145cb841b0ca9815c9e0b658e34c48a0d Mon Sep 17 00:00:00 2001 From: rishi-salunkhe-mettle Date: Mon, 23 Sep 2024 16:19:33 -0500 Subject: [PATCH] Implemented logging for the query-endpoint-resources.sh script --- scripts/query-endpoint-resources.sh | 33 ++++++++++++++++------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/scripts/query-endpoint-resources.sh b/scripts/query-endpoint-resources.sh index 25c9ad24d..1d7b1eea1 100755 --- a/scripts/query-endpoint-resources.sh +++ b/scripts/query-endpoint-resources.sh @@ -1,30 +1,33 @@ #!/bin/sh +log_file="/etc/lantern/logs/query-endpoint-resources_logs.txt" +current_datetime=$(date +"%Y-%m-%d %H:%M:%S") + #Iterate through endpoint source list json to query each url and store as properly named file cd .. export $(cat .env) cd resources/prod_resources -echo "Downloading Medicaid state Endpoint List..." +echo "$current_datetime - Downloading Medicaid state Endpoint List..." >> $log_file file_path="MedicaidState_EndpointSources.json" csv_file_path="medicaid-state-endpoints.csv" if [ -f "$csv_file_path" ]; then cd ../../endpointmanager/cmd/medicaidendpointquerier - echo "Querying Medicaid state endpoints..." + echo "$current_datetime - Querying Medicaid state endpoints..." >> $log_file go run main.go $file_path cd ../../../resources/prod_resources - echo "done" + echo "$current_datetime - done" >> $log_file fi -echo "Parsing State Payer Endpoint List..." +echo "$current_datetime - Parsing State Payer Endpoint List..." >> $log_file file_path="MedicareStateEndpointResourcesList.json" csv_file_path="payer-patient-access.csv" if [ -f "$csv_file_path" ]; then cd ../../endpointmanager/cmd/medicareendpointquerier - echo "Querying Medicare state endpoints..." + echo "$current_datetime - Querying Medicare state endpoints..." >> $log_file go run main.go $file_path cd ../../../resources/prod_resources - echo "done" + echo "$current_datetime - done" >> $log_file fi jq -c '.[]' EndpointResourcesList.json | while read endpoint; do @@ -34,7 +37,7 @@ jq -c '.[]' EndpointResourcesList.json | while read endpoint; do if [ -n "$URL" ]; then - echo "Downloading $NAME Endpoint Sources..." + echo "$current_datetime - Downloading $NAME Endpoint Sources..." >> $log_file if [ "$NAME" = "CareEvolution" ] || [ "$NAME" = "1Up" ]; then cd ../../endpointmanager/cmd/endpointwebscraper @@ -50,18 +53,18 @@ jq -c '.[]' EndpointResourcesList.json | while read endpoint; do jq 'del(.Endpoints.[10:])' $FILENAME > ../dev_resources/$FILENAME fi fi - echo "done" + echo "$current_datetime - done" >> $log_file fi done #Query CHPL endpoint resource list -echo "Downloading Medicare State Endpoint List..." +echo "$current_datetime - Downloading Medicare State Endpoint List..." >> $log_file URL="https://chpl.healthit.gov/rest/search/v3?api_key=${LANTERN_CHPLAPIKEY}&certificationCriteriaIds=182" FILENAME="CHPLEndpointResourcesList.json" cd ../../endpointmanager/cmd/CHPLpopulator go run main.go $URL $FILENAME cd ../../../resources/prod_resources -echo "done" +echo "$current_datetime - done" >> $log_file jq -c '.[]' MedicareStateEndpointResourcesList.json | while read endpoint; do NAME=$(echo $endpoint | jq -c -r '.EndpointName') @@ -70,14 +73,14 @@ jq -c '.[]' MedicareStateEndpointResourcesList.json | while read endpoint; do if [ -n "$URL" ]; then cd ../../endpointmanager/cmd/chplendpointquerier - echo "Downloading $NAME Endpoint Sources..." + echo "$current_datetime - Downloading $NAME Endpoint Sources..." >> $log_file go run main.go $URL $FILENAME cd ../../../resources/prod_resources - echo "done" + echo "$current_datetime - done" >> $log_file fi done -echo "Downloading CHPL Endpoint List..." +echo "$current_datetime - Downloading CHPL Endpoint List..." >> $log_file jq -c '.[]' CHPLEndpointResourcesList.json | while read endpoint; do NAME=$(echo $endpoint | jq -c -r '.EndpointName') FILENAME=$(echo $endpoint | jq -c -r '.FileName') @@ -86,9 +89,9 @@ jq -c '.[]' CHPLEndpointResourcesList.json | while read endpoint; do if [ -n "$URL" ]; then cd ../../endpointmanager/cmd/chplendpointquerier - echo "Downloading $NAME Endpoint Sources..." + echo "$current_datetime - Downloading $NAME Endpoint Sources..." >> $log_file go run main.go $URL $FILENAME cd ../../../resources/prod_resources - echo "done" + echo "$current_datetime - done" >> $log_file fi done \ No newline at end of file