Skip to content

Commit

Permalink
LANTERN-782-Add-curemd-webscraper
Browse files Browse the repository at this point in the history
  • Loading branch information
archita-ekkirala committed Nov 8, 2024
1 parent d8f98ab commit 9b68e3c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ var pointclickURL = "https://fhir.pointclickcare.com/"
var nextgenPracticeURL = "https://www.nextgen.com/api/practice-search"
var aspmdURL = "https://fhirapi.asp.md:3030/aspmd/fhirserver/fhir_aspmd.asp"
var axeiumURL = "https://apifhir.axeium.net:8443/reference-server/"
var curemdURL = "https://www.curemd.com/developer/base-fhir-urls/"

var bundleQuerierArray = [30]string{"https://ac-fhir.harrisambulatory.com/endpoints/r4", "https://dynamicfhirpresentation.dynamicfhirsandbox.com/fhir/r4/endpoints",
"https://ct-fhir.harrisambulatory.com/Endpoints/R4", "https://kantime.com/wp-content/uploads/2024/03/fhir-base-urls.json",
Expand Down Expand Up @@ -552,6 +553,8 @@ func QueryCHPLEndpointList(chplURL string, fileToWriteTo string) {
AxeiumeWebscraper(axeiumURL, fileToWriteTo)
} else if contains(bundleQuerierArray, chplURL) {
BundleQuerierParser(chplURL, fileToWriteTo)
} else if URLsEqual(chplURL, curemdURL) {
CuremdWebscraper(curemdURL, fileToWriteTo)
} else {
log.Warnf("Handler is required for url %s", chplURL)
}
Expand Down
45 changes: 45 additions & 0 deletions endpointmanager/pkg/chplendpointquerier/curemdwebscraper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package chplendpointquerier

import (
"strings"

"github.com/PuerkitoBio/goquery"
"github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/helpers"
log "github.com/sirupsen/logrus"
)

func CuremdWebscraper(CHPLURL string, fileToWriteTo string) {

var entry LanternEntry
var lanternEntryList []LanternEntry
var endpointEntryList EndpointList

doc, err := helpers.ChromedpQueryEndpointList(CHPLURL, "")
if err != nil {
log.Fatal(err)
}

doc.Find("label").Each(func(index int, item *goquery.Selection) {
labelText := strings.TrimSpace(item.Text())
if labelText == "Capability Statement:" {
pTag := item.NextFiltered("p")
if pTag.Length() > 0 {
pTag.Find("a").Each(func(i int, link *goquery.Selection) {
url, exists := link.Attr("href")
if exists {
entry.URL = url
lanternEntryList = append(lanternEntryList, entry)
}
})
}
}
})

endpointEntryList.Endpoints = lanternEntryList

err = WriteCHPLFile(endpointEntryList, fileToWriteTo)
if err != nil {
log.Fatal(err)
}

}

0 comments on commit 9b68e3c

Please sign in to comment.