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 f6b4274
Show file tree
Hide file tree
Showing 12 changed files with 321 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/staging_multitenant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ env:
jobs:
deploy_to_multitenant_staging:
name: Deploy multitenant staging server to google kubernetes engine
if: ${{ github.ref == 'refs/heads/develop-v2'}}
if: ${{ github.ref == 'refs/heads/record-ultrasound'}}
strategy:
matrix:
environment: [multitenant-staging, sil-uat]
Expand Down
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
2 changes: 1 addition & 1 deletion pkg/clinical/domain/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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"`
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/clinical/domain/patient.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ type FHIRPatientInput struct {
Link []*FHIRPatientLinkInput `json:"link,omitempty"`

// Meta stores more information about the resource
Meta FHIRMetaInput `json:"meta,omitempty"`
Meta *FHIRMetaInput `json:"meta,omitempty"`

// Extension is an optional element that provides additional information not captured in the basic resource definition
Extension []*FHIRExtension `json:"extension,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 f6b4274

Please sign in to comment.