Skip to content

Commit

Permalink
feat: record ultrasound test
Browse files Browse the repository at this point in the history
Signed-off-by: Kathurima Kimathi <kathurimakimathi415@gmail.com>
  • Loading branch information
KathurimaKimathi committed Feb 29, 2024
1 parent 1e7435f commit 66a6a04
Show file tree
Hide file tree
Showing 9 changed files with 330 additions and 3 deletions.
9 changes: 9 additions & 0 deletions pkg/clinical/application/common/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ const (

// MRITerminologySystem is the terminology code used to represent MRI scan of the breast
MRITerminologySystem = "168651"

// LeftBreastUltrasoundTerminologySystem is the terminology code used to represent left breast ultrasound scan
LeftBreastUltrasoundTerminologySystem = "161289"

// RightBreastUltrasoundTerminologySystem is the terminology code used to represent right breast scan
RightBreastUltrasoundTerminologySystem = "161290"

// BilateralConceptTerminologySystem is the terminology code used to represent miscellaneous bilateral concepts
BilateralConceptTerminologySystem = "160406"
)

// DefaultIdentifier assigns a patient a code to function as their
Expand Down
10 changes: 9 additions & 1 deletion pkg/clinical/domain/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package domain
import (
"time"

"github.com/go-playground/validator"
"github.com/savannahghi/scalarutils"
)

Expand All @@ -11,11 +12,18 @@ type FHIRMetaInput struct {
VersionID string `json:"versionId,omitempty"`
LastUpdated time.Time `json:"lastUpdated,omitempty"`
Source string `json:"source,omitempty"`
Tag []FHIRCodingInput `json:"tag,omitempty"`
Tag []FHIRCodingInput `json:"tag,omitempty" validate:"required"`
Security []FHIRCodingInput `json:"security,omitempty"`
Profile []scalarutils.URI `json:"profile,omitempty"`
}

func (m FHIRMetaInput) Validate() error {
v := validator.New()
err := v.Struct(m)

return err
}

// FHIRMeta is a set of metadata that provides technical and workflow context to a resource.
type FHIRMeta struct {
VersionID string `json:"versionId,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions pkg/clinical/presentation/graph/clinical.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ extend type Mutation {
recordMammographyResult(input: DiagnosticReportInput!): DiagnosticReport!
recordBiopsy(input: DiagnosticReportInput!): DiagnosticReport!
recordMRI(input: DiagnosticReportInput!): DiagnosticReport!
recordUltrasound(input: DiagnosticReportInput!): DiagnosticReport!

getEncounterAssociatedResources(encounterID: String!): EncounterAssociatedResources!
}
5 changes: 5 additions & 0 deletions pkg/clinical/presentation/graph/clinical.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

110 changes: 110 additions & 0 deletions pkg/clinical/presentation/graph/generated/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions pkg/clinical/usecases/clinical/diagnostic_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,28 @@ func (c *UseCasesClinicalImpl) RecordMRI(ctx context.Context, input dto.Diagnost
return c.RecordDiagnosticReport(ctx, common.MRITerminologySystem, input, observationOutput, []DiagnosticReportMutatorFunc{addNuclearMagneticResonanceCategory})
}

// RecordUltrasound is used to record the breast ultrasound diagnostic reports
func (c *UseCasesClinicalImpl) RecordUltrasound(ctx context.Context, input dto.DiagnosticReportInput) (*dto.DiagnosticReport, error) {
err := input.Validate()
if err != nil {
return nil, err
}

observationInput := &dto.ObservationInput{
Status: dto.ObservationStatusFinal,
EncounterID: input.EncounterID,
Value: input.Findings,
}

observationOutput, err := c.RecordObservation(ctx, *observationInput, common.BilateralConceptTerminologySystem, []ObservationInputMutatorFunc{addImagingCategory})
if err != nil {
return nil, err
}

// TODO: `BilateralConceptTerminologySystem` is a `PLACE HOLDER`. It should be adjusted accordingly when the breast cancer designs are revamped
return c.RecordDiagnosticReport(ctx, common.BilateralConceptTerminologySystem, input, observationOutput, []DiagnosticReportMutatorFunc{addRadiologyUltrasoundCategory})
}

// RecordDiagnosticReport is a re-usable method to help with diagnostic report recording
func (c *UseCasesClinicalImpl) RecordDiagnosticReport(ctx context.Context, conceptID string, input dto.DiagnosticReportInput, observation *dto.Observation, mutators []DiagnosticReportMutatorFunc) (*dto.DiagnosticReport, error) {
observationsReference := fmt.Sprintf("Observation/%s", observation.ID)
Expand Down
20 changes: 20 additions & 0 deletions pkg/clinical/usecases/clinical/diagnostic_report_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,23 @@ var addNuclearMagneticResonanceCategory = func(ctx context.Context, diagnosticRe

return nil
}

// addRadiologyUltrasoundCategory is used to add radiology ultrasound category
var addRadiologyUltrasoundCategory = func(ctx context.Context, diagnosticReport *domain.FHIRDiagnosticReportInput) error {
category := []*domain.FHIRCodeableConceptInput{
{
Coding: []*domain.FHIRCodingInput{
{
System: (*scalarutils.URI)(&diagnosticReportCategorySystem),
Code: scalarutils.Code("RUS"),
Display: "Radiology Ultrasound",
},
},
Text: "Radiology Ultrasound",
},
}

diagnosticReport.Category = append(diagnosticReport.Category, category...)

return nil
}
Loading

0 comments on commit 66a6a04

Please sign in to comment.