Skip to content

Commit

Permalink
feat: add record MRI api
Browse files Browse the repository at this point in the history
  • Loading branch information
allansifuna committed Feb 13, 2024
1 parent 2fcb2b2 commit 115e262
Show file tree
Hide file tree
Showing 8 changed files with 311 additions and 4 deletions.
3 changes: 3 additions & 0 deletions pkg/clinical/application/common/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ const (

// BiopsyTerminologySystem is the terminology code used to represent Biopsy of cervix.
BiopsyTerminologySystem = "161826"

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

// DefaultIdentifier assigns a patient a code to function as their
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 @@ -219,4 +219,5 @@ extend type Mutation {
# Diagnostic Report
recordMammographyResult(input: DiagnosticReportInput!): DiagnosticReport!
recordBiopsy(input: DiagnosticReportInput!): DiagnosticReport!
recordMRI(input: DiagnosticReportInput!): DiagnosticReport!
}
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.

25 changes: 23 additions & 2 deletions pkg/clinical/usecases/clinical/diagnostic_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (c *UseCasesClinicalImpl) RecordMammographyResult(ctx context.Context, inpu
return c.RecordDiagnosticReport(ctx, common.MammogramTerminologyCode, input, observationOutput, nil)
}

// RecordBiopsy is used to record biopsy test results as observations
// RecordBiopsy is used to record biopsy test results as a diagnostic report
// FHIR recommends use of diagnostic resource to record the findings and interpretation of biopsy test results
// performed on patients, groups of patients, devices, and locations, and/or specimens.
func (c *UseCasesClinicalImpl) RecordBiopsy(ctx context.Context, input dto.DiagnosticReportInput) (*dto.DiagnosticReport, error) {
Expand All @@ -55,7 +55,28 @@ func (c *UseCasesClinicalImpl) RecordBiopsy(ctx context.Context, input dto.Diagn
return nil, err
}

return c.RecordDiagnosticReport(ctx, common.BiopsyTerminologySystem, input, observationOutput, []DiagnosticReportMutatorFunc{addCytologyCategory})
return c.RecordDiagnosticReport(ctx, common.BiopsyTerminologySystem, input, observationOutput, []DiagnosticReportMutatorFunc{addCytopathologyCategory})
}

// RecordMRI is used to record MRI scan results as a diagnostic report
func (c *UseCasesClinicalImpl) RecordMRI(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.MRITerminologySystem, []ObservationInputMutatorFunc{addProcedureCategory})
if err != nil {
return nil, err
}

return c.RecordDiagnosticReport(ctx, common.MRITerminologySystem, input, observationOutput, []DiagnosticReportMutatorFunc{addNuclearMagneticResonanceCategory})
}

// RecordDiagnosticReport is a re-usable method to help with diagnostic report recording
Expand Down
24 changes: 22 additions & 2 deletions pkg/clinical/usecases/clinical/diagnostic_report_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
// with the aapropriate data to suit its use case.
type DiagnosticReportMutatorFunc func(context.Context, *domain.FHIRDiagnosticReportInput) error

// addProcedureCategory is used to add procedure category for various observations records such as biopsy etc.
var addCytologyCategory = func(ctx context.Context, diagnosticReport *domain.FHIRDiagnosticReportInput) error {
// addCytopathologyCategory is used to add a cytopathology category for various diagnostic reports such as biopsy etc.
var addCytopathologyCategory = func(ctx context.Context, diagnosticReport *domain.FHIRDiagnosticReportInput) error {
category := []*domain.FHIRCodeableConceptInput{
{
Coding: []*domain.FHIRCodingInput{
Expand All @@ -30,3 +30,23 @@ var addCytologyCategory = func(ctx context.Context, diagnosticReport *domain.FHI

return nil
}

// addNuclearMagneticResonanceCategory is used to add a nuclear magnetic resonance category for diagnostic report such as MRI reports etc.
var addNuclearMagneticResonanceCategory = func(ctx context.Context, diagnosticReport *domain.FHIRDiagnosticReportInput) error {
category := []*domain.FHIRCodeableConceptInput{
{
Coding: []*domain.FHIRCodingInput{
{
System: (*scalarutils.URI)(&diagnosticReportCategorySystem),
Code: scalarutils.Code("NMR"),
Display: "Nuclear Magnetic Resonance",
},
},
Text: "Nuclear Magnetic Resonance",
},
}

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

return nil
}

0 comments on commit 115e262

Please sign in to comment.