Skip to content

Commit

Permalink
Medicaid endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
svginc committed Apr 1, 2024
1 parent d46b644 commit 2854fc4
Show file tree
Hide file tree
Showing 17 changed files with 75,588 additions and 75,142 deletions.
22 changes: 22 additions & 0 deletions endpointmanager/cmd/medicaidendpointquerier/main.go
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 endpointmanager/pkg/medicaidendpointquerier/medicaidendpointquerier.go
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
}
32 changes: 32 additions & 0 deletions refresh.py
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()
26 changes: 16 additions & 10 deletions resources/dev_resources/CHPLEndpointResourcesList.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@
{
"FormatType": "Lantern",
"URL": "https://unify-developer.chbase.com/?page=FHIRAPI",
"EndpointName": "Get Real Health",
"FileName": "Get_Real_Health_EndpointSources.json"
"EndpointName": "TruBridge, Inc.",
"FileName": "TruBridge_Inc_EndpointSources.json"
},
{
"FormatType": "Lantern",
Expand Down Expand Up @@ -415,7 +415,7 @@
},
{
"FormatType": "Lantern",
"URL": "https://fhir.myeyecarerecords.com/fhir-endpoints",
"URL": "https://smartonfhir.myeyecarerecords.com/fhir/Endpoint?_format=application/fhir+json\u0026status=active",
"EndpointName": "EyeMD EMR Healthcare Systems, Inc.",
"FileName": "EyeMD_EMR_Healthcare_Systems_Inc_EndpointSources.json"
},
Expand Down Expand Up @@ -533,12 +533,6 @@
"EndpointName": "InteliChart LLC",
"FileName": "InteliChart_LLC_EndpointSources.json"
},
{
"FormatType": "Lantern",
"URL": "https://www.nextech.com/developers-portal",
"EndpointName": "Nextech",
"FileName": "Nextech_EndpointSources.json"
},
{
"FormatType": "Lantern",
"URL": "https://www.meditab.com/fhir/endpoints",
Expand Down Expand Up @@ -761,6 +755,12 @@
"EndpointName": "NextGen Healthcare",
"FileName": "NextGen_Healthcare_1_EndpointSources.json"
},
{
"FormatType": "Lantern",
"URL": "https://www.nextech.com/developers-portal",
"EndpointName": "Nextech",
"FileName": "Nextech_EndpointSources.json"
},
{
"FormatType": "Lantern",
"URL": "https://www.nextech.com/hubfs/Nextech%20FHIR%20Base%20URL.csv",
Expand Down Expand Up @@ -1033,10 +1033,16 @@
},
{
"FormatType": "Lantern",
"URL": "https://dhfhirpresentation.smartcarenet.com/fhir/r4/endpoints",
"URL": "https://dhfhirpresentation.smartcarenet.com/",
"EndpointName": "Streamline Healthcare Solutions",
"FileName": "Streamline_Healthcare_Solutions_EndpointSources.json"
},
{
"FormatType": "Lantern",
"URL": "https://dhfhirpresentation.smartcarenet.com/fhir/r4/endpoints",
"EndpointName": "Streamline Healthcare Solutions",
"FileName": "Streamline_Healthcare_Solutions_1_EndpointSources.json"
},
{
"FormatType": "Lantern",
"URL": "https://smilecdr.com/docs/javascript_execution_environment/fhir_rest.html",
Expand Down
Loading

0 comments on commit 2854fc4

Please sign in to comment.