-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathHIVInfectionUpdater.cpp
More file actions
1309 lines (1182 loc) · 70 KB
/
Copy pathHIVInfectionUpdater.cpp
File metadata and controls
1309 lines (1182 loc) · 70 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "include.h"
/** \brief Constructor takes in the patient object */
HIVInfectionUpdater::HIVInfectionUpdater(Patient *patient) : StateUpdater(patient) {
}
/** \brief Destructor is empty, no cleanup required */
HIVInfectionUpdater::~HIVInfectionUpdater(void) {
}
/** \brief performInitialUpdates perform all of the state and statistics updates upon patient creation */
void HIVInfectionUpdater::performInitialUpdates() {
/** First calls the parent function to perform general updates and initialization */
StateUpdater::performInitialUpdates();
/** Determine the initial HIV state */
SimContext::HIV_INF infectedState = SimContext::HIV_INF_NEG;
SimContext::PEDS_HIV_STATE pedsHIVState = SimContext::PEDS_HIV_NEG;
SimContext::PEDS_MATERNAL_STATUS momHIVState = SimContext::PEDS_MATERNAL_STATUS_NEG;
bool isHighRisk = true;
setHIVIncReducMultiplier(1.0);
// Start with Pediatric initial breastfeeding, maternal, and HIV states if enabled
if (simContext->getPedsInputs()->enablePediatricsModel) {
/** For pediatrics: */
setInitialMaternalState();
/** Roll for age at which to stop breastfeeding */
bool reroll = true;
int bfStopAge;
while(reroll){
bfStopAge = (int)(CepacUtil::getRandomGaussian(simContext->getPedsInputs()->initialBFStopAgeMean,simContext->getPedsInputs()->initialBFStopAgeStdDev, 90017, patient)+0.5);
if (bfStopAge <= simContext->getPedsInputs()->initialBFStopAgeMax)
reroll = false;
}
setBreastfeedingStopAge(bfStopAge);
// Set the breastfeeding status
SimContext::PEDS_BF_TYPE bfType = SimContext::PEDS_BF_REPL;
double randNum;
// Use the initial distribution for exclusive and mixed breastfeeding with the patient's age to determine the appropriate status
if (patient->getGeneralState()->ageMonths < patient->getPedsState()->breastfeedingStopAge){
randNum = CepacUtil::getRandomDouble(90015, patient);
for (int i = 0; i < SimContext::PEDS_BF_COMP; i++) {
if (randNum < simContext->getPedsInputs()->initialBFDistribution[i]) {
if (patient->getGeneralState()->ageMonths >= SimContext::PEDS_BF_STOP_EXCL_MIXED)
bfType = (SimContext::PEDS_BF_COMP);
else
bfType = (SimContext::PEDS_BF_TYPE) i;
break;
}
randNum -= simContext->getPedsInputs()->initialBFDistribution[i];
}
}
setBreastfeedingStatus(bfType);
/** - Roll for and set the initial pediatrics and maternal HIV state */
//Set Maternal Status
bool motherBecameInfected = false;
randNum = CepacUtil::getRandomDouble(90005, patient);
for (int i = 0; i < SimContext::PEDS_MATERNAL_STATUS_NUM; i++){
if (randNum < simContext->getPedsInputs()->maternalStatusDistribution[i]){
momHIVState = (SimContext::PEDS_MATERNAL_STATUS) i;
if (momHIVState != SimContext::PEDS_MATERNAL_STATUS_NEG)
motherBecameInfected = true;
break;
}
randNum -= simContext->getPedsInputs()->maternalStatusDistribution[i];
}
setMaternalHIVState(momHIVState, motherBecameInfected, true);
//Roll for if maternal HIV+ status is known
randNum = CepacUtil::getRandomDouble(90007, patient);
bool statusKnown = false;
if(patient->getPedsState()->maternalStatus != SimContext::PEDS_MATERNAL_STATUS_NEG){
if (randNum < simContext->getPedsInputs()->probMotherStatusKnownPregnancy[patient->getPedsState()->maternalStatus])
statusKnown = true;
}
setMaternalStatusKnown(statusKnown);
//Roll for if mother on ART
randNum = CepacUtil::getRandomDouble(90008, patient);
bool isOnART = false;
if (patient->getPedsState()->maternalStatusKnown && patient->getPedsState()->maternalStatus!=SimContext::PEDS_MATERNAL_STATUS_NEG){
if (randNum < simContext->getPedsInputs()->probMotherOnARTInitial[patient->getPedsState()->maternalStatus])
isOnART = true;
}
bool isSuppressed = false;
bool suppressionKnown = false;
if (isOnART){
randNum = CepacUtil::getRandomDouble(90009, patient);
if (randNum < simContext->getPedsInputs()->probMotherOnSuppressedART[patient->getPedsState()->maternalStatus])
isSuppressed = true;
randNum = CepacUtil::getRandomDouble(90009, patient);
double probKnown = 0.0;
if(isSuppressed)
probKnown = simContext->getPedsInputs()->probMotherKnownSuppressed[patient->getPedsState()->maternalStatus];
else
probKnown = simContext->getPedsInputs()->probMotherKnownNotSuppressed[patient->getPedsState()->maternalStatus];
if (randNum < probKnown)
suppressionKnown = true;
}
setMaternalARTStatus(isOnART, isSuppressed, suppressionKnown, true);
//Roll for mother hvl
randNum = CepacUtil::getRandomDouble(90009, patient);
if (randNum < simContext->getPedsInputs()->probMotherLowHVL[patient->getPedsState()->maternalStatus])
setMaternalHVLStatus(true, true);
else
setMaternalHVLStatus(false, true);
//Roll for stop BF upon status known not supp
if (isOnART && !isSuppressed && suppressionKnown){
randNum = CepacUtil::getRandomDouble(90009, patient);
double prob = 0;
if (patient->getPedsState()->motherLowHVL)
prob = simContext->getPedsInputs()->probStopBFNotSuppressedLowHVL;
else
prob = simContext->getPedsInputs()->probStopBFNotSuppressedHighHVL;
if (randNum < prob)
setBreastfeedingStatus(SimContext::PEDS_BF_REPL);
}
//Roll for baby infected status
randNum = CepacUtil::getRandomDouble(90009, patient);
bool isBabyInfected = false;
double probInfected = 0.0;
if (patient->getPedsState()->motherOnART){
if (patient->getPedsState()->motherOnSuppressedART)
probInfected = simContext->getPedsInputs()->earlyVTHIVDistributionMotherOnArtSuppressed[patient->getPedsState()->maternalStatus];
else{
if (patient->getPedsState()->motherLowHVL)
probInfected = simContext->getPedsInputs()->earlyVTHIVDistributionMotherOnArtNotSuppressedLowHVL[patient->getPedsState()->maternalStatus];
else
probInfected = simContext->getPedsInputs()->earlyVTHIVDistributionMotherOnArtNotSuppressedHighHVL[patient->getPedsState()->maternalStatus];
}
}
else
probInfected = simContext->getPedsInputs()->earlyVTHIVDistributionMotherOffArt[patient->getPedsState()->maternalStatus];
if (randNum < probInfected){
randNum = CepacUtil::getRandomDouble(90010, patient);
if (randNum < simContext->getPedsInputs()->propEarlyVTHIVIU)
pedsHIVState = SimContext::PEDS_HIV_POS_IU;
else
pedsHIVState = SimContext::PEDS_HIV_POS_IP;
}
else
pedsHIVState = SimContext::PEDS_HIV_NEG;
setInfectedPediatricsHIVState(pedsHIVState, true);
/** - Set the regular HIV infected state */
// Set the regular infected state for children who were infected at birth or are HIV negative. There are no initial PP infections so the HIV+ are either IU or IP
if (patient->getDiseaseState()->infectedPediatricsHIVState != SimContext::PEDS_HIV_NEG){
// if infected at birth, set the infected state to acute or chronic based on the age category; late childhood draws on the adult CD4 and HVL inputs for chronic HIV
if(patient->getPedsState()->ageCategoryPediatrics < SimContext::PEDS_AGE_LATE)
infectedState = SimContext::HIV_INF_ACUTE_SYN;
else
infectedState = SimContext::HIV_INF_ASYMP_CHR_POS;
}
else {
infectedState = SimContext::HIV_INF_NEG;
setCareState(SimContext::HIV_CARE_NEG);
}
setInfectedHIVState(infectedState, true, true);
//Roll for age of serorversion
if (simContext->getEIDInputs()->enableHIVTestingEID){
int ageOfSeroreversion = (int)(CepacUtil::getRandomGaussian(simContext->getEIDInputs()->ageOfSeroreversionMean, simContext->getEIDInputs()->ageOfSeroreversionStdDev, 90018, patient)+0.5);
setAgeOfSeroreversion(ageOfSeroreversion);
}
//Set initial prob of infant HIV proph efficacy
for (int i = 0; i < SimContext::INFANT_HIV_PROPHS_NUM; ++i){
setInfantHIVProphEffProb(i, 1.0);
setInfantHIVProph(i, false, false, true);
setInfantHIVProphMajorToxicity(i,false);
}
} // end of Pediatric initial breastfeeding, maternal, and HIV states
else {
if (simContext->getHIVTestInputs()->enableHIVTesting) {
/** For adults: */
/** - Roll for initial HIV state from distribution if using HIV testing module */
double randNum = CepacUtil::getRandomDouble(90020, patient);
for (int i = 0; i < SimContext::HIV_INF_NUM; i++) {
if ((simContext->getHIVTestInputs()->initialHIVDistribution[i] != 0) &&
(randNum < simContext->getHIVTestInputs()->initialHIVDistribution[i])) {
infectedState = (SimContext::HIV_INF) i;
break;
}
randNum -= simContext->getHIVTestInputs()->initialHIVDistribution[i];
}
/** - If patient was preset to not being a prevalent case (likely from transmission model) set them to HIV negative state */
if (patient->getGeneralState()->predefinedAgeAndGender && !patient->getDiseaseState()->isPrevalentHIVCase){
//Set non-prevalent cases to HIV Negative
infectedState = SimContext::HIV_INF_NEG;
}
}
else {
/** - Always use chronic HIV if HIV testing module is disabled */
infectedState = SimContext::HIV_INF_ASYMP_CHR_POS;
setCareState(SimContext::HIV_CARE_IN_CARE);
}
//Roll for risk state
double randNum = CepacUtil::getRandomDouble(90020, patient);
if (infectedState == SimContext::HIV_INF_NEG &&
randNum < simContext->getHIVTestInputs()->initialRiskDistribution[SimContext::HIV_BEHAV_LO])
isHighRisk = false;
/** isInitial is true if this is a prevalent case (was true by default, but this changed with transmission model's need to predefine incidence cases) */
bool isInitial = !(patient->getGeneralState()->predefinedAgeAndGender && !patient->getDiseaseState()->isPrevalentHIVCase);
setInfectedHIVState(infectedState, isInitial, true, isHighRisk);
if (infectedState == SimContext::HIV_INF_NEG)
setCareState(SimContext::HIV_CARE_NEG);
} // end of adult initial HIV state
/** Set the initial CD4 percentage for early childhood if HIV positive*/
if (patient->getPedsState()->ageCategoryPediatrics < SimContext::PEDS_AGE_LATE) {
/** Set the initial true CD4 percentage and strata for HIV positive infants */
/** If HIV-negative, CD4 will be initialized to 0 but should not be used unless they become HIV+ */
double cd4PercMean = 0;
double cd4PercStdDev = 0;
if (pedsHIVState == SimContext::PEDS_HIV_POS_IU) {
cd4PercMean = simContext->getPedsInputs()->initialCD4PercentageIUMean;
cd4PercStdDev = simContext->getPedsInputs()->initialCD4PercentageIUStdDev;
}
else if (pedsHIVState == SimContext::PEDS_HIV_POS_IP) {
cd4PercMean = simContext->getPedsInputs()->initialCD4PercentageIPMean;
cd4PercStdDev = simContext->getPedsInputs()->initialCD4PercentageIPStdDev;
}
double cd4PercValue = CepacUtil::getRandomGaussian(cd4PercMean, cd4PercStdDev, 90030, patient);
setTrueCD4Percentage(cd4PercValue, true);
}
/** Set the initial true CD4 value and strata for adults and late childhood if HIV positive*/
/** If HIV-negative, CD4 will be initialized to 0 but should not be used unless they become HIV+ */
else {
double cd4Mean = 0;
double cd4StdDev = 0;
double cd4Value = -1;
if (infectedState == SimContext::HIV_INF_ACUTE_SYN) {
cd4Mean = simContext->getHIVTestInputs()->initialAcuteCD4DistributionMean;
cd4StdDev = simContext->getHIVTestInputs()->initialAcuteCD4DistributionStdDev;
}
else if (infectedState == SimContext::HIV_INF_ASYMP_CHR_POS) {
cd4Mean = simContext->getCohortInputs()->initialCD4Mean;
cd4StdDev = simContext->getCohortInputs()->initialCD4StdDev;
}
int count = 0;
// If we are using the square root transformation the drawn value is squared to get the actual CD4
if (simContext->getCohortInputs()->enableSquareRootTransform){
while ((cd4Value < 0) || ((simContext->getRunSpecsInputs()->maxPatientCD4 != SimContext::NOT_APPL) && (cd4Value*cd4Value > simContext->getRunSpecsInputs()->maxPatientCD4))){
cd4Value = CepacUtil::getRandomGaussian(cd4Mean, cd4StdDev, 90040+count, patient);
count++;
}
cd4Value = cd4Value * cd4Value;
}
else{
while ((cd4Value < 0) || ((simContext->getRunSpecsInputs()->maxPatientCD4 != SimContext::NOT_APPL) && (cd4Value > simContext->getRunSpecsInputs()->maxPatientCD4))){
cd4Value = CepacUtil::getRandomGaussian(cd4Mean, cd4StdDev, 90040+count, patient);
count++;
}
}
setTrueCD4(cd4Value, true);
}
/** Set the initial HVL strata if HIV positive, get distribution for pediatric early childhood or adult/pediatric late childhood */
const double *hvlDist = NULL;
if (patient->getPedsState()->ageCategoryPediatrics < SimContext::PEDS_AGE_LATE) {
if (pedsHIVState == SimContext::PEDS_HIV_POS_IU) {
hvlDist = simContext->getPedsInputs()->initialHVLDistributionIU;
}
else if (pedsHIVState == SimContext::PEDS_HIV_POS_IP) {
hvlDist = simContext->getPedsInputs()->initialHVLDistributionIP;
}
}
// After early childhood, draw initial HVL from adult inputs
else {
if (infectedState == SimContext::HIV_INF_ACUTE_SYN) {
SimContext::CD4_STRATA cd4Strata = patient->getDiseaseState()->currTrueCD4Strata;
hvlDist = simContext->getHIVTestInputs()->initialAcuteHVLDistribution[cd4Strata];
}
else if (infectedState == SimContext::HIV_INF_ASYMP_CHR_POS) {
SimContext::CD4_STRATA cd4Strata = patient->getDiseaseState()->currTrueCD4Strata;
hvlDist = simContext->getCohortInputs()->initialHVLDistribution[cd4Strata];
}
}
if (hvlDist != NULL) {
SimContext::HVL_STRATA hvlStrata = SimContext::HVL__LO;
double randNum = CepacUtil::getRandomDouble(90050, patient);
for (int i = SimContext::HVL_NUM_STRATA - 1; i >= 0; i--) {
if ((hvlDist[i] != 0) && (randNum < hvlDist[i])) {
hvlStrata = (SimContext::HVL_STRATA) i;
break;
}
randNum -= hvlDist[i];
}
setTrueHVLStrata(hvlStrata);
setSetpointHVLStrata(hvlStrata);
setTargetHVLStrata(hvlStrata);
}
/** Set the patients Transmission risk category */
int ageCat = getAgeCategoryTransmRisk(patient->getGeneralState()->ageMonths);
SimContext::TRANSM_RISK transmRisk = SimContext::TRANSM_RISK_OTHER;
double randNum = CepacUtil::getRandomDouble(60055, patient);
for (int i = 0; i < SimContext::TRANSM_RISK_NUM; i++){
double distValue = simContext->getCohortInputs()->transmRiskDistrib[patient->getGeneralState()->gender][ageCat][i];
if (randNum < distValue){
transmRisk = (SimContext::TRANSM_RISK) i;
break;
}
randNum -= distValue;
}
setTransmRiskCategory(transmRisk);
setInitialPrEPParams();
/** Roll for initially on PrEP if age eligible */
if (patient->getDiseaseState()->infectedHIVState == SimContext::HIV_INF_NEG &&
simContext->getHIVTestInputs()->enableHIVTesting && simContext->getHIVTestInputs()->enablePrEP && !patient->getGeneralState()->isPediatric && (simContext->getHIVTestInputs()->HIVRegularTestingStopAge == SimContext::NOT_APPL || patient->getGeneralState()->ageMonths <= simContext->getHIVTestInputs()->HIVRegularTestingStopAge)){
randNum = CepacUtil::getRandomDouble(60055, patient);
SimContext::HIV_BEHAV risk = patient->getMonitoringState()->isHighRiskForHIV?SimContext::HIV_BEHAV_HI:SimContext::HIV_BEHAV_LO;
if (randNum < simContext->getHIVTestInputs()->PrEPInitialDistribution[risk]){
setPrEP(true);
incrementCostsPrEP(simContext->getHIVTestInputs()->costPrEPInitial[risk], 1.0);
}
else{
setPrEP(false);
}
}
else
setPrEP(false);
} /* end performInitialUpdates */
/** \brief performMonthlyUpdates perform all of the state and statistics updates for a simulated month */
void HIVInfectionUpdater::performMonthlyUpdates() {
/** If the patient is pediatric, determine maternal updates and early to late childhood transition by calling HIVInfectionUpdater::performPediatricDiseaseUpdates() */
if (patient->getGeneralState()->isPediatric) {
performPediatricDiseaseUpdates();
}
/** If the patient is an adolescent, perform updates and age-based transitions specific to adolescents*/
if (patient->getGeneralState()->isAdolescent){
performAdolescentDiseaseUpdates();
}
/** determines if HIV negative patients become infected by calling HIVInfectionUpdater::performHIVNegativeUpdates() */
if (patient->getDiseaseState()->infectedHIVState == SimContext::HIV_INF_NEG) {
performHIVNegativeUpdates();
}
/** Perform acute to chronic transition if this should occur this month by calling HIVInfectionUpdater::performAcuteToChronicHIVUpdates() */
if ((patient->getDiseaseState()->infectedHIVState == SimContext::HIV_INF_ACUTE_SYN) &&
(patient->getDiseaseState()->monthOfAcuteToChronicHIV == patient->getGeneralState()->monthNum)) {
performAcuteToChronicHIVUpdates();
}
} /* end performMonthlyUpdates */
/** \brief performHIVNegativeUpdates determines if HIV negative patients become infected */
void HIVInfectionUpdater::performHIVNegativeUpdates() {
//Count number of uninfected
updateStartMonthHIVNeg();
//Roll for dropout PrEP - currently, those who drop out cannot rejoin, and patients who are infected on PrEP but not yet detected cannot drop out. Adjustments will be needed to the code related to PrEP dropouts if we begin to allow dropouts to rejoin or HIV+ patients still on PrEP to drop out.
if (simContext->getHIVTestInputs()->enableHIVTesting && simContext->getHIVTestInputs()->enablePrEP &&
patient->getMonitoringState()->hasPrEP){
SimContext::HIV_BEHAV risk = patient->getMonitoringState()->isHighRiskForHIV?SimContext::HIV_BEHAV_HI:SimContext::HIV_BEHAV_LO;
double probDropout;
// the dropout threshold month is relative to a reference month, either Month 0 (simulation start) or the month of PrEP start, based on user input
if (patient->getGeneralState()->monthNum <= patient->getMonitoringState()->PrEPDropoutThresholdMonth)
probDropout = simContext->getHIVTestInputs()->PrEPDropoutPreThreshold[risk];
else
probDropout = simContext->getHIVTestInputs()->PrEPDropoutPostThreshold[risk];
double randNum = CepacUtil::getRandomDouble(90060, patient);
if (randNum < probDropout) {
setPrEP(false, true);
/** - Print tracing information for dropout PrEP */
if (patient->getGeneralState()->tracingEnabled)
tracer->printTrace(1, "**%d DROPOUT PrEP;\n", patient->getGeneralState()->monthNum);
}
}
//Roll for start PrEP
SimContext::HIV_BEHAV risk = patient->getMonitoringState()->isHighRiskForHIV?SimContext::HIV_BEHAV_HI:SimContext::HIV_BEHAV_LO;
if (simContext->getHIVTestInputs()->enableHIVTesting && simContext->getHIVTestInputs()->enablePrEP &&
!patient->getMonitoringState()->everPrEP &&
(simContext->getHIVTestInputs()->PrEPAfterRollout[risk] || patient->getGeneralState()->monthNum < simContext->getHIVTestInputs()->PrEPRolloutDuration[risk])){
double probPrEP;
double coverage = simContext->getHIVTestInputs()->PrEPCoverage[risk];
int duration = simContext->getHIVTestInputs()->PrEPRolloutDuration[risk];
double shape = simContext->getHIVTestInputs()->PrEPShape[risk];
int month = patient->getGeneralState()->monthNum;
//prob from Weibull distribution
probPrEP = 1-pow(1-coverage,(pow(month+1,shape)-pow(month,shape))/pow(duration,shape));
//log probability of age-eligible patients joining
updatePrEPProbLogging(probPrEP, risk);
if(!patient->getGeneralState()->isPediatric &&
(simContext->getHIVTestInputs()->HIVRegularTestingStopAge == SimContext::NOT_APPL || patient->getGeneralState()->ageMonths <= simContext->getHIVTestInputs()->HIVRegularTestingStopAge)){
double randNum = CepacUtil::getRandomDouble(90060, patient);
if (randNum < probPrEP) {
setPrEP(true);
incrementCostsPrEP(simContext->getHIVTestInputs()->costPrEPInitial[risk], 1.0);
/** - Print tracing information for starting PrEP */
if (patient->getGeneralState()->tracingEnabled) {
tracer->printTrace(1, "**%d START PrEP;\n", patient->getGeneralState()->monthNum);
}//if we're tracing the patient
} //if we started PrEP
} //if patient is age-eligible for PrEP
}
/** If Adult or Adolescent, roll for adult HIV infection */
if ((patient->getPedsState()->ageCategoryPediatrics == SimContext::PEDS_AGE_ADULT)|| patient->getGeneralState()->isAdolescent) {
int ageCategory = patient->getGeneralState()->ageCategoryHIVInfection;
SimContext::GENDER_TYPE gender = patient->getGeneralState()->gender;
SimContext::HIV_BEHAV riskType = patient->getMonitoringState()->isHighRiskForHIV ? SimContext::HIV_BEHAV_HI : SimContext::HIV_BEHAV_LO;
double randNum = CepacUtil::getRandomDouble(90060, patient);
double probInfect;
if (patient->getMonitoringState()->hasPrEP)
probInfect = simContext->getHIVTestInputs()->PrEPIncidence[gender][ageCategory][riskType];
else
probInfect = simContext->getHIVTestInputs()->probHIVInfection[gender][ageCategory][riskType];
//Reduce incidence by global incidence reduction; multipliers accumulate based on 6 stage bounds. First stage bound is always 1. After the 6th bound month, no new multipliers are accumulated
if (simContext->getHIVTestInputs()->useHIVIncReductionMult){
if(patient->getGeneralState()->monthNum <= simContext->getHIVTestInputs()->HIVIncReducStageBounds[SimContext::INC_REDUC_PERIODS_NUM - 1]){
// accumulate a new multplier if a new stage bound was reached this month
double newReducMult = patient->getMonitoringState()->HIVIncReducMultiplier;
for(int i = 0; i < SimContext::INC_REDUC_PERIODS_NUM; i++){
if(patient->getGeneralState()->monthNum == simContext->getHIVTestInputs()->HIVIncReducStageBounds[i]){
newReducMult *= simContext->getHIVTestInputs()->HIVIncReducMultipliers[i];
setHIVIncReducMultiplier(newReducMult);
break;
}
}
}
probInfect *= patient->getMonitoringState()->HIVIncReducMultiplier;
}
//Roll for infection
if (randNum < probInfect) {
/** - If infected, initialize the new infection by calling HIVInfectionUpdater::performHIVNewInfectionUpdates() */
performHIVNewInfectionUpdates();
}
}
// Pediatric infection
else {
/** Roll for infant PP HIV infection (aka PP Vertical Transmission of HIV, or PP VTHIV) which only occurs during bf */
// No pediatric patients are infected between the end of bf and the transition to either Adolescent or Adult
SimContext::PEDS_MATERNAL_STATUS momHIVState = patient->getPedsState()->maternalStatus;
if ((patient->getGeneralState()->ageMonths < patient->getPedsState()->breastfeedingStopAge) &&patient->getPedsState()->isMotherAlive && (momHIVState != SimContext::PEDS_MATERNAL_STATUS_NEG)){
SimContext::PEDS_BF_TYPE bfType = patient->getPedsState()->breastfeedingStatus;
double randNum = CepacUtil::getRandomDouble(90065, patient);
bool isIncident = false;
if (bfType != SimContext::PEDS_BF_REPL){
double probVTHIV;
if (patient->getPedsState()->motherOnART){
if (patient->getPedsState()->motherOnSuppressedART)
probVTHIV = simContext->getPedsInputs()->probVTHIVPPMotherOnARTSuppressed[momHIVState];
else{
if (patient->getPedsState()->motherLowHVL)
probVTHIV = simContext->getPedsInputs()->probVTHIVPPMotherOnARTNotSuppressedLowHVL[momHIVState];
else
probVTHIV = simContext->getPedsInputs()->probVTHIVPPMotherOnARTNotSuppressedHighHVL[momHIVState];
}
}
else
probVTHIV = simContext->getPedsInputs()->probVTHIVPPMotherOffART[momHIVState][bfType];
//Modify by infant proph - when the patient is within the duration for multiple lines of infant prophylaxis, the efficacy multipliers are applied cumulatively to the probability of VTHIV
for (int i = 0; i < SimContext::INFANT_HIV_PROPHS_NUM; ++i){
if (patient->getPedsState()->hasEffectiveInfantHIVProph[i]){
const SimContext::EIDInputs::InfantHIVProph &infantProph = simContext->getEIDInputs()->infantHIVProphs[i];
int timeSinceProph = patient->getGeneralState()->monthNum - patient->getPedsState()->monthOfEffectiveInfantHIVProph[i];
//First check if the proph dose has any remaining efficacy; skip if not
if(timeSinceProph > infantProph.infantProphEffHorizon + infantProph.infantProphDecayTime){
continue;
}
//Find the multiplier defined for the patient age and maternal status
int period = 0;
if (patient->getGeneralState()->ageMonths >= infantProph.infantProphVTHIVPPMultAgeThreshold)
period = 1;
double VTHIVmult;
if (patient->getPedsState()->motherOnART){
if (patient->getPedsState()->motherOnSuppressedART)
VTHIVmult = infantProph.infantProphVTHIVPPMultMotherOnARTSuppressed[momHIVState][period];
else{
if (patient->getPedsState()->motherLowHVL)
VTHIVmult = infantProph.infantProphVTHIVPPMultMotherOnARTNotSuppressedLowHVL[momHIVState][period];
else
VTHIVmult = infantProph.infantProphVTHIVPPMultMotherOnARTNotSuppressedHighHVL[momHIVState][period];
}
}
else
VTHIVmult = infantProph.infantProphVTHIVPPMultMotherOffART[momHIVState][bfType][period];
//Check if in efficacy time horizon
if (timeSinceProph <= infantProph.infantProphEffHorizon)
probVTHIV = CepacUtil::probRateMultiply(probVTHIV, VTHIVmult);
else if(timeSinceProph <= infantProph.infantProphEffHorizon + infantProph.infantProphDecayTime){
int timeSinceDecay = timeSinceProph - infantProph.infantProphEffHorizon;
double propDecay = (double) timeSinceDecay / infantProph.infantProphDecayTime;
probVTHIV = CepacUtil::probRateMultiply(probVTHIV, (VTHIVmult + propDecay*(1-VTHIVmult)));
}
}
}
if (randNum < probVTHIV)
isIncident=true;
}//end patient is breastfeeding
if (isIncident) {
/** - If infected, initialize the new infection by calling HIVInfectionUpdater::performHIVNewInfectionUpdates() */
performHIVNewInfectionUpdates();
}//end we infected a pediatric patient
}//end mom is HIV positive and patient is of breastfeeding age
}//end we're dealing with a pediatric patient
} /* end performHIVNegativeUpdates */
/** \brief performHIVNewInfectionUpdates handles the new infection of an HIV negative patient
*
* Note: This functions assumes that an HIV infection is scheduled to occur */
void HIVInfectionUpdater::performHIVNewInfectionUpdates(){
/** Don't do anything if the patient is already infected */
if (patient->getDiseaseState()->infectedHIVState != SimContext::HIV_INF_NEG){
return;
}
/** Use one set of infection rules for adults and adolescents, and another for Peds early */
if ((patient->getPedsState()->ageCategoryPediatrics == SimContext::PEDS_AGE_ADULT) || patient->getGeneralState()->isAdolescent){
/** For adults and adolescents:
/* - Update the Patient's infected state to acute infected */
setInfectedHIVState(SimContext::HIV_INF_ACUTE_SYN, false, true);
setDetectedHIVState(false);
/** - Set the CD4 level for an incident case of acute HIV infection */
double cd4Mean = simContext->getHIVTestInputs()->initialAcuteCD4DistributionMean;
double cd4StdDev = simContext->getHIVTestInputs()->initialAcuteCD4DistributionStdDev;
double cd4Value = -1;
int count = 0;
if (simContext->getCohortInputs()->enableSquareRootTransform){
while ((cd4Value < 0) || ((simContext->getRunSpecsInputs()->maxPatientCD4 != SimContext::NOT_APPL) && (cd4Value*cd4Value > simContext->getRunSpecsInputs()->maxPatientCD4))){
cd4Value = CepacUtil::getRandomGaussian(cd4Mean, cd4StdDev, 90067+count, patient);
count++;
}
cd4Value = cd4Value * cd4Value;
}
else{
while ((cd4Value < 0) || ((simContext->getRunSpecsInputs()->maxPatientCD4 != SimContext::NOT_APPL) && (cd4Value > simContext->getRunSpecsInputs()->maxPatientCD4))){
cd4Value = CepacUtil::getRandomGaussian(cd4Mean, cd4StdDev, 90068+count, patient);
count++;
}
}
setTrueCD4(cd4Value, true);
/** - Set the HVL level for an incident case of acute HIV infection */
SimContext::CD4_STRATA cd4Strata = patient->getDiseaseState()->currTrueCD4Strata;
double randNum = CepacUtil::getRandomDouble(90080, patient);
for (int i = SimContext::HVL_NUM_STRATA - 1; i >= 0; i--) {
if ((simContext->getHIVTestInputs()->initialAcuteHVLDistribution[cd4Strata][i] != 0) &&
(randNum < simContext->getHIVTestInputs()->initialAcuteHVLDistribution[cd4Strata][i])) {
setTrueHVLStrata((SimContext::HVL_STRATA) i);
setSetpointHVLStrata((SimContext::HVL_STRATA) i);
setTargetHVLStrata((SimContext::HVL_STRATA) i);
break;
}//If we choose to set to this HVL Strata...
randNum -= simContext->getHIVTestInputs()->initialAcuteHVLDistribution[cd4Strata][i];
}//end for loop through all HVL strata
/** - Update the initial distributions at time of infection statistics */
updateInitialDistributions();
/** - Print tracing information for infection and the initial CD4/HVL */
if (patient->getGeneralState()->tracingEnabled) {
tracer->printTrace(1, "**%d HIV INFECTION;\n", patient->getGeneralState()->monthNum);
tracer->printTrace(1, " %d init CD4: %1.0f;\n", patient->getGeneralState()->monthNum,
patient->getDiseaseState()->currTrueCD4);
tracer->printTrace(1, " %d init HVL: %s, setpt: %s;\n", patient->getGeneralState()->monthNum,
SimContext::HVL_STRATA_STRS[patient->getDiseaseState()->currTrueHVLStrata],
SimContext::HVL_STRATA_STRS[patient->getDiseaseState()->setpointHVLStrata]);
}//end if we're tracing the patient
}//end if patient is an adult or adolescent
/** Or process a Pediatric infection: only occurs in early childhood, during bf*/
else{
//If they were false positive they are now true positive
if (patient->getPedsState()->isFalsePositive){
setFalsePositiveStatus(false, false);
if (patient->getGeneralState()->tracingEnabled)
tracer->printTrace(1, "**%d EID patient no longer false positive\n", patient->getGeneralState()->monthNum);
}
/** - Update pediatrics and regular HIV state to positive */
setInfectedPediatricsHIVState(SimContext::PEDS_HIV_POS_PP, false);
setInfectedHIVState(SimContext::HIV_INF_ACUTE_SYN, false, true);
setDetectedHIVState(false);
/** - Set the initial CD4 percentage for the newly infected infant */
int ageCatInfant = getAgeCategoryInfant(patient->getGeneralState()->ageMonths);
double percCD4Mean = simContext->getPedsInputs()->initialCD4PercentagePPMean[ageCatInfant];
double percCD4StdDev = simContext->getPedsInputs()->initialCD4PercentagePPStdDev[ageCatInfant];
double percCD4 = CepacUtil::getRandomGaussian(percCD4Mean, percCD4StdDev, 90066, patient);
setTrueCD4Percentage(percCD4, true);
/** - Set the initial childhood HVL setpoint */
SimContext::HVL_STRATA hvlStrata = SimContext::HVL_VLO;
double randNum = CepacUtil::getRandomDouble(90067, patient);
for (int i = SimContext::HVL_NUM_STRATA - 1; i >= 0; i--) {
if ((simContext->getPedsInputs()->initialHVLDistributionPP[ageCatInfant][i] != 0) &&
(randNum < simContext->getPedsInputs()->initialHVLDistributionPP[ageCatInfant][i])) {
hvlStrata = (SimContext::HVL_STRATA) i;
break;
}
randNum -= simContext->getPedsInputs()->initialHVLDistributionPP[ageCatInfant][i];
}
setTrueHVLStrata(hvlStrata);
setSetpointHVLStrata(hvlStrata);
setTargetHVLStrata(hvlStrata);
/** - Print tracing information for infection and the initial CD4/HVL */
if (patient->getGeneralState()->tracingEnabled) {
tracer->printTrace(1, "**%d HIV INFECTION;\n", patient->getGeneralState()->monthNum);
tracer->printTrace(1, " %d init CD4 perc: %1.3f;\n", patient->getGeneralState()->monthNum,
patient->getDiseaseState()->currTrueCD4Percentage);
tracer->printTrace(1, " %d init HVL: %s, setpt: %s;\n", patient->getGeneralState()->monthNum,
SimContext::HVL_STRATA_STRS[patient->getDiseaseState()->currTrueHVLStrata],
SimContext::HVL_STRATA_STRS[patient->getDiseaseState()->setpointHVLStrata]);
}
}//end if patient is pediatric
}/* end performHIVNewInfectionUpdates*/
/** \brief performAcuteToChronicHIVUpdates handles the transition from acute to chronic HIV */
void HIVInfectionUpdater::performAcuteToChronicHIVUpdates() {
/** Set the infection state based on the prior OI history (symptomatic or asymptomatic)*/
if (patient->getDiseaseState()->typeTrueOIHistory == SimContext::HIST_EXT_N) {
setInfectedHIVState(SimContext::HIV_INF_ASYMP_CHR_POS, false, false);
}
else {
setInfectedHIVState(SimContext::HIV_INF_SYMP_CHR_POS, false, false);
}
if (!patient->getGeneralState()->isPediatric){
if(simContext->getHIVTestInputs()->enableHIVTesting){
SimContext::HVL_STRATA hvlStrata = patient->getDiseaseState()->currTrueHVLStrata;
/** Update the true CD4 levels according to the chronic transition parameters */
double cd4ChangeMean = simContext->getHIVTestInputs()->CD4ChangeAtChronicHIVMean[hvlStrata];
double cd4ChangeStdDev = simContext->getHIVTestInputs()->CD4ChangeAtChronicHIVStdDev[hvlStrata];
double cd4Change = CepacUtil::getRandomGaussian(cd4ChangeMean, cd4ChangeStdDev, 90090, patient);
setTrueCD4(patient->getDiseaseState()->currTrueCD4 + cd4Change);
/** Update setpoint HVL level based on the specified distribution of current to new levels */
SimContext::HVL_STRATA hvlSetpoint = patient->getDiseaseState()->setpointHVLStrata;
double randNum = CepacUtil::getRandomDouble(90100, patient);
for (int i = 0; i < SimContext::HVL_NUM_STRATA; i++) {
if ((simContext->getHIVTestInputs()->HVLDistributionAtChronicHIV[hvlSetpoint][i] > 0) &&
(randNum < simContext->getHIVTestInputs()->HVLDistributionAtChronicHIV[hvlSetpoint][i])) {
hvlSetpoint = (SimContext::HVL_STRATA) i;
setSetpointHVLStrata(hvlSetpoint);
break;
}
randNum -= simContext->getHIVTestInputs()->HVLDistributionAtChronicHIV[hvlSetpoint][i];
}
/** If patient is not on ART or is on failed ART, set true and target HVL to the setpoint level */
if (!patient->getARTState()->isOnART || (patient->getARTState()->currRegimenEfficacy == SimContext::ART_EFF_FAILURE)) {
setTrueHVLStrata(hvlSetpoint);
setTargetHVLStrata(hvlSetpoint);
}
/** Print out trace information about transition for those in adult age category*/
if (patient->getGeneralState()->tracingEnabled) {
tracer->printTrace(1, "**%d HIV ACUTE TO CHR: CD4 %1.0f, HVLsetpt %s;\n",
patient->getGeneralState()->monthNum, patient->getDiseaseState()->currTrueCD4,
SimContext::HVL_STRATA_STRS[patient->getDiseaseState()->setpointHVLStrata]);
}
}
}
/** Print out separate trace information about transition for those in late childhood or early childhood age categories, for whom the transition has no clinical meaning*/
else if (patient->getGeneralState()->tracingEnabled){
if(patient->getPedsState()->ageCategoryPediatrics == SimContext::PEDS_AGE_LATE){
tracer->printTrace(1, "**%d PEDIATRIC HIV ACUTE TO CHR: CD4 %1.0f, HVLsetpt %s;\n",
patient->getGeneralState()->monthNum, patient->getDiseaseState()->currTrueCD4,
SimContext::HVL_STRATA_STRS[patient->getDiseaseState()->setpointHVLStrata]);
}
else{
tracer->printTrace(1, "**%d PEDIATRIC HIV ACUTE TO CHR: HVLsetpt %s;\n",
patient->getGeneralState()->monthNum,
SimContext::HVL_STRATA_STRS[patient->getDiseaseState()->setpointHVLStrata]);
}
}
} /* end performAcuteToChronicHIVUpdates */
/** \brief performPediatricDiseaseUpdates determines maternal updates, early to late childhood transition, and late childhood to adolescent or adult transitions */
void HIVInfectionUpdater::performPediatricDiseaseUpdates() {
if (patient->getPedsState()->isMotherAlive) {
/** Update breastfeeding status if the age at which to stop breastfeeding or age of exclusive/mixed to complementary transition is reached */
SimContext::PEDS_BF_TYPE bfType = patient->getPedsState()->breastfeedingStatus;
if (patient->getGeneralState()->ageMonths == patient->getPedsState()->breastfeedingStopAge && bfType != SimContext::PEDS_BF_REPL) {
setBreastfeedingStatus(SimContext::PEDS_BF_REPL);
if (patient->getGeneralState()->tracingEnabled) {
tracer->printTrace(1, "**%d PEDS BREASTFEEDING STATUS: %s\n", patient->getGeneralState()->monthNum, SimContext::PEDS_BF_TYPE_STRS[patient->getPedsState()->breastfeedingStatus]);
}
}
else if ((bfType == SimContext::PEDS_BF_EXCL || bfType == SimContext::PEDS_BF_MIXED) && (patient->getGeneralState()->ageMonths == SimContext::PEDS_BF_STOP_EXCL_MIXED)) {
setBreastfeedingStatus(SimContext::PEDS_BF_COMP);
if (patient->getGeneralState()->tracingEnabled) {
tracer->printTrace(1, "**%d PEDS BREASTFEEDING STATUS: %s\n", patient->getGeneralState()->monthNum, SimContext::PEDS_BF_TYPE_STRS[patient->getPedsState()->breastfeedingStatus]);
}
}
/** Handle transitions in maternal HIV infection state */
SimContext::PEDS_MATERNAL_STATUS momHIVState = patient->getPedsState()->maternalStatus;
if (momHIVState == SimContext::PEDS_MATERNAL_STATUS_NEG) {
/** Roll for incident maternal infection if HIV-negative */
rollForMaternalInfection();
}
if ((momHIVState == SimContext::PEDS_MATERNAL_STATUS_ACUTE) &&
(patient->getGeneralState()->monthNum == patient->getPedsState()->monthOfMaternalHIVInfection + SimContext::PEDS_MOM_MTHS_ACUTE)) {
/** If mom's acute time period is reached, transition to chronic CD4>350 (chronic high)*/
setMaternalHIVState(SimContext::PEDS_MATERNAL_STATUS_CHR_HIGH, false, false);
if (patient->getGeneralState()->tracingEnabled) {
tracer->printTrace(1, "**%d MATERNAL TRANSITION CHRONIC HIV: %s\n", patient->getGeneralState()->monthNum, SimContext::PEDS_BF_TYPE_STRS[patient->getPedsState()->breastfeedingStatus]);
}
}
/** Roll for maternal mortality */
momHIVState = patient->getPedsState()->maternalStatus;
double randNum = CepacUtil::getRandomDouble(90106, patient);
if (randNum < simContext->getPedsInputs()->probMaternalDeath[momHIVState]) {
setMaternalDeath();
if (patient->getGeneralState()->tracingEnabled) {
tracer->printTrace(1, "**%d MATERNAL DEATH\n", patient->getGeneralState()->monthNum);
}
}
// Update HIV never exposed status based on the updated maternal and patient status
if(patient->getPedsState()->ageCategoryPediatrics < SimContext::PEDS_AGE_LATE &&patient->getDiseaseState()->infectedPediatricsHIVState == SimContext::PEDS_HIV_NEG){
updatePedsNeverExposed();
}
//Roll for status becoming known during BF
if (patient->getPedsState()->isMotherAlive && (patient->getPedsState()->maternalStatus != SimContext::PEDS_MATERNAL_STATUS_NEG)
&& (patient->getPedsState()->breastfeedingStatus != SimContext::PEDS_BF_REPL)){
double randNum = CepacUtil::getRandomDouble(90108, patient);
if (!patient->getPedsState()->maternalStatusKnown && randNum < simContext->getPedsInputs()->probMotherStatusBecomeKnown[momHIVState]){
setMaternalStatusKnown(true);
if (patient->getGeneralState()->tracingEnabled) {
tracer->printTrace(1, "**%d MATERNAL HIV Status Known\n", patient->getGeneralState()->monthNum);
}
}
}
//Roll for Maternal ART status among breastfeeding women if known
if (simContext->getPedsInputs()->usePPMaternalARTStatus &&
patient->getPedsState()->isMotherAlive &&
(patient->getPedsState()->maternalStatus != SimContext::PEDS_MATERNAL_STATUS_NEG) &&
(patient->getPedsState()->breastfeedingStatus != SimContext::PEDS_BF_REPL) &&
patient->getPedsState()->maternalStatusKnown){
int ageCatPP = patient->getGeneralState()->ageMonths;
if (ageCatPP >= SimContext::PEDS_PP_MATERNAL_ART_STATUS_NUM)
ageCatPP = SimContext::PEDS_PP_MATERNAL_ART_STATUS_NUM -1;
//Roll for maternal suppression status known
randNum = CepacUtil::getRandomDouble(90109, patient);
bool suppressionKnown = false;
if (randNum < simContext->getPedsInputs()->ppMaternalARTStatusProbSuppressionKnown[ageCatPP])
suppressionKnown = true;
randNum = CepacUtil::getRandomDouble(90109, patient);
//Roll for mother being on suppressed ART
if (randNum < simContext->getPedsInputs()->ppMaternalARTStatusProbSuppressed[ageCatPP]){
setMaternalARTStatus(true, true, suppressionKnown, false);
if (patient->getGeneralState()->tracingEnabled) {
tracer->printTrace(1, "**%d MOTHER ON SUPPRESSED ART\n", patient->getGeneralState()->monthNum);
}
}
//If mother is not on suppressed ART, the other options are on ART unsuppressed with either Low or High HVL and off ART
else{
randNum -= simContext->getPedsInputs()->ppMaternalARTStatusProbSuppressed[ageCatPP];
if(randNum < simContext->getPedsInputs()->ppMaternalARTStatusProbNotSuppressedLowHVL[ageCatPP]){
setMaternalARTStatus(true, false, suppressionKnown,false);
setMaternalHVLStatus(true);
if (patient->getGeneralState()->tracingEnabled) {
tracer->printTrace(1, "**%d MOTHER ON NON SUPPRESSED ART LOW HVL\n", patient->getGeneralState()->monthNum);
}
}
else{
randNum -=simContext->getPedsInputs()->ppMaternalARTStatusProbNotSuppressedLowHVL[ageCatPP];
if (randNum < simContext->getPedsInputs()->ppMaternalARTStatusProbNotSuppressedHighHVL[ageCatPP]){
setMaternalARTStatus(true, false, suppressionKnown,false);
setMaternalHVLStatus(false);
if (patient->getGeneralState()->tracingEnabled) {
tracer->printTrace(1, "**%d MOTHER ON NON SUPPRESSED ART HIGH HVL\n", patient->getGeneralState()->monthNum);
}
}
else{
setMaternalARTStatus(false, false, false, false);
if (patient->getGeneralState()->tracingEnabled) {
tracer->printTrace(1, "**%d MOTHER OFF ART\n", patient->getGeneralState()->monthNum);
}
}
}
}
//Roll for stop BF upon status known not supp
if (patient->getPedsState()->motherOnART && !patient->getPedsState()->motherOnSuppressedART && patient->getPedsState()->motherSuppressionKnown){
randNum = CepacUtil::getRandomDouble(90009, patient);
double prob = 0;
if (patient->getPedsState()->motherLowHVL)
prob = simContext->getPedsInputs()->probStopBFNotSuppressedLowHVL;
else
prob = simContext->getPedsInputs()->probStopBFNotSuppressedHighHVL;
if (randNum < prob){
setBreastfeedingStatus(SimContext::PEDS_BF_REPL);
if (patient->getGeneralState()->tracingEnabled) {
tracer->printTrace(1, "**%d PEDS BREASTFEEDING STATUS: %s\n", patient->getGeneralState()->monthNum, SimContext::PEDS_BF_TYPE_STRS[patient->getPedsState()->breastfeedingStatus]);
}
}
}
} // end of updates to maternal ART and breastfeeding status if using PP maternal ART status and mother HIV+
} //end if mother is alive at the beginning of the month
/** Check for receiving HIV infant proph if not linked to care - can't receive it if they have switched to adult HIV tests due to the effects on sensitivity and specificity of HIV tests */
bool ageEligible = false;
if ((!simContext->getHIVTestInputs()->enableHIVTesting || patient->getGeneralState()->ageMonths < simContext->getHIVTestInputs()->HIVRegularTestingStartAge))
ageEligible = true;
if (simContext->getEIDInputs()->enableHIVTestingEID && ageEligible && (patient->getMonitoringState()->careState < SimContext::HIV_CARE_IN_CARE)){
// For each Infant HIV Prophylaxis regimen
for (int i = 0; i < SimContext::INFANT_HIV_PROPHS_NUM; ++i){
const SimContext::EIDInputs::InfantHIVProph &infantProph = simContext->getEIDInputs()->infantHIVProphs[i];
//don't do anything if proph not enabled
if (!infantProph.infantProphEnabled)
continue;
// Check for receiving a dose of infant HIV prophylaxis if patient is breastfeeding
if(patient->getPedsState()->isMotherAlive &&
patient->getPedsState()->breastfeedingStatus != SimContext::PEDS_BF_REPL){
int ageCatProph = patient->getGeneralState()->ageMonths;
if (ageCatProph >= SimContext::INFANT_PROPH_AGES_NUM)
ageCatProph = SimContext::INFANT_PROPH_AGES_NUM-1;
double randNum = CepacUtil::getRandomDouble(90009, patient);
//Roll for getting infant proph, if so check EID policy
if (randNum < infantProph.infantProphProb[ageCatProph]){
int negEIDMonths = infantProph.infantProphNegEIDMonths[ageCatProph];
bool passesEID = false;
// Check test requirements, starting with whether a positive EID test result will disqualify them, then whether a negative result is required
if (!infantProph.infantProphEligibilityStopOnPosEID || !patient->getPedsState()->hasMostRecentPositiveEIDTest){
if (negEIDMonths==SimContext::NOT_APPL)
passesEID = true;
else{
if(patient->getPedsState()->hasMostRecentNegativeEIDTest){
int timeSinceNegEID = patient->getGeneralState()->monthNum - patient->getPedsState()->monthOfMostRecentNegativeEIDTest;
if (timeSinceNegEID <= negEIDMonths)
passesEID = true;
}
}
}
// Check major tox eligibility
if (passesEID && evaluatePedsHIVProphPolicy(infantProph) &&
!(infantProph.infantProphMajorToxStopOnTox && patient->getPedsState()->hasInfantHIVProphMajorToxicity[i])){
//Add cost
int costAgeCat = getAgeCategoryInfantHIVProphCost(patient->getGeneralState()->ageMonths);
if (!patient->getPedsState()->everInfantHIVProph[i])
incrementCostsInfantHIVProphDirect(infantProph.infantProphStartupCost[costAgeCat]);
incrementCostsInfantHIVProphDirect(infantProph.infantProphDoseCost[costAgeCat]);
//Tox only happens on the first dose, but the death rate ratio has a duration
if (!patient->getPedsState()->everInfantHIVProph[i]){
/** Infant Proph Toxicities - both major and minor may occur */
double probMajorTox = infantProph.infantProphMajorToxProb;
double probMinorTox = infantProph.infantProphMinorToxProb;
/** Roll for major toxicity occurring */
double randNum = CepacUtil::getRandomDouble(90009, patient);
if (randNum < probMajorTox) {
setInfantHIVProphMajorToxicity(i,true);
accumulateQOLModifier(infantProph.infantProphMajorToxQOLMod);
incrementCostsInfantHIVProphTox(infantProph.infantProphMajorToxCost);
// Print tracing information if enabled
if (patient->getGeneralState()->tracingEnabled) {
tracer->printTrace(1, "**%d MAJ TOX: INFANT HIV PROPH, %1.2lf QAred, $ %1.0lf;\n",
patient->getGeneralState()->monthNum, patient->getGeneralState()->QOLValue,
patient->getGeneralState()->costsDiscounted);
}
}
/** Roll for minor toxicity occurring */
randNum = CepacUtil::getRandomDouble(90011, patient);
if(randNum < probMinorTox){
accumulateQOLModifier(infantProph.infantProphMinorToxQOLMod);
incrementCostsInfantHIVProphTox(infantProph.infantProphMinorToxCost);
// Print tracing information if enabled
if (patient->getGeneralState()->tracingEnabled) {
tracer->printTrace(1, "**%d MIN TOX: INFANT HIV PROPH %d, %1.2lf QAred, $ %1.0lf;\n",
patient->getGeneralState()->monthNum, i, patient->getGeneralState()->QOLValue,
patient->getGeneralState()->costsDiscounted);
}
}
}
//Roll for dose efficacy
bool isEff = false;
randNum = CepacUtil::getRandomDouble(90009, patient);
if (randNum < patient->getPedsState()->probHIVProphEffective[i])
isEff = true;
setInfantHIVProph(i, true, isEff);
if (isEff){
//Set next dose efficacy
setInfantHIVProphEffProb(i, patient->getPedsState()->probHIVProphEffective[i] * infantProph.infantProphProbEff);
}
if (patient->getGeneralState()->tracingEnabled) {
tracer->printTrace(1, "**%d INFANT HIV PROPH %d Administered: Dose %s\n", patient->getGeneralState()->monthNum, i, isEff?"Succeeds":"Fails");
}
} //end of administering infant HIV proph dose
} // end of rolling for whether to get an infant HIV proph dose
} // end if patient is breastfeeding
/** Check whether the risk of death from HIV infant proph from a past dose is still active and add the death rate ratio if applicable*/
if(patient->getPedsState()->hasInfantHIVProphMajorToxicity[i] && patient->getGeneralState()->monthNum - patient->getPedsState()->monthOfInfantHIVProphMajorToxicity[i] < infantProph.infantProphMajorToxDeathRateRatioDuration){
if(infantProph.infantProphMajorToxDeathRateRatio > 1.0) {
addMortalityRisk(SimContext::DTH_TOX_INFANT_HIV_PROPH, infantProph.infantProphMajorToxDeathRateRatio, infantProph.infantProphMajorToxDeathCost);
}
}
} // end code for this proph line and move on to next
} // end if EID is enabled
/** Handle conversions if this is the month of transition from early to late childhood */
if ((patient->getDiseaseState()->infectedPediatricsHIVState != SimContext::PEDS_HIV_NEG) &&
(patient->getGeneralState()->ageMonths == (SimContext::PEDS_YEAR_EARLY * 12))) {
// If they started at the age category boundary of age 5, there is no need to transition between early and late childhood and it's too soon to transition to adult, so return
if(patient->getGeneralState()->monthNum == patient->getGeneralState()->initialMonthNum){
return;
}
/** - Convert the CD4 percentage to an absolute CD4 value */
SimContext::PEDS_CD4_PERC cd4PercStrata = patient->getDiseaseState()->currTrueCD4PercentageStrata;
double cd4Mean = simContext->getPedsInputs()->absoluteCD4TransitionMean[cd4PercStrata];
double cd4StdDev = simContext->getPedsInputs()->absoluteCD4TransitionStdDev[cd4PercStrata];
double cd4Value = CepacUtil::getRandomGaussian(cd4Mean, cd4StdDev, 90110, patient);
setTrueCD4(cd4Value, true);
// Update CD4 envelope types from CD4 percentage to absolute CD4 count if they are active
if (patient->getARTState()->overallCD4PercentageEnvelope.isActive){
setCD4EnvelopeRegimen(SimContext::ENVL_CD4_OVERALL,patient->getARTState()->overallCD4PercentageEnvelope.regimenNum, patient->getARTState()->overallCD4PercentageEnvelope.monthOfStart);
}
if (patient->getARTState()->indivCD4PercentageEnvelope.isActive){
setCD4EnvelopeRegimen(SimContext::ENVL_CD4_INDIV,patient->getARTState()->indivCD4PercentageEnvelope.regimenNum, patient->getARTState()->indivCD4PercentageEnvelope.monthOfStart);
}
/** If patient is on ART and suppressed, update the actual CD4 slope */
if (patient->getARTState()->isOnART && (patient->getARTState()->currRegimenEfficacy == SimContext::ART_EFF_SUCCESS)) {
//draw for a CD4 slope
int monthsSinceRegimenStart = patient->getGeneralState()->monthNum - patient->getARTState()->monthOfCurrRegimenStart;
double cd4Slope = drawCD4Slope(patient->getARTState()->currRegimenNum, monthsSinceRegimenStart);
setCurrRegimenCD4Slope(cd4Slope);
}
// Update the CD4 envelope slopes if active - the individual envelope cannot be active without the overall envelope being active
if(patient->getARTState()->overallCD4Envelope.isActive)
performCD4EnvelopeAgeTransition(true, patient->getARTState()->indivCD4Envelope.isActive);
/** - Convert the childhood HVL setpoint to the adult setpoint HVL value */
SimContext::HVL_STRATA currSetpoint = patient->getDiseaseState()->setpointHVLStrata;
SimContext::HVL_STRATA newSetpoint = currSetpoint;
double randNum = CepacUtil::getRandomDouble(90120, patient);
for (int i = 0; i < SimContext::HVL_NUM_STRATA; i++) {
if ((simContext->getPedsInputs()->setpointHVLTransition[currSetpoint][i] > 0) &&
(randNum < simContext->getPedsInputs()->setpointHVLTransition[currSetpoint][i])) {
newSetpoint = (SimContext::HVL_STRATA) i;
break;
}
randNum -= simContext->getPedsInputs()->setpointHVLTransition[currSetpoint][i];
}
setSetpointHVLStrata(newSetpoint);
/** - If not on ART or on failed ART, also set the true HVL to the new setpoint */
if (!patient->getARTState()->isOnART || (patient->getARTState()->currRegimenEfficacy == SimContext::ART_EFF_FAILURE)) {
setTrueHVLStrata(newSetpoint);
setTargetHVLStrata(newSetpoint);
}
/** - Reset observed CD4 percentage and HVL values, the early childhood ones are no longer relevant */
setObservedCD4Percentage(false);