private void CalculateChemistryTestConducted() { _chemRepeatsduetoClinicianRequest = (ChemTestProtocol.TestReapeated / 100d); _chemAdditionalTestsDuetoWastage = (InvAssumption.Chemistry / 100d); for (int i = 1; i <= 12; i++) { MOutputChemistryTest chemOut = new MOutputChemistryTest(); chemOut.Month = i; foreach (PSymptomDirectedTest sdt in ChemTestProtocol.SymptomDirectedTests) { ChemistrySymptomDirectedTest csdt = new ChemistrySymptomDirectedTest(); csdt.TestId = sdt.Test.Id; csdt.AdultSymptomDirectTest = (CurrentAdultinTreatment * (sdt.AdultInTreatmeant / 100d)) / 12d; csdt.PedSymptomDirectTest = (CurrentPediatricinTreatment * (sdt.PediatricInTreatmeant / 100d)) / 12d; csdt.PreArtAdultSymptomDirectTest = (CurrentAdultinPreArt * (sdt.AdultPreART / 100d)) / 12d; csdt.PreArtPedSymptomDirectTest = (CurrentPediatricinPreArt * (sdt.PediatricPreART / 100d)) / 12d; csdt.RepeatPercent = _chemRepeatsduetoClinicianRequest; chemOut.ChemSymptomDirectedTest.Add(csdt); } foreach (ProtocolPanel panel in ChemTestProtocol.ProtocolPanels) { ChemistryTestByPannel chemp = new ChemistryTestByPannel(); chemp.ExistingAdultPatientsinTreatment = CalculatedPatientNos[i].ArtAdultPreExistingPatients * panel.AdultInTreatmentDistribution; chemp.ExistingPedPatientsinTreatment = CalculatedPatientNos[i].ArtPediatricPreExistingPatients * panel.PediatricInTreatmentDistribution; // ((pediatricsinTreatment / 12d) * preExistingPatientsonPanel); chemp.ExistingAdultPatientsinPreArt = CalculatedPatientNos[i].PreArtAdultPreExistingPatients * panel.AdultPreARTDistribution; chemp.ExistingPedPatientsinPreArt = CalculatedPatientNos[i].PreArtPediatricPreExistingPatients * panel.PediatricPreARTDistribution; for (int x = 1, y = i; x <= i; x++, y--) { chemp.NewAdultPatientstoTreatment += CalculatedPatientNos[i].GetArtAdultPatientsEntering(x) * panel.AdultArtTestGivenInMonth(y) * (panel.AITNewPatient / 100d); chemp.NewPedPatientstoTreatment += CalculatedPatientNos[i].GetArtPediatricPatientsEntering(x) * panel.PediatricArtTestGivenInMonth(y) * (panel.PITNewPatient / 100d); chemp.NewAdultPatientstoPreArt += CalculatedPatientNos[i].GetPreArtAdultPatientsEntering(x) * panel.AdultPreArtTestGivenInMonth(y) * (panel.APARTNewPatient / 100d); chemp.NewPedPatientstoPreArt += CalculatedPatientNos[i].GetPreArtPediatricPatientsEntering(x) * panel.PediatricPreArtTestGivenInMonth(y) * (panel.PPARTNewPatient / 100d); } //ChemistryTestNameEnum[] chemtest = LqtUtil.EnumToArray<ChemistryTestNameEnum>(); //for (int z = 0; z < chemtest.Length; z++) foreach (Test t in _testingArea.Tests) { double tconducted = 0d; if (panel.IsTestSelected(t.Id)) { tconducted = chemp.TotalTestsForRegimen(); } chemp.SetChemTestValue(t.Id, tconducted); if (chemOut.GetChemSymptomDirectedTestById(t.Id) != null) { chemOut.GetChemSymptomDirectedTestById(t.Id).TestConducted += tconducted; } } chemOut.ChemTestByPanel.Add(chemp); } _chemMonthlyOutputs.Add(i, chemOut); } double adultPatientEnterPerMonth = 0d; double pedPatientEnterPerMonth = 0d; double preAdultPatientEnterPerMonth = 0d; double prePedPatientEnterPerMonth = 0d; foreach (PSymptomDirectedTest sdt in ChemTestProtocol.SymptomDirectedTests) { for (int i = 1; i <= 12; i++) { ChemistrySymptomDirectedTest csdt = _chemMonthlyOutputs[i].GetChemSymptomDirectedTestById(sdt.Test.Id); adultPatientEnterPerMonth = (CalculatedPatientNos[i].GetArtAdultPatientsEntering(i) * (sdt.AdultInTreatmeant / 100d)) / 12d; csdt.AdultSymptomDirectTest += adultPatientEnterPerMonth; pedPatientEnterPerMonth = (CalculatedPatientNos[i].GetArtPediatricPatientsEntering(i) * (sdt.PediatricInTreatmeant / 100d)) / 12d; csdt.PedSymptomDirectTest += pedPatientEnterPerMonth; preAdultPatientEnterPerMonth = (CalculatedPatientNos[i].GetPreArtAdultPatientsEntering(i) * (sdt.AdultPreART / 100d)) / 12d; csdt.PreArtAdultSymptomDirectTest += preAdultPatientEnterPerMonth; prePedPatientEnterPerMonth = (CalculatedPatientNos[i].GetPreArtPediatricPatientsEntering(i) * (sdt.PediatricPreART / 100d)) / 12d; csdt.PreArtPedSymptomDirectTest += prePedPatientEnterPerMonth; for (int x = i + 1; x <= 12; x++) { ChemistrySymptomDirectedTest ct = _chemMonthlyOutputs[x].GetChemSymptomDirectedTestById(sdt.Test.Id); ct.AdultSymptomDirectTest += adultPatientEnterPerMonth; ct.PedSymptomDirectTest += pedPatientEnterPerMonth; ct.PreArtAdultSymptomDirectTest += preAdultPatientEnterPerMonth; ct.PreArtPedSymptomDirectTest += prePedPatientEnterPerMonth; } if (1 >= PeriodInfo.FirstMonth && i <= PeriodInfo.LastMonth) { csdt.TestBasedonProtocol = csdt.GetCalculatedTotalTest(); } if (1 >= PeriodInfo.BeginsOnmonth && i <= PeriodInfo.EndOnMonth) { csdt.TestsforBufferStock = csdt.GetCalculatedTotalTest(); } csdt.AdditionalTestsdueToWastage = csdt.TestBasedonProtocol * _chemAdditionalTestsDuetoWastage; csdt.AdditionalTestsdueToWastageBeyondForecast = csdt.TestsforBufferStock * _chemAdditionalTestsDuetoWastage; } } for (int i = 2; i <= 13; i++) { if (i >= PeriodInfo.FirstMonth && i <= PeriodInfo.LastMonth) { _chemMonthlyOutputs[i - 1].TotalChemistrySamplesWithinForecastPeriod = _chemMonthlyOutputs[i - 1].GetSumOfTotalChemistrySamples(); } else { _chemMonthlyOutputs[i - 1].TotalChemistrySamplesWithinForecastPeriod = 0d; } if (i >= PeriodInfo.BeginsOnmonth && i <= PeriodInfo.EndOnMonth) { _chemMonthlyOutputs[i - 1].TotalChemistrySamplesWithinBufferStock = _chemMonthlyOutputs[i - 1].GetSumOfTotalChemistrySamples(); } else { _chemMonthlyOutputs[i - 1].TotalChemistrySamplesWithinBufferStock = 0d; } } }
private void CalculateChemistryTestConducted() { _chemRepeatsduetoClinicianRequest = (ChemTestProtocol.TestReapeated / 100d); _chemAdditionalTestsDuetoWastage = (InvAssumption.Chemistry / 100d); for (int i = 1; i <= 12; i++) { MOutputChemistryTest chemOut = new MOutputChemistryTest(); chemOut.Month = i; foreach (PSymptomDirectedTest sdt in ChemTestProtocol.SymptomDirectedTests) { ChemistrySymptomDirectedTest csdt = new ChemistrySymptomDirectedTest(); csdt.TestName = sdt.ChemTestNameToEnum; csdt.AdultSymptomDirectTest = (CurrentAdultinTreatment * (sdt.AdultInTreatmeant / 100d)) / 12d; csdt.PedSymptomDirectTest = (CurrentPediatricinTreatment * (sdt.PediatricInTreatmeant / 100d)) / 12d; csdt.PreArtAdultSymptomDirectTest = (CurrentAdultinPreArt * (sdt.AdultPreART / 100d)) / 12d; csdt.PreArtPedSymptomDirectTest = (CurrentPediatricinPreArt * (sdt.PediatricPreART / 100d)) / 12d; csdt.RepeatPercent = _chemRepeatsduetoClinicianRequest; chemOut.ChemSymptomDirectedTest.Add(csdt); } foreach (ProtocolPanel panel in ChemTestProtocol.ProtocolPanels) { ChemistryTestByPannel chemp = new ChemistryTestByPannel(); chemp.ExistingAdultPatientsinTreatment = CalculatedPatientNos[i].ArtAdultPreExistingPatients * panel.AdultInTreatmentDistribution; chemp.ExistingPedPatientsinTreatment = CalculatedPatientNos[i].ArtPediatricPreExistingPatients * panel.PediatricInTreatmentDistribution; // ((pediatricsinTreatment / 12d) * preExistingPatientsonPanel); chemp.ExistingAdultPatientsinPreArt = CalculatedPatientNos[i].PreArtAdultPreExistingPatients * panel.AdultPreARTDistribution; chemp.ExistingPedPatientsinPreArt = CalculatedPatientNos[i].PreArtPediatricPreExistingPatients * panel.PediatricPreARTDistribution; for (int x = 1, y = i; x <= i; x++, y--) { chemp.NewAdultPatientstoTreatment += CalculatedPatientNos[i].GetArtAdultPatientsEntering(x) * panel.AdultArtTestGivenInMonth(y) * (panel.AITNewPatient/100d); chemp.NewPedPatientstoTreatment += CalculatedPatientNos[i].GetArtPediatricPatientsEntering(x) * panel.PediatricArtTestGivenInMonth(y) * (panel.PITNewPatient/100d); chemp.NewAdultPatientstoPreArt += CalculatedPatientNos[i].GetPreArtAdultPatientsEntering(x) * panel.AdultPreArtTestGivenInMonth(y) * (panel.APARTNewPatient/100d); chemp.NewPedPatientstoPreArt += CalculatedPatientNos[i].GetPreArtPediatricPatientsEntering(x) * panel.PediatricPreArtTestGivenInMonth(y) * (panel.PPARTNewPatient/100d); } ChemistryTestNameEnum[] chemtest = LqtUtil.EnumToArray<ChemistryTestNameEnum>(); for (int z = 0; z < chemtest.Length; z++) { double tconducted = 0d; if (panel.IsChemTestSelected(chemtest[z])) { tconducted = chemp.TotalTestsForRegimen(); } chemp.SetChemTestValue(chemtest[z], tconducted); if (chemOut.GetChemSymptomDirectedTestById(chemtest[z]) != null) chemOut.GetChemSymptomDirectedTestById(chemtest[z]).TestConducted += tconducted; } chemOut.ChemTestByPanel.Add(chemp); } _chemMonthlyOutputs.Add(i, chemOut); } double adultPatientEnterPerMonth = 0d; double pedPatientEnterPerMonth = 0d; double preAdultPatientEnterPerMonth = 0d; double prePedPatientEnterPerMonth = 0d; foreach (PSymptomDirectedTest sdt in ChemTestProtocol.SymptomDirectedTests) { for (int i = 1; i <= 12; i++) { ChemistrySymptomDirectedTest csdt = _chemMonthlyOutputs[i].GetChemSymptomDirectedTestById(sdt.ChemTestNameToEnum); adultPatientEnterPerMonth = (CalculatedPatientNos[i].GetArtAdultPatientsEntering(i) * (sdt.AdultInTreatmeant / 100d)) / 12d; csdt.AdultSymptomDirectTest += adultPatientEnterPerMonth; pedPatientEnterPerMonth = (CalculatedPatientNos[i].GetArtPediatricPatientsEntering(i) * (sdt.PediatricInTreatmeant / 100d)) / 12d; csdt.PedSymptomDirectTest += pedPatientEnterPerMonth; preAdultPatientEnterPerMonth = (CalculatedPatientNos[i].GetPreArtAdultPatientsEntering(i) * (sdt.AdultPreART / 100d)) / 12d; csdt.PreArtAdultSymptomDirectTest += preAdultPatientEnterPerMonth; prePedPatientEnterPerMonth = (CalculatedPatientNos[i].GetPreArtPediatricPatientsEntering(i) * (sdt.PediatricPreART / 100d)) / 12d; csdt.PreArtPedSymptomDirectTest += prePedPatientEnterPerMonth; for (int x = i + 1; x <= 12; x++) { ChemistrySymptomDirectedTest ct = _chemMonthlyOutputs[x].GetChemSymptomDirectedTestById(sdt.ChemTestNameToEnum); ct.AdultSymptomDirectTest += adultPatientEnterPerMonth; ct.PedSymptomDirectTest += pedPatientEnterPerMonth; ct.PreArtAdultSymptomDirectTest += preAdultPatientEnterPerMonth; ct.PreArtPedSymptomDirectTest += prePedPatientEnterPerMonth; } if (1 >= PeriodInfo.FirstMonth && i <= PeriodInfo.LastMonth) csdt.TestBasedonProtocol = csdt.GetCalculatedTotalTest(); if (1 >= PeriodInfo.BeginsOnmonth && i <= PeriodInfo.EndOnMonth) csdt.TestsforBufferStock = csdt.GetCalculatedTotalTest(); csdt.AdditionalTestsdueToWastage = csdt.TestBasedonProtocol * _chemAdditionalTestsDuetoWastage; csdt.AdditionalTestsdueToWastageBeyondForecast = csdt.TestsforBufferStock * _chemAdditionalTestsDuetoWastage; } } for (int i = 2; i <= 13; i++) { if (i >= PeriodInfo.FirstMonth && i <= PeriodInfo.LastMonth) _chemMonthlyOutputs[i - 1].TotalChemistrySamplesWithinForecastPeriod = _chemMonthlyOutputs[i - 1].GetSumOfTotalChemistrySamples(); else _chemMonthlyOutputs[i - 1].TotalChemistrySamplesWithinForecastPeriod = 0d; if (i >= PeriodInfo.BeginsOnmonth && i <= PeriodInfo.EndOnMonth) _chemMonthlyOutputs[i - 1].TotalChemistrySamplesWithinBufferStock = _chemMonthlyOutputs[i - 1].GetSumOfTotalChemistrySamples(); else _chemMonthlyOutputs[i - 1].TotalChemistrySamplesWithinBufferStock = 0d; } }