Skip to content

Commit

Permalink
chore: add 'Not At Risk' as part of cervical cancer stratification
Browse files Browse the repository at this point in the history
  • Loading branch information
Salaton committed Apr 4, 2024
1 parent 1709d24 commit a451484
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 16 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 @@ -161,6 +161,9 @@ const (
// LowRiskCIELCode represents the CIEL code for a low-risk condition
LowRiskCIELCode = "166675"

// NoRiskFactorsCIELCode represents the CIEL code for no known risk factors
NoRiskFactorsCIELCode = "1064"

// CIELTerminologySystem is the identity of CIEL terminology system
CIELTerminologySystem = "https://CIELterminology.org"

Expand Down
72 changes: 56 additions & 16 deletions pkg/clinical/usecases/clinical/questionnaire_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/mitchellh/mapstructure"
"github.com/savannahghi/clinical/pkg/clinical/application/common"
"github.com/savannahghi/clinical/pkg/clinical/application/dto"
"github.com/savannahghi/clinical/pkg/clinical/application/utils"
"github.com/savannahghi/clinical/pkg/clinical/domain"
"github.com/savannahghi/scalarutils"
)
Expand Down Expand Up @@ -122,44 +123,50 @@ func (u *UseCasesClinicalImpl) generateQuestionnaireReviewSummary(

switch {
case totalScore >= 2:
riskLevel, err = u.recordRiskAssessment(
riskLevel, err = u.recordAssessmentAndSegmentPatient(
ctx,
*patient.Resource.ID,
encounter,
questionnaireResponseID,
common.HighRiskCIELCode,
"High Risk",
domain.CervicalCancerScreeningTypeEnum.Text(), // TODO: This is TEMPORARY. A follow up PR is to follow supplying the value from params
domain.CervicalCancerScreeningTypeEnum.Text(),
dto.SegmentationCategoryHighRiskNegative,
)
if err != nil {
utils.ReportErrorToSentry(err)
return "", err
}

err := u.infrastructure.Pubsub.NotifySegmentation(ctx, dto.SegmentationPayload{
ClinicalID: *patient.Resource.ID,
SegmentLabel: dto.SegmentationCategoryHighRiskNegative,
})
if err != nil {
return "", err
}

case totalScore < 2:
riskLevel, err = u.recordRiskAssessment(
case totalScore == 1:
riskLevel, err = u.recordAssessmentAndSegmentPatient(
ctx,
*patient.Resource.ID,
encounter,
questionnaireResponseID,
common.LowRiskCIELCode,
"Low Risk",
domain.CervicalCancerScreeningTypeEnum.Text(),
dto.SegmentationCategoryLowRisk,
)
if err != nil {
utils.ReportErrorToSentry(err)
return "", err
}

err := u.infrastructure.Pubsub.NotifySegmentation(ctx, dto.SegmentationPayload{
ClinicalID: *patient.Resource.ID,
SegmentLabel: dto.SegmentationCategoryLowRisk,
})
case totalScore == 0:
riskLevel, err = u.recordAssessmentAndSegmentPatient(
ctx,
*patient.Resource.ID,
encounter,
questionnaireResponseID,
common.NoRiskFactorsCIELCode,
"Not At Risk",
domain.CervicalCancerScreeningTypeEnum.Text(),
dto.SegmentationCategoryNoRisk,
)
if err != nil {
utils.ReportErrorToSentry(err)
return "", err
}
}
Expand Down Expand Up @@ -286,6 +293,39 @@ func mapLinkIdsToOrdinalValuesAndDisplay(items []*domain.FHIRQuestionnaireItem)
return ordinalValues
}

// recordAssessmentAndSegmentPatient records a cancer screening risk assessment for a patient,
// then segments the patient for targeted engagement based on the assessment's risk level.
func (u *UseCasesClinicalImpl) recordAssessmentAndSegmentPatient(
ctx context.Context,
patientID string,
encounter *domain.FHIREncounterRelayPayload,
questionnaireResponseID, outcomeCode string,
outcomeDisplay, usageContext string,
segmentLabel dto.SegmentationCategory,
) (string, error) {
riskLevel, err := u.recordRiskAssessment(
ctx,
encounter,
questionnaireResponseID,
outcomeCode,
outcomeDisplay,
usageContext,
)
if err != nil {
return "", err
}

err = u.infrastructure.Pubsub.NotifySegmentation(ctx, dto.SegmentationPayload{
ClinicalID: patientID,
SegmentLabel: segmentLabel,
})
if err != nil {
return "", err
}

return riskLevel, nil
}

func (u *UseCasesClinicalImpl) recordRiskAssessment(
ctx context.Context,
encounter *domain.FHIREncounterRelayPayload,
Expand Down

0 comments on commit a451484

Please sign in to comment.