Skip to content

Commit

Permalink
Randomisation seed fix for the CRCCP FQHC Scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
pzirali committed Apr 29, 2024
1 parent 4ac3c9b commit 14b38d2
Show file tree
Hide file tree
Showing 94 changed files with 2 additions and 114,128 deletions.
157 changes: 2 additions & 155 deletions crcsim/experiment/prepare.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json
import random
from copy import deepcopy
from pathlib import Path
from typing import Callable, Dict, List, Optional

Expand Down Expand Up @@ -87,43 +86,6 @@ def transform(params):
return transform


def transform_treatment_cost(stage: str, phase: str, value: int) -> Callable:
def transform(params):
params[f"cost_treatment_stage{stage}_{phase}"] = value

return transform


def transform_repeat_compliance(rate: float, test: str) -> Callable:
def transform(params):
params["tests"][test]["compliance_rate_given_prev_compliant"] = [
rate for _ in params["tests"][test]["compliance_rate_given_prev_compliant"]
]

return transform


def transform_diagnostic_compliance(rate) -> Callable:
def transform(params):
params["diagnostic_compliance_rate"] = rate

return transform


def transform_surveillance_frequency(stage: str, frequency: int) -> Callable:
def transform(params):
params[f"surveillance_freq_{stage}"] = frequency

return transform


def transform_surveillance_end_age(age: int) -> Callable:
def transform(params):
params["surveillance_end_age"] = age

return transform


def create_scenarios() -> List:
# For each health center, define the initial compliance rate in the baseline
# scenario and the implementation scenario.
Expand All @@ -137,15 +99,7 @@ def create_scenarios() -> List:
"fqhc7": (0.257, 0.354),
"fqhc8": (0.190, 0.390),
}
low_initial_stage_3_treatment_cost = 67_300
low_initial_stage_4_treatment_cost = 97_931
extra_low_initial_stage_3_treatment_cost = 50_000
extra_low_initial_stage_4_treatment_cost = 80_000
low_diagnostic_compliance_rate = 0.525
lower_repeat_compliance = 0.8
low_surveillance_freq_mild = 10
low_surveillance_freq_severe = 2
low_surveillance_end_age = 80

scenarios = []

for fqhc, rates in initial_compliance.items():
Expand All @@ -159,113 +113,6 @@ def create_scenarios() -> List:
).transform(transform_initial_compliance(rates[1]))
scenarios.append(implementation)

# Sensitivity Analysis 1. Lower repeat compliance (note that the baseline runs stay the same)

test_name = "FIT"
implementation_lower_repeat_compliance = deepcopy(implementation)
implementation_lower_repeat_compliance.transform(
transform_repeat_compliance(lower_repeat_compliance, test_name)
)
implementation_lower_repeat_compliance.name = (
f"{fqhc}_implementation_lower_repeat_compliance"
)
scenarios.append(implementation_lower_repeat_compliance)

# Sensitivity analysis 2. Lower cost for stage III and stage IV initial phase
baseline_low_cost = deepcopy(baseline)
baseline_low_cost.transform(
transform_treatment_cost("3", "initial", low_initial_stage_3_treatment_cost)
).transform(
transform_treatment_cost("4", "initial", low_initial_stage_4_treatment_cost)
)
baseline_low_cost.name = f"{fqhc}_baseline_low_initial_treat_cost"
scenarios.append(baseline_low_cost)

implementation_low_cost = deepcopy(implementation)
implementation_low_cost.transform(
transform_treatment_cost("3", "initial", low_initial_stage_3_treatment_cost)
).transform(
transform_treatment_cost("4", "initial", low_initial_stage_4_treatment_cost)
)
implementation_low_cost.name = f"{fqhc}_implementation_low_initial_treat_cost"
scenarios.append(implementation_low_cost)

# Sensitivity analysis 2a. Extra low cost for stage III and stage IV initial phase
baseline_extra_low_cost = deepcopy(baseline)
baseline_extra_low_cost.transform(
transform_treatment_cost(
"3", "initial", extra_low_initial_stage_3_treatment_cost
)
).transform(
transform_treatment_cost(
"4", "initial", extra_low_initial_stage_4_treatment_cost
)
)
baseline_extra_low_cost.name = f"{fqhc}_baseline_extra_low_initial_treat_cost"
scenarios.append(baseline_extra_low_cost)

implementation_extra_low_cost = deepcopy(implementation)
implementation_extra_low_cost.transform(
transform_treatment_cost(
"3", "initial", extra_low_initial_stage_3_treatment_cost
)
).transform(
transform_treatment_cost(
"4", "initial", extra_low_initial_stage_4_treatment_cost
)
)
implementation_extra_low_cost.name = (
f"{fqhc}_implementation_extra_low_initial_treat_cost"
)
scenarios.append(implementation_extra_low_cost)

# Sensitivity analysis 3. Lower compliance with diagnostic colonoscopy
baseline_lower_compliance = deepcopy(baseline)
baseline_lower_compliance.transform(
transform_diagnostic_compliance(low_diagnostic_compliance_rate)
)
baseline_lower_compliance.name = f"{fqhc}_baseline_lower_diagnostic_compliance"
scenarios.append(baseline_lower_compliance)

implementation_lower_compliance = deepcopy(implementation)
implementation_lower_compliance.transform(
transform_diagnostic_compliance(low_diagnostic_compliance_rate)
)
implementation_lower_compliance.name = (
f"{fqhc}_implementation_lower_diagnostic_compliance"
)
scenarios.append(implementation_lower_compliance)

# Sensitivity analysis 4. Lower surveillance frequency and end age.

baseline_lower_surveillance = deepcopy(baseline)
baseline_lower_surveillance.transform(
transform_surveillance_frequency("polyp_mild", low_surveillance_freq_mild)
).transform(
transform_surveillance_frequency(
"polyp_severe", low_surveillance_freq_severe
)
).transform(
transform_surveillance_end_age(low_surveillance_end_age)
)
baseline_lower_surveillance.name = f"{fqhc}_baseline_lower_surveillance"
scenarios.append(baseline_lower_surveillance)

implementation_lower_surveillance = deepcopy(implementation)
implementation_lower_surveillance.transform(
transform_surveillance_frequency("polyp_mild", low_surveillance_freq_mild)
).transform(
transform_surveillance_frequency(
"polyp_severe", low_surveillance_freq_severe
)
).transform(
transform_surveillance_end_age(low_surveillance_end_age)
)
implementation_lower_surveillance.name = (
f"{fqhc}_implementation_lower_surveillance"
)
scenarios.append(implementation_lower_surveillance)

return scenarios


Expand All @@ -281,4 +128,4 @@ def main() -> None:


if __name__ == "__main__":
main()
main()
Loading

0 comments on commit 14b38d2

Please sign in to comment.