private void CalculateSerialAlgorithm() { double totalHIVPostoContinue, totalHIVNegativetoContinue; double HIVPostoContinueTiebreaker, HIVNegativetoContinueTiebreaker; for (int i = 0; i < 12; i++) { MOutputRapidTest rapidout = new MOutputRapidTest(i + 1); rapidout.HIVAdultsThatDonotFollowup = _adultsThatdonotFollowup; rapidout.HIVPediatrcisThatDonotFollowup = _pediatrcisThatdonotFollowup; rapidout.PrevalenceOfAdultTestingPop = _prevalenceofAdultTestingPop; rapidout.PrevalenceOfPediatricTestingPop = _prevalenceofPediatricTestingPop; rapidout.AdultsEnteringTreatment = CalculatedPatientNos[i + 1].AdultEnteringARTfromoutsidePreART; rapidout.AdultsEnteringPreART = CalculatedPatientNos[i + 1].AdultEnteringpreARTeachmonth; rapidout.PediatricsEnteringTreatment = CalculatedPatientNos[i + 1].PediatricEnteringARTfromoutsidePreART; rapidout.PediatricsEnteringPreART = CalculatedPatientNos[i + 1].PediatricEnteringpreARTeachmonth; _screeningTests[i, 0] = rapidout.TotalPatientsToScreen * (ArtSite.ScrTest1Percent / 100d); _screeningTests[i, 1] = rapidout.TotalPatientsToScreen * (ArtSite.ScrTest2Percent / 100d); _screeningTests[i, 2] = rapidout.TotalPatientsToScreen * (ArtSite.ScrTest3Percent / 100d); totalHIVPostoContinue = (ArtSite.ScrTest1Percent / 100d) * rapidout.HIVPositivePopulation * RTestAlgorithm.ScreeningTestSensitivty(1); totalHIVPostoContinue += (ArtSite.ScrTest2Percent / 100d) * rapidout.HIVPositivePopulation * RTestAlgorithm.ScreeningTestSensitivty(2); totalHIVPostoContinue += (ArtSite.ScrTest3Percent / 100d) * rapidout.HIVPositivePopulation * RTestAlgorithm.ScreeningTestSensitivty(3); totalHIVNegativetoContinue = (ArtSite.ScrTest1Percent / 100d) * rapidout.HIVNegativePopulation * RTestAlgorithm.ScreeningTestFalsePositive(1); totalHIVNegativetoContinue += (ArtSite.ScrTest2Percent / 100d) * rapidout.HIVNegativePopulation * RTestAlgorithm.ScreeningTestFalsePositive(2); totalHIVNegativetoContinue += (ArtSite.ScrTest3Percent / 100d) * rapidout.HIVNegativePopulation * RTestAlgorithm.ScreeningTestFalsePositive(3); _confirmateryTests[i, 0] = (totalHIVPostoContinue + totalHIVNegativetoContinue) * (ArtSite.ConTest1Percent / 100d); _confirmateryTests[i, 1] = (totalHIVPostoContinue + totalHIVNegativetoContinue) * (ArtSite.ConTest2Percent / 100d); _confirmateryTests[i, 2] = (totalHIVPostoContinue + totalHIVNegativetoContinue) * (ArtSite.ConTest3Percent / 100d); HIVPostoContinueTiebreaker = (ArtSite.ConTest1Percent / 100d) * totalHIVPostoContinue * RTestAlgorithm.ConfirmatoryTestFalseNegative(1); HIVPostoContinueTiebreaker += (ArtSite.ConTest2Percent / 100d) * totalHIVPostoContinue * RTestAlgorithm.ConfirmatoryTestFalseNegative(2); HIVPostoContinueTiebreaker += (ArtSite.ConTest3Percent / 100d) * totalHIVPostoContinue * RTestAlgorithm.ConfirmatoryTestFalseNegative(3); HIVNegativetoContinueTiebreaker = (ArtSite.ConTest1Percent / 100d) * totalHIVNegativetoContinue * RTestAlgorithm.ConfirmatoryTestSpecificity(1); HIVNegativetoContinueTiebreaker += (ArtSite.ConTest2Percent / 100d) * totalHIVNegativetoContinue * RTestAlgorithm.ConfirmatoryTestSpecificity(2); HIVNegativetoContinueTiebreaker += (ArtSite.ConTest3Percent / 100d) * totalHIVNegativetoContinue * RTestAlgorithm.ConfirmatoryTestSpecificity(3); _tiebreakerTests[i, 0] = (HIVPostoContinueTiebreaker + HIVNegativetoContinueTiebreaker) * (ArtSite.TieTest1Percent / 100d); _tiebreakerTests[i, 1] = (HIVPostoContinueTiebreaker + HIVNegativetoContinueTiebreaker) * (ArtSite.TieTest2Percent / 100d); _tiebreakerTests[i, 2] = (HIVPostoContinueTiebreaker + HIVNegativetoContinueTiebreaker) * (ArtSite.TieTest3Percent / 100d); _rapidTestOutputs.Add(i + 1, rapidout); } AdjustRapidTestBufferStock(); }
private void CalculateParallelAlgorithm() { double[,] proToNextstage = new double[3, 2]; double proc, an, pn; for (int i = 1; i <= 3; i++) { proc = an = pn = 0; proc = RTestAlgorithm.ScreeningTestSensitivty(i) * RTestAlgorithm.ConfirmatoryTestSensitivty(i); an += RTestAlgorithm.BothPositiveProceed ? proc * _prevalenceofAdultTestingPop : 0; pn += RTestAlgorithm.BothPositiveProceed ? proc * _prevalenceofPediatricTestingPop : 0; proc = RTestAlgorithm.ScreeningTestSensitivty(i) * RTestAlgorithm.ConfirmatoryTestFalseNegative(i); an += RTestAlgorithm.DiscordantProceed ? proc * _prevalenceofAdultTestingPop : 0; pn += RTestAlgorithm.DiscordantProceed ? proc * _prevalenceofPediatricTestingPop : 0; proc = RTestAlgorithm.ScreeningTestFalseNegative(i) * RTestAlgorithm.ConfirmatoryTestSensitivty(i); an += RTestAlgorithm.DiscordantProceed ? proc * _prevalenceofAdultTestingPop : 0; pn += RTestAlgorithm.DiscordantProceed ? proc * _prevalenceofPediatricTestingPop : 0; proc = RTestAlgorithm.ScreeningTestFalseNegative(i) * RTestAlgorithm.ConfirmatoryTestFalseNegative(i); an += RTestAlgorithm.BothNegativeProceed ? proc * _prevalenceofAdultTestingPop : 0; pn += RTestAlgorithm.BothNegativeProceed ? proc * _prevalenceofPediatricTestingPop : 0; proc = RTestAlgorithm.ScreeningTestSpecificity(i) * RTestAlgorithm.ConfirmatoryTestSpecificity(i); an += RTestAlgorithm.BothNegativeProceed ? proc * (1 - _prevalenceofAdultTestingPop) : 0; pn += RTestAlgorithm.BothNegativeProceed ? proc * (1 - _prevalenceofPediatricTestingPop) : 0; proc = RTestAlgorithm.ScreeningTestSpecificity(i) * RTestAlgorithm.ConfirmatoryTestFalsePositive(i); an += RTestAlgorithm.DiscordantProceed ? proc * (1 - _prevalenceofAdultTestingPop) : 0; pn += RTestAlgorithm.DiscordantProceed ? proc * (1 - _prevalenceofPediatricTestingPop) : 0; proc = RTestAlgorithm.ScreeningTestFalsePositive(i) * RTestAlgorithm.ConfirmatoryTestSpecificity(i); an += RTestAlgorithm.DiscordantProceed ? proc * (1 - _prevalenceofAdultTestingPop) : 0; pn += RTestAlgorithm.DiscordantProceed ? proc * (1 - _prevalenceofPediatricTestingPop) : 0; proc = RTestAlgorithm.ScreeningTestFalsePositive(i) * RTestAlgorithm.ConfirmatoryTestFalsePositive(i); an += RTestAlgorithm.BothPositiveProceed ? proc * (1 - _prevalenceofAdultTestingPop) : 0; pn += RTestAlgorithm.BothPositiveProceed ? proc * (1 - _prevalenceofPediatricTestingPop) : 0; proToNextstage[i - 1, 0] = an; proToNextstage[i - 1, 1] = pn; } string[,] product = new string[9, 2]; product[0, 0] = ArtSite.ScrTest1.ToString(); product[1, 0] = ArtSite.ConTest1.ToString(); product[2, 0] = ArtSite.ScrTest2.ToString(); product[3, 0] = ArtSite.ConTest2.ToString(); product[4, 0] = ArtSite.ScrTest3.ToString(); product[5, 0] = ArtSite.ConTest3.ToString(); product[6, 0] = ArtSite.TieTest1.ToString(); product[7, 0] = ArtSite.TieTest2.ToString(); product[8, 0] = ArtSite.TieTest3.ToString(); double s1, n1, s2, n2; for (int i = 0; i < 12; i++) { MOutputRapidTest rapidout = new MOutputRapidTest(i + 1); rapidout.HIVAdultsThatDonotFollowup = _adultsThatdonotFollowup; rapidout.HIVPediatrcisThatDonotFollowup = _pediatrcisThatdonotFollowup; rapidout.PrevalenceOfAdultTestingPop = _prevalenceofAdultTestingPop; rapidout.PrevalenceOfPediatricTestingPop = _prevalenceofPediatricTestingPop; rapidout.AdultsEnteringTreatment = CalculatedPatientNos[i + 1].AdultEnteringARTfromoutsidePreART; rapidout.AdultsEnteringPreART = CalculatedPatientNos[i + 1].AdultEnteringpreARTeachmonth; rapidout.PediatricsEnteringTreatment = CalculatedPatientNos[i + 1].PediatricEnteringARTfromoutsidePreART; rapidout.PediatricsEnteringPreART = CalculatedPatientNos[i + 1].PediatricEnteringpreARTeachmonth; _rapidTestOutputs.Add(i + 1, rapidout); s1 = rapidout.TotalAdultsTested * (ArtSite.ScrTest1Percent / 100d); // _totalPositiveToscreen[i, 1] * (ArtSite.ScrTest1Percent / 100d); n1 = s1 * proToNextstage[0, 0]; s2 = rapidout.TotalPediatricsTested * (ArtSite.ScrTest1Percent / 100d); // _totalPositiveToscreen[i, 2] * (ArtSite.ScrTest1Percent / 100d); n2 = s2 * proToNextstage[0, 1]; product[0, 1] = (s1 + s2).ToString(); product[1, 1] = (s1 + s2).ToString(); s1 = rapidout.TotalAdultsTested * (ArtSite.ScrTest2Percent / 100d); //_totalPositiveToscreen[i, 1] * (ArtSite.ScrTest2Percent / 100d); n1 += s1 * proToNextstage[1, 0]; s2 = rapidout.TotalPediatricsTested * (ArtSite.ScrTest2Percent / 100d); //_totalPositiveToscreen[i, 2] * (ArtSite.ScrTest2Percent / 100d); n2 += s2 * proToNextstage[1, 1]; product[2, 1] = (s1 + s2).ToString(); product[3, 1] = (s1 + s2).ToString(); s1 = rapidout.TotalAdultsTested * (ArtSite.ScrTest3Percent / 100d); //_totalPositiveToscreen[i, 1] * (ArtSite.ScrTest3Percent / 100d); n1 += s1 * proToNextstage[2, 0]; s2 = rapidout.TotalPediatricsTested * (ArtSite.ScrTest3Percent / 100d); //_totalPositiveToscreen[i, 2] * (ArtSite.ScrTest3Percent / 100d); n2 += s2 * proToNextstage[2, 1]; product[4, 1] = (s1 + s2).ToString(); product[5, 1] = (s1 + s2).ToString(); product[6, 1] = (n1 + n2).ToString(); product[7, 1] = (n1 + n2).ToString(); product[8, 1] = (n1 + n2).ToString(); _screeningTests[i, 0] = SumByProductId(ArtSite.ScrTest1, product, 0, 5); _screeningTests[i, 1] = SumByProductId(ArtSite.ScrTest2, product, 0, 5); _screeningTests[i, 2] = SumByProductId(ArtSite.ScrTest3, product, 0, 5); _confirmateryTests[i, 0] = SumByProductId(ArtSite.ConTest1, product, 0, 5); _confirmateryTests[i, 1] = SumByProductId(ArtSite.ConTest2, product, 0, 5); _confirmateryTests[i, 2] = SumByProductId(ArtSite.ConTest3, product, 0, 5); _tiebreakerTests[i, 0] = (ArtSite.TieTest1Percent / 100d) * SumByProductId(ArtSite.TieTest1, product, 6, 8); _tiebreakerTests[i, 1] = (ArtSite.TieTest2Percent / 100d) * SumByProductId(ArtSite.TieTest2, product, 6, 8); _tiebreakerTests[i, 2] = (ArtSite.TieTest3Percent / 100d) * SumByProductId(ArtSite.TieTest3, product, 6, 8); } AdjustRapidTestBufferStock(); }