Skip to content

Commit 8d8d0b9

Browse files
authored
Add files via upload
1 parent 8633281 commit 8d8d0b9

File tree

2 files changed

+189
-85
lines changed

2 files changed

+189
-85
lines changed

bcrs.pl

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/usr/bin/perl
2+
3+
use strict;
4+
use warnings;
5+
6+
sub calculate_bcrs_total_score {
7+
my @bcrs_items = (
8+
'1. Axis-I: Concentration',
9+
'2. Axis-II: Recent memory',
10+
'3. Axis-III: Past memory',
11+
'4. Axis-IV: Orientation',
12+
'5. Axis-V: Functioning and self-care'
13+
# Add more items as needed
14+
);
15+
16+
my %bcrs_scores;
17+
18+
# Get user input for each BCRS item
19+
foreach my $item (@bcrs_items) {
20+
my $valid_input = 0;
21+
22+
while (!$valid_input) {
23+
print "Enter score for $item (1-7): ";
24+
my $score = <STDIN>;
25+
chomp($score);
26+
27+
# Validate input
28+
if ($score =~ /^\d+$/ && $score >= 1 && $score <= 7) {
29+
@bcrs_scores{$item} = $score;
30+
$valid_input = 1;
31+
} else {
32+
print "Invalid input. Please, enter a number between 1 and 7.\n";
33+
}
34+
}
35+
}
36+
# Add order to the hash
37+
my @ordered_hash = qw(
38+
1. Axis-I: Concentration 2. Axis-II: Recent memory 3. Axis-III: Past memory 4. Axis-IV: Orientation 5. Axis-V: Functioning and self-care);
39+
40+
41+
42+
# Calculate total BCRS score
43+
my $total_score = 0;
44+
foreach my $item_score (sort values %bcrs_scores) {
45+
$total_score += $item_score;
46+
}
47+
48+
# return @ordered_hash, total_score => $total_score;
49+
return %bcrs_scores, total_score => $total_score;
50+
}
51+
52+
sub save_result_to_file {
53+
my %scores = @_;
54+
# added sort
55+
print "Enter the filename to save the result: ";
56+
my $filename = <STDIN>;
57+
chomp($filename);
58+
59+
open my $fh, '>', $filename or die "Cannot open file '$filename' for writing: $!";
60+
61+
print $fh "BCRS item scores:\n";
62+
foreach my $item (sort keys %scores) {
63+
# foreach instead of for
64+
print $fh "$item: $scores{$item}\n";
65+
}
66+
print $fh "\nTotal BCRS Score: $scores{total_score}\n";
67+
68+
close $fh;
69+
70+
print "Result saved to $filename\n";
71+
}
72+
73+
# Main program
74+
print " \n";
75+
print "Brief Cognitive Rating Scale (BCRS) Total Score Calculator\n";
76+
print "===========================================================\n";
77+
78+
my @bcrs_scores = calculate_bcrs_total_score();
79+
80+
# Print the total score
81+
print "\nBCRS item scores:\n";
82+
for my $item (sort @bcrs_scores) {
83+
# added sort command
84+
print "$item: %bcrs_scores{$item}\n";
85+
}
86+
print "\nTotal BCRS score: %bcrs_scores{total_score}/35\n";
87+
88+
# Ask user if they want to save the result
89+
while(1) {
90+
print "Do you want to save the result to a file? (yes/no): ";
91+
my $save_option = lc(<STDIN>);
92+
chomp($save_option);
93+
94+
if ($save_option eq 'yes') {
95+
save_result_to_file(@bcrs_scores) && exit print "saved\n"
96+
}
97+
elsif ($save_option eq 'no') {exit print "not saved\n"
98+
99+
}
100+
else
101+
{ print "invalid option, please, type yes or no\n"
102+
}
103+
}

cbi.pl

+86-85
Original file line numberDiff line numberDiff line change
@@ -6,94 +6,95 @@
66
# CBI score items, subroutine (pronoun they/their/them added in square brackets)
77
sub calculate_cbi_total_score {
88
my @cbi_items = (
9-
'Memory: 1. Forgets to pass on phone messages',
10-
'Memory: 2. Has poor day-to-day memory (e.g. about conversations, trips etc.)',
11-
'Memory: 3. Asks the same question over and over again',
12-
'Memory: 4. Loses or misplaces things',
13-
'Memory: 5. Forgets the names of familiar people',
14-
'Memory: 6. Forgets the names of objects and things',
15-
'Orientation & attention: 7. Has difficulty completing activities once started',
16-
'Orientation & attention: 8. Shows poor concentration when reading or watching television',
17-
'Orientation & attention: 9. Forgets what day it is',
18-
'Orientation & attention: 10. Forgets what time of day it is',
19-
'Orientation & attention: 11. Gets the present mixed up with past situations',
20-
'Orientation & attention: 12. Becomes confused or muddled in unusual surroundings',
21-
'Orientation & attention: 13. Gets lost inside the house',
22-
'Everyday Skills: 14. Has difficulties using electrical appliances (e.g. TV, radio, cooker, washing machine)',
23-
'Everyday skills: 15. Has problems preparing meals',
24-
'Everyday skills: 16. Has difficulties writing (letters, Christmas cards, lists etc.)',
25-
'Everyday skills: 17. Has difficulties using the telephone',
26-
'Everyday skills: 18. Has difficulties making a hot drink (e.g. tea/coffee)',
27-
'Everyday skills: 19. Has difficulties shopping',
28-
'Everyday skills: 20. Has problems handling money or paying bills',
29-
'Everyday skills: 21. Has difficulties with household chores',
30-
'Self care: 22. Has difficulties travelling to places by self (either by driving or on public transportation',
31-
'Self care: 23. Has difficulties grooming self (e.g. shaving or putting on make-up)',
32-
'Self care: 24. Has difficulties dressing self',
33-
'Self care: 25. Has problems feeding self without assistance',
34-
'Self care: 26. Has problems bathing or showering self',
35-
'Self care: 27. Has difficulties using toilet by self',
36-
'Self care: 28. Wets self with urine',
37-
'Mood: 29. Cries',
38-
'Mood: 30. Appears sad or depressed',
39-
'Mood: 31. Is anxious or fearful',
40-
'Mood: 32. Is very restless or agitated',
41-
'Mood: 33. Is very irritable',
42-
'Mood: 34. Has rapid shifts between different emotions',
43-
'Mood: 35. Appears inappropriately cheerful',
44-
'Mood: 36. Talks big e.g. claims more welath than true',
45-
'Mood: 37. Finds humour or laughs at things others do not find funny',
46-
'Beliefs: 38. Is suspicious or accusative',
47-
'Beliefs: 39. Sees things that are not really there (visual hallucinations)',
48-
'Beliefs: 40. Hears voices that are not really there (auditory hallucinations)',
49-
'Beliefs: 41. Has odd or bizarre ideas that cannot be true',
50-
'Beliefs: 42. Believs that additional people are living in the house',
51-
'Beliefs: 43 Thinks that a family member has been replaced by an impostor',
52-
'Beliefs: 44. Thinks that people on the TV are actually in the room',
53-
'Challenging behaviour: 45. Has temper outbursts',
54-
'Challenging behaviour: 46. Threatens to harm self/others or property',
55-
'Challenging behaviour: 47. Is uncooperative when asked to do something',
56-
'Challenging behaviour: 48. Disturbs others by shouting or yelling',
57-
'Disinhibition: 49. Shows socially embarassing behaviour',
58-
'Disinhibition: 50. Makes tactless or suggestive remarks',
59-
'Disnihibition: 51. Displays suggestive behaviour (e.g. touching inappropriately)',
60-
'Disinhibition: 52. Acts impulsively without thinking',
61-
'Disnihibition: 53. Talks to total strangers as if they know them',
62-
'Eating habits: 54. Prefers sweet foods more than before',
63-
'Eating habits: 55. Wants to eat the same foods repeatedly',
64-
'Eating habits: 56. Her/his appetite is greater, s/he/[they] eat[s] more than before',
65-
'Eating habits: 57. Table manners are declining eg stuffing food into mouth',
66-
'Eating Habits: 58. Eats non-edible foodstuffs or things not normally eaten',
67-
'Sleep: 59. Sleep is disturbed at night',
68-
'Sleep: 60. Sleeps more by day than before (cat naps etc.)',
69-
'Stereotypic & motor behaviours: 61. Is rigid in her/his/[their] ideas and opinions',
70-
'Stereotypic & motor behaviours: 62. Develops routines from which s/he/[they] cannot easily be discouraged eg wanting to eat or go for walks at fixed times',
71-
'Stereotypic & motor behaviours: 63. Exhibits rituals eg takes the same route across the kitchen, only steps on certain floor tiles',
72-
'Stereotypic & motor behaviours: 64. Clock watches or appears pre-occupied with time',
73-
'Sterotypic & motor behaviours: 65. Appears pre-occupied with counting, numbers, puzzles or jigsaws',
74-
'Stereotypic & motor behaviours: 66. Takes, hides or heards things, or packs away special items',
75-
'Stereotypic & motor behaviours: 67. Repeatedly uses the same expression or catch phrase',
76-
'Stereotypic & motor mehaviours: 68. S/he/[they] immediately repeat[s] words and sentences that you or others have just said (echolalia)',
77-
'Stereotypic & motor behaviours: 69. Paces around without purpose',
78-
'Stereotypic & motor behaviours: 70. Rummages around excessively',
79-
'Stereotypic & motor behaviours: 71. S/he/[they] fidget[s] (eg bounces, taps feet/hands) a lot',
80-
'Motivation: 72. Shows less enthusiasm for her/his/[their] usual interests',
81-
'Motivation: 73. Shows little interest in doing new things',
82-
'Motivation: 74. Requires nagging to start activities and chores',
83-
'Motivation: 75. Shows no interest in attending social functions',
84-
'Motivation: 76. Fails to maintain motivation to keep in contact with friends and family',
85-
'Motivation: 77. Withdraws from others, fails to start conversations',
86-
'Motivation: 78. Appears indifferent to the worries and concerns of family members',
87-
'Motivation: 79. Shows reduced affection',
88-
'Insight/Awareness: 80. Shows insight into changes in behaviour and personality (if appropriate)',
89-
'Insight/Awareness: 81. Shows insight into memory problems'
9+
'01. Memory: Forgets to pass on phone messages',
10+
'02. Memory: Has poor day-to-day memory (e.g. about conversations, trips etc.)',
11+
'03. Memory: Asks the same question over and over again',
12+
'04. Memory: Loses or misplaces things',
13+
'05. Memory: Forgets the names of familiar people',
14+
'06. Memory: Forgets the names of objects and things',
15+
'07. Orientation & attention: Has difficulty completing activities once started',
16+
'08. Orientation & attention:Shows poor concentration when reading or watching television',
17+
'09. Orientation & attention: Forgets what day it is',
18+
'10. Orientation & attention: Forgets what time of day it is',
19+
'11. Orientation & attention: Gets the present mixed up with past situations',
20+
'12. Orientation & attention: Becomes confused or muddled in unusual surroundings',
21+
'13. Orientation & attention: Gets lost inside the house',
22+
'14. Everyday Skills: Has difficulties using electrical appliances (e.g. TV, radio, cooker, washing machine)',
23+
'15. Everyday skills: Has problems preparing meals',
24+
'16. Everyday skills: Has difficulties writing (letters, Christmas cards, lists etc.)',
25+
'17. Everyday skills: Has difficulties using the telephone',
26+
'18. Everyday skills: Has difficulties making a hot drink (e.g. tea/coffee)',
27+
'19. Everyday skills: Has difficulties shopping',
28+
'20. Everyday skills: Has problems handling money or paying bills',
29+
'21. Everyday skills: Has difficulties with household chores',
30+
'22. Self care: Has difficulties travelling to places by self (either by driving or on public transportation',
31+
'23. Self care: Has difficulties grooming self (e.g. shaving or putting on make-up)',
32+
'24. Self care: Has difficulties dressing self',
33+
'25. Self care: Has problems feeding self without assistance',
34+
'26. Self care: Has problems bathing or showering self',
35+
'27. Self care: Has difficulties using toilet by self',
36+
'28. Self care: Wets self with urine',
37+
'29. Mood: Cries',
38+
'30. Mood: Appears sad or depressed',
39+
'31. Mood: Is anxious or fearful',
40+
'32. Mood: Is very restless or agitated',
41+
'33. Mood: Is very irritable',
42+
'34. Mood: Has rapid shifts between different emotions',
43+
'35. Mood: Appears inappropriately cheerful',
44+
'36. Mood: Talks big e.g. claims more welath than true',
45+
'37. Mood: Finds humour or laughs at things others do not find funny',
46+
'38. Beliefs: Is suspicious or accusative',
47+
'39. Beliefs: Sees things that are not really there (visual hallucinations)',
48+
'40. Beliefs: Hears voices that are not really there (auditory hallucinations)',
49+
'41. Beliefs: Has odd or bizarre ideas that cannot be true',
50+
'42. Beliefs: Believs that additional people are living in the house',
51+
'43. Beliefs: Thinks that a family member has been replaced by an impostor',
52+
'44. Beliefs: Thinks that people on the TV are actually in the room',
53+
'45. Challenging behaviour: Has temper outbursts',
54+
'46. Challenging behaviour: Threatens to harm self/others or property',
55+
'47. Challenging behaviour: Is uncooperative when asked to do something',
56+
'48. Challenging behaviour: 48. Disturbs others by shouting or yelling',
57+
'49. Disinhibition: Shows socially embarassing behaviour',
58+
'50. Disinhibition: Makes tactless or suggestive remarks',
59+
'51. Disnihibition: Displays suggestive behaviour (e.g. touching inappropriately)',
60+
'52. Disinhibition: Acts impulsively without thinking',
61+
'53. Disnihibition: Talks to total strangers as if they know them',
62+
'54. Eating habits: Prefers sweet foods more than before',
63+
'55. Eating habits: Wants to eat the same foods repeatedly',
64+
'56. Eating habits: Her/his appetite is greater, s/he/[they] eat[s] more than before',
65+
'57. Eating habits: Table manners are declining eg stuffing food into mouth',
66+
'58. Eating Habits: Eats non-edible foodstuffs or things not normally eaten',
67+
'59. Sleep: Sleep is disturbed at night',
68+
'60. Sleep: Sleeps more by day than before (cat naps etc.)',
69+
'61. Stereotypic & motor behaviours: Is rigid in her/his/[their] ideas and opinions',
70+
'62. Stereotypic & motor behaviours: Develops routines from which s/he/[they] cannot easily be discouraged eg wanting to eat or go for walks at fixed times',
71+
'63. Stereotypic & motor behaviours: Exhibits rituals eg takes the same route across the kitchen, only steps on certain floor tiles',
72+
'64. Stereotypic & motor behaviours: Clock watches or appears pre-occupied with time',
73+
'65. Stereotypic & motor behaviours: Appears pre-occupied with counting, numbers, puzzles or jigsaws',
74+
'66. Stereotypic & motor behaviours: Takes, hides or heards things, or packs away special items',
75+
'67. Stereotypic & motor behaviours: Repeatedly uses the same expression or catch phrase',
76+
'68. Stereotypic & motor mehaviours: S/he/[they] immediately repeat[s] words and sentences that you or others have just said (echolalia)',
77+
'69. Stereotypic & motor behaviours: Paces around without purpose',
78+
'70. Stereotypic & motor behaviours: Rummages around excessively',
79+
'71. Stereotypic & motor behaviours: S/he/[they] fidget[s] (eg bounces, taps feet/hands) a lot',
80+
'72. Motivation: Shows less enthusiasm for her/his/[their] usual interests',
81+
'73. Motivation: Shows little interest in doing new things',
82+
'74. Motivation: Requires nagging to start activities and chores',
83+
'75. Motivation: Shows no interest in attending social functions',
84+
'76. Motivation: Fails to maintain motivation to keep in contact with friends and family',
85+
'77. Motivation: Withdraws from others, fails to start conversations',
86+
'78. Motivation: Appears indifferent to the worries and concerns of family members',
87+
'79. Motivation: Shows reduced affection',
88+
'80. Insight/Awareness: Shows insight into changes in behaviour and personality (if appropriate)',
89+
'81. Insight/Awareness: Shows insight into memory problems'
9090
# Add more items as needed
9191
);
9292

9393
my %cbi_scores;
9494

9595
# Get user input for each CBI item
96-
foreach my $item (@cbi_items) {
96+
foreach my $item (sort @cbi_items) {
97+
# added sort
9798
my $valid_input = 0;
9899

99100
while (!$valid_input) {
@@ -113,7 +114,7 @@ sub calculate_cbi_total_score {
113114

114115
# Calculate total CBI score
115116
my $total_score = 0;
116-
foreach my $item_score (values %cbi_scores) {
117+
foreach my $item_score (sort values %cbi_scores) {
117118
$total_score += $item_score;
118119
}
119120

@@ -130,7 +131,7 @@ sub save_result_to_file {
130131
open my $fh, '>', $filename or die "Cannot open file '$filename' for writing: $!";
131132

132133
print $fh "CBI item scores:\n";
133-
for my $item (keys %scores) {
134+
for my $item (sort keys %scores) {
134135
print $fh "$item: $scores{$item}\n";
135136
}
136137
print $fh "\nTotal CBI score: $scores{total_score}\n";
@@ -169,7 +170,7 @@ sub save_result_to_file {
169170
chomp($save_option);
170171

171172
if ($save_option eq 'yes') {
172-
save_result_to_file(%cbi_scores);
173+
save_result_to_file(%cbi_scores) && exit print "saved\n"
173174
}
174175
elsif ($save_option eq 'no') {exit print "not saved\n"
175176

0 commit comments

Comments
 (0)