Skip to content

Commit

Permalink
Merge pull request #50 from rcpch/age-strings-rephrase
Browse files Browse the repository at this point in the history
Age-strings-rephrase
  • Loading branch information
eatyourpeas authored Nov 14, 2024
2 parents 3cb7f41 + e75f1cf commit ddefc14
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
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.7
current_version = 4.2.8
tag = False
commit = True

Expand Down
16 changes: 12 additions & 4 deletions rcpchgrowth/age_advice_strings.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from rcpchgrowth.constants import CDC

def comment_prematurity_correction(
chronological_decimal_age: float,
corrected_decimal_age: float,
gestation_weeks: int,
gestation_days: int):
gestation_days: int,
reference: str):
"""
Returns interpretations on age correction as a string
"""
Expand All @@ -14,17 +17,22 @@ def comment_prematurity_correction(
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 < 42 and reference == CDC:
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."
clinician_chronological_decimal_age_comment = f"Born at term ({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."
clinician_corrected_decimal_age_comment = f"Born at term ({gestation_weeks}+{gestation_days} weeks gestation). No correction for gestation has been made."
if gestation_weeks == 40 and gestation_days == 0:
lay_chronological_decimal_age_comment = "Your child was born at term. No correction for gestation has been made."
clinician_chronological_decimal_age_comment = "Born at term. No correction for gestation has been made."
lay_corrected_decimal_age_comment = "Your child was born at term. No correction for gestation has been made."
clinician_corrected_decimal_age_comment = "Born at term. 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
14 changes: 6 additions & 8 deletions rcpchgrowth/measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,6 @@ 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(
Expand All @@ -418,9 +414,10 @@ def __calculate_ages(
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 reference is CDC, we must treat >37 week infants as term and we also stop correcting for prematurity at 2 years of age
if self.reference == CDC:
if (self.corrected_decimal_age >= 2 and gestation_weeks < 37) or (gestation_weeks >= 37 and gestation_weeks <= 42):
self.corrected_decimal_age = self.chronological_decimal_age

if self.corrected_decimal_age is None:
self._age_comments = None
Expand All @@ -433,7 +430,8 @@ def __calculate_ages(
chronological_decimal_age=self.chronological_decimal_age,
corrected_decimal_age=self.corrected_decimal_age,
gestation_weeks=gestation_weeks,
gestation_days=gestation_days)
gestation_days=gestation_days,
reference=self.reference)
except:
self.age_comments = None
corrected_decimal_age_error = "Error in comment on prematurity."
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.7",
version="4.2.8",
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

0 comments on commit ddefc14

Please sign in to comment.