From 600a95fcf05d2ebda3e2c4dfabfa065322ff0f82 Mon Sep 17 00:00:00 2001 From: Andy Mitchell <326561+Themitchell@users.noreply.github.com> Date: Thu, 28 Aug 2025 10:43:25 +0100 Subject: [PATCH 1/7] Initial BMI and Age calculations for PLCO --- .python-version | 1 + docker-compose.yml | 1 + .../calculators/__init__.py | 0 lung_cancer_screening/calculators/plco.py | 19 +++++++++ .../calculators/tests/__init__.py | 0 .../calculators/tests/test_plco.py | 41 +++++++++++++++++++ lung_cancer_screening/settings.py | 1 + 7 files changed, 63 insertions(+) create mode 100644 .python-version rename tests/.gitkeep => lung_cancer_screening/calculators/__init__.py (100%) create mode 100644 lung_cancer_screening/calculators/plco.py create mode 100644 lung_cancer_screening/calculators/tests/__init__.py create mode 100644 lung_cancer_screening/calculators/tests/test_plco.py diff --git a/.python-version b/.python-version new file mode 100644 index 00000000..c10780c6 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.13.1 diff --git a/docker-compose.yml b/docker-compose.yml index b9f5a375..c437bbb9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,6 +17,7 @@ services: - ./lung_cancer_screening:/app/lung_cancer_screening restart: unless-stopped + asset_builder: build: context: . diff --git a/tests/.gitkeep b/lung_cancer_screening/calculators/__init__.py similarity index 100% rename from tests/.gitkeep rename to lung_cancer_screening/calculators/__init__.py diff --git a/lung_cancer_screening/calculators/plco.py b/lung_cancer_screening/calculators/plco.py new file mode 100644 index 00000000..7804fd9a --- /dev/null +++ b/lung_cancer_screening/calculators/plco.py @@ -0,0 +1,19 @@ +from decimal import Decimal, getcontext + +getcontext().prec = 999999 + +class Plco: + AGE_COEFFICIENT = Decimal('0.0778868') + AGE_CENTRED_OR_REFERENT_REF_GROUP = Decimal('62') + BMI_COEFFICIENT = Decimal('-0.0274194') + BMI_CENTRED_OR_REFERENT_REF_GROUP = Decimal('27') + + def __init__(self, age=None, bmi=None): + self.age = Decimal(str(age or 0)) + self.bmi = Decimal(str(bmi or 0)) + + def age_in_years_contribution_to_estimate(self): + return (self.age - self.AGE_CENTRED_OR_REFERENT_REF_GROUP) * self.AGE_COEFFICIENT + + def bmi_contribution_to_estimate(self): + return (self.bmi - self.BMI_CENTRED_OR_REFERENT_REF_GROUP) * self.BMI_COEFFICIENT diff --git a/lung_cancer_screening/calculators/tests/__init__.py b/lung_cancer_screening/calculators/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lung_cancer_screening/calculators/tests/test_plco.py b/lung_cancer_screening/calculators/tests/test_plco.py new file mode 100644 index 00000000..cfb2e9ff --- /dev/null +++ b/lung_cancer_screening/calculators/tests/test_plco.py @@ -0,0 +1,41 @@ +from django.test import TestCase +from decimal import Decimal + +from lung_cancer_screening.calculators.plco import Plco + +class TestPlco(TestCase): + def test_age_in_years_contribution_to_estimate_when_age_is_none(self): + calculator = Plco(age=None) + result = calculator.age_in_years_contribution_to_estimate() + + self.assertEqual(result, Decimal('-4.8289816')) + + def test_age_in_years_contribution_to_estimate_at_74(self): + calculator = Plco(age=74) + result = calculator.age_in_years_contribution_to_estimate() + + self.assertEqual(result, Decimal('0.9346416')) + + def test_age_in_years_contribution_to_estimate_at_62(self): + calculator = Plco(age=58) + result = calculator.age_in_years_contribution_to_estimate() + + self.assertEqual(result, Decimal('-0.3115472')) + + def test_bmi_contribution_to_estimate_when_bmi_is_none(self): + calculator = Plco(bmi=None) + result = calculator.bmi_contribution_to_estimate() + + self.assertEqual(result, Decimal('0.7403238')) + + def test_bmi_contribution_to_estimate_when_bmi_is_23_point_5(self): + calculator = Plco(bmi=23.5) + result = calculator.bmi_contribution_to_estimate() + + self.assertEqual(result, Decimal('0.0959679')) + + def test_bmi_contribution_to_estimate_when_bmi_is_a_long_decimal(self): + calculator = Plco(bmi="26.4749212") + result = calculator.bmi_contribution_to_estimate() + + self.assertEqual(result, Decimal('0.01439734564872')) diff --git a/lung_cancer_screening/settings.py b/lung_cancer_screening/settings.py index a153d970..14cff180 100644 --- a/lung_cancer_screening/settings.py +++ b/lung_cancer_screening/settings.py @@ -48,6 +48,7 @@ def boolean_env(key, default=None): 'django.contrib.staticfiles', 'lung_cancer_screening.core', 'lung_cancer_screening.questions' + 'lung_cancer_screening.calculators', ] MIDDLEWARE = [ From 9655600b4d15ca72c4c34fbcf476ddcffa652ff7 Mon Sep 17 00:00:00 2001 From: Andy Mitchell <326561+Themitchell@users.noreply.github.com> Date: Thu, 28 Aug 2025 11:18:52 +0100 Subject: [PATCH 2/7] Add copd_enphysema_or_bronchitis to PLCO calculator --- lung_cancer_screening/calculators/plco.py | 14 +++++++++++- .../calculators/tests/test_plco.py | 22 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/lung_cancer_screening/calculators/plco.py b/lung_cancer_screening/calculators/plco.py index 7804fd9a..7e1ab062 100644 --- a/lung_cancer_screening/calculators/plco.py +++ b/lung_cancer_screening/calculators/plco.py @@ -7,13 +7,25 @@ class Plco: AGE_CENTRED_OR_REFERENT_REF_GROUP = Decimal('62') BMI_COEFFICIENT = Decimal('-0.0274194') BMI_CENTRED_OR_REFERENT_REF_GROUP = Decimal('27') + COPD_ENPHYSEMA_OR_CHRONIC_BRONCHITIS_COEFFICIENT = Decimal('0.3553063') - def __init__(self, age=None, bmi=None): + def __init__(self, age=None, bmi=None, copd_enphysema_or_chronic_bronchitis=None): self.age = Decimal(str(age or 0)) self.bmi = Decimal(str(bmi or 0)) + self.copd_enphysema_or_chronic_bronchitis = copd_enphysema_or_chronic_bronchitis def age_in_years_contribution_to_estimate(self): return (self.age - self.AGE_CENTRED_OR_REFERENT_REF_GROUP) * self.AGE_COEFFICIENT def bmi_contribution_to_estimate(self): return (self.bmi - self.BMI_CENTRED_OR_REFERENT_REF_GROUP) * self.BMI_COEFFICIENT + + def copd_enphysema_or_chronic_bronchitis_contribution_to_estimate(self): + if self.copd_enphysema_or_chronic_bronchitis is None: + raise self.InvalidValueError( + "copd_enphysema_or_chronic_bronchitis must be true or false") + + return self.copd_enphysema_or_chronic_bronchitis * self.COPD_ENPHYSEMA_OR_CHRONIC_BRONCHITIS_COEFFICIENT + + class InvalidValueError(Exception): + pass diff --git a/lung_cancer_screening/calculators/tests/test_plco.py b/lung_cancer_screening/calculators/tests/test_plco.py index cfb2e9ff..62510599 100644 --- a/lung_cancer_screening/calculators/tests/test_plco.py +++ b/lung_cancer_screening/calculators/tests/test_plco.py @@ -39,3 +39,25 @@ def test_bmi_contribution_to_estimate_when_bmi_is_a_long_decimal(self): result = calculator.bmi_contribution_to_estimate() self.assertEqual(result, Decimal('0.01439734564872')) + + def test_copd_enphysema_or_chronic_bronchitiscontribution_to_estimate_when_none(self): + calculator = Plco(copd_enphysema_or_chronic_bronchitis=None) + + self.assertRaises( + Plco.InvalidValueError, + calculator.copd_enphysema_or_chronic_bronchitis_contribution_to_estimate + ) + + def test_copd_enphysema_or_chronic_bronchitiscontribution_to_estimate_when_true(self): + calculator = Plco(copd_enphysema_or_chronic_bronchitis=True) + + result = calculator.copd_enphysema_or_chronic_bronchitis_contribution_to_estimate() + + self.assertEqual(result, Decimal('0.3553063')) + + def test_copd_enphysema_or_chronic_bronchitiscontribution_to_estimate_when_false(self): + calculator = Plco(copd_enphysema_or_chronic_bronchitis=False) + + result = calculator.copd_enphysema_or_chronic_bronchitis_contribution_to_estimate() + + self.assertEqual(result, Decimal('0')) From 0fccc18b09193a563f727004c14a0f9b9eb127b7 Mon Sep 17 00:00:00 2001 From: Andy Mitchell <326561+Themitchell@users.noreply.github.com> Date: Thu, 28 Aug 2025 11:24:04 +0100 Subject: [PATCH 3/7] Add personal history of cancer to PLCO calculator --- lung_cancer_screening/calculators/plco.py | 12 +++++++++- .../calculators/tests/test_plco.py | 22 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/lung_cancer_screening/calculators/plco.py b/lung_cancer_screening/calculators/plco.py index 7e1ab062..babd1e6a 100644 --- a/lung_cancer_screening/calculators/plco.py +++ b/lung_cancer_screening/calculators/plco.py @@ -8,11 +8,13 @@ class Plco: BMI_COEFFICIENT = Decimal('-0.0274194') BMI_CENTRED_OR_REFERENT_REF_GROUP = Decimal('27') COPD_ENPHYSEMA_OR_CHRONIC_BRONCHITIS_COEFFICIENT = Decimal('0.3553063') + PERSONAL_HISTORY_OF_CANCER_COEFFICIENT = Decimal('0.4589971') - def __init__(self, age=None, bmi=None, copd_enphysema_or_chronic_bronchitis=None): + def __init__(self, age=None, bmi=None, copd_enphysema_or_chronic_bronchitis=None, personal_history_of_cancer=None): self.age = Decimal(str(age or 0)) self.bmi = Decimal(str(bmi or 0)) self.copd_enphysema_or_chronic_bronchitis = copd_enphysema_or_chronic_bronchitis + self.personal_history_of_cancer = personal_history_of_cancer def age_in_years_contribution_to_estimate(self): return (self.age - self.AGE_CENTRED_OR_REFERENT_REF_GROUP) * self.AGE_COEFFICIENT @@ -27,5 +29,13 @@ def copd_enphysema_or_chronic_bronchitis_contribution_to_estimate(self): return self.copd_enphysema_or_chronic_bronchitis * self.COPD_ENPHYSEMA_OR_CHRONIC_BRONCHITIS_COEFFICIENT + + def personal_history_of_cancer_contribution_to_estimate(self): + if self.personal_history_of_cancer is None: + raise self.InvalidValueError( + "personal_history_of_cancer must be true or false") + + return self.personal_history_of_cancer * self.PERSONAL_HISTORY_OF_CANCER_COEFFICIENT + class InvalidValueError(Exception): pass diff --git a/lung_cancer_screening/calculators/tests/test_plco.py b/lung_cancer_screening/calculators/tests/test_plco.py index 62510599..88a2ab28 100644 --- a/lung_cancer_screening/calculators/tests/test_plco.py +++ b/lung_cancer_screening/calculators/tests/test_plco.py @@ -61,3 +61,25 @@ def test_copd_enphysema_or_chronic_bronchitiscontribution_to_estimate_when_false result = calculator.copd_enphysema_or_chronic_bronchitis_contribution_to_estimate() self.assertEqual(result, Decimal('0')) + + def test_personal_history_of_cancer_contribution_to_estimate_when_none(self): + calculator = Plco(personal_history_of_cancer=None) + + self.assertRaises( + Plco.InvalidValueError, + calculator.personal_history_of_cancer_contribution_to_estimate + ) + + def test_personal_history_of_cancer_contribution_to_estimate_when_true(self): + calculator = Plco(personal_history_of_cancer=True) + + result = calculator.personal_history_of_cancer_contribution_to_estimate() + + self.assertEqual(result, Decimal('0.4589971')) + + def test_personal_history_of_cancer_contribution_to_estimate_when_false(self): + calculator = Plco(personal_history_of_cancer=False) + + result = calculator.personal_history_of_cancer_contribution_to_estimate() + + self.assertEqual(result, Decimal('0')) From 99695720b5f58649b5af7c28831d65b0b0769946 Mon Sep 17 00:00:00 2001 From: Andy Mitchell <326561+Themitchell@users.noreply.github.com> Date: Thu, 28 Aug 2025 11:34:57 +0100 Subject: [PATCH 4/7] Add family history of cancer to PLCO calculator --- lung_cancer_screening/calculators/plco.py | 15 +++++++++++- .../calculators/tests/test_plco.py | 23 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/lung_cancer_screening/calculators/plco.py b/lung_cancer_screening/calculators/plco.py index babd1e6a..6d45ab2e 100644 --- a/lung_cancer_screening/calculators/plco.py +++ b/lung_cancer_screening/calculators/plco.py @@ -9,12 +9,18 @@ class Plco: BMI_CENTRED_OR_REFERENT_REF_GROUP = Decimal('27') COPD_ENPHYSEMA_OR_CHRONIC_BRONCHITIS_COEFFICIENT = Decimal('0.3553063') PERSONAL_HISTORY_OF_CANCER_COEFFICIENT = Decimal('0.4589971') + FAMILY_HISTORY_OF_CANCER_COEFFICIENT = Decimal('0.587185') - def __init__(self, age=None, bmi=None, copd_enphysema_or_chronic_bronchitis=None, personal_history_of_cancer=None): + def __init__(self, + age=None, + bmi=None, + copd_enphysema_or_chronic_bronchitis=None, + personal_history_of_cancer=None, family_history_of_cancer=None): self.age = Decimal(str(age or 0)) self.bmi = Decimal(str(bmi or 0)) self.copd_enphysema_or_chronic_bronchitis = copd_enphysema_or_chronic_bronchitis self.personal_history_of_cancer = personal_history_of_cancer + self.family_history_of_cancer = family_history_of_cancer def age_in_years_contribution_to_estimate(self): return (self.age - self.AGE_CENTRED_OR_REFERENT_REF_GROUP) * self.AGE_COEFFICIENT @@ -37,5 +43,12 @@ def personal_history_of_cancer_contribution_to_estimate(self): return self.personal_history_of_cancer * self.PERSONAL_HISTORY_OF_CANCER_COEFFICIENT + def family_history_of_cancer_contribution_to_estimate(self): + if self.family_history_of_cancer is None: + raise self.InvalidValueError( + "family_history_of_cancer must be true or false") + + return self.family_history_of_cancer * self.FAMILY_HISTORY_OF_CANCER_COEFFICIENT + class InvalidValueError(Exception): pass diff --git a/lung_cancer_screening/calculators/tests/test_plco.py b/lung_cancer_screening/calculators/tests/test_plco.py index 88a2ab28..2a8efa17 100644 --- a/lung_cancer_screening/calculators/tests/test_plco.py +++ b/lung_cancer_screening/calculators/tests/test_plco.py @@ -83,3 +83,26 @@ def test_personal_history_of_cancer_contribution_to_estimate_when_false(self): result = calculator.personal_history_of_cancer_contribution_to_estimate() self.assertEqual(result, Decimal('0')) + + def test_family_history_of_cancer_contribution_to_estimate_when_none(self): + calculator = Plco(family_history_of_cancer=None) + + self.assertRaises( + Plco.InvalidValueError, + calculator.family_history_of_cancer_contribution_to_estimate + ) + + def test_family_history_of_cancer_contribution_to_estimate_when_true(self): + calculator = Plco(family_history_of_cancer=True) + + result = calculator.family_history_of_cancer_contribution_to_estimate() + + self.assertEqual(result, Decimal('0.587185')) + + def test_family_history_of_cancer_contribution_to_estimate_when_false(self): + calculator = Plco(family_history_of_cancer=False) + + result = calculator.family_history_of_cancer_contribution_to_estimate() + + self.assertEqual(result, Decimal('0')) + From 5db59a0ab2518828cd713991522cdd1636b3cee9 Mon Sep 17 00:00:00 2001 From: Andy Mitchell <326561+Themitchell@users.noreply.github.com> Date: Thu, 28 Aug 2025 11:44:40 +0100 Subject: [PATCH 5/7] Do not allow default arguments in the calculator --- lung_cancer_screening/calculators/plco.py | 15 +++---- .../calculators/tests/test_plco.py | 39 ++++++++++++------- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/lung_cancer_screening/calculators/plco.py b/lung_cancer_screening/calculators/plco.py index 6d45ab2e..e81b3ca7 100644 --- a/lung_cancer_screening/calculators/plco.py +++ b/lung_cancer_screening/calculators/plco.py @@ -12,10 +12,11 @@ class Plco: FAMILY_HISTORY_OF_CANCER_COEFFICIENT = Decimal('0.587185') def __init__(self, - age=None, - bmi=None, - copd_enphysema_or_chronic_bronchitis=None, - personal_history_of_cancer=None, family_history_of_cancer=None): + age, + bmi, + copd_enphysema_or_chronic_bronchitis, + personal_history_of_cancer, + family_history_of_cancer): self.age = Decimal(str(age or 0)) self.bmi = Decimal(str(bmi or 0)) self.copd_enphysema_or_chronic_bronchitis = copd_enphysema_or_chronic_bronchitis @@ -31,7 +32,7 @@ def bmi_contribution_to_estimate(self): def copd_enphysema_or_chronic_bronchitis_contribution_to_estimate(self): if self.copd_enphysema_or_chronic_bronchitis is None: raise self.InvalidValueError( - "copd_enphysema_or_chronic_bronchitis must be true or false") + "copd_enphysema_or_chronic_bronchitis must be set") return self.copd_enphysema_or_chronic_bronchitis * self.COPD_ENPHYSEMA_OR_CHRONIC_BRONCHITIS_COEFFICIENT @@ -39,14 +40,14 @@ def copd_enphysema_or_chronic_bronchitis_contribution_to_estimate(self): def personal_history_of_cancer_contribution_to_estimate(self): if self.personal_history_of_cancer is None: raise self.InvalidValueError( - "personal_history_of_cancer must be true or false") + "personal_history_of_cancer must be set") return self.personal_history_of_cancer * self.PERSONAL_HISTORY_OF_CANCER_COEFFICIENT def family_history_of_cancer_contribution_to_estimate(self): if self.family_history_of_cancer is None: raise self.InvalidValueError( - "family_history_of_cancer must be true or false") + "family_history_of_cancer must be set") return self.family_history_of_cancer * self.FAMILY_HISTORY_OF_CANCER_COEFFICIENT diff --git a/lung_cancer_screening/calculators/tests/test_plco.py b/lung_cancer_screening/calculators/tests/test_plco.py index 2a8efa17..42331bb8 100644 --- a/lung_cancer_screening/calculators/tests/test_plco.py +++ b/lung_cancer_screening/calculators/tests/test_plco.py @@ -4,44 +4,53 @@ from lung_cancer_screening.calculators.plco import Plco class TestPlco(TestCase): + def setUp(self): + self.defaultArgs = { + "age": 62, + "bmi": 27, + "copd_enphysema_or_chronic_bronchitis": False, + "personal_history_of_cancer": False, + "family_history_of_cancer": False + } + def test_age_in_years_contribution_to_estimate_when_age_is_none(self): - calculator = Plco(age=None) + calculator = Plco(**dict(self.defaultArgs, age=None)) result = calculator.age_in_years_contribution_to_estimate() self.assertEqual(result, Decimal('-4.8289816')) def test_age_in_years_contribution_to_estimate_at_74(self): - calculator = Plco(age=74) + calculator = Plco(**dict(self.defaultArgs, age=74)) result = calculator.age_in_years_contribution_to_estimate() self.assertEqual(result, Decimal('0.9346416')) def test_age_in_years_contribution_to_estimate_at_62(self): - calculator = Plco(age=58) + calculator = Plco(**dict(self.defaultArgs, age=58)) result = calculator.age_in_years_contribution_to_estimate() self.assertEqual(result, Decimal('-0.3115472')) def test_bmi_contribution_to_estimate_when_bmi_is_none(self): - calculator = Plco(bmi=None) + calculator = Plco(**dict(self.defaultArgs, bmi=None)) result = calculator.bmi_contribution_to_estimate() self.assertEqual(result, Decimal('0.7403238')) def test_bmi_contribution_to_estimate_when_bmi_is_23_point_5(self): - calculator = Plco(bmi=23.5) + calculator = Plco(**dict(self.defaultArgs, bmi=23.5)) result = calculator.bmi_contribution_to_estimate() self.assertEqual(result, Decimal('0.0959679')) def test_bmi_contribution_to_estimate_when_bmi_is_a_long_decimal(self): - calculator = Plco(bmi="26.4749212") + calculator = Plco(**dict(self.defaultArgs, bmi="26.4749212")) result = calculator.bmi_contribution_to_estimate() self.assertEqual(result, Decimal('0.01439734564872')) def test_copd_enphysema_or_chronic_bronchitiscontribution_to_estimate_when_none(self): - calculator = Plco(copd_enphysema_or_chronic_bronchitis=None) + calculator = Plco(**dict(self.defaultArgs, copd_enphysema_or_chronic_bronchitis=None)) self.assertRaises( Plco.InvalidValueError, @@ -49,21 +58,21 @@ def test_copd_enphysema_or_chronic_bronchitiscontribution_to_estimate_when_none( ) def test_copd_enphysema_or_chronic_bronchitiscontribution_to_estimate_when_true(self): - calculator = Plco(copd_enphysema_or_chronic_bronchitis=True) + calculator = Plco(**dict(self.defaultArgs, copd_enphysema_or_chronic_bronchitis=True)) result = calculator.copd_enphysema_or_chronic_bronchitis_contribution_to_estimate() self.assertEqual(result, Decimal('0.3553063')) def test_copd_enphysema_or_chronic_bronchitiscontribution_to_estimate_when_false(self): - calculator = Plco(copd_enphysema_or_chronic_bronchitis=False) + calculator = Plco(**dict(self.defaultArgs, copd_enphysema_or_chronic_bronchitis=False)) result = calculator.copd_enphysema_or_chronic_bronchitis_contribution_to_estimate() self.assertEqual(result, Decimal('0')) def test_personal_history_of_cancer_contribution_to_estimate_when_none(self): - calculator = Plco(personal_history_of_cancer=None) + calculator = Plco(**dict(self.defaultArgs, personal_history_of_cancer=None)) self.assertRaises( Plco.InvalidValueError, @@ -71,21 +80,21 @@ def test_personal_history_of_cancer_contribution_to_estimate_when_none(self): ) def test_personal_history_of_cancer_contribution_to_estimate_when_true(self): - calculator = Plco(personal_history_of_cancer=True) + calculator = Plco(**dict(self.defaultArgs, personal_history_of_cancer=True)) result = calculator.personal_history_of_cancer_contribution_to_estimate() self.assertEqual(result, Decimal('0.4589971')) def test_personal_history_of_cancer_contribution_to_estimate_when_false(self): - calculator = Plco(personal_history_of_cancer=False) + calculator = Plco(**dict(self.defaultArgs, personal_history_of_cancer=False)) result = calculator.personal_history_of_cancer_contribution_to_estimate() self.assertEqual(result, Decimal('0')) def test_family_history_of_cancer_contribution_to_estimate_when_none(self): - calculator = Plco(family_history_of_cancer=None) + calculator = Plco(**dict(self.defaultArgs, family_history_of_cancer=None)) self.assertRaises( Plco.InvalidValueError, @@ -93,14 +102,14 @@ def test_family_history_of_cancer_contribution_to_estimate_when_none(self): ) def test_family_history_of_cancer_contribution_to_estimate_when_true(self): - calculator = Plco(family_history_of_cancer=True) + calculator = Plco(**dict(self.defaultArgs, family_history_of_cancer=True)) result = calculator.family_history_of_cancer_contribution_to_estimate() self.assertEqual(result, Decimal('0.587185')) def test_family_history_of_cancer_contribution_to_estimate_when_false(self): - calculator = Plco(family_history_of_cancer=False) + calculator = Plco(**dict(self.defaultArgs, family_history_of_cancer=False)) result = calculator.family_history_of_cancer_contribution_to_estimate() From 797ee3eb29fe6985739d49eaa7d9524ce4bb2345 Mon Sep 17 00:00:00 2001 From: Andy Mitchell <326561+Themitchell@users.noreply.github.com> Date: Tue, 9 Sep 2025 15:53:26 +0100 Subject: [PATCH 6/7] Fix init padding for PLCO calculator --- lung_cancer_screening/calculators/plco.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lung_cancer_screening/calculators/plco.py b/lung_cancer_screening/calculators/plco.py index e81b3ca7..dd2c0cf2 100644 --- a/lung_cancer_screening/calculators/plco.py +++ b/lung_cancer_screening/calculators/plco.py @@ -12,11 +12,11 @@ class Plco: FAMILY_HISTORY_OF_CANCER_COEFFICIENT = Decimal('0.587185') def __init__(self, - age, - bmi, - copd_enphysema_or_chronic_bronchitis, - personal_history_of_cancer, - family_history_of_cancer): + age, + bmi, + copd_enphysema_or_chronic_bronchitis, + personal_history_of_cancer, + family_history_of_cancer): self.age = Decimal(str(age or 0)) self.bmi = Decimal(str(bmi or 0)) self.copd_enphysema_or_chronic_bronchitis = copd_enphysema_or_chronic_bronchitis From 7a37b564ffa3b2a43d82a968cee62b35b893dcdf Mon Sep 17 00:00:00 2001 From: Andy Mitchell <326561+Themitchell@users.noreply.github.com> Date: Tue, 9 Sep 2025 15:59:34 +0100 Subject: [PATCH 7/7] Fix incorrect merge conflict of app import in settings --- lung_cancer_screening/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lung_cancer_screening/settings.py b/lung_cancer_screening/settings.py index 14cff180..68d23928 100644 --- a/lung_cancer_screening/settings.py +++ b/lung_cancer_screening/settings.py @@ -47,7 +47,7 @@ def boolean_env(key, default=None): 'django.contrib.messages', 'django.contrib.staticfiles', 'lung_cancer_screening.core', - 'lung_cancer_screening.questions' + 'lung_cancer_screening.questions', 'lung_cancer_screening.calculators', ]