diff --git a/endpointmanager/pkg/chplendpointquerier/chplendpointquerier.go b/endpointmanager/pkg/chplendpointquerier/chplendpointquerier.go index 27a154dff..969c6a0ff 100644 --- a/endpointmanager/pkg/chplendpointquerier/chplendpointquerier.go +++ b/endpointmanager/pkg/chplendpointquerier/chplendpointquerier.go @@ -119,7 +119,7 @@ var novomediciURL = "https://www.novomedici.com/api-documents/" var patientpatternURL = "https://patientpattern-static.s3.us-west-2.amazonaws.com/static/documents/fhir-base-urls.csv" var pcisgoldURL = "https://fhir.pcisgold.com/fhirdocs/practices.json" -// var healthieURL = "https://app-52512.on-aptible.com/service-base-urls" +var healthieURL = "https://app-52512.on-aptible.com/service-base-urls" var medConnectURL = "https://api.medconnecthealth.com/fhir/r4/endpoints" var citiusTechURL = "https://8759937.fs1.hubspotusercontent-na1.net/hubfs/8759937/assets/pdfs/Perform+ConnectServerEndpoints.json" var enableHealthcareURL = "https://ehifire.ehiconnect.com/fhir/r4/endpoints" @@ -243,7 +243,7 @@ func QueryCHPLEndpointList(chplURL string, fileToWriteTo string) { } else if URLsEqual(chplURL, firstInsightURL) { FirstInsightBundleParser(chplURL, fileToWriteTo) } else if URLsEqual(chplURL, healthSamuraiURL) { - HealthSamuraiWebscraper("https://smartbox.aidbox.app/service-base-urls", fileToWriteTo) + CustomBundleQuerierParser("https://smartbox.aidbox.app/service-base-urls", fileToWriteTo) } else if URLsEqual(chplURL, triarqURL) { TRIARQPracticeWebscraper(chplURL, fileToWriteTo) } else if URLsEqual(chplURL, cyfluentURL) { @@ -406,8 +406,8 @@ func QueryCHPLEndpointList(chplURL string, fileToWriteTo string) { PatientpatternURLCSVParser(chplURL, fileToWriteTo) } else if URLsEqual(chplURL, pcisgoldURL) { PCISgoldURLWebscraper(chplURL, fileToWriteTo) - // } else if URLsEqual(chplURL, healthieURL) { - // BundleQuerierParser(chplURL, fileToWriteTo) + } else if URLsEqual(chplURL, healthieURL) { + CustomBundleQuerierParser(chplURL, fileToWriteTo) } else if URLsEqual(chplURL, medConnectURL) { BundleQuerierParser(chplURL, fileToWriteTo) } else if URLsEqual(chplURL, citiusTechURL) { diff --git a/endpointmanager/pkg/chplendpointquerier/custombundlequerierparser.go b/endpointmanager/pkg/chplendpointquerier/custombundlequerierparser.go new file mode 100644 index 000000000..a4df4272e --- /dev/null +++ b/endpointmanager/pkg/chplendpointquerier/custombundlequerierparser.go @@ -0,0 +1,51 @@ +package chplendpointquerier + +import ( + "encoding/json" + + "github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/helpers" + log "github.com/sirupsen/logrus" +) + +type CustomBundle struct { + Entries []CustomBundleEntry `json:"entry"` +} + +type CustomBundleEntry struct { + Id string `json:"id"` + Name string `json:"name"` + Url string `json:"url"` +} + +func CustomBundleQuerierParser(CHPLURL string, fileToWriteTo string) { + + var entry LanternEntry + var lanternEntryList []LanternEntry + var endpointEntryList EndpointList + + respBody, err := helpers.QueryEndpointList(CHPLURL) + if err != nil { + log.Fatal(err) + } + + var customBundle CustomBundle + err = json.Unmarshal(respBody, &customBundle) + if err != nil { + log.Fatal(err) + } + + for _, bundleEntry := range customBundle.Entries { + entry.URL = bundleEntry.Url + entry.OrganizationName = bundleEntry.Name + + lanternEntryList = append(lanternEntryList, entry) + } + + endpointEntryList.Endpoints = lanternEntryList + + err = WriteCHPLFile(endpointEntryList, fileToWriteTo) + if err != nil { + log.Fatal(err) + } + +} diff --git a/endpointmanager/pkg/chplendpointquerier/healthsamuraiparser.go b/endpointmanager/pkg/chplendpointquerier/healthsamuraiparser.go deleted file mode 100644 index f2076ca28..000000000 --- a/endpointmanager/pkg/chplendpointquerier/healthsamuraiparser.go +++ /dev/null @@ -1,45 +0,0 @@ -package chplendpointquerier - -import ( - "strings" - - "github.com/PuerkitoBio/goquery" - "github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/helpers" - log "github.com/sirupsen/logrus" -) - -func HealthSamuraiWebscraper(CHPLURL string, fileToWriteTo string) { - - var lanternEntryList []LanternEntry - var endpointEntryList EndpointList - - doc, err := helpers.ChromedpQueryEndpointList(CHPLURL, ".container") - if err != nil { - log.Fatal(err) - } - - doc.Find(".container").Each(func(index int, containterElems *goquery.Selection) { - containterElems.Find(".row").Each(func(index int, rowElems *goquery.Selection) { - rowElems.Find(".col-12").Each(func(index int, colElems *goquery.Selection) { - colElems.Find("ul").Each(func(index int, ulElems *goquery.Selection) { - ulElems.Find("li").Each(func(index int, liElems *goquery.Selection) { - var entry LanternEntry - - entryURL := strings.TrimSpace(liElems.Text()) - entry.URL = entryURL - - lanternEntryList = append(lanternEntryList, entry) - }) - }) - }) - }) - }) - - endpointEntryList.Endpoints = lanternEntryList - - err = WriteCHPLFile(endpointEntryList, fileToWriteTo) - if err != nil { - log.Fatal(err) - } - -}