diff --git a/src/DTOs/PopulationMaternityDTO.ts b/src/DTOs/PopulationMaternityDTO.ts index 940f618adef39ceaa551e8dd37fc6ee7dc413407..c47f4730af1b3aa2a7067e455b31291ff6c45ce7 100644 --- a/src/DTOs/PopulationMaternityDTO.ts +++ b/src/DTOs/PopulationMaternityDTO.ts @@ -1,5 +1,6 @@ type PopulationMaternity = { countryBirthRate: number; + countryWomenInAgeGroup: number; countryPopulation: number; }; diff --git a/src/Enum/AgeBracket.ts b/src/Enum/AgeBracket.ts index 2017b243bce735fb12ad292cb427a43e10f9d5a0..4d9fdbbca68fddfcca9731f76048ccfefbf91dfe 100644 --- a/src/Enum/AgeBracket.ts +++ b/src/Enum/AgeBracket.ts @@ -11,7 +11,7 @@ enum AgeBracket { m9 = '9 meses', m10 = '10 meses', m11 = '11 meses', - a1 = '1 año', + a1 = '1 años', a2 = '2 años', a3 = '3 años', a4 = '4 años', diff --git a/src/Services/ERCalculator.ts b/src/Services/ERCalculator.ts index 3a3513adfbb7360e8542761c3e07fc6c8c2d4973..f9af891fd6c66b6ac307a3b7df9d0c80305cd10b 100644 --- a/src/Services/ERCalculator.ts +++ b/src/Services/ERCalculator.ts @@ -13,7 +13,7 @@ import ParserService from './ParserService'; // eslint-disable-next-line max-len const isIndividualMaternity = (obj: IndividualMaternity | PopulationMaternity): obj is IndividualMaternity => { - if ((obj as IndividualMaternity).pregnantWomen) { + if ((obj as IndividualMaternity).pregnantWomen !== undefined) { return true; } return false; @@ -23,9 +23,9 @@ const isIndividualMaternity = (obj: IndividualMaternity | PopulationMaternity): const calculateTEE = (group: AgeGroup, params: number[], preval: MinorPAL): number => { const teeModerate: number = params[0] + (params[1] * group.medianWeight) - - params[2] * (group.medianWeight * group.medianWeight); + + params[2] * (group.medianWeight * group.medianWeight); - const teeLow: number = teeModerate - (teeModerate * params[4]) / 100; + const teeLow: number = teeModerate + (teeModerate * params[4]) / 100; const teeIntense: number = teeModerate + (teeModerate * params[5]) / 100; const ret: number = (teeLow * preval.lowPALPrevalence) / 100 @@ -66,11 +66,11 @@ const calculateERWomenIndividual = (group: AgeGroup, params: number[], popData: }; // eslint-disable-next-line max-len -const calculateERWomenPopulation = (group: AgeGroup, params: number[], popData: PopulationMaternity, req: number): number => { - const annualBirths = popData.countryBirthRate * popData.countryPopulation; +const calculateERWomenPopulation = (params: number[], popData: PopulationMaternity, req: number): number => { + const annualBirths = (popData.countryBirthRate * popData.countryPopulation) / 1000; - const percentPregnantWomen = (annualBirths * 75) / group.population; - const percentLactatingWomen = (annualBirths * 50) / group.population; + const percentPregnantWomen = (annualBirths * 75) / popData.countryWomenInAgeGroup; + const percentLactatingWomen = (annualBirths * 50) / popData.countryWomenInAgeGroup; const reqPregnantWomen = (percentPregnantWomen * (req + params[6])) / 100; const reqLactatingWomen = (percentLactatingWomen * (req + params[7])) / 100; @@ -147,7 +147,7 @@ const calculate18To29Years = (group: AgeGroup, params: number[], data: ExtraData } else if (isIndividualMaternity(data.maternity18To29)) { requirement = calculateERWomenIndividual(group, params, data.maternity18To29, requirement); } else { - requirement = calculateERWomenPopulation(group, params, data.maternity18To29, requirement); + requirement = calculateERWomenPopulation(params, data.maternity18To29, requirement); } } @@ -181,7 +181,7 @@ const calculate30To59Years = (group: AgeGroup, params: number[], data: ExtraData } else if (isIndividualMaternity(data.maternity30To59)) { requirement = calculateERWomenIndividual(group, params, data.maternity30To59, requirement); } else { - requirement = calculateERWomenPopulation(group, params, data.maternity30To59, requirement); + requirement = calculateERWomenPopulation(params, data.maternity30To59, requirement); } } diff --git a/src/Services/ParameterService.ts b/src/Services/ParameterService.ts index 30f6085b228efb7e6534bcad8818c630f1bf9916..41469c5ef27a065ceb36d291ca53f62d2821a524 100644 --- a/src/Services/ParameterService.ts +++ b/src/Services/ParameterService.ts @@ -179,120 +179,120 @@ const getEquationValues = (ageBracket: AgeBracket, sex: Sex): number[] => { case (AgeBracket.a6): { if (sex === Sex.Male) { // 310.2 + (63.3*MP) - 0.263*MP^2 + 11, -15%/+15% for light/intense TEE - res = [310.2, 63.3, -0.263, 12, 15, 15]; + res = [310.2, 63.3, -0.263, 12, -15, 15]; } else if (sex === Sex.Female) { // 263.4 + (65.3*MP) - 0.454*MP^2 + 10, -15%/+15% for light/intense TEE - res = [263.4, 65.3, -0.454, 13, 15, 15]; + res = [263.4, 65.3, -0.454, 13, -15, 15]; } break; } case (AgeBracket.a7): { if (sex === Sex.Male) { // 310.2 + (63.3*MP) - 0.263*MP^2 + 14, -15%/+15% for light/intense TEE - res = [310.2, 63.3, -0.263, 14, 15, 15]; + res = [310.2, 63.3, -0.263, 14, -15, 15]; } else if (sex === Sex.Female) { // 263.4 + (65.3*MP) - 0.454*MP^2 + 17, -15%/+15% for light/intense TEE - res = [263.4, 65.3, -0.454, 17, 15, 15]; + res = [263.4, 65.3, -0.454, 17, -15, 15]; } break; } case (AgeBracket.a8): { if (sex === Sex.Male) { // 310.2 + (63.3*MP) - 0.263*MP^2 + 16, -15%/+15% for light/intense TEE - res = [310.2, 63.3, -0.263, 16, 15, 15]; + res = [310.2, 63.3, -0.263, 16, -15, 15]; } else if (sex === Sex.Female) { // 263.4 + (65.3*MP) - 0.454*MP^2 + 20, -15%/+15% for light/intense TEE - res = [263.4, 65.3, -0.454, 20, 15, 15]; + res = [263.4, 65.3, -0.454, 20, -15, 15]; } break; } case (AgeBracket.a9): { if (sex === Sex.Male) { // 310.2 + (63.3*MP) - 0.263*MP^2 + 19, -15%/+15% for light/intense TEE - res = [310.2, 63.3, -0.263, 19, 15, 15]; + res = [310.2, 63.3, -0.263, 19, -15, 15]; } else if (sex === Sex.Female) { // 263.4 + (65.3*MP) - 0.454*MP^2 + 23, -15%/+15% for light/intense TEE - res = [263.4, 65.3, -0.454, 23, 15, 15]; + res = [263.4, 65.3, -0.454, 23, -15, 15]; } break; } case (AgeBracket.a10): { if (sex === Sex.Male) { // 310.2 + (63.3*MP) - 0.263*MP^2 + 22, -15%/+15% for light/intense TEE - res = [310.2, 63.3, -0.263, 22, 15, 15]; + res = [310.2, 63.3, -0.263, 22, -15, 15]; } else if (sex === Sex.Female) { // 263.4 + (65.3*MP) - 0.454*MP^2 + 25, -15%/+15% for light/intense TEE - res = [263.4, 65.3, -0.454, 25, 15, 15]; + res = [263.4, 65.3, -0.454, 25, -15, 15]; } break; } case (AgeBracket.a11): { if (sex === Sex.Male) { // 310.2 + (63.3*MP) - 0.263*MP^2 + 25, -15%/+15% for light/intense TEE - res = [310.2, 63.3, -0.263, 25, 15, 15]; + res = [310.2, 63.3, -0.263, 25, -15, 15]; } else if (sex === Sex.Female) { // 263.4 + (65.3*MP) - 0.454*MP^2 + 25, -15%/+15% for light/intense TEE - res = [263.4, 65.3, -0.454, 25, 15, 15]; + res = [263.4, 65.3, -0.454, 25, -15, 15]; } break; } case (AgeBracket.a12): { if (sex === Sex.Male) { // 310.2 + (63.3*MP) - 0.263*MP^2 + 29, -15%/+15% for light/intense TEE - res = [310.2, 63.3, -0.263, 29, 15, 15]; + res = [310.2, 63.3, -0.263, 29, -15, 15]; } else if (sex === Sex.Female) { // 263.4 + (65.3*MP) - 0.454*MP^2 + 26, -15%/+15% for light/intense TEE - res = [263.4, 65.3, -0.454, 26, 15, 15]; + res = [263.4, 65.3, -0.454, 26, -15, 15]; } break; } case (AgeBracket.a13): { if (sex === Sex.Male) { // 310.2 + (63.3*MP) - 0.263*MP^2 + 33, -15%/+15% for light/intense TEE - res = [310.2, 63.3, -0.263, 33, 15, 15]; + res = [310.2, 63.3, -0.263, 33, -15, 15]; } else if (sex === Sex.Female) { // 263.4 + (65.3*MP) - 0.454*MP^2 + 24, -15%/+15% for light/intense TEE - res = [263.4, 65.3, -0.454, 24, 15, 15]; + res = [263.4, 65.3, -0.454, 24, -15, 15]; } break; } case (AgeBracket.a14): { if (sex === Sex.Male) { // 310.2 + (63.3*MP) - 0.263*MP^2 + 33, -15%/+15% for light/intense TEE - res = [310.2, 63.3, -0.263, 33, 15, 15]; + res = [310.2, 63.3, -0.263, 33, -15, 15]; } else if (sex === Sex.Female) { // 263.4 + (65.3*MP) - 0.454*MP^2 + 19, -15%/+15% for light/intense TEE - res = [263.4, 65.3, -0.454, 19, 15, 15]; + res = [263.4, 65.3, -0.454, 19, -15, 15]; } break; } case (AgeBracket.a15): { if (sex === Sex.Male) { // 310.2 + (63.3*MP) - 0.263*MP^2 + 31, -15%/+15% for light/intense TEE - res = [310.2, 63.3, -0.263, 31, 15, 15]; + res = [310.2, 63.3, -0.263, 31, -15, 15]; } else if (sex === Sex.Female) { // 263.4 + (65.3*MP) - 0.454*MP^2 + 13, -15%/+15% for light/intense TEE - res = [263.4, 65.3, -0.454, 13, 15, 15]; + res = [263.4, 65.3, -0.454, 13, -15, 15]; } break; } case (AgeBracket.a16): { if (sex === Sex.Male) { // 310.2 + (63.3*MP) - 0.263*MP^2 + 24, -15%/+15% for light/intense TEE - res = [310.2, 63.3, -0.263, 24, 15, 15]; + res = [310.2, 63.3, -0.263, 24, -15, 15]; } else if (sex === Sex.Female) { // 263.4 + (65.3*MP) - 0.454*MP^2 + 5, -15%/+15% for light/intense TEE - res = [263.4, 65.3, -0.454, 5, 15, 15]; + res = [263.4, 65.3, -0.454, 5, -15, 15]; } break; } case (AgeBracket.a17): { if (sex === Sex.Male) { // 310.2 + (63.3*MP) - 0.263*MP^2 + 14, -15%/+15% for light/intense TEE - res = [310.2, 63.3, -0.263, 14, 15, 15]; + res = [310.2, 63.3, -0.263, 14, -15, 15]; } else if (sex === Sex.Female) { // 263.4 + (65.3*MP) - 0.454*MP^2 + 0, -15%/+15% for light/intense TEE - res = [263.4, 65.3, -0.454, 0, 15, 15]; + res = [263.4, 65.3, -0.454, 0, -15, 15]; } break; }