Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lantern 575 1 up webscraper #415

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 40 additions & 8 deletions endpointmanager/pkg/chplendpointquerier/csvparser.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package chplendpointquerier

import (
"encoding/csv"
"io"
"strings"

Expand All @@ -11,15 +12,44 @@ import (
log "github.com/sirupsen/logrus"
)

func CSVParser(CHPLURL string, fileToWriteTo string, csvFilePath string, numrecords int, startrecord int, header bool, urlIndex int, organizationIndex int) {
// CSVParser reads a CSV from a URL or file and writes processed data to an output file.
// Parameters:
// - inputSource: URL or file path of the input CSV.
// - fileToWriteTo: File path to write the processed data.
// - csvFilePath: Temporary file path for storing the downloaded CSV (if applicable).
// - numrecords: Number of records to process (-1 for all records).
// - startrecord: Starting index of records to process.
// - header: Boolean indicating if the CSV has a header to skip.
// - urlIndex: Column index where the URL is located.
// - organizationIndex: Column index where the organization name is located.
func CSVParser(inputSource string, fileToWriteTo string, csvFilePath string, numrecords int, startrecord int, header bool, urlIndex int, organizationIndex int) {
var lanternEntryList []LanternEntry
var endpointEntryList EndpointList

csvReader, file, err := helpers.QueryAndOpenCSV(CHPLURL, csvFilePath, header)
if err != nil {
log.Fatal(err)
var csvReader *csv.Reader
var file *os.File
var err error
if strings.HasPrefix(inputSource, "http://") || strings.HasPrefix(inputSource, "https://") {
csvReader, file, err = helpers.QueryAndOpenCSV(inputSource, csvFilePath, header)
if err != nil {
log.Fatal(err)
}
defer file.Close()
} else {
file, err = os.Open(inputSource)
if err != nil {
log.Fatal(err)
}
defer file.Close()

csvReader = csv.NewReader(file)
if header {
_, err := csvReader.Read()
if err != nil {
log.Fatal(err)
}
}
}
defer file.Close()

records := 0
for {
Expand Down Expand Up @@ -59,8 +89,10 @@ func CSVParser(CHPLURL string, fileToWriteTo string, csvFilePath string, numreco
log.Fatal(err)
}

err = os.Remove(csvFilePath)
if err != nil {
log.Fatal(err)
if _, err := os.Stat(csvFilePath); err == nil {
err = os.Remove(csvFilePath)
if err != nil {
log.Fatal(err)
}
}
}
4 changes: 3 additions & 1 deletion endpointmanager/pkg/endpointwebscraper/endpointwebscraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package endpointwebscraper
import (
"encoding/json"
"os"

"github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/chplendpointquerier"
)

type EndpointList struct {
Expand All @@ -24,7 +26,7 @@ func EndpointListWebscraper(vendorURL string, vendor string, fileToWriteTo strin
if vendorURL == careEvolutionURL {
HTMLtablewebscraper(vendorURL, vendor, fileToWriteTo)
} else if vendorURL == oneUpURL {
OneUpQuerier("https://api.1up.health/connect/system/clinical", fileToWriteTo)
chplendpointquerier.CSVParser("../../../resources/prod_resources/oneupdata.csv", "1UpEndpointSources.json", "", -1, 0, true, 2, 0)
}
}

Expand Down
72 changes: 72 additions & 0 deletions resources/prod_resources/oneupdata.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
Parent Organization Name,"Brand Name(s) (displayed in auth app, recognizable by members)",Prod FHIR URL (Resource URL),Notes
AHF,AIDS Healthcare Foundation (AHF),https://api.ahffhir.com/r4,
AHF,Positive Healthcare,https://api.ahffhir.com/r4,
Arkansas,Arkansas Medicaid,https://api.arkansasfhir.com/r4,
Centers Health Plan,Centers Plan Healthy Living (CPHL),https://api.cphlfhir.com/r4,
Cox HealthPlans,Cox HealthPlans,https://api.coxhealthplanfhir.com/r4,
Dean Health Plan,Dean Health Plan,https://api.deanhealthfhir.com/r4,
Dean Health Plan,WellFirst Health (WFH),https://api.deanhealthfhir.com/r4,
Dean Health Plan,WFH provided by SSM Health Plan (WFH SSM),https://api.deanhealthfhir.com/r4,
Dean Health Plan,PREVEA360 (P360),https://api.deanhealthfhir.com/r4,
Delaware State Medicaid,Delaware Medicaid,https://api.delawarefhir.com/r4,
Hamaspik Choice,Hamaspik Choice,https://api.hamaspikfhir.com/r4,
GlobalHealth,GlobalHealth,https://api.globalhealthfhir.com/r4,
HealthPartners,HealthPartners,https://api/healthpartnersfhir.com/rt,
Harvard Pilgrim,Harvard Pilgrim,https://api.hphcfhir.com/r4,
Southwestern Health,Care N' Care,https://api.swhrfhir.com/r4,
Health Plan San Mateo (HPSM),Health Plan San Mateo (HPSM),https://api.hpsmfhir.com/r4,
Inclusa,Inclusa,https://api.inclusafhir.com/r4,
Kentucky,Kentucky Medicaid,https://api.kentuckyfhir.com/r4,
Network Health,Network Health,https://api.networkhealthfhir.com/r4,
Oscar,Oscar,https://api.oscarfhir.com/r4,
Partners Health Management,Partners Health Management,https://api.partnershealthfhir.com/r4,
State of Kansas,Kansas Medical Assistance Program (KMAP),https://api.kansasfhir.com/r4,
Vaya Health,Vaya Health,https://api.vayahealthfhir.com/r4,
Visiting Nurse Service of New York (VNSNY),VNSNY,https://api.vnshealthfhir.com/r4,
Visiting Nurse Service of New York (VNSNY),VNSNY CHOICE,https://api.vnshealthfhir.com/r4,
Western Health,Western Health Advantage,https://api.westernhealthfhir.com/r4,
Zing Health,Zing Health,https://api.zinghealthfhir.com/r4,
Boston Medical Center (BMC) Health,"BMC HealthNet Plan
Well Sense Health Plan",https://api.bmcfhir.com/r4,
Georgia,Georgie Medicaid,https://api.georgiafhir.com/r4,
Maine,MaineCare,https://api.mainefhir.com/r4,
Nevada,Nevada Medicaid,https://api.nevadafhir.com/r4,
Oklahoma,Oklahoma Health Care Authority,https://api.oklahomafhir.com/r4,
Rhode Island,Rhode Island Medicaid,https://api.rhodeislandfhir.com/r4,
State of Louisiana,Louisiana Medicaid,https://api.louisianafhir.com/r4,
Tufts Health Plan,Tufts Health Public Plans (THPP),https://api.tuftsfhir.com/r4,
Tufts Health Plan,CarePartners of CT (CPCT),https://api.tuftsfhir.com/r4,
Tufts Health Plan,Tufts Senior Plan (Medicare),https://api.tuftsfhir.com/r4,
West Virginia,West Viriginia Medicaid,https://api.westvirginiafhir.com/r4,
Wisconsin,Wisconsin Department of Health Services,https://api.wisconsinfhir.com/r4,
Cook County Health,Cook County Health CountyCare ,https://api.cookcountyhealthfhir.com/r4,
Priority Health,,https://api.priorityfhir.com/r4,
Empower Health,Empower Health,https://api.empowerfhir.com/r4,
Physicians Health Plan,,https://api.phpfhir.com/r4,
AultCare,AultCare,https://api.aultcarefhir.com/r4,
Alaska,Alaska Department of Health,https://api.alaskafhir.com/r4,
Georgia,Georgia Department of Community Health,https://api.georgiafhir.com/r4,
Health First Health Plans,Health First ,https://api.healthfirstfhir.com/r4,
Mass General Brigham Health Plan ,MGB Health Plan,https://api.mgbhealthplanfhir.com/r4,
Fallon Health,Fallon Health,https://api.fallonhealthfhir.com/r4,
Maryland Physicians Care,Maryland Physicians Care,https://api.mpcfhir.com/r4,
MassHealth,MassHealth,https://api.masshealthfhir.com/r4,
New York Meidcaid,,,
Vermont Medicaid ,Vermont Medicaid,https://api.vermontfhir.com/r4,
Blue Cross Blue Shield Nebraska,Blue Cross Blue Shield Nebraska,https://api.bcbsnefhir.com/r4,
The Health Plan of West Virginia,The Health Plan ,https://api.thehealthplanfhir.com/r4,
MMM Healthcare,MMM Healthcare,https://api.mmmhealthcarefhir.com/r4,
MMM Healthcare,MMM Multihealth,https://api.mmmhealthcarefhir.com/r4,
Sendero Health Plans,Sendero Health Plans,https://api.senderohealthfhir.com/r4,
Cascade Health Alliance,Cascade Health Alliance,https://api.cascadecompfhir.com/r4,
Iowa Health and Human Service,Iowa Health and Human Service,https://api.iowafhir.com/r4,
Oklahoma Health Care Authority ,Oklahoma Health Care Authority ,https://api.oklahomafhir.com/r4,
Viva Health,Viva Health,https://api.vivahealthfhir.com/r4,
Medical Card System,Medical Card System,https://api.mcsfhir.com/r4,
Yamhill Community Care,Yamhill Community Care,https://api.yamhillfhir.com/r4,
Independent Living System,Florida Community Care,https://api.ilshealthfhir.com/r4/,
Independent Living System,Florida Complete Care,https://api.ilshealthfhir.com/r4/,
Commonwealth of PA (CoPa),Commonwealth of PA (CoPA),https://api.pennsylvaniafhir.com/r4,
Alliant Health Plans,Alliant Health Plans,https://api.allianthealthplansfhir.com/r4,
BayCare,BayCare,https://api.baycarefhir.com/r4,
UCare,UCare,https://api.ucarefhir.com/r4,
Loading