Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/numerator obs values #260

Merged
merged 10 commits into from
Feb 15, 2024
111,759 changes: 55,880 additions & 55,879 deletions dist/browser.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion lib/helpers/calculator_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ module.exports = class CalculatorHelpers {
}
if ('observation_values' in populationResults) {
// DENOM observation will be the first of 2 observations
populationResultsHandled.observation_values[1] = populationResultsHandled.observation_values[0];
populationResultsHandled.observation_values[0] = 0;
}
}
if (populationResults.DENEX != null && !this.isValueZero('DENEX', populationResults) && populationResults.DENEX >= populationResults.DENOM) {
if ('observation_values' in populationResults) {
// DENOM observation will be the first of 2 observations
populationResultsHandled.observation_values[0] = 0;
}
}
Expand Down Expand Up @@ -311,6 +311,7 @@ module.exports = class CalculatorHelpers {
});
}
}

if ((observationDefs != null ? observationDefs.length : undefined) > 0) {
// Handle observations using the names of the define statements that
// were added to the ELM to call the observation functions.
Expand Down
63 changes: 63 additions & 0 deletions spec/helpers/calculator_helpers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,68 @@ describe('CalculatorHelpers', () => {
const processedResults = CalculatorHelpers.handlePopulationValues(initialResults);
expect(processedResults).toEqual(expectedResults);
});

it('Should remove DENEX and defaults denominator observation value if not a member of DENOM for RATIO measures', () => {
const initialResults = {
IPP: 1,
DENOM: 0,
DENEX: 7,
NUMER: 1,
NUMEX: 0,
observation_values: [4],
};
const expectedResults = {
IPP: 1,
DENOM: 0,
DENEX: 0,
NUMER: 1,
NUMEX: 0,
observation_values: [0, 4],
};
const processedResults = CalculatorHelpers.handlePopulationValues(initialResults, 'RATIO');
expect(processedResults).toEqual(expectedResults);
});

it('Should default denominator observation value if the episode is a member of DENOM and DENEX for RATIO measures', () => {
const initialResults = {
IPP: 1,
DENOM: 1,
DENEX: 1,
NUMER: 1,
NUMEX: 0,
observation_values: [2, 4],
};
const expectedResults = {
IPP: 1,
DENOM: 1,
DENEX: 1,
NUMER: 1,
NUMEX: 0,
observation_values: [0, 4],
};
const processedResults = CalculatorHelpers.handlePopulationValues(initialResults, 'RATIO');
expect(processedResults).toEqual(expectedResults);
});

it('Should remove NUMEX and updated Observation values if not a member of NUMER for RATIO measures', () => {
const initialResults = {
IPP: 1,
DENOM: 1,
DENEX: 0,
NUMER: 0,
NUMEX: 0,
observation_values: [4],
};
const expectedResults = {
IPP: 1,
DENOM: 1,
DENEX: 0,
NUMER: 0,
NUMEX: 0,
observation_values: [4, 0],
};
const processedResults = CalculatorHelpers.handlePopulationValues(initialResults, 'RATIO');
expect(processedResults).toEqual(expectedResults);
});
});
});
Loading