Skip to content

Commit

Permalink
feat(calcs): start back, visa, zarit
Browse files Browse the repository at this point in the history
  • Loading branch information
nckhell committed Jan 8, 2025
1 parent 32e98d9 commit 885ba46
Show file tree
Hide file tree
Showing 58 changed files with 1,160 additions and 1,586 deletions.
16 changes: 8 additions & 8 deletions src/scores/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ import { sccai } from './sccai/sccai'
import { sf12 } from './sf12/sf12'
// import { spadi } from './spadi/spadi'
import { simple_shoulder_test } from './sst/simple_shoulder_test'
// import { start_back_screening_tool } from './start_back_screening_tool/start_back_screening_tool'
import { start_back_screening_tool } from './start_back_screening_tool/start_back_screening_tool'
import { tampa } from './tampa/tampa'
// import { visa_a, visa_g, visa_p } from './visa'
import { visa_a, visa_g, visa_p } from './visa'
import { yp_core } from './yp_core/yp_core'
// import { zarit_12 } from './zarit_12/zarit_12'
import { zarit_12 } from './zarit_12/zarit_12'
import { acro } from './acro/acro'
import { Score } from '../classes'
import { ScoreType } from '../types'
Expand Down Expand Up @@ -260,13 +260,13 @@ export const ScoreLibrary = createScoreLibrary({
// short_fes_i,
// spadi,
simple_shoulder_test,
// start_back_screening_tool,
start_back_screening_tool,
stop_bang,
tampa,
ten_meter_walk_test,
// visa_a,
// visa_g,
// visa_p,
visa_a,
visa_g,
visa_p,
yp_core,
// zarit_12,
zarit_12,
})
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,92 +1,77 @@
import type { InputType } from '../../../src/types/calculations.types'
import { NumberInputType } from '../../../src/types/calculations/inputs/calculation-inputs.types'
import { z } from 'zod'
import { EnumNumberInputType, ScoreInputSchemaType } from '../../../types'

const DISAGREE_ANSWER = 0
const AGREE_ANSWER = 1

const type: NumberInputType = {
type: 'number',
allowed_answers: [
{ value: DISAGREE_ANSWER, label: { en: 'Disagree', nl: 'Oneens' } },
{ value: AGREE_ANSWER, label: { en: 'Agree', nl: 'Eens' } },
],
}
const type = {
type: z.union([z.literal(DISAGREE_ANSWER), z.literal(AGREE_ANSWER)]),
uiOptions: {
options: [
{ value: DISAGREE_ANSWER, label: { en: 'Disagree', nl: 'Oneens' } },
{ value: AGREE_ANSWER, label: { en: 'Agree', nl: 'Eens' } },
],
},
} satisfies EnumNumberInputType

export const START_BACK_INPUTS: Array<InputType> = [
{
input_id: 'Q01',
export const START_BACK_INPUTS = {
Q01: {
label: {
en: 'My back pain has spread down my leg(s) at some time in the last 2 weeks',
nl: 'In de laatste 2 weken straalde mijn rugpijn wel eens uit naar één of beide benen.',
},
input_type,
required: true,
...type,
},
{
input_id: 'Q02',
Q02: {
label: {
en: 'I have had pain in the shoulder or neck at some time in the last 2 weeks',
nl: 'In de laatste 2 weken heb ik wel eens pijn in mijn schouder of nek gehad.',
},
input_type,
required: true,
...type,
},
{
input_id: 'Q03',
Q03: {
label: {
en: 'I have only walked short distances because of my back pain',
nl: 'Vanwege mijn rugpijn liep ik alleen korte afstanden.',
},
input_type,
required: true,
...type,
},
{
input_id: 'Q04',
Q04: {
label: {
en: 'In the last 2 weeks, I have dressed more slowly than usual because of back pain',
nl: 'In de laatste 2 weken kleedde ik me trager dan gewoonlijk aan vanwege mijn rugpijn.',
},
input_type,
required: true,
...type,
},
{
input_id: 'Q05',
Q05: {
label: {
en: `It's not really safe for a person with a condition like mine to be physically active`,
nl: 'Voor iemand in mijn toestand is het echt niet veilig om lichamelijk actief te zijn.',
},
input_type,
required: true,
...type,
},
{
input_id: 'Q06',
Q06: {
label: {
en: 'Worrying thoughts have been going through my mind a lot of the time',
nl: 'Ongeruste gedachten gingen vaak door mijn hoofd.',
},
input_type,
required: true,
...type,
},
{
input_id: 'Q07',
Q07: {
label: {
en: `I feel that my back pain is terrible and it's never going to get any better`,
nl: 'Ik vind dat mijn rugpijn verschrikkelijk is en ik geloof dat het nooit meer beter zal worden.',
},
input_type,
required: true,
...type,
},
{
input_id: 'Q08',
Q08: {
label: {
en: 'In general I have not enjoyed all the things I used to enjoy',
nl: 'Over het geheel genomen heb ik niet genoten van alle dingen waar ik vroeger wel van genoot.',
},
input_type,
required: true,
...type,
},
{
input_id: 'Q09',
Q09: {
label: {
en: 'Overall, how bothersome has your back pain been in th last 2 weeks?',
nl: 'Over het geheel genomen, hoe hinderlijk was uw rugpijn in de laatste 2 weken ?',
Expand All @@ -95,9 +80,15 @@ export const START_BACK_INPUTS: Array<InputType> = [
* Answer values 1 and 2 will be recoded to 0
* Answer values 3 and 4 will be recoded to 1
*/
type: {
type: 'number',
allowed_answers: [
type: z.union([
z.literal(0),
z.literal(1),
z.literal(2),
z.literal(3),
z.literal(4),
]),
uiOptions: {
options: [
{ value: 0, label: { en: 'Not at all', nl: 'In het geheel niet' } },
{ value: 1, label: { en: 'Slightly', nl: 'Een beetje' } },
{ value: 2, label: { en: 'Moderately', nl: 'Matig' } },
Expand All @@ -109,6 +100,5 @@ export const START_BACK_INPUTS: Array<InputType> = [
en: '"Slightly" (1) and "Moderately" (2) will be recoded to 0; "Very much" (3) and "Extremely" (4) will be recoded to 1;',
nl: '"Een beetje" (1) en "matig" (2) worden gehercodeerd naar 0; "Erg" en "Extreem" worden gehercodeerd naar 1; ',
},
required: true,
},
]
} satisfies ScoreInputSchemaType
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { z } from 'zod'
import { ScoreOutputSchemaType } from '../../../types'

export const START_BACK_OUTPUT = {
START_BACK_TOTAL: {
label: { en: 'Total score', nl: 'Totale score' },
type: z.number(),
},
START_BACK_SUBSCALE: {
label: { en: 'Subscale score', nl: 'Sub uitslag (Q5-9)' },
type: z.number(),
},
START_BACK_RISK_CLASSIFICATION: {
label: { en: 'Risk classification', nl: 'Risicoprofiel' },
type: z.string(),
},
} satisfies ScoreOutputSchemaType
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { classifyRisk, RiskClassification } from './classifyRisk'
describe('Classify risk', function () {
describe('when total score and subscale score are not missing', function () {
describe('when total score <= 3', function () {
it('should return low risk', function () {
const outcome = classifyRisk({ totalScore: 0, subscaleScore: 0 })
expect(outcome).toEqual(RiskClassification.LOW_RISK)
})
})

describe('when total score >= 4', function () {
describe('and when subscale score <= 3', function () {
it('should return medium risk', function () {
const outcome = classifyRisk({ totalScore: 4, subscaleScore: 0 })
expect(outcome).toEqual(RiskClassification.MEDIUM_RISK)
})
})

describe('and when subscale score >= 4', function () {
it('should return medium risk', function () {
const outcome = classifyRisk({ totalScore: 4, subscaleScore: 4 })
expect(outcome).toEqual(RiskClassification.HIGH_RISK)
})
})
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export enum RiskClassification {
LOW_RISK = 'Low risk',
MEDIUM_RISK = 'Medium risk',
HIGH_RISK = 'High risk',
}

export const classifyRisk = ({
totalScore,
subscaleScore,
}: {
totalScore: number
subscaleScore: number
}): RiskClassification => {
const TOTAL_SCORE_CUT_OFF = 3
const SUBSCALE_SCORE_CUT_OFF = 3

if (totalScore <= TOTAL_SCORE_CUT_OFF) {
return RiskClassification.LOW_RISK
}

if (
totalScore > TOTAL_SCORE_CUT_OFF &&
subscaleScore <= SUBSCALE_SCORE_CUT_OFF
) {
return RiskClassification.MEDIUM_RISK
}

return RiskClassification.HIGH_RISK
}
Loading

0 comments on commit 885ba46

Please sign in to comment.