Skip to content

Commit

Permalink
Merge pull request #440 from onc-healthit/LANTERN-788-Add-json-parser…
Browse files Browse the repository at this point in the history
…-emds

LLANTERN-788: Add-json-parser-emds
  • Loading branch information
vishnu-mettles authored Nov 20, 2024
2 parents 08c14c3 + ffdbce2 commit 9a34eb4
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ var pointclickURL = "https://fhir.pointclickcare.com/"
var nextgenPracticeURL = "https://www.nextgen.com/api/practice-search"
var aspmdURL = "https://fhirapi.asp.md:3030/aspmd/fhirserver/fhir_aspmd.asp"
var axeiumURL = "https://apifhir.axeium.net:8443/reference-server/"
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"

Expand Down Expand Up @@ -566,6 +567,8 @@ func QueryCHPLEndpointList(chplURL string, fileToWriteTo string) {
EzemrxWebscraper(chplURL, fileToWriteTo)
} else if contains(bundleQuerierArray, chplURL) {
BundleQuerierParser(chplURL, fileToWriteTo)
} else if URLsEqual(emdscloudURL, chplURL) {
EmdsCloudWebscraper(emdscloudURL, fileToWriteTo)
} else if URLsEqual(chplURL, betaAfoundriaURL) {
BetaAfoundriaWebScraper(chplURL, fileToWriteTo)
} else if URLsEqual(chplURL, ontadaURL) {
Expand Down
56 changes: 56 additions & 0 deletions endpointmanager/pkg/chplendpointquerier/emdscloudwebscraper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package chplendpointquerier

import (
"encoding/json"
"io"
"net/http"

log "github.com/sirupsen/logrus"
)

func EmdsCloudWebscraper(CHPLURL string, fileToWriteTo string) {
var entry LanternEntry
var lanternEntryList []LanternEntry
var endpointEntryList EndpointList

client := &http.Client{}
req, err := http.NewRequest("GET", CHPLURL, nil)
if err != nil {
log.Fatalf("Error creating HTTP request: %v", err)
return
}

req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36")

res, err := client.Do(req)
if err != nil {
log.Fatalf("Error making HTTP request: %v", err)
return
}
defer res.Body.Close()

body, err := io.ReadAll(res.Body)
if err != nil {
log.Fatalf("Error reading response body: %v", err)
return
}

var resources []map[string]interface{}
if err := json.Unmarshal(body, &resources); err != nil {
log.Fatalf("Error parsing JSON: %v", err)
return
}

for _, resource := range resources {
if url, ok := resource["ResourceUrl"].(string); ok {
entry.URL = url
lanternEntryList = append(lanternEntryList, entry)
}
}
endpointEntryList.Endpoints = lanternEntryList

err = WriteCHPLFile(endpointEntryList, fileToWriteTo)
if err != nil {
log.Fatalf("Error writing to file: %v", err)
}
}

0 comments on commit 9a34eb4

Please sign in to comment.