|
1 | 1 | /* eslint-disable perfectionist/sort-objects */ |
2 | 2 |
|
3 | 3 | import { defineInstrument } from '/runtime/v1/@opendatacapture/runtime-core'; |
4 | | -import { sum } from '/runtime/v1/[email protected]'; |
| 4 | +import { omit, sum } from '/runtime/v1/[email protected]'; |
5 | 5 | import { z } from '/runtime/v1/[email protected]'; |
6 | 6 |
|
| 7 | +const $Response = z.number().int().min(0).max(3); |
| 8 | + |
7 | 9 | export default defineInstrument({ |
8 | 10 | kind: 'FORM', |
9 | 11 | language: ['en', 'fr'], |
@@ -216,21 +218,21 @@ export default defineInstrument({ |
216 | 218 | totalScore: { |
217 | 219 | kind: 'computed', |
218 | 220 | label: { en: 'Total Score', fr: 'Score total' }, |
219 | | - value: ({ questions }) => sum(Object.values(questions)) |
| 221 | + value: ({ questions }) => sum(Object.values(omit(questions, 'impactOnFunctioning'))) |
220 | 222 | } |
221 | 223 | }, |
222 | 224 | validationSchema: z.object({ |
223 | 225 | questions: z.object({ |
224 | | - interestPleasure: z.number().int().min(0).max(3), |
225 | | - feelingDown: z.number().int().min(0).max(3), |
226 | | - sleepIssues: z.number().int().min(0).max(3), |
227 | | - energyLevel: z.number().int().min(0).max(3), |
228 | | - appetiteChanges: z.number().int().min(0).max(3), |
229 | | - selfWorth: z.number().int().min(0).max(3), |
230 | | - concentrationIssues: z.number().int().min(0).max(3), |
231 | | - psychomotorChanges: z.number().int().min(0).max(3), |
232 | | - suicidalThoughts: z.number().int().min(0).max(3) |
| 226 | + interestPleasure: $Response, |
| 227 | + feelingDown: $Response, |
| 228 | + sleepIssues: $Response, |
| 229 | + energyLevel: $Response, |
| 230 | + appetiteChanges: $Response, |
| 231 | + selfWorth: $Response, |
| 232 | + concentrationIssues: $Response, |
| 233 | + psychomotorChanges: $Response, |
| 234 | + suicidalThoughts: $Response |
233 | 235 | }), |
234 | | - impactOnFunctioning: z.number().int().min(0).max(3).optional() |
| 236 | + impactOnFunctioning: $Response.optional() |
235 | 237 | }) |
236 | 238 | }); |
0 commit comments