-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #364 from onc-healthit/add_chpl_list_sep
Add CHPL endpoint list
- Loading branch information
Showing
57 changed files
with
63,388 additions
and
34,719 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
endpointmanager/pkg/chplendpointquerier/tenzingwebscraper.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package chplendpointquerier | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/PuerkitoBio/goquery" | ||
"github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/helpers" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
func TenzingURLWebscraper(chplURL string, fileToWriteTo string) { | ||
|
||
var lanternEntryList []LanternEntry | ||
var endpointEntryList EndpointList | ||
doc, err := helpers.ChromedpQueryEndpointList(chplURL, "main") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
fhirEndpointsHeaderElem := doc.Find("#introduction/terms-and-conditions/fhir-endpoints") | ||
if fhirEndpointsHeaderElem.Length() > 0 { | ||
spanElem := fhirEndpointsHeaderElem.Eq(0).Next() | ||
spanElem.Find("ul").Each(func(index int, ulElems *goquery.Selection) { | ||
ulElems.Find("li").Each(func(index int, liElems *goquery.Selection) { | ||
liElems.Find("p").Each(func(index int, pElems *goquery.Selection) { | ||
if strings.HasPrefix(pElems.Text(), "FHIR ") { | ||
aElems := pElems.Find("a") | ||
if aElems.Length() > 0 { | ||
hrefText, exists := aElems.Eq(0).Attr("href") | ||
if exists { | ||
var entry LanternEntry | ||
|
||
fhirURL := strings.TrimSpace(hrefText) | ||
entry.URL = fhirURL | ||
lanternEntryList = append(lanternEntryList, entry) | ||
} | ||
} | ||
} | ||
}) | ||
}) | ||
}) | ||
} | ||
|
||
endpointEntryList.Endpoints = lanternEntryList | ||
|
||
err = WriteCHPLFile(endpointEntryList, fileToWriteTo) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
} |
Oops, something went wrong.