Skip to content

Commit

Permalink
Merge pull request #463 from onc-healthit/LANTERN-803-add-webscraper-…
Browse files Browse the repository at this point in the history
…chntechsolns

LANTERN-803: Add webscraper chntechsolns
  • Loading branch information
vishnu-mettles authored Dec 16, 2024
2 parents d524cef + 845966c commit 81d9061
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package chplendpointquerier

import (
"regexp"
"strings"

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

func ChntechsolutionsWebscraper(CHPLURL string, fileToWriteTo string) {

var lanternEntryList []LanternEntry
var endpointEntryList EndpointList
var entry LanternEntry

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

doc.Find("p").Each(func(index int, phtml *goquery.Selection) {
phtml.Find("code").Each(func(index int, phtml *goquery.Selection) {
urlString := strings.ReplaceAll(phtml.Text(), "\n", " ")
pattern := `https[^\s]*metadata`
re := regexp.MustCompile(pattern)
match := re.FindString(urlString)
if len(match) != 0 {
match = strings.TrimSpace(match)
entry.URL = strings.TrimSuffix(match, "/metadata")
lanternEntryList = append(lanternEntryList, entry)
endpointEntryList.Endpoints = lanternEntryList
}

})
})

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ var curemdURL = "https://www.curemd.com/developer/base-fhir-urls/"
var emdscloudURL = "https://identity.emdscloud.com/api/api-resource/fhir"
var betaAfoundriaURL = "https://beta.afoundria.com/api/fhir/urls"
var ehealthlineURL = "http://ehealthline.com/dev/pdf/FHIR%20API%20Endpoints.htm"
var chntechURL = "https://onc.chntechsolutions.com/ic-ehr-fhir-api/"
var zoobooksystemsURL = "https://zoobooksystems.com/api-documentation/"

var bundleQuerierArray = [30]string{"https://ac-fhir.harrisambulatory.com/endpoints/r4", "https://dynamicfhirpresentation.dynamicfhirsandbox.com/fhir/r4/endpoints",
Expand Down Expand Up @@ -586,6 +587,8 @@ func QueryCHPLEndpointList(chplURL string, fileToWriteTo string) {
CSVParser(chplURL, fileToWriteTo, "./endpoints.csv", -1, 0, true, 1, 0)
} else if URLsEqual(chplURL, ehealthlineURL) {
EhealthlineWebscraper(ehealthlineURL, fileToWriteTo)
} else if URLsEqual(chplURL, chntechURL) {
ChntechsolutionsWebscraper(chplURL, fileToWriteTo)
} else if URLsEqual(chplURL, zoobooksystemsURL) {
err = ZoobooksystemsWebscraper(zoobooksystemsURL, fileToWriteTo)
} else {
Expand Down

0 comments on commit 81d9061

Please sign in to comment.