|
| 1 | +import { defineInstrument } from '/runtime/v1/@opendatacapture/runtime-core'; |
| 2 | +import { z } from '/runtime/v1/[email protected]'; |
| 3 | + |
| 4 | +const likertOptions = { |
| 5 | + en: { |
| 6 | + 0: 'Not at All', |
| 7 | + 1: 'Several Days', |
| 8 | + 2: 'More than half the days', |
| 9 | + 3: 'Nearly every day' |
| 10 | + }, |
| 11 | + fr: { |
| 12 | + 0: 'Jamais', |
| 13 | + 1: 'Plusieurs jours', |
| 14 | + 2: 'Plus de la moitié des jours', |
| 15 | + 3: 'Presque tous les jours' |
| 16 | + } |
| 17 | +}; |
| 18 | + |
| 19 | +const calculateGAD7total = (data: { [key: string]: unknown }) => { |
| 20 | + let sum = 0; |
| 21 | + for (const key in data) { |
| 22 | + const value = data[key as keyof typeof data]; |
| 23 | + if (typeof value === 'number' && key != 'difficultyCoping') { |
| 24 | + sum += value; |
| 25 | + } |
| 26 | + } |
| 27 | + return sum; |
| 28 | +}; |
| 29 | + |
| 30 | +export default defineInstrument({ |
| 31 | + details: { |
| 32 | + title: { |
| 33 | + en: 'Generalized Anxiety Disorder-7 (GAD-7)', |
| 34 | + fr: "Trouble d'anxiété générale-7 (GAD-7)" |
| 35 | + }, |
| 36 | + description: { |
| 37 | + en: 'The Generalized Anxiety Disorder 7 (GAD-7) is a self-reported questionnaire for screening and severity measuring of generalized anxiety disorder (GAD). The GAD7 asks for self-reported anxiety symptoms over the past two weeks.', |
| 38 | + fr: "Le trouble d'anxiété généralisée 7 (GAD-7) est un questionnaire autodéclaré pour le dépistage et la mesure de la gravité du trouble d'anxiété généralisée (TAG). Le GAD7 demande les symptômes d’anxiété autodéclarés au cours des deux dernières semaines." |
| 39 | + }, |
| 40 | + estimatedDuration: 1, |
| 41 | + instructions: { |
| 42 | + en: ['Please complete all questions'], |
| 43 | + fr: ['Veuillez répondre à toutes les questions'] |
| 44 | + }, |
| 45 | + license: 'PUBLIC-DOMAIN' |
| 46 | + }, |
| 47 | + kind: 'FORM', |
| 48 | + language: ['en', 'fr'], |
| 49 | + tags: { |
| 50 | + en: ['Anxiety'], |
| 51 | + fr: ['Anxiété'] |
| 52 | + }, |
| 53 | + internal: { |
| 54 | + name: 'GAD_7', |
| 55 | + edition: 1 |
| 56 | + }, |
| 57 | + content: [ |
| 58 | + { |
| 59 | + title: { |
| 60 | + en: 'Over the last two weeks, how often have you been bothered by the following problems?', |
| 61 | + fr: 'Au cours des 14 derniers jours, à quelle fréquence avez-vous été dérangé(e) par les problèmes suivants?' |
| 62 | + }, |
| 63 | + fields: { |
| 64 | + nervousAnxiousOnEdge: { |
| 65 | + description: { |
| 66 | + en: 'Over the last two weeks, how often have you been bothered by feeling nervous, anxious, or on edge?', |
| 67 | + fr: "Au cours des 14 derniers jours, à quelle fréquence avez-vous été dérangé(e) par sentiment de nervosité, d'anxiété ou de tension?" |
| 68 | + }, |
| 69 | + label: { |
| 70 | + en: 'Feeling nervous, anxious, or on edge', |
| 71 | + fr: "Sentiment de nervosité, d'anxiété ou de tension" |
| 72 | + }, |
| 73 | + kind: 'number', |
| 74 | + options: likertOptions, |
| 75 | + variant: 'radio' |
| 76 | + }, |
| 77 | + noStopControlWorrying: { |
| 78 | + description: { |
| 79 | + en: 'Over the last two weeks, how often have you been bothered by not being able to stop or control worrying?', |
| 80 | + fr: "Au cours des 14 derniers jours, à quelle fréquence avez-vous été dérangé(e) par incapable d'arrêter de vous inquiéter ou de contrôler vos inquiétudes?" |
| 81 | + }, |
| 82 | + label: { |
| 83 | + en: 'Not being able to stop or control worrying', |
| 84 | + fr: "Incapable d'arrêter de vous inquiéter ou de contrôler vos inquiétudes" |
| 85 | + }, |
| 86 | + kind: 'number', |
| 87 | + options: likertOptions, |
| 88 | + variant: 'radio' |
| 89 | + }, |
| 90 | + worryingTooMuch: { |
| 91 | + description: { |
| 92 | + en: 'Over the last two weeks, how often have you been bothered by worrying too much about different things?', |
| 93 | + fr: 'Au cours des 14 derniers jours, à quelle fréquence avez-vous été dérangé(e) par inquiétudes excessives à propos de tout et de rien?' |
| 94 | + }, |
| 95 | + label: { |
| 96 | + en: 'Worrying too much about different things', |
| 97 | + fr: 'Inquiétudes excessives à propos de tout et de rien' |
| 98 | + }, |
| 99 | + kind: 'number', |
| 100 | + options: likertOptions, |
| 101 | + variant: 'radio' |
| 102 | + }, |
| 103 | + troubleRelaxing: { |
| 104 | + description: { |
| 105 | + en: 'Over the last two weeks, how often have you had trouble relaxing?', |
| 106 | + fr: 'Au cours des deux dernières semaines, à quelle fréquence avez-vous eu du mal à vous détendre?' |
| 107 | + }, |
| 108 | + label: { |
| 109 | + en: 'Have trouble relaxing', |
| 110 | + fr: 'Difficulté à se détendre' |
| 111 | + }, |
| 112 | + kind: 'number', |
| 113 | + options: likertOptions, |
| 114 | + variant: 'radio' |
| 115 | + }, |
| 116 | + restless: { |
| 117 | + description: { |
| 118 | + en: 'Over the last two weeks, how often have you been bothered by being so restless that it is hard to sit still?', |
| 119 | + fr: "Au cours des 14 derniers jours, à quelle fréquence avez-vous été dérangé(e) par agitation telle qu'il est difficile de rester tranquille?" |
| 120 | + }, |
| 121 | + label: { |
| 122 | + en: 'Being so restless that it is hard to sit still', |
| 123 | + fr: "Agitation telle qu'il est difficile de rester tranquille" |
| 124 | + }, |
| 125 | + kind: 'number', |
| 126 | + options: likertOptions, |
| 127 | + variant: 'radio' |
| 128 | + }, |
| 129 | + easilyAnnoyedIrritable: { |
| 130 | + description: { |
| 131 | + en: 'Over the last two weeks, how often have you been bothered by becoming easily annoyed or irritable?', |
| 132 | + fr: 'Au cours des 14 derniers jours, à quelle fréquence avez-vous été dérangé(e) par devenir facilement contrarié(e) ou irritable?' |
| 133 | + }, |
| 134 | + label: { |
| 135 | + en: 'Becoming easily annoyed or irritable', |
| 136 | + fr: 'Devenir facilement contrarié(e) ou irritable' |
| 137 | + }, |
| 138 | + kind: 'number', |
| 139 | + options: likertOptions, |
| 140 | + variant: 'radio' |
| 141 | + }, |
| 142 | + afraidSomethingAwful: { |
| 143 | + description: { |
| 144 | + en: 'Over the last two weeks, how often have you been bothered by feeling afraid, as if something awful might happen?', |
| 145 | + fr: "Au cours des 14 derniers jours, à quelle fréquence avez-vous été dérangé(e) par avoir peur que quelque chose d'épouvantable puisse arriver?" |
| 146 | + }, |
| 147 | + label: { |
| 148 | + en: 'Feeling afraid, as if something awful might happen', |
| 149 | + fr: "Avoir peur que quelque chose d'épouvantable puisse arriver" |
| 150 | + }, |
| 151 | + kind: 'number', |
| 152 | + options: likertOptions, |
| 153 | + variant: 'radio' |
| 154 | + } |
| 155 | + } |
| 156 | + }, |
| 157 | + { |
| 158 | + title: { |
| 159 | + en: ' ', |
| 160 | + fr: 'Difficulté à faire face' |
| 161 | + }, |
| 162 | + fields: { |
| 163 | + difficultyCoping: { |
| 164 | + kind: 'dynamic', |
| 165 | + deps: [ |
| 166 | + 'nervousAnxiousOnEdge', |
| 167 | + 'noStopControlWorrying', |
| 168 | + 'worryingTooMuch', |
| 169 | + 'troubleRelaxing', |
| 170 | + 'restless', |
| 171 | + 'easilyAnnoyedIrritable', |
| 172 | + 'afraidSomethingAwful' |
| 173 | + ], |
| 174 | + render(data) { |
| 175 | + if ( |
| 176 | + !( |
| 177 | + data?.nervousAnxiousOnEdge || |
| 178 | + data?.noStopControlWorrying || |
| 179 | + data?.worryingTooMuch || |
| 180 | + data?.troubleRelaxing || |
| 181 | + data?.restless || |
| 182 | + data?.easilyAnnoyedIrritable || |
| 183 | + data?.afraidSomethingAwful |
| 184 | + ) |
| 185 | + ) { |
| 186 | + return null; |
| 187 | + } |
| 188 | + return { |
| 189 | + description: { |
| 190 | + en: 'Given your problems selected above, how difficult have they made it for you to do your work, take care of things at home, or get along with other people?', |
| 191 | + fr: 'Compte tenu des problèmes sélectionnés ci-dessus, dans quelle mesure ceux-ci rendus plus difficile votre travail, vous occuper de vos affaires à la maison ou vous entendre avec les autres personnes?' |
| 192 | + }, |
| 193 | + label: { |
| 194 | + en: 'Given your problems selected above, how difficult have they made it for you to do your work, take care of things at home, or get along with other people?', |
| 195 | + fr: 'Compte tenu des problèmes sélectionnés ci-dessus, dans quelle mesure ceux-ci rendus plus difficile votre travail, vous occuper de vos affaires à la maison ou vous entendre avec les autres personnes?' |
| 196 | + }, |
| 197 | + kind: 'number', |
| 198 | + options: { |
| 199 | + en: { |
| 200 | + 0: 'Not difficult at all', |
| 201 | + 1: 'Somewhat difficult', |
| 202 | + 2: 'Very difficult', |
| 203 | + 3: 'Extremely difficult' |
| 204 | + }, |
| 205 | + fr: { |
| 206 | + 0: 'Pas difficile', |
| 207 | + 1: 'Un peu difficile', |
| 208 | + 2: 'Très difficile', |
| 209 | + 3: 'Extrêmement difficile' |
| 210 | + } |
| 211 | + }, |
| 212 | + variant: 'radio' |
| 213 | + }; |
| 214 | + } |
| 215 | + } |
| 216 | + } |
| 217 | + } |
| 218 | + ], |
| 219 | + measures: { |
| 220 | + nervousAnxiousOnEdge: { |
| 221 | + kind: 'const', |
| 222 | + ref: 'nervousAnxiousOnEdge' |
| 223 | + }, |
| 224 | + noStopControlWorrying: { |
| 225 | + kind: 'const', |
| 226 | + ref: 'noStopControlWorrying' |
| 227 | + }, |
| 228 | + worryingTooMuch: { |
| 229 | + kind: 'const', |
| 230 | + ref: 'worryingTooMuch' |
| 231 | + }, |
| 232 | + troubleRelaxing: { |
| 233 | + kind: 'const', |
| 234 | + ref: 'troubleRelaxing' |
| 235 | + }, |
| 236 | + restless: { |
| 237 | + kind: 'const', |
| 238 | + ref: 'restless' |
| 239 | + }, |
| 240 | + easilyAnnoyedIrritable: { |
| 241 | + kind: 'const', |
| 242 | + ref: 'easilyAnnoyedIrritable' |
| 243 | + }, |
| 244 | + afraidSomethingAwful: { |
| 245 | + kind: 'const', |
| 246 | + ref: 'afraidSomethingAwful' |
| 247 | + }, |
| 248 | + difficultyCoping: { |
| 249 | + kind: 'const', |
| 250 | + ref: 'difficultyCoping' |
| 251 | + }, |
| 252 | + gad7Total: { |
| 253 | + kind: 'computed', |
| 254 | + label: { |
| 255 | + en: 'Total of GAD7', |
| 256 | + fr: '' |
| 257 | + }, |
| 258 | + value: (data) => { |
| 259 | + return calculateGAD7total(data); |
| 260 | + } |
| 261 | + } |
| 262 | + }, |
| 263 | + validationSchema: z.object({ |
| 264 | + nervousAnxiousOnEdge: z.number().int().min(0).max(3), |
| 265 | + noStopControlWorrying: z.number().int().min(0).max(3), |
| 266 | + worryingTooMuch: z.number().int().min(0).max(3), |
| 267 | + troubleRelaxing: z.number().int().min(0).max(3), |
| 268 | + restless: z.number().int().min(0).max(3), |
| 269 | + easilyAnnoyedIrritable: z.number().int().min(0).max(3), |
| 270 | + afraidSomethingAwful: z.number().int().min(0).max(3), |
| 271 | + difficultyCoping: z.number().int().min(0).max(3).optional() |
| 272 | + }) |
| 273 | +}); |
0 commit comments