Skip to content

Commit

Permalink
Implemented logging for the query-endpoint-resources.sh script
Browse files Browse the repository at this point in the history
  • Loading branch information
rishi-salunkhe-mettle committed Sep 23, 2024
1 parent 97c4769 commit 7a9e403
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions scripts/query-endpoint-resources.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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

0 comments on commit 7a9e403

Please sign in to comment.