diff --git a/endpointmanager/pkg/chplendpointquerier/chntechsolutionswebscraper.go b/endpointmanager/pkg/chplendpointquerier/chntechsolutionswebscraper.go new file mode 100644 index 000000000..175fa75bd --- /dev/null +++ b/endpointmanager/pkg/chplendpointquerier/chntechsolutionswebscraper.go @@ -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) + } + +} diff --git a/endpointmanager/pkg/chplendpointquerier/chplendpointquerier.go b/endpointmanager/pkg/chplendpointquerier/chplendpointquerier.go index 9c33bb761..a522cf8c8 100644 --- a/endpointmanager/pkg/chplendpointquerier/chplendpointquerier.go +++ b/endpointmanager/pkg/chplendpointquerier/chplendpointquerier.go @@ -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", @@ -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 {