Skip to content

Commit

Permalink
Added EzemrxWebscraper and its unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
rishi-salunkhe-mettle committed Nov 13, 2024
1 parent 52471df commit bc387bf
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ var bundleQuerierArray = [30]string{"https://ac-fhir.harrisambulatory.com/endpoi
"https://appstudio.interopengine.com/partner/fhirR4endpoints-umc.json", "https://testauth.strateqhealth.com/SmartOnFHIR/ValidURLs.json",
"https://fhir.ethizo.com/api/4.0.0/service_based_url"}

var ezemrxURL = "https://www.ezemrx.com/fhir"

func contains(arr [30]string, str string) bool {
for _, v := range arr {
if v == str {
Expand Down Expand Up @@ -550,6 +552,8 @@ func QueryCHPLEndpointList(chplURL string, fileToWriteTo string) {
AspMDeWebscraper(aspmdURL, fileToWriteTo)
} else if URLsEqual(chplURL, axeiumURL) {
AxeiumeWebscraper(axeiumURL, fileToWriteTo)
} else if URLsEqual(chplURL, ezemrxURL) {
EzemrxWebscraper(chplURL, fileToWriteTo)
} else if contains(bundleQuerierArray, chplURL) {
BundleQuerierParser(chplURL, fileToWriteTo)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ func TestWebScrapers(t *testing.T) {
url: "https://fhirapi.asp.md:3030/aspmd/fhirserver/fhir_aspmd.asp",
fileName: "ASPMD_Inc_EndpointSources.json",
},
{
scraperFunc: EzemrxWebscraper,
url: "https://www.ezemrx.com/fhir",
fileName: "ezEMRx_Inc_EndpointSources.json",
},
}

for _, tc := range testCases {
Expand Down
38 changes: 38 additions & 0 deletions endpointmanager/pkg/chplendpointquerier/ezemrxwebscraper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package chplendpointquerier

import (
"strings"

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

func EzemrxWebscraper(CHPLURL string, fileToWriteTo string) {

var lanternEntryList []LanternEntry
var endpointEntryList EndpointList
var entry LanternEntry

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

divElem := doc.Find("#comp-lb6njyhb").First()
pElem := divElem.Find("p").First()
spanElem := pElem.Find("span").First()

parts := strings.Split(spanElem.Text(), "\n")

entry.URL = strings.TrimSpace(parts[1])

lanternEntryList = append(lanternEntryList, entry)

endpointEntryList.Endpoints = lanternEntryList

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

}

0 comments on commit bc387bf

Please sign in to comment.