Skip to content

Commit

Permalink
BCDA-7550: Job ID and CMS ID missing from BFD request/response (#887)
Browse files Browse the repository at this point in the history
## 🎫 Ticket

https://jira.cms.gov/browse/BCDA-7550

## 🛠 Changes

- Modified BBRequestSuite to configure a logger for the client so tests
can be run individually
- Modified createQueueJobs to set the CMS ID in the job arguments
- Added a test in bluebutton_test.go to make sure we are getting values
set when making a request to BFD

## ℹ️ Context for reviewers

Requests outgoing to BFD are missing values for the CMS_ID and the Job
ID when attempting to get the Patient Identifier.

## ✅ Acceptance Validation

Tested changes locally and with unit tests. Confirmed that 

## 🔒 Security Implications

- [ ] This PR adds a new software dependency or dependencies.
- [ ] This PR modifies or invalidates one or more of our security
controls.
- [ ] This PR stores or transmits data that was not stored or
transmitted before.
- [ ] This PR requires additional review of its security implications
for other reasons.

If any security implications apply, add Jason Ashbaugh (GitHub username:
StewGoin) as a reviewer and do not merge this PR without his approval.
  • Loading branch information
laurenkrugen-navapbc authored Nov 21, 2023
1 parent f20e558 commit e83513f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 24 additions & 1 deletion bcda/client/bluebutton_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http/httptest"
"net/url"
"os"
"strconv"
"strings"
"testing"
"time"
Expand All @@ -16,6 +17,7 @@ import (
"github.com/CMSgov/bcda-app/bcda/constants"
"github.com/CMSgov/bcda-app/bcda/models"
fhirModels "github.com/CMSgov/bcda-app/bcda/models/fhir"
"github.com/CMSgov/bcda-app/bcda/testUtils"
"github.com/CMSgov/bcda-app/conf"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/test"
Expand Down Expand Up @@ -44,6 +46,7 @@ type BBRequestTestSuite struct {

var (
ts200, ts500 *httptest.Server
logger = testUtils.GetLogger(logrus.StandardLogger())
now = time.Now()
nowFormatted = url.QueryEscape(now.Format(time.RFC3339Nano))
since = "gt2020-02-14"
Expand All @@ -60,7 +63,7 @@ func (s *BBTestSuite) SetupSuite() {
conf.SetEnv(s.T(), "BB_TIMEOUT_MS", "2000")

// Set up the logger since we're using the real client
client.SetLogger(logrus.StandardLogger())
client.SetLogger(logger)
}

func (s *BBRequestTestSuite) SetupSuite() {
Expand All @@ -74,6 +77,7 @@ func (s *BBRequestTestSuite) SetupSuite() {
}

func (s *BBRequestTestSuite) BeforeTest(suiteName, testName string) {
client.SetLogger(logger)
if strings.Contains(testName, "500") {
s.ts = ts500
} else {
Expand Down Expand Up @@ -223,6 +227,25 @@ func (s *BBTestSuite) TestGetDefaultParams() {

}

func (s *BBRequestTestSuite) TestGetBBLogs() {
hook := test.NewLocal(logger)
_, err := s.bbClient.GetPatient(jobData, "012345")
var logCMSID, logJobID bool
for _, entry := range hook.AllEntries() {
test := entry.Data
s.T().Log(test)
if entry.Data["cms_id"] == jobData.CMSID {
logCMSID = true
}
if entry.Data["job_id"] == strconv.Itoa(jobData.ID) {
logJobID = true
}
}
assert.True(s.T(), logCMSID)
assert.True(s.T(), logJobID)
assert.Nil(s.T(), err)
}

/* Tests that make requests, using clients configured with the 200 response and 500 response httptest.Servers initialized in SetupSuite() */
func (s *BBRequestTestSuite) TestGetPatient() {
p, err := s.bbClient.GetPatient(jobData, "012345")
Expand Down
2 changes: 2 additions & 0 deletions bcda/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ func (s *service) createQueueJobs(conditions RequestConditions, since time.Time,
enqueueArgs := models.JobEnqueueArgs{
ID: int(conditions.JobID),
ACOID: conditions.ACOID.String(),
CMSID: conditions.CMSID,
BeneficiaryIDs: jobIDs,
ResourceType: rt,
Since: sinceArg,
Expand All @@ -307,6 +308,7 @@ func (s *service) createQueueJobs(conditions RequestConditions, since time.Time,

jobs = append(jobs, &enqueueArgs)
}

} else {
// This should never be possible, would have returned earlier
return nil, errors.New("Invalid resource type: " + rt)
Expand Down

0 comments on commit e83513f

Please sign in to comment.