-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
75,588 additions
and
75,142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
querier "github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/medicaidendpointquerier" | ||
|
||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
func main() { | ||
|
||
var fileToWriteTo string | ||
|
||
if len(os.Args) >= 1 { | ||
fileToWriteTo = os.Args[1] | ||
} else { | ||
log.Fatalf("ERROR: Missing command-line arguments") | ||
} | ||
|
||
querier.QueryMedicaidEndpointList(fileToWriteTo) | ||
} |
123 changes: 123 additions & 0 deletions
123
endpointmanager/pkg/medicaidendpointquerier/medicaidendpointquerier.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
package medicaidendpointquerier | ||
|
||
import ( | ||
"encoding/csv" | ||
"encoding/json" | ||
"io" | ||
"io/ioutil" | ||
"log" | ||
"os" | ||
"strings" | ||
) | ||
|
||
type EndpointList struct { | ||
Endpoints []LanternEntry `json:"Endpoints"` | ||
} | ||
|
||
type LanternEntry struct { | ||
URL string `json:"URL"` | ||
OrganizationName string `json:"OrganizationName"` | ||
NPIID string `json:"NPIID"` | ||
OrganizationZipCode string `json:"OrganizationZipCode"` | ||
} | ||
|
||
func QueryMedicaidEndpointList(fileToWriteTo string) { | ||
var lanternEntryList []LanternEntry | ||
var endpointEntryList EndpointList | ||
|
||
csvFilePath := "../../../resources/prod_resources/medicaid-state-endpoints.csv" | ||
csvReader, file, err := QueryAndOpenCSV(csvFilePath, true) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
defer file.Close() | ||
for { | ||
rec, err := csvReader.Read() | ||
if err == io.EOF { | ||
break | ||
} | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
var entry LanternEntry | ||
|
||
organizationName := strings.TrimSpace(rec[0]) | ||
URL := strings.TrimSpace(rec[1]) | ||
|
||
entry.OrganizationName = organizationName | ||
entry.URL = URL | ||
|
||
lanternEntryList = append(lanternEntryList, entry) | ||
} | ||
|
||
endpointEntryList.Endpoints = lanternEntryList | ||
err = WriteCHPLFile(endpointEntryList, fileToWriteTo) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
|
||
func QueryAndOpenCSV(csvFilePath string, header bool) (*csv.Reader, *os.File, error) { | ||
|
||
// open file | ||
f, err := os.Open(csvFilePath) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
// read csv values using csv.Reader | ||
csvReader := csv.NewReader(f) | ||
csvReader.Comma = ',' // Set the delimiter (default is ',') | ||
csvReader.LazyQuotes = true // Enable handling of lazy quotes | ||
|
||
if header { | ||
// Read first line to skip over headers | ||
_, err = csvReader.Read() | ||
if err != nil { | ||
return nil, f, err | ||
} | ||
} | ||
|
||
return csvReader, f, nil | ||
} | ||
|
||
// WriteCHPLFile writes the given endpointEntryList to a json file and stores it in the prod resources directory | ||
func WriteCHPLFile(endpointEntryList EndpointList, fileToWriteTo string) error { | ||
finalFormatJSON, err := json.MarshalIndent(endpointEntryList, "", "\t") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = ioutil.WriteFile("../../../resources/prod_resources/"+fileToWriteTo, finalFormatJSON, 0644) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if len(endpointEntryList.Endpoints) > 10 { | ||
endpointEntryList.Endpoints = endpointEntryList.Endpoints[0:10] | ||
} | ||
|
||
reducedFinalFormatJSON, err := json.MarshalIndent(endpointEntryList, "", "\t") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = ioutil.WriteFile("../../../resources/dev_resources/"+fileToWriteTo, reducedFinalFormatJSON, 0644) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func URLsEqual(chplURL string, savedURL string) bool { | ||
savedURLNorm := strings.TrimSuffix(savedURL, "/") | ||
chplURLNorm := strings.TrimSuffix(chplURL, "/") | ||
|
||
savedURLNorm = strings.TrimPrefix(savedURLNorm, "https://") | ||
chplURLNorm = strings.TrimPrefix(chplURLNorm, "https://") | ||
savedURLNorm = strings.TrimPrefix(savedURLNorm, "http://") | ||
chplURLNorm = strings.TrimPrefix(chplURLNorm, "http://") | ||
|
||
return savedURLNorm == chplURLNorm | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from selenium import webdriver | ||
from selenium.webdriver.chrome.options import Options | ||
from selenium.webdriver.common.keys import Keys | ||
from selenium.webdriver.common.by import By | ||
from selenium.webdriver.support.ui import WebDriverWait | ||
from selenium.webdriver.support import expected_conditions as EC | ||
|
||
# Path to the WebDriver executable (download from Selenium website) | ||
#driver_path = '/path/to/webdriver/executable' | ||
|
||
chrome_options = Options() | ||
chrome_options.add_argument('--headless') # Run in headless mode | ||
chrome_options.add_argument('--disable-gpu') # Disable GPU acceleration | ||
|
||
# Initialize the WebDriver for Chrome | ||
#driver = webdriver.Chrome(executable_path=driver_path) | ||
driver = webdriver.Chrome(options=chrome_options) | ||
|
||
# Open the Shiny app URL | ||
driver.get('http://localhost:8090/?tab=dashboard_tab') | ||
|
||
# Wait for specific element to be present | ||
try: | ||
element = WebDriverWait(driver, 3600).until( | ||
EC.presence_of_element_located((By.ID, "httpvendor")) | ||
) | ||
print("Element found:", element.text) | ||
except: | ||
print("Element not found within 10 seconds") | ||
|
||
# Close the browser window | ||
driver.quit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.