Skip to content

Commit

Permalink
Adding endpoints and parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
svginc committed Jan 26, 2024
1 parent 1712803 commit 6cf30cb
Show file tree
Hide file tree
Showing 28 changed files with 81,738 additions and 78,186 deletions.
5 changes: 3 additions & 2 deletions capabilityreceiver/pkg/capabilityhandler/supportedProfiles.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package capabilityhandler

import (
"fmt"
"github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/endpointmanager"
"github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/helpers"
)
Expand Down Expand Up @@ -75,7 +76,7 @@ func getCapabilityStatementProfiles(capInt map[string]interface{}, supportedProf
supportedProfileArr, ok := resourceInt["supportedProfile"].([]interface{})
if !ok {
// Handle the case where "supportedProfile" is not a []interface{}
//fmt.Println("Error: 'supportedProfile' is not a []interface{}")
fmt.Println("Error: 'supportedProfile' is not a []interface{}")
// Add appropriate error handling or return from the function
}

Expand All @@ -89,7 +90,7 @@ func getCapabilityStatementProfiles(capInt map[string]interface{}, supportedProf
supportedProfiles = append(supportedProfiles, profileInfo)
} else {
// Handle the case where profileEntry is not a string
//fmt.Println("Error: 'supportedProfile' entry is not a string")
fmt.Println("Error: 'supportedProfile' entry is not a string")
// Add appropriate error handling or return from the function
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package chplendpointquerier

import (
"strings"

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

func AllegianceMDWebscraper(chplURL string, fileToWriteTo string) {
Expand All @@ -18,7 +17,6 @@ func AllegianceMDWebscraper(chplURL string, fileToWriteTo string) {
if err != nil {
log.Fatal(err)
}

doc.Each(func(index int, pElem *goquery.Selection) {
aElem := pElem.Find("a").First()
hrefText, exists := aElem.Attr("href")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package chplendpointquerier

import (
"strings"

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

func BridgePatientPortalWebscraper(chplURL string, fileToWriteTo string) {
Expand All @@ -17,7 +17,7 @@ func BridgePatientPortalWebscraper(chplURL string, fileToWriteTo string) {
if err != nil {
log.Fatal(err)
}

fmt.Println(doc.Html())
fhirEndpointsHeaderElem := doc.Find("#introduction/fhir-bridge-patient-portal/fhir-endpoints")
if fhirEndpointsHeaderElem.Length() > 0 {
spanElem := fhirEndpointsHeaderElem.Eq(0).Next()
Expand Down
44 changes: 44 additions & 0 deletions endpointmanager/pkg/chplendpointquerier/broadstreetwebscraper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package chplendpointquerier

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

func BroadStreetURLWebscraper(CHPLURL string, fileToWriteTo string) {

var lanternEntryList []LanternEntry
var endpointEntryList EndpointList

doc, err := helpers.ChromedpQueryEndpointList(CHPLURL, "article")
if err != nil {
log.Fatal(err)
}
doc.Find("article").Each(func(index int, articleElems *goquery.Selection) {
articleElems.Find("table").Each(func(index int, tableElems *goquery.Selection) {
tableElems.Find("tbody").Each(func(index int, bodyElems *goquery.Selection) {
bodyElems.Find("tr").Each(func(index int, trElems *goquery.Selection) {
tdEntry := trElems.Find("td").First()
if strings.Contains(tdEntry.Text(), "FHIR Production") {
tdEntryNext := trElems.Find("td").Next()
if tdEntryNext.Length() > 0 {
var entry LanternEntry
entry.URL = strings.TrimSpace(tdEntryNext.Text())
lanternEntryList = append(lanternEntryList, entry)
}
}
})
})
})
})

endpointEntryList.Endpoints = lanternEntryList

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

}
19 changes: 14 additions & 5 deletions endpointmanager/pkg/chplendpointquerier/chplendpointquerier.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,13 @@ var varianmedicalURL = "https://variandev.dynamicfhir.com/"
var caretrackerURL = "https://hag-fhir.amazingcharts.com/ac/endpoints"
var zhhealthcareURL = "https://blueehr.com/fhir-urls/"
var emedpracticeURL = "https://emedpractice.com/Fhir/FhirHelpDocument.html"
var modernizingmedicineURL = "https://mm-fhir-endpoint-display.qa.fhir.ema-api.com/"
var doc_torURL = "https://hag-fhir.amazingcharts.com/pc/endpoints"
var azaleahealthURL = "https://api.azaleahealth.com/fhir/R4/Endpoint"
var cloudcraftURL = "https://fhirapitest.naiacorp.net/fhir/r4/endpoints/"
var darenasolutionsURL = "https://api.meldrx.com/Directories/fhir/endpoints"
var glenwoodsystemsURL = "https://static.glaceemr.com/endpoints/urls.json"
var practicefusionURL = "https://www.practicefusion.com/assets/static_files/ServiceBaseURLs.json"
var universalEHRURL = "https://appstudio.interopengine.com/partner/fhirR4endpoints-universalehr.json"
var welligentURL = "https://mu3test.welligent.com/fhir/r4/endpoints/"
var astronautURL = "https://astronautehr.com/index.php/fhir-base-urls/"
var bestpracticesacademyURL = "https://ipatientcare.com/onc-acb-certified-2015-edition"
var californiamedicalsystemsURL = "https://cal-med.com/fhir/Fhir-base-urls.csv"
Expand Down Expand Up @@ -137,6 +135,11 @@ var CarepathsURL = "https://carepaths.com/uploads/org_endpoint_bundle.json"
var athenaClinicalsURL = "https://docs.athenahealth.com/api/guides/base-fhir-urls"
var canvasMedicalURL = "https://docs.canvasmedical.com/api/service-base-urls/"
var veradigmURL = "https://open.platform.veradigm.com/fhirendpoints"
var broadStreetURL = "https://broadstreetcare.com/docs"
var officePracticumURL = "https://fhir-documentation.patientmedrecords.com/endpoints"
var modernizingMedicineURL = "https://mm-fhir-endpoint-display.prod.fhir.ema-api.com/"
var welligentURL = "https://fhir.qa.welligent.com/"
var willowURL = "https://www.willowgladetechnologies.com/requirements"

func QueryCHPLEndpointList(chplURL string, fileToWriteTo string) {

Expand All @@ -148,6 +151,8 @@ func QueryCHPLEndpointList(chplURL string, fileToWriteTo string) {
Canvaswebscraper(chplURL, fileToWriteTo)
} else if URLsEqual(chplURL, AlteraURL) {
AlteraQuerier(chplURL, fileToWriteTo)
} else if URLsEqual(chplURL, modernizingMedicineURL) {
ModernizingMedicineQuerier(chplURL, fileToWriteTo)
} else if URLsEqual(chplURL, EpicURL) {
EpicQuerier(chplURL, fileToWriteTo)
} else if URLsEqual(chplURL, MeditechURL) {
Expand Down Expand Up @@ -236,8 +241,6 @@ func QueryCHPLEndpointList(chplURL string, fileToWriteTo string) {
MedicalInformaticsEngineeringWebscraper(chplURL, fileToWriteTo)
} else if chplURL == emedpracticeURL {
eMedPracticeWebscraper("https://servicebackup.emedpractice.com:8443/helpdoc/fhir_helpdoc.html", fileToWriteTo)
} else if chplURL == modernizingmedicineURL {
ModernizingMedicineQuerier("qa.fhir.ema-api.com/fhir/r4/Endpoint?connection-type=hl7-fhir-rest", fileToWriteTo)
} else if chplURL == doc_torURL {
BundleQuerierParser(chplURL+"/r4", fileToWriteTo)
} else if URLsEqual(chplURL, azaleahealthURL) {
Expand All @@ -253,7 +256,7 @@ func QueryCHPLEndpointList(chplURL string, fileToWriteTo string) {
} else if URLsEqual(chplURL, universalEHRURL) {
BundleQuerierParser(chplURL, fileToWriteTo)
} else if URLsEqual(chplURL, welligentURL) {
BundleQuerierParser(chplURL, fileToWriteTo)
BundleQuerierParser("https://fhir.qa.welligent.com/fhir/r4/endpoints", fileToWriteTo)
} else if URLsEqual(chplURL, astronautURL) {
CSVParser("https://astronautehr.com/wp-content/uploads/2022/12/Astronaut-fhir-base-urls.csv", fileToWriteTo, "./astronaut_fhir_base_urls.csv", 1, 2, true, 1, -1)
} else if URLsEqual(chplURL, bestpracticesacademyURL) {
Expand Down Expand Up @@ -382,6 +385,12 @@ func QueryCHPLEndpointList(chplURL string, fileToWriteTo string) {
CSVParser(MEDENTURL, fileToWriteTo, "./ServiceBaseURL.csv", 1, 0, true, 1, 0)
} else if URLsEqual(chplURL, canvasMedicalURL) {
CanvasMedicalURLWebscraper(chplURL, fileToWriteTo)
} else if URLsEqual(chplURL, broadStreetURL) {
BroadStreetURLWebscraper(chplURL, fileToWriteTo)
} else if URLsEqual(chplURL, officePracticumURL) {
OfficePracticumURLWebscraper(chplURL, fileToWriteTo)
} else if URLsEqual(chplURL, willowURL) {
WillowQuerierParser("https://ccdoc.phn.care/service-base-urls", fileToWriteTo)
} else if URLsEqual(chplURL, veradigmURL) {
BundleQuerierParser("https://open.platform.veradigm.com/fhirendpoints/download/R4", fileToWriteTo)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,46 @@ import (
)

func ModernizingMedicineQuerier(chplURL string, fileToWriteTo string) {

emaURL := "https://fhir.m2qa." + chplURL
gastroURL := "https://fhir.gastro." + chplURL
emaURL := "https://fhir.mmi.prod.fhir.ema-api.com/fhir/r4/Endpoint?connection-type=hl7-fhir-rest"
gastroURL := "https://fhir.gastro.prod.fhir.ema-api.com/fhir/r4/Endpoint?connection-type=hl7-fhir-rest"
exscribeURL := "https://ehrapi-exscribe-prod-fhir.ema-api.com/api/Endpoint"
//traknetURL := "https://ehrapi-traknet-prod-fhir.ema-api.com/api/Endpoint"
//sammyURL := "https://ehrapi-sammyehr-prod-fhir.ema-api.com/api/Endpoint"

var endpointEntryList EndpointList

respBody, err := helpers.QueryEndpointList(emaURL)
if err != nil {
log.Fatal(err)
}

endpointEntryList.Endpoints = BundleToLanternFormat(respBody)

respBody, err = helpers.QueryEndpointList(gastroURL)
if err != nil {
log.Fatal(err)
}
endpointEntryList.Endpoints = append(endpointEntryList.Endpoints, BundleToLanternFormat(respBody)...)

respBody, err = helpers.QueryEndpointList(exscribeURL)
if err != nil {
log.Fatal(err)
}
endpointEntryList.Endpoints = append(endpointEntryList.Endpoints, BundleToLanternFormat(respBody)...)

//respBody, err = helpers.QueryEndpointList(traknetURL)
//if err != nil {
// log.Fatal(err)
//}
//endpointEntryList.Endpoints = append(endpointEntryList.Endpoints, BundleToLanternFormat(respBody)...)

// respBody, err = helpers.QueryEndpointList(sammyURL)
// if err != nil {
// log.Fatal(err)
// }

// endpointEntryList.Endpoints = append(endpointEntryList.Endpoints, BundleToLanternFormat(respBody)...)

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

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package chplendpointquerier

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

func OfficePracticumURLWebscraper(CHPLURL string, fileToWriteTo string) {

var lanternEntryList []LanternEntry
var endpointEntryList EndpointList

doc, err := helpers.ChromedpQueryEndpointList(CHPLURL, ".MuiTableCell-root.MuiTableCell-body.MuiTableCell-sizeMedium.css-q34dxg")
if err != nil {
log.Fatal(err)
}

doc.Find("tbody.MuiTableBody-root.css-1xnox0e").Each(func(i int, bodyEle *goquery.Selection) {
bodyEle.Find("tr").Each(func(index int, trEle *goquery.Selection) {
organizationName := trEle.Find("td").First().Text()
URL := trEle.Find("td").Next().Text()
var entry LanternEntry
entry.OrganizationName = strings.TrimSpace(organizationName)
entry.URL = strings.TrimSpace(URL)
lanternEntryList = append(lanternEntryList, entry)
})
})

endpointEntryList.Endpoints = lanternEntryList

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

}
54 changes: 54 additions & 0 deletions endpointmanager/pkg/chplendpointquerier/willowquerierparser.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package chplendpointquerier

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

type Entry struct {
ID string `json:"id"`
Name string `json:"name"`
LogoURL string `json:"logoUrl,omitempty"`
URL string `json:"url"`
}

type Bundle struct {
ResourceType string `json:"resourceType"`
Type string `json:"type"`
Total int `json:"total"`
Entry []Entry `json:"entry"`
ID string `json:"id"`
}

func WillowQuerierParser(willowURL string, fileToWriteTo string) {

var lanternEntryList []LanternEntry
var endpointEntryList EndpointList

respBody, err := helpers.QueryEndpointList(willowURL)
if err != nil {
log.Fatal(err)
}
var willowArr Bundle
err = json.Unmarshal(respBody, &willowArr)
if err != nil {
log.Fatal(err)
}

for _, willowEntry := range willowArr.Entry {
var entry LanternEntry

entry.URL = willowEntry.URL
entry.OrganizationName = willowEntry.Name

lanternEntryList = append(lanternEntryList, entry)
}

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

}
2 changes: 2 additions & 0 deletions endpointmanager/pkg/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ func ChromedpQueryEndpointList(endpointListURL string, waitVisibleElement string
func QueryEndpointList(endpointListURL string) ([]byte, error) {
client := &http.Client{}
req, err := http.NewRequest("GET", endpointListURL, nil)
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36")

if err != nil {
return nil, err
}
Expand Down
9 changes: 1 addition & 8 deletions resources/dev_resources/AdvancedMD_EndpointSources.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
{
"Endpoints": [
{
"URL": "https://providerapi.advancedmd.com/v1/r4",
"OrganizationName": "",
"NPIID": "",
"OrganizationZipCode": ""
}
]
"Endpoints": null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"Endpoints": [
{
"URL": "https://broadstreet.arsanahealth.com/api/fhir/",
"OrganizationName": "",
"NPIID": "",
"OrganizationZipCode": ""
}
]
}
Loading

0 comments on commit 6cf30cb

Please sign in to comment.