Skip to content

Commit

Permalink
feat: Omit Report Scores with Scoring Type "Score" from the Report Su…
Browse files Browse the repository at this point in the history
…mmary Screen (M2-8097) (#875)

This PR updates the Report Summary screen to omit report scores configured with scoring type `score`. These are scores that are linked to a subscale and are currently not supported as part of the report summary screen.
  • Loading branch information
sultanofcardio authored Oct 25, 2024
1 parent 637ed17 commit e8d4584
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
20.10.0
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Running the app:

### 1. Prerequisites

- NodeJS `18` or higher, recommend using `asdf` or `nvm` to manage local node version
- NodeJS `20.10.0` or higher, recommend using `asdf` or `nvm` to manage local node version
- Yarn 1.x
- Follow steps in [React Native CLI Environment Setup](https://reactnative.dev/docs/environment-setup?guide=native), including:
- Watchman
Expand Down
9 changes: 9 additions & 0 deletions src/entities/activity/lib/types/activityReportSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,20 @@ export type ScoreConditionalLogic = {
conditions: Array<Condition>;
};

export const ScoreReportScoringType = ['score', 'raw_score'] as const;

export type ScoreReportScoringType = (typeof ScoreReportScoringType)[number];

export type Report = {
id: string;
calculationType: CalculationType;
includedItems: Array<string>;
name: string;
type: ReportType;
conditionalLogic: Array<ScoreConditionalLogic>;

/** Whether to show raw score or T scores in the report */
scoringType: ScoreReportScoringType;
/** The name of a subscale to use for a lookup table, if `scoringType` is set to "score" */
subscaleName?: string;
};
1 change: 1 addition & 0 deletions src/entities/activity/model/mappers.input.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,7 @@ export const conditionalInput: ActivityDto = {
{
itemsScore: ['one'],
type: 'score',
scoringType: 'raw_score',
id: '1',
name: 'name',
calculationType: 'sum',
Expand Down
1 change: 1 addition & 0 deletions src/entities/activity/model/mappers.output.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,7 @@ export const conditionalOutput: ActivityDetails = {
includedItems: ['one'],
name: 'name',
type: 'score',
scoringType: 'raw_score',
},
],
showAllAtOnce: false,
Expand Down
2 changes: 2 additions & 0 deletions src/entities/activity/model/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,8 @@ export function mapToActivity(dto: ActivityDto): ActivityDetails {
calculationType: x.calculationType,
conditionalLogic: x.conditionalLogic,
includedItems: x.itemsScore,
scoringType: x.scoringType,
subscaleName: x.subscaleName,
})),
};

Expand Down
8 changes: 8 additions & 0 deletions src/features/pass-survey/model/ScoresExtractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ export class ScoresExtractor implements IScoresExtractor {
);

for (const scoreSettings of settings) {
if (
scoreSettings.type === 'score' &&
scoreSettings.scoringType === 'score'
) {
// Skip report scores that are not configured as raw scores
continue;
}

const logScore = `'${scoreSettings.name}' for settings with index '${settingsIndex}'`;

try {
Expand Down
32 changes: 32 additions & 0 deletions src/features/pass-survey/model/tests/ScoresExtractor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ describe('ScoresCalculator: test collectScoreForRadio', () => {
includedItems: [RadioItemName, CheckboxesItemName, SliderItemName],
name: 'mock-report-name-1',
type: 'score',
scoringType: 'raw_score',
},
];

Expand Down Expand Up @@ -247,6 +248,7 @@ describe('ScoresCalculator: test collectScoreForRadio', () => {
includedItems: [RadioItemName, CheckboxesItemName, SliderItemName],
name: 'mock-report-name-1',
type: 'score',
scoringType: 'raw_score',
},
{
calculationType: 'average',
Expand All @@ -255,6 +257,7 @@ describe('ScoresCalculator: test collectScoreForRadio', () => {
includedItems: [RadioItemName, CheckboxesItemName, SliderItemName],
name: 'mock-report-name-2',
type: 'score',
scoringType: 'raw_score',
},
{
calculationType: 'percentage',
Expand All @@ -263,6 +266,7 @@ describe('ScoresCalculator: test collectScoreForRadio', () => {
includedItems: [RadioItemName, CheckboxesItemName, SliderItemName],
name: 'mock-report-name-3',
type: 'score',
scoringType: 'raw_score',
},
];

Expand Down Expand Up @@ -328,6 +332,7 @@ describe('ScoresCalculator: test collectScoreForRadio', () => {
includedItems: selectedItems,
name: 'mock-report-name-1',
type: 'score',
scoringType: 'raw_score',
},
];

Expand All @@ -347,6 +352,32 @@ describe('ScoresCalculator: test collectScoreForRadio', () => {
},
);

it('Should exclude report items with scoringType "score"', () => {
const { pipelineItems, answers } = getItemsAndAnswers();

const reportSettings: Report[] = [
{
calculationType: 'sum',
conditionalLogic: [],
id: 'mock-report-id-1',
includedItems: ['item-radio', 'item-checkboxes'],
name: 'mock-report-name-1',
type: 'score',
scoringType: 'score',
subscaleName: 'mock-subscale-name-1',
},
];

const result: ScoreRecord[] = extractor.extract(
pipelineItems,
answers,
reportSettings,
'mock-log-activity-name-1',
);

expect(result).toHaveLength(0);
});

it("Should return 517 and flagged set to true when calculationType is 'sum' and one condition is set: equal to 517", () => {
const { pipelineItems, answers } = getItemsAndAnswers();

Expand All @@ -372,6 +403,7 @@ describe('ScoresCalculator: test collectScoreForRadio', () => {
includedItems: [RadioItemName, CheckboxesItemName, SliderItemName],
name: 'mock-report-name-1',
type: 'score',
scoringType: 'raw_score',
},
];

Expand Down
8 changes: 8 additions & 0 deletions src/shared/api/services/ActivityReportSettingsDtos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ type CalculationType = 'average' | 'percentage' | 'sum';

type MatchType = 'all' | 'any';

const ScoreReportScoringType = ['score', 'raw_score'] as const;

type ScoreReportScoringType = (typeof ScoreReportScoringType)[number];

type ConditionDto =
| GreaterThanCondition
| LessThanCondition
Expand Down Expand Up @@ -77,4 +81,8 @@ export type ReportDto = {
name: string;
type: ReportType;
conditionalLogic: Array<ScoreConditionalLogicDto>;
/** Whether to show raw score or T scores in the report */
scoringType: ScoreReportScoringType;
/** The name of a subscale to use for a lookup table, if `scoringType` is set to "score" */
subscaleName?: string;
};

0 comments on commit e8d4584

Please sign in to comment.