private void DoQuantification() { //DOES THIS SITE RECEIVE Chemistry SUPPLIES? if (ArtSite.ForecastVCT) { double value; foreach (QuantifyMenu qm in _platformObject.GeneralQuantifyMenus) { value = 0; if (qm.Title == GeneralQuantifyMenuEnum.Total_Rapid_Tests.ToString()) { value = _s1 + _s2 + _s3 + _c1 + _c2 + _c3 + _t1 + _t2 + _t3; } else if (qm.Title == GeneralQuantifyMenuEnum.Total_Screenings.ToString()) { value = _s1 + _s2 + _s3; } if (qm.Title == GeneralQuantifyMenuEnum.Total_Confirmatory_Tests.ToString()) { value = _c1 + _c2 + _c3; } if (qm.Title == GeneralQuantifyMenuEnum.Total_Tie_Breaker_Tests.ToString()) { value = _t1 + _t2 + _t3; } if (qm.Title == GeneralQuantifyMenuEnum.Total_Screenings_Plus_Confirmatory.ToString()) { value = _s1 + _s2 + _s3 + _c1 + _c2 + _c3; } if (qm.Title == GeneralQuantifyMenuEnum.Total_Screenings_Plus_Tie_Breaker.ToString()) { value = _s1 + _s2 + _s3 + _t1 + _t2 + _t3; } if (qm.Title == GeneralQuantifyMenuEnum.Total_Confirmatory_Plus_Tie_Breaker.ToString()) { value = _c1 + _c2 + _c3 + _t1 + _t2 + _t3; } if (value > 0) { QMenuWithValue qval = new QMenuWithValue(); qval.QuantifyMenuId = qm.Id; qval.SiteValue = value; qval.ReferalSiteValue = 0; _listOfQMenuWithValue.Add(qval); } } for (int i = 1; i <= 3; i++) { int prodcutId = RTestAlgorithm.GetProductId(TestingSpecificationGroup.Screening, i); if (prodcutId > 0) { QuantifyMenu pqm = _platformObject.GetQuantifyMenuByProductId(prodcutId); QMenuWithValue qval = new QMenuWithValue(); qval.QuantifyMenuId = pqm.Id; qval.ReferalSiteValue = 0; if (i == 1) { qval.SiteValue = _s1; } else if (i == 2) { qval.SiteValue = _s2; } else { qval.SiteValue = _s3; } _listOfQMenuWithValue.Add(qval); } prodcutId = RTestAlgorithm.GetProductId(TestingSpecificationGroup.Confirmatory, i); if (prodcutId > 0) { QuantifyMenu pqmC = _platformObject.GetQuantifyMenuByProductId(prodcutId); QMenuWithValue qvalC = new QMenuWithValue(); qvalC.QuantifyMenuId = pqmC.Id; qvalC.ReferalSiteValue = 0; if (i == 1) { qvalC.SiteValue = _c1; } else if (i == 2) { qvalC.SiteValue = _c2; } else { qvalC.SiteValue = _c3; } _listOfQMenuWithValue.Add(qvalC); } prodcutId = RTestAlgorithm.GetProductId(TestingSpecificationGroup.Tie_Breaker, i); if (prodcutId > 0) { QuantifyMenu pqmT = _platformObject.GetQuantifyMenuByProductId(prodcutId); QMenuWithValue qvalT = new QMenuWithValue(); qvalT.QuantifyMenuId = pqmT.Id; qvalT.ReferalSiteValue = 0; if (i == 1) { qvalT.SiteValue = _t1; } else if (i == 2) { qvalT.SiteValue = _t2; } else { qvalT.SiteValue = _t3; } _listOfQMenuWithValue.Add(qvalT); } } foreach (QMenuWithValue qm in _listOfQMenuWithValue) { IList <QuantificationMetric> list = _platformObject.GetQuanMetricByQuanMenuId(qm.QuantifyMenuId); foreach (QuantificationMetric r in list) { PrimeryQuantifyedReagent pqr = new PrimeryQuantifyedReagent(); pqr.ProductId = r.Product.Id; pqr.UnitCost = r.Product.GetActiveProductPrice(DateTime.Now).Price; pqr.PackSize = r.Product.GetActiveProductPrice(DateTime.Now).PackSize; pqr.Unit = r.Product.BasicUnit; double testperpack = r.Product.GetActiveProductPrice(DateTime.Now).PackSize / r.UsageRate; double valueofmetric = r.CollectionSupplieAppliedTo == CollectionSupplieAppliedToEnum.Collection.ToString() ? qm.SiteValue : qm.TotalValue; if (ArtSite.Site.CD4RefSite > 0 && r.CollectionSupplieAppliedTo == CollectionSupplieAppliedToEnum.Testing.ToString()) { valueofmetric = 0; } pqr.Value = testperpack > 0 ? valueofmetric / testperpack : 0; pqr.MinimumQuantity = r.Product.MinimumPackSize; _lstPrimaryQuanReagents.AddPrimeryQR(pqr); } } } }
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(); }