Skip to content

Commit

Permalink
LLANTERN-788: Add-json-parser-emds
Browse files Browse the repository at this point in the history
  • Loading branch information
archita-ekkirala committed Nov 13, 2024
1 parent 52471df commit 33a55c4
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,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 bundleQuerierArray = [30]string{"https://ac-fhir.harrisambulatory.com/endpoints/r4", "https://dynamicfhirpresentation.dynamicfhirsandbox.com/fhir/r4/endpoints",
"https://ct-fhir.harrisambulatory.com/Endpoints/R4", "https://kantime.com/wp-content/uploads/2024/03/fhir-base-urls.json",
Expand Down Expand Up @@ -552,6 +553,8 @@ func QueryCHPLEndpointList(chplURL string, fileToWriteTo string) {
AxeiumeWebscraper(axeiumURL, fileToWriteTo)
} else if contains(bundleQuerierArray, chplURL) {
BundleQuerierParser(chplURL, fileToWriteTo)
} else if URLsEqual(emdscloudURL, chplURL) {
EmdsCloudWebscraper(emdscloudURL, fileToWriteTo)
} else {
log.Warnf("Handler is required for url %s", chplURL)
}
Expand Down
48 changes: 48 additions & 0 deletions endpointmanager/pkg/chplendpointquerier/emdscloudwebscraper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package chplendpointquerier

import (
"io/ioutil"
"net/http"

"encoding/json"

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)
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)

defer res.Body.Close()

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

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

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.Fatal(err)
}
}

0 comments on commit 33a55c4

Please sign in to comment.