Skip to content

Commit

Permalink
Merge pull request #545 from rcpch/update-kpi
Browse files Browse the repository at this point in the history
Updating KPIs as per E12 + misc issue cleaning
  • Loading branch information
eatyourpeas authored Aug 4, 2023
2 parents 46cb6ae + de7f191 commit 59e18e6
Show file tree
Hide file tree
Showing 33 changed files with 609 additions and 383 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def score_kpi_1(registration_instance) -> int:
Calculation Method
Numerator = Number of children and young people [diagnosed with epilepsy] at first year AND (who had [input from a paediatrician with expertise in epilepsy] OR a [input from a paediatric neurologist] within 2 weeks of initial referral. (initial referral to mean first paediatric assessment)
Numerator = Number of children and young people [diagnosed with epilepsy] at first year AND (who had [input from a paediatrician with expertise in epilepsy] OR a [input from a paediatric neurologist] within 2 weeks of initial referral. (initial referral to mean first paediatric assessment)
Denominator = Number of and young people [diagnosed with epilepsy] at first year
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@

def score_kpi_10(registration_instance, age_at_first_paediatric_assessment) -> int:
"""10. school_individual_healthcare_plan
Percentage of children and young people with epilepsy aged 5 years and above with evidence of a school individual healthcare plan by 1 year after first paediatric assessment.
Calculation Method
Numerator = Number of children and young people aged 5 years and above diagnosed with epilepsy at first year AND with evidence of EHCP
Denominator =Number of children and young people aged 5 years and above diagnosed with epilepsy at first year
"""

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# python imports
from dateutil.relativedelta import relativedelta

# django imports

Expand All @@ -12,9 +13,9 @@ def score_kpi_2(registration_instance) -> int:
% of children and young people with epilepsy, with input by epilepsy specialist nurse within the first year of care
Calculation Method
Numerator= Number of children and young people [diagnosed with epilepsy] AND who had [input from or referral to an Epilepsy Specialist Nurse] by first year
Numerator= Number of children and young people [diagnosed with epilepsy] AND who had input from an Epilepsy Specialist Nurse by first year
Denominator = Number of children and young people [diagnosed with epilepsy] at first year
"""

Expand All @@ -33,14 +34,11 @@ def score_kpi_2(registration_instance) -> int:
return KPI_SCORE["NOT_SCORED"]

# score check
has_seen_nurse_before_close_date = (
assessment.epilepsy_specialist_nurse_input_date
<= registration_instance.registration_close_date
or assessment.epilepsy_specialist_nurse_referral_date
<= registration_instance.registration_close_date
has_seen_nurse_within_1_yr_registration = (
assessment.epilepsy_specialist_nurse_input_date <= registration_instance.registration_date + relativedelta(years=1)
)

if has_seen_nurse_before_close_date:
if has_seen_nurse_within_1_yr_registration:
return KPI_SCORE["PASS"]
else:
return KPI_SCORE["FAIL"]
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# python imports
from datetime import date

# django imports
from django.contrib.gis.db.models import Q
Expand All @@ -14,7 +15,7 @@ def score_kpi_3(registration_instance, age_at_first_paediatric_assessment) -> in
Calculation Method
Numerator = Number of children ([less than 3 years old at first assessment] AND [diagnosed with epilepsy] OR (number of children and young people diagnosed with epilepsy who had [3 or more maintenance AEDS] at first year) OR (Number of children less than 4 years old at first assessment with epilepsy AND myoclonic seizures) OR (number of children and young people diagnosed with epilepsy who met [CESS criteria] ) AND had [evidence of referral or involvement of a paediatric neurologist] OR [evidence of referral or involvement of CESS]
Numerator = Number of children ([less than 3 years old at first assessment] AND [diagnosed with epilepsy] OR (number of children and young people diagnosed with epilepsy who had [3 or more maintenance AEDS] at first year) OR (Number of children less than 4 years old at first assessment with epilepsy AND myoclonic seizures) OR (number of children and young people diagnosed with epilepsy who met [CESS criteria] ) AND had [evidence of involvement of a paediatric neurologist] OR [evidence of referral or involvement of CESS]
Denominator = Number of children [less than 3 years old at first assessment] AND [diagnosed with epilepsy] OR (number of children and young people diagnosed with epilepsy who had [3 or more maintenance AEDS] at first year )OR (number of children and young people diagnosed with epilepsy who met [CESS criteria] OR (Number of children less than 4 years old at first assessment with epilepsy AND [myoclonic seizures])
"""
Expand Down Expand Up @@ -52,22 +53,20 @@ def score_kpi_3(registration_instance, age_at_first_paediatric_assessment) -> in
if not any(eligibility_criteria):
return KPI_SCORE["INELIGIBLE"]

# Eligible for measure - EVALUATE IF AT LEAST REFERRED FROM NEUROLOGIST OR CESS. NOTE: technically the Assessment model allows a referral_date & input_date filled WITHOUT referral_made, but this is a rare edge case just for API-use. The UI does not allow you to enter either date, if referral_made is False. If the API has an endpoint for this measure, need to ensure referral_made==True, if dates are both valid.

# first evaluate relevant fields complete
tertiary_input_complete = (
assessment.paediatric_neurologist_referral_made is not None
tertiary_input_answered = (
assessment.paediatric_neurologist_input_date is not None
) or (assessment.childrens_epilepsy_surgical_service_referral_made is not None)

if not tertiary_input_complete:
if not tertiary_input_answered:
return KPI_SCORE["NOT_SCORED"]

pass_criteria = [
(assessment.paediatric_neurologist_referral_made is True),
(isinstance(assessment.paediatric_neurologist_input_date, date)),
(assessment.childrens_epilepsy_surgical_service_referral_made is True),
]

# if referral made to either neurologist or CESS, they pass
# if input neurologist or referral CESS, they pass
if any(pass_criteria):
return KPI_SCORE["PASS"]
else:
Expand All @@ -80,9 +79,10 @@ def score_kpi_3b(registration_instance) -> int:
% of ongoing children and young people meeting defined epilepsy surgery referral criteria with evidence of epilepsy surgery referral
Calculation Method
Numerator = Number of children and young people diagnosed with epilepsy AND met [CESS criteria] at first year AND had [evidence of referral or involvement of CESS]
Calculation Method
Numerator = Number of children and young people diagnosed with epilepsy AND met [CESS criteria] at first year AND had [evidence of referral of CESS]
Denominator = Number of children and young people diagnosed with epilepsy AND met CESS criteria at first year
Denominator =Number of children and young people diagnosed with epilepsy AND met CESS criteria at first year
"""

assessment = registration_instance.assessment
Expand All @@ -105,7 +105,7 @@ def score_kpi_3b(registration_instance) -> int:
# score KPI
if (
assessment.childrens_epilepsy_surgical_service_referral_made
or assessment.paediatric_neurologist_referral_made
or assessment.paediatric_neurologist_input_date
):
return KPI_SCORE["PASS"]
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ def score_kpi_4(registration_instance) -> int:
% of children and young people with convulsive seizures and epilepsy, with an ECG at first year
Calculation Method
Numerator = Number of children and young people diagnosed with epilepsy at first year AND with convulsive episodes at first year AND who have [12 lead ECG obtained]
Denominator = Number of children and young people diagnosed with epilepsy at first year AND with convulsive episodes at first year
"""
epilepsy_context = registration_instance.epilepsycontext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def score_kpi_5(registration_instance, age_at_first_paediatric_assessment) -> in
Calculation Method
Numerator = Number of children and young people diagnosed with epilepsy at first year AND who are NOT JME or JAE or CAE or CECTS/Rolandic OR number of children aged under 2 years at first assessment with a diagnosis of epilepsy at first year AND who had an MRI within 6 weeks of request
Denominator = Number of children and young people diagnosed with epilepsy at first year AND ((who are NOT JME or JAE or CAE or BECTS) OR (number of children aged under 2 years at first assessment with a diagnosis of epilepsy at first year))
Denominator = Number of children and young people diagnosed with epilepsy at first year AND ((who are NOT JME or JAE or CAE or BECTS) OR (number of children aged under 2 years at first assessment with a diagnosis of epilepsy at first year))
"""
multiaxial_diagnosis = registration_instance.multiaxialdiagnosis
investigations = registration_instance.investigations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,27 @@
# E12 imports
from epilepsy12.constants import KPI_SCORE


def score_kpi_6(registration_instance, age_at_first_paediatric_assessment) -> int:
"""6. assessment_of_mental_health_issues
Calculation Method
Numerator = Number of children and young people over 5 years diagnosed with epilepsy AND who had documented evidence of enquiry or screening for their mental health
Denominator = = Number of children and young people over 5 years diagnosed with epilepsy
denominator"""
"""

multiaxial_diagnosis = registration_instance.multiaxialdiagnosis

# ineligible
if age_at_first_paediatric_assessment < 5:
return KPI_SCORE["INELIGIBLE"]

# not scored
if multiaxial_diagnosis.mental_health_screen is None:
return KPI_SCORE["NOT_SCORED"]


# score kpi
if multiaxial_diagnosis.mental_health_screen:
return KPI_SCORE["PASS"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ def score_kpi_7(registration_instance) -> int:
Percentage of children with epilepsy and a mental health problem who have evidence of mental health support
Calculation Method
Numerator = Number of children and young people diagnosed with epilepsy AND had a mental health issue identified AND had evidence of mental health support received
Denominator= Number of children and young people diagnosed with epilepsy AND had a mental health issue identified
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ def score_kpi_8(registration_instance, age_at_first_paediatric_assessment) -> in
Percentage of all females 12 years and above currently on valproate treatment with annual risk acknowledgement form completed
Calculation Method
Numerator = Number of females aged 12 and above diagnosed with epilepsy at first year AND on valproate AND annual risk acknowledgement forms completed AND pregnancy prevention programme in place
Numerator = Number of females aged 12 and above diagnosed with epilepsy at first year AND on valproate AND
(
annual risk acknowledgement forms completed
OR
pregnancy prevention programme in place
)
Denominator = Number of females aged 12 and above diagnosed with epilepsy at first year AND on valproate
"""
# ineligible - < 12yo or male
Expand All @@ -43,10 +48,15 @@ def score_kpi_8(registration_instance, age_at_first_paediatric_assessment) -> in
medicine_name="Sodium valproate"
).first(),
).first()

# not scored
if (valproate.is_a_pregnancy_prevention_programme_needed is None
or valproate.has_a_valproate_annual_risk_acknowledgement_form_been_completed is None):
return KPI_SCORE['NOT_SCORED']

if (
valproate.is_a_pregnancy_prevention_programme_needed
and valproate.has_a_valproate_annual_risk_acknowledgement_form_been_completed
or valproate.has_a_valproate_annual_risk_acknowledgement_form_been_completed
):
return KPI_SCORE["PASS"]
else:
Expand Down
Loading

0 comments on commit 59e18e6

Please sign in to comment.