From 9b68e3c3c14579f3e4256d80ef5f112d388ce387 Mon Sep 17 00:00:00 2001 From: archita-ekkirala Date: Fri, 8 Nov 2024 09:44:49 -0600 Subject: [PATCH] LANTERN-782-Add-curemd-webscraper --- .../chplendpointquerier.go | 3 ++ .../chplendpointquerier/curemdwebscraper.go | 45 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 endpointmanager/pkg/chplendpointquerier/curemdwebscraper.go diff --git a/endpointmanager/pkg/chplendpointquerier/chplendpointquerier.go b/endpointmanager/pkg/chplendpointquerier/chplendpointquerier.go index 4d7c2013d..ebe9e75f9 100644 --- a/endpointmanager/pkg/chplendpointquerier/chplendpointquerier.go +++ b/endpointmanager/pkg/chplendpointquerier/chplendpointquerier.go @@ -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", @@ -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) } diff --git a/endpointmanager/pkg/chplendpointquerier/curemdwebscraper.go b/endpointmanager/pkg/chplendpointquerier/curemdwebscraper.go new file mode 100644 index 000000000..40a561370 --- /dev/null +++ b/endpointmanager/pkg/chplendpointquerier/curemdwebscraper.go @@ -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) + } + +}