diff --git a/capabilityquerier/cmd/main.go b/capabilityquerier/cmd/main.go index f33a66b23..dfeee3e86 100644 --- a/capabilityquerier/cmd/main.go +++ b/capabilityquerier/cmd/main.go @@ -4,8 +4,8 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "net/http" + "os" "strings" "time" @@ -187,7 +187,7 @@ func main() { log.Info("Successfully connected to DB!") // Read version file that is mounted - version, err := ioutil.ReadFile("/etc/lantern/VERSION") + version, err := os.ReadFile("/etc/lantern/VERSION") helpers.FailOnError("", err) versionString := string(version) versionNum := strings.Split(versionString, "=") diff --git a/capabilityquerier/pkg/capabilityquerier/capabilityquerier.go b/capabilityquerier/pkg/capabilityquerier/capabilityquerier.go index cbf1174c8..6a31f3e3b 100644 --- a/capabilityquerier/pkg/capabilityquerier/capabilityquerier.go +++ b/capabilityquerier/pkg/capabilityquerier/capabilityquerier.go @@ -6,7 +6,7 @@ import ( "database/sql" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptrace" "net/url" @@ -422,7 +422,7 @@ func requestWithMimeType(req *http.Request, mimeType string, client *http.Client defer resp.Body.Close() mimeMatches = true - capStat, err = ioutil.ReadAll(resp.Body) + capStat, err = io.ReadAll(resp.Body) if err != nil { return -1, "", false, nil, -1, errors.Wrapf(err, "reading the response from %s failed", req.URL.String()) } diff --git a/capabilityquerier/pkg/capabilityquerier/capabilityquerier_integration_test.go b/capabilityquerier/pkg/capabilityquerier/capabilityquerier_integration_test.go index 4899fafe0..1292c4e87 100644 --- a/capabilityquerier/pkg/capabilityquerier/capabilityquerier_integration_test.go +++ b/capabilityquerier/pkg/capabilityquerier/capabilityquerier_integration_test.go @@ -8,7 +8,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "net/http" "net/url" "os" @@ -290,7 +289,7 @@ func setup() error { func capabilityStatementOriginalBytes() ([]byte, error) { path := filepath.Join("testdata", "metadata.json") - expectedCapStat, err := ioutil.ReadFile(path) + expectedCapStat, err := os.ReadFile(path) if err != nil { return nil, err } diff --git a/capabilityquerier/pkg/capabilityquerier/capabilityquerier_test.go b/capabilityquerier/pkg/capabilityquerier/capabilityquerier_test.go index f5ac6b478..67776463c 100644 --- a/capabilityquerier/pkg/capabilityquerier/capabilityquerier_test.go +++ b/capabilityquerier/pkg/capabilityquerier/capabilityquerier_test.go @@ -6,7 +6,7 @@ import ( "crypto/tls" "encoding/json" "fmt" - "io/ioutil" + "os" "path/filepath" "testing" "time" @@ -356,7 +356,7 @@ func basicTestClient() (*th.TestClient, error) { func testClientWithContentType(contentType string) (*th.TestClient, error) { path := filepath.Join("testdata", "metadata.json") - okResponse, err := ioutil.ReadFile(path) + okResponse, err := os.ReadFile(path) if err != nil { return nil, err } @@ -378,7 +378,7 @@ func testClientWithContentType(contentType string) (*th.TestClient, error) { func testClientOnlyAcceptGivenType(contentType string) (*th.TestClient, error) { path := filepath.Join("testdata", "metadata.json") - okResponse, err := ioutil.ReadFile(path) + okResponse, err := os.ReadFile(path) if err != nil { return nil, err } @@ -414,7 +414,7 @@ func testClientWithTLSVersion(tlsVersion uint16) (*th.TestClient, error) { func testClientWithNoTLS() (*th.TestClient, error) { path := filepath.Join("testdata", "metadata.json") - okResponse, err := ioutil.ReadFile(path) + okResponse, err := os.ReadFile(path) if err != nil { return nil, err } @@ -430,7 +430,7 @@ func testClientWithNoTLS() (*th.TestClient, error) { func capabilityStatement() ([]byte, error) { path := filepath.Join("testdata", "metadata.json") - expectedCapStat, err := ioutil.ReadFile(path) + expectedCapStat, err := os.ReadFile(path) if err != nil { return nil, err } diff --git a/capabilityreceiver/cmd/migrateresources/main_integration_test.go b/capabilityreceiver/cmd/migrateresources/main_integration_test.go index d39a7669a..0b62b9663 100644 --- a/capabilityreceiver/cmd/migrateresources/main_integration_test.go +++ b/capabilityreceiver/cmd/migrateresources/main_integration_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package main @@ -6,7 +7,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" "testing" @@ -170,14 +170,14 @@ func Test_updateOperationResource(t *testing.T) { func setupCapabilityStatements(t *testing.T, path1 string, path2 string) { // capability statement - csJSON, err := ioutil.ReadFile(path1) + csJSON, err := os.ReadFile(path1) th.Assert(t, err == nil, err) cs, err := capabilityparser.NewCapabilityStatement(csJSON) th.Assert(t, err == nil, err) capStat1, err = cs.GetJSON() th.Assert(t, err == nil, err) - csJSON2, err := ioutil.ReadFile(path2) + csJSON2, err := os.ReadFile(path2) th.Assert(t, err == nil, err) cs2, err := capabilityparser.NewCapabilityStatement(csJSON2) th.Assert(t, err == nil, err) diff --git a/capabilityreceiver/cmd/migratevalidations/main_integration_test.go b/capabilityreceiver/cmd/migratevalidations/main_integration_test.go index ca4f7db3a..0939661e6 100644 --- a/capabilityreceiver/cmd/migratevalidations/main_integration_test.go +++ b/capabilityreceiver/cmd/migratevalidations/main_integration_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package main @@ -5,7 +6,6 @@ package main import ( "context" "fmt" - "io/ioutil" "os" "path/filepath" "testing" @@ -338,14 +338,14 @@ func Test_addToValidationTableInfo(t *testing.T) { func setupCapabilityStatements(t *testing.T, path1 string, path2 string) { // capability statement - csJSON, err := ioutil.ReadFile(path1) + csJSON, err := os.ReadFile(path1) th.Assert(t, err == nil, err) cs, err := capabilityparser.NewCapabilityStatement(csJSON) th.Assert(t, err == nil, err) capStat1, err = cs.GetJSON() th.Assert(t, err == nil, err) - csJSON2, err := ioutil.ReadFile(path2) + csJSON2, err := os.ReadFile(path2) th.Assert(t, err == nil, err) cs2, err := capabilityparser.NewCapabilityStatement(csJSON2) th.Assert(t, err == nil, err) diff --git a/capabilityreceiver/pkg/capabilityhandler/capabilityreceiver_integration_test.go b/capabilityreceiver/pkg/capabilityhandler/capabilityreceiver_integration_test.go index e1e7c4373..b519610f8 100644 --- a/capabilityreceiver/pkg/capabilityhandler/capabilityreceiver_integration_test.go +++ b/capabilityreceiver/pkg/capabilityhandler/capabilityreceiver_integration_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package capabilityhandler diff --git a/capabilityreceiver/pkg/capabilityhandler/capabilityreceiver_test.go b/capabilityreceiver/pkg/capabilityhandler/capabilityreceiver_test.go index e9bfada4f..6bbb5aab1 100644 --- a/capabilityreceiver/pkg/capabilityhandler/capabilityreceiver_test.go +++ b/capabilityreceiver/pkg/capabilityhandler/capabilityreceiver_test.go @@ -3,7 +3,7 @@ package capabilityhandler import ( "encoding/json" "fmt" - "io/ioutil" + "os" "path/filepath" "testing" @@ -256,7 +256,7 @@ func convertInterfaceToBytes(message map[string]interface{}) ([]byte, error) { func setupCapabilityStatement(t *testing.T, path string) { // capability statement - csJSON, err := ioutil.ReadFile(path) + csJSON, err := os.ReadFile(path) th.Assert(t, err == nil, err) cs, err := capabilityparser.NewCapabilityStatement(csJSON) th.Assert(t, err == nil, err) diff --git a/capabilityreceiver/pkg/capabilityhandler/validation/validation_test.go b/capabilityreceiver/pkg/capabilityhandler/validation/validation_test.go index c54ce3e82..cfa78de0a 100644 --- a/capabilityreceiver/pkg/capabilityhandler/validation/validation_test.go +++ b/capabilityreceiver/pkg/capabilityhandler/validation/validation_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "os" "path/filepath" "reflect" "testing" @@ -940,7 +940,7 @@ func Test_VersionResponseValid(t *testing.T) { // getDSTU2CapStat gets a DSTU2 Capability Statement func getDSTU2CapStat() (capabilityparser.CapabilityStatement, error) { path := filepath.Join("../../../testdata", "test_dstu2_capability_statement.json") - csJSON, err := ioutil.ReadFile(path) + csJSON, err := os.ReadFile(path) if err != nil { return nil, err } @@ -954,7 +954,7 @@ func getDSTU2CapStat() (capabilityparser.CapabilityStatement, error) { // getDSTU2CapStat gets a R4 Capability Statement func getR4CapStat() (capabilityparser.CapabilityStatement, error) { path := filepath.Join("../../../testdata", "test_r4_capability_statement.json") - csJSON, err := ioutil.ReadFile(path) + csJSON, err := os.ReadFile(path) if err != nil { return nil, err } @@ -967,7 +967,7 @@ func getR4CapStat() (capabilityparser.CapabilityStatement, error) { func getSmartResponse() (smartparser.SMARTResponse, error) { path := filepath.Join("../../../testdata", "authorization_cerner_smart_response.json") - srJSON, err := ioutil.ReadFile(path) + srJSON, err := os.ReadFile(path) if err != nil { return nil, err } diff --git a/capabilityreceiver/pkg/chplmapper/capabilityinfo.go b/capabilityreceiver/pkg/chplmapper/capabilityinfo.go index a41f5d09c..a20045dd8 100644 --- a/capabilityreceiver/pkg/chplmapper/capabilityinfo.go +++ b/capabilityreceiver/pkg/chplmapper/capabilityinfo.go @@ -4,7 +4,7 @@ import ( "context" "database/sql" "encoding/json" - "io/ioutil" + "io" "os" "strings" @@ -211,7 +211,7 @@ func openProductLinksFile(filepath string) (map[string]map[string]string, error) defer jsonFile.Close() var softwareNameVersion []map[string]string - byteValueFile, err := ioutil.ReadAll(jsonFile) + byteValueFile, err := io.ReadAll(jsonFile) if err != nil { return nil, err } @@ -322,7 +322,7 @@ func OpenCHPLEndpointListInfoFile(filepath string) (map[string]ChplMapResults, e var softwareListMap = make(map[string]ChplMapResults) - byteValueFile, err := ioutil.ReadAll(jsonFile) + byteValueFile, err := io.ReadAll(jsonFile) if err != nil { return nil, err } diff --git a/capabilityreceiver/pkg/chplmapper/capabilityinfo_integration_test.go b/capabilityreceiver/pkg/chplmapper/capabilityinfo_integration_test.go index c371f386c..d4134dd7a 100644 --- a/capabilityreceiver/pkg/chplmapper/capabilityinfo_integration_test.go +++ b/capabilityreceiver/pkg/chplmapper/capabilityinfo_integration_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package chplmapper @@ -6,7 +7,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" "testing" @@ -200,14 +200,14 @@ func Test_MatchEndpointToProduct(t *testing.T) { // populate fhir endpoint ep := &endpointmanager.FHIREndpoint{ - URL: "example.com/FHIR/DSTU2", + URL: "example.com/FHIR/DSTU2", OrganizationList: []*endpointmanager.FHIREndpointOrganization{epOrg}} - + store.AddFHIREndpoint(ctx, ep) // capability statement path := filepath.Join("../../testdata", "cerner_capability_dstu2.json") - csJSON, err := ioutil.ReadFile(path) + csJSON, err := os.ReadFile(path) th.Assert(t, err == nil, err) cs, err := capabilityparser.NewCapabilityStatement(csJSON) th.Assert(t, err == nil, err) @@ -230,7 +230,7 @@ func Test_MatchEndpointToProduct(t *testing.T) { // capability statement path = filepath.Join("../../testdata", "allscripts_capability_dstu2.json") - csJSON, err = ioutil.ReadFile(path) + csJSON, err = os.ReadFile(path) th.Assert(t, err == nil, err) cs, err = capabilityparser.NewCapabilityStatement(csJSON) th.Assert(t, err == nil, err) @@ -240,9 +240,9 @@ func Test_MatchEndpointToProduct(t *testing.T) { // populate fhir endpoint ep = &endpointmanager.FHIREndpoint{ - URL: "example2.com/FHIR/DSTU2", + URL: "example2.com/FHIR/DSTU2", OrganizationList: []*endpointmanager.FHIREndpointOrganization{epOrg2}} - + store.AddFHIREndpoint(ctx, ep) var epOrg3 = &endpointmanager.FHIREndpointOrganization{ @@ -250,20 +250,20 @@ func Test_MatchEndpointToProduct(t *testing.T) { // populate fhir endpoint with list source found in CHPL products info file ep2 := &endpointmanager.FHIREndpoint{ - URL: "example3.com/FHIR/DSTU2", + URL: "example3.com/FHIR/DSTU2", OrganizationList: []*endpointmanager.FHIREndpointOrganization{epOrg3}, - ListSource: "https://api.bluebuttonpro.com/swagger/index.html"} - + ListSource: "https://api.bluebuttonpro.com/swagger/index.html"} + store.AddFHIREndpoint(ctx, ep2) var epOrg4 = &endpointmanager.FHIREndpointOrganization{ OrganizationName: "Example2 Inc."} ep3 := &endpointmanager.FHIREndpoint{ - URL: "example4.com/FHIR/DSTU2", + URL: "example4.com/FHIR/DSTU2", OrganizationList: []*endpointmanager.FHIREndpointOrganization{epOrg4}, - ListSource: "https://nextgen.com/api/practice-search"} - + ListSource: "https://nextgen.com/api/practice-search"} + store.AddFHIREndpoint(ctx, ep3) // endpoint info @@ -296,7 +296,7 @@ func Test_MatchEndpointToProduct(t *testing.T) { // capability statement path = filepath.Join("../../testdata", "advantagecare_physicians_stu3.json") - csJSON, err = ioutil.ReadFile(path) + csJSON, err = os.ReadFile(path) th.Assert(t, err == nil, err) cs, err = capabilityparser.NewCapabilityStatement(csJSON) th.Assert(t, err == nil, err) @@ -363,14 +363,14 @@ func Test_MatchEndpointToProduct(t *testing.T) { // populate fhir endpoint ep = &endpointmanager.FHIREndpoint{ - URL: "example5.com/FHIR/DSTU2", + URL: "example5.com/FHIR/DSTU2", OrganizationList: []*endpointmanager.FHIREndpointOrganization{epOrg5}} - + store.AddFHIREndpoint(ctx, ep) // capability statement with product HIEBus path = filepath.Join("../../testdata", "careevolution_dstu2.json") - csJSON, err = ioutil.ReadFile(path) + csJSON, err = os.ReadFile(path) th.Assert(t, err == nil, err) cs, err = capabilityparser.NewCapabilityStatement(csJSON) th.Assert(t, err == nil, err) @@ -396,7 +396,7 @@ func Test_MatchEndpointToProduct(t *testing.T) { OrganizationName: "Example Inc."} ep = &endpointmanager.FHIREndpoint{ - URL: "example6.com/FHIR/DSTU2", + URL: "example6.com/FHIR/DSTU2", OrganizationList: []*endpointmanager.FHIREndpointOrganization{epOrg6}} store.AddFHIREndpoint(ctx, ep) @@ -452,7 +452,7 @@ func Test_MatchEndpointToVendor(t *testing.T) { OrganizationName: "Example Inc."} ep := &endpointmanager.FHIREndpoint{ - URL: "example.com/FHIR/DSTU2", + URL: "example.com/FHIR/DSTU2", OrganizationList: []*endpointmanager.FHIREndpointOrganization{epOrg7}} store.AddFHIREndpoint(ctx, ep) @@ -460,7 +460,7 @@ func Test_MatchEndpointToVendor(t *testing.T) { // capability statement path := filepath.Join("../../testdata", "cerner_capability_dstu2.json") - csJSON, err := ioutil.ReadFile(path) + csJSON, err := os.ReadFile(path) th.Assert(t, err == nil, err) cs, err := capabilityparser.NewCapabilityStatement(csJSON) th.Assert(t, err == nil, err) @@ -483,7 +483,7 @@ func Test_MatchEndpointToVendor(t *testing.T) { // capability statement path = filepath.Join("../../testdata", "novendor_capability_dstu2.json") - csJSON, err = ioutil.ReadFile(path) + csJSON, err = os.ReadFile(path) th.Assert(t, err == nil, err) cs, err = capabilityparser.NewCapabilityStatement(csJSON) th.Assert(t, err == nil, err) @@ -536,9 +536,9 @@ func Test_MatchEndpointToVendor(t *testing.T) { OrganizationName: "Example Inc."} ep2 := &endpointmanager.FHIREndpoint{ - URL: "example2.com/FHIR/DSTU2", + URL: "example2.com/FHIR/DSTU2", OrganizationList: []*endpointmanager.FHIREndpointOrganization{epOrg8}, - ListSource: "https://nextgen.com/api/practice-search"} + ListSource: "https://nextgen.com/api/practice-search"} store.AddFHIREndpoint(ctx, ep2) // endpoint info @@ -576,7 +576,7 @@ func Test_getVendorMatch(t *testing.T) { expected = vendors[1].ID // "Cerner Corporation" path = filepath.Join("../../testdata", "cerner_capability_dstu2.json") - dstu2JSON, err = ioutil.ReadFile(path) + dstu2JSON, err = os.ReadFile(path) th.Assert(t, err == nil, err) dstu2, err = capabilityparser.NewCapabilityStatement(dstu2JSON) @@ -590,7 +590,7 @@ func Test_getVendorMatch(t *testing.T) { expected = vendors[0].ID // "Epic Systems Corporation" // this uses the "hackMatch" capability path = filepath.Join("../../testdata", "epic_capability_dstu2.json") - dstu2JSON, err = ioutil.ReadFile(path) + dstu2JSON, err = os.ReadFile(path) th.Assert(t, err == nil, err) dstu2, err = capabilityparser.NewCapabilityStatement(dstu2JSON) @@ -618,7 +618,7 @@ func Test_getVendorMatch(t *testing.T) { expected = vendors[5].ID // "Allscripts" path = filepath.Join("../../testdata", "allscripts_capability_dstu2.json") - dstu2JSON, err = ioutil.ReadFile(path) + dstu2JSON, err = os.ReadFile(path) th.Assert(t, err == nil, err) dstu2, err = capabilityparser.NewCapabilityStatement(dstu2JSON) @@ -632,7 +632,7 @@ func Test_getVendorMatch(t *testing.T) { expected = vendors[4].ID // "Medical Information Technology, Inc. (MEDITECH)" path = filepath.Join("../../testdata", "meditech_capability_dstu2.json") - dstu2JSON, err = ioutil.ReadFile(path) + dstu2JSON, err = os.ReadFile(path) th.Assert(t, err == nil, err) dstu2, err = capabilityparser.NewCapabilityStatement(dstu2JSON) @@ -689,7 +689,7 @@ func Test_publisherMatch(t *testing.T) { expected = "Cerner Corporation" path = filepath.Join("../../testdata", "cerner_capability_dstu2.json") - dstu2JSON, err = ioutil.ReadFile(path) + dstu2JSON, err = os.ReadFile(path) th.Assert(t, err == nil, err) dstu2, err = capabilityparser.NewCapabilityStatement(dstu2JSON) @@ -703,7 +703,7 @@ func Test_publisherMatch(t *testing.T) { expected = "" // the capability statement is missing the publisher path = filepath.Join("../../testdata", "epic_capability_dstu2.json") - dstu2JSON, err = ioutil.ReadFile(path) + dstu2JSON, err = os.ReadFile(path) th.Assert(t, err == nil, err) dstu2, err = capabilityparser.NewCapabilityStatement(dstu2JSON) @@ -717,7 +717,7 @@ func Test_publisherMatch(t *testing.T) { expected = "Allscripts" // the capability statement is missing the publisher path = filepath.Join("../../testdata", "allscripts_capability_dstu2.json") - dstu2JSON, err = ioutil.ReadFile(path) + dstu2JSON, err = os.ReadFile(path) th.Assert(t, err == nil, err) dstu2, err = capabilityparser.NewCapabilityStatement(dstu2JSON) @@ -731,7 +731,7 @@ func Test_publisherMatch(t *testing.T) { expected = "Medical Information Technology, Inc. (MEDITECH)" // the capability statement is missing the publisher path = filepath.Join("../../testdata", "meditech_capability_dstu2.json") - dstu2JSON, err = ioutil.ReadFile(path) + dstu2JSON, err = os.ReadFile(path) th.Assert(t, err == nil, err) dstu2, err = capabilityparser.NewCapabilityStatement(dstu2JSON) @@ -788,7 +788,7 @@ func Test_hackMatch(t *testing.T) { expected = "Epic Systems Corporation" path = filepath.Join("../../testdata", "epic_capability_dstu2.json") - dstu2JSON, err = ioutil.ReadFile(path) + dstu2JSON, err = os.ReadFile(path) th.Assert(t, err == nil, err) dstu2, err = capabilityparser.NewCapabilityStatement(dstu2JSON) @@ -825,7 +825,7 @@ func Test_hackMatchEpic(t *testing.T) { expected = "Epic Systems Corporation" path = filepath.Join("../../testdata", "epic_capability_dstu2.json") - dstu2JSON, err = ioutil.ReadFile(path) + dstu2JSON, err = os.ReadFile(path) th.Assert(t, err == nil, err) dstu2, err = capabilityparser.NewCapabilityStatement(dstu2JSON) @@ -840,7 +840,7 @@ func Test_hackMatchEpic(t *testing.T) { expected = "" path = filepath.Join("../../testdata", "cerner_capability_dstu2.json") - dstu2JSON, err = ioutil.ReadFile(path) + dstu2JSON, err = os.ReadFile(path) th.Assert(t, err == nil, err) dstu2, err = capabilityparser.NewCapabilityStatement(dstu2JSON) @@ -855,7 +855,7 @@ func Test_hackMatchEpic(t *testing.T) { expected = "" path = filepath.Join("../../testdata", "meditech_capability_dstu2.json") - dstu2JSON, err = ioutil.ReadFile(path) + dstu2JSON, err = os.ReadFile(path) th.Assert(t, err == nil, err) dstu2, err = capabilityparser.NewCapabilityStatement(dstu2JSON) diff --git a/e2e/integration_tests/data_flow_test.go b/e2e/integration_tests/data_flow_test.go index 5493d8150..a6338470a 100644 --- a/e2e/integration_tests/data_flow_test.go +++ b/e2e/integration_tests/data_flow_test.go @@ -1,3 +1,4 @@ +//go:build e2e // +build e2e package integration_tests @@ -6,7 +7,6 @@ import ( "context" "database/sql" "fmt" - "io/ioutil" "log" "net/http" "os" @@ -85,7 +85,7 @@ func populateTestEndpointData(testEndpointList string, source string) { var listOfEndpoints fetcher.ListOfEndpoints var knownSource string var knownFormat string - content, err := ioutil.ReadFile(testEndpointList) + content, err := os.ReadFile(testEndpointList) helpers.FailOnError("", err) if source == "Test" { diff --git a/endpointmanager/cmd/CHPLpopulator/main.go b/endpointmanager/cmd/CHPLpopulator/main.go index 003f64bf6..3a3417dfd 100644 --- a/endpointmanager/cmd/CHPLpopulator/main.go +++ b/endpointmanager/cmd/CHPLpopulator/main.go @@ -3,7 +3,7 @@ package main import ( "context" "encoding/json" - "io/ioutil" + "io" http "net/http" "os" "regexp" @@ -214,7 +214,7 @@ func main() { log.Fatal(err) } - err = ioutil.WriteFile("../../../resources/prod_resources/"+fileToWriteToCHPLList, finalFormatJSON, 0644) + err = os.WriteFile("../../../resources/prod_resources/"+fileToWriteToCHPLList, finalFormatJSON, 0644) if err != nil { log.Fatal(err) } @@ -225,7 +225,7 @@ func main() { log.Fatal(err) } - err = ioutil.WriteFile("../../../resources/dev_resources/"+fileToWriteToCHPLList, devfinalFormatJSONEndpoints, 0644) + err = os.WriteFile("../../../resources/dev_resources/"+fileToWriteToCHPLList, devfinalFormatJSONEndpoints, 0644) if err != nil { log.Fatal(err) } @@ -235,7 +235,7 @@ func main() { log.Fatal(err) } - err = ioutil.WriteFile("../../../resources/prod_resources/"+fileToWriteToSoftwareInfo, finalFormatJSONSoftware, 0644) + err = os.WriteFile("../../../resources/prod_resources/"+fileToWriteToSoftwareInfo, finalFormatJSONSoftware, 0644) if err != nil { log.Fatal(err) } @@ -246,7 +246,7 @@ func main() { log.Fatal(err) } - err = ioutil.WriteFile("../../../resources/dev_resources/"+fileToWriteToSoftwareInfo, devfinalFormatJSONSoftware, 0644) + err = os.WriteFile("../../../resources/dev_resources/"+fileToWriteToSoftwareInfo, devfinalFormatJSONSoftware, 0644) if err != nil { log.Fatal(err) } @@ -271,7 +271,7 @@ func getEndpointListJSON(chplURL string, pageSize int, pageNumber int, ctx conte } defer res.Body.Close() - respBody, err := ioutil.ReadAll(res.Body) + respBody, err := io.ReadAll(res.Body) if err != nil { return nil, err } diff --git a/endpointmanager/cmd/CHPLupdatecheck/main.go b/endpointmanager/cmd/CHPLupdatecheck/main.go index 5e6c96552..30f7eedda 100644 --- a/endpointmanager/cmd/CHPLupdatecheck/main.go +++ b/endpointmanager/cmd/CHPLupdatecheck/main.go @@ -3,7 +3,7 @@ package main import ( "encoding/json" "fmt" - "io/ioutil" + "io" http "net/http" "os" "path/filepath" @@ -48,7 +48,7 @@ func main() { } defer res.Body.Close() - respBody, err := ioutil.ReadAll(res.Body) + respBody, err := io.ReadAll(res.Body) if err != nil { log.Fatal(err) } @@ -71,7 +71,7 @@ func main() { // Get CHPL Endpoint list stored in Lantern resources folder path := filepath.Join("../../../resources/prod_resources/", "CHPLEndpointResourcesList.json") - CHPLFile, err := ioutil.ReadFile(path) + CHPLFile, err := os.ReadFile(path) if err != nil { log.Fatal(err) } @@ -91,7 +91,7 @@ func main() { log.Fatal(err) } - err = ioutil.WriteFile("../../../resources/prod_resources/"+fileToWriteTo, finalFormatJSON, 0644) + err = os.WriteFile("../../../resources/prod_resources/"+fileToWriteTo, finalFormatJSON, 0644) if err != nil { log.Fatal(err) } @@ -101,7 +101,7 @@ func main() { log.Fatal(err) } - err = ioutil.WriteFile("../../../resources/prod_resources/updatedEmails.json", finalFormatJSON, 0644) + err = os.WriteFile("../../../resources/prod_resources/updatedEmails.json", finalFormatJSON, 0644) if err != nil { log.Fatal(err) } diff --git a/endpointmanager/cmd/archivefile/main.go b/endpointmanager/cmd/archivefile/main.go index 8750d8d90..8c2593d8c 100644 --- a/endpointmanager/cmd/archivefile/main.go +++ b/endpointmanager/cmd/archivefile/main.go @@ -3,7 +3,6 @@ package main import ( "context" "encoding/json" - "io/ioutil" "os" "time" @@ -55,6 +54,6 @@ func main() { helpers.FailOnError("", err) // Write to the given file - err = ioutil.WriteFile(writeFile, finalFormatJSON, 0644) + err = os.WriteFile(writeFile, finalFormatJSON, 0644) helpers.FailOnError("ERROR: Writing to given file failed", err) } diff --git a/endpointmanager/cmd/chplquerier/main.go b/endpointmanager/cmd/chplquerier/main.go index 09dbee65f..2c352aaac 100644 --- a/endpointmanager/cmd/chplquerier/main.go +++ b/endpointmanager/cmd/chplquerier/main.go @@ -2,16 +2,15 @@ package main import ( "context" - "io/ioutil" - "net/http" - "strings" - "time" - "github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/chplquerier" "github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/config" "github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/endpointmanager/postgresql" "github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/helpers" log "github.com/sirupsen/logrus" + "net/http" + "os" + "strings" + "time" "github.com/spf13/viper" ) @@ -33,7 +32,7 @@ func main() { } // Read version file that is mounted to make user agent - version, err := ioutil.ReadFile("/etc/lantern/VERSION") + version, err := os.ReadFile("/etc/lantern/VERSION") if err != nil { log.Warnf("Cannot read VERSION file") } diff --git a/endpointmanager/cmd/sendendpoints/main.go b/endpointmanager/cmd/sendendpoints/main.go index 6811b6c37..3d29dbda8 100644 --- a/endpointmanager/cmd/sendendpoints/main.go +++ b/endpointmanager/cmd/sendendpoints/main.go @@ -2,7 +2,6 @@ package main import ( "context" - "io/ioutil" "os" "sync" @@ -33,7 +32,7 @@ func main() { var emptyJSON []byte if _, err := os.Stat("/etc/lantern/exportfolder/fhir_endpoints_fields.json"); os.IsNotExist(err) { - err = ioutil.WriteFile("/etc/lantern/exportfolder/fhir_endpoints_fields.json", emptyJSON, 0644) + err = os.WriteFile("/etc/lantern/exportfolder/fhir_endpoints_fields.json", emptyJSON, 0644) helpers.FailOnError("Failed to create empty JSON export file", err) } diff --git a/endpointmanager/pkg/archivefile/archivefile_integration_test.go b/endpointmanager/pkg/archivefile/archivefile_integration_test.go index 9ea7e4564..242b774e1 100644 --- a/endpointmanager/pkg/archivefile/archivefile_integration_test.go +++ b/endpointmanager/pkg/archivefile/archivefile_integration_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package archivefile @@ -6,7 +7,6 @@ import ( "context" "database/sql" "fmt" - "io/ioutil" "os" "path/filepath" "testing" @@ -33,16 +33,16 @@ var workerDur int var numWorkers int var testFhirEndpointInfo = endpointmanager.FHIREndpointInfo{ - URL: "http://example.com/DTSU2/", - MIMETypes: []string{"application/json+fhir"}, - TLSVersion: "TLS 1.2", + URL: "http://example.com/DTSU2/", + MIMETypes: []string{"application/json+fhir"}, + TLSVersion: "TLS 1.2", RequestedFhirVersion: "None", } var testFhirEndpointInfo2 = endpointmanager.FHIREndpointInfo{ - URL: "http://example.com/DTSU2/", - MIMETypes: []string{"application/fhir+json"}, - TLSVersion: "TLS 1.3", + URL: "http://example.com/DTSU2/", + MIMETypes: []string{"application/fhir+json"}, + TLSVersion: "TLS 1.3", RequestedFhirVersion: "None", } @@ -51,26 +51,26 @@ var testFhirEndpointOrganization = &endpointmanager.FHIREndpointOrganization{ } var testFhirEndpoint = endpointmanager.FHIREndpoint{ - URL: "http://example.com/DTSU2/", + URL: "http://example.com/DTSU2/", OrganizationList: []*endpointmanager.FHIREndpointOrganization{testFhirEndpointOrganization}, - ListSource: "http://cerner.com/dstu2", + ListSource: "http://cerner.com/dstu2", } var testMetadata = endpointmanager.FHIREndpointMetadata{ - URL: "http://example.com/DTSU2/", - HTTPResponse: 200, - Errors: "Smart Response Failed", - ResponseTime: 0.8, - SMARTHTTPResponse: 400, + URL: "http://example.com/DTSU2/", + HTTPResponse: 200, + Errors: "Smart Response Failed", + ResponseTime: 0.8, + SMARTHTTPResponse: 400, RequestedFhirVersion: "None", } var testMetadata2 = endpointmanager.FHIREndpointMetadata{ - URL: "http://example.com/DTSU2/", - HTTPResponse: 200, - Errors: "Smart Response Failed", - ResponseTime: 1.0, - SMARTHTTPResponse: 0, + URL: "http://example.com/DTSU2/", + HTTPResponse: 200, + Errors: "Smart Response Failed", + ResponseTime: 1.0, + SMARTHTTPResponse: 0, RequestedFhirVersion: "None", } @@ -332,12 +332,12 @@ func Test_getHistory(t *testing.T) { resultCh2 := make(chan Result) jobArgs2 := make(map[string]interface{}) jobArgs2["historyArgs"] = historyArgs{ - fhirURL: "http://example.com/DTSU2/", + fhirURL: "http://example.com/DTSU2/", requestedFhirVersion: "None", - dateStart: formatToday, - dateEnd: formatTomorrow, - store: store, - result: resultCh2, + dateStart: formatToday, + dateEnd: formatTomorrow, + store: store, + result: resultCh2, } go getHistory(ctx, &jobArgs2) @@ -361,12 +361,12 @@ func Test_getHistory(t *testing.T) { resultCh := make(chan Result) jobArgs := make(map[string]interface{}) jobArgs["historyArgs"] = historyArgs{ - fhirURL: "http://example.com/DTSU2/", + fhirURL: "http://example.com/DTSU2/", requestedFhirVersion: "None", - dateStart: formatToday, - dateEnd: formatTomorrow, - store: store, - result: resultCh, + dateStart: formatToday, + dateEnd: formatTomorrow, + store: store, + result: resultCh, } go getHistory(ctx, &jobArgs) @@ -395,12 +395,12 @@ func Test_getHistory(t *testing.T) { resultCh4 := make(chan Result) jobArgs4 := make(map[string]interface{}) jobArgs4["historyArgs"] = historyArgs{ - fhirURL: "thisurldoesntexist.com", + fhirURL: "thisurldoesntexist.com", requestedFhirVersion: "None", - dateStart: formatToday, - dateEnd: formatTomorrow, - store: store, - result: resultCh4, + dateStart: formatToday, + dateEnd: formatTomorrow, + store: store, + result: resultCh4, } go getHistory(ctx, &jobArgs4) @@ -435,12 +435,12 @@ func Test_getMetadata(t *testing.T) { resultCh := make(chan Result) jobArgs := make(map[string]interface{}) jobArgs["historyArgs"] = historyArgs{ - fhirURL: "http://example.com/DTSU2/", + fhirURL: "http://example.com/DTSU2/", requestedFhirVersion: "None", - dateStart: formatToday, - dateEnd: formatTomorrow, - store: store, - result: resultCh, + dateStart: formatToday, + dateEnd: formatTomorrow, + store: store, + result: resultCh, } go getMetadata(ctx, &jobArgs) @@ -460,12 +460,12 @@ func Test_getMetadata(t *testing.T) { resultCh2 := make(chan Result) jobArgs2 := make(map[string]interface{}) jobArgs2["historyArgs"] = historyArgs{ - fhirURL: "http://example.com/DTSU2/", + fhirURL: "http://example.com/DTSU2/", requestedFhirVersion: "None", - dateStart: formatToday, - dateEnd: formatTomorrow, - store: store, - result: resultCh2, + dateStart: formatToday, + dateEnd: formatTomorrow, + store: store, + result: resultCh2, } go getMetadata(ctx, &jobArgs2) @@ -488,12 +488,12 @@ func Test_getMetadata(t *testing.T) { resultCh3 := make(chan Result) jobArgs3 := make(map[string]interface{}) jobArgs3["historyArgs"] = historyArgs{ - fhirURL: "http://example.com/DTSU2/", + fhirURL: "http://example.com/DTSU2/", requestedFhirVersion: "None", - dateStart: formatToday, - dateEnd: formatTomorrow, - store: store, - result: resultCh3, + dateStart: formatToday, + dateEnd: formatTomorrow, + store: store, + result: resultCh3, } go getMetadata(ctx, &jobArgs3) @@ -524,12 +524,12 @@ func Test_getMetadata(t *testing.T) { resultCh5 := make(chan Result) jobArgs5 := make(map[string]interface{}) jobArgs5["historyArgs"] = historyArgs{ - fhirURL: "thisurldoesntexist.com", + fhirURL: "thisurldoesntexist.com", requestedFhirVersion: "None", - dateStart: formatToday, - dateEnd: formatTomorrow, - store: store, - result: resultCh5, + dateStart: formatToday, + dateEnd: formatTomorrow, + store: store, + result: resultCh5, } go getMetadata(ctx, &jobArgs5) @@ -544,7 +544,7 @@ func Test_getMetadata(t *testing.T) { func setupCapabilityStatement(t *testing.T, path string) { // capability statement - csJSON, err := ioutil.ReadFile(path) + csJSON, err := os.ReadFile(path) th.Assert(t, err == nil, err) cs, err := capabilityparser.NewCapabilityStatement(csJSON) th.Assert(t, err == nil, err) @@ -583,7 +583,7 @@ func addFHIREndpointInfoHistory(ctx context.Context, pq.Array(e.MIMETypes), vendorID, capabilityStatementJSON, - e.CapabilityFhirVersion, + e.CapabilityFhirVersion, e.RequestedFhirVersion) if err != nil { return err diff --git a/endpointmanager/pkg/capabilityparser/capabilityparser_test.go b/endpointmanager/pkg/capabilityparser/capabilityparser_test.go index d3ffcc187..89e076a3e 100644 --- a/endpointmanager/pkg/capabilityparser/capabilityparser_test.go +++ b/endpointmanager/pkg/capabilityparser/capabilityparser_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "os" "path/filepath" "reflect" "testing" @@ -100,7 +100,7 @@ func Test_NewCapabilityStatement(t *testing.T) { // capability statement path = filepath.Join("../testdata", "epic_capability_dstu2.json") - csJSON, err = ioutil.ReadFile(path) + csJSON, err = os.ReadFile(path) th.Assert(t, err == nil, err) cs, err = NewCapabilityStatement(csJSON) th.Assert(t, err == nil, err) @@ -113,7 +113,7 @@ func Test_NewCapabilityStatement(t *testing.T) { // capability statement path = filepath.Join("../testdata", "epic_capability_stu3.json") - csJSON, err = ioutil.ReadFile(path) + csJSON, err = os.ReadFile(path) th.Assert(t, err == nil, err) cs, err = NewCapabilityStatement(csJSON) th.Assert(t, err == nil, err) @@ -764,7 +764,7 @@ func Test_Equal_Ignore(t *testing.T) { func getDSTU2CapStat() (CapabilityStatement, error) { path := filepath.Join("../testdata", "allscripts_capability_dstu2.json") - csJSON, err := ioutil.ReadFile(path) + csJSON, err := os.ReadFile(path) if err != nil { return nil, err } diff --git a/endpointmanager/pkg/chplendpointquerier/chplendpointquerier.go b/endpointmanager/pkg/chplendpointquerier/chplendpointquerier.go index c9d77f439..8c55e98e1 100644 --- a/endpointmanager/pkg/chplendpointquerier/chplendpointquerier.go +++ b/endpointmanager/pkg/chplendpointquerier/chplendpointquerier.go @@ -2,7 +2,7 @@ package chplendpointquerier import ( "encoding/json" - "io/ioutil" + "os" "strings" ) @@ -119,7 +119,7 @@ var novomediciURL = "https://www.novomedici.com/api-documents/" var patientpatternURL = "https://patientpattern-static.s3.us-west-2.amazonaws.com/static/documents/fhir-base-urls.csv" var pcisgoldURL = "https://fhir.pcisgold.com/fhirdocs/practices.json" -// var healthieURL = "https://app-52512.on-aptible.com/service-base-urls" +var healthieURL = "https://app-52512.on-aptible.com/service-base-urls" var medConnectURL = "https://api.medconnecthealth.com/fhir/r4/endpoints" var citiusTechURL = "https://8759937.fs1.hubspotusercontent-na1.net/hubfs/8759937/assets/pdfs/Perform+ConnectServerEndpoints.json" var enableHealthcareURL = "https://ehifire.ehiconnect.com/fhir/r4/endpoints" @@ -166,7 +166,7 @@ var anthemURL = "https://patient360.anthem.com/P360Member/fhir" // var guidewellURL = "https://developer.bcbsfl.com/interop/interop-developer-portal/product/469/api/466#/PatientAccessAPI_105/overview" // var hcscURL = "https://interoperability.hcsc.com/s/patient-access-api" var humanaURL = "https://developers.humana.com/apis/patient-api/doc" -// var kaiserURL = "https://developer.kp.org/#/apis/639c015049655aa96ab5b2f1" +var kaiserURL = "https://developer.kp.org/#/apis/639c015049655aa96ab5b2f1" // var molinaURL = "https://developer.interop.molinahealthcare.com/api-details#api=patient-access&operation=5f72ab665269f310ef58b361" var unitedHealthURL = "https://www.uhc.com/legal/interoperability-apis" var meldrxURL = "https://app.meldrx.com/api/Directories/fhir/endpoints" @@ -243,7 +243,7 @@ func QueryCHPLEndpointList(chplURL string, fileToWriteTo string) { } else if URLsEqual(chplURL, firstInsightURL) { FirstInsightBundleParser(chplURL, fileToWriteTo) } else if URLsEqual(chplURL, healthSamuraiURL) { - HealthSamuraiWebscraper("https://smartbox.aidbox.app/service-base-urls", fileToWriteTo) + CustomBundleQuerierParser("https://smartbox.aidbox.app/service-base-urls", fileToWriteTo) } else if URLsEqual(chplURL, triarqURL) { TRIARQPracticeWebscraper(chplURL, fileToWriteTo) } else if URLsEqual(chplURL, cyfluentURL) { @@ -406,8 +406,8 @@ func QueryCHPLEndpointList(chplURL string, fileToWriteTo string) { PatientpatternURLCSVParser(chplURL, fileToWriteTo) } else if URLsEqual(chplURL, pcisgoldURL) { PCISgoldURLWebscraper(chplURL, fileToWriteTo) - // } else if URLsEqual(chplURL, healthieURL) { - // BundleQuerierParser(chplURL, fileToWriteTo) + } else if URLsEqual(chplURL, healthieURL) { + CustomBundleQuerierParser(chplURL, fileToWriteTo) } else if URLsEqual(chplURL, medConnectURL) { BundleQuerierParser(chplURL, fileToWriteTo) } else if URLsEqual(chplURL, citiusTechURL) { @@ -510,10 +510,11 @@ func QueryCHPLEndpointList(chplURL string, fileToWriteTo string) { // GuidewellURLWebscraper(chplURL, fileToWriteTo) // } else if URLsEqual(chplURL, hcscURL) { // HcscURLWebscraper(chplURL, fileToWriteTo) + } else if URLsEqual(chplURL, humanaURL) { HumanaURLWebscraper(chplURL, fileToWriteTo) - //} else if URLsEqual(chplURL, kaiserURL) { - //KaiserURLWebscraper(chplURL, fileToWriteTo) + } else if URLsEqual(chplURL, kaiserURL) { + KaiserURLWebscraper(chplURL, fileToWriteTo) // } else if URLsEqual(chplURL, molinaURL) { // MolinaURLWebscraper(chplURL, fileToWriteTo) } else if URLsEqual(chplURL, unitedHealthURL) { @@ -534,7 +535,7 @@ func WriteCHPLFile(endpointEntryList EndpointList, fileToWriteTo string) error { return err } - err = ioutil.WriteFile("../../../resources/prod_resources/"+fileToWriteTo, finalFormatJSON, 0644) + err = os.WriteFile("../../../resources/prod_resources/"+fileToWriteTo, finalFormatJSON, 0644) if err != nil { return err } @@ -548,7 +549,7 @@ func WriteCHPLFile(endpointEntryList EndpointList, fileToWriteTo string) error { return err } - err = ioutil.WriteFile("../../../resources/dev_resources/"+fileToWriteTo, reducedFinalFormatJSON, 0644) + err = os.WriteFile("../../../resources/dev_resources/"+fileToWriteTo, reducedFinalFormatJSON, 0644) if err != nil { return err } diff --git a/endpointmanager/pkg/chplendpointquerier/custombundlequerierparser.go b/endpointmanager/pkg/chplendpointquerier/custombundlequerierparser.go new file mode 100644 index 000000000..a4df4272e --- /dev/null +++ b/endpointmanager/pkg/chplendpointquerier/custombundlequerierparser.go @@ -0,0 +1,51 @@ +package chplendpointquerier + +import ( + "encoding/json" + + "github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/helpers" + log "github.com/sirupsen/logrus" +) + +type CustomBundle struct { + Entries []CustomBundleEntry `json:"entry"` +} + +type CustomBundleEntry struct { + Id string `json:"id"` + Name string `json:"name"` + Url string `json:"url"` +} + +func CustomBundleQuerierParser(CHPLURL string, fileToWriteTo string) { + + var entry LanternEntry + var lanternEntryList []LanternEntry + var endpointEntryList EndpointList + + respBody, err := helpers.QueryEndpointList(CHPLURL) + if err != nil { + log.Fatal(err) + } + + var customBundle CustomBundle + err = json.Unmarshal(respBody, &customBundle) + if err != nil { + log.Fatal(err) + } + + for _, bundleEntry := range customBundle.Entries { + entry.URL = bundleEntry.Url + entry.OrganizationName = bundleEntry.Name + + lanternEntryList = append(lanternEntryList, entry) + } + + endpointEntryList.Endpoints = lanternEntryList + + err = WriteCHPLFile(endpointEntryList, fileToWriteTo) + if err != nil { + log.Fatal(err) + } + +} diff --git a/endpointmanager/pkg/chplendpointquerier/healthsamuraiparser.go b/endpointmanager/pkg/chplendpointquerier/healthsamuraiparser.go deleted file mode 100644 index f2076ca28..000000000 --- a/endpointmanager/pkg/chplendpointquerier/healthsamuraiparser.go +++ /dev/null @@ -1,45 +0,0 @@ -package chplendpointquerier - -import ( - "strings" - - "github.com/PuerkitoBio/goquery" - "github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/helpers" - log "github.com/sirupsen/logrus" -) - -func HealthSamuraiWebscraper(CHPLURL string, fileToWriteTo string) { - - var lanternEntryList []LanternEntry - var endpointEntryList EndpointList - - doc, err := helpers.ChromedpQueryEndpointList(CHPLURL, ".container") - if err != nil { - log.Fatal(err) - } - - doc.Find(".container").Each(func(index int, containterElems *goquery.Selection) { - containterElems.Find(".row").Each(func(index int, rowElems *goquery.Selection) { - rowElems.Find(".col-12").Each(func(index int, colElems *goquery.Selection) { - colElems.Find("ul").Each(func(index int, ulElems *goquery.Selection) { - ulElems.Find("li").Each(func(index int, liElems *goquery.Selection) { - var entry LanternEntry - - entryURL := strings.TrimSpace(liElems.Text()) - entry.URL = entryURL - - lanternEntryList = append(lanternEntryList, entry) - }) - }) - }) - }) - }) - - endpointEntryList.Endpoints = lanternEntryList - - err = WriteCHPLFile(endpointEntryList, fileToWriteTo) - if err != nil { - log.Fatal(err) - } - -} diff --git a/endpointmanager/pkg/chplendpointquerier/kaiserwebscraper.go b/endpointmanager/pkg/chplendpointquerier/kaiserwebscraper.go index ccd53b480..fce02eda3 100644 --- a/endpointmanager/pkg/chplendpointquerier/kaiserwebscraper.go +++ b/endpointmanager/pkg/chplendpointquerier/kaiserwebscraper.go @@ -1,10 +1,12 @@ package chplendpointquerier import ( + "context" "strings" + "time" "github.com/PuerkitoBio/goquery" - "github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/helpers" + "github.com/chromedp/chromedp" log "github.com/sirupsen/logrus" ) @@ -13,7 +15,7 @@ func KaiserURLWebscraper(CHPLURL string, fileToWriteTo string) { var lanternEntryList []LanternEntry var endpointEntryList EndpointList - doc, err := helpers.ChromedpQueryEndpointList(CHPLURL, ".language-json") + doc, err := KaiserChromedpQueryEndpointList(CHPLURL, ".opblock-tag-section") if err != nil { log.Fatal(err) } @@ -25,9 +27,10 @@ func KaiserURLWebscraper(CHPLURL string, fileToWriteTo string) { found = true } if found { - if strings.Contains(spanhtml.Text(), "/FHIR/api") { + if strings.HasSuffix(spanhtml.Text(), "/FHIR/api\"") { var entry LanternEntry URL := strings.TrimSpace(spanhtml.Text()) + URL = strings.ReplaceAll(URL, "\"", "") entry.URL = URL processed = true lanternEntryList = append(lanternEntryList, entry) @@ -49,3 +52,53 @@ func KaiserURLWebscraper(CHPLURL string, fileToWriteTo string) { } } + +// KaiserChromedpQueryEndpointList queries the given endpoint list and clicks buttons using chromedp and returns the html document +func KaiserChromedpQueryEndpointList(endpointListURL string, waitVisibleElement string) (*goquery.Document, error) { + + ctx, cancel := chromedp.NewContext(context.Background()) + defer cancel() + + timeoutContext, cancel := context.WithTimeout(ctx, 90*time.Second) + defer cancel() + + var htmlContent string + var err error + + if len(waitVisibleElement) > 0 { + // Chromedp will wait a max of 30 seconds for webpage to run javascript code to generate api search results before grapping HTML + err = chromedp.Run(timeoutContext, + chromedp.Navigate(endpointListURL), + chromedp.WaitVisible(waitVisibleElement, chromedp.ByQuery), + + // Expand the Metadata section + chromedp.WaitVisible(`.expand-operation`), + chromedp.Click(`.expand-operation`, chromedp.ByQuery), + + // Expand the Metadata endpoint section + chromedp.WaitVisible(`.opblock-summary-control`), + chromedp.Click(`.opblock-summary-control`, chromedp.ByQuery), + + // Wait till the code snippet is rendered + chromedp.WaitVisible(`.language-json`), + + chromedp.OuterHTML("html", &htmlContent, chromedp.ByQuery), + ) + } else { + err = chromedp.Run(timeoutContext, + chromedp.Navigate(endpointListURL), + chromedp.OuterHTML("html", &htmlContent, chromedp.ByQuery), + ) + } + + if err != nil { + return nil, err + } + + doc, err := goquery.NewDocumentFromReader(strings.NewReader(htmlContent)) + if err != nil { + return nil, err + } + + return doc, nil +} diff --git a/endpointmanager/pkg/chplquerier/chplquerier.go b/endpointmanager/pkg/chplquerier/chplquerier.go index eac961fb2..361e70a07 100644 --- a/endpointmanager/pkg/chplquerier/chplquerier.go +++ b/endpointmanager/pkg/chplquerier/chplquerier.go @@ -3,7 +3,7 @@ package chplquerier import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "strconv" @@ -66,7 +66,7 @@ func getJSON(ctx context.Context, client *http.Client, chplURL *url.URL, userAge return nil, errors.New("CHPL request responded with status: " + resp.Status) } - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, errors.Wrap(err, "reading the CHPL response body failed") } diff --git a/endpointmanager/pkg/chplquerier/criteriaquerier_test.go b/endpointmanager/pkg/chplquerier/criteriaquerier_test.go index 90f3b91a1..f4031956e 100644 --- a/endpointmanager/pkg/chplquerier/criteriaquerier_test.go +++ b/endpointmanager/pkg/chplquerier/criteriaquerier_test.go @@ -4,8 +4,8 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "net/url" + "os" "path/filepath" "strings" "testing" @@ -236,7 +236,7 @@ func Test_getCriteriaJSON(t *testing.T) { func basicTestCriteriaClient() (*th.TestClient, error) { path := filepath.Join("testdata", "chpl_criteria.json") - okResponse, err := ioutil.ReadFile(path) + okResponse, err := os.ReadFile(path) if err != nil { return nil, err } diff --git a/endpointmanager/pkg/chplquerier/productquerier.go b/endpointmanager/pkg/chplquerier/productquerier.go index f8b12165b..918b47934 100644 --- a/endpointmanager/pkg/chplquerier/productquerier.go +++ b/endpointmanager/pkg/chplquerier/productquerier.go @@ -5,9 +5,9 @@ import ( "database/sql" "encoding/json" "fmt" - "io/ioutil" "net/http" "net/url" + "os" "sort" "strconv" "strings" @@ -111,7 +111,7 @@ func GetCHPLEndpointListProducts(ctx context.Context, store *postgresql.Store) e log.Info("Getting chpl product information from CHPLProductsInfo.json file") // Get CHPL Endpoint list stored in Lantern resources folder - CHPLFile, err := ioutil.ReadFile("/etc/lantern/resources/CHPLProductsInfo.json") + CHPLFile, err := os.ReadFile("/etc/lantern/resources/CHPLProductsInfo.json") if err != nil { log.Fatal(err) } diff --git a/endpointmanager/pkg/chplquerier/productquerier_test.go b/endpointmanager/pkg/chplquerier/productquerier_test.go index 8434635b2..b3ad54dd2 100644 --- a/endpointmanager/pkg/chplquerier/productquerier_test.go +++ b/endpointmanager/pkg/chplquerier/productquerier_test.go @@ -4,8 +4,8 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "net/url" + "os" "path/filepath" "reflect" "strings" @@ -661,7 +661,7 @@ func Test_getProductJSON(t *testing.T) { func basicTestClient() (*th.TestClient, error) { path := filepath.Join("testdata", "chpl_certified_products.json") - okResponse, err := ioutil.ReadFile(path) + okResponse, err := os.ReadFile(path) if err != nil { return nil, err } diff --git a/endpointmanager/pkg/chplquerier/vendorquerier_integration_test.go b/endpointmanager/pkg/chplquerier/vendorquerier_integration_test.go index ec4599003..77f0bde15 100644 --- a/endpointmanager/pkg/chplquerier/vendorquerier_integration_test.go +++ b/endpointmanager/pkg/chplquerier/vendorquerier_integration_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package chplquerier diff --git a/endpointmanager/pkg/chplquerier/vendorquerier_test.go b/endpointmanager/pkg/chplquerier/vendorquerier_test.go index fd713b907..5d1ba6b93 100644 --- a/endpointmanager/pkg/chplquerier/vendorquerier_test.go +++ b/endpointmanager/pkg/chplquerier/vendorquerier_test.go @@ -4,8 +4,8 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "net/url" + "os" "path/filepath" "strings" "testing" @@ -428,7 +428,7 @@ func Test_parseVendor(t *testing.T) { func basicVendorTestClient() (*th.TestClient, error) { path := filepath.Join("testdata", "chpl_vendors.json") - okResponse, err := ioutil.ReadFile(path) + okResponse, err := os.ReadFile(path) if err != nil { return nil, err } diff --git a/endpointmanager/pkg/endpointlinker/endpointlinker.go b/endpointmanager/pkg/endpointlinker/endpointlinker.go index 3263753ff..c03bfa3f4 100644 --- a/endpointmanager/pkg/endpointlinker/endpointlinker.go +++ b/endpointmanager/pkg/endpointlinker/endpointlinker.go @@ -5,7 +5,7 @@ import ( "database/sql" "encoding/json" "fmt" - "io/ioutil" + "io" "math" "os" "regexp" @@ -415,7 +415,7 @@ func openLinkerCorrectionFiles(filepath string) ([]map[string]string, error) { defer jsonFile.Close() var linkerCorrections []map[string]string - byteValueFile, err := ioutil.ReadAll(jsonFile) + byteValueFile, err := io.ReadAll(jsonFile) if err != nil { return nil, err } diff --git a/endpointmanager/pkg/endpointlinker/endpointlinker_integration_test.go b/endpointmanager/pkg/endpointlinker/endpointlinker_integration_test.go index 4960022e8..5337f3975 100644 --- a/endpointmanager/pkg/endpointlinker/endpointlinker_integration_test.go +++ b/endpointmanager/pkg/endpointlinker/endpointlinker_integration_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package endpointlinker @@ -12,8 +13,8 @@ import ( "github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/config" "github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/endpointmanager" "github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/endpointmanager/postgresql" - th "github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/testhelper" "github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/helpers" + th "github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/testhelper" "github.com/spf13/viper" ) @@ -49,26 +50,26 @@ func Test_matchByID(t *testing.T) { defer teardown(t, store.DB) var epOrganization1 = &endpointmanager.FHIREndpointOrganization{ - OrganizationName: "FOO FOO BAR", + OrganizationName: "FOO FOO BAR", OrganizationNPIID: "1"} var epOrganization2 = &endpointmanager.FHIREndpointOrganization{ - OrganizationName: "FOO FOO BAR", + OrganizationName: "FOO FOO BAR", OrganizationNPIID: "2"} var epOrganization3 = &endpointmanager.FHIREndpointOrganization{ - OrganizationName: "FOO FOO BAR", + OrganizationName: "FOO FOO BAR", OrganizationNPIID: "3"} var epOrganization4 = &endpointmanager.FHIREndpointOrganization{ - OrganizationName: "FOO FOO BAR", + OrganizationName: "FOO FOO BAR", OrganizationNPIID: "4"} var ep = &endpointmanager.FHIREndpoint{ - ID: 1, - URL: "example.com/FHIR/DSTU2", + ID: 1, + URL: "example.com/FHIR/DSTU2", OrganizationList: []*endpointmanager.FHIREndpointOrganization{epOrganization1, epOrganization2, epOrganization3}, - ListSource: "https://open.epic.com/Endpoints/DSTU2"} + ListSource: "https://open.epic.com/Endpoints/DSTU2"} ctx := context.Background() @@ -131,15 +132,15 @@ func Test_addMatch(t *testing.T) { defer teardown(t, store.DB) ctx := context.Background() - + var epOrganization = &endpointmanager.FHIREndpointOrganization{ OrganizationName: "FOO FOO BAR"} ep := &endpointmanager.FHIREndpoint{ - ID: 1, - URL: "example.com/FHIR/DSTU2", - OrganizationList: []*endpointmanager.FHIREndpointOrganization{epOrganization}, - ListSource: "https://open.epic.com/Endpoints/DSTU2"} + ID: 1, + URL: "example.com/FHIR/DSTU2", + OrganizationList: []*endpointmanager.FHIREndpointOrganization{epOrganization}, + ListSource: "https://open.epic.com/Endpoints/DSTU2"} npiID := "1" confidence := .6 @@ -186,28 +187,28 @@ func Test_manualLinkerCorrections(t *testing.T) { OrganizationName: "FOO BAR BAR"} var epOrganization3 = &endpointmanager.FHIREndpointOrganization{ - OrganizationName: "BAR BAR FOO", + OrganizationName: "BAR BAR FOO", OrganizationNPIID: "3"} - + ep1 := &endpointmanager.FHIREndpoint{ - ID: 1, - URL: "example.com/FHIR/DSTU2", + ID: 1, + URL: "example.com/FHIR/DSTU2", OrganizationList: []*endpointmanager.FHIREndpointOrganization{epOrganization1}, - ListSource: "https://open.epic.com/Endpoints/DSTU2"} + ListSource: "https://open.epic.com/Endpoints/DSTU2"} npiID1 := "1" confidence1 := .6 ep2 := &endpointmanager.FHIREndpoint{ - ID: 2, - URL: "example2.com/FHIR/DSTU2", + ID: 2, + URL: "example2.com/FHIR/DSTU2", OrganizationList: []*endpointmanager.FHIREndpointOrganization{epOrganization2}, - ListSource: "https://open.epic.com/Endpoints/DSTU2"} + ListSource: "https://open.epic.com/Endpoints/DSTU2"} npiID2 := "2" confidence2 := .8 ep3 := &endpointmanager.FHIREndpoint{ - ID: 3, - URL: "example3.com/FHIR/DSTU2", + ID: 3, + URL: "example3.com/FHIR/DSTU2", OrganizationList: []*endpointmanager.FHIREndpointOrganization{epOrganization3}, - ListSource: "https://open.epic.com/Endpoints/DSTU2"} + ListSource: "https://open.epic.com/Endpoints/DSTU2"} npiID3 := "3" confidence3 := .5 @@ -287,7 +288,7 @@ func Test_manualLinkerCorrections(t *testing.T) { sNpiID, sEpURL, sConfidence, err = store.GetNPIOrganizationFHIREndpointLink(ctx, npiID2, ep2.URL) th.Assert(t, err == sql.ErrNoRows, "Expected sql no rows error due to being in blocklist file") - + endpoint3, err := store.GetFHIREndpoint(ctx, ep3.ID) npiIDsArray := endpoint3.GetNPIIDs() organizationNamesArray := endpoint3.GetOrganizationNames() diff --git a/endpointmanager/pkg/endpointmanager/fhirendpointinfo_test.go b/endpointmanager/pkg/endpointmanager/fhirendpointinfo_test.go index 39a7d91b6..02b9a1aa7 100644 --- a/endpointmanager/pkg/endpointmanager/fhirendpointinfo_test.go +++ b/endpointmanager/pkg/endpointmanager/fhirendpointinfo_test.go @@ -1,7 +1,7 @@ package endpointmanager import ( - "io/ioutil" + "os" "path/filepath" "testing" @@ -259,7 +259,7 @@ func Test_FHIREndpointInfoEqual(t *testing.T) { // capability statement path := filepath.Join("../testdata", "cerner_capability_dstu2.json") - csJSON, err := ioutil.ReadFile(path) + csJSON, err := os.ReadFile(path) if err != nil { t.Error(err) } diff --git a/endpointmanager/pkg/endpointmanager/postgresql/criteriastore_integration_test.go b/endpointmanager/pkg/endpointmanager/postgresql/criteriastore_integration_test.go index 6c4f462ab..217834e69 100644 --- a/endpointmanager/pkg/endpointmanager/postgresql/criteriastore_integration_test.go +++ b/endpointmanager/pkg/endpointmanager/postgresql/criteriastore_integration_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package postgresql diff --git a/endpointmanager/pkg/endpointmanager/postgresql/fhirendpointinfostore_test.go b/endpointmanager/pkg/endpointmanager/postgresql/fhirendpointinfostore_test.go index 2c737b538..3d8e379d5 100644 --- a/endpointmanager/pkg/endpointmanager/postgresql/fhirendpointinfostore_test.go +++ b/endpointmanager/pkg/endpointmanager/postgresql/fhirendpointinfostore_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package postgresql @@ -6,7 +7,7 @@ import ( "bytes" "context" "fmt" - "io/ioutil" + "os" "path/filepath" "reflect" "testing" @@ -26,7 +27,7 @@ func Test_PersistFHIREndpointInfo(t *testing.T) { // capability statement path := filepath.Join("../../testdata", "cerner_capability_dstu2.json") - csJSON, err := ioutil.ReadFile(path) + csJSON, err := os.ReadFile(path) if err != nil { t.Error(err) } @@ -36,7 +37,7 @@ func Test_PersistFHIREndpointInfo(t *testing.T) { } var endpointOrganization1 = &endpointmanager.FHIREndpointOrganization{ - OrganizationName: "Example Inc.", + OrganizationName: "Example Inc.", OrganizationNPIID: "1"} var endpointOrganization2 = &endpointmanager.FHIREndpointOrganization{ @@ -44,11 +45,11 @@ func Test_PersistFHIREndpointInfo(t *testing.T) { // add endpoints that can later be referenced var endpoint1 = &endpointmanager.FHIREndpoint{ - URL: "example.com/FHIR/DSTU2/", + URL: "example.com/FHIR/DSTU2/", OrganizationList: []*endpointmanager.FHIREndpointOrganization{endpointOrganization1}, - ListSource: "https://github.com/cerner/ignite-endpoints"} + ListSource: "https://github.com/cerner/ignite-endpoints"} var endpoint2 = &endpointmanager.FHIREndpoint{ - URL: "other.example.com/FHIR/DSTU2/", + URL: "other.example.com/FHIR/DSTU2/", OrganizationList: []*endpointmanager.FHIREndpointOrganization{endpointOrganization2}} store.AddFHIREndpoint(ctx, endpoint1) store.AddFHIREndpoint(ctx, endpoint2) @@ -87,30 +88,30 @@ func Test_PersistFHIREndpointInfo(t *testing.T) { // endpointInfos var endpointInfo1 = &endpointmanager.FHIREndpointInfo{ - URL: endpoint1.URL, - VendorID: cerner.ID, - TLSVersion: "TLS 1.1", - MIMETypes: []string{"application/json+fhir"}, - CapabilityStatement: cs, + URL: endpoint1.URL, + VendorID: cerner.ID, + TLSVersion: "TLS 1.1", + MIMETypes: []string{"application/json+fhir"}, + CapabilityStatement: cs, CapabilityStatementBytes: csJSON, - SMARTResponse: nil, - SMARTResponseBytes: []byte("null"), - RequestedFhirVersion: "None", - CapabilityFhirVersion: "1.0.2", - Metadata: endpointMetadata1} + SMARTResponse: nil, + SMARTResponseBytes: []byte("null"), + RequestedFhirVersion: "None", + CapabilityFhirVersion: "1.0.2", + Metadata: endpointMetadata1} var endpointInfo1RequestedVersion = &endpointmanager.FHIREndpointInfo{ - URL: endpoint1.URL, - VendorID: cerner.ID, - TLSVersion: "TLS 1.1", - MIMETypes: []string{"application/json+fhir"}, - CapabilityStatement: cs, + URL: endpoint1.URL, + VendorID: cerner.ID, + TLSVersion: "TLS 1.1", + MIMETypes: []string{"application/json+fhir"}, + CapabilityStatement: cs, CapabilityStatementBytes: csJSON, - SMARTResponse: nil, - SMARTResponseBytes: []byte("null"), - RequestedFhirVersion: "1.0.0", - CapabilityFhirVersion: "1.0.2", - Metadata: endpointMetadata1RequestedVersion} + SMARTResponse: nil, + SMARTResponseBytes: []byte("null"), + RequestedFhirVersion: "1.0.0", + CapabilityFhirVersion: "1.0.2", + Metadata: endpointMetadata1RequestedVersion} var endpointInfo2 = &endpointmanager.FHIREndpointInfo{ URL: endpoint2.URL, diff --git a/endpointmanager/pkg/endpointmanager/postgresql/fhirendpointmetadatastore_test.go b/endpointmanager/pkg/endpointmanager/postgresql/fhirendpointmetadatastore_test.go index 19369fa63..2e27a7701 100644 --- a/endpointmanager/pkg/endpointmanager/postgresql/fhirendpointmetadatastore_test.go +++ b/endpointmanager/pkg/endpointmanager/postgresql/fhirendpointmetadatastore_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package postgresql @@ -5,7 +6,7 @@ package postgresql import ( "context" "fmt" - "io/ioutil" + "os" "path/filepath" "testing" @@ -24,7 +25,7 @@ func Test_PersistFHIREndpointMetadata(t *testing.T) { // capability statement path := filepath.Join("../../testdata", "cerner_capability_dstu2.json") - csJSON, err := ioutil.ReadFile(path) + csJSON, err := os.ReadFile(path) if err != nil { t.Error(err) } @@ -51,16 +52,16 @@ func Test_PersistFHIREndpointMetadata(t *testing.T) { // endpointInfos var endpointInfo1 = &endpointmanager.FHIREndpointInfo{ - URL: "example.com/FHIR/DSTU2/", - TLSVersion: "TLS 1.1", - MIMETypes: []string{"application/json+fhir"}, - CapabilityStatement: cs, + URL: "example.com/FHIR/DSTU2/", + TLSVersion: "TLS 1.1", + MIMETypes: []string{"application/json+fhir"}, + CapabilityStatement: cs, CapabilityStatementBytes: csJSON, - RequestedFhirVersion: "None", - CapabilityFhirVersion: "1.0.2", - SMARTResponse: nil, - SMARTResponseBytes: []byte("null"), - Metadata: endpointMetadata1} + RequestedFhirVersion: "None", + CapabilityFhirVersion: "1.0.2", + SMARTResponse: nil, + SMARTResponseBytes: []byte("null"), + Metadata: endpointMetadata1} var endpointInfo2 = &endpointmanager.FHIREndpointInfo{ URL: "other.example.com/FHIR/DSTU2/", TLSVersion: "TLS 1.2", diff --git a/endpointmanager/pkg/endpointmanager/postgresql/fhirendpointstore_test.go b/endpointmanager/pkg/endpointmanager/postgresql/fhirendpointstore_test.go index 6c50cd1b9..23f90f16d 100644 --- a/endpointmanager/pkg/endpointmanager/postgresql/fhirendpointstore_test.go +++ b/endpointmanager/pkg/endpointmanager/postgresql/fhirendpointstore_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package postgresql @@ -22,7 +23,7 @@ func Test_PersistFHIREndpoint(t *testing.T) { ctx := context.Background() var endpointOrganization1 = &endpointmanager.FHIREndpointOrganization{ - OrganizationName: "Example Inc.", + OrganizationName: "Example Inc.", OrganizationNPIID: "1"} var endpointOrganization2 = &endpointmanager.FHIREndpointOrganization{ @@ -30,12 +31,12 @@ func Test_PersistFHIREndpoint(t *testing.T) { // endpoints var endpoint1 = &endpointmanager.FHIREndpoint{ - URL: "https://example.com/FHIR/DSTU2/", + URL: "https://example.com/FHIR/DSTU2/", OrganizationList: []*endpointmanager.FHIREndpointOrganization{endpointOrganization1}, - ListSource: "https://github.com/cerner/ignite-endpoints"} + ListSource: "https://github.com/cerner/ignite-endpoints"} var endpoint2 = &endpointmanager.FHIREndpoint{ - URL: "https://other.example.com/FHIR/DSTU2/", + URL: "https://other.example.com/FHIR/DSTU2/", OrganizationList: []*endpointmanager.FHIREndpointOrganization{endpointOrganization2}} // add endpoints @@ -118,11 +119,11 @@ func Test_PersistFHIREndpoint(t *testing.T) { } var org1 = &endpointmanager.FHIREndpointOrganization{ - OrganizationName: "Org 1", + OrganizationName: "Org 1", OrganizationNPIID: "2"} var org2 = &endpointmanager.FHIREndpointOrganization{ - OrganizationName: "Org 2", + OrganizationName: "Org 2", OrganizationNPIID: "3"} e1.OrganizationList = []*endpointmanager.FHIREndpointOrganization{org1, org2} @@ -152,11 +153,11 @@ func Test_PersistFHIREndpoint(t *testing.T) { // update endpoint NPI Org var NPIOrg = &endpointmanager.FHIREndpointOrganization{ - OrganizationName: "Fake Organization", + OrganizationName: "Fake Organization", OrganizationNPIID: "123"} var fhirEndpointNPIOrg = &endpointmanager.FHIREndpoint{ - URL: "https://example.com/FHIR/DSTU2/", + URL: "https://example.com/FHIR/DSTU2/", OrganizationList: []*endpointmanager.FHIREndpointOrganization{NPIOrg}, } @@ -260,7 +261,7 @@ func Test_PersistFHIREndpoint(t *testing.T) { } for _, ep := range endpts { - + epOrganizationsList := ep.GetOrganizationNames() if ep.ID == endpoint1.ID { diff --git a/endpointmanager/pkg/endpointmanager/postgresql/healthitproductstore_test.go b/endpointmanager/pkg/endpointmanager/postgresql/healthitproductstore_test.go index b15ed6ad1..b96d51ec3 100644 --- a/endpointmanager/pkg/endpointmanager/postgresql/healthitproductstore_test.go +++ b/endpointmanager/pkg/endpointmanager/postgresql/healthitproductstore_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package postgresql @@ -63,7 +64,7 @@ func Test_PersistHealthITProduct(t *testing.T) { LastModifiedInCHPL: time.Date(2019, 10, 19, 0, 0, 0, 0, time.UTC), CHPLID: "ID", PracticeType: "Ambulatory", - ACB: "SLI Compliance"} + ACB: "SLI Compliance"} var hitp2 = &endpointmanager.HealthITProduct{ Name: "Health IT System 2", Version: "2.0", diff --git a/endpointmanager/pkg/endpointmanager/postgresql/npicontactstore_test.go b/endpointmanager/pkg/endpointmanager/postgresql/npicontactstore_test.go index cb9e90a69..ba65092d3 100644 --- a/endpointmanager/pkg/endpointmanager/postgresql/npicontactstore_test.go +++ b/endpointmanager/pkg/endpointmanager/postgresql/npicontactstore_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package postgresql diff --git a/endpointmanager/pkg/endpointmanager/postgresql/npiorganizationstore_test.go b/endpointmanager/pkg/endpointmanager/postgresql/npiorganizationstore_test.go index 516335983..e28fabf2a 100644 --- a/endpointmanager/pkg/endpointmanager/postgresql/npiorganizationstore_test.go +++ b/endpointmanager/pkg/endpointmanager/postgresql/npiorganizationstore_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package postgresql @@ -322,18 +323,18 @@ func Test_LinkNPIOrganizationToFHIREndpoint(t *testing.T) { // endpoints var endpoint1Org = &endpointmanager.FHIREndpointOrganization{ - OrganizationName: "Example Inc.", + OrganizationName: "Example Inc.", OrganizationNPIID: "1"} - + var endpoint2Org = &endpointmanager.FHIREndpointOrganization{ OrganizationName: "Other Example Inc."} var endpoint1 = &endpointmanager.FHIREndpoint{ - URL: "example.com/FHIR/DSTU2/", + URL: "example.com/FHIR/DSTU2/", OrganizationList: []*endpointmanager.FHIREndpointOrganization{endpoint1Org}, - ListSource: "https://github.com/cerner/ignite-endpoints"} + ListSource: "https://github.com/cerner/ignite-endpoints"} var endpoint2 = &endpointmanager.FHIREndpoint{ - URL: "other.example.com/FHIR/DSTU2/", + URL: "other.example.com/FHIR/DSTU2/", OrganizationList: []*endpointmanager.FHIREndpointOrganization{endpoint2Org}} err = store.AddNPIOrganization(ctx, npio1) diff --git a/endpointmanager/pkg/endpointmanager/postgresql/store_test.go b/endpointmanager/pkg/endpointmanager/postgresql/store_test.go index d66f7839f..198eabfad 100644 --- a/endpointmanager/pkg/endpointmanager/postgresql/store_test.go +++ b/endpointmanager/pkg/endpointmanager/postgresql/store_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package postgresql diff --git a/endpointmanager/pkg/endpointmanager/postgresql/validationstore_test.go b/endpointmanager/pkg/endpointmanager/postgresql/validationstore_test.go index 3333f6922..497fa0c78 100644 --- a/endpointmanager/pkg/endpointmanager/postgresql/validationstore_test.go +++ b/endpointmanager/pkg/endpointmanager/postgresql/validationstore_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package postgresql diff --git a/endpointmanager/pkg/endpointmanager/postgresql/vendorstore_test.go b/endpointmanager/pkg/endpointmanager/postgresql/vendorstore_test.go index 2f0ebf5fe..ab7350b32 100644 --- a/endpointmanager/pkg/endpointmanager/postgresql/vendorstore_test.go +++ b/endpointmanager/pkg/endpointmanager/postgresql/vendorstore_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package postgresql diff --git a/endpointmanager/pkg/endpointwebscraper/endpointwebscraper.go b/endpointmanager/pkg/endpointwebscraper/endpointwebscraper.go index 47351d1bd..e3ab4e6d7 100644 --- a/endpointmanager/pkg/endpointwebscraper/endpointwebscraper.go +++ b/endpointmanager/pkg/endpointwebscraper/endpointwebscraper.go @@ -2,7 +2,7 @@ package endpointwebscraper import ( "encoding/json" - "io/ioutil" + "os" ) type EndpointList struct { @@ -35,7 +35,7 @@ func WriteEndpointListFile(endpointEntryList EndpointList, fileToWriteTo string) return err } - err = ioutil.WriteFile("../../../resources/prod_resources/"+fileToWriteTo, finalFormatJSON, 0644) + err = os.WriteFile("../../../resources/prod_resources/"+fileToWriteTo, finalFormatJSON, 0644) if err != nil { return err } @@ -49,7 +49,7 @@ func WriteEndpointListFile(endpointEntryList EndpointList, fileToWriteTo string) return err } - err = ioutil.WriteFile("../../../resources/dev_resources/"+fileToWriteTo, reducedFinalFormatJSON, 0644) + err = os.WriteFile("../../../resources/dev_resources/"+fileToWriteTo, reducedFinalFormatJSON, 0644) if err != nil { return err } diff --git a/endpointmanager/pkg/fetcher/fetcher.go b/endpointmanager/pkg/fetcher/fetcher.go index c793b0008..6dbe01683 100644 --- a/endpointmanager/pkg/fetcher/fetcher.go +++ b/endpointmanager/pkg/fetcher/fetcher.go @@ -3,7 +3,7 @@ package fetcher import ( "encoding/json" "fmt" - "io/ioutil" + "io" "os" "github.com/onc-healthit/lantern-back-end/endpointmanager/pkg/helpers" @@ -50,7 +50,7 @@ func GetEndpointsFromFilepath(filePath string, format string, source string, lis // Defer the closing of our jsonFile so that we can parse it later on defer jsonFile.Close() - byteValue, _ := ioutil.ReadAll(jsonFile) + byteValue, _ := io.ReadAll(jsonFile) if len(byteValue) == 0 { return ListOfEndpoints{}, nil } diff --git a/endpointmanager/pkg/fhirendpointquerier/populatefhirendpoints_integration_test.go b/endpointmanager/pkg/fhirendpointquerier/populatefhirendpoints_integration_test.go index 38bde843e..60edf3fef 100644 --- a/endpointmanager/pkg/fhirendpointquerier/populatefhirendpoints_integration_test.go +++ b/endpointmanager/pkg/fhirendpointquerier/populatefhirendpoints_integration_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package populatefhirendpoints @@ -31,11 +32,11 @@ var testEndpointEntry2 fetcher.EndpointEntry = fetcher.EndpointEntry{ ListSource: "epicList", } var testEndpointEntry3 fetcher.EndpointEntry = fetcher.EndpointEntry{ - OrganizationName: "fakeOrganization", + OrganizationName: "fakeOrganization", FHIRPatientFacingURI: "http://example.com/DTSU2/", ListSource: "Lantern", NPIID: "1", - OrganizationZipCode: "12345", + OrganizationZipCode: "12345", } var testEndpointEntry4 fetcher.EndpointEntry = fetcher.EndpointEntry{ OrganizationName: "fakeOrganization2", @@ -48,19 +49,19 @@ var testFHIREndpoint2Org = &endpointmanager.FHIREndpointOrganization{ OrganizationName: "Access Community Health Network"} var testFHIREndpoint3Org = &endpointmanager.FHIREndpointOrganization{ - OrganizationName: "fakeOrganization", - OrganizationNPIID: "1", + OrganizationName: "fakeOrganization", + OrganizationNPIID: "1", OrganizationZipCode: "12345"} var testFHIREndpoint2 endpointmanager.FHIREndpoint = endpointmanager.FHIREndpoint{ OrganizationList: []*endpointmanager.FHIREndpointOrganization{testFHIREndpoint2Org}, - URL: "https://eprescribing.accesscommunityhealth.net/FHIR/api/FHIR/DSTU2/", - ListSource: "epicList", + URL: "https://eprescribing.accesscommunityhealth.net/FHIR/api/FHIR/DSTU2/", + ListSource: "epicList", } var testFHIREndpoint3 endpointmanager.FHIREndpoint = endpointmanager.FHIREndpoint{ OrganizationList: []*endpointmanager.FHIREndpointOrganization{testFHIREndpoint3Org}, - URL: "http://example.com/DTSU2/", - ListSource: "Lantern", + URL: "http://example.com/DTSU2/", + ListSource: "Lantern", } func TestMain(m *testing.M) { @@ -182,7 +183,7 @@ func Test_saveEndpointData(t *testing.T) { th.Assert(t, fhirEndpt.Equal(savedEndpt), "stored data does not equal expected store data") // check that an item with the same URL replaces item and merges the organization names lists - + endpt.OrganizationName = "AdvantageCare Physicians 2" err = saveEndpointData(ctx, store, &endpt) th.Assert(t, err == nil, err) @@ -195,7 +196,7 @@ func Test_saveEndpointData(t *testing.T) { th.Assert(t, err == nil, err) savedEndpt, err = store.GetFHIREndpoint(ctx, endptID) th.Assert(t, err == nil, err) - + savedEndptOrganizationList := savedEndpt.GetOrganizationNames() th.Assert(t, helpers.StringArraysEqual(savedEndptOrganizationList, []string{"AdvantageCare Physicians", "AdvantageCare Physicians 2"}), fmt.Sprintf("stored data %v does not equal expected store data [AdvantageCare Physicians, AdvantageCare Physicians 2]", savedEndptOrganizationList)) @@ -303,7 +304,7 @@ func Test_AddEndpointData(t *testing.T) { endpt2 = testEndpointEntry endpt2.OrganizationName = "New Name" - + // endpt1 and endpt2 identical other than organization name. // endpt1 has organization name "AdvantageCare Physicians" listEndpoints = fetcher.ListOfEndpoints{Entries: []fetcher.EndpointEntry{endpt1, endpt2}} @@ -351,7 +352,7 @@ func Test_RemoveOldEndpointsAndOldOrganizations(t *testing.T) { org_query_str := "SELECT COUNT(*) FROM fhir_endpoint_organizations;" var ct int var ctOrg int - + // Add first endpoint err = store.AddFHIREndpoint(ctx, &endpt1) th.Assert(t, err == nil, err) @@ -416,11 +417,11 @@ func Test_RemoveOldEndpointsAndOldOrganizations(t *testing.T) { // Check that first endpoint is removed based on update time _, err = store.GetFHIREndpointUsingURLAndListSource(ctx, endpt1.URL, endpt1.ListSource) th.Assert(t, err == sql.ErrNoRows, "Expected endpoint to removed") - + // Check that first endpoint's organization is removed based on update time _, err = store.GetFHIREndpointOrganizationByInfo(ctx, endpt1.ID, endpt1.OrganizationList[0]) th.Assert(t, err == sql.ErrNoRows, "Expected endpoint 1's organization to removed") - + // Check that second endpoint still exist _, err = store.GetFHIREndpointUsingURLAndListSource(ctx, endpt2.URL, endpt2.ListSource) th.Assert(t, err == nil, "Endpoint should still exist from different listsource") diff --git a/endpointmanager/pkg/helpers/helpers.go b/endpointmanager/pkg/helpers/helpers.go index c20a5e022..71d55fa1f 100644 --- a/endpointmanager/pkg/helpers/helpers.go +++ b/endpointmanager/pkg/helpers/helpers.go @@ -4,7 +4,6 @@ import ( "context" "encoding/csv" "io" - "io/ioutil" "log" "net/http" "os" @@ -143,7 +142,7 @@ func QueryEndpointList(endpointListURL string) ([]byte, error) { } defer res.Body.Close() - respBody, err := ioutil.ReadAll(res.Body) + respBody, err := io.ReadAll(res.Body) if err != nil { return nil, err } diff --git a/endpointmanager/pkg/historypruning/historypruning_integration_test.go b/endpointmanager/pkg/historypruning/historypruning_integration_test.go index 91249ec43..f5d504256 100644 --- a/endpointmanager/pkg/historypruning/historypruning_integration_test.go +++ b/endpointmanager/pkg/historypruning/historypruning_integration_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package historypruning @@ -7,7 +8,6 @@ import ( "database/sql" "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" "strconv" @@ -1209,7 +1209,7 @@ func checkValidationResultCount(ctx context.Context, store *postgresql.Store, to func setupCapabilityStatement(t *testing.T, path string) { // capability statement - csJSON, err := ioutil.ReadFile(path) + csJSON, err := os.ReadFile(path) th.Assert(t, err == nil, err) cs, err := capabilityparser.NewCapabilityStatement(csJSON) th.Assert(t, err == nil, err) diff --git a/endpointmanager/pkg/jsonexport/jsonexport.go b/endpointmanager/pkg/jsonexport/jsonexport.go index ff2f2baf9..a1f13dba7 100644 --- a/endpointmanager/pkg/jsonexport/jsonexport.go +++ b/endpointmanager/pkg/jsonexport/jsonexport.go @@ -5,7 +5,7 @@ import ( "database/sql" "encoding/json" "fmt" - "io/ioutil" + "os" "time" "github.com/lib/pq" @@ -60,7 +60,7 @@ func CreateJSONExport(ctx context.Context, store *postgresql.Store, fileToWriteT return err } // Write to the given file - err = ioutil.WriteFile(fileToWriteTo, finalFormatJSON, 0644) + err = os.WriteFile(fileToWriteTo, finalFormatJSON, 0644) return err } diff --git a/endpointmanager/pkg/jsonexport/jsonexport_integration_test.go b/endpointmanager/pkg/jsonexport/jsonexport_integration_test.go index 2d4a58e8e..5777c9986 100644 --- a/endpointmanager/pkg/jsonexport/jsonexport_integration_test.go +++ b/endpointmanager/pkg/jsonexport/jsonexport_integration_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package jsonexport @@ -25,9 +26,9 @@ var testEndpointOrganization = &endpointmanager.FHIREndpointOrganization{ OrganizationName: "Test Org"} var testEndpoint = endpointmanager.FHIREndpoint{ - URL: "www.testURL.com", + URL: "www.testURL.com", OrganizationList: []*endpointmanager.FHIREndpointOrganization{testEndpointOrganization}, - ListSource: "Test List Source", + ListSource: "Test List Source", } var testEndpointMetadata = endpointmanager.FHIREndpointMetadata{ @@ -146,9 +147,9 @@ func Test_getHistory(t *testing.T) { resultCh := make(chan Result) jobArgs := make(map[string]interface{}) jobArgs["historyArgs"] = historyArgs{ - fhirURL: "www.testURL.com", - store: store, - result: resultCh, + fhirURL: "www.testURL.com", + store: store, + result: resultCh, exportType: "30days", } @@ -193,9 +194,9 @@ func Test_getHistory(t *testing.T) { resultChMonth := make(chan Result) jobArgsMonth := make(map[string]interface{}) jobArgsMonth["historyArgs"] = historyArgs{ - fhirURL: "www.testURL.com", - store: store, - result: resultChMonth, + fhirURL: "www.testURL.com", + store: store, + result: resultChMonth, exportType: "month", } @@ -210,7 +211,6 @@ func Test_getHistory(t *testing.T) { // base case with export type equal to all - _, err = store.DB.Exec("DElETE FROM fhir_endpoints_info;") th.Assert(t, err == nil, err) @@ -227,13 +227,12 @@ func Test_getHistory(t *testing.T) { // 3 endpoints should be stored since 1 entry will also be added for deleting from the fhir_endpoints_info table th.Assert(t, actualNumEndptsStored == 3, fmt.Sprintf("Expected 3 endpoints stored. Actually had %d endpoints stored.", actualNumEndptsStored)) - resultChAll := make(chan Result) jobArgsAll := make(map[string]interface{}) jobArgsAll["historyArgs"] = historyArgs{ - fhirURL: "www.testURL.com", - store: store, - result: resultChAll, + fhirURL: "www.testURL.com", + store: store, + result: resultChAll, exportType: "all", } @@ -261,9 +260,9 @@ func Test_getHistory(t *testing.T) { resultCh3 := make(chan Result) jobArgs3 := make(map[string]interface{}) jobArgs3["historyArgs"] = historyArgs{ - fhirURL: "thisurldoesntexist.com", - store: store, - result: resultCh3, + fhirURL: "thisurldoesntexist.com", + store: store, + result: resultCh3, exportType: "30days", } diff --git a/endpointmanager/pkg/medicaidendpointquerier/medicaidendpointquerier.go b/endpointmanager/pkg/medicaidendpointquerier/medicaidendpointquerier.go index 42f2f3dd7..0ed8a584f 100644 --- a/endpointmanager/pkg/medicaidendpointquerier/medicaidendpointquerier.go +++ b/endpointmanager/pkg/medicaidendpointquerier/medicaidendpointquerier.go @@ -4,7 +4,6 @@ import ( "encoding/csv" "encoding/json" "io" - "io/ioutil" "log" "os" "strings" @@ -88,7 +87,7 @@ func WriteCHPLFile(endpointEntryList EndpointList, fileToWriteTo string) error { return err } - err = ioutil.WriteFile("../../../resources/prod_resources/"+fileToWriteTo, finalFormatJSON, 0644) + err = os.WriteFile("../../../resources/prod_resources/"+fileToWriteTo, finalFormatJSON, 0644) if err != nil { return err } @@ -102,7 +101,7 @@ func WriteCHPLFile(endpointEntryList EndpointList, fileToWriteTo string) error { return err } - err = ioutil.WriteFile("../../../resources/dev_resources/"+fileToWriteTo, reducedFinalFormatJSON, 0644) + err = os.WriteFile("../../../resources/dev_resources/"+fileToWriteTo, reducedFinalFormatJSON, 0644) if err != nil { return err } diff --git a/endpointmanager/pkg/medicareendpointquerier/medicareendpointquerier.go b/endpointmanager/pkg/medicareendpointquerier/medicareendpointquerier.go index adf44e17b..5bb1b2f7c 100644 --- a/endpointmanager/pkg/medicareendpointquerier/medicareendpointquerier.go +++ b/endpointmanager/pkg/medicareendpointquerier/medicareendpointquerier.go @@ -4,7 +4,6 @@ import ( "encoding/csv" "encoding/json" "io" - "io/ioutil" "log" "os" "strings" @@ -97,7 +96,7 @@ func WritePayerFile(endpointEntryList EndpointList, fileToWriteTo string) error return err } - err = ioutil.WriteFile("../../../resources/prod_resources/"+fileToWriteTo, finalFormatJSON, 0644) + err = os.WriteFile("../../../resources/prod_resources/"+fileToWriteTo, finalFormatJSON, 0644) if err != nil { return err } @@ -111,7 +110,7 @@ func WritePayerFile(endpointEntryList EndpointList, fileToWriteTo string) error return err } - err = ioutil.WriteFile("../../../resources/dev_resources/"+fileToWriteTo, reducedFinalFormatJSON, 0644) + err = os.WriteFile("../../../resources/dev_resources/"+fileToWriteTo, reducedFinalFormatJSON, 0644) if err != nil { return err } diff --git a/endpointmanager/pkg/nppesquerier/populatenpi_integration_test.go b/endpointmanager/pkg/nppesquerier/populatenpi_integration_test.go index 94a896bce..d1647b837 100644 --- a/endpointmanager/pkg/nppesquerier/populatenpi_integration_test.go +++ b/endpointmanager/pkg/nppesquerier/populatenpi_integration_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package nppesquerier_test diff --git a/endpointmanager/pkg/sendendpoints/sendenpt_integration_test.go b/endpointmanager/pkg/sendendpoints/sendenpt_integration_test.go index 4b9a58e84..12a057a50 100644 --- a/endpointmanager/pkg/sendendpoints/sendenpt_integration_test.go +++ b/endpointmanager/pkg/sendendpoints/sendenpt_integration_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package sendendpoints diff --git a/endpointmanager/pkg/smartparser/smartresponse_test.go b/endpointmanager/pkg/smartparser/smartresponse_test.go index 96bec8114..f3c6f8f13 100644 --- a/endpointmanager/pkg/smartparser/smartresponse_test.go +++ b/endpointmanager/pkg/smartparser/smartresponse_test.go @@ -1,7 +1,7 @@ package smartparser import ( - "io/ioutil" + "os" "path/filepath" "testing" @@ -13,7 +13,7 @@ func Test_SMARTResponseEqual(t *testing.T) { // get SMART Response path := filepath.Join("../testdata", "authorization_cerner_smart_response.json") - smartResponseJSON1, err := ioutil.ReadFile(path) + smartResponseJSON1, err := os.ReadFile(path) th.Assert(t, err == nil, err) SMARTResponse1, err := NewSMARTResp(smartResponseJSON1) @@ -27,7 +27,7 @@ func Test_SMARTResponseEqual(t *testing.T) { th.Assert(t, !equal, "expected equality comparison to nil to be false") // test equal - smartResponseJSON2, err := ioutil.ReadFile(path) + smartResponseJSON2, err := os.ReadFile(path) th.Assert(t, err == nil, err) SMARTResponse2, err = NewSMARTResp(smartResponseJSON2) @@ -73,7 +73,7 @@ func Test_SMARTResponseEqual(t *testing.T) { // get different SMART Response format to ensure Equal works for any smart response format path = filepath.Join("../testdata", "fhir_sandbox_smart_response.json") - smartResponseJSON1, err = ioutil.ReadFile(path) + smartResponseJSON1, err = os.ReadFile(path) th.Assert(t, err == nil, err) SMARTResponse1, err = NewSMARTResp(smartResponseJSON1) @@ -87,7 +87,7 @@ func Test_SMARTResponseEqual(t *testing.T) { th.Assert(t, !equal, "expected equality comparison to nil to be false") // test equal - smartResponseJSON2, err = ioutil.ReadFile(path) + smartResponseJSON2, err = os.ReadFile(path) th.Assert(t, err == nil, err) SMARTResponse2, err = NewSMARTResp(smartResponseJSON2) @@ -113,7 +113,7 @@ func Test_SMARTResponseEqualIgnore(t *testing.T) { // get SMART Response path := filepath.Join("../testdata", "authorization_cerner_smart_response.json") - smartResponseJSON1, err := ioutil.ReadFile(path) + smartResponseJSON1, err := os.ReadFile(path) th.Assert(t, err == nil, err) SMARTResponse1, err := NewSMARTResp(smartResponseJSON1) @@ -127,7 +127,7 @@ func Test_SMARTResponseEqualIgnore(t *testing.T) { th.Assert(t, !equal, "expected equality comparison to nil to be false") // test equal - smartResponseJSON2, err := ioutil.ReadFile(path) + smartResponseJSON2, err := os.ReadFile(path) th.Assert(t, err == nil, err) SMARTResponse2, err = NewSMARTResp(smartResponseJSON2) diff --git a/lanternmq/pkg/accessqueue/accessqueue_integration_test.go b/lanternmq/pkg/accessqueue/accessqueue_integration_test.go index 4f216defc..5c615ef2d 100644 --- a/lanternmq/pkg/accessqueue/accessqueue_integration_test.go +++ b/lanternmq/pkg/accessqueue/accessqueue_integration_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package accessqueue_test @@ -143,7 +144,6 @@ func Test_CleanQueue(t *testing.T) { th.Assert(t, err == nil, err) } - func Test_QueueCount(t *testing.T) { queueIsEmpty(t, qName) defer checkCleanQueue(t, qName, channel) @@ -182,7 +182,7 @@ func Test_QueueCount(t *testing.T) { // ack the message _, _, err = channel.Get(qName, true) th.Assert(t, err == nil, err) - + } func queueIsEmpty(t *testing.T, queueName string) { diff --git a/refresh.go b/refresh.go index 0aae4f219..c7c621395 100644 --- a/refresh.go +++ b/refresh.go @@ -3,7 +3,7 @@ package main import ( "context" "fmt" - "io/ioutil" + "io" "log" "net/http" "strings" @@ -58,7 +58,7 @@ func QueryEndpointList(endpointListURL string) ([]byte, error) { } defer res.Body.Close() - respBody, err := ioutil.ReadAll(res.Body) + respBody, err := io.ReadAll(res.Body) if err != nil { return nil, err }