Skip to content
Snippets Groups Projects
Commit a9216ee6 authored by Agustin Ruiz Diaz Cambon's avatar Agustin Ruiz Diaz Cambon
Browse files

Maternity women aged 30 to 59 fixed

Now population maternity calculation is only available for women
aged 18 to 29
parent 8d5c22ee
No related branches found
No related tags found
No related merge requests found
......@@ -130,27 +130,7 @@ const getRepBody = {
type: 'number' as const,
minimum: 0,
},
countryBirthRate: {
type: 'number' as const,
minimum: 0,
},
countryWomenInAgeGroup: {
type: 'number' as const,
exclusiveMinimum: 0,
},
countryPopulation: {
type: 'number' as const,
exclusiveMinimum: 0,
},
},
oneOf: [
{
required: ['pregnantWomen', 'lactatingWomen'],
},
{
required: ['countryBirthRate', 'countryWomenInAgeGroup', 'countryPopulation'],
},
],
},
},
},
......
......@@ -196,13 +196,11 @@ const calculate30To59Years = (group: AgeGroup, params: number[], data: ExtraData
// If the group's sex is Female, then you have to take into account
// the extra energy required by women that are pregnant or lactating
if (group.sex === Sex.Female) {
if (typeof (data.maternity30To59) === 'undefined') {
throw new Error('Missing maternity data for women aged 30 to 59');
} else if (isIndividualMaternity(data.maternity30To59)) {
if (group.sex === Sex.Female && data.maternity30To59 !== undefined) {
if (isIndividualMaternity(data.maternity30To59)) {
requirement = calculateERWomenIndividual(group, params, data.maternity30To59, requirement);
} else {
requirement = calculateERWomenPopulation(params, data.maternity30To59, requirement);
throw new Error('Invalid maternity data for 30 to 59 years old women group');
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment