Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't-correct-cdc-term #49

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 4.2.6
current_version = 4.2.7
tag = False
commit = True

Expand Down
14 changes: 13 additions & 1 deletion rcpchgrowth/age_advice_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,23 @@ def comment_prematurity_correction(
"""

if chronological_decimal_age == corrected_decimal_age:
# no adjustment has been made so the child was born at 40 weeks
# no adjustment has been made so the child was born at 40 weeks or this child is being plotted on the CDC reference, where no adjustment is made for 37-42 weeks or beyond the age of 2 years
lay_corrected_decimal_age_comment = "Your child was born on their due date."
clinician_corrected_decimal_age_comment = "Born at term. No correction has been made for gestation."
lay_chronological_decimal_age_comment = "Your child was born on their due date."
clinician_chronological_decimal_age_comment = "Born Term. No correction has been made for gestation."
# These fields should only apply to CDC reference, since UK-WHO corrects for all gestations (and therefore corrected_decimal_age will never be equal to chronological_decimal_age if gestation_weeks is not 40)
if gestation_weeks < 42:
if gestation_weeks < 37:
lay_chronological_decimal_age_comment = f"Your child was born at {gestation_weeks}+{gestation_days} weeks gestation. No correction is made for this beyond 2 years of age."
clinician_chronological_decimal_age_comment =f"Born preterm at {gestation_weeks}+{gestation_days} weeks gestation. No correction is made for this beyond 2 years of age."
lay_corrected_decimal_age_comment = f"Your child was born at {gestation_weeks}+{gestation_days} weeks gestation. No correction is made for this beyond 2 years of age."
clinician_corrected_decimal_age_comment = f"Born preterm at {gestation_weeks}+{gestation_days} weeks gestation. No correction is made for this beyond 2 years of age."
else:
lay_chronological_decimal_age_comment = f"Your child was born at {gestation_weeks}+{gestation_days} weeks gestation. This is considered term and no correction for gestation has been made."
clinician_chronological_decimal_age_comment = f"Born at term at {gestation_weeks}+{gestation_days} weeks gestation. No correction for gestation has been made."
lay_corrected_decimal_age_comment = f"Your child was born at {gestation_weeks}+{gestation_days} weeks gestation. This is considered term and no correction for gestation has been made."
clinician_corrected_decimal_age_comment = f"Born at term at {gestation_weeks}+{gestation_days} weeks gestation. No correction for gestation has been made."
elif chronological_decimal_age > corrected_decimal_age or chronological_decimal_age < corrected_decimal_age:
## adjustment for gestational age has been made - even if >=37 weeks
lay_corrected_decimal_age_comment = f"Because your child was born at {gestation_weeks}+{gestation_days} weeks gestation an adjustment has been made to take this into account."
Expand Down
9 changes: 9 additions & 0 deletions rcpchgrowth/measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ def __calculate_ages(
gestation_weeks = 40
# calculate ages from dates and gestational ages at birth

# if reference is CDC, we must treat >37 week infants as term.
if self.reference == CDC and gestation_weeks >= 37:
gestation_weeks = 40
gestation_days = 0

try:
self.corrected_decimal_age = corrected_decimal_age(
birth_date=birth_date,
Expand All @@ -412,6 +417,10 @@ def __calculate_ages(
except Exception as err:
self.chronological_decimal_age = None
chronological_decimal_age_error = f"{err}"

# if the reference is CDC, we also stop correcting for prematurity at 2 years of age
if self.reference == CDC and self.corrected_decimal_age >= 2:
self.corrected_decimal_age = self.chronological_decimal_age

if self.corrected_decimal_age is None:
self._age_comments = None
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name="rcpchgrowth",
version="4.2.6",
version="4.2.7",
description="SDS and Centile calculations for UK Growth Data",
long_description=long_description,
url="https://github.com/rcpch/digital-growth-charts/blob/master/README.md",
Expand Down
Loading