-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
2893 lines (2893 loc) · 135 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { Questionnaire, Item, ItemType } from "questionnaire-core/dist";
export * from "questionnaire-core/dist";
// Utility navigation functions
const panic_navigation = (ans, state) => {
var _a, _b;
if (((_a = state.getItemById("anxiety").answer) === null || _a === void 0 ? void 0 : _a.value) === 1 &&
((_b = state.getItemById("anxiety-tense").answer) === null || _b === void 0 ? void 0 : _b.value) === 1)
return "anxiety-outro";
return "panic";
};
export const _overall_navigation = (ans, state) => {
const counters = [
"somatic",
"hypochondria",
"fatigue",
"sleep",
"irritability",
"concentration",
"depression",
"depressive_ideas",
"phobia",
"worry",
"anxiety",
"panic",
"compulsions",
"obsessions",
];
let follow_up = false;
counters.forEach((c) => {
const v = state.counters.get(c, 0);
if (v >= 2)
follow_up = true;
});
return follow_up ? "overall-follow-up" : null;
};
// Questionnaire definition
export const _state_properties = {
items: [
new Item({
id: "demo-intro",
question: "To begin with, I would like to ask you about yourself and your background",
next_item: "demo-sex",
}),
new Item({
id: "demo-sex",
question: "Are you male or female?",
answer_options: [
{ value: 1, text: "Male" },
{ value: 2, text: "Female" },
],
next_item: "demo-age",
}),
new Item({
id: "demo-age",
question: "How old are you?",
type: ItemType.NUMBER,
next_item: "demo-marital",
}),
new Item({
id: "demo-marital",
question: "What is your marital status?",
answer_options: [
{ value: 1, text: "Married/Living as married" },
{ value: 2, text: "Single" },
{ value: 3, text: "Separated" },
{ value: 4, text: "Divorced" },
{ value: 5, text: "Widowed" },
],
next_item: "demo-employment",
}),
new Item({
id: "demo-employment",
question: "What is your current employment status?",
answer_options: [
{ value: 1, text: "Employed full-time" },
{ value: 2, text: "Employed part-time" },
{ value: 3, text: "Studying at school, college or university" },
{ value: 4, text: "Retired" },
{ value: 5, text: "Houseperson" },
{ value: 6, text: "Unemployed job seeker" },
{ value: 7, text: "Unemployed due to ill-health" },
{
value: 8,
text: "On a government or other employment training scheme",
},
],
next_item: "demo-housing",
}),
new Item({
id: "demo-housing",
question: "What is your housing situation?",
answer_options: [
{ value: 1, text: "Home owner" },
{ value: 2, text: "Renting" },
{ value: 3, text: "Living with relative or friend" },
{ value: 4, text: "Hostel or care home" },
{ value: 5, text: "Homeless" },
{ value: 6, text: "Other" },
],
next_item: "health-intro",
}),
new Item({
id: "health-intro",
question: "I would now like to ask you about your health and well-being",
next_item: "health-appetite-loss",
}),
new Item({
id: "health-appetite-loss",
question: "Have you noticed a marked LOSS in your appetite in the PAST MONTH?",
answer_options: [
{ value: 1, text: "No" },
{ value: 2, text: "Yes" },
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 2) {
state.counters.increment("depression_criterion_3", 1);
state.counters.set("weight_detail", 1);
}
},
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 2 ? "health-weight-loss" : "health-appetite-gain",
}),
new Item({
id: "health-weight-loss",
question: "Have you lost any weight in the PAST MONTH?",
answer_options: [
{ value: 1, text: "No" },
{ value: 2, text: "Yes" },
],
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 2 ? "health-weight-loss-diet" : "health-gp-visits",
}),
new Item({
id: "health-weight-loss-diet",
question: "Were you trying to lose weight or on a diet?",
answer_options: [
{ value: 1, text: "No, I was not trying to lose weight" },
{ value: 2, text: "Yes, I have been trying to lose weight" },
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 1) {
state.counters.set("weight_detail", 2);
}
},
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 1 ? "health-weight-loss-amount" : "health-gp-visits",
}),
new Item({
id: "health-weight-loss-amount",
question: "Did you lose half a stone or more, or did you lose less than this (in the PAST MONTH)?\n\n(NOTE: Half a stone = 7 pounds or 3 kg)",
answer_options: [
{ value: 1, text: "I lost half a stone or more" },
{ value: 2, text: "I lost less than half a stone" },
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 1) {
state.counters.increment("depression_criterion_3", 1);
state.counters.set("weight_detail", 3);
}
},
next_item: "health-gp-visits",
}),
new Item({
id: "health-appetite-gain",
question: "Have you noticed a marked INCREASE in your appetite in the PAST MONTH?",
answer_options: [
{ value: 1, text: "No" },
{ value: 2, text: "Yes" },
],
next_item_fun: (ans, state) => {
var _a, _b;
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 1)
return "health-gp-visits";
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 2) {
const sex_ans = (_a = state.getItemById("demo-sex").answer) === null || _a === void 0 ? void 0 : _a.value;
if (typeof sex_ans === "number")
return sex_ans === 1
? "health-weight-gain-male"
: "health-weight-gain-female";
}
throw `Could not determine next question for ${(_b = state.current_item) === null || _b === void 0 ? void 0 : _b.id} [${ans === null || ans === void 0 ? void 0 : ans.value}]`;
},
}),
new Item({
id: "health-weight-gain-male",
question: "Have you gained any weight in the PAST MONTH?",
answer_options: [
{ value: 1, text: "No" },
{ value: 2, text: "Yes" },
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 2) {
state.counters.set("weight_detail", 2);
}
},
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 2 ? "health-weight-gain-amount" : "health-gp-visits",
}),
new Item({
id: "health-weight-gain-female",
question: "Have you gained any weight in the PAST MONTH?",
answer_options: [
{ value: 1, text: "No" },
{ value: 2, text: "Yes" },
{ value: 3, text: "Yes, but I am pregnant" },
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 2) {
state.counters.set("weight_detail", 2);
}
},
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 2 ? "health-weight-gain-amount" : "health-gp-visits",
}),
new Item({
id: "health-weight-gain-amount",
question: "Did you gain half a stone or more, or did you gain less than this (in the PAST MONTH)?\n\n(NOTE: Half a stone = 7 pounds or 3 kg)",
answer_options: [
{ value: 1, text: "I gained half a stone or more" },
{ value: 2, text: "I gained less than half a stone" },
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 1 && state.counters.get("weight_detail", 0) === 2) {
state.counters.set("weight_detail", 4);
}
},
next_item: "health-gp-visits",
}),
new Item({
id: "health-gp-visits",
question: "In the PAST YEAR, approximately how many times have you talked to or visited a GP or family doctor about your OWN health? Do NOT include any visits to hospital.",
answer_options: [
{ value: 0, text: "None" },
{ value: 1, text: "1 or 2 times" },
{ value: 2, text: "3 to 5 times" },
{ value: 3, text: "6 to 10 times" },
{ value: 4, text: "More than 10 times" },
],
process_answer_fun: (ans, state) => {
var _a, _b;
if (state.counters.get("weight_detail", 0) === 3 &&
((_a = state.getItemById("health-appetite-loss").answer) === null || _a === void 0 ? void 0 : _a.value) === 2)
state.counters.increment("depression_criterion_2", 1);
if (state.counters.get("weight_detail", 0) === 4 &&
((_b = state.getItemById("health-appetite-gain").answer) === null || _b === void 0 ? void 0 : _b.value) === 2)
state.counters.increment("depression_criterion_2", 1);
},
next_item: "health-disability",
}),
new Item({
id: "health-disability",
question: "Do you have any long-standing illness, disability or infirmity?\n\nLong-standing means anything that has troubled you over a period of time or that is likely to affect you over a period of time",
answer_options: [
{ value: 1, text: "No" },
{ value: 2, text: "Yes" },
],
next_item: "health-illness",
}),
new Item({
id: "health-illness",
question: "Do you have any of the following conditions? If you have more than one condition answer for the most serious condition.",
answer_options: [
{ value: 1, text: "Diabetes" },
{ value: 2, text: "Asthma or COPD" },
{ value: 3, text: "Arthritis" },
{ value: 4, text: "Heart disease or heart problems" },
{ value: 5, text: "Stroke" },
{ value: 6, text: "Cancer" },
{ value: 7, text: "Kidney disease" },
{ value: 8, text: "Mental health problems" },
{ value: 9, text: "None of the above" },
],
next_item: "somatic-pain",
}),
new Item({
id: "somatic-pain",
question: "Have you had ANY sort of aches or pains in the PAST MONTH, including headaches or indigestion?",
answer_options: [
{ value: 1, text: "No" },
{ value: 2, text: "Yes" },
],
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 1 ? "somatic-discomfort" : "somatic-stress",
}),
new Item({
id: "somatic-stress",
question: "Was this pain or ache BROUGHT ON or MADE WORSE because you were feeling low, anxious or stressed?",
answer_options: [
{ value: 1, text: "Never" },
{ value: 2, text: "Sometimes" },
{ value: 3, text: "Always" },
],
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 1 ? "somatic-discomfort" : "somatic-pain-frequency",
}),
new Item({
id: "somatic-pain-frequency",
question: "On how many days have you noticed this pain during the PAST SEVEN DAYS?",
answer_options: [
{ value: 1, text: "None" },
{ value: 2, text: "Between one and three days" },
{ value: 3, text: "Four days or more" },
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 3)
state.counters.increment("somatic", 1);
},
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 1 ? "somatic-discomfort" : "somatic-pain-duration",
}),
new Item({
id: "somatic-pain-duration",
question: "In total, did the pain or ache last for more than 3 hours on ANY day during the PAST SEVEN DAYS?",
answer_options: [
{ value: 1, text: "No, less than 3 hours" },
{
value: 2,
text: "Yes, it has lasted for more than 3 hours on at least one day",
},
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 2)
state.counters.increment("somatic", 1);
},
next_item: "somatic-pain-valence",
}),
new Item({
id: "somatic-pain-valence",
question: "Has the pain been unpleasant in the PAST SEVEN DAYS?",
answer_options: [
{ value: 1, text: "Not at all" },
{ value: 2, text: "A little unpleasant" },
{ value: 3, text: "Unpleasant" },
{ value: 4, text: "Very unpleasant" },
],
process_answer_fun: (ans, state) => {
if (typeof (ans === null || ans === void 0 ? void 0 : ans.value) === "number" && (ans === null || ans === void 0 ? void 0 : ans.value) >= 3)
state.counters.increment("somatic", 1);
},
next_item: "somatic-pain-distress",
}),
new Item({
id: "somatic-pain-distress",
question: "Has the pain bothered you when you were doing something interesting in the PAST SEVEN DAYS?",
answer_options: [
{ value: 1, text: "No, pain has not bothered me" },
{
value: 2,
text: "Yes, pain bothered me while doing something interesting",
},
{
value: 3,
text: "I haven't done anything interesting in the past week",
},
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 2)
state.counters.increment("somatic", 1);
},
next_item: "somatic-duration",
}),
new Item({
id: "somatic-discomfort",
question: "Have you been troubled by any sort of bodily discomfort in THE PAST MONTH?",
answer_options: [
{ value: 1, text: "No" },
{ value: 2, text: "Yes" },
],
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 1 ? "fatigue" : "somatic-discomfort-stress",
}),
new Item({
id: "somatic-discomfort-stress",
question: "Was this discomfort BROUGHT ON or MADE WORSE because you were feeling low, anxious or stressed?",
answer_options: [
{ value: 1, text: "Never" },
{ value: 2, text: "Sometimes" },
{ value: 3, text: "Always" },
],
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 1 ? "fatigue" : "somatic-discomfort-frequency",
}),
new Item({
id: "somatic-discomfort-frequency",
question: "On how many days have you noticed this discomfort during the PAST SEVEN DAYS?",
answer_options: [
{ value: 1, text: "None" },
{ value: 2, text: "Between one and three days" },
{ value: 3, text: "Four days or more" },
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 3)
state.counters.increment("somatic", 1);
},
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 1 ? "fatigue" : "somatic-discomfort-long",
}),
new Item({
id: "somatic-discomfort-long",
question: "In total, did the discomfort last for more than 3 hours on ANY day during the PAST SEVEN DAYS?",
answer_options: [
{ value: 1, text: "No, less than 3 hours" },
{
value: 2,
text: "Yes, it has lasted for more than 3 hours on at least one day",
},
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 2)
state.counters.increment("somatic", 1);
},
next_item: "somatic-discomfort-valence",
}),
new Item({
id: "somatic-discomfort-valence",
question: "Has the discomfort been unpleasant in the PAST SEVEN DAYS?",
answer_options: [
{ value: 1, text: "Not at all" },
{ value: 2, text: "A little unpleasant" },
{ value: 3, text: "Unpleasant" },
{ value: 4, text: "Very unpleasant" },
],
process_answer_fun: (ans, state) => {
if (typeof (ans === null || ans === void 0 ? void 0 : ans.value) === "number" && (ans === null || ans === void 0 ? void 0 : ans.value) >= 3)
state.counters.increment("somatic", 1);
},
next_item: "somatic-discomfort-distress",
}),
new Item({
id: "somatic-discomfort-distress",
question: "Has the discomfort bothered you when you were doing something interesting in the PAST SEVEN DAYS?",
answer_options: [
{ value: 1, text: "No, discomfort has not bothered me" },
{
value: 2,
text: "Yes, discomfort bothered me while doing something interesting",
},
{
value: 3,
text: "I haven't done anything interesting in the past week",
},
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 2)
state.counters.increment("somatic", 1);
},
next_item: "somatic-duration",
}),
new Item({
id: "somatic-duration",
question: "How long have you been feeling this ache, pain or discomfort as you have just described?",
answer_options: [
{ value: 1, text: "Less than 2 weeks" },
{ value: 2, text: "Between 2 weeks and 6 months" },
{ value: 3, text: "Between 6 months and 1 year" },
{ value: 4, text: "Between 1 and 2 years" },
{ value: 5, text: "Between 2 and 5 years" },
{ value: 6, text: "More than 5 years" },
],
next_item: "fatigue",
}),
new Item({
id: "fatigue",
question: "Have you noticed that you've been getting tired in the PAST MONTH?",
answer_options: [
{ value: 1, text: "No" },
{ value: 2, text: "Yes" },
],
process_answer_fun: (ans, state) => {
state.counters.set("score", state.counters.get("somatic", 0));
},
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 1 ? "fatigue-energy" : "fatigue-tired-cause",
}),
new Item({
id: "fatigue-tired-cause",
question: "What do you think is the main reason for feeling tired?",
answer_options: [
{ value: 1, text: "Problems with sleep" },
{ value: 2, text: "Tablets or medication" },
{ value: 3, text: "Physical illness" },
{
value: 4,
text: "Working too hard, including looking after children",
},
{ value: 5, text: "Stress, worry or other psychological reason" },
{ value: 6, text: "Physical exercise" },
{ value: 7, text: "Other cause" },
{ value: 8, text: "Don't know" },
],
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 6 ? "concentration" : "fatigue-tired-frequency",
}),
new Item({
id: "fatigue-tired-frequency",
question: "On how many days have you felt tired during the PAST SEVEN DAYS?",
answer_options: [
{ value: 1, text: "None" },
{ value: 2, text: "Between one and three days" },
{ value: 3, text: "Four days or more" },
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 3)
state.counters.increment("fatigue", 1);
},
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 1 ? "fatigue-energy" : "fatigue-tired-duration",
}),
new Item({
id: "fatigue-tired-duration",
question: "Have you felt tired for more than 3 hours in total on ANY day in the PAST SEVEN DAYS?",
answer_options: [
{ value: 1, text: "No, less than 3 hours" },
{
value: 2,
text: "Yes, I felt tired for more than 3 hours on at least one day",
},
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 2)
state.counters.increment("fatigue", 1);
},
next_item: "fatigue-tired-push",
}),
new Item({
id: "fatigue-tired-push",
question: "Have you felt so tired that you've had to push yourself to get things done during the PAST SEVEN DAYS?",
answer_options: [
{ value: 1, text: "No" },
{ value: 2, text: "Yes, on one or more occasion" },
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 2)
state.counters.increment("fatigue", 1);
},
next_item: "fatigue-tired-enjoy",
}),
new Item({
id: "fatigue-tired-enjoy",
question: "Have you felt tired when doing things that you enjoy during the PAST SEVEN DAYS?",
answer_options: [
{ value: 1, text: "No, not tired during enjoyable activities" },
{ value: 2, text: "Yes, tired during an enjoyable activity" },
{
value: 3,
text: "I haven't done anything enjoyable in the past week",
},
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 2)
state.counters.increment("fatigue", 1);
},
next_item: "fatigue-duration",
}),
new Item({
id: "fatigue-energy",
question: "During the PAST MONTH, have you felt you've been lacking in energy?",
answer_options: [
{ value: 1, text: "No" },
{ value: 2, text: "Yes" },
],
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 1 ? "concentration" : "fatigue-energy-cause",
}),
new Item({
id: "fatigue-energy-cause",
question: "What do you think is the main reason for lacking in energy?",
answer_options: [
{ value: 1, text: "Problems with sleep" },
{ value: 2, text: "Tablets or medication" },
{ value: 3, text: "Physical illness" },
{
value: 4,
text: "Working too hard, including looking after children",
},
{ value: 5, text: "Stress, worry or other psychological reason" },
{ value: 6, text: "Physical exercise" },
{ value: 7, text: "Other cause" },
{ value: 8, text: "Don't know" },
],
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 6 ? "concentration" : "fatigue-energy-frequency",
}),
new Item({
id: "fatigue-energy-frequency",
question: "On how many days have you felt lacking in energy during the PAST SEVEN DAYS?",
answer_options: [
{ value: 1, text: "None" },
{ value: 2, text: "Between one and three days" },
{ value: 3, text: "Four days or more" },
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 3)
state.counters.increment("fatigue", 1);
},
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 1 ? "concentration" : "fatigue-energy-duration",
}),
new Item({
id: "fatigue-energy-duration",
question: "Have you felt lacking in energy for more than 3 hours in total on ANY day in the PAST SEVEN DAYS?",
answer_options: [
{ value: 1, text: "No, less than 3 hours" },
{
value: 2,
text: "Yes, I felt tired for more than 3 hours on at least one day",
},
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 2)
state.counters.increment("fatigue", 1);
},
next_item: "fatigue-energy-push",
}),
new Item({
id: "fatigue-energy-push",
question: "Have you felt so lacking in energy that you've had to push yourself to get things done during the PAST SEVEN DAYS?",
answer_options: [
{ value: 1, text: "No" },
{ value: 2, text: "Yes, on one or more occasion" },
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 2)
state.counters.increment("fatigue", 1);
},
next_item: "fatigue-energy-enjoy",
}),
new Item({
id: "fatigue-energy-enjoy",
question: "Have you felt lacking in energy when doing things that you enjoy during the PAST SEVEN DAYS?",
answer_options: [
{ value: 1, text: "No, not tired during enjoyable activities" },
{ value: 2, text: "Yes, tired during an enjoyable activity" },
{
value: 3,
text: "I haven't done anything enjoyable in the past week",
},
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 2)
state.counters.increment("fatigue", 1);
},
next_item: "fatigue-duration",
}),
new Item({
id: "fatigue-duration",
question: "How long have you been feeling tired or lacking in energy in the way you have just described?",
answer_options: [
{ value: 1, text: "Less than 2 weeks" },
{ value: 2, text: "Between 2 weeks and 6 months" },
{ value: 3, text: "Between 6 months and 1 year" },
{ value: 4, text: "Between 1 and 2 years" },
{ value: 5, text: "Between 2 and 5 years" },
{ value: 6, text: "More than 5 years" },
],
process_answer_fun: (ans, state) => {
if (state.counters.get("somatic", 0) >= 2 &&
state.counters.get("fatigue", 0) >= 2)
state.counters.increment("NEURAS", 1);
},
next_item: "concentration",
}),
new Item({
id: "concentration",
question: "In the PAST MONTH, have you had any problems in concentrating on what you are doing?",
answer_options: [
{ value: 1, text: "No" },
{ value: 2, text: "Yes, problems concentrating on what I am doing" },
],
process_answer_fun: (ans, state) => {
const fatigue = state.counters.get("fatigue", 0);
if (!fatigue)
return;
state.counters.increment("score", fatigue);
if (fatigue >= 2)
state.counters.increment("depression_criterion_1", 1);
},
next_item: "concentration-forgetting",
}),
new Item({
id: "concentration-forgetting",
question: "Have you noticed any problems with forgetting things in the PAST MONTH?",
answer_options: [
{ value: 1, text: "No" },
{ value: 2, text: "Yes" },
],
next_item_fun: (ans, state) => {
var _a;
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 1 &&
((_a = state.getItemById("concentration").answer) === null || _a === void 0 ? void 0 : _a.value) === 1)
return "sleep-loss";
return "concentration-frequency";
},
}),
new Item({
id: "concentration-frequency",
question: "On how many days have you noticed problems with your concentration OR your memory during the PAST SEVEN DAYS?",
answer_options: [
{ value: 1, text: "None" },
{ value: 2, text: "Between one and three days" },
{ value: 3, text: "Four days or more" },
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 3)
state.counters.increment("concentration", 1);
},
next_item_fun: (ans, state) => {
var _a;
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 1)
return "sleep-loss";
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 1 &&
((_a = state.getItemById("concentration-forgetting").answer) === null || _a === void 0 ? void 0 : _a.value) === 2)
return "concentration-forgetting-important";
return "concentration-tasks";
},
}),
new Item({
id: "concentration-tasks",
question: "In the PAST SEVEN DAYS could you concentrate on all of the following without your mind wandering?:\n\na whole TV programme\n\na newspaper article\n\ntalking to someone?",
answer_options: [
{ value: 1, text: "Yes, I could concentrate on all of them" },
{
value: 2,
text: "No, I couldn't concentrate on at least one of these things",
},
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 2)
state.counters.increment("concentration", 1);
},
next_item: "concentration-distress",
}),
new Item({
id: "concentration-distress",
question: "In the PAST SEVEN DAYS, have these problems with your concentration actually STOPPED you from getting on with things you used to do or would like to do?",
answer_options: [
{ value: 1, text: "No" },
{ value: 2, text: "Yes" },
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 2)
state.counters.increment("concentration", 1);
},
next_item: "concentration-duration",
}),
new Item({
id: "concentration-duration",
question: "How long have you been having problems with your CONCENTRATION as you have described?",
answer_options: [
{ value: 1, text: "Less than 2 weeks" },
{ value: 2, text: "Between 2 weeks and 6 months" },
{ value: 3, text: "Between 6 months and 1 year" },
{ value: 4, text: "Between 1 and 2 years" },
{ value: 5, text: "Between 2 and 5 years" },
{ value: 6, text: "More than 5 years" },
],
process_answer_fun: (ans, state) => {
if (state.counters.get("somatic", 0) >= 2 &&
state.counters.get("fatigue", 0) >= 2)
state.counters.increment("NEURAS", 1);
},
next_item_fun: (ans, state) => {
var _a;
if (((_a = state.getItemById("concentration-forgetting").answer) === null || _a === void 0 ? void 0 : _a.value) === 1)
return "sleep-loss";
return "concentration-forgetting-important";
},
}),
new Item({
id: "concentration-forgetting-important",
question: "Have you forgotten anything important in the PAST SEVEN DAYS?",
answer_options: [
{ value: 1, text: "No" },
{ value: 2, text: "Yes, I have forgotten something important" },
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 2)
state.counters.increment("concentration", 1);
},
next_item: "concentration-forgetting-duration",
}),
new Item({
id: "concentration-forgetting-duration",
question: "How long have you been having problems with your MEMORY as you have described?",
answer_options: [
{ value: 1, text: "Less than 2 weeks" },
{ value: 2, text: "Between 2 weeks and 6 months" },
{ value: 3, text: "Between 6 months and 1 year" },
{ value: 4, text: "Between 1 and 2 years" },
{ value: 5, text: "Between 2 and 5 years" },
{ value: 6, text: "More than 5 years" },
],
next_item: "sleep-loss",
}),
new Item({
id: "sleep-loss",
question: "In the PAST MONTH, have you been having problems with trying to get to sleep or with getting back to sleep if you woke up or were woken up?",
answer_options: [
{ value: 1, text: "No" },
{ value: 2, text: "Yes" },
],
process_answer_fun: (ans, state) => {
const conc = state.counters.get("concentration", 0);
if (!conc)
return;
state.counters.increment("score", conc);
if (conc >= 2)
state.counters.increment("depression_criterion_2", 1);
},
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 1 ? "sleep-gain" : "sleep-loss-frequency",
}),
new Item({
id: "sleep-loss-frequency",
question: "On how many nights in the SEVEN NIGHTS did you have problems with your sleep?",
answer_options: [
{ value: 1, text: "None" },
{ value: 2, text: "Between one and three nights" },
{ value: 3, text: "Four nights or more" },
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 3)
state.counters.increment("sleep", 1);
},
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 1 ? "irritability" : "sleep-loss-time",
}),
new Item({
id: "sleep-loss-time",
question: "Thinking about the night you had the LEAST sleep in the PAST WEEK, how long did you spend trying to get to sleep?\n\nOnly include time spent lying awake in bed TRYING to return to sleep.",
answer_options: [
{ value: 1, text: "Less than 15 minutes" },
{ value: 2, text: "Between 15 minutes and 1 hour" },
{ value: 3, text: "Between 1 and 3 hours" },
{ value: 4, text: "Three hours or more" },
],
process_answer_fun: (ans, state) => {
const v = ans === null || ans === void 0 ? void 0 : ans.value;
if (!v)
return;
if (v === 2)
state.counters.increment("sleep", 1);
if (v >= 3)
state.counters.increment("sleep", 2);
},
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 1 ? "irritability" : "sleep-loss-long",
}),
new Item({
id: "sleep-loss-long",
question: "In the PAST SEVEN DAYS, how many nights did you spend 3 or more hours trying to get to sleep?",
answer_options: [
{ value: 1, text: "None" },
{ value: 2, text: "Between one and three nights" },
{ value: 3, text: "Four nights or more" },
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 3)
state.counters.increment("sleep", 1);
},
next_item: "sleep-loss-morning",
}),
new Item({
id: "sleep-loss-morning",
question: "In the PAST SEVEN DAYS, have you woken more than two hours earlier than you needed to and found that you couldn't get back to sleep?",
answer_options: [
{ value: 1, text: "No" },
{ value: 2, text: "Yes, and I couldn't get back to sleep" },
],
process_answer_fun: (ans, state) => {
const v = ans === null || ans === void 0 ? void 0 : ans.value;
const sleep = state.counters.get("sleep", 0);
if (!v || !sleep)
return;
if (v >= 1 && sleep >= 1)
state.counters.set("sleep_detail", 2);
if (v === 2) {
if (sleep >= 1)
state.counters.set("sleep_detail", 1);
state.counters.increment("depression_criterion_3", 1);
}
},
next_item: "sleep-cause",
}),
new Item({
id: "sleep-cause",
question: "What are your sleep difficulties caused by?",
answer_options: [
{ value: 1, text: "Noises (babies crying, busy roads etc.)" },
{ value: 2, text: "Shift work or late nights" },
{ value: 3, text: "Pain or illness" },
{ value: 4, text: "Worries" },
{ value: 5, text: "Reason not known" },
{ value: 6, text: "Other" },
],
next_item: "sleep-duration",
}),
new Item({
id: "sleep-gain",
question: "Has sleeping more than usual been a problem for you in the PAST MONTH?",
answer_options: [
{ value: 1, text: "No" },
{
value: 2,
text: "I have slept more than usual but this is not a problem",
},
{ value: 3, text: "Yes" },
],
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) !== 3 ? "irritability" : "sleep-gain-frequency",
}),
new Item({
id: "sleep-gain-frequency",
question: "On how many nights in the SEVEN NIGHTS did you have problems with your sleep?",
answer_options: [
{ value: 1, text: "None" },
{ value: 2, text: "Between one and three nights" },
{ value: 3, text: "Four nights or more" },
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 3)
state.counters.increment("sleep", 1);
},
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 1 ? "irritability" : "sleep-gain-time",
}),
new Item({
id: "sleep-gain-time",
question: "Thinking about the night you slept the longest in the PAST SEVEN DAYS, how much longer did you sleep compared with how long you normally sleep for?",
answer_options: [
{ value: 1, text: "Less than 15 minutes" },
{ value: 2, text: "Between 15 minutes and 1 hour" },
{ value: 3, text: "Between 1 and 3 hours" },
{ value: 4, text: "Three hours or more" },
],
process_answer_fun: (ans, state) => {
const v = ans === null || ans === void 0 ? void 0 : ans.value;
if (!v)
return;
if (v === 2)
state.counters.increment("sleep", 1);
if (v >= 3)
state.counters.increment("sleep", 2);
if (v >= 3 && state.counters.get("sleep_detail", 0) >= 1)
state.counters.set("sleep_detail", 3);
},
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 1 ? "irritability" : "sleep-gain-long",
}),
new Item({
id: "sleep-gain-long",
question: "In the PAST SEVEN DAYS, on how many nights did you sleep for more than 3 hours longer usual?",
answer_options: [
{ value: 1, text: "None" },
{ value: 2, text: "Between one and three nights" },
{ value: 3, text: "Four nights or more" },
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 3)
state.counters.increment("sleep", 1);
},
next_item: "sleep-duration",
}),
new Item({
id: "sleep-duration",
question: "How long have you had these problems with your sleep as you have described?",
answer_options: [
{ value: 1, text: "Less than 2 weeks" },
{ value: 2, text: "Between 2 weeks and 6 months" },
{ value: 3, text: "Between 6 months and 1 year" },
{ value: 4, text: "Between 1 and 2 years" },
{ value: 5, text: "Between 2 and 5 years" },
{ value: 6, text: "More than 5 years" },
],
next_item: "irritability",
}),
new Item({
id: "irritability",
question: "Many people become irritable or short tempered at times, though they may not show it.\n\nHave you felt irritable or short tempered with those around you in the PAST MONTH?",
answer_options: [
{ value: 1, text: "No" },
{
value: 2,
text: "Yes, I have felt irritable or short tempered recently",
},
],
process_answer_fun: (ans, state) => {
const sleep = state.counters.get("sleep", 0);
if (!sleep)
return;
state.counters.increment("score", sleep);
if (sleep >= 2)
state.counters.increment("depression_criterion_2", 1);
},
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 2 ? "irritability-frequency" : "irritability-trivial",
}),
new Item({
id: "irritability-trivial",
question: "During the PAST MONTH, did you get short tempered or angry over things which now seem trivial when you look back on them?",
answer_options: [
{ value: 1, text: "No" },
{ value: 2, text: "Sometimes" },
{ value: 3, text: "Yes" },
],
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 1 ? "hypochondria" : "irritability-frequency",
}),
new Item({
id: "irritability-frequency",
question: "On how many days have you felt irritable, short tempered or angry in the PAST SEVEN DAYS?",
answer_options: [
{ value: 1, text: "None" },
{ value: 2, text: "Between one and three days" },
{ value: 3, text: "Four days or more" },
],
process_answer_fun: (ans, state) => {
if ((ans === null || ans === void 0 ? void 0 : ans.value) === 3)
state.counters.increment("irritability", 1);
},
next_item_fun: (ans) => (ans === null || ans === void 0 ? void 0 : ans.value) === 1 ? "hypochondria" : "irritability-long",
}),
new Item({
id: "irritability-long",
question: "In total, have you felt irritable, short tempered or angry for more than one hour on any day in the PAST SEVEN DAYS?",