diff --git a/delphi/LeapfrogInterface.pas b/delphi/LeapfrogInterface.pas index 69ad946f..680902f2 100644 --- a/delphi/LeapfrogInterface.pas +++ b/delphi/LeapfrogInterface.pas @@ -278,8 +278,8 @@ LeapfrogHivChildParamsView = record hc1Cd4ProgLength: Integer; hc2Cd4Prog: PDouble; hc2Cd4ProgLength: Integer; - ctxVal: PDouble; - ctxValLength: Integer; + cotrimVal: PDouble; + cotrimValLength: Integer; hcArtEligAge: PInteger; hcArtEligAgeLength: Integer; hcArtEligCd4: PInteger; @@ -322,8 +322,8 @@ LeapfrogHivChildParamsView = record propLt200Length: Integer; propGte350: PDouble; propGte350Length: Integer; - ctxValIsPercent: PInteger; - ctxValIsPercentLength: Integer; + cotrimValIsPercent: PInteger; + cotrimValIsPercentLength: Integer; hcArtIsAgeSpec: PInteger; hcArtIsAgeSpecLength: Integer; abortion: PDouble; @@ -338,8 +338,8 @@ LeapfrogHivChildParamsView = record fertHivnpopLength: Integer; totalBirths: PDouble; totalBirthsLength: Integer; - ctxEffect: PDouble; - ctxEffectLength: Integer; + cotrimEffect: PDouble; + cotrimEffectLength: Integer; hcArtStart: Integer; hcArtStartLength: Integer; hcAgeSpecificFertilityRate: PDouble; @@ -355,7 +355,7 @@ LeapfrogHivChildParams = class hc2Cd4Mort: TGBFixedArray; hc1Cd4Prog: TGBFixedArray; hc2Cd4Prog: TGBFixedArray; - ctxVal: TGBFixedArray; + cotrimVal: TGBFixedArray; hcArtEligAge: TGBFixedArray; hcArtEligCd4: TGBFixedArray; hcArtMortRr: TGBFixedArray; @@ -377,7 +377,7 @@ LeapfrogHivChildParams = class matPrevInput: TGBFixedArray; propLt200: TGBFixedArray; propGte350: TGBFixedArray; - ctxValIsPercent: TGBFixedArray; + cotrimValIsPercent: TGBFixedArray; hcArtIsAgeSpec: TGBFixedArray; abortion: TGBFixedArray; patientsReallocated: TGBFixedArray; @@ -385,7 +385,7 @@ LeapfrogHivChildParams = class fertInfections: TGBFixedArray; fertHivnpop: TGBFixedArray; totalBirths: TGBFixedArray; - ctxEffect: TGBFixedArray; + cotrimEffect: TGBFixedArray; hcArtStart: Integer; hcAgeSpecificFertilityRate: TGBFixedArray; function getView(): LeapfrogHivChildParamsView; @@ -419,8 +419,8 @@ LeapfrogHivChildStateView = record hcArtInitTotalLength: Integer; hcArtNeedInit: PDouble; hcArtNeedInitLength: Integer; - ctxNeed: PDouble; - ctxNeedLength: Integer; + cotrimNeed: PDouble; + cotrimNeedLength: Integer; infectionByType: PDouble; infectionByTypeLength: Integer; mtctBySourceTr: PDouble; @@ -449,7 +449,7 @@ LeapfrogHivChildState = class hcArtInit: TGBFixedArray; hcArtInitTotal: TGBFixedArray; hcArtNeedInit: TGBFixedArray; - ctxNeed: TGBFixedArray; + cotrimNeed: TGBFixedArray; infectionByType: TGBFixedArray; mtctBySourceTr: TGBFixedArray; mtctBySourceWomen: TGBFixedArray; @@ -1164,7 +1164,7 @@ destructor LeapfrogHivChildParams.Destroy; hc2Cd4Mort.Free; hc1Cd4Prog.Free; hc2Cd4Prog.Free; - ctxVal.Free; + cotrimVal.Free; hcArtEligAge.Free; hcArtEligCd4.Free; hcArtMortRr.Free; @@ -1186,7 +1186,7 @@ destructor LeapfrogHivChildParams.Destroy; matPrevInput.Free; propLt200.Free; propGte350.Free; - ctxValIsPercent.Free; + cotrimValIsPercent.Free; hcArtIsAgeSpec.Free; abortion.Free; patientsReallocated.Free; @@ -1194,7 +1194,7 @@ destructor LeapfrogHivChildParams.Destroy; fertInfections.Free; fertHivnpop.Free; totalBirths.Free; - ctxEffect.Free; + cotrimEffect.Free; hcAgeSpecificFertilityRate.Free; inherited; end; @@ -1212,7 +1212,7 @@ destructor LeapfrogHivChildState.Destroy; hcArtInit.Free; hcArtInitTotal.Free; hcArtNeedInit.Free; - ctxNeed.Free; + cotrimNeed.Free; infectionByType.Free; mtctBySourceTr.Free; mtctBySourceWomen.Free; @@ -1236,8 +1236,8 @@ function LeapfrogHivChildParams.getView(): LeapfrogHivChildParamsView; Result.hc1Cd4ProgLength := hc1Cd4Prog.GetLength(); Result.hc2Cd4Prog := PDouble(hc2Cd4Prog.data); Result.hc2Cd4ProgLength := hc2Cd4Prog.GetLength(); - Result.ctxVal := PDouble(ctxVal.data); - Result.ctxValLength := ctxVal.GetLength(); + Result.cotrimVal := PDouble(cotrimVal.data); + Result.cotrimValLength := cotrimVal.GetLength(); Result.hcArtEligAge := PInteger(hcArtEligAge.data); Result.hcArtEligAgeLength := hcArtEligAge.GetLength(); Result.hcArtEligCd4 := PInteger(hcArtEligCd4.data); @@ -1280,8 +1280,8 @@ function LeapfrogHivChildParams.getView(): LeapfrogHivChildParamsView; Result.propLt200Length := propLt200.GetLength(); Result.propGte350 := PDouble(propGte350.data); Result.propGte350Length := propGte350.GetLength(); - Result.ctxValIsPercent := PInteger(ctxValIsPercent.data); - Result.ctxValIsPercentLength := ctxValIsPercent.GetLength(); + Result.cotrimValIsPercent := PInteger(cotrimValIsPercent.data); + Result.cotrimValIsPercentLength := cotrimValIsPercent.GetLength(); Result.hcArtIsAgeSpec := PInteger(hcArtIsAgeSpec.data); Result.hcArtIsAgeSpecLength := hcArtIsAgeSpec.GetLength(); Result.abortion := PDouble(abortion.data); @@ -1296,8 +1296,8 @@ function LeapfrogHivChildParams.getView(): LeapfrogHivChildParamsView; Result.fertHivnpopLength := fertHivnpop.GetLength(); Result.totalBirths := PDouble(totalBirths.data); Result.totalBirthsLength := totalBirths.GetLength(); - Result.ctxEffect := PDouble(ctxEffect.data); - Result.ctxEffectLength := ctxEffect.GetLength(); + Result.cotrimEffect := PDouble(cotrimEffect.data); + Result.cotrimEffectLength := cotrimEffect.GetLength(); Result.hcArtStart := hcArtStart; Result.hcArtStartLength := 1; Result.hcAgeSpecificFertilityRate := PDouble(hcAgeSpecificFertilityRate.data); @@ -1328,8 +1328,8 @@ function LeapfrogHivChildState.getView(): LeapfrogHivChildStateView; Result.hcArtInitTotalLength := hcArtInitTotal.GetLength(); Result.hcArtNeedInit := PDouble(hcArtNeedInit.data); Result.hcArtNeedInitLength := hcArtNeedInit.GetLength(); - Result.ctxNeed := PDouble(ctxNeed.data); - Result.ctxNeedLength := ctxNeed.GetLength(); + Result.cotrimNeed := PDouble(cotrimNeed.data); + Result.cotrimNeedLength := cotrimNeed.GetLength(); Result.infectionByType := PDouble(infectionByType.data); Result.infectionByTypeLength := infectionByType.GetLength(); Result.mtctBySourceTr := PDouble(mtctBySourceTr.data); @@ -1809,7 +1809,7 @@ procedure LeapfrogHivChildParams.writeToDisk(dir: string); hc2Cd4Mort.WriteToDisk(IncludeTrailingPathDelimiter(dir) + 'hc2Cd4Mort'); hc1Cd4Prog.WriteToDisk(IncludeTrailingPathDelimiter(dir) + 'hc1Cd4Prog'); hc2Cd4Prog.WriteToDisk(IncludeTrailingPathDelimiter(dir) + 'hc2Cd4Prog'); - ctxVal.WriteToDisk(IncludeTrailingPathDelimiter(dir) + 'ctxVal'); + cotrimVal.WriteToDisk(IncludeTrailingPathDelimiter(dir) + 'cotrimVal'); hcArtEligAge.WriteToDisk(IncludeTrailingPathDelimiter(dir) + 'hcArtEligAge'); hcArtEligCd4.WriteToDisk(IncludeTrailingPathDelimiter(dir) + 'hcArtEligCd4'); hcArtMortRr.WriteToDisk(IncludeTrailingPathDelimiter(dir) + 'hcArtMortRr'); @@ -1831,7 +1831,7 @@ procedure LeapfrogHivChildParams.writeToDisk(dir: string); matPrevInput.WriteToDisk(IncludeTrailingPathDelimiter(dir) + 'matPrevInput'); propLt200.WriteToDisk(IncludeTrailingPathDelimiter(dir) + 'propLt200'); propGte350.WriteToDisk(IncludeTrailingPathDelimiter(dir) + 'propGte350'); - ctxValIsPercent.WriteToDisk(IncludeTrailingPathDelimiter(dir) + 'ctxValIsPercent'); + cotrimValIsPercent.WriteToDisk(IncludeTrailingPathDelimiter(dir) + 'cotrimValIsPercent'); hcArtIsAgeSpec.WriteToDisk(IncludeTrailingPathDelimiter(dir) + 'hcArtIsAgeSpec'); abortion.WriteToDisk(IncludeTrailingPathDelimiter(dir) + 'abortion'); patientsReallocated.WriteToDisk(IncludeTrailingPathDelimiter(dir) + 'patientsReallocated'); @@ -1839,7 +1839,7 @@ procedure LeapfrogHivChildParams.writeToDisk(dir: string); fertInfections.WriteToDisk(IncludeTrailingPathDelimiter(dir) + 'fertInfections'); fertHivnpop.WriteToDisk(IncludeTrailingPathDelimiter(dir) + 'fertHivnpop'); totalBirths.WriteToDisk(IncludeTrailingPathDelimiter(dir) + 'totalBirths'); - ctxEffect.WriteToDisk(IncludeTrailingPathDelimiter(dir) + 'ctxEffect'); + cotrimEffect.WriteToDisk(IncludeTrailingPathDelimiter(dir) + 'cotrimEffect'); hcAgeSpecificFertilityRate.WriteToDisk(IncludeTrailingPathDelimiter(dir) + 'hcAgeSpecificFertilityRate'); end; diff --git a/goals/pyproject.toml b/goals/pyproject.toml index 9403d101..1f63c6ff 100644 --- a/goals/pyproject.toml +++ b/goals/pyproject.toml @@ -35,7 +35,7 @@ dev = [ "docopt>=0.6.2", "pytest>=8.3.5", "avenir-spectrum-import-pjnz>=0.1.15", - "avenir-spectrum-common>=0.1.22" + "avenir-spectrum-common>=0.1.24" ] # Uncomment and set file path to use local development versions diff --git a/goals/tests/test_goals.py b/goals/tests/test_goals.py index b4285da1..5e86d8c6 100644 --- a/goals/tests/test_goals.py +++ b/goals/tests/test_goals.py @@ -61,7 +61,7 @@ def test_goals_model(test_data): "hc_art_init", "hc_art_init_total", "hc_art_need_init", - "ctx_need", + "cotrim_need", "infection_by_type", "mtct_by_source_tr", "mtct_by_source_women", diff --git a/goals/uv.lock b/goals/uv.lock index 6078ec93..845679a7 100644 --- a/goals/uv.lock +++ b/goals/uv.lock @@ -38,7 +38,7 @@ wheels = [ [[package]] name = "avenir-spectrum-common" -version = "0.1.22" +version = "0.1.24" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "avenir-common" }, @@ -50,22 +50,22 @@ dependencies = [ { name = "requests" }, { name = "ujson" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/5c/37/ada2c883369a09b8cf785a40d11ade65083c32414fb01e82ec7582cbedcb/avenir_spectrum_common-0.1.22.tar.gz", hash = "sha256:cee33a4b9754cf7a5df9937fe34ab64d0c1fc7210c3ac9ae61c7098d2429ade1", size = 657656, upload-time = "2026-08-18T09:47:32.718Z" } +sdist = { url = "https://files.pythonhosted.org/packages/2a/41/28534adb7de37f093c2d2e85e841e1ab1479d97ac979d446c5cd437da685/avenir_spectrum_common-0.1.24.tar.gz", hash = "sha256:b0ff3424656e40fb6e10bbf463069fe0d11630ee31bb2d406ca99bbdcb380356", size = 657624, upload-time = "2026-08-20T15:35:13.408Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/7a/f0/e45d9d754a2e14193e87b22c27816c9cbfcce068f244eeec919aa1a75f9e/avenir_spectrum_common-0.1.22-py3-none-any.whl", hash = "sha256:544568a925444807a3091ded615c748019d6470dc91803470d8cd24eb2fd7dc9", size = 735151, upload-time = "2026-08-18T09:47:30.979Z" }, + { url = "https://files.pythonhosted.org/packages/4c/5a/74340ef0cb7a0ced9b661ca0f631d4dd65b8e74b742fd4e5675debbbac2c/avenir_spectrum_common-0.1.24-py3-none-any.whl", hash = "sha256:4b3e5d55bcea2493f2566e6b4c6a3afbf901ac11050da63d9a5529306eb170fc", size = 735161, upload-time = "2026-08-20T15:35:15.379Z" }, ] [[package]] name = "avenir-spectrum-import-pjnz" -version = "0.1.15" +version = "0.1.16" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "avenir-common" }, { name = "avenir-spectrum-common" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/27/99/400a0ce2691c07fc7ed22d22ee996bc49e9e0a526f49c85427ffa9c8f340/avenir_spectrum_import_pjnz-0.1.15.tar.gz", hash = "sha256:fa2ccdb8f18177dcd33e84ba7386b0be452e2718fa7665478af4348cecf50b39", size = 46969, upload-time = "2026-08-18T09:48:37.65Z" } +sdist = { url = "https://files.pythonhosted.org/packages/d4/a3/e659965208d7900526e91a43fd6858ea74c204f1ffc082d260db23a2a258/avenir_spectrum_import_pjnz-0.1.16.tar.gz", hash = "sha256:0c29602d8d353fe59886f08c59cbe1141983674de88947d6afadc295c57f352a", size = 47003, upload-time = "2026-08-20T13:47:45.047Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/f4/1f/89fcb626f861987a01dd885967394d51ff62a4f24d5f832e411331f56902/avenir_spectrum_import_pjnz-0.1.15-py3-none-any.whl", hash = "sha256:f32bc4b316cd865807296f3ef39c152c097b7c52c4566b4039ffa2f560585735", size = 49573, upload-time = "2026-08-18T09:48:36.446Z" }, + { url = "https://files.pythonhosted.org/packages/97/18/62ebfde65a3ab99ee8ec30566a87799c2b44bd2b022007a1830baa4d64bc/avenir_spectrum_import_pjnz-0.1.16-py3-none-any.whl", hash = "sha256:d16106f0e842d1aea4976379b0b02c38e6633da9ddbe1f09c6412428221add82", size = 49617, upload-time = "2026-08-20T13:47:43.737Z" }, ] [[package]] @@ -566,7 +566,7 @@ requires-dist = [ [package.metadata.requires-dev] dev = [ - { name = "avenir-spectrum-common", specifier = ">=0.1.22" }, + { name = "avenir-spectrum-common", specifier = ">=0.1.24" }, { name = "avenir-spectrum-import-pjnz", specifier = ">=0.1.15" }, { name = "deepdiff", specifier = ">=8.4.2" }, { name = "docopt", specifier = ">=0.6.2" }, diff --git a/leapfrog-core/include/model_debugger.hpp b/leapfrog-core/include/model_debugger.hpp index 4316e16d..b3a3c668 100644 --- a/leapfrog-core/include/model_debugger.hpp +++ b/leapfrog-core/include/model_debugger.hpp @@ -427,7 +427,7 @@ struct HcDebugInfo { NdaInfo hc2_art_aids_deaths; NdaInfo hc_art_init; NdaInfo hc_art_need_init; - double ctx_need; + double cotrim_need; NdaInfo infection_by_type; NdaInfo mtct_by_source_tr; NdaInfo mtct_by_source_women; @@ -455,7 +455,7 @@ struct HcDebugInfo { NdaInfo PMTCT_coverage; NdaInfo PMTCT_not_retained; NdaInfo bf_transmission_rate; - NdaInfo ctx_mean; + NdaInfo cotrim_mean; // Pars (selected) //NdaInfo hc_nosocomial; @@ -464,7 +464,7 @@ struct HcDebugInfo { NdaInfo hc2_cd4_mort; NdaInfo hc1_cd4_prog; NdaInfo hc2_cd4_prog; - NdaInfo ctx_val; + NdaInfo cotrim_val; NdaInfo hc_art_mort_rr; NdaInfo hc1_art_mort; NdaInfo hc2_art_mort; @@ -486,7 +486,7 @@ struct HcDebugInfo { NdaInfo fert_infections; NdaInfo fert_hivnpop; NdaInfo total_births; - NdaInfo ctx_effect; + NdaInfo cotrim_effect; int hc_art_start; NdaInfo hc_age_specific_fertility_rate; }; @@ -837,7 +837,7 @@ inline HcDebugInfo capture_hc(const HcState& hc, const IntermediateHc& i_hc, out.hc2_art_aids_deaths = nda_capture(hc.hc2_art_aids_deaths); out.hc_art_init = nda_capture(hc.hc_art_init); out.hc_art_need_init = nda_capture(hc.hc_art_need_init); - out.ctx_need = static_cast(hc.ctx_need); + out.cotrim_need = static_cast(hc.cotrim_need); out.infection_by_type = nda_capture(hc.infection_by_type); out.mtct_by_source_tr = nda_capture(hc.mtct_by_source_tr); out.mtct_by_source_women = nda_capture(hc.mtct_by_source_women); @@ -864,7 +864,7 @@ inline HcDebugInfo capture_hc(const HcState& hc, const IntermediateHc& i_hc, out.PMTCT_coverage = nda_capture(i_hc.PMTCT_coverage); out.PMTCT_not_retained = nda_capture(i_hc.PMTCT_not_retained); out.bf_transmission_rate = nda_capture(i_hc.bf_transmission_rate); - out.ctx_mean = nda_capture(i_hc.ctx_mean); + out.cotrim_mean = nda_capture(i_hc.cotrim_mean); //out.hc_nosocomial = nda_capture(p_hc.hc_nosocomial); out.hc1_cd4_dist = nda_capture(p_hc.hc1_cd4_dist); @@ -872,7 +872,7 @@ inline HcDebugInfo capture_hc(const HcState& hc, const IntermediateHc& i_hc, out.hc2_cd4_mort = nda_capture(p_hc.hc2_cd4_mort); out.hc1_cd4_prog = nda_capture(p_hc.hc1_cd4_prog); out.hc2_cd4_prog = nda_capture(p_hc.hc2_cd4_prog); - out.ctx_val = nda_capture(p_hc.ctx_val); + out.cotrim_val = nda_capture(p_hc.cotrim_val); out.hc_art_mort_rr = nda_capture(p_hc.hc_art_mort_rr); out.hc1_art_mort = nda_capture(p_hc.hc1_art_mort); out.hc2_art_mort = nda_capture(p_hc.hc2_art_mort); @@ -894,7 +894,7 @@ inline HcDebugInfo capture_hc(const HcState& hc, const IntermediateHc& i_hc, out.fert_infections = nda_capture(p_hc.fert_infections); out.fert_hivnpop = nda_capture(p_hc.fert_hivnpop); out.total_births = nda_capture(p_hc.total_births); - out.ctx_effect = nda_capture(p_hc.ctx_effect); + out.cotrim_effect = nda_capture(p_hc.cotrim_effect); out.hc_art_start = static_cast(p_hc.hc_art_start); out.hc_age_specific_fertility_rate = nda_capture(p_hc.hc_age_specific_fertility_rate); diff --git a/leapfrog-core/include/models/child_model_simulation.hpp b/leapfrog-core/include/models/child_model_simulation.hpp index 02395172..7b895b6a 100644 --- a/leapfrog-core/include/models/child_model_simulation.hpp +++ b/leapfrog-core/include/models/child_model_simulation.hpp @@ -844,7 +844,7 @@ struct ChildModelSimulation { auto& n_ha = state_next.ha; // Births from the last 18 months are eligible - n_hc.ctx_need = n_ha.hiv_births * 1.5; + n_hc.cotrim_need = n_ha.hiv_births * 1.5; // All children 1.5-4 eligible for (int s = 0; s < NS; ++s) { @@ -852,9 +852,9 @@ struct ChildModelSimulation { for (int cat = 0; cat < hcTT; ++cat) { for (int hd = 0; hd < hc1DS; ++hd) { if (a == age_1) { - n_hc.ctx_need += n_hc.hc1_hivpop(hd, cat, a, s) * 0.5; + n_hc.cotrim_need += n_hc.hc1_hivpop(hd, cat, a, s) * 0.5; } else { - n_hc.ctx_need += n_hc.hc1_hivpop(hd, cat, a, s); + n_hc.cotrim_need += n_hc.hc1_hivpop(hd, cat, a, s); } } } @@ -867,9 +867,9 @@ struct ChildModelSimulation { for (int hd = 0; hd < hc1DS; ++hd) { for (int dur = 0; dur < hTS; ++dur) { if (a == age_1) { - n_hc.ctx_need += n_hc.hc1_artpop(dur, hd, a, s) * 0.5; + n_hc.cotrim_need += n_hc.hc1_artpop(dur, hd, a, s) * 0.5; } else { - n_hc.ctx_need += n_hc.hc1_artpop(dur, hd, a, s) ; + n_hc.cotrim_need += n_hc.hc1_artpop(dur, hd, a, s) ; } } // end hTS } // end hc1DS @@ -883,7 +883,7 @@ struct ChildModelSimulation { for (int cat = 0; cat < hcTT; ++cat) { for (int hd = 0; hd < hc2DS; ++hd) { if (a < p_hc.hc_art_elig_age(t) || hd >= p_hc.hc_art_elig_cd4(a, t - 1)) { - n_hc.ctx_need += c_hc.hc2_hivpop(hd, cat, a - hc2_agestart, s); + n_hc.cotrim_need += c_hc.hc2_hivpop(hd, cat, a - hc2_agestart, s); } } // end hc2DS } // end hcTT @@ -896,10 +896,10 @@ struct ChildModelSimulation { auto& n_hc = state_next.hc; auto& i_hc = intermediate.hc; - if (p_hc.ctx_val_is_percent(t)) { - i_hc.ctx_mean(art_flag) = 1 - p_hc.ctx_effect(art_flag) * p_hc.ctx_val(t); - } else if (n_hc.ctx_need > 0) { - i_hc.ctx_mean(art_flag) = 1 - p_hc.ctx_effect(art_flag) * p_hc.ctx_val(t) / n_hc.ctx_need; + if (p_hc.cotrim_val_is_percent(t)) { + i_hc.cotrim_mean(art_flag) = 1 - p_hc.cotrim_effect(art_flag) * p_hc.cotrim_val(t); + } else if (n_hc.cotrim_need > 0) { + i_hc.cotrim_mean(art_flag) = 1 - p_hc.cotrim_effect(art_flag) * p_hc.cotrim_val(t) / n_hc.cotrim_need; } }; @@ -915,7 +915,7 @@ struct ChildModelSimulation { for (int a = 0; a < hc2_agestart; ++a) { for (int cat = 0; cat < hcTT; ++cat) { for (int hd = 0; hd < hc1DS; ++hd) { - auto hiv_deaths_strat = i_hc.ctx_mean(art_flag) * n_hc.hc1_hivpop(hd, cat, a, s) * p_hc.hc1_cd4_mort(hd, cat, a); + auto hiv_deaths_strat = i_hc.cotrim_mean(art_flag) * n_hc.hc1_hivpop(hd, cat, a, s) * p_hc.hc1_cd4_mort(hd, cat, a); i_hc.hc_posthivmort(hd, cat, a, s) = n_hc.hc1_hivpop(hd, cat, a, s) - hiv_deaths_strat; } } @@ -926,7 +926,7 @@ struct ChildModelSimulation { for (int a = hc2_agestart; a < hcAG_end; ++a) { for (int cat = 0; cat < hcTT; ++cat) { for (int hd = 0; hd < hc2DS; ++hd) { - auto hiv_deaths_strat = i_hc.ctx_mean(art_flag) * n_hc.hc2_hivpop(hd, cat, a - hc2_agestart, s) * + auto hiv_deaths_strat = i_hc.cotrim_mean(art_flag) * n_hc.hc2_hivpop(hd, cat, a - hc2_agestart, s) * p_hc.hc2_cd4_mort(hd, cat, a - hc2_agestart); i_hc.hc_posthivmort(hd, cat, a, s) = n_hc.hc2_hivpop(hd, cat, a - hc2_agestart, s) - hiv_deaths_strat; @@ -977,7 +977,7 @@ struct ChildModelSimulation { for (int a = 0; a < hc2_agestart; ++a) { for (int cat = 0; cat < hcTT; ++cat) { for (int hd = 0; hd < hc1DS; ++hd) { - auto cd4_deaths_grad = i_hc.ctx_mean(art_flag) * n_hc.hc1_hivpop(hd, cat, a, s) * + auto cd4_deaths_grad = i_hc.cotrim_mean(art_flag) * n_hc.hc1_hivpop(hd, cat, a, s) * p_hc.hc1_cd4_mort(hd, cat, a); i_hc.hc_grad(hd, cat, a, s) -= cd4_deaths_grad; n_hc.hc1_noart_aids_deaths(hd, cat, a, s) += cd4_deaths_grad; @@ -990,7 +990,7 @@ struct ChildModelSimulation { for (int a = hc2_agestart; a < hcAG_end; ++a) { for (int cat = 0; cat < hcTT; ++cat) { for (int hd = 0; hd < hc2DS; ++hd) { - auto cd4_mort_grad = i_hc.ctx_mean(art_flag) * + auto cd4_mort_grad = i_hc.cotrim_mean(art_flag) * n_hc.hc2_hivpop(hd, cat, a - hc2_agestart, s) * p_hc.hc2_cd4_mort(hd, cat, a - hc2_agestart); i_hc.hc_grad(hd, cat, a, s) -= cd4_mort_grad; @@ -1082,8 +1082,8 @@ struct ChildModelSimulation { } } - // ctx reduction on mortality for those on ART - hc_death_rate *= i_hc.ctx_mean(art_flag); + // cotrim reduction on mortality for those on ART + hc_death_rate *= i_hc.cotrim_mean(art_flag); //impact of new products if constexpr (ModelVariant::run_goals) { if (t > pars.hv.goals_base_year_idx) { @@ -1150,9 +1150,9 @@ struct ChildModelSimulation { } } - // ctx reduction on mortality for those on ART + // cotrim reduction on mortality for those on ART // NOTE: ART initiation calculations don't include the effect of cotrim (TODO: verify) - // hc_death_rate *= i_hc.ctx_mean(art_flag); + // hc_death_rate *= i_hc.cotrim_mean(art_flag); if (a < hc2_agestart) { bool any_hc1_art_deaths = hc_death_rate * n_hc.hc1_artpop(dur, hd, a, s) >= 0; if (any_hc1_art_deaths) { diff --git a/leapfrog-core/model_schemas/configs/HcConfig.json b/leapfrog-core/model_schemas/configs/HcConfig.json index 6f93e39c..31e9182b 100644 --- a/leapfrog-core/model_schemas/configs/HcConfig.json +++ b/leapfrog-core/model_schemas/configs/HcConfig.json @@ -83,7 +83,7 @@ "num_type": "real_type", "dims": ["SS::hc2DS", "SS::hc2AG_c", "SS::NS"] }, - "ctx_val": { + "cotrim_val": { "num_type": "real_type", "dims": ["opts.proj_steps"] }, @@ -171,7 +171,7 @@ "num_type": "real_type", "dims": ["opts.proj_steps"] }, - "ctx_val_is_percent": { + "cotrim_val_is_percent": { "num_type": "int", "dims": ["opts.proj_steps"] }, @@ -203,7 +203,7 @@ "num_type": "real_type", "dims": ["opts.proj_steps"] }, - "ctx_effect": { + "cotrim_effect": { "num_type": "real_type", "dims": ["3"] }, @@ -355,7 +355,7 @@ "bf_incident_hiv_transmission_rate": { "num_type": "real_type" }, - "ctx_mean": { + "cotrim_mean": { "num_type": "real_type", "dims": ["3"] }, @@ -410,7 +410,7 @@ "num_type": "real_type", "dims": ["SS::hc1DS", "SS::hcTT", "SS::hcAG_end", "SS::NS"] }, - "ctx_need": { + "cotrim_need": { "num_type": "real_type" }, "infection_by_type": { diff --git a/leapfrog-py/tests/test_leapfrog.py b/leapfrog-py/tests/test_leapfrog.py index 2d0e341a..ef2d40ab 100644 --- a/leapfrog-py/tests/test_leapfrog.py +++ b/leapfrog-py/tests/test_leapfrog.py @@ -88,7 +88,7 @@ def test_child_model(): "hc_art_init", "hc_art_init_total", "hc_art_need_init", - "ctx_need", + "cotrim_need", "infection_by_type", "mtct_by_source_tr", "mtct_by_source_women", diff --git a/leapfrogr/R/process_pjnz_hc.R b/leapfrogr/R/process_pjnz_hc.R index 0bbdbce3..31f08fde 100644 --- a/leapfrogr/R/process_pjnz_hc.R +++ b/leapfrogr/R/process_pjnz_hc.R @@ -262,16 +262,16 @@ prepare_art_elig <- function(dat, pars, dim_vars, proj_years, year_idx) { prepare_cotrim_effect <- function(dat, pars, dim_vars) { ##cotrim is effective for five years for children not on ART and for four years for children on ART - ctx_yrs_no_art = 5 - ctx_yrs_art = 4 - - ctx_effect <- pars$effect_treat_child - off_art_ctx <- sum(as.numeric(unlist(ctx_effect["no art", ]))) / ctx_yrs_no_art - on_art_ctx_lte12mo <- sum(as.numeric(unlist(ctx_effect["art", 1]))) - on_art_ctx_gte12mo <- sum(as.numeric(unlist(ctx_effect["art", 2:5]))) / ctx_yrs_art - array(data = c(off_art_ctx, on_art_ctx_lte12mo, on_art_ctx_gte12mo), + cotrim_yrs_no_art = 5 + cotrim_yrs_art = 4 + + cotrim_effect <- pars$effect_treat_child + off_art_cotrim <- sum(as.numeric(unlist(cotrim_effect["no art", ]))) / cotrim_yrs_no_art + on_art_cotrim_lte12mo <- sum(as.numeric(unlist(cotrim_effect["art", 1]))) + on_art_cotrim_gte12mo <- sum(as.numeric(unlist(cotrim_effect["art", 2:5]))) / cotrim_yrs_art + array(data = c(off_art_cotrim, on_art_cotrim_lte12mo, on_art_cotrim_gte12mo), dim = c(3), - dimnames = list(ctx_effect = c("Off ART", "On ART, lte12mo", "On ART, gte12mo"))) + dimnames = list(cotrim_effect = c("Off ART", "On ART, lte12mo", "On ART, gte12mo"))) } prepare_art_mort <- function(dat, pars, dim_vars) { @@ -435,12 +435,12 @@ process_pjnz_hc <- function(dat, pars, dim_vars, dp_params, use_coarse_age_group hc_art_init_dist <- pars$child_art_dist ## Cotrim coverage - ctx_val_is_percent <- as.integer(pars$child_art_by_age_group_pernum["Cotrim", ] == 1) - ctx_val <- pars$child_treat_inputs["Cotrim", ] - if (any(ctx_val_is_percent == 1)) { - ctx_val[ctx_val_is_percent == 1] <- ctx_val[ctx_val_is_percent == 1] / 100 + cotrim_val_is_percent <- as.integer(pars$child_art_by_age_group_pernum["Cotrim", ] == 1) + cotrim_val <- pars$child_treat_inputs["Cotrim", ] + if (any(cotrim_val_is_percent == 1)) { + cotrim_val[cotrim_val_is_percent == 1] <- cotrim_val[cotrim_val_is_percent == 1] / 100 } - ctx_effect <- prepare_cotrim_effect(dat, pars, dim_vars) + cotrim_effect <- prepare_cotrim_effect(dat, pars, dim_vars) ## ART coverage art <- pars$child_treat_inputs @@ -469,7 +469,7 @@ process_pjnz_hc <- function(dat, pars, dim_vars, dp_params, use_coarse_age_group hc2_cd4_mort = hc2_cd4_mort, hc1_cd4_prog = hc1_cd4_prog, hc2_cd4_prog = hc2_cd4_prog, - ctx_val = ctx_val, + cotrim_val = cotrim_val, hc_art_elig_age = hc_art_elig_age, hc_art_elig_cd4 = hc_art_elig_cd4, hc_art_mort_rr = hc_art_mort_rr, @@ -491,7 +491,7 @@ process_pjnz_hc <- function(dat, pars, dim_vars, dp_params, use_coarse_age_group mat_prev_input = mat_prev_input, prop_lt200 = prop_lt200, prop_gte350 = prop_gte350, - ctx_val_is_percent = ctx_val_is_percent, + cotrim_val_is_percent = cotrim_val_is_percent, hc_art_is_age_spec = hc_art_is_age_spec, abortion = abortion, patients_reallocated = patients_reallocated, @@ -499,7 +499,7 @@ process_pjnz_hc <- function(dat, pars, dim_vars, dp_params, use_coarse_age_group fert_infections = fert_infections, fert_hivnpop = fert_hivnpop, total_births = total_births, - ctx_effect = ctx_effect, + cotrim_effect = cotrim_effect, hc_art_start = hc_art_start, hc_age_specific_fertility_rate = hc_age_specific_fertility_rate ) diff --git a/leapfrogr/tests/testthat/test-child-model.R b/leapfrogr/tests/testthat/test-child-model.R index 4c0367f5..0c475862 100644 --- a/leapfrogr/tests/testthat/test-child-model.R +++ b/leapfrogr/tests/testthat/test-child-model.R @@ -18,7 +18,7 @@ test_that("Child model can be run for all years", { "hc1_artpop", "hc2_artpop", "hc1_noart_aids_deaths", "hc2_noart_aids_deaths", "hc1_art_aids_deaths", "hc2_art_aids_deaths", - "hc_art_init", "hc_art_init_total", "hc_art_need_init", "ctx_need", "infection_by_type", + "hc_art_init", "hc_art_init_total", "hc_art_need_init", "cotrim_need", "infection_by_type", "mtct_by_source_tr", "mtct_by_source_women", "mtct_by_source_hc_infections", "pmtct_coverage_at_delivery", "prevalence_15to49_hts", "incidence_15to49_hts", "artcoverage_15to49_hts", @@ -65,7 +65,7 @@ test_that("Coarse child model can be run for all years", { "hc1_artpop", "hc2_artpop", "hc1_noart_aids_deaths", "hc2_noart_aids_deaths", "hc1_art_aids_deaths", "hc2_art_aids_deaths", - "hc_art_init", "hc_art_init_total", "hc_art_need_init", "ctx_need", "infection_by_type", + "hc_art_init", "hc_art_init_total", "hc_art_need_init", "cotrim_need", "infection_by_type", "mtct_by_source_tr", "mtct_by_source_women", "mtct_by_source_hc_infections", "pmtct_coverage_at_delivery", "prevalence_15to49_hts", "incidence_15to49_hts", "artcoverage_15to49_hts", @@ -348,10 +348,10 @@ test_that("Children in need of cotrim aligns", { out <- run_model(parameters, "ChildModel", 1970:2030) - spec <- utils$ctx_need + spec <- utils$cotrim_need dt <- data.frame(year = 1970:2030, spec = as.numeric(unlist(spec)), - lfrog = out$ctx_need) + lfrog = out$cotrim_need) dt <- dt %>% dplyr::mutate(diff = spec - lfrog) diff --git a/leapfrogr/tests/testthat/test-process-pjnz.R b/leapfrogr/tests/testthat/test-process-pjnz.R index 5cdc5dbe..5a4aba5d 100644 --- a/leapfrogr/tests/testthat/test-process-pjnz.R +++ b/leapfrogr/tests/testthat/test-process-pjnz.R @@ -69,9 +69,9 @@ test_that("process_pjnz extract_child_params adds child-specific parameters", { pars_adult <- process_pjnz(bwa_pmtct_pjnz) pars_child <- process_pjnz(bwa_pmtct_pjnz, extract_child_params = TRUE) - child_pars <- c("hc_nosocomial_infections_by_age", "hc1_cd4_dist", "hc1_cd4_mort", + child_pars <- c("hc_nosocomial_infections_by_age", "hc1_cd4_dist", "hc1_cd4_mort", "hc2_cd4_mort", "hc1_cd4_prog", "hc2_cd4_prog", - "ctx_val", "PMTCT", "vertical_transmission_rate") + "cotrim_val", "PMTCT", "vertical_transmission_rate") expect_true(all(child_pars %in% names(pars_child))) expect_false(any(child_pars %in% names(pars_adult))) diff --git a/leapfrogr/vignettes/variables.Rmd b/leapfrogr/vignettes/variables.Rmd index ecd10a01..9fb2f6ad 100644 --- a/leapfrogr/vignettes/variables.Rmd +++ b/leapfrogr/vignettes/variables.Rmd @@ -136,8 +136,8 @@ In 5 structs as part of the `Parameters`, named `Demography`, `Incidence`, `Natu | adol_cd4_mort | children.hc2_cd4_mort | Probability of mortality by CD4 stage, age, and sex for 5-14 year olds | | paed_cd4_prog | children.hc1_cd4_prog | Probability of progressing to the subsequent CD4 stage for 0-4 year olds | | adol_cd4_prog | children.hc2_cd4_prog | Probability of progressing to the subsequent CD4 stage for 5-14 year olds | -| ctx_effect | children.ctx_effect | Effectiveness of cotrimoxazole at averting mortality | -| ctx_val | children.ctx_val | Number of children receiving cotrimoxazole | +| ctx_effect | children.cotrim_effect | Effectiveness of cotrimoxazole at averting mortality | +| ctx_val | children.cotrim_val | Number of children receiving cotrimoxazole | | paed_art_elig_age | children.hc_art_elig_age | Age at which children are eligible for ART by year | | paed_art_elig_cd4 | children.hc_art_elig_cd4 | CD4 at which children are eligible for ART by year | | mort_art_rr | children.hc_art_mort_rr | Mortality rate ratios by age and treatment duration | @@ -195,9 +195,8 @@ In 5 structs as part of the `Parameters`, named `Demography`, `Incidence`, `Natu | | hiv_births | Number of births to WLHIV by year | | | hc_art_need_init | Children who are eligible for ART by CD4, transmsission, age, sex, and year | | | hc_art_init | Number of new ART initiates by five year age group. | -| | ctx_need | Number of children in need of cotrim | -| | infecton_by_type | Number of paediatric HIV infections by type of infection (peri vs bf) and age at infection.| -| | ctx_need | Number of children in need of cotrim | +| | cotrim_need | Number of children in need of cotrim | +| | infecton_by_type | Number of paediatric HIV infections by type of infection (peri vs bf) and age at infection.| | | | mtct_by_source_tr | Transmission rate by maternal treatement history (stacked bar output) | | | mtct_by_source_women | Number of pregnant WLHIV by maternal treatement history (stacked bar output) | | | mtct_by_source_hc_infections | Number of paediatric infections by maternal treatement history (stacked bar output) | diff --git a/scripts/create_test_data.R b/scripts/create_test_data.R index b9dd2993..1de06ace 100755 --- a/scripts/create_test_data.R +++ b/scripts/create_test_data.R @@ -108,7 +108,7 @@ aids_deathsart <- array(0, dim = c(15,2,61), dimnames = list(age = 0:14, sex = c aids_deathsart[,'male',] <- dat$data$aids_deaths_art_single_age$data[as.character(0:14),"male",] aids_deathsart[,'female',] <- dat$data$aids_deaths_art_single_age$data[as.character(0:14),"female",] -spec_ctx_need <- dat$data$child_art_calc$data["both", "Children needing cotrim (0-14): ",] +spec_cotrim_need <- dat$data$child_art_calc$data["both", "Children needing cotrim (0-14): ",] out <- list(dp = dp, pjnz = pjnz_child, @@ -117,7 +117,7 @@ out <- list(dp = dp, offtrt = df$off_treatment, deaths_noart = aids_deathsnoart, deaths_art = aids_deathsart, - ctx_need = as.numeric(unlist(spec_ctx_need))) + cotrim_need = as.numeric(unlist(spec_cotrim_need))) save_parameters(parameters, testthat::test_path("testdata/child_parms_full.h5")) save_parameters(parameters_coarse, testthat::test_path("testdata/child_parms_coarse.h5"))