Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 32 additions & 34 deletions lib/forms/FAGERSTRÖM_NICOTINE_DEPENDENCE/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { z } from '/runtime/v1/zod@3.x';

const yesNoOptions = {
en: {
1: 'Yes',
0: 'No'
'-1': 'Yes',
'0': 'No'
},
fr: {
1: 'Oui',
0: 'Non'
'-1': 'Oui',
'0': 'Non'
}
};

Expand Down Expand Up @@ -51,16 +51,16 @@ export default defineInstrument({
},
options: {
en: {
3: 'Within 5 minutes',
2: '6-30 minutes',
1: '31-60 minutes',
0: 'More than 60 minutes'
'-3': 'Within 5 minutes',
'-2': '6-30 minutes',
'-1': '31-60 minutes',
'0': 'More than 60 minutes'
},
fr: {
3: 'Dans les 5 minutes',
2: '6 à 30 minutes',
1: '31 à 60 minutes ',
0: 'Plus de 60 minutes'
'-3': 'Dans les 5 minutes',
'-2': '6 à 30 minutes',
'-1': '31 à 60 minutes',
'0': 'Plus de 60 minutes'
}
},
variant: 'radio'
Expand All @@ -84,12 +84,12 @@ export default defineInstrument({
},
options: {
en: {
1: 'The first in the morning',
0: 'Any other'
'-1': 'The first in the morning',
'0': 'Any other'
},
fr: {
1: 'La première du matin',
0: 'À une autre'
'-1': 'La première du matin',
'0': 'À une autre'
}
},
variant: 'radio'
Expand All @@ -98,21 +98,21 @@ export default defineInstrument({
disableAutoPrefix: true,
kind: 'number',
label: {
en: '4. How many cigarettes a do you smoke?',
en: '4. How many cigarettes do you smoke per day?',
fr: '4. Combien de cigarettes fumez-vous par jour?'
},
options: {
en: {
0: '10 or less',
1: '11 - 20',
2: '21 - 30',
3: '31 or more'
'0': '10 or less',
'1': '11 - 20',
'2': '21 - 30',
'3': '31 or more'
},
fr: {
0: '10 ou moins',
1: '11 à 20',
2: '21 à 30',
3: '31 ou plus 3'
'0': '10 ou moins',
'1': '11 à 20',
'2': '21 à 30',
'3': '31 ou plus'
}
},
variant: 'radio'
Expand All @@ -139,23 +139,21 @@ export default defineInstrument({
}
},
measures: {
auditCScore: {
nicotineDependenceScore: {
kind: 'computed',
label: {
en: 'Total Score:',
fr: 'Score total:'
},
value: (data) => {
return sum(Object.values(data));
}
value: (data) => sum(Object.values(data).map((v) => Math.abs(v ?? 0)))
}
},
validationSchema: z.object({
smokeTime: z.number().int().min(0).max(3),
difficultToRefrainSmoking: z.number().int().min(0).max(1),
cigaretteHateToGiveup: z.number().int().min(0).max(1),
smokeTime: z.number().int().min(-3).max(0),
difficultToRefrainSmoking: z.number().int().min(-1).max(0),
cigaretteHateToGiveup: z.number().int().min(-1).max(0),
cigaretteAmount: z.number().int().min(0).max(3),
smokeMoreInMorning: z.number().int().min(0).max(1),
smokeWhileSickInBed: z.number().int().min(0).max(1)
smokeMoreInMorning: z.number().int().min(-1).max(0),
smokeWhileSickInBed: z.number().int().min(-1).max(0)
})
});
Loading