/// <summary> /// Calculates a single indicator /// </summary> /// <param name="formTranslationKey">The form translation key</param> /// <param name="field">Indicator being calculated</param> /// <param name="relatedValues">Related indicator values used in the calculation</param> /// <param name="demo">Demography data for the admin unit</param> /// <param name="start">The starting point used to determine demography information</param> /// <param name="end">The ending point used to determine demography information</param> /// <param name="errors">Errors to be displayed and managed by the ReportGenerator</param> /// <returns>The indicator name and the calculated value</returns> public override KeyValuePair<string, string> GetCalculatedValue(string formTranslationKey, string field, Dictionary<string, string> relatedValues, AdminLevelDemography demo, DateTime start, DateTime end, ref string errors) { try { // First check shared intervention calculations KeyValuePair<string, string> sharedIntvCalc = CheckPcIntvCalculations(relatedValues, field, formTranslationKey, demo.AdminLevelId, start, end, ref errors); if (sharedIntvCalc.Key != null && sharedIntvCalc.Value != null) return sharedIntvCalc; // Determine the form name to avoid traversing the whole case statement if (formTranslationKey == "BuruliUlcerIntv") return CalculateBuruliUlcerIntv(formTranslationKey, field, relatedValues, demo, start, end, ref errors); else if (formTranslationKey == "GuineaWormIntervention") return CalculateGuineaWormIntv(formTranslationKey, field, relatedValues, demo, start, end, ref errors); else if (formTranslationKey == "HatIntervention") return CalculateHatIntv(formTranslationKey, field, relatedValues, demo, start, end, ref errors); else if (formTranslationKey == "YawsIntervention") return CalculateYawsIntv(formTranslationKey, field, relatedValues, demo, start, end, ref errors); else if (formTranslationKey == "LeishAnnualIntervention") return CalculateLeishAnnualIntv(formTranslationKey, field, relatedValues, demo, start, end, ref errors); else if (formTranslationKey == "LeishMonthlyIntervention") return CalculateLeishMonthlyIntv(formTranslationKey, field, relatedValues, demo, start, end, ref errors); else return new KeyValuePair<string, string>(field, Translations.NA); } catch (Exception) { } return new KeyValuePair<string, string>(field, Translations.CalculationError); }
/// <summary> /// Calculates a single indicator /// </summary> /// <param name="formTranslationKey">The form translation key</param> /// <param name="field">Indicator being calculated</param> /// <param name="relatedValues">Related indicator values used in the calculation</param> /// <param name="demo">Demography data for the admin unit</param> /// <param name="start">The starting point used to determine demography information</param> /// <param name="end">The ending point used to determine demography information</param> /// <param name="errors">Errors to be displayed and managed by the ReportGenerator</param> /// <returns>The indicator name and the calculated value</returns> public override KeyValuePair<string, string> GetCalculatedValue(string formTranslationKey, string field, Dictionary<string, string> relatedValues, AdminLevelDemography demo, DateTime start, DateTime end, ref string errors) { // Combine the form translation key and field name string formNameFieldComposite = formTranslationKey + field; try { switch (formNameFieldComposite) { case "SCMSCMRemaining": return new KeyValuePair<string, string>(Translations.SCMRemaining, GetTotal( GetValueOrDefault("SCMSCMReceived", relatedValues), GetValueOrDefault("SCMSCMTransferredFromAnotherDisrict", relatedValues), GetDifferences(GetValueOrDefault("SCMSCMUsedDistributed", relatedValues), GetValueOrDefault("SCMSCMExpiredDrugs", relatedValues), GetValueOrDefault("SCMSCMWasted", relatedValues), GetValueOrDefault("SCMSCMUnusable", relatedValues), GetValueOrDefault("SCMSCMLosses", relatedValues), GetValueOrDefault("SCMSCMStolen", relatedValues), GetValueOrDefault("SCMSCMTransferredToAnotherDistrict", relatedValues), GetValueOrDefault("SCMSCMAdjustments", relatedValues)))); default: return new KeyValuePair<string, string>(formNameFieldComposite, Translations.NA); } } catch (Exception) { } return new KeyValuePair<string, string>(formNameFieldComposite, Translations.CalculationError); }
public void Save(AdminLevelDemography demo, int userId) { bool transWasStarted = false; OleDbConnection connection = new OleDbConnection(DatabaseData.Instance.AccessConnectionString); using (connection) { connection.Open(); try { // START TRANS OleDbCommand command = new OleDbCommand("BEGIN TRANSACTION", connection); command.ExecuteNonQuery(); transWasStarted = true; SaveAdminDemography(command, connection, demo, userId); // COMMIT TRANS command = new OleDbCommand("COMMIT TRANSACTION", connection); command.ExecuteNonQuery(); transWasStarted = false; } catch (Exception) { if (transWasStarted) { try { OleDbCommand cmd = new OleDbCommand("ROLLBACK TRANSACTION", connection); cmd.ExecuteNonQuery(); } catch { } } throw; } } }
private void GetDemoByUnitAndDate(AdminLevelDemography demo, int adminLevelUnitId, DateTime dateReported, OleDbConnection connection, OleDbCommand command) { command = new OleDbCommand(@"Select a.Id, a.AdminLevelId, a.DateDemographyData, a.YearCensus, a.GrowthRate, a.PercentRural, a.TotalPopulation, a.AdultPopulation, a.Pop0Month, a.PopPsac, a.PopSac, a.Pop5yo, a.PopAdult, a.PopFemale, a.PopMale, a.Notes, a.UpdatedById, a.UpdatedAt, aspnet_Users.UserName, AdminLevels.DisplayName, a.CreatedAt, c.UserName as CreatedBy FROM (((AdminLevelDemography a INNER JOIN aspnet_Users on a.UpdatedById = aspnet_Users.UserId) LEFT OUTER JOIN AdminLevels on a.AdminLevelId = AdminLevels.ID) INNER JOIN aspnet_Users c on a.CreatedById = c.UserId) WHERE AdminLevels.Id=@aid AND a.DateDemographyData=@DateReported ORDER BY a.Id DESC", connection); command.Parameters.Add(new OleDbParameter("@aid", adminLevelUnitId)); command.Parameters.Add(new OleDbParameter("@DateReported", dateReported)); using (OleDbDataReader reader = command.ExecuteReader()) { if (reader.HasRows) { reader.Read(); demo.Id = reader.GetValueOrDefault<int>("Id"); demo.AdminLevelId = reader.GetValueOrDefault<int>("AdminLevelId"); demo.DateDemographyData = reader.GetValueOrDefault<DateTime>("DateDemographyData"); demo.YearCensus = reader.GetValueOrDefault<Nullable<int>>("YearCensus"); demo.GrowthRate = reader.GetValueOrDefault<Nullable<double>>("GrowthRate"); demo.PercentRural = reader.GetValueOrDefault<Nullable<double>>("PercentRural"); demo.TotalPopulation = reader.GetValueOrDefault<Nullable<int>>("TotalPopulation"); demo.Pop0Month = reader.GetValueOrDefault<Nullable<int>>("Pop0Month"); demo.PopPsac = reader.GetValueOrDefault<Nullable<int>>("PopPsac"); demo.PopSac = reader.GetValueOrDefault<Nullable<int>>("PopSac"); demo.Pop5yo = reader.GetValueOrDefault<Nullable<int>>("Pop5yo"); demo.PopAdult = reader.GetValueOrDefault<Nullable<int>>("PopAdult"); demo.PopFemale = reader.GetValueOrDefault<Nullable<int>>("PopFemale"); demo.PopMale = reader.GetValueOrDefault<Nullable<int>>("PopMale"); demo.Notes = reader.GetValueOrDefault<string>("Notes"); demo.UpdatedAt = reader.GetValueOrDefault<DateTime>("UpdatedAt"); demo.UpdatedBy = GetAuditInfo(reader); } reader.Close(); } }
public AdminLevelDemography GetDemoById(int id) { AdminLevelDemography demo = new AdminLevelDemography(); OleDbConnection connection = new OleDbConnection(DatabaseData.Instance.AccessConnectionString); using (connection) { connection.Open(); try { // START TRANS OleDbCommand command = new OleDbCommand(); GetDemoById(demo, id, connection, command); } catch (Exception) { throw; } } return demo; }
public AdminLevelDemography GetDemoByAdminLevelIdAndYear(int adminLevelid, DateTime startDate, DateTime endDate) { AdminLevelDemography demo = new AdminLevelDemography { DateDemographyData = startDate, AdminLevelId = adminLevelid }; int id = 0; OleDbConnection connection = new OleDbConnection(DatabaseData.Instance.AccessConnectionString); using (connection) { connection.Open(); try { // START TRANS OleDbCommand command = new OleDbCommand(@"Select ID FROM AdminLevelDemography WHERE AdminLevelId = @id and IsDeleted = 0 " + CreateDemoYearRange(startDate, endDate) + @"ORDER BY DateDemographyData DESC", connection); command.Parameters.Add(new OleDbParameter("@id", adminLevelid)); using (OleDbDataReader reader = command.ExecuteReader()) { if (reader.HasRows) { reader.Read(); id = reader.GetValueOrDefault<int>("ID"); } } if (id > 0) GetDemoById(demo, id, connection, command); } catch (Exception) { throw; } } return demo; }
private List<AdminLevelDemography> GetRecentDemographyByLevel(int level, OleDbCommand command, OleDbConnection connection) { List<AdminLevelDemography> demo = new List<AdminLevelDemography>(); command = new OleDbCommand( @"SELECT AdminLevels.Id as aid, MAX(a.DateDemographyData) as mdate FROM ((AdminLevelDemography a INNER JOIN AdminLevels on a.AdminLevelId = AdminLevels.ID) INNER JOIN AdminLevelTypes on AdminLevels.AdminLevelTypeId = AdminLevelTypes.ID) WHERE AdminLevelTypes.AdminLevel>=@lvl GROUP BY AdminLevels.Id", connection); command.Parameters.Add(new OleDbParameter("@lvl", level)); using (OleDbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { AdminLevelDemography d = new AdminLevelDemography(); GetDemoByUnitAndDate(d, reader.GetValueOrDefault<int>("aid"), reader.GetValueOrDefault<DateTime>("mdate"), connection, command); demo.Add(d); } reader.Close(); } return demo; }
private List<AdminLevelDemography> GetRecentDemographyByLevel(int level, int recentYear, OleDbCommand command, OleDbConnection connection) { List<AdminLevelDemography> demo = new List<AdminLevelDemography>(); command = new OleDbCommand(@"SELECT MAX(AdminLevelDemography.ID) as MID, MAX(AdminLevels.DisplayName) as MName FROM ((AdminLevelDemography INNER JOIN AdminLevels on AdminLevelDemography.AdminLevelId = AdminLevels.ID) INNER JOIN AdminLevelTypes on AdminLevels.AdminLevelTypeId = AdminLevelTypes.ID) WHERE AdminLevelTypes.AdminLevel=@lvl AND DatePart('yyyy', [AdminLevelDemography.DateDemographyData])=@Year GROUP BY AdminLevelDemography.AdminLevelId", connection); command.Parameters.Add(new OleDbParameter("@lvl", level)); command.Parameters.Add(new OleDbParameter("@Year", recentYear)); using (OleDbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { AdminLevelDemography d = new AdminLevelDemography(); GetDemoById(d, reader.GetValueOrDefault<int>("MID"), connection, command); d.NameDisplayOnly = reader.GetValueOrDefault<string>("MName"); demo.Add(d); } reader.Close(); } return demo; }
/// <summary> /// Calculates a single indicator /// </summary> /// <param name="formTranslationKey">The form translation key</param> /// <param name="field">Indicator being calculated</param> /// <param name="relatedValues">Related indicator values used in the calculation</param> /// <param name="demo">Demography data for the admin unit</param> /// <param name="start">The starting point used to determine demography information</param> /// <param name="end">The ending point used to determine demography information</param> /// <param name="errors">Errors to be displayed and managed by the ReportGenerator</param> /// <returns>The indicator name and the calculated value</returns> public override KeyValuePair<string, string> GetCalculatedValue(string formTranslationKey, string field, Dictionary<string, string> relatedValues, AdminLevelDemography demo, DateTime start, DateTime end, ref string errors) { // Combine the form translation key and field name string formNameFieldComposite = formTranslationKey + field; try { switch (formNameFieldComposite) { case "YAWSPercentNewChildren": return new KeyValuePair<string, string>(Translations.PercentNewChildren, GetPercentage(GetValueOrDefault("YAWSTotalNumChildNewCases", relatedValues), GetValueOrDefault("YAWSTotalNumNewCases", relatedValues))); case "YAWSPercentNewFemales": return new KeyValuePair<string,string>(Translations.PercentNewFemales, GetPercentage(GetValueOrDefault("YAWSTotalNumFemaleNewCases", relatedValues), GetValueOrDefault("YAWSTotalNumNewCases", relatedValues))); case "LeprosyPercentNewChildren": return new KeyValuePair<string, string>(Translations.PercentNewChildren, GetPercentage(GetValueOrDefault("LeprosyTotalNumChildNewCases", relatedValues), GetValueOrDefault("LeprosyTotalNumNewCases", relatedValues))); case "LeprosyPercentNewFemales": return new KeyValuePair<string, string>(Translations.PercentNewFemales, GetPercentage(GetValueOrDefault("LeprosyTotalNumFemaleNewCases", relatedValues), GetValueOrDefault("LeprosyTotalNumNewCases", relatedValues))); case "LeprosyTotalNumCasesRegistered": //if (L5 >= 0 && L24 >= 0 && L25 >= 0 && l9 >= 0) // calcs.Add(new KeyValuePair<string, string>("TotalNumCasesRegistered", string.Format("{0}", L5 + L24 + L25 + l9).ToString()))); return new KeyValuePair<string,string>(Translations.TotalNumCasesRegistered, Translations.CalculationError); case "LeprosyPercentNewMb": return new KeyValuePair<string,string>(Translations.PercentNewMb, GetPercentage(GetValueOrDefault("LeprosyTotalNumMbCases", relatedValues), GetValueOrDefault("LeprosyTotalNumNewCases", relatedValues))); case "LeprosyPrevalenceRateEndOfYear": if (demo != null) return new KeyValuePair<string,string>(Translations.PrevalenceRateEndOfYear, GetPercentage(GetValueOrDefault("LeprosyMbCasesRegisteredMdtEnd", relatedValues), demo.TotalPopulation.ToString(), 100000)); break; case "LeprosyRateNewGrade2": //L15 Rate of New Grade II per 1 million population number CALC: L23 (Total number of new cases with Grade II disabilities)/total population return new KeyValuePair<string,string>(Translations.RateNewGrade2, Translations.CalculationError); case "LeprosyDetectionRate100k": if (demo != null) return new KeyValuePair<string, string>(Translations.DetectionRate100k, GetPercentage(GetValueOrDefault("LeprosyTotalNumNewCases", relatedValues), demo.TotalPopulation.ToString(), 100000)); break; case "HATPercentCasesHat2": return new KeyValuePair<string, string>(Translations.PercentCasesHat2, GetPercentage(GetValueOrDefault("HATTotalNumHat2", relatedValues), GetValueOrDefault("HATTotalNumHat", relatedValues))); case "HATPercentNewChildren": return new KeyValuePair<string, string>(Translations.PercentNewChildren, GetPercentage(GetValueOrDefault("HATTotalNumHatChild", relatedValues), GetValueOrDefault("HATTotalNumHat", relatedValues))); case "HATPercentNewFemales": return new KeyValuePair<string, string>(Translations.PercentNewFemales, GetPercentage(GetValueOrDefault("HATTotalNumHatFemale", relatedValues), GetValueOrDefault("HATTotalNumHat", relatedValues))); case "BuruliUlcerPercentNewChildren": return new KeyValuePair<string, string>(Translations.PercentNewChildren, GetPercentage(GetValueOrDefault("BuruliUlcerTotalNumChildNewCases", relatedValues), GetValueOrDefault("BuruliUlcerTotalNumNewCases", relatedValues))); case "BuruliUlcerPercentNewFemales": return new KeyValuePair<string, string>(Translations.PercentNewFemales, GetPercentage(GetValueOrDefault("BuruliUlcerTotalNumFemaleNewCases", relatedValues), GetValueOrDefault("BuruliUlcerTotalNumNewCases", relatedValues))); case "BuruliUlcerPercentUlcerativeCases": return new KeyValuePair<string, string>(Translations.PercentUlcerativeCases, GetPercentage(GetValueOrDefault("BuruliUlcerTotalUlcerativeCases", relatedValues), GetValueOrDefault("BuruliUlcerTotalNumNewCases", relatedValues))); case "BuruliUlcerPercentCatICases": return new KeyValuePair<string, string>(Translations.PercentCatICases, GetPercentage(GetValueOrDefault("BuruliUlcerTotalCat1Cases", relatedValues), GetValueOrDefault("BuruliUlcerTotalNumNewCases", relatedValues))); case "BuruliUlcerPercentCatIICases": return new KeyValuePair<string, string>(Translations.PercentCatIICases, GetPercentage(GetValueOrDefault("BuruliUlcerTotalCat3Cases", relatedValues), GetValueOrDefault("BuruliUlcerTotalNumNewCases", relatedValues))); case "BuruliUlcerPercentPcrCases": return new KeyValuePair<string, string>(Translations.PercentPcrCases, GetPercentage(GetValueOrDefault("BuruliUlcerTotalCasesConfirmedPcr", relatedValues), GetValueOrDefault("BuruliUlcerTotalNumNewCases", relatedValues))); case "BuruliUlcerDetectionRate100k": if(demo != null) return new KeyValuePair<string, string>(Translations.DetectionRate100k, GetPercentage(GetValueOrDefault("BuruliUlcerTotalNumNewCases", relatedValues), demo.TotalPopulation.ToString(), 100000)); break; case "OnchoDDOnchoTotalPopulation": return new KeyValuePair<string, string>(Translations.DDOnchoTotalPopulation, demo.TotalPopulation.ToString()); case "LFDDLFTotalPopulation": return new KeyValuePair<string, string>(Translations.DDLFTotalPopulation, demo.TotalPopulation.ToString()); case "LFDDLFPsacPopulation": return new KeyValuePair<string, string>(Translations.DDLFPsacPopulation, demo.PopPsac.ToString()); case "LFDDLFSacPopulation": return new KeyValuePair<string, string>(Translations.DDLFSacPopulation, demo.PopSac.ToString()); case "LFDDLFAdultPopulation": return new KeyValuePair<string, string>(Translations.DDLFAdultPopulation, demo.PopAdult.ToString()); case "SchistoDDSchistoTotalPopulation": return new KeyValuePair<string, string>(Translations.DDSchistoTotalPopulation, demo.TotalPopulation.ToString()); case "SchistoDDSchistoSacPopulation": return new KeyValuePair<string, string>(Translations.DDSchistoSacPopulation, demo.PopSac.ToString()); case "SchistoDDSchistoAdultPopulation": return new KeyValuePair<string, string>(Translations.DDSchistoAdultPopulation, demo.PopAdult.ToString()); case "STHDDSTHTotalPopulation": return new KeyValuePair<string, string>(Translations.DDSTHTotalPopulation, demo.TotalPopulation.ToString()); case "STHDDSTHPsacPopulation": return new KeyValuePair<string, string>(Translations.DDSTHPsacPopulation, demo.PopPsac.ToString()); case "STHDDSTHSacPopulation": return new KeyValuePair<string, string>(Translations.DDSTHSacPopulation, demo.PopSac.ToString()); case "STHDDSTHAdultPopulation": return new KeyValuePair<string, string>(Translations.DDSTHAdultPopulation, demo.PopAdult.ToString()); case "TrachomaDDTraTotalPopulation": return new KeyValuePair<string, string>(Translations.DDTraTotalPopulation, demo.TotalPopulation.ToString()); case "TrachomaDDTraSacPopulation": return new KeyValuePair<string, string>(Translations.DDTraSacPopulation, demo.PopSac.ToString()); case "TrachomaDDTraAdultPopulation": return new KeyValuePair<string, string>(Translations.DDTraAdultPopulation, demo.PopAdult.ToString()); default: return new KeyValuePair<string, string>(formNameFieldComposite, Translations.NA); } } catch (Exception) { } return new KeyValuePair<string, string>(formNameFieldComposite, Translations.CalculationError); }
private KeyValuePair<string, string> CalculateBuruliUlcerIntv(string formTranslationKey, string field, Dictionary<string, string> relatedValues, AdminLevelDemography demo, DateTime start, DateTime end, ref string errors) { // Combine the form translation key and field name string formNameFieldComposite = formTranslationKey + field; try { switch (formNameFieldComposite) { case "BuruliUlcerIntvPercentCoverageBu": if (demo != null) return new KeyValuePair<string, string>(Translations.PercentCoverageBu, GetPercentage(GetValueOrDefault("BuruliUlcerIntvNumFacilitiesProvidingBu", relatedValues), demo.PopAdult.ToString())); break; default: return new KeyValuePair<string, string>(formNameFieldComposite, Translations.NA); } } catch (Exception) { } return new KeyValuePair<string, string>(formNameFieldComposite, Translations.CalculationError); }
private KeyValuePair<string, string> CalculateLeishMonthlyIntv(string formTranslationKey, string field, Dictionary<string, string> relatedValues, AdminLevelDemography demo, DateTime start, DateTime end, ref string errors) { // Combine the form translation key and field name string formNameFieldComposite = formTranslationKey + field; try { switch (formNameFieldComposite) { case "LeishMonthlyInterventionLeishMontIntvDetectionRatePer100000": if (demo != null) { return new KeyValuePair<string, string>(Translations.LeishMontIntvDetectionRatePer100000, GetPercentage( GetTotal(new string[2] { GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewCLCasesDiagnosedLabAndClinical", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewVLCasesDiagnosedLabAndClinical", relatedValues) }), demo.TotalPopulation.ToString(), 10000 )); } break; case "LeishMonthlyInterventionLeishMontIntvPrcntOfLabConfirmedCases": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfLabConfirmedCases, GetPercentage( GetTotal(new string[3] { GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfLabConfirmedCLCases", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfVLCasesDiagnosedByAPositiveRapidDiagnosticTestsRDT", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfLabConfirmedVisceralLeishmaniasisVLCases", relatedValues) }), GetTotal(new string[2] { GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewCLCasesDiagnosedLabAndClinical", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewVLCasesDiagnosedLabAndClinical", relatedValues) } ))); case "LeishMonthlyInterventionLeishMontIntvPrcntCasesActivelyFound": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntCasesActivelyFound, GetPercentage( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfCasesFoundActively", relatedValues), GetTotal(new string[6] { GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfPeopleScreenedActivelyForVL", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfPeopleScreenedPassivelyForVL", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfPeopleScreenedActivelyForCL", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfPeopleScreenedPassivelyForCL", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfPeopleScreenedActivelyForPKDL", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfPeopleScreenedPassivelyForPKDL", relatedValues) } ))); case "LeishMonthlyInterventionLeishMontIntvPrcntOfVLHIVCoInfectedCasesOfTheTotalNewVLCases": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfVLHIVCoInfectedCasesOfTheTotalNewVLCases, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfVisceralLeishmaniasisHIVCoInfection", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewVLCasesDiagnosedLabAndClinical", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfPKDLHIVCoInfectedCasesOfTheTotalNewPKDLCases": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfPKDLHIVCoInfectedCasesOfTheTotalNewPKDLCases, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewPKDLCasesHIVCoInfection", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewPKDLCasesDiagnosed", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfVLCasesDiagnosedByRDT": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfVLCasesDiagnosedByRDT, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfVLCasesDiagnosedByAPositiveRapidDiagnosticTestsRDT", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewVLCasesDiagnosedLabAndClinical", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfPostitiveRDT": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfPostitiveRDT, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfVLCasesDiagnosedByAPositiveRapidDiagnosticTestsRDT", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfVLSuspectsTestedWithRapidDiagnosticTests", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfVLParasitologicallyConfirmedCases": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfVLParasitologicallyConfirmedCases, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfLabConfirmedVisceralLeishmaniasisVLCases", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewVLCasesDiagnosedLabAndClinical", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfCLParasitologicallyConfirmedCases": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfCLParasitologicallyConfirmedCases, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfLabConfirmedCLCases", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewCLCasesDiagnosedLabAndClinical", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfParasitologicallyConfirmedVLSamples": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfParasitologicallyConfirmedVLSamples, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfLabConfirmedVisceralLeishmaniasisVLCases", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfVLCasesTestedByDirectExamParasitology", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfParasitologicallyConfirmedCLSamples": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfParasitologicallyConfirmedCLSamples, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfLabConfirmedCLCases", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfCLCasesTestedByDirectExamParasitology", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfInitialCuredCasesOutOfTotalNewCasesTreatedForVL": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfInitialCuredCasesOutOfTotalNewCasesTreatedForVL, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewVLCasesWithInitialCure", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewVLCasesTreated", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfInitialCuredCasesOutOfTotalNewCasesTreatedForCL": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfInitialCuredCasesOutOfTotalNewCasesTreatedForCL, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewCLCasesWithInitialCure", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewCLCasesTreated", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfFailureCasesOutOfTotalNewCasesTreatedForVL": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfFailureCasesOutOfTotalNewCasesTreatedForVL, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfFailureCasesVL", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewVLCasesTreated", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfFailureCasesOutOfTotalNewCasesTreatedForCL": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfFailureCasesOutOfTotalNewCasesTreatedForCL, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfFailureCasesCL", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewCLCasesTreated", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntCaseFatalityRateForVL": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntCaseFatalityRateForVL, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfDeathsForNewVLCases", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewVLCasesTreated", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntCaseFatalityRateForCL": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntCaseFatalityRateForCL, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfDeathsForNewCLCases", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewCLCasesTreated", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfCLPatientsWithLesionsGrtrThnOrEqlTo4Cm": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfCLPatientsWithLesionsGrtrThnOrEqlTo4Cm, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfCLPatientsWithLesionsGrtrThnOrEqlTo4Cm", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewCLCasesDiagnosedLabAndClinical", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfCLPatientsWithGrtrThnOrEqlTo4Lesions": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfCLPatientsWithGrtrThnOrEqlTo4Lesions, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfCLPatientsWithGrtrThnOrEqlTo4Lesions", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewCLCasesDiagnosedLabAndClinical", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfCLPatientsWithLesionsOnFaceEars": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfCLPatientsWithLesionsOnFaceEars, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfCLPatientsWithLesionsOnFaceOrEars", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewCLCasesDiagnosedLabAndClinical", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfCLPatientsUndergoingSystemicTreatment": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfCLPatientsUndergoingSystemicTreatment, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfCLPatientsUndergoingSystemicTreatment", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewCLCasesTreated", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvVLIncidenceRate10000PeopleYear": if (demo != null) { return new KeyValuePair<string, string>(Translations.LeishMontIntvVLIncidenceRate10000PeopleYear, GetPercentage( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewVLCasesDiagnosedLabAndClinical", relatedValues), demo.TotalPopulation.ToString(), 10000 )); } break; case "LeishMonthlyInterventionLeishMontIntvCLIncidenceRate10000PeopleYear": if (demo != null) { return new KeyValuePair<string, string>(Translations.LeishMontIntvCLIncidenceRate10000PeopleYear, GetPercentage( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewCLCasesDiagnosedLabAndClinical", relatedValues), demo.TotalPopulation.ToString(), 10000 )); } break; case "LeishMonthlyInterventionLeishMontIntvPrcntFemaleVL": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntFemaleVL, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewVLFemaleCases", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewVLCasesDiagnosedLabAndClinical", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntFemaleCL": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntFemaleCL, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewCLFemaleCases", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewCLCasesDiagnosedLabAndClinical", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntFemalePKDL": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntFemalePKDL, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewPKDLFemaleCases", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewPKDLCasesDiagnosed", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntFemaleMCL": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntFemaleMCL, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewMCLFemaleCases", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewMCLCasesDiagnosed", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfNewVLCasesInChildrenLssThn5Years": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfNewVLCasesInChildrenLssThn5Years, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewVLCasesInChildrenLssThn5Years", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewVLCasesDiagnosedLabAndClinical", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfNewVLCasesInChildren5To14Years": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfNewVLCasesInChildren5To14Years, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewVLCasesInChildren5To14Years", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewVLCasesDiagnosedLabAndClinical", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfNewVLCasesInAdultsGrtrThn14Years": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfNewVLCasesInAdultsGrtrThn14Years, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewVLCasesInAdultsGrtrThn14Years", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewVLCasesDiagnosedLabAndClinical", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfNewCLCasesInChildrenLssThn5Years": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfNewCLCasesInChildrenLssThn5Years, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewCLCasesInChildrenLssThn5Years", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewCLCasesDiagnosedLabAndClinical", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfNewCLCasesInChildren5To14Years": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfNewCLCasesInChildren5To14Years, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewCLCasesInChildren5To14Years", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewCLCasesDiagnosedLabAndClinical", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfNewCLCasesInAdultsGrtrThn14Years": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfNewCLCasesInAdultsGrtrThn14Years, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewCLCasesInAdultsGrtrThn14Years", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewCLCasesDiagnosedLabAndClinical", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfNewPKDLCasesInChildrenLssThn5Years": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfNewPKDLCasesInChildrenLssThn5Years, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewPKDLCasesInChildrenLssThn5Years", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewPKDLCasesDiagnosed", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfNewPKDLCasesInChildren5To14Years": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfNewPKDLCasesInChildren5To14Years, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewPKDLCasesInChildren5To14Years", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewPKDLCasesDiagnosed", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfNewPKDLCasesInAdultsGrtrThn14Years": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfNewPKDLCasesInAdultsGrtrThn14Years, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewPKDLCasesInAdultsGrtrThn14Years", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewPKDLCasesDiagnosed", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfNewMCLCasesInChildrenLssThn5Years": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfNewMCLCasesInChildrenLssThn5Years, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewMCLCasesInChildrenLssThn5Years", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewMCLCasesDiagnosed", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfNewMCLCasesInChildren5To14Years": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfNewMCLCasesInChildren5To14Years, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewMCLCasesInChildren5To14Years", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewMCLCasesDiagnosed", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvPrcntOfNewMCLCasesInAdultsGrtrThn14Years": return new KeyValuePair<string, string>(Translations.LeishMontIntvPrcntOfNewMCLCasesInAdultsGrtrThn14Years, GetPercentageWithRatio( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfNewMCLCasesInAdultsGrtrThn14Years", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvTotalNumberOfNewMCLCasesDiagnosed", relatedValues) )); case "LeishMonthlyInterventionLeishMontIntvMonthlyConsumptionRate1StLineTreatmentUnits": return new KeyValuePair<string, string>(Translations.LeishMontIntvMonthlyConsumptionRate1StLineTreatmentUnits, GetDifference( GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfUnitsVialsFor1StLineTreatmentAtTheBeginningOfTheMonth", relatedValues), GetValueOrDefault("LeishMonthlyInterventionLeishMontIntvNumberOfUnitsVialsFor1StLineTreatmentAtTheEndOfTheMonth", relatedValues) )); default: return new KeyValuePair<string, string>(formNameFieldComposite, Translations.NA); } } catch (Exception) { } return new KeyValuePair<string, string>(formNameFieldComposite, Translations.CalculationError); }
private KeyValuePair<string, string> CalculateLeishAnnualIntv(string formTranslationKey, string field, Dictionary<string, string> relatedValues, AdminLevelDemography demo, DateTime start, DateTime end, ref string errors) { // Combine the form translation key and field name string formNameFieldComposite = formTranslationKey + field; try { switch (formNameFieldComposite) { case "LeishAnnualInterventionLeishAnnIntvOfNewVLCasesCuredOutOfNewCasesFollowedUp": return new KeyValuePair<string, string>( Translations.LeishAnnIntvOfNewVLCasesCuredOutOfNewCasesFollowedUp, GetPercentage( GetValueOrDefault("LeishAnnualInterventionLeishAnnIntvNumberOfNewVLCasesCuredAfterFollowUpOfAtLeast6Months", relatedValues), GetValueOrDefault("LeishAnnualInterventionLeishAnnIntvNumberOfNewVLCasesFollowedUpAtLeast6Months", relatedValues) )); case "LeishAnnualInterventionLeishAnnIntvOfNewCLCasesCuredOutOfNewCasesFollowedUp": return new KeyValuePair<string, string>( Translations.LeishAnnIntvOfNewCLCasesCuredOutOfNewCasesFollowedUp, GetPercentage( GetValueOrDefault("LeishAnnualInterventionLeishAnnIntvNumberOfNewCLCasesCuredAfterFollowUpOfAtLeast6Months", relatedValues), GetValueOrDefault("LeishAnnualInterventionLeishAnnIntvNumberOfNewCLCasesFollowedUpAtLeast6Months", relatedValues) )); case "LeishAnnualInterventionLeishAnnIntvOfVLRelapseCasesOutOfTotalNewCasesFollowedUp": return new KeyValuePair<string, string>( Translations.LeishAnnIntvOfVLRelapseCasesOutOfTotalNewCasesFollowedUp, GetPercentage( GetValueOrDefault("LeishAnnualInterventionLeishAnnIntvNumberOfVLRelapseCases", relatedValues), GetValueOrDefault("LeishAnnualInterventionLeishAnnIntvNumberOfNewVLCasesFollowedUpAtLeast6Months", relatedValues) )); case "LeishAnnualInterventionLeishAnnIntvOfCLRelapseCasesOutOfTotalNewCasesFollowedUp": return new KeyValuePair<string, string>( Translations.LeishAnnIntvOfCLRelapseCasesOutOfTotalNewCasesFollowedUp, GetPercentage( GetValueOrDefault("LeishAnnualInterventionLeishAnnIntvNumberOfCLRelapseCases", relatedValues), GetValueOrDefault("LeishAnnualInterventionLeishAnnIntvNumberOfNewCLCasesFollowedUpAtLeast6Months", relatedValues) )); default: return new KeyValuePair<string, string>(formNameFieldComposite, Translations.NA); } } catch (Exception) { } return new KeyValuePair<string, string>(formNameFieldComposite, Translations.CalculationError); }
private KeyValuePair<string, string> CalculateYawsIntv(string formTranslationKey, string field, Dictionary<string, string> relatedValues, AdminLevelDemography demo, DateTime start, DateTime end, ref string errors) { // Combine the form translation key and field name string formNameFieldComposite = formTranslationKey + field; try { switch (formNameFieldComposite) { case "YawsInterventionPercentTreatedYw": return new KeyValuePair<string, string>(Translations.PercentTreatedYw, GetPercentage(GetValueOrDefault("YawsInterventionNumContactsTreatedYw", relatedValues), GetTotal(GetValueOrDefault("YawsInterventionNumContactsTreatedYw", relatedValues), GetValueOrDefault("YawsInterventionNumCasesTreatedYaws", relatedValues)))); default: return new KeyValuePair<string, string>(formNameFieldComposite, Translations.NA); } } catch (Exception) { } return new KeyValuePair<string, string>(formNameFieldComposite, Translations.CalculationError); }
private KeyValuePair<string, string> CalculateHatIntv(string formTranslationKey, string field, Dictionary<string, string> relatedValues, AdminLevelDemography demo, DateTime start, DateTime end, ref string errors) { // Combine the form translation key and field name string formNameFieldComposite = formTranslationKey + field; try { switch (formNameFieldComposite) { case "HatInterventionPercentLabConfirmed": return new KeyValuePair<string, string>(Translations.PercentLabConfirmed, GetPercentage(GetValueOrDefault("HatInterventionNumLabCases", relatedValues), GetValueOrDefault("HatInterventionNumClinicalCasesHat", relatedValues))); case "HatInterventionPercentTGamb": return new KeyValuePair<string, string>(Translations.PercentTGamb, GetPercentage(GetValueOrDefault("HatInterventionNumTGamb", relatedValues), GetValueOrDefault("HatInterventionNumLabCases", relatedValues))); case "HatInterventionPercentTRhod": return new KeyValuePair<string, string>(Translations.PercentTRhod, GetPercentage(GetValueOrDefault("HatInterventionNumTRhod", relatedValues), GetValueOrDefault("HatInterventionNumLabCases", relatedValues))); case "HatInterventionPercentTGambTRhod": return new KeyValuePair<string, string>(Translations.PercentTGambTRhod, GetPercentage(GetValueOrDefault("HatInterventionNumTGambTRhod", relatedValues), GetValueOrDefault("HatInterventionNumClinicalCasesHat", relatedValues))); case "HatInterventionPercentCasesActivelyFound": return new KeyValuePair<string, string>(Translations.PercentCasesActivelyFound, GetPercentage(GetValueOrDefault("HatInterventionNumProspection", relatedValues), GetValueOrDefault("HatInterventionNumClinicalCasesHat", relatedValues))); case "HatInterventionCureRate": return new KeyValuePair<string, string>(Translations.CureRate, GetPercentage(GetValueOrDefault("HatInterventionNumCasesCured", relatedValues), GetValueOrDefault("HatInterventionNumCasesTreated", relatedValues))); case "HatInterventionPercentTreatmentFailure": return new KeyValuePair<string, string>(Translations.PercentTreatmentFailure, GetPercentage(GetValueOrDefault("HatInterventionNumTreatmentFailures", relatedValues), GetValueOrDefault("HatInterventionNumCasesTreated", relatedValues))); case "HatInterventionPercentSae": return new KeyValuePair<string, string>(Translations.PercentSae, GetPercentage(GetValueOrDefault("HatInterventionNumCasesSaes", relatedValues), GetValueOrDefault("HatInterventionNumCasesTreated", relatedValues))); case "HatInterventionFatalityRate": return new KeyValuePair<string, string>(Translations.FatalityRate, GetPercentage(GetValueOrDefault("HatInterventionNumDeaths", relatedValues), GetValueOrDefault("HatInterventionNumClinicalCasesHat", relatedValues))); case "HatInterventionDetectionRatePer100k": if (demo != null) return new KeyValuePair<string, string>(Translations.DetectionRatePer100k, GetPercentage(GetValueOrDefault("HatInterventionNumClinicalCasesHat", relatedValues), demo.TotalPopulation.ToString(), 100000)); break; default: return new KeyValuePair<string, string>(formNameFieldComposite, Translations.NA); } } catch (Exception) { } return new KeyValuePair<string, string>(formNameFieldComposite, Translations.CalculationError); }
private KeyValuePair<string, string> CalculateGuineaWormIntv(string formTranslationKey, string field, Dictionary<string, string> relatedValues, AdminLevelDemography demo, DateTime start, DateTime end, ref string errors) { // Combine the form translation key and field name string formNameFieldComposite = formTranslationKey + field; try { switch (formNameFieldComposite) { case "GuineaWormInterventionNumImported": return new KeyValuePair<string, string>(Translations.NumImported, GetDifference(GetValueOrDefault("GuineaWormInterventionNumClinical", relatedValues), GetValueOrDefault("GuineaWormInterventionNumIndigenous", relatedValues))); case "GuineaWormInterventionPercentVas": return new KeyValuePair<string, string>(Translations.PercentVas, GetPercentage(GetValueOrDefault("GuineaWormInterventionVasReporting", relatedValues), GetValueOrDefault("GuineaWormInterventionNumVas", relatedValues))); case "GuineaWormInterventionPercentIdsr": return new KeyValuePair<string, string>(Translations.PercentIdsr, GetPercentage(GetValueOrDefault("GuineaWormInterventionNumIdsrReporting", relatedValues), GetValueOrDefault("GuineaWormInterventionNumIdsr", relatedValues))); case "GuineaWormInterventionPercentRumorsInvestigated": return new KeyValuePair<string, string>(Translations.PercentRumorsInvestigated, GetPercentage(GetValueOrDefault("GuineaWormInterventionNumRumorsInvestigated", relatedValues), GetValueOrDefault("GuineaWormInterventionNumRumors", relatedValues))); case "GuineaWormInterventionPercentCasesContained": return new KeyValuePair<string, string>(Translations.PercentCasesContained, GetPercentage(GetValueOrDefault("GuineaWormInterventionNumCasesContained", relatedValues), GetValueOrDefault("GuineaWormInterventionNumClinical", relatedValues))); case "GuineaWormInterventionPercentEndemicReporting": return new KeyValuePair<string, string>(Translations.PercentEndemicReporting, GetPercentage(GetValueOrDefault("GuineaWormInterventionNumEndemicVillagesReporting", relatedValues), GetValueOrDefault("GuineaWormInterventionNumEndemicVillages", relatedValues))); default: return new KeyValuePair<string, string>(formNameFieldComposite, Translations.NA); } } catch (Exception) { } return new KeyValuePair<string, string>(formNameFieldComposite, Translations.CalculationError); }
public void SaveAdminDemography(OleDbCommand command, OleDbConnection connection, AdminLevelDemography demo, int userId) { if (demo.Id > 0) command = new OleDbCommand(@"UPDATE AdminLevelDemography SET AdminLevelId=@AdminLevelId, DateDemographyData=@DateDemographyData, YearCensus=@YearCensus, GrowthRate=@GrowthRate, PercentRural=@PercentRural, TotalPopulation=@TotalPopulation, Pop0Month=@Pop0Month, PopPsac=@PopPsac, PopSac=@PopSac, Pop5yo=@Pop5yo, PopAdult=@PopAdult, PopFemale=@PopFemale, PopMale=@PopMale, Notes=@Notes, UpdatedById=@UpdatedById, UpdatedAt=@UpdatedAt WHERE ID=@id", connection); else command = new OleDbCommand(@"INSERT INTO AdminLevelDemography (AdminLevelId, DateDemographyData, YearCensus, GrowthRate, PercentRural, TotalPopulation, Pop0Month, PopPsac, PopSac, Pop5yo, PopAdult, PopFemale, PopMale, Notes, UpdatedById, UpdatedAt, CreatedById, CreatedAt) values (@AdminLevelId, @DateDemographyData, @YearCensus, @GrowthRate, @PercentRural, @TotalPopulation, @Pop0Month, @PopPsac, @PopSac, @Pop5yo, @PopAdult, @PopFemale, @PopMale, @Notes, @UpdatedById, @UpdatedAt, @CreatedById, @CreatedAt)", connection); command.Parameters.Add(new OleDbParameter("@AdminLevelId", demo.AdminLevelId)); command.Parameters.Add(OleDbUtil.CreateDateTimeOleDbParameter("@DateDemographyData", demo.DateDemographyData)); command.Parameters.Add(OleDbUtil.CreateNullableParam("@YearCensus", demo.YearCensus)); command.Parameters.Add(OleDbUtil.CreateNullableParam("@GrowthRate", demo.GrowthRate)); command.Parameters.Add(OleDbUtil.CreateNullableParam("@PercentRural", demo.PercentRural)); command.Parameters.Add(OleDbUtil.CreateNullableParam("@TotalPopulation", demo.TotalPopulation)); command.Parameters.Add(OleDbUtil.CreateNullableParam("@Pop0Month", demo.Pop0Month)); command.Parameters.Add(OleDbUtil.CreateNullableParam("@PopPsac", demo.PopPsac)); command.Parameters.Add(OleDbUtil.CreateNullableParam("@PopSac", demo.PopSac)); command.Parameters.Add(OleDbUtil.CreateNullableParam("@Pop5yo", demo.Pop5yo)); command.Parameters.Add(OleDbUtil.CreateNullableParam("@PopAdult", demo.PopAdult)); command.Parameters.Add(OleDbUtil.CreateNullableParam("@PopFemale", demo.PopFemale)); command.Parameters.Add(OleDbUtil.CreateNullableParam("@PopMale", demo.PopMale)); command.Parameters.Add(OleDbUtil.CreateNullableParam("@Notes", demo.Notes)); command.Parameters.Add(new OleDbParameter("@UpdatedById", userId)); command.Parameters.Add(OleDbUtil.CreateDateTimeOleDbParameter("@UpdatedAt", DateTime.Now)); if (demo.Id > 0) command.Parameters.Add(new OleDbParameter("@id", demo.Id)); else { command.Parameters.Add(new OleDbParameter("@CreatedById", userId)); command.Parameters.Add(OleDbUtil.CreateDateTimeOleDbParameter("@CreatedAt", DateTime.Now)); } command.ExecuteNonQuery(); if (demo.Id <= 0) { command = new OleDbCommand(@"SELECT Max(ID) FROM AdminLevelDemography", connection); demo.Id = (int)command.ExecuteScalar(); } }
/// <summary> /// Calculates a single indicator /// </summary> /// <param name="formTranslationKey">The form translation key</param> /// <param name="field">Indicator being calculated</param> /// <param name="relatedValues">Related indicator values used in the calculation</param> /// <param name="demo">Demography data for the admin unit</param> /// <param name="start">The starting point used to determine demography information</param> /// <param name="end">The ending point used to determine demography information</param> /// <param name="errors">Errors to be displayed and managed by the ReportGenerator</param> /// <returns>The indicator name and the calculated value</returns> public override KeyValuePair<string, string> GetCalculatedValue(string formTranslationKey, string field, Dictionary<string, string> relatedValues, AdminLevelDemography demo, DateTime start, DateTime end, ref string errors) { // Combine the form translation key and field name string formNameFieldComposite = formTranslationKey + field; try { switch (formNameFieldComposite) { case "SurLeishSurvey6aff65b1-ca6f-4bd8-9982-4f0527dd8a99": return new KeyValuePair<string, string>(Translations._6aff65b1_ca6f_4bd8_9982_4f0527dd8a99, GetPercentage(GetValueOrDefault("SurLeishSurvey5f5b7326-b505-4321-90d8-ea69d6464801", relatedValues), GetValueOrDefault("SurLeishSurveye4ece583-91ce-4f0a-baf7-de45831c1135", relatedValues))); case "SurLeishSurvey9dd22c4f-8130-4fbc-8251-607f65d3a7b2": return new KeyValuePair<string, string>(Translations._9dd22c4f_8130_4fbc_8251_607f65d3a7b2, GetPercentage(GetValueOrDefault("SurLeishSurvey08bde675-17ca-4ed4-8dea-af284e15ba3d", relatedValues), GetValueOrDefault("SurLeishSurvey5f5b7326-b505-4321-90d8-ea69d6464801", relatedValues))); case "SurLeishSurvey9ed458a6-2495-4ffb-adc0-1dfd5a2b6397": return new KeyValuePair<string, string>(Translations._9ed458a6_2495_4ffb_adc0_1dfd5a2b6397, GetPercentage(GetValueOrDefault("SurLeishSurveyd61a5efa-4b2c-4f72-bf56-edab9025b6f2", relatedValues), GetValueOrDefault("SurLeishSurveya47f1af8-7399-4915-a541-ded4c2c9d739", relatedValues))); case "SurLeishSurvey71bec938-836c-467e-8e58-5fab966b71ea": return new KeyValuePair<string, string>(Translations._71bec938_836c_467e_8e58_5fab966b71ea, GetPercentage(GetValueOrDefault("SurLeishSurvey0d21bea5-9f29-4973-aa51-d3503bb284ac", relatedValues), GetValueOrDefault("SurLeishSurveyd61a5efa-4b2c-4f72-bf56-edab9025b6f2", relatedValues))); case "SurLfSentinelSpotCheckSurveyLFSurPositive": return new KeyValuePair<string, string>(Translations.LFSurPositive, GetPercentage(GetValueOrDefault("SurLfSentinelSpotCheckSurveyLFSurNumberOfIndividualsPositive", relatedValues), GetValueOrDefault("SurLfSentinelSpotCheckSurveyLFSurNumberOfIndividualsExamined", relatedValues))); case "SurBuSurveyPercentNewCasesPcrCm": return new KeyValuePair<string, string>(Translations.PercentNewCasesPcrCm, GetPercentage(GetValueOrDefault("SurBuSurveyNumCasesPcrCm", relatedValues), GetValueOrDefault("SurBuSurveyNumCasesDiagnosedCm", relatedValues))); case "SurOnchoAssesmentsOnchoSurAttendanceRate": return new KeyValuePair<string, string>(Translations.OnchoSurAttendanceRate, GetPercentage(GetValueOrDefault("SurOnchoAssesmentsOnchoSurNumberOfIndividualsExamined", relatedValues), GetValueOrDefault("SurOnchoAssesmentsOnchoSurRegistrationPopulation", relatedValues))); case "SurOnchoAssesmentsOnchoSurPercentPositive": return new KeyValuePair<string, string>(Translations.OnchoSurPercentPositive, GetPercentage(GetValueOrDefault("SurOnchoAssesmentsOnchoSurNumberOfIndividualsPositive", relatedValues), GetValueOrDefault("SurOnchoAssesmentsOnchoSurNumberOfIndividualsExamined", relatedValues))); case "SurOnchoAssesmentsOnchoSurIfTestTypeIsNpPerDep": return new KeyValuePair<string, string>(Translations.OnchoSurIfTestTypeIsNpPerDep, GetPercentage(GetValueOrDefault("SurOnchoAssesmentsOnchoSurIfTestTypeIsNpNumDep", relatedValues), GetValueOrDefault("SurOnchoAssesmentsOnchoSurNumberOfIndividualsExamined", relatedValues))); case "SurOnchoAssesmentsOnchoSurIfTestTypeIsNpPerNod": return new KeyValuePair<string, string>(Translations.OnchoSurIfTestTypeIsNpPerNod, GetPercentage(GetValueOrDefault("SurOnchoAssesmentsOnchoSurIfTestTypeIsNpNumNod", relatedValues), GetValueOrDefault("SurOnchoAssesmentsOnchoSurNumberOfIndividualsExamined", relatedValues))); case "SurOnchoAssesmentsOnchoSurIfTestTypeIsNpPerWri": return new KeyValuePair<string, string>(Translations.OnchoSurIfTestTypeIsNpPerWri, GetPercentage(GetValueOrDefault("SurOnchoAssesmentsOnchoSurIfTestTypeIsNpNumWri", relatedValues), GetValueOrDefault("SurOnchoAssesmentsOnchoSurNumberOfIndividualsExamined", relatedValues))); case "SurSchSentinelSpotCheckSurveySCHSurPrevalenceOfIntestinalSchistosomeI": return new KeyValuePair<string, string>(Translations.SCHSurPrevalenceOfIntestinalSchistosomeI, GetPercentage(GetValueOrDefault("SurSchSentinelSpotCheckSurveySCHSurNumberOfIndividualsPositiveForInte", relatedValues), GetValueOrDefault("SurSchSentinelSpotCheckSurveySCHSurNumberOfIndividualsExaminedForInte", relatedValues))); case "SurSchSentinelSpotCheckSurveySCHSurPrevalenceOfAnyHaemuaturiaOrParasi": return new KeyValuePair<string, string>(Translations.SCHSurPrevalenceOfAnyHaemuaturiaOrParasi, GetPercentage(GetValueOrDefault("SurSchSentinelSpotCheckSurveySCHSurNumberOfIndividualsPositiveForHaem", relatedValues), GetValueOrDefault("SurSchSentinelSpotCheckSurveySCHSurNumberOfIndividualsExaminedForUrin", relatedValues))); case "SurSthSentinelSpotCheckSurveySTHSurPositiveOverall": return new KeyValuePair<string, string>(Translations.STHSurPositiveOverall, GetPercentage(GetValueOrDefault("SurSthSentinelSpotCheckSurveySTHSurNumberOfIndividualsPositiveOverall", relatedValues), GetValueOrDefault("SurSthSentinelSpotCheckSurveySTHSurNumberOfIndividualsExaminedOverall", relatedValues))); case "SurSthSentinelSpotCheckSurveySTHSurPositiveTrichuris": return new KeyValuePair<string, string>(Translations.STHSurPositiveTrichuris, GetPercentage(GetValueOrDefault("SurSthSentinelSpotCheckSurveySTHSurNumberOfIndividualsPositiveTrichur", relatedValues), GetValueOrDefault("SurSthSentinelSpotCheckSurveySTHSurNumberOfIndividualsExaminedTrichur", relatedValues))); case "SurSthSentinelSpotCheckSurveySTHSurPositiveHookworm": return new KeyValuePair<string, string>(Translations.STHSurPositiveHookworm, GetPercentage(GetValueOrDefault("SurSthSentinelSpotCheckSurveySTHSurNumberOfIndividualsPositiveHookwor", relatedValues), GetValueOrDefault("SurSthSentinelSpotCheckSurveySTHSurNumberOfIndividualsExaminedHookwor", relatedValues))); case "SurSthSentinelSpotCheckSurveySTHSurPositiveAscaris": return new KeyValuePair<string, string>(Translations.STHSurPositiveAscaris, GetPercentage(GetValueOrDefault("SurSthSentinelSpotCheckSurveySTHSurNumberOfIndividualsPositiveAscaris", relatedValues), GetValueOrDefault("SurSthSentinelSpotCheckSurveySTHSurNumberOfIndividualsExaminedAscaris", relatedValues))); case "SurImpactSurveyTraSurWithClinicalSignTf": return new KeyValuePair<string, string>(Translations.TraSurWithClinicalSignTf, GetPercentage(GetValueOrDefault("SurImpactSurveyTraSurNumberOfIndividualsWithCSTF", relatedValues), GetValueOrDefault("SurImpactSurveyTraSurNumberOfIndividualsExaminedTf", relatedValues))); case "SurImpactSurveyTraSurWithClinicalSignTi": return new KeyValuePair<string, string>(Translations.TraSurWithClinicalSignTi, GetPercentage(GetValueOrDefault("SurImpactSurveyTraSurNumberOfIndividualsWithCSTI", relatedValues), GetValueOrDefault("SurImpactSurveyTraSurNumberOfIndividualsExaminedTi", relatedValues))); case "SurImpactSurveyTraSurWithClinicalSignTs": return new KeyValuePair<string, string>(Translations.TraSurWithClinicalSignTs, GetPercentage(GetValueOrDefault("SurImpactSurveyTraSurNumberOfIndividualsWithCSTS", relatedValues), GetValueOrDefault("SurImpactSurveyTraSurNumberOfIndividualsExaminedTs", relatedValues))); case "SurImpactSurveyTraSurWithClinicalSignCo": return new KeyValuePair<string, string>(Translations.TraSurWithClinicalSignCo, GetPercentage(GetValueOrDefault("SurImpactSurveyTraSurNumberOfIndividualsWithClinicalSig", relatedValues), GetValueOrDefault("SurImpactSurveyTraSurNumberOfIndividualsExaminedCo", relatedValues))); case "SurImpactSurveyTraSurWithClinicalSignTt": return new KeyValuePair<string, string>(Translations.TraSurWithClinicalSignTt, GetPercentage(GetValueOrDefault("SurImpactSurveyTraSurNumberOfIndividualsWithCSTT", relatedValues), GetValueOrDefault("SurImpactSurveyTraSurNumberOfIndividualsExaminedTt", relatedValues))); case "SurTransAssessSurveyTASActualSampleSizeTotal": return new KeyValuePair<string, string>(Translations.TASActualSampleSizeTotal, GetTotal(GetValueOrDefault("SurTransAssessSurveyTASActualSampleSizeNegative", relatedValues), GetValueOrDefault("SurTransAssessSurveyTASActualSampleSizePositive", relatedValues))); case "SurLfMappingLFMapSurPositive": return new KeyValuePair<string, string>(Translations.LFMapSurPositive, GetPercentage(GetValueOrDefault("SurLfMappingLFMapSurNumberOfIndividualsPositive", relatedValues), GetValueOrDefault("SurLfMappingLFMapSurNumberOfIndividualsExamined", relatedValues))); case "SurOnchoMappingOnchoMapSurAttendanceRate": return new KeyValuePair<string, string>(Translations.OnchoMapSurAttendanceRate, GetPercentage(GetValueOrDefault("SurOnchoMappingOnchoMapSurNumberOfIndividualsExamined", relatedValues), GetValueOrDefault("SurOnchoMappingOnchoMapSurRegistrationPopulation", relatedValues))); case "SurOnchoMappingOnchoMapSurPercentPositive": return new KeyValuePair<string, string>(Translations.OnchoMapSurPercentPositive, GetPercentage(GetValueOrDefault("SurOnchoMappingOnchoMapSurNumberOfIndividualsPositive", relatedValues), GetValueOrDefault("SurOnchoMappingOnchoMapSurNumberOfIndividualsExamined", relatedValues))); case "SurOnchoMappingOnchoMapSurIfTestTypeIsNpPerDep": return new KeyValuePair<string, string>(Translations.OnchoMapSurIfTestTypeIsNpPerDep, GetPercentage(GetValueOrDefault("SurOnchoMappingOnchoMapSurIfTestTypeIsNpNumDep", relatedValues), GetValueOrDefault("SurOnchoMappingOnchoMapSurNumberOfIndividualsExamined", relatedValues))); case "SurOnchoMappingOnchoMapSurIfTestTypeIsNpPerNod": return new KeyValuePair<string, string>(Translations.OnchoMapSurIfTestTypeIsNpPerNod, GetPercentage(GetValueOrDefault("SurOnchoMappingOnchoMapSurIfTestTypeIsNpNumNod", relatedValues), GetValueOrDefault("SurOnchoMappingOnchoMapSurNumberOfIndividualsExamined", relatedValues))); case "SurOnchoMappingOnchoMapSurIfTestTypeIsNpPerWri": return new KeyValuePair<string, string>(Translations.OnchoMapSurIfTestTypeIsNpPerWri, GetPercentage(GetValueOrDefault("SurOnchoMappingOnchoMapSurIfTestTypeIsNpNumWri", relatedValues), GetValueOrDefault("SurOnchoMappingOnchoMapSurNumberOfIndividualsExamined", relatedValues))); case "SurSchMappingSCHMapSurPrevalenceOfAnyHaemuaturiaOrPar": return new KeyValuePair<string, string>(Translations.SCHMapSurPrevalenceOfAnyHaemuaturiaOrPar, GetPercentage(GetValueOrDefault("SurSchMappingSCHMapSurNumberOfIndividualsPositiveForH", relatedValues), GetValueOrDefault("SurSchMappingSCHMapSurNumberOfIndividualsExaminedForU", relatedValues))); case "SurSchMappingSCHMapSurPrevalenceOfIntestinalSchistoso": return new KeyValuePair<string, string>(Translations.SCHMapSurPrevalenceOfIntestinalSchistoso, GetPercentage(GetValueOrDefault("SurSchMappingSCHMapSurNumberOfIndividualsPositiveForI", relatedValues), GetValueOrDefault("SurSchMappingSCHMapSurNumberOfIndividualsExaminedForI", relatedValues))); case "SurSthMappingSTHMapSurSurPerPositiveOverall": return new KeyValuePair<string, string>(Translations.STHMapSurSurPerPositiveOverall, GetPercentage(GetValueOrDefault("SurSthMappingSTHMapSurSurNumberOfIndividualsPositiveOverall", relatedValues), GetValueOrDefault("SurSthMappingSTHMapSurSurNumberOfIndividualsExaminedOverall", relatedValues))); case "SurSthMappingSTHMapSurSurPerPositiveTrichuris": return new KeyValuePair<string, string>(Translations.STHMapSurSurPerPositiveTrichuris, GetPercentage(GetValueOrDefault("SurSthMappingSTHMapSurSurNumberOfIndividualsPositiveTrichur", relatedValues), GetValueOrDefault("SurSthMappingSTHMapSurSurNumberOfIndividualsExaminedTrichur", relatedValues))); case "SurSthMappingSTHMapSurSurPerPositiveHookworm": return new KeyValuePair<string, string>(Translations.STHMapSurSurPerPositiveHookworm, GetPercentage(GetValueOrDefault("SurSthMappingSTHMapSurSurNumberOfIndividualsPositiveHookwor", relatedValues), GetValueOrDefault("SurSthMappingSTHMapSurSurNumberOfIndividualsExaminedHookwor", relatedValues))); case "SurSthMappingSTHMapSurSurPerPositiveAscaris": return new KeyValuePair<string, string>(Translations.STHMapSurSurPerPositiveAscaris, GetPercentage(GetValueOrDefault("SurSthMappingSTHMapSurSurNumberOfIndividualsPositiveAscaris", relatedValues), GetValueOrDefault("SurSthMappingSTHMapSurSurNumberOfIndividualsExaminedAscaris", relatedValues))); case "SurTrachomaMappingTraMapSurPerWithClinicalSignTf": return new KeyValuePair<string, string>(Translations.TraMapSurPerWithClinicalSignTf, GetPercentage(GetValueOrDefault("SurTrachomaMappingTraMapSurNumberOfIndividualsWithClTF", relatedValues), GetValueOrDefault("SurTrachomaMappingTraMapSurNumberOfIndividualsExaminedTf", relatedValues))); case "SurTrachomaMappingTraMapSurPerWithClinicalSignTt": return new KeyValuePair<string, string>(Translations.TraMapSurPerWithClinicalSignTt, GetPercentage(GetValueOrDefault("SurTrachomaMappingTraMapSurNumberOfIndividualsWithClTT", relatedValues), GetValueOrDefault("SurTrachomaMappingTraMapSurNumberOfIndividualsExaminedTt", relatedValues))); case "SurTrachomaMappingTraMapSurPerWithClinicalSignTi": return new KeyValuePair<string, string>(Translations.TraMapSurPerWithClinicalSignTi, GetPercentage(GetValueOrDefault("SurTrachomaMappingTraMapSurNumberOfIndividualsWithClTI", relatedValues), GetValueOrDefault("SurTrachomaMappingTraMapSurNumberOfIndividualsExaminedTi", relatedValues))); case "SurTrachomaMappingTraMapSurPerWithClinicalSignTs": return new KeyValuePair<string, string>(Translations.TraMapSurPerWithClinicalSignTs, GetPercentage(GetValueOrDefault("SurTrachomaMappingTraMapSurNumberOfIndividualsWithClTS", relatedValues), GetValueOrDefault("SurTrachomaMappingTraMapSurNumberOfIndividualsExaminedTs", relatedValues))); case "SurTrachomaMappingTraMapSurPerWithClinicalSignCo": return new KeyValuePair<string, string>(Translations.TraMapSurPerWithClinicalSignCo, GetPercentage(GetValueOrDefault("SurTrachomaMappingTraMapSurNumberOfIndividualsWithClinical", relatedValues), GetValueOrDefault("SurTrachomaMappingTraMapSurNumberOfIndividualsExamined", relatedValues))); case "OnchoSurEntomologicalOnchoSurInfectionRate": return new KeyValuePair<string, string>(Translations.OnchoSurInfectionRate, GetPercentage(GetValueOrDefault("OnchoSurEntomologicalOnchoSurParousFliesInfected", relatedValues), GetValueOrDefault("OnchoSurEntomologicalOnchoSurParousFliesDisected", relatedValues))); case "OnchoSurEntomologicalOnchoSurParousRate": return new KeyValuePair<string, string>(Translations.OnchoSurParousRate, GetPercentage(GetValueOrDefault("OnchoSurEntomologicalOnchoSurParousFlies", relatedValues), GetValueOrDefault("OnchoSurEntomologicalOnchoSurFliesDissected", relatedValues))); case "OnchoSurEntomologicalOnchoSurInfectivityRate": return new KeyValuePair<string, string>(Translations.OnchoSurInfectivityRate, GetPercentage(GetValueOrDefault("OnchoSurEntomologicalOnchoSurInfectiveFlies", relatedValues), GetValueOrDefault("OnchoSurEntomologicalOnchoSurNoFlies", relatedValues), 1000)); case "SurSchSentinelSpotCheckSurveySchSentinelPrevalenceEggsInUrine": return new KeyValuePair<string, string>(Translations.SchSentinelPrevalenceEggsInUrine, GetPercentage(GetValueOrDefault("SurSchSentinelSpotCheckSurveySCHSurNumPosSchParasite", relatedValues), GetValueOrDefault("SurSchSentinelSpotCheckSurveySCHSurNumberOfIndividualsExaminedForUrin", relatedValues))); case "SurSchMappingSchMappingPrevalenceEggsInUrine": return new KeyValuePair<string, string>(Translations.SchMappingPrevalenceEggsInUrine, GetPercentage(GetValueOrDefault("SurSchMappingSCHMapSurNumPosSchParasite", relatedValues), GetValueOrDefault("SurSchMappingSCHMapSurNumberOfIndividualsExaminedForU", relatedValues))); default: return new KeyValuePair<string, string>(formNameFieldComposite, Translations.NA); } } catch (Exception) { return new KeyValuePair<string, string>(formNameFieldComposite, Translations.CalculationError); } }
public AdminLevelDemography GetRecentDemography(int adminLevelId, DateTime? start, DateTime? end, OleDbConnection connection) { AdminLevelDemography demog = new AdminLevelDemography { AdminLevelId = adminLevelId }; OleDbCommand command = new OleDbCommand(@"Select a.ID FROM AdminLevelDemography a WHERE AdminLevelId = @id and IsDeleted = 0 " + CreateDateRange(start, end) + " ORDER BY DateDemographyData Desc", connection); command.Parameters.Add(new OleDbParameter("@id", adminLevelId)); using (OleDbDataReader reader = command.ExecuteReader()) { if (reader.Read()) { int id = reader.GetValueOrDefault<int>("ID"); GetDemoById(demog, id, connection, command); } reader.Close(); } return demog; }