-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_dictionary.R
More file actions
879 lines (854 loc) · 85.7 KB
/
Copy pathcreate_dictionary.R
File metadata and controls
879 lines (854 loc) · 85.7 KB
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
# -----------------------------------------------------------------------------#
# COMBINE THE FILES
# -----------------------------------------------------------------------------#
library(tidyverse)
library(ggplot2)
library(ggsci)
library(lubridate)
# set the path where you save the 2 large csv files (pronet_all and
# prescient_all) including all individuals
setwd('C:/Users/Nora/Documents/Harvard/U24/Outcomes/testOutcomesNew/')
# -----------------------------------------------------------------------------#
# create a distribution plot for each variable
pronet_all <- read.csv('pronet_outcome_new.csv')
prescient_all <- read.csv('prescient_all.csv')
# divide the data based on their data-types
pronet_all_integer <- pronet_all %>%
filter(data_type == 'Integer')%>%
mutate(value = case_when(data_type == 'Integer' ~ as.integer(value)))
pronet_all_float <- pronet_all %>%
filter(data_type == 'Float')%>%
mutate(value = case_when(data_type == 'Float' ~ as.numeric(value)))
pronet_all_date <- pronet_all %>%
filter(data_type == 'Date')%>%
mutate(value = case_when(data_type == 'Date' ~ as.Date(ymd_hms(value))))
prescient_all_integer <- prescient_all %>%
filter(data_type == 'Integer')%>%
mutate(value = case_when(data_type == 'Integer' ~ as.integer(value)))
prescient_all_float <- prescient_all %>%
filter(data_type == 'Float')%>%
mutate(value = case_when(data_type == 'Float' ~ as.numeric(value)))
prescient_all_date <- prescient_all %>%
filter(data_type == 'Date')%>%
mutate(value = case_when(data_type == 'Date' ~ as.Date(ymd_hms(value))))
# combine the data from the two dataframes
outcomes_integer <- pronet_all_integer %>%
rbind(., prescient_all_integer)%>%
dplyr::select(-data_type)%>%
pivot_wider(names_from = 'variable', values_from = 'value')
outcomes_date <- pronet_all_date %>%
rbind(., prescient_all_date)%>%
dplyr::select(-data_type)%>%
pivot_wider(names_from = 'variable', values_from = 'value')
outcomes_float <- pronet_all_float %>%
rbind(., prescient_all_float)%>%
dplyr::select(-data_type)%>%
pivot_wider(names_from = 'variable', values_from = 'value')
# -----------------------------------------------------------------------------#
# Create the dictionary of the data
# -----------------------------------------------------------------------------#
# combine the data from the two dataframes
outcomes_integer_long <- pronet_all_integer %>%
# rbind(., prescient_all_integer)%>%
group_by(variable) %>%
arrange(value)%>%
summarize(distinct_values = paste(unique(value), collapse = "; "))%>%
mutate(n_distinct_values = str_count(distinct_values, ";\\s?") + 1)%>%
mutate(distinct_values_list = str_extract_all(distinct_values, "-?\\d+"),
distinct_values_list_no_missing = lapply(distinct_values_list, function(x) x[x != "-300" & x != "-900"]),
distinct_values_list_numeric = lapply(distinct_values_list_no_missing, as.numeric),
min_value = sapply(distinct_values_list_numeric, min),
max_value = sapply(distinct_values_list_numeric, max))%>%
dplyr::select(variable, distinct_values, n_distinct_values, min_value, max_value)%>%
mutate_all(as.character)
outcomes_date_long <- pronet_all_date %>%
# rbind(., prescient_all_date)%>%
group_by(variable) %>%
arrange(value)%>%
summarize(distinct_values = paste(unique(value), collapse = "; "))%>%
mutate(n_distinct_values = str_count(distinct_values, ";\\s?") + 1)%>%
mutate(distinct_values_list = str_extract_all(distinct_values, "\\d{4}-\\d{2}-\\d{2}"),
distinct_values_list_no_missing =
lapply(distinct_values_list, function(x) x[x != "1903-03-03" & x != "1909-09-09"]),
distinct_values_list_numeric = lapply(distinct_values_list_no_missing, function(x) as.Date(x, format = "%Y-%m-%d")),
min_value = sapply(distinct_values_list_numeric, min, na.rm = TRUE),
max_value = sapply(distinct_values_list_numeric, max, na.rm = TRUE))%>%
dplyr::select(variable, distinct_values, n_distinct_values, min_value, max_value)%>%
mutate(min_value = as.Date(min_value, origin = "1970-01-01"),
max_value = as.Date(max_value, origin = "1970-01-01"))%>%
mutate_all(as.character)
outcomes_float_long <- pronet_all_float %>%
# rbind(., prescient_all_float)%>%
group_by(variable) %>%
arrange(value)%>%
summarize(distinct_values = paste(unique(value), collapse = "; "))%>%
mutate(n_distinct_values = str_count(distinct_values, ";\\s?") + 1)%>%
mutate(distinct_values_list = str_extract_all(distinct_values, "(?<!-)[0-9]+(?:\\.[0-9]+)?"),
distinct_values_list_no_missing = lapply(distinct_values_list, function(x) x[x != "-300" & x != "-900"]),
distinct_values_list_numeric = lapply(distinct_values_list_no_missing, as.double),
min_value = sapply(distinct_values_list_numeric, min),
max_value = sapply(distinct_values_list_numeric, max))%>%
dplyr::select(variable, distinct_values, n_distinct_values, min_value, max_value)%>%
mutate_all(as.character)
outcomes_long_types <- outcomes_float_long %>%
rbind(., outcomes_integer_long)%>%
rbind(., outcomes_date_long)%>%
dplyr::select(-n_distinct_values)
# -----------------------------------------------------------------------------#
outcome_long <- pronet_all %>%
distinct(variable, data_type, .keep_all = FALSE)%>%
left_join(., outcomes_long_types, by = 'variable')
# Email from Sylvain with the indications for the dictionary
# Nora, if it's not already done could you generate a data dictionary that has the following information:
#
# Variable name (use REDCap name if it already exists) - update for the psychs variables!
# Data type (integer, date, etc.) - DONE
# Description (something readable: e.g., "Anxiety score") - UPDATE
# Value range if applicable (e.g., 1-10 or M;F or 0;1) - DONE
# Notes (the formula used to calculate the score, perhaps note your code but the information originally provided by the expert?) DONE
# Aliases: If an expert has given you a variable name that is different than the one in REDCap, put it here.
# I have added the name of the csv and the name of the expert as well.
variables_outcome <- outcome_long %>%
mutate(csv_names =
case_when(
str_detect(variable, 'pds_total_score|chrpds_pds_f5b_p') ~ 'pubertal_developmental_scale.csv',
str_detect(variable, 'global_role') ~ 'global_functioning_role_scale.csv',
str_detect(variable, 'global_social') ~ 'global_functioning_social_scale.csv',
str_detect(variable, 'bprs') ~ 'bprs.csv',
str_detect(variable, 'perceived_stress') ~ 'perceived_stress_scale.csv',
str_detect(variable, 'oasis') ~ 'oasis.csv',
str_detect(variable, 'perceived_disc') ~ 'perceived_discrimination_scale.csv',
str_detect(variable, 'cdss') ~ 'cdss.csv',
str_detect(variable, 'chrsofas_currscore_fu|chrsofas_currscore12mo_fu') ~ 'sofas_followup.csv',
str_detect(variable, 'chrsofas_premorbid|chrsofas_currscore12mo|chrsofas_currscore|chrsofas_lowscore') ~ 'sofas_screening.csv',
str_detect(variable, 'psychs|sips|caarms|psychosis|dsm_schizo|first_degree_relative|drop30_sofas|premorbid_less90|conversion_date|sofas_premorbid') ~ 'psychs.csv',
variable == 'sofas_oneyearago' | variable == 'sofas_pasyear' | variable == 'sofas_pastmonth' ~ 'psychs.csv',
str_detect(variable, 'nsipr') ~ 'nsipr.csv',
str_detect(variable, 'promis') ~ 'item_promis_for_sleep.csv',
str_detect(variable, 'chrpgi_2') ~ 'pgis.csv',
str_detect(variable, 'promis') ~ 'item_promis_for_sleep.csv',
str_detect(variable, 'cssrs') ~ 'cssrs_baseline.csv',
str_detect(variable, 'chrpps') ~ 'psychosis_polyrisk_score.csv',
str_detect(variable, 'tobac|alco|cannab|cocaine|ampheta|inhalant|sedative|halluc|opiod|other') ~ 'assist.csv',
str_detect(variable, 'chrpred') ~ 'ra_prediction.csv',
str_detect(variable, 'childhood_subtotal|adolescence_sub|adulthood_sub|only_childhood|upto_') ~ 'premorbid_adjustment_scale.csv'))%>%
mutate(description =
case_when(variable == "psychs_pos_tot" ~ 'PSYCHS Total Score',
variable == "psychs_sips_p1" ~ 'SIPS P1 Severity Score: Unusual Thought Content/Delusional Ideas',
variable == "psychs_sips_p2" ~ 'SIPS P2 Severity Score: Suspiciousness/Persecutory Ideas',
variable == "psychs_sips_p3" ~ 'SIPS P3 Severity Score: Grandiose Ideas',
variable == "psychs_sips_p4" ~ 'SIPS P4 Severity Score: Perceptual Abnormalities/Hallucinations',
variable == "psychs_sips_p5" ~ 'SIPS P5 Severity Score: Disorganized Communication',
variable == "sips_pos_tot" ~ 'SIPS Positive Severity Score',
variable == "psychs_caarms_p1" ~ 'product of frequency by intensity of positive scale P1',
variable == "psychs_caarms_p2" ~ 'product of frequency by intensity of positive scale P2',
variable == "psychs_caarms_p3" ~ 'product of frequency by intensity of positive scale P3',
variable == "psychs_caarms_p4" ~ 'product of frequency by intensity of positive scale P4',
variable == "caarms_pos_tot" ~ 'sum of Caarms P1-4',
variable == "psychosis_onset_date" ~ 'earliest date (minimum) of all psychosis onset dates measured',
variable == "sips_" ~ 'earliest date (minimum) of all psychosis onset dates measured',
variable == "chrpsychs_scr_ac1" ~ 'Psychosis',
variable == "chrpsychs_scr_ac2" ~ 'CAARMS BLIPS',
variable == "chrpsychs_scr_ac3" ~ 'CAARMS APS subthreshold frequency',
variable == "chrpsychs_scr_ac4" ~ 'CAARMS APS subthreshold intensity',
variable == "chrpsychs_scr_ac5" ~ 'CAARMS APS',
variable == "chrpsychs_scr_ac6" ~ 'CAARMS Vulnerability',
variable == "chrpsychs_scr_ac7" ~ 'CAARMS ultra high risk group',
variable == "chrpsychs_scr_ac9" ~ 'SIPS - BIPS Progression',
variable == "chrpsychs_scr_ac10" ~ 'SIPS - BIPS Persistence',
variable == "chrpsychs_scr_ac11" ~ 'SIPS - BIPS Partial Remission',
variable == "chrpsychs_scr_ac12" ~ 'SIPS - BIPS Full Remission',
variable == "chrpsychs_scr_ac15" ~ 'SIPS - APSS Progression',
variable == "chrpsychs_scr_ac16" ~ 'SIPS - APSS Persistence',
variable == "chrpsychs_scr_ac17" ~ 'SIPS - APSS Partial Remission',
variable == "chrpsychs_scr_ac18" ~ 'SIPS - APSS Full Remission',
variable == "chrpsychs_scr_ac21" ~ 'SIPS - GRD Progression',
variable == "chrpsychs_scr_ac22" ~ 'SIPS - GRD Persistence',
variable == "chrpsychs_scr_ac23" ~ 'SIPS - GRD Partial Remission',
variable == "chrpsychs_scr_ac24" ~ 'SIPS - GRD Full Remission',
variable == "chrpsychs_scr_ac27" ~ 'SIPS - CHR Progression',
variable == "chrpsychs_scr_ac28" ~ 'SIPS - CHR Persistence',
variable == "chrpsychs_scr_ac29" ~ 'SIPS - CHR Partial Remission',
variable == "chrpsychs_scr_ac30" ~ 'SIPS - CHR Full Remission',
variable == "chrpsychs_scr_ac31" ~ 'SIPS - Current Status',
variable == "chrpsychs_scr_ac32" ~ 'DSM5 - Attenuated Psychosis',
variable == "conversion_date" ~ 'Date of Conversion',
variable == "hcpsychs_fu_ac1" ~ 'Psychosis',
variable == "hcpsychs_fu_ac1_curr" ~ 'Psychosis at any time since the previous visit',
variable == "hcpsychs_fu_ac1_prev" ~ 'Psychosis at previous visit',
variable == "hcpsychs_fu_ac1_first" ~ 'Psychosis for the first time at the current visit',
variable == "hcpsychs_fu_ac1_conv" ~ 'Psychosis for the first time at the current visit and no psychosis before',
variable == "hcpsychs_fu_ac9" ~ 'SIPS BIPS Progression',
variable == "hcpsychs_fu_ac10" ~ 'SIPS BIPS Persistence',
variable == "hcpsychs_fu_ac11" ~ 'SIPS BIPS Partial Remission',
variable == "hcpsychs_fu_ac12" ~ 'SIPS BIPS Full Remission',
variable == "hcpsychs_fu_ac15" ~ 'SIPS APSS Progression',
variable == "hcpsychs_fu_ac16" ~ 'SIPS APSS Persistence',
variable == "hcpsychs_fu_ac17" ~ 'SIPS APSS Partial Remission',
variable == "hcpsychs_fu_ac18" ~ 'SIPS APSS Full Remission',
variable == "hcpsychs_fu_ac21" ~ 'SIPS GRD Progression',
variable == "hcpsychs_fu_ac22" ~ 'SIPS GRD Persistence',
variable == "hcpsychs_fu_ac23" ~ 'SIPS GRD Partial Remission',
variable == "hcpsychs_fu_ac24" ~ 'SIPS GRD Full Remission',
variable == "hcpsychs_fu_ac27" ~ 'SIPS CHR Progression',
variable == "hcpsychs_fu_ac28" ~ 'SIPS CHR Persistence',
variable == "hcpsychs_fu_ac29" ~ 'SIPS CHR Partial Remission',
variable == "hcpsychs_fu_ac30" ~ 'SIPS CHR Full Remission',
variable == "hcpsychs_fu_ac31" ~ 'SIPS Current Status',
variable == "hcpsychs_fu_ac32" ~ 'DSM-5 Attenuated Psychosis Syndrome',
variable == "chrpsychs_fu_ac1" ~ 'Psychosis',
variable == "chrpsychs_fu_ac1_curr" ~ 'Psychosis at any time since the previous visit',
variable == "chrpsychs_fu_ac1_prev" ~ 'Psychosis at previous visit',
variable == "chrpsychs_fu_ac1_first" ~ 'Psychosis for the first time at the current visit',
variable == "chrpsychs_fu_ac1_conv" ~ 'Psychosis for the first time at the current visit and no psychosis before',
variable == "chrpsychs_fu_ac9" ~ 'SIPS BIPS Progression',
variable == "chrpsychs_fu_ac10" ~ 'SIPS BIPS Persistence',
variable == "chrpsychs_fu_ac11" ~ 'SIPS BIPS Partial Remission',
variable == "chrpsychs_fu_ac12" ~ 'SIPS BIPS Full Remission',
variable == "chrpsychs_fu_ac15" ~ 'SIPS APSS Progression',
variable == "chrpsychs_fu_ac16" ~ 'SIPS APSS Persistence',
variable == "chrpsychs_fu_ac17" ~ 'SIPS APSS Partial Remission',
variable == "chrpsychs_fu_ac18" ~ 'SIPS APSS Full Remission',
variable == "chrpsychs_fu_ac21" ~ 'SIPS GRD Progression',
variable == "chrpsychs_fu_ac22" ~ 'SIPS GRD Persistence',
variable == "chrpsychs_fu_ac23" ~ 'SIPS GRD Partial Remission',
variable == "chrpsychs_fu_ac24" ~ 'SIPS GRD Full Remission',
variable == "chrpsychs_fu_ac27" ~ 'SIPS CHR Progression',
variable == "chrpsychs_fu_ac28" ~ 'SIPS CHR Persistence',
variable == "chrpsychs_fu_ac29" ~ 'SIPS CHR Partial Remission',
variable == "chrpsychs_fu_ac30" ~ 'SIPS CHR Full Remission',
variable == "chrpsychs_fu_ac31" ~ 'SIPS Current Status',
variable == "chrpsychs_fu_ac32" ~ 'DSM-5 Attenuated Psychosis Syndrome',
variable == "psychosis_current" ~ 'Psychosis Current',
variable == "psychosis_previous" ~ 'Psychosis Previous',
variable == "psychosis_first" ~ 'Psychosis First',
variable == "psychosis_conversion" ~ 'Psychosis Conversion',
variable == "chrpps_sum1" ~ 'Risk 1 based on Sex/Age',
variable == "chrpps_sum2" ~ 'Risk 2 based on handedness',
variable == "chrpps_sum7" ~ 'Risk 7 based on paternal age',
variable == "chrpps_sum8" ~ 'Risk 8 based on social economic status',
variable == "chrpps_sum9" ~ 'Risk 9 based on parental severe mental illness',
variable == "chrpps_sum10" ~ 'Risk 10 based on adult life events',
variable == "chrpps_sum11" ~ 'Risk 11 based on daily smoking',
variable == "chrpps_sum12" ~ 'Risk 12 based on heavy cannabis use',
variable == "chrpps_sum13" ~ 'Risk 13 based on childhood trauma',
variable == "chrpps_sum14" ~ 'Risk 14 based on Trait anhedonia',
variable == "chrassist_tobacco" ~ 'Severity of use: tobacco',
variable == "chrassist_alcohol" ~ 'Severity of use: alcohol',
variable == "chrassist_cannabis" ~ 'Severity of use: cannabis',
variable == "chrassist_cocaine" ~ 'Severity of use: cocaine',
variable == "chrassist_amphetamines" ~ 'Severity of use: amphetamines',
variable == "chrassist_inhalants" ~ 'Severity of use: inhalants',
variable == "chrassist_sedatives" ~ 'Severity of use: sedatives',
variable == "chrassist_hallucinogens" ~ 'Severity of use: hallucinogens',
variable == "chrassist_opiods" ~ 'Severity of use: opiods',
variable == "chrassist_other" ~ 'Severity of use: other',
variable == "chrpas_childhood_subtotal" ~ 'PAS: Childhood',
variable == "chrpas_early_adolescence_subtotal" ~ 'PAS: Early Adolescence',
variable == "chrpas_late_adolescence_subtotal" ~ 'PAS: Late Adolescence',
variable == "chrpas_adulthood_subtotal" ~ 'PAS: Adulthood',
variable == "chrpas_total_score_only_childhood" ~ 'PAS: Only Childhood',
variable == "chrpas_total_score_upto_early_adolescence" ~ 'PAS: Up to early adolescence',
variable == "chrpas_total_score_upto_late_adolescence" ~ 'PAS: Up to late adolescence',
variable == "chrpas_total_score_upto_adulthood" ~ 'PAS: Up to Adulthood',
variable == "chrcssrs_intensity_lifetime" ~ 'CSSRS (Suicide intensity): Lifetime',
variable == "chrcssrs_intensity_pastmonth" ~ 'CSSRS (Suicide intensity): Past Month',
variable == "chrpred_transition" ~ 'Rater prediction Transition: Yes/No',
variable == "chrpred_experience" ~ 'Month of experience of the raters',
variable == "chrpgi_2" ~ 'Overall health symptoms of the last 7 days (PGI-S)',
variable == "chrpromis_total" ~ 'Sleep quality (PROMIS)',
variable == "chrgfrs_decline_in_global_role_functioning" ~ 'Decline in role functioning (highest score in lifetime - current score)',
variable == "chrgfss_decline_in_global_social_functioning" ~ 'Decline in social functioning (highest score in lifetime - current score)',
variable == "chrnsipr_motivation_and_pleasure_dimension" ~ 'Motivation and Pleasure (NSIPR)',
variable == "chrnsipr_diminished_expression_dimension" ~ 'Diminished Expression Dimension (NSIPR)',
variable == "chrnsipr_avolition_domain" ~ 'Avolition (NSIPR)',
variable == "chrnsipr_asociality_domain" ~ 'Asociality (NSIPR)',
variable == "chrnsipr_anhedonia_domain" ~ 'Anhedonia (NSIPR)',
variable == "chrnsipr_blunted_affect_domain" ~ 'Blunted Affect (NSIPR)',
variable == "chrnsipr_item11_rating" ~ 'Alogia (NSIPR)',
variable == "chrsofas_premorbid" ~ 'SOFAS: Premorbid',
variable == "chrsofas_currscore12mo" ~ 'SOFAS: 12 months ago',
variable == "chrsofas_currscore" ~ 'SOFAS: Current score at screening',
variable == "chrsofas_lowscore" ~ 'SOFAS: Lowest score in the last year',
variable == "chrsofas_currscore_fu" ~ 'SOFAS: current score at follow-up',
variable == "chrsofas_currscore12mo_fu" ~ 'SOFAS: Score 12 months ago at follow up',
variable == "chrpds_total_score_female_sex" ~ 'Pubertal developmental scale: total score',
variable == "chrpds_total_score_male_sex" ~ 'Pubertal developmental scale: total score',
variable == "chrpds_pds_f5b_p" ~ 'Menarche: Yes/No',
variable == "chrbprs_bprs_total" ~ 'BRPS: Total score',
variable == "chrbprs_affect_subscale" ~ 'BRPS: Affect subscale',
variable == "chrbprs_positive_symptom_subscale" ~ 'BRPS: Positive symptoms subscale',
variable == "chrbprs_negative_symptom_subscale" ~ 'BRPS: Negative symptoms subscale',
variable == "chrbprs_activation_subscale" ~ 'BRPS: Activation subscale',
variable == "chrbprs_disorganization_subscale" ~ 'BRPS: Disorganization',
variable == "chroasis_total" ~ 'OASIS total (Anxiety)',
variable == "chrpds_perceived_discrimination_total" ~ 'Total score of Perceived discrimination',
variable == "chrcdss_total" ~ 'Total of depressive symptoms (CDSS)',
variable == "chrpss_perceived_stress_scale_total" ~ 'Total of perceived stress'))%>%
mutate(diverging_expert_variable_name =
case_when(variable == "psychs_pos_tot" ~ 'PSYCHS Total Score',
variable == "psychs_sips_p1" ~ 'SIPS P1 Severity Score: Unusual Thought Content/Delusional Ideas',
variable == "psychs_sips_p2" ~ 'SIPS P2 Severity Score: Suspiciousness/Persecutory Ideas',
variable == "psychs_sips_p3" ~ 'SIPS P3 Severity Score: Grandiose Ideas',
variable == "psychs_sips_p4" ~ 'SIPS P4 Severity Score: Perceptual Abnormalities/Hallucinations',
variable == "psychs_sips_p5" ~ 'SIPS P5 Severity Score: Disorganized Communication',
variable == "sips_pos_tot" ~ 'SIPS Positive Severity Score',
variable == "psychs_caarms_p1" ~ 'product of frequency by intensity of positive scale P1',
variable == "psychs_caarms_p2" ~ 'product of frequency by intensity of positive scale P2',
variable == "psychs_caarms_p3" ~ 'product of frequency by intensity of positive scale P3',
variable == "psychs_caarms_p4" ~ 'product of frequency by intensity of positive scale P4',
variable == "caarms_pos_tot" ~ 'sum of Caarms P1-4',
variable == "psychosis_onset_date" ~ 'earliest date (minimum) of all psychosis onset dates measured',
variable == "chrpsychs_scr_ac1" ~ 'Psychosis - yes/no',
variable == "chrpsychs_scr_ac2" ~ 'CAARMS BLIPS',
variable == "chrpsychs_scr_ac3" ~ 'CAARMS APS subthreshold frequency',
variable == "chrpsychs_scr_ac4" ~ 'CAARMS APS subthreshold intensity',
variable == "chrpsychs_scr_ac5" ~ 'CAARMS APS',
variable == "chrpsychs_scr_ac6" ~ 'CAARMS Vulnerability',
variable == "chrpsychs_scr_ac7" ~ 'CAARMS ultra high risk group',
variable == "chrpsychs_scr_ac9" ~ 'SIPS - BIPS Progression',
variable == "chrpsychs_scr_ac10" ~ 'SIPS - BIPS Persistence',
variable == "chrpsychs_scr_ac11" ~ 'SIPS - BIPS Partial Remission',
variable == "chrpsychs_scr_ac12" ~ 'SIPS - BIPS Full Remission',
variable == "chrpsychs_scr_ac15" ~ 'SIPS - APSS Progression',
variable == "chrpsychs_scr_ac16" ~ 'SIPS - APSS Persistence',
variable == "chrpsychs_scr_ac17" ~ 'SIPS - APSS Partial Remission',
variable == "chrpsychs_scr_ac18" ~ 'SIPS - APSS Full Remission',
variable == "chrpsychs_scr_ac21" ~ 'SIPS - GRD Progression',
variable == "chrpsychs_scr_ac22" ~ 'SIPS - GRD Persistence',
variable == "chrpsychs_scr_ac23" ~ 'SIPS - GRD Partial Remission',
variable == "chrpsychs_scr_ac24" ~ 'SIPS - GRD Full Remission',
variable == "chrpsychs_scr_ac27" ~ 'SIPS - CHR Progression',
variable == "chrpsychs_scr_ac28" ~ 'SIPS - CHR Persistence',
variable == "chrpsychs_scr_ac29" ~ 'SIPS - CHR Partial Remission',
variable == "chrpsychs_scr_ac30" ~ 'SIPS - CHR Full Remission',
variable == "chrpsychs_scr_ac31" ~ 'SIPS - Current Status',
variable == "chrpsychs_scr_ac32" ~ 'DSM5 - Attenuated Psychosis',
variable == "conversion_date" ~ 'Date of Conversion',
variable == "psychosis_current" ~ 'Psychosis Current',
variable == "psychosis_previous" ~ 'Psychosis Previous',
variable == "psychosis_first" ~ 'Psychosis First',
variable == "psychosis_conversion" ~ 'Psychosis Conversion',
variable == "chrpps_sum1" ~ '',
variable == "chrpps_sum2" ~ '',
variable == "chrpps_sum7" ~ '',
variable == "chrpps_sum8" ~ '',
variable == "chrpps_sum9" ~ '',
variable == "chrpps_sum10" ~ '',
variable == "chrpps_sum11" ~ '',
variable == "chrpps_sum12" ~ '',
variable == "chrpps_sum13" ~ 'chrpps_sum14',
variable == "chrpps_sum14" ~ 'chrpps_sum15',
variable == "chrassist_tobacco" ~ '',
variable == "chrassist_alcohol" ~ '',
variable == "chrassist_cannabis" ~ '',
variable == "chrassist_cocaine" ~ '',
variable == "chrassist_amphetamines" ~ '',
variable == "chrassist_inhalants" ~ '',
variable == "chrassist_sedatives" ~ '',
variable == "chrassist_hallucinogens" ~ '',
variable == "chrassist_opiods" ~ '',
variable == "chrassist_other" ~ '',
variable == "chrpas_childhood_subtotal" ~ '',
variable == "chrpas_early_adolescence_subtotal" ~ '',
variable == "chrpas_late_adolescence_subtotal" ~ '',
variable == "chrpas_adulthood_subtotal" ~ '',
variable == "chrpas_total_score_only_childhood" ~ '',
variable == "chrpas_total_score_upto_early_adolescence" ~ '',
variable == "chrpas_total_score_upto_late_adolescence" ~ '',
variable == "chrpas_total_score_upto_adulthood" ~ '',
variable == "chrcssrs_intensity_lifetime" ~ '',
variable == "chrcssrs_intensity_pastmonth" ~ '',
variable == "chrpred_transition" ~ '',
variable == "chrpred_experience" ~ '',
variable == "chrpgi_2" ~ '',
variable == "chrpromis_total" ~ 'A total of the 8 items with very poor being 1 and up to very good being 5',
variable == "chrgfrs_decline_in_global_role_functioning" ~ '',
variable == "chrgfss_decline_in_global_social_functioning" ~ '',
variable == "chrnsipr_motivation_and_pleasure_dimension" ~ '',
variable == "chrnsipr_diminished_expression_dimension" ~ '',
variable == "chrnsipr_avolition_domain" ~ '',
variable == "chrnsipr_asociality_domain" ~ '',
variable == "chrnsipr_anhedonia_domain" ~ '',
variable == "chrnsipr_blunted_affect_domain" ~ '',
variable == "chrnsipr_item11_rating" ~ 'nsipr_alogia_domain',
variable == "chrsofas_premorbid" ~ 'SOFAS Premorbid',
variable == "chrsofas_currscore12mo" ~ 'SOFAS score 12 months ago',
variable == "chrsofas_currscore" ~ 'SOFAS current score at screening',
variable == "chrsofas_lowscore" ~ 'SOFAS lowest score in the last year',
variable == "chrsofas_currscore_fu" ~ 'SOFAS current score at follow-up',
variable == "chrsofas_currscore12mo_fu" ~ 'SOFAS score 12 months ago from follow up',
variable == "chrpds_total_score_sex" ~ 'PDS total score female sex/PDS total score male sex',
variable == "chrpds_pds_f5b_p" ~ 'pds_menarche',
variable == "chrbprs_bprs_total" ~ 'bprs_total',
variable == "chrbprs_affect_subscale" ~ '',
variable == "chrbprs_positive_symptom_subscale" ~ '',
variable == "chrbprs_negative_symptom_subscale" ~ '',
variable == "chrbprs_activation_subscale" ~ '',
variable == "chrbprs_disorganization_subscale" ~ '',
variable == "chroasis_total" ~ '',
variable == "chrpds_perceived_discrimination_total" ~ '',
variable == "chrcdss_total" ~ '',
variable == "chrpss_perceived_stress_scale_total" ~ ''))%>%
mutate(Experts =
case_when(
str_detect(variable, 'pds') ~ 'Melissa Kerr',
str_detect(variable, 'global_role') ~ 'Jean Addington',
str_detect(variable, 'global_social') ~ 'Jean Addington',
str_detect(variable, 'bprs') ~ 'Melissa Kerr',
str_detect(variable, 'perceived_stress') ~ 'Jean Addington',
str_detect(variable, 'oasis') ~ 'Jean Addington',
str_detect(variable, 'perceived_disc') ~ 'Jean Addington',
str_detect(variable, 'cdss') ~ 'Jean Addington',
str_detect(variable, 'chrsofas_premorbid|chrsofas_currscore12mo|chrsofas_currscore|chrsofas_lowscore') ~ 'Melissa Kerr',
str_detect(variable, 'chrsofas_currscore_fu|chrsofas_currscore12mo_fu') ~ 'Melissa Kerr',
str_detect(variable, 'psychs|sips|caarms|psychosis|dsm_schizo|first_degree_relative|drop30_sofas|premorbid_less90|conversion_date|sofas_premorbid') ~ 'Scott Woods',
variable == 'sofas_oneyearago' | variable == 'sofas_pasyear' | variable == 'sofas_pastmonth' ~ 'Scott Woods',
str_detect(variable, 'nsipr') ~ 'Greg Strauss',
str_detect(variable, 'promis') ~ 'Jean Addington',
str_detect(variable, 'pgi') ~ 'Jean Addington',
str_detect(variable, 'promis') ~ 'Jean Addington',
str_detect(variable, 'cssrs') ~ 'Cheryl Corcoran',
str_detect(variable, 'chrpps') ~ 'Dominic Oliver',
str_detect(variable, 'tobac|alco|cannab|cocaine|ampheta|inhalant|sedative|halluc|opiod|other') ~ 'Melissa Kerr',
str_detect(variable, 'chrpred') ~ 'Jean Addington',
str_detect(variable, 'childhood_subtotal|adolescence_sub|adulthood_sub|only_childhood|upto_') ~ 'Jean Addington'))%>%
mutate(Notes =
case_when(variable == "psychs_pos_tot" ~ 'chrpsychs_scr_1d1+chrpsychs_scr_2d1+chrpsychs_scr_3d1+chrpsychs_scr_4d5+chrpsychs_scr_5d1+chrpsychs_scr_6d1+chrpsychs_scr_7d1+chrpsychs_scr_8d1+chrpsychs_scr_9d1+chrpsychs_scr_10d1+chrpsychs_scr_11d1+chrpsychs_scr_12d1+chrpsychs_scr_13d1+chrpsychs_scr_14d1+chrpsychs_scr_15d1',
variable == "psychs_sips_p1" ~ 'Maximum of chrpsychs_scr_1d1, chrpsychs_scr_3d1, chrpsychs_scr_4d1, chrpsychs_scr_5d1, chrpsychs_scr_6d1',
variable == "psychs_sips_p3" ~ 'Maximum of chrpsychs_scr_7d1, chrpsychs_scr_8d1',
variable == "psychs_sips_p4" ~ 'Maximum of chrpsychs_scr_9d1, chrpsychs_scr_10d1, chrpsychs_scr_11d1, chrpsychs_scr_12d1, chrpsychs_scr_13d1, chrpsychs_scr_14d1',
variable == "sips_pos_tot" ~ 'if screening: psychs_sips_p1+chrpsychs_scr_2d1+psychs_sips_p3+psychs_sips_p4+chrpsychs_scr_15d1, elseif: redcap_event_name != screening and network == pronet and studygroup == hc: psychs_sips_p1+hcpsychs_fu_2d1+psychs_sips_p3+psychs_sips_p4+hcpsychs_fu_15d1, else: psychs_sips_p1+chrpsychs_fu_2d1+psychs_sips_p3+psychs_sips_p4+chrpsychs_fu_15d1',
variable == "psychs_caarms_p1" ~ 'chrpsychs_scr_1d1*chrpsychs_scr_1d2',
variable == "psychs_caarms_p2" ~ 'Maximum of (chrpsychs_scr_2d1*chrpsychs_scr_2d2),(chrpsychs_scr_3d1*chrpsychs_scr_3d2),(chrpsychs_scr_4d1*chrpsychs_scr_4d2),(chrpsychs_scr_5d1*chrpsychs_scr_5d2),(chrpsychs_scr_6d1*chrpsychs_scr_6d2),(chrpsychs_scr_7d1*chrpsychs_scr_7d2),(chrpsychs_scr_8d1*chrpsychs_scr_8d2)',
variable == "psychs_caarms_p3" ~ 'Maximum of (chrpsychs_scr_9d1*chrpsychs_scr_9d2),(chrpsychs_scr_10d1*chrpsychs_scr_10d2),(chrpsychs_scr_11d1*chrpsychs_scr_11d2),(chrpsychs_scr_12d1*chrpsychs_scr_12d2),(chrpsychs_scr_13d1*chrpsychs_scr_13d2),(chrpsychs_scr_14d1*chrpsychs_scr_14d2)',
variable == "psychs_caarms_p4" ~ 'chrpsychs_scr_15d1*chrpsychs_scr_15d2',
variable == "caarms_pos_tot" ~ 'psychs_caarms_p1+psychs_caarms_p2+psychs_caarms_p3+psychs_caarms_p4',
variable == "psychosis_onset_date" ~ 'Minimum of chrpsychs_scr_1a6_on,chrpsychs_scr_2a6_on,chrpsychs_scr_3a6_on,chrpsychs_scr_4a6_on,chrpsychs_scr_5a6_on,chrpsychs_scr_6a6_on,chrpsychs_scr_7a6_on,chrpsychs_scr_8a6_on,chrpsychs_scr_9a6_on,chrpsychs_scr_10a6_on,chrpsychs_scr_11a6_on,chrpsychs_scr_12a6_on,chrpsychs_scr_13a6_on,chrpsychs_scr_14a6_on,chrpsychs_scr_15a6_on',
variable == "conversion_date" ~ 'if network == pronet and studygroup == hc and any of (hcpsychs_fu_1c6,hcpsychs_fu_2c6,hcpsychs_fu_3c6,hcpsychs_fu_4c6,hcpsychs_fu_5c6,hcpsychs_fu_6c6,hcpsychs_fu_7c6,hcpsychs_fu_8c6,hcpsychs_fu_9c6,hcpsychs_fu_10c6,hcpsychs_fu_11c6,hcpsychs_fu_12c6,hcpsychs_fu_13c6,hcpsychs_fu_14c6,hcpsychs_fu_15c6 == 1): min(hcpsychs_fu_1c6_on,hcpsychs_fu_2c6_on,hcpsychs_fu_3c6_on,hcpsychs_fu_4c6_on,hcpsychs_fu_5c6_on,hcpsychs_fu_6c6_on,hcpsychs_fu_7c6_on,hcpsychs_fu_8c6_on,hcpsychs_fu_9c6_on,hcpsychs_fu_10c6_on,hcpsychs_fu_11c6_on,hcpsychs_fu_12c6_on,hcpsychs_fu_13c6_on,hcpsychs_fu_14c6_on,hcpsychs_fu_15c6_on), elseif network == pronet and studygroup == hc: 1903-03-03, elseif: any of (chrpsychs_fu_1c6,chrpsychs_fu_2c6,chrpsychs_fu_3c6,chrpsychs_fu_4c6,chrpsychs_fu_5c6,chrpsychs_fu_6c6,chrpsychs_fu_7c6,chrpsychs_fu_8c6,chrpsychs_fu_9c6,chrpsychs_fu_10c6,chrpsychs_fu_11c6,chrpsychs_fu_12c6,chrpsychs_fu_13c6,chrpsychs_fu_14c6,chrpsychs_fu_15c6) == 1: min(chrpsychs_fu_1c6_on,chrpsychs_fu_2c6_on,chrpsychs_fu_3c6_on,chrpsychs_fu_4c6_on,chrpsychs_fu_5c6_on,chrpsychs_fu_6c6_on,chrpsychs_fu_7c6_on,chrpsychs_fu_8c6_on,chrpsychs_fu_9c6_on,chrpsychs_fu_10c6_on,chrpsychs_fu_11c6_on,chrpsychs_fu_12c6_on,chrpsychs_fu_13c6_on,chrpsychs_fu_14c6_on,chrpsychs_fu_15c6_on), else: 1903-03-03',
variable == "psychosis" ~ 'Redcap variable',
variable == "dsm_schizotypal_lifetime" ~ 'Redcap variable',
variable == "first_degree_relative" ~ 'Redcap variable',
variable == "sips_grd_lifetime" ~ 'Redcap variable',
variable == "caarms_vulnerability_pastyear" ~ 'Redcap variable',
variable == "drop30_sofas_pastmonth" ~ 'Redcap variable',
variable == "sips_grd_progression_pastmonth" ~ 'Redcap variable',
variable == "sofas_curr_premorbid_less90" ~ 'Redcap variable',
variable == "sips_grd_persistence_pastmonth" ~ 'Redcap variable',
variable == "sips_grd_partial_remission_pastmonth" ~ 'Redcap variable',
variable == "sips_grd_full_remission_pastmonth" ~ 'Redcap variable',
variable == "caarms_blips" ~ 'Redcap variable',
variable == "caarms_aps_subthreshold_frequency" ~ 'Redcap variable',
variable == "caarms_aps_subthreshold_intensity" ~ 'Redcap variable',
variable == "caarms_aps" ~ 'Redcap variable',
variable == "caarms_vulnerability" ~ 'Redcap variable',
variable == "caarms_uhr" ~ 'Redcap variable',
variable == "sips_bips_progression" ~ 'Redcap variable',
variable == "sips_bips_persistence" ~ 'Redcap variable',
variable == "sips_bips_partial_remission" ~ 'Redcap variable',
variable == "sips_bips_full_remission" ~ 'Redcap variable',
variable == "sips_apss_progression" ~ 'Redcap variable',
variable == "sips_apss_persistence" ~ 'Redcap variable',
variable == "sips_apss_partial_remission" ~ 'Redcap variable',
variable == "sips_apss_full_remission" ~ 'Redcap variable',
variable == "sips_grd_progression" ~ 'Redcap variable',
variable == "sips_grd_persistence" ~ 'Redcap variable',
variable == "sips_grd_partial_remission" ~ 'Redcap variable',
variable == "sips_grd_full_remission" ~ 'Redcap variable',
variable == "sips_chr_progression" ~ 'Redcap variable',
variable == "sips_chr_persistence" ~ 'Redcap variable',
variable == "sips_chr_partial_remission" ~ 'Redcap variable',
variable == "sips_chr_full_remission" ~ 'Redcap variable',
variable == "sips_current_status" ~ 'Redcap variable',
variable == "dsm5_attenuated_psychosis" ~ 'Redcap variable',
variable == "psychosis_current" ~ 'Redcap variable',
variable == "psychosis_previous" ~ 'Redcap variable',
variable == "psychosis_first" ~ 'Redcap variable',
variable == "psychosis_conversion" ~ 'Redcap variable',
variable == "sofas_premorbid" ~ 'Redcap variable',
variable == "sofas_oneyearago" ~ 'Redcap variable',
variable == "sofas_pasyear" ~ 'Redcap variable',
variable == "sofas_pasyear" ~ 'Redcap variable',
variable == "sofas_pastmonth" ~ 'Redcap variable',
variable == "drop30_sofas_sincelastvisit" ~ 'Redcap variable',
variable == "sips_grd_new" ~ 'Redcap variable',
variable == "sips_grd_remain" ~ 'Redcap variable',
variable == "chrpps_sum1" ~ 'chrpps_sum1 = 2 if (24<chrdemo_age_yrs_chr<36 and chrguid_sex_chr==1) else chrpps_sum1 = 0',
variable == "chrpps_sum2" ~ 'chrpps_sum2 = 2 if (chrpps_writing+chrpps_throwing+chrpps_toothbrush+chrpps_spoon)<16 else chrpps_sum2 = 0',
variable == "chrpps_sum7" ~ 'chrpps_sum7 = 3.5 if chrpps_fage - chrpps_chrdemo_age_yrs_chr >45 else if chrpps_fage- chrpps_chrdemo_age_yrs_chr>35 chrpps_sum7=0.5 else chrpps_sum7=-0.5',
variable == "chrpps_sum8" ~ 'chrpps_sum8=1 if chrpps_focc>6 else chrpps_sum8=0',
variable == "chrpps_sum9" ~ 'chrpps_sum9 = 5.5 if at least one of the following variables is scored as a 3: chrfigs_mother_ddx chrfigs_mother_mdx chrfigs_mother_pdx chrfigs_mother_napdx chrfigs_mother_apdx chrfigs_father_ddx chrfigs_father_mdx chrfigs_father_pdx chrfigs_father_napdx chrfigs_father_apdx else chrpps_sum9=-2',
variable == "chrpps_sum10" ~ 'chrpps_sum10=5.5 if chrpps_sixmo>1 else chrpps_sum10=-2',
variable == "chrpps_sum11" ~ 'chrpps_sum11=3 if chrassist_whoassist_often1=6 else chrpps_sum=-0.5',
variable == "chrpps_sum12" ~ 'chrpps_sum12=7 if chrassist_whoassist_often3 > 3 else chrpps_sum12=0',
variable == "chrpps_sum13" ~ 'chrpps_sum13=4 if sum(chrpps_lazy chrpps_born, chrpps_hate, chrpps_hurt, chrpps_emoab, chrpps_doc, chrpps_bruise, chrpps_belt, chrpps_physab, chrpps_beat, chrpps_touch, chrpps_threat, chrpps_sexual, chrpps_molest, chrpps_sexab, chrpps_loved(R), chrpps_special(R), chrpps_care(R), chrpps_closefam(R), chrpps_support(R), chrpps_hunger, chrpps_protect(R), chrpps_pardrunk, chrpps_dirty, chrpps_docr(R)) >55 else chrpps_sum13=-0.5',
variable == "chrpps_sum14" ~ 'chrpps_sum14=6.5 sum(chrpps_excite chrpps_taste chrpps_restaur (R) chrpps_roller chrpps_holiday chrpps_tasty chrpps_pleasure chrpps_lookfwd chrpps_menu chrpps_actor chrpps_crackle chrpps_rain chrpps_grass chrpps_air chrpps_coffee chrpps_hair chrpps_yawn chrpps_snow) >35 else chrpps_sum14=0',
variable == "chrassist_tobacco" ~ 'chrassist_whoassist_often1 + chrassist_whoassist_urge1 + chrassist_whoassist_prob1 + chrassist_whoassist_fail1 + chrassist_whoassist_concern1 + chrassist_whoassist_control1',
variable == "chrassist_alcohol" ~ 'chrassist_whoassist_often2 + chrassist_whoassist_urge2 + chrassist_whoassist_prob2 + chrassist_whoassist_fail2 + chrassist_whoassist_concern2 + chrassist_whoassist_control2',
variable == "chrassist_cannabis" ~ 'chrassist_whoassist_often3 + chrassist_whoassist_urge3 + chrassist_whoassist_prob3 + chrassist_whoassist_fail3 + chrassist_whoassist_concern3 + chrassist_whoassist_control3',
variable == "chrassist_cocaine" ~ 'chrassist_whoassist_often4 + chrassist_whoassist_urge4 + chrassist_whoassist_prob4 + chrassist_whoassist_fail4 + chrassist_whoassist_concern4 + chrassist_whoassist_control4',
variable == "chrassist_amphetamines" ~ 'chrassist_whoassist_often5 + chrassist_whoassist_urge5 + chrassist_whoassist_prob5 + chrassist_whoassist_fail5 + chrassist_whoassist_concern5 + chrassist_whoassist_control5',
variable == "chrassist_inhalants" ~ 'chrassist_whoassist_often6 + chrassist_whoassist_urge6 + chrassist_whoassist_prob6 + chrassist_whoassist_fail6 + chrassist_whoassist_concern6 + chrassist_whoassist_control6',
variable == "chrassist_sedatives" ~ 'chrassist_whoassist_often7 + chrassist_whoassist_urge7 + chrassist_whoassist_prob7 + chrassist_whoassist_fail7 + chrassist_whoassist_concern7 + chrassist_whoassist_control7',
variable == "chrassist_hallucinogens" ~ 'chrassist_whoassist_often8 + chrassist_whoassist_urge8 + chrassist_whoassist_prob8 + chrassist_whoassist_fail8 + chrassist_whoassist_concern8 + chrassist_whoassist_control8',
variable == "chrassist_opiods" ~ 'chrassist_whoassist_often9 + chrassist_whoassist_urge9 + chrassist_whoassist_prob9 + chrassist_whoassist_fail9 + chrassist_whoassist_concern9 + chrassist_whoassist_control9',
variable == "chrassist_other" ~ 'chrassist_whoassist_often10 + chrassist_whoassist_urge10 + chrassist_whoassist_prob10 + chrassist_whoassist_fail10 + chrassist_whoassist_concern10 + chrassist_whoassist_control10',
variable == "chrpas_childhood_subtotal" ~ '(chrpas_pmod_child1+chrpas_pmod_child2+chrpas_pmod_child3+chrpas_pmod_child4)/24',
variable == "chrpas_early_adolescence_subtotal" ~ '(chrpas_pmod_adol_early1+chrpas_pmod_adol_early2+chrpas_pmod_adol_early3+chrpas_pmod_adol_early4+chrpas_pmod_adol_early5)/30',
variable == "chrpas_late_adolescence_subtotal" ~ '(chrpas_pmod_adol_late1+chrpas_pmod_adol_late2+chrpas_pmod_adol_late3+chrpas_pmod_adol_late4+chrpas_pmod_adol_late5)/30',
variable == "chrpas_adulthood_subtotal" ~ '(chrpas_pmod_adult1+chrpas_pmod_adult2+(chrpas_pmod_adult3v1 or + chrpas_pmod_adult3v3))/18',
variable == "chrpas_total_score_only_childhood" ~ 'Childhood subtotal',
variable == "chrpas_total_score_upto_early_adolescence" ~ '(Childhood subtotal +Early Adolescence subtotal)/2',
variable == "chrpas_total_score_upto_late_adolescence" ~ '(Childhood subtotal +Early Adolescence subtotal+Late Adolescence subtotal)/3',
variable == "chrpas_total_score_upto_adulthood" ~ '(Childhood subtotal +Early Adolescence subtotal+Late Adolescence subtotal+Adulthood subtotal)/4',
variable == "chrcssrs_intensity_lifetime" ~ 'chrcssrsb_sidfrql + chrcssrsb_siddurl + chrcssrsb_sidctrl + chrcssrs_siddtrl + chrcssrsb_sidrsnl',
variable == "chrcssrs_intensity_pastmonth" ~ 'chrcssrsb_css_sipmfreq + chrcssrsb_css_sipmdur + chrcssrsb_css_sipmctrl + chrcssrsb_css_sipmdet + chrcssrsb_css_sipmreas',
variable == "chrpred_transition" ~ 'Redcap variable',
variable == "chrpred_experience" ~ 'Redcap variable',
variable == "chrpgi_2" ~ 'Redcap variable',
variable == "chrpromis_total" ~ 'chrpromis_sleep109+chrpromis_sleep116+(6-chrpromis_sleep20)+(6-chrpromis_sleep44)+(6-chrpromise_sleep108)+(6-chrpromis_sleep72)+(6-chrpromis_sleep67)+chrpromis_sleep115',
variable == "chrgfrs_decline_in_global_role_functioning" ~ 'chrgfr_gf_role_high-chrgfr_gf_role_scole',
variable == "chrgfss_decline_in_global_social_functioning" ~ 'chrgfs_gf_social_high-chrgfs_gf_social_scale ',
variable == "chrnsipr_motivation_and_pleasure_dimension" ~ '(chrnsipr_item1 + chrnsipr_item2 + chrnsipr_item3 + chrnsipr_item4 + chrnsipr_item5 + chrnsipr_item6 + chrnsipr_item7)/7',
variable == "chrnsipr_diminished_expression_dimension" ~ '(chrnsipr_item8 + chrnsipr_item9 + chrnsipr_item10 + chrnsipr_item11)/4',
variable == "chrnsipr_avolition_domain" ~ '(chrnsipr_item1 + chrnsipr_item2)/2',
variable == "chrnsipr_asociality_domain" ~ '(chrnsipr_item3 + chrnsipr_item4 + chrnsipr_item5)/3',
variable == "chrnsipr_anhedonia_domain" ~ '(chrnsipr_item6 + chrnsipr_item7)/2',
variable == "chrnsipr_blunted_affect_domain" ~ '(chrnsipr_item8 + chrnsipr_item9 + chrnsipr_item10)/3',
variable == "chrnsipr_item11_rating" ~ 'Redcap variable',
variable == "chrsofas_premorbid" ~ 'Redcap variable',
variable == "chrsofas_currscore12mo" ~ 'Redcap variable',
variable == "chrsofas_currscore" ~ 'Redcap variable',
variable == "chrsofas_lowscore" ~ 'Redcap variable',
variable == "chrsofas_currscore_fu" ~ 'Redcap variable',
variable == "chrsofas_currscore12mo_fu" ~ 'Redcap variable',
variable == "chrpds_total_score_female_sex" ~ 'if female: chrpds_pds_1_p + chrpds_pds_2_p + chrpds_pds_3_p + chrpds_pds_f4_p + chrpds_pds_f5b_p, if male: -300',
variable == "chrpds_total_score_male_sex" ~ 'if female: -300 if male: chrpds_pds_1_p + chrpds_pds_2_p + chrpds_pds_3_p + chrpds_pds_m4_p + chrpds_pds_m5_p',
variable == "chrpds_pds_f5b_p" ~ 'Redcap variable',
variable == "chrbprs_bprs_total" ~ 'Redcap variable',
variable == "chrbprs_affect_subscale" ~ 'chrbprs_bprs_depr+chrbprs_bprs_suic+chrbprs_depr_guil',
variable == "chrbprs_positive_symptom_subscale" ~ 'chrbprs_bprs_unus+chrbprs_bprs_hall+chrbprs_bprs_susp',
variable == "chrbprs_negative_symptom_subscale" ~ 'chrbprs_bprs_blun+chrbprs_bprs_motr+chrbprs_bprs_emot',
variable == "chrbprs_activation_subscale" ~ 'chrbprs_bprs_exci+chrbprs_bprs_mohy+chrbprs_bprs_elat ',
variable == "chrbprs_disorganization_subscale" ~ 'chrbprs_bprs_diso+chrbprs_bprs_conc+chrbprs_bprs_self',
variable == "chroasis_total" ~ 'chroasis_oasis_1+chroasis_oasis_2+chroasis_oasis_3+chroasis_oasis_4+chroasis_oasis_5',
variable == "chrpds_perceived_discrimination_total" ~ 'chrdim_dim_yesno_q1_1+chrdim_dim_yesno_q1_2+chrdlm_dim_sex+chrdlm_dim_yesno_age+chrdlm_dim_yesno_q4_1+chrdlm_dim_yesno_q5+chrdlm_dim_yesno_q3+chrdlm_dim_yesno_q6+chrdlm_dim_yesno_other',
variable == "chrcdss_total" ~ 'chrcdss_calg1 + chrcdss_calg2+chrcdss_calg3+chrcdss_calg4+chrcdss_calg5+chrcdss_calg6+chrcdss_calg7+chrcdss_calg8+chrcdss_calg9',
variable == "chrpss_perceived_stress_scale_total" ~ 'chrpss_pssp1_1+chrpss_pssp1_2+chrpss_pssp1_3+(4-chrpss_pssp2_1)+(4-chrpss_pssp2_2)+chrpss_pssp2_3+(4-chrpss_pssp2_4)+(4-chrpss_pssp2_5)+chrpss_pssp3_1+chrpss_pssp3_4'))%>%
mutate(Notes = case_when(is.na(Notes) ~ 'Redcap variable',
TRUE ~ Notes))%>%
mutate(original_calculation_adapted_np_or_comment =
case_when(variable == "psychs_pos_tot" ~ '',
variable == "psychs_sips_p1" ~ '',
variable == "psychs_sips_p2" ~ '',
variable == "psychs_sips_p3" ~ '',
variable == "psychs_sips_p4" ~ '',
variable == "psychs_sips_p5" ~ '',
variable == "sips_pos_tot" ~ '',
variable == "psychs_caarms_p1" ~ '',
variable == "psychs_caarms_p2" ~ '',
variable == "psychs_caarms_p3" ~ '',
variable == "psychs_caarms_p4" ~ '',
variable == "caarms_pos_tot" ~ '',
variable == "psychosis_onset_date" ~ '',
variable == "psychosis" ~ '',
variable == "dsm_schizotypal_lifetime" ~ '',
variable == "first_degree_relative" ~ '',
variable == "sips_grd_lifetime" ~ '',
variable == "caarms_vulnerability_pastyear" ~ '',
variable == "drop30_sofas_pastmonth" ~ '',
variable == "sips_grd_progression_pastmonth" ~ '',
variable == "sofas_curr_premorbid_less90" ~ '',
variable == "sips_grd_persistence_pastmonth" ~ '',
variable == "sips_grd_partial_remission_pastmonth" ~ '',
variable == "sips_grd_full_remission_pastmonth" ~ '',
variable == "caarms_blips" ~ '',
variable == "caarms_aps_subthreshold_frequency" ~ '',
variable == "caarms_aps_subthreshold_intensity" ~ '',
variable == "caarms_aps" ~ '',
variable == "caarms_vulnerability" ~ '',
variable == "caarms_uhr" ~ '',
variable == "sips_bips_progression" ~ '',
variable == "sips_bips_persistence" ~ '',
variable == "sips_bips_partial_remission" ~ '',
variable == "sips_bips_full_remission" ~ '',
variable == "sips_apss_progression" ~ '',
variable == "sips_apss_persistence" ~ '',
variable == "sips_apss_partial_remission" ~ '',
variable == "sips_apss_full_remission" ~ '',
variable == "sips_grd_progression" ~ '',
variable == "sips_grd_persistence" ~ '',
variable == "sips_grd_partial_remission" ~ '',
variable == "sips_grd_full_remission" ~ '',
variable == "sips_chr_progression" ~ '',
variable == "sips_chr_persistence" ~ '',
variable == "sips_chr_partial_remission" ~ '',
variable == "sips_chr_full_remission" ~ '',
variable == "sips_current_status" ~ '',
variable == "dsm5_attenuated_psychosis" ~ '',
variable == "conversion_date" ~ '',
variable == "psychosis_current" ~ '',
variable == "psychosis_previous" ~ '',
variable == "psychosis_first" ~ '',
variable == "psychosis_conversion" ~ '',
variable == "sofas_premorbid" ~ '',
variable == "sofas_oneyearago" ~ '',
variable == "sofas_pasyear" ~ '',
variable == "sofas_pasyear" ~ '',
variable == "sofas_pastmonth" ~ '',
variable == "drop30_sofas_sincelastvisit" ~ '',
variable == "sips_grd_new" ~ '',
variable == "sips_grd_remain" ~ '',
variable == "chrpps_sum1" ~ '',
variable == "chrpps_sum2" ~ '',
variable == "chrpps_sum7" ~ '',
variable == "chrpps_sum8" ~ '',
variable == "chrpps_sum9" ~ '',
variable == "chrpps_sum10" ~ 'event number 15 is None of the above. Therefore, if subject fulfills only event number 15 still -2',
variable == "chrpps_sum11" ~ '',
variable == "chrpps_sum12" ~ '',
variable == "chrpps_sum13" ~ '',
variable == "chrpps_sum14" ~ 'here, the code has to be the other way around. If the score is below 36 (<36) there is a higher risk (=6.5) and if the score is higher than 35 (>35) there is a lower risk (=0) ',
variable == "chrassist_tobacco" ~ 'Additionally, to the sum we consider whether individual ever consumed the substance. If not this score is 0',
variable == "chrassist_alcohol" ~ 'Additionally, to the sum we consider whether individual ever consumed the substance. If not this score is 0',
variable == "chrassist_cannabis" ~ 'Additionally, to the sum we consider whether individual ever consumed the substance. If not this score is 0',
variable == "chrassist_cocaine" ~ 'Additionally, to the sum we consider whether individual ever consumed the substance. If not this score is 0',
variable == "chrassist_amphetamines" ~ 'Additionally, to the sum we consider whether individual ever consumed the substance. If not this score is 0',
variable == "chrassist_inhalants" ~ 'Additionally, to the sum we consider whether individual ever consumed the substance. If not this score is 0',
variable == "chrassist_sedatives" ~ 'Additionally, to the sum we consider whether individual ever consumed the substance. If not this score is 0',
variable == "chrassist_hallucinogens" ~ 'Additionally, to the sum we consider whether individual ever consumed the substance. If not this score is 0',
variable == "chrassist_opiods" ~ 'Additionally, to the sum we consider whether individual ever consumed the substance. If not this score is 0',
variable == "chrassist_other" ~ 'Additionally, to the sum we consider whether individual ever consumed the substance. If not this score is 0',
variable == "chrpas_childhood_subtotal" ~ '',
variable == "chrpas_early_adolescence_subtotal" ~ '',
variable == "chrpas_late_adolescence_subtotal" ~ '',
variable == "chrpas_adulthood_subtotal" ~ '',
variable == "chrpas_total_score_only_childhood" ~ '',
variable == "chrpas_total_score_upto_early_adolescence" ~ '',
variable == "chrpas_total_score_upto_late_adolescence" ~ '',
variable == "chrpas_total_score_upto_adulthood" ~ '',
variable == "chrcssrs_intensity_lifetime" ~ 'Before the sum score calculation: if someone never had suicidal thoughts in a lifetime (chrcssrsb_si1l and chrcssrsb_si2l == 0), cssrs intensity for lifetime and past month should be zero.',
variable == "chrcssrs_intensity_pastmonth" ~ 'Before the sum score calculation: if someone never had suicidal thoughts in a lifetime (chrcssrsb_si1l and chrcssrsb_si2l == 0) or in the past month (chrcssrsb_css_sim1 and chrcssrsb_css_sim1 == 0), cssrs intensity for lifetime and past month should be zero.',
variable == "chrpred_transition" ~ '',
variable == "chrpred_experience" ~ '',
variable == "chrpgi_2" ~ '',
variable == "chrpromis_total" ~ '',
variable == "chrgfrs_decline_in_global_role_functioning" ~ '',
variable == "chrgfss_decline_in_global_social_functioning" ~ '',
variable == "chrnsipr_motivation_and_pleasure_dimension" ~ '',
variable == "chrnsipr_diminished_expression_dimension" ~ '',
variable == "chrnsipr_avolition_domain" ~ '',
variable == "chrnsipr_asociality_domain" ~ '',
variable == "chrnsipr_anhedonia_domain" ~ '',
variable == "chrnsipr_blunted_affect_domain" ~ '',
variable == "chrnsipr_item11_rating" ~ '',
variable == "chrsofas_premorbid" ~ '',
variable == "chrsofas_currscore12mo" ~ '',
variable == "chrsofas_currscore" ~ '',
variable == "chrsofas_lowscore" ~ '',
variable == "chrsofas_currscore_fu" ~ '',
variable == "chrsofas_currscore12mo_fu" ~ '',
variable == "chrpds_total_score_sex" ~ 'Other than in the outcome calculation we have only one score instead of female/male. Depending on which sex the individual was assigned at birth. We then calculate the score based on the originally provided calculations.',
variable == "chrpds_pds_f5b_p" ~ '',
variable == "chrbprs_bprs_total" ~ '',
variable == "chrbprs_affect_subscale" ~ '',
variable == "chrbprs_positive_symptom_subscale" ~ '',
variable == "chrbprs_negative_symptom_subscale" ~ '',
variable == "chrbprs_activation_subscale" ~ '',
variable == "chrbprs_disorganization_subscale" ~ '',
variable == "chroasis_total" ~ '',
variable == "chrpds_perceived_discrimination_total" ~ '',
variable == "chrcdss_total" ~ '',
variable == "chrpss_perceived_stress_scale_total" ~ '4 of the scores have to be reversed: (4-xxx) [chrpss_pssp2_1, chrpss_pssp2_2, chrpss_pssp2_4, chrpss_pssp2_5]'))%>%
mutate(Expert_Name = 'Expert: ',
Calculation = ', Calculation: ',
#Calculation = 'Calculation: ',
Adaptation = ', adapted by AMP-SCZ staff: ')%>%
mutate(distinct_values_new = case_when(
variable == 'psychosis_onset_date'|variable == 'conversion_date' ~
'',
TRUE ~ ';-900;-300'))%>%
mutate(value_range = case_when( variable == "psychs_pos_tot" ~ '0::90',
variable == "psychs_sips_p1" ~ '0::6',
variable == "psychs_sips_p2" ~ '0::6',
variable == "psychs_sips_p3" ~ '0::6',
variable == "psychs_sips_p4" ~ '0::6',
variable == "psychs_sips_p5" ~ '0::6',
variable == "sips_pos_tot" ~ '0::30',
variable == "psychs_caarms_p1" ~ '0::36',
variable == "psychs_caarms_p2" ~ '0::36',
variable == "psychs_caarms_p3" ~ '0::36',
variable == "psychs_caarms_p4" ~ '0::36',
variable == "caarms_pos_tot" ~ '0::144',
variable == "psychosis_onset_date" ~ '',
variable == "chrpsychs_scr_ac1" ~ '0;1',
variable == "chrpsychs_scr_ac2" ~ '0;1',
variable == "chrpsychs_scr_ac3" ~ '0;1',
variable == "chrpsychs_scr_ac4" ~ '0;1',
variable == "chrpsychs_scr_ac5" ~ '0;1',
variable == "chrpsychs_scr_ac6" ~ '0;1',
variable == "chrpsychs_scr_ac7" ~ '0;1',
variable == "chrpsychs_scr_ac9" ~ '0;1',
variable == "chrpsychs_scr_ac10" ~ '0;1',
variable == "chrpsychs_scr_ac11" ~ '0;1',
variable == "chrpsychs_scr_ac12" ~ '0;1',
variable == "chrpsychs_scr_ac15" ~ '0;1',
variable == "chrpsychs_scr_ac16" ~ '0;1',
variable == "chrpsychs_scr_ac17" ~ '0;1',
variable == "chrpsychs_scr_ac18" ~ '0;1',
variable == "chrpsychs_scr_ac21" ~ '0;1',
variable == "chrpsychs_scr_ac22" ~ '0;1',
variable == "chrpsychs_scr_ac23" ~ '0;1',
variable == "chrpsychs_scr_ac24" ~ '0;1',
variable == "chrpsychs_scr_ac27" ~ '0;1',
variable == "chrpsychs_scr_ac28" ~ '0;1',
variable == "chrpsychs_scr_ac29" ~ '0;1',
variable == "chrpsychs_scr_ac30" ~ '0;1',
variable == "chrpsychs_scr_ac31" ~ '1::5',
variable == "chrpsychs_scr_ac32" ~ '0;1',
variable == "conversion_date" ~ '',
variable == "hcpsychs_fu_ac1" ~ '0;1',
variable == "hcpsychs_fu_ac1_curr" ~ '0;1',
variable == "hcpsychs_fu_ac1_prev" ~ '0;1',
variable == "hcpsychs_fu_ac1_first" ~ '0;1',
variable == "hcpsychs_fu_ac1_conv" ~ '0;1',
variable == "hcpsychs_fu_ac9" ~ '0;1',
variable == "hcpsychs_fu_ac10" ~ '0;1',
variable == "hcpsychs_fu_ac11" ~ '0;1',
variable == "hcpsychs_fu_ac12" ~ '0;1',
variable == "hcpsychs_fu_ac15" ~ '0;1',
variable == "hcpsychs_fu_ac16" ~ '0;1',
variable == "hcpsychs_fu_ac17" ~ '0;1',
variable == "hcpsychs_fu_ac18" ~ '0;1',
variable == "hcpsychs_fu_ac21" ~ '0;1',
variable == "hcpsychs_fu_ac22" ~ '0;1',
variable == "hcpsychs_fu_ac23" ~ '0;1',
variable == "hcpsychs_fu_ac24" ~ '0;1',
variable == "hcpsychs_fu_ac27" ~ '0;1',
variable == "hcpsychs_fu_ac28" ~ '0;1',
variable == "hcpsychs_fu_ac29" ~ '0;1',
variable == "hcpsychs_fu_ac30" ~ '0;1',
variable == "hcpsychs_fu_ac31" ~ '1::5',
variable == "hcpsychs_fu_ac32" ~ '0;1',
variable == "chrpsychs_fu_ac1" ~'0;1',
variable == "chrpsychs_fu_ac1_curr" ~'0;1',
variable == "chrpsychs_fu_ac1_prev" ~'0;1',
variable == "chrpsychs_fu_ac1_first" ~'0;1',
variable == "chrpsychs_fu_ac1_conv" ~'0;1',
variable == "chrpsychs_fu_ac9" ~'0;1',
variable == "chrpsychs_fu_ac10" ~'0;1',
variable == "chrpsychs_fu_ac11" ~'0;1',
variable == "chrpsychs_fu_ac12" ~'0;1',
variable == "chrpsychs_fu_ac15" ~'0;1',
variable == "chrpsychs_fu_ac16" ~'0;1',
variable == "chrpsychs_fu_ac17" ~'0;1',
variable == "chrpsychs_fu_ac18" ~'0;1',
variable == "chrpsychs_fu_ac21" ~'0;1',
variable == "chrpsychs_fu_ac22" ~'0;1',
variable == "chrpsychs_fu_ac23" ~'0;1',
variable == "chrpsychs_fu_ac24" ~'0;1',
variable == "chrpsychs_fu_ac27" ~'0;1',
variable == "chrpsychs_fu_ac28" ~'0;1',
variable == "chrpsychs_fu_ac29" ~'0;1',
variable == "chrpsychs_fu_ac30" ~'0;1',
variable == "chrpsychs_fu_ac31" ~'1::5',
variable == "chrpsychs_fu_ac32" ~'0;1',
variable == "psychosis_current" ~ '0;1',
variable == "psychosis_previous" ~ '0;1',
variable == "psychosis_first" ~ '0;1',
variable == "psychosis_conversion" ~ '0;1',
variable == "chrpps_sum1" ~ '0;2',
variable == "chrpps_sum2" ~ '0;2',
variable == "chrpps_sum7" ~ '0;5',
variable == "chrpps_sum8" ~ '0;1',
variable == "chrpps_sum9" ~ '0;5.5',
variable == "chrpps_sum10" ~ '0;5.5',
variable == "chrpps_sum11" ~ '0;5',
variable == "chrpps_sum12" ~ '0;7',
variable == "chrpps_sum13" ~ '0;5',
variable == "chrpps_sum14" ~ '0;6.5',
variable == "chrassist_tobacco" ~ '0::39',
variable == "chrassist_alcohol" ~ '0::39',
variable == "chrassist_cannabis" ~ '0::39',
variable == "chrassist_cocaine" ~ '0::39',
variable == "chrassist_amphetamines" ~ '0::39',
variable == "chrassist_inhalants" ~ '0::39',
variable == "chrassist_sedatives" ~ '0::39',
variable == "chrassist_hallucinogens" ~ '0::39',
variable == "chrassist_opiods" ~ '0::39',
variable == "chrassist_other" ~ '0::39',
variable == "chrpas_childhood_subtotal" ~ '0::24',
variable == "chrpas_early_adolescence_subtotal" ~ '0::30',
variable == "chrpas_late_adolescence_subtotal" ~ '0::30',
variable == "chrpas_adulthood_subtotal" ~ '0::18',
variable == "chrpas_total_score_only_childhood" ~ '0::24',
variable == "chrpas_total_score_upto_early_adolescence" ~ '0::27',
variable == "chrpas_total_score_upto_late_adolescence" ~ '0::28',
variable == "chrpas_total_score_upto_adulthood" ~ '0::26',
variable == "chrcssrs_intensity_lifetime" ~ '0::25',
variable == "chrcssrs_intensity_pastmonth" ~ '0::25',
variable == "chrpred_transition" ~ '0;1',
variable == "chrpred_experience" ~ '1::240',
variable == "chrpgi_2" ~ '1::5',
variable == "chrpromis_total" ~ '7::35',
variable == "chrgfrs_decline_in_global_role_functioning" ~ '0::10',
variable == "chrgfss_decline_in_global_social_functioning" ~ '0::10',
variable == "chrnsipr_motivation_and_pleasure_dimension" ~ '0::5',
variable == "chrnsipr_diminished_expression_dimension" ~ '0::5',
variable == "chrnsipr_avolition_domain" ~ '0::5',
variable == "chrnsipr_asociality_domain" ~ '0::5',
variable == "chrnsipr_anhedonia_domain" ~ '0::5',
variable == "chrnsipr_blunted_affect_domain" ~ '0::5',
variable == "chrnsipr_item11_rating" ~ '0::5',
variable == "chrsofas_premorbid" ~ '0::100',
variable == "chrsofas_currscore12mo" ~ '0::100',
variable == "chrsofas_currscore" ~ '0::100',
variable == "chrsofas_lowscore" ~ '0::100',
variable == "chrsofas_currscore_fu" ~ '0::100',
variable == "chrsofas_currscore12mo_fu" ~ '0::100',
variable == "chrpds_total_score_female_sex" ~ '5::20',
variable == "chrpds_total_score_male_sex" ~ '5::20',
variable == "chrpds_pds_f5b_p" ~ '1;4',
variable == "chrbprs_bprs_total" ~ '24::168',
variable == "chrbprs_affect_subscale" ~ '3::21',
variable == "chrbprs_positive_symptom_subscale" ~ '3::21',
variable == "chrbprs_negative_symptom_subscale" ~ '3::21',
variable == "chrbprs_activation_subscale" ~ '3::21',
variable == "chrbprs_disorganization_subscale" ~ '3::21',
variable == "chroasis_total" ~ '0::20',
variable == "chrpds_perceived_discrimination_total" ~ '0::9',
variable == "chrcdss_total" ~ '0::27',
variable == "chrpss_perceived_stress_scale_total" ~ '0::40'))%>%
mutate_all(~ case_when(is.na(.) ~ "", TRUE ~ .))%>%
mutate(Notes_for_Calc = Notes)%>%
unite('Notes', c(Expert_Name, Experts, Calculation, Notes, Adaptation, original_calculation_adapted_np_or_comment), sep = '')%>%
#unite('Notes', c(Calculation, Notes), sep = '')%>%
unite('VALUE_RANGE', c(value_range, distinct_values_new), sep = '')%>%
dplyr::select(variable, VALUE_RANGE, min_value, max_value, data_type, description, Notes, csv_names, distinct_values, diverging_expert_variable_name, Notes_for_Calc)%>%
dplyr::rename(ELEMENT_NAME = variable ,
DATA_TYPE = data_type,
DESCRIPTION = description,
NOTES = Notes,
ALIASES = diverging_expert_variable_name)%>%
dplyr::select(ELEMENT_NAME, DATA_TYPE, DESCRIPTION, VALUE_RANGE, NOTES, csv_names, ALIASES, Notes_for_Calc)%>%
mutate(real_calculation = case_when(ELEMENT_NAME == 'chrpps_sum10' ~ 'chrpps_sum10=5.5 if (chrpps_sixmo___1 == 1 or chrpps_sixmo___2 == 1 or chrpps_sixmo___3 == 1 or chrpps_sixmo___4 == 1 or chrpps_sixmo___5 == 1 or chrpps_sixmo___6 == 1 or chrpps_sixmo___7 == 1 or chrpps_sixmo___8 == 1 or chrpps_sixmo___9 == 1 or chrpps_sixmo___10 == 1 or chrpps_sixmo___11 == 1 or chrpps_sixmo___12 == 1 or chrpps_sixmo___13 == 1 or chrpps_sixmo___14 == 1) elif chrpps_sum10 = -2 (chrpps_sixmo___1 == 0 and chrpps_sixmo___2 == 0 and chrpps_sixmo___3 == 0 and chrpps_sixmo___4 == 0 and chrpps_sixmo___5 == 0 and chrpps_sixmo___6 == 0 and chrpps_sixmo___7 == 0 and chrpps_sixmo___8 == 0 and chrpps_sixmo___9 == 0 and chrpps_sixmo___10 == 0 and chrpps_sixmo___11 == 0 and chrpps_sixmo___12 == 0 and chrpps_sixmo___13 == 0 and chrpps_sixmo___14 == 0 and chrpps_sixmo___15 ==1)',
ELEMENT_NAME == "chrpps_sum14" ~ 'chrpps_sum14=0 if sum(chrpps_excite, chrpps_taste,(7-chrpps_restaur),chrpps_roller, chrpps_holiday, chrpps_tasty, chrpps_pleasure, chrpps_lookfwd, chrpps_menu, chrpps_actor, chrpps_crackle, chrpps_rain, chrpps_grass, chrpps_air, chrpps_coffee, chrpps_hair, chrpps_yawn, chrpps_snow) >35 else chrpps_sum14=6.5',
ELEMENT_NAME == "chrassist_tobacco" ~ 'chrassist_tobacco = 0 if chrassist_whoassist_use1 == 0, else chrassist_whoassist_often1 + chrassist_whoassist_urge1 + chrassist_whoassist_prob1 + chrassist_whoassist_fail1 + chrassist_whoassist_concern1 + chrassist_whoassist_control1',
ELEMENT_NAME == "chrassist_alcohol" ~ 'chrassist_alcohol = 0 if chrassist_whoassist_use2 == 0, else chrassist_whoassist_often2 + chrassist_whoassist_urge2 + chrassist_whoassist_prob2 + chrassist_whoassist_fail2 + chrassist_whoassist_concern2 + chrassist_whoassist_control2',
ELEMENT_NAME == "chrassist_cannabis" ~ 'chrassist_cannabis = 0 if chrassist_whoassist_use3 == 0, else chrassist_whoassist_often3 + chrassist_whoassist_urge3 + chrassist_whoassist_prob3 + chrassist_whoassist_fail3 + chrassist_whoassist_concern3 + chrassist_whoassist_control3',
ELEMENT_NAME == "chrassist_cocaine" ~ 'chrassist_cocaine = 0 if chrassist_whoassist_use4 == 0, else chrassist_whoassist_often4 + chrassist_whoassist_urge4 + chrassist_whoassist_prob4 + chrassist_whoassist_fail4 + chrassist_whoassist_concern4 + chrassist_whoassist_control4',
ELEMENT_NAME == "chrassist_amphetamines" ~ 'chrassist_amphetamines = 0 if chrassist_whoassist_use5 == 0, else chrassist_whoassist_often5 + chrassist_whoassist_urge5 + chrassist_whoassist_prob5 + chrassist_whoassist_fail5 + chrassist_whoassist_concern5 + chrassist_whoassist_control5',
ELEMENT_NAME == "chrassist_inhalants" ~ 'chrassist_inhalants = 0 if chrassist_whoassist_use6 == 0, else chrassist_whoassist_often6 + chrassist_whoassist_urge6 + chrassist_whoassist_prob6 + chrassist_whoassist_fail6 + chrassist_whoassist_concern6 + chrassist_whoassist_control6',
ELEMENT_NAME == "chrassist_sedatives" ~ 'chrassist_sedatives = 0 if chrassist_whoassist_use7 == 0, else chrassist_whoassist_often7 + chrassist_whoassist_urge7 + chrassist_whoassist_prob7 + chrassist_whoassist_fail7 + chrassist_whoassist_concern7 + chrassist_whoassist_control7',
ELEMENT_NAME == "chrassist_hallucinogens" ~ 'chrassist_hallucinogens = 0 if chrassist_whoassist_use8 == 0, else chrassist_whoassist_often8 + chrassist_whoassist_urge8 + chrassist_whoassist_prob8 + chrassist_whoassist_fail8 + chrassist_whoassist_concern8 + chrassist_whoassist_control8',
ELEMENT_NAME == "chrassist_opiods" ~ 'chrassist_opiods = 0 if chrassist_whoassist_use9 == 0, else chrassist_whoassist_often9 + chrassist_whoassist_urge9 + chrassist_whoassist_prob9 + chrassist_whoassist_fail9 + chrassist_whoassist_concern9 + chrassist_whoassist_control9',
ELEMENT_NAME == "chrassist_other" ~ 'chrassist_other = 0 if chrassist_whoassist_use10 == 0, else chrassist_whoassist_often10 + chrassist_whoassist_urge10 + chrassist_whoassist_prob10 + chrassist_whoassist_fail10 + chrassist_whoassist_concern10 + chrassist_whoassist_control10',
ELEMENT_NAME == "chrcssrs_intensity_lifetime" ~ 'chrcssrs_intensity_lifetime = -300 if (chrcssrsb_si1l and chrcssrsb_si2l == 0) else chrcssrsb_sidfrql + chrcssrsb_siddurl + chrcssrsb_sidctrl + chrcssrs_siddtrl + chrcssrsb_sidrsnl',
ELEMENT_NAME == "chrcssrs_intensity_pastmonth" ~ 'chrcssrs_intensity_pastmonth = -300 if (chrcssrsb_si1l and chrcssrsb_si2l) or (chrcssrsb_css_sim1 and chrcssrsb_css_sim1 == 0) else chrcssrsb_css_sipmfreq + chrcssrsb_css_sipmdur + chrcssrsb_css_sipmctrl + chrcssrsb_css_sipmdet + chrcssrsb_css_sipmreas',
ELEMENT_NAME == "chrpss_perceived_stress_scale_total" ~ 'chrpss_pssp1_1+chrpss_pssp1_2+chrpss_pssp1_3+(4-chrpss_pssp2_1)+(4-chrpss_pssp2_2)+chrpss_pssp2_3+(4-chrpss_pssp2_4)+(4-chrpss_pssp2_5)+chrpss_pssp3_1+chrpss_pssp3_4',
TRUE ~ Notes_for_Calc))%>%
dplyr::select(-NOTES)%>%
rename(NOTES = real_calculation)%>%
dplyr::select(ELEMENT_NAME, DATA_TYPE, DESCRIPTION, VALUE_RANGE, NOTES, csv_names, ALIASES)
write.csv(variables_outcome, 'C:/Users/Nora/Documents/Harvard/U24/outcome_calculations/dictionary_outcomes_new.csv', row.names = FALSE)
#write.csv(variables_outcome, 'C:/Users/Nora/Documents/Harvard/U24/outcome_calculations/dictionary_outcomes.csv', row.names = FALSE)