Skip to content

Commit

Permalink
Merge pull request #75 from tidepool-org/tk-visit-location
Browse files Browse the repository at this point in the history
[BACK-3287] Set visit location in results, notes and flowsheets
  • Loading branch information
toddkazakov authored Dec 16, 2024
2 parents 5ff8d64 + 46c3c7c commit e3a632c
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 0 deletions.
4 changes: 4 additions & 0 deletions redox/processor_neworder.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ func (o *newOrderProcessor) createSummaryStatisticsFlowsheet(params SummaryAndRe
flowsheet.Patient.Demographics = params.Order.Patient.Demographics

SetVisitNumberInFlowsheet(params.Order, &flowsheet)
SetVisitLocationInFlowsheet(params.Order, &flowsheet)
SetAccountNumberInFlowsheet(params.Order, &flowsheet)
PopulateSummaryStatistics(patient, params.Match.Clinic, &flowsheet)

Expand Down Expand Up @@ -561,6 +562,7 @@ func (o *newOrderProcessor) createReportNote(ctx context.Context, params Summary
notes.SetDestination(params.Match.Settings.DestinationIds.Notes)

notes.SetOrderId(params.Order)
notes.SetVisitLocationFromOrder(params.Order)
notes.SetVisitNumberFromOrder(params.Order)
notes.SetAccountNumberFromOrder(params.Order)

Expand Down Expand Up @@ -691,6 +693,7 @@ func (o *newOrderProcessor) sendMatchingResultsNotification(ctx context.Context,
SetMatchingResult(notification, params.Order, &results)
SetAccountNumberInResult(params.Order, &results)
SetVisitNumberInResult(params.Order, &results)
SetVisitLocationInResult(params.Order, &results)

if err := o.client.Send(ctx, results); err != nil {
// Return an error so we can retry the request
Expand Down Expand Up @@ -718,6 +721,7 @@ func (o *newOrderProcessor) sendAccountCreationResultsNotification(ctx context.C
SetAccountCreationResults(notification, order, &results)
SetAccountNumberInResult(order, &results)
SetVisitNumberInResult(order, &results)
SetVisitLocationInResult(order, &results)

if err := o.client.Send(ctx, results); err != nil {
// Return an error so we can retry the request
Expand Down
11 changes: 11 additions & 0 deletions redox/response_flowsheet.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,17 @@ func SetVisitNumberInFlowsheet(order models.NewOrder, flowsheet *models.NewFlows
}
}

func SetVisitLocationInFlowsheet(order models.NewOrder, flowsheet *models.NewFlowsheet) {
if order.Visit == nil {
return
}

if flowsheet.Visit == nil {
flowsheet.Visit = types.NewStructPtr(flowsheet.Visit)
}
flowsheet.Visit.Location = order.Visit.Location
}

func SetAccountNumberInFlowsheet(order models.NewOrder, flowsheet *models.NewFlowsheet) {
if order.Visit != nil && order.Visit.AccountNumber != nil {
if flowsheet.Visit == nil {
Expand Down
8 changes: 8 additions & 0 deletions redox/response_flowsheet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ var _ = Describe("Flowsheet", func() {
Expect(flowsheet.Visit).ToNot(BeNil())
Expect(flowsheet.Visit.VisitNumber).To(PointTo(Equal(*order.Visit.VisitNumber)))
})

Describe("SetVisitLocationFromOrder", func() {
It("sets the visit location from the order", func() {
redox.SetVisitLocationInFlowsheet(order, &flowsheet)
Expect(flowsheet.Visit).ToNot(BeNil())
Expect(flowsheet.Visit.Location).To(PointTo(Equal(*order.Visit.Location)))
})
})
})

Context("With EHR Match Response", func() {
Expand Down
11 changes: 11 additions & 0 deletions redox/response_new_notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ func (n *NewNotes) SetVisitNumberFromOrder(order models.NewOrder) {
}
}

func (n *NewNotes) SetVisitLocationFromOrder(order models.NewOrder) {
if order.Visit == nil {
return
}

if n.Visit == nil {
n.Visit = types.NewStructPtr(n.Visit)
}
n.Visit.Location = order.Visit.Location
}

func (n *NewNotes) SetAccountNumberFromOrder(order models.NewOrder) {
if order.Visit != nil && order.Visit.AccountNumber != nil {
if n.Visit == nil {
Expand Down
8 changes: 8 additions & 0 deletions redox/response_new_notes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ var _ = Describe("Notes", func() {
})
})

Describe("SetVisitLocationFromOrder", func() {
It("sets the visit location from the order", func() {
notes.SetVisitLocationFromOrder(order)
Expect(notes.Visit).ToNot(BeNil())
Expect(notes.Visit.Location).To(PointTo(Equal(*order.Visit.Location)))
})
})

Describe("SetAccountNumberInNotes", func() {
It("sets the visit number from the order", func() {
notes.SetAccountNumberFromOrder(order)
Expand Down
1 change: 1 addition & 0 deletions redox/response_notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Notes interface {
SetProviderFromOrder(order models.NewOrder)
SetProcedureFromOrder(order models.NewOrder)
SetVisitNumberFromOrder(order models.NewOrder)
SetVisitLocationFromOrder(order models.NewOrder)
SetOrderId(order models.NewOrder)
SetReportMetadata(documentId string)
SetEmbeddedFile(fileName string, fileType string, reader io.Reader) error
Expand Down
11 changes: 11 additions & 0 deletions redox/response_replace_notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ func (n *ReplaceNotes) SetVisitNumberFromOrder(order models.NewOrder) {
}
}

func (n *ReplaceNotes) SetVisitLocationFromOrder(order models.NewOrder) {
if order.Visit == nil {
return
}

if n.Visit == nil {
n.Visit = types.NewStructPtr(n.Visit)
}
n.Visit.Location = order.Visit.Location
}

func (n *ReplaceNotes) SetAccountNumberFromOrder(order models.NewOrder) {
if order.Visit != nil && order.Visit.AccountNumber != nil {
if n.Visit == nil {
Expand Down
8 changes: 8 additions & 0 deletions redox/response_replace_notes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ var _ = Describe("Notes", func() {
})
})

Describe("SetVisitLocationFromOrder", func() {
It("sets the visit location from the order", func() {
notes.SetVisitLocationFromOrder(order)
Expect(notes.Visit).ToNot(BeNil())
Expect(notes.Visit.Location).To(PointTo(Equal(*order.Visit.Location)))
})
})

Describe("SetAccountNumberInNotes", func() {
It("sets the account number from the order", func() {
notes.SetAccountNumberFromOrder(order)
Expand Down
11 changes: 11 additions & 0 deletions redox/response_results.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@ func SetVisitNumberInResult(order models.NewOrder, result *models.NewResults) {
}
}

func SetVisitLocationInResult(order models.NewOrder, result *models.NewResults) {
if order.Visit == nil {
return
}

if result.Visit == nil {
result.Visit = types.NewStructPtr(result.Visit)
}
result.Visit.Location = order.Visit.Location
}

func SetAccountNumberInResult(order models.NewOrder, result *models.NewResults) {
if order.Visit != nil && order.Visit.AccountNumber != nil {
if result.Visit == nil {
Expand Down
8 changes: 8 additions & 0 deletions redox/response_results_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ var _ = Describe("Results", func() {
})
})

Describe("SetVisitLocationFromOrder", func() {
It("sets the visit location from the order", func() {
redox.SetVisitLocationInResult(order, &results)
Expect(results.Visit).ToNot(BeNil())
Expect(results.Visit.Location).To(PointTo(Equal(*order.Visit.Location)))
})
})

Describe("SetResultsPatientFromOrder", func() {
It("sets the patient identifier and demographics from the order", func() {
redox.SetResultsPatientFromOrder(order, &results)
Expand Down

0 comments on commit e3a632c

Please sign in to comment.