susu_fast_track_gem 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 988bdd1d3b2077d2cf19e31e771c50ba45b688002a7e7a9294d108a40820b37e
4
- data.tar.gz: 2c4b6af3f760fdae8d6f7fcfa5ab11da940e7991d45cf36968fa1e794d26d31c
3
+ metadata.gz: 521e94dbbd74e615129e9c58154a758817eb7d2aeb00f01d6c1cf5da236cdbcc
4
+ data.tar.gz: 45590297c38936092467dab836b395ba534d6aeaa5c0687d5c1956aa3bbc0fcf
5
5
  SHA512:
6
- metadata.gz: df844073e6bfdf5dda93e9e1c4fcb7b1dee7b706c56c8da3ee9fd19cf50db784a789bd73535d164a18c27027b92ccb6a443ea560dae81aa9c2e467f83390aeb3
7
- data.tar.gz: 1dd8188137977559988d242fa125c1a55daa77952b866ec4662e23897ca46d8b58a3e1a64322e1afb7eaebb6b3d45e332e29f10c6716e920b0721e6ee34c7dbd
6
+ metadata.gz: 4854147fe35d0e0e08cc9e2b74817e2f079763b5231beb1f37abe31b3c1007db390089774a0f7e8d4380cb7c9453df4d1763fb44f6890e2d0e87885dbc21fd9c
7
+ data.tar.gz: 22fc5751393b05048c9ea2841c90b7db2d868ed094f13e1c109fed463447842b7d72f76a4d3f0d966d0728b7f6efc2dcff4da264f83c894f2768782d11e00e19
data/.DS_Store CHANGED
Binary file
data/Gemfile CHANGED
@@ -5,3 +5,7 @@ gemspec
5
5
 
6
6
  gem "rake", "~> 12.0"
7
7
  gem "rspec", "~> 3.0"
8
+ gem 'artii', '~> 2.1', '>= 2.1.2'
9
+ gem 'terminal-table', '~> 1.8'
10
+ gem 'colorize', '~> 0.8.1'
11
+ gem 'tty-prompt', '~> 0.21.0'
data/Gemfile.lock ADDED
@@ -0,0 +1,61 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ susu_fast_track_gem (0.1.1)
5
+ colorize (~> 0.8.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ artii (2.1.2)
11
+ colorize (0.8.1)
12
+ diff-lcs (1.3)
13
+ equatable (0.6.1)
14
+ necromancer (0.5.1)
15
+ pastel (0.7.3)
16
+ equatable (~> 0.6)
17
+ tty-color (~> 0.5)
18
+ rake (12.3.3)
19
+ rspec (3.9.0)
20
+ rspec-core (~> 3.9.0)
21
+ rspec-expectations (~> 3.9.0)
22
+ rspec-mocks (~> 3.9.0)
23
+ rspec-core (3.9.1)
24
+ rspec-support (~> 3.9.1)
25
+ rspec-expectations (3.9.0)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.9.0)
28
+ rspec-mocks (3.9.1)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.9.0)
31
+ rspec-support (3.9.2)
32
+ terminal-table (1.8.0)
33
+ unicode-display_width (~> 1.1, >= 1.1.1)
34
+ tty-color (0.5.1)
35
+ tty-cursor (0.7.1)
36
+ tty-prompt (0.21.0)
37
+ necromancer (~> 0.5.0)
38
+ pastel (~> 0.7.0)
39
+ tty-reader (~> 0.7.0)
40
+ tty-reader (0.7.0)
41
+ tty-cursor (~> 0.7)
42
+ tty-screen (~> 0.7)
43
+ wisper (~> 2.0.0)
44
+ tty-screen (0.7.1)
45
+ unicode-display_width (1.7.0)
46
+ wisper (2.0.1)
47
+
48
+ PLATFORMS
49
+ ruby
50
+
51
+ DEPENDENCIES
52
+ artii (~> 2.1, >= 2.1.2)
53
+ colorize (~> 0.8.1)
54
+ rake (~> 12.0)
55
+ rspec (~> 3.0)
56
+ susu_fast_track_gem!
57
+ terminal-table (~> 1.8)
58
+ tty-prompt (~> 0.21.0)
59
+
60
+ BUNDLED WITH
61
+ 2.1.4
data/README.md CHANGED
@@ -1,18 +1,39 @@
1
1
  # SusuFastTrackGem
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/susu_fast_track_gem`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ AUSDRISK tool for health professionals to access patients' risk of type 2 diabetes.
6
4
 
7
5
  ## Installation
8
6
 
9
- Add this line to your application's Gemfile:
7
+ To install this gem using terminal :
8
+ 1. Install rbenv by typing the following into terminal:
9
+ brew install rbenv
10
+
11
+ 2. Set up rbenv by typing into the terminal:
12
+
13
+ rbenv init
14
+
15
+ Close the terminal
16
+
17
+ 3. Open terminal and check that rbenv is properly installed by entering the following into the terminal:
18
+ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
19
+
20
+ There should be no errors.
21
+
22
+ 4. Enter the following into the terminal:
23
+ rbenv install 2.7.0
24
+
25
+ 5.Enter the following into terminal:
26
+
27
+ rbenv global 2.7.0
28
+
29
+ 6.Enter the following into terminal:
30
+
31
+ ruby --version
10
32
 
11
- ```ruby
12
- gem 'susu_fast_track_gem'
13
- ```
33
+ version 2.7.0 should show,
34
+ ruby is successfully installed.
14
35
 
15
- And then execute:
36
+ 7. And then execute:
16
37
 
17
38
  $ bundle install
18
39
 
@@ -20,9 +41,9 @@ Or install it yourself as:
20
41
 
21
42
  $ gem install susu_fast_track_gem
22
43
 
23
- ## Usage
44
+ ## Software Requiremets
24
45
 
25
- TODO: Write usage instructions here
46
+ The computer must be a MAC OS and follow the installation instrutions as above under installation.
26
47
 
27
48
  ## Development
28
49
 
@@ -42,3 +63,86 @@ The gem is available as open source under the terms of the [MIT License](https:/
42
63
  ## Code of Conduct
43
64
 
44
65
  Everyone interacting in the SusuFastTrackGem project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/susu_fast_track_gem/blob/master/CODE_OF_CONDUCT.md).
66
+
67
+
68
+ ## User interaction with application
69
+
70
+ Menu :
71
+ Health care professional will have the option to :
72
+ 1. Do the AUSDRISK test
73
+ 2. View patient data
74
+ 3. View diabetes targets
75
+ 4. Exit the test
76
+
77
+ **If the user selects 1:**
78
+ The user will go through the ausdrisk quiz in which they either answer yes or no questions or select the options using 1,2 or 3 .
79
+
80
+ **If the user selects 2:**
81
+ THe user will be able to view data.They have the option to -
82
+
83
+ Look up all patient history.
84
+ The user must type in the patient's name to search for the history
85
+
86
+ Update the patient.
87
+ The user must type in the patient's name then manually type in their new score.
88
+
89
+ Delete the patient.
90
+ The user must type in the patient's name.
91
+
92
+ **If the user selects 3**
93
+ The app will open some documentation regarding glucose targets for non diabetics.
94
+
95
+
96
+ ## Referenced sources
97
+ Australian type 2 diabetes risk assessment tool (AUSDRISK)
98
+ link:https://www1.health.gov.au/internet/main/publishing.nsf/Content/chronic-diab-prev-aus/$File/austool5.pdf
99
+
100
+ Blood glucose levels:
101
+ https://www.diabetesaustralia.com.au/blood-glucose-monitoring
102
+
103
+
104
+ ## Source code repository
105
+ https://github.com/ssfung/fast-track-gem.git
106
+
107
+ ## Statement of Purpose
108
+ This application is created for health professionals such as doctors, nurses or pharmacists to help quickly determine a patient's risk of type two diabetes following the AUSDRISK assessment tool. This AUSDRISK tool is a questionnaire assessing a patient's lifestyle habits, waist measurement, age, medical history and ethnicity in order to determine their risk. These are important factors which can be modified in order to reduce a patient’s risk of type 2 diabetes. The tool will tally up all the points collected and place the patient in low, medium and high risk.
109
+
110
+ Healthcare professionals can use this application as a means to accurately add up the patient's risk rather than manually completing it hence reducing the risk of miscalculation which may be common during 15 minute consultations at the doctors.
111
+
112
+ The application has the ability to store patient's name and their score, update their score by manually entering it and to also delete the patient's record. There is also a table included which is to outline the normal HBA1C range and blood glucose range as a friendly reminder for the healthcare professional if they are looking for a quick reference guide.
113
+
114
+ Doctors can access this tool by visiting my github page and download via the terminal line to their computers. After installing the program, they are able to use the menu to go to do the following options:
115
+
116
+ 1. Ausdrisk tool
117
+ 2. View the patient's records, by searching for the patient's first name. A patient's score can also be updated by firstly searching for the patient’s first name then inputting the new score. Lastly the clinician can also have their patient’s record deleted if needed.
118
+ 3. Table for healthy range diabetes parameters for non diabetics
119
+ 4. Doctors can exit this program
120
+
121
+ ## Features
122
+ 1. Ausdrisk quiz
123
+ The AUSDRISK quiz is comprised of if loops to prompt a yes or no answer from the user. There is also a case statement for the user to select options 1-3 if a yes or no answer is not required. In order to prevent errors such as typing in a number or non-valid answer when a yes/no answer is required, the loop will put ‘wrong user input’ and repeat the original question until a valid input is attained.
124
+
125
+ 2. Storing patient details such as name, ethnicity, gender and score
126
+ The user's details are initially blank then as the user goes through the quiz, details such as ethnicity, gender are saved. This step is especially important, as the user has to have the ethnicity and gender saved in order to answer the waist measurement question. The points accumulated are saved at each step of the quiz by adding the points the patient gained in each step to the total. This reduces the use for asking the same question again at the waist measurement step (gender and ethnicity are required in order to answer this question).
127
+
128
+ 3. Storing, updating patient details
129
+ After the AUSDRISK quiz is done, patient's details are pushed into a CSV file and recorded. This allows a user to view the history of other patients. Another feature that is used is to update the patient's score. The csv data is put into an array which can be accessed via asking for the patient's name and searching for that array. User can override the previous history by entering the new value. Furthermore, the patient's details can be deleted by using delete function for arrays. The user then is returned to the view patient page and can exit then.
130
+
131
+
132
+
133
+ ## Control Flow (UML GRAPH)
134
+ ![UML control flow](./docs/AUSDRISK.png)
135
+
136
+
137
+
138
+ ## Project Management tool (Trello)
139
+ Please use the link below to see how I planned the app:
140
+ https://trello.com/b/zsc3W9gX/terminal-app
141
+
142
+ ![Trello project manager ](./docs/trello.png)
143
+
144
+ ## Manual Testing
145
+ Manual testing was done to test the app. Please kindly click the link below to view:
146
+ https://docs.google.com/spreadsheets/d/1PtMvniPatgDjO9aTjCvsZXQBiMGvjynCTeK8o0_nDos/edit#gid=0
147
+
148
+ ![manual testing](./docs/errors.png)
data/lib/.DS_Store ADDED
Binary file
data/lib/Gender.rb ADDED
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './input.rb'
4
+
5
+ def get_gender(user)
6
+ system 'clear'
7
+ sex = read_string('Are you male or female?')
8
+ valid_input = false
9
+ points_total = 0
10
+
11
+ until valid_input
12
+ if sex == 'female'
13
+ valid_input = true
14
+ points_total = 0
15
+ elsif sex == 'male'
16
+ valid_input = true
17
+ points_total += 3
18
+ else
19
+ puts 'Please choose male or female'
20
+ puts "you entered #{sex}"
21
+ sex = read_string('Are you male or female?')
22
+ end
23
+ end
24
+ user[:gender] = sex
25
+ user[:points_total] += points_total
26
+ user
27
+ end
data/lib/age_group.rb ADDED
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './input.rb'
4
+
5
+ def age_group(user)
6
+ age_points = 0
7
+ age = read_integer('How old are you?')
8
+
9
+ if age < 34
10
+ age_points += 0
11
+ elsif age > 35 && age <= 44
12
+ age_points += 2
13
+ elsif age > 45 && age <= 54
14
+ age_points += 4
15
+ elsif age > 55 && age <= 64
16
+ age_points += 6
17
+ elsif age > 65
18
+ age_points += 8
19
+ else
20
+ puts 'Wrong user input'
21
+ age = read_integer('How old are you?')
22
+ end
23
+ user[:points_total] += age_points
24
+ user
25
+ end
data/lib/ausdrisk.rb ADDED
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './age_group'
4
+ require_relative './Gender'
5
+ require_relative './ethnicity'
6
+ require_relative './birth_place'
7
+ require_relative './family'
8
+ require_relative './glucose'
9
+ require_relative './lifestyle'
10
+ require_relative './waist_measurement'
11
+ require 'colorize'
12
+ require 'tty-prompt'
13
+ require 'csv'
14
+
15
+ def add_data(patient_name, score)
16
+ CSV.open('patient_data.csv', 'a') do |csv|
17
+ csv << [patient_name, score]
18
+ end
19
+ end
20
+
21
+ def ausdrisk_test
22
+ system 'clear'
23
+ puts 'What is your name?'
24
+ name = gets.chomp
25
+
26
+ user = {
27
+ name: name,
28
+ gender: nil,
29
+ ethnicity: nil,
30
+ points_total: 0
31
+
32
+ }
33
+
34
+ user = age_group(user)
35
+ user = get_gender(user)
36
+ user = get_ethnicity(user)
37
+ user = get_destination(user)
38
+ user = get_family(user)
39
+ user = get_glucose(user)
40
+ user = Lifestyle.diet(user)
41
+ user = Lifestyle.exercise(user)
42
+ user = Lifestyle.blood_pressure(user)
43
+ user = Lifestyle.smoking(user)
44
+ result = waist_measurement(user)
45
+
46
+ if user[:points_total] < 5
47
+ puts 'Low risk - You scored 6-11 points in the AUSDRISK. You may be at increased risk of type 2 diabetes. Improving your lifestyle may reduce your risk of type 2 diabetes'.colorize(:green)
48
+ elsif user[:points_total] > 6 && user[:points_total] <= 11
49
+ puts 'intermediate risk'.colorize(:blue)
50
+ else user[:points_total] > 12
51
+ puts "You scored 12 points or more in the AUSDRISK. You may have
52
+ undiagnosed type 2 diabetes or be at high risk of developing the
53
+ disease. Speak to your healthcare professional as soon as possible.". colorize(:red)
54
+ end
55
+ add_data(user[:name], user[:points_total])
56
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ def birth_place_menu
4
+ system 'clear'
5
+ puts '1. Australia'
6
+ puts '2. Asia (including the Indian sub-continent), Middle East, North Africa, Southern Europe'
7
+ puts '3. Other'
8
+ puts 'Where were you born?'
9
+ print '>'
10
+ user_input = gets.chomp.to_i
11
+ user_input
12
+ end
13
+
14
+ def get_destination(user)
15
+ points_birth_place = 0
16
+ case birth_place_menu
17
+ when 1
18
+ points_birth_place += 0
19
+ when 2
20
+ points_birth_place += 2
21
+ when 3
22
+ points_birth_place += 0
23
+ else
24
+ puts 'Please choose an option from 1-3 only'
25
+ return birth_place_menu
26
+ end
27
+ user[:points_total] = (points_birth_place + user[:points_total])
28
+ user
29
+ end
data/lib/ethnicity.rb ADDED
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './input.rb'
4
+
5
+ def get_ethnicity(user)
6
+ system 'clear'
7
+ user_input = read_string('Are you of Aboriginal, Torres Straight Islander or Maori descent? yes or no')
8
+ print '>'
9
+ valid_input = false
10
+ points_ethnicity = 0
11
+
12
+ until valid_input
13
+ if user_input == 'yes'
14
+ valid_input = true
15
+ points_ethnicity += 2
16
+ elsif user_input == 'no'
17
+ valid_input = true
18
+ points_ethnicity = 0
19
+ else
20
+ puts 'Please answer yes or no'
21
+ puts "you entered #{user_input}"
22
+ user_input = read_string('Are you of Aboriginal, Torres Straight Islander or Maori descent? yes or not')
23
+ end
24
+ end
25
+ user[:ethnicity] = user_input
26
+ user[:points_total] += points_ethnicity
27
+ user
28
+ end
data/lib/family.rb ADDED
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ def get_family(user)
4
+ system 'clear'
5
+ family_points = 0
6
+ repeat = true
7
+ while repeat
8
+ puts 'Have either of your parents, or any of your brothers or sisters been diagnosed with diabetes (type 1 or type 2)? '
9
+ puts 'yes or No'
10
+ print '>'
11
+ user_input = gets.chomp.to_s.downcase
12
+
13
+ if user_input == 'yes'
14
+ family_points = 3
15
+ repeat = false
16
+ elsif user_input == 'no'
17
+ family_points = 0
18
+ repeat = false
19
+ else
20
+ puts 'Wrong user input'
21
+ end
22
+ end
23
+ return user
24
+ user[:points_total] += family_points
25
+ end
data/lib/glucose.rb ADDED
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ def get_glucose(user)
4
+ system 'clear'
5
+ glucose_points = 0
6
+ repeat = true
7
+ while repeat
8
+ puts "Have you ever been found to have high blood glucose
9
+ (sugar) (for example, in a health examination,
10
+ during an illness, during pregnancy)? yes or no"
11
+ print '>'
12
+ user_input = gets.chomp.to_s.downcase
13
+ if user_input == 'yes'
14
+ glucose_points = 6
15
+ repeat = false
16
+ elsif user_input == 'no'
17
+ glucose_points = 0
18
+ repeat = false
19
+ else
20
+ puts 'Wrong user input'
21
+ end
22
+ # user[:points_total] = (glucose_points + user[:points_total])
23
+ end
24
+ user[:points_total] += glucose_points
25
+ user
26
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'terminal-table'
4
+
5
+ def view_targets
6
+ puts 'Normal Range'
7
+ rows = []
8
+ rows << ['HBA1C', '<7%']
9
+ rows << ['random glucose test', '4-7.8 mmol/L']
10
+ table = Terminal::Table.new rows: rows
11
+ table = Terminal::Table.new headings: %w[Name Target], rows: rows
12
+ puts table
13
+ end
data/lib/input.rb ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ def read_string(question)
4
+ puts question
5
+ print '>'
6
+ user_input = gets.chomp
7
+ end
8
+
9
+ def read_integer(question)
10
+ read_string(question).to_i
11
+ end
data/lib/lifestyle.rb ADDED
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './input.rb'
4
+
5
+ module Lifestyle
6
+ def self.exercise(user)
7
+ exercise_points = 0
8
+ repeat = true
9
+ while repeat
10
+ exercise = read_string('On average, would you say you do at least 2.5 hours of physical activity per week (for example, 30 minutes a day on 5 or more days a week)? yes or no')
11
+
12
+ if exercise == 'yes'
13
+ exercise_points = 0
14
+ repeat = false
15
+ elsif exercise == 'no'
16
+ exercise_points = 1
17
+ repeat = false
18
+ else
19
+ puts 'Wrong user input'
20
+ end
21
+ end
22
+ user[:points_total] += exercise_points
23
+ user
24
+ end
25
+
26
+ def self.diet(user)
27
+ food_points = 0
28
+ repeat = true
29
+ while repeat
30
+ food = read_string('Do you eat fruit and vegetables everyday? yes or no')
31
+
32
+ if food == 'yes'
33
+ food_points = 0
34
+ repeat = false
35
+ elsif food == 'no'
36
+ food_points = 1
37
+ repeat = false
38
+ else
39
+ puts 'Wrong user input'
40
+ end
41
+ end
42
+ user[:points_total] += food_points
43
+ user
44
+ end
45
+
46
+ def self.blood_pressure(user)
47
+ bp_points = 0
48
+ repeat = true
49
+ while repeat
50
+
51
+ bp = read_string('Are you currently taking medication for high blood pressure? yes or no')
52
+
53
+ if bp == 'yes'
54
+ bp_points = 6
55
+ repeat = false
56
+ elsif bp == 'no'
57
+ bp_points = 0
58
+ repeat = false
59
+ else
60
+ puts 'Wrong user input'
61
+ end
62
+ end
63
+ user[:points_total] += bp_points
64
+ user
65
+ end
66
+
67
+ def self.smoking(user)
68
+ repeat = true
69
+ smoke_points = 0
70
+ while repeat
71
+ smokes = read_string('Do you currently smoke cigarettes or any other tobacco products on a daily basis? yes or no ')
72
+
73
+ if smokes == 'yes'
74
+ smoke_points = 2
75
+ repeat = false
76
+ elsif smokes == 'no'
77
+ smoke_points = 0
78
+ repeat = false
79
+ else
80
+ puts 'Wrong user input'
81
+ end
82
+ end
83
+ user[:points_total] += smoke_points
84
+ user
85
+ end
86
+ end
data/lib/menu.rb ADDED
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './ausdrisk.rb'
4
+ require_relative './patient_history.rb'
5
+ require_relative './glucose_targets.rb'
6
+ require 'artii'
7
+
8
+ $arter = Artii::Base.new
9
+
10
+ def menu
11
+ system 'clear'
12
+ puts $arter.asciify('DIABETES')
13
+ puts '1. AUSDRISK test'
14
+ puts ' '
15
+ puts '2. View patient data'
16
+ puts ' '
17
+ puts '3. View Diabetes targets'
18
+ puts ' '
19
+ puts '4. Exit'
20
+ puts ' '
21
+ puts 'Please chose one option from the above menu:'
22
+ user_selection = gets.chomp.to_i
23
+ print '>'
24
+ user_selection
25
+ end
26
+
27
+ input = menu
28
+ case input
29
+ when 1
30
+ ausdrisk_test
31
+ when 2
32
+ menu_patient
33
+ when 3
34
+ view_targets
35
+ when 4
36
+ exit
37
+ else
38
+ puts 'Please choose an option from 1-4 only'
39
+ end
@@ -0,0 +1,3 @@
1
+ name,score
2
+ bella, 30
3
+ dom, 18
@@ -0,0 +1,104 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'csv'
4
+ require 'tty-prompt'
5
+
6
+ def update_data(patients)
7
+ CSV.open('patient_data.csv', 'w') do |csv|
8
+ csv << %w[name score]
9
+ patients.each do |patient|
10
+ print 'PATIENT: '
11
+ p patient
12
+ csv << patient.values
13
+ end
14
+ end
15
+ end
16
+
17
+ def patient_look_up(patients_array)
18
+ system 'clear'
19
+ loop do
20
+ puts 'which patient would you like to look up?'
21
+ print = '>'
22
+ patient_search = gets.chomp.downcase
23
+ found_patient = nil
24
+ patients_array.each do |patient|
25
+ return patient if patient_search == patient['name']
26
+ end
27
+ puts 'patient does not exist'
28
+ end
29
+ end
30
+
31
+ def read_csv(csv)
32
+ arr = []
33
+ csv.each do |row|
34
+ patient = row.to_hash
35
+ arr << patient
36
+ end
37
+ arr
38
+ end
39
+
40
+ def update_patient(patients_array)
41
+ system 'clear'
42
+ puts 'which patient would you like to look up?'
43
+ patient_search = gets.chomp.downcase
44
+ print = '>'
45
+ found_patient = nil
46
+ patients_array.each do |patient|
47
+ found_patient = patient if patient_search == patient['name']
48
+ end
49
+ puts "what was the patient's new score? "
50
+ new_score = gets.chomp
51
+ print '>'
52
+ patients_array.each do |patient|
53
+ next unless patient_search == patient['name']
54
+
55
+ found_patient = patient
56
+ patient['score'] = new_score
57
+ end
58
+ update_data(patients_array)
59
+ end
60
+
61
+ def delete_patient(patients_array)
62
+ puts 'which patient would you like to delete?'
63
+ patient_search = gets.chomp
64
+ print = '>'
65
+ found_patient = nil
66
+
67
+ patients_array.each do |patient|
68
+ if patient_search == patient['name']
69
+ found_patient = patient
70
+ patients_array.delete(found_patient)
71
+ end
72
+ end
73
+ update_data(patients_array)
74
+ end
75
+
76
+ def menu_patient
77
+ system 'clear'
78
+ loop do
79
+ csv_text = File.read('patient_data.csv')
80
+ csv = CSV.parse(csv_text, headers: true)
81
+ patients_array = read_csv(csv)
82
+
83
+ choices = [
84
+ { name: 'Look up all patient history', value: 1 },
85
+ { name: 'Update Patient', value: 2 },
86
+ { name: 'Delete patient', value: 3 },
87
+ { name: 'Exit', value: 4 }
88
+ ]
89
+ prompt = TTY::Prompt.new
90
+ user_input = prompt.select('Select an action?', choices)
91
+ case user_input
92
+ when 1
93
+ p patient_look_up(patients_array)
94
+ when 2
95
+ p update_patient(patients_array)
96
+ when 3
97
+ delete_patient(patients_array)
98
+ when 4
99
+ exit
100
+ else
101
+ puts 'Please choose an option from 1-4 only'
102
+ end
103
+ end
104
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SusuFastTrackGem
2
- VERSION = "0.1.0"
4
+ VERSION = '0.1.2'
3
5
  end
@@ -1,7 +1,5 @@
1
- require_relative
2
- "susu_fast_track_gem/version"
1
+ # frozen_string_literal: true
3
2
 
4
- module SusuFastTrackGem
5
- class Error < StandardError; end
6
- # Your code goes here...
7
- end
3
+ require_relative
4
+ 'susu_fast_track_gem/version'
5
+ require_relative 'menu'
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ def get_waist_measurement
4
+ system 'clear'
5
+ puts 'Please measure your waist measurement taken below the ribs usually at the level of the navel, and while standing'
6
+ puts 'Waist measurement (in cm)'
7
+ print '>'
8
+ user_input = gets.chomp.to_i
9
+ end
10
+
11
+ def waist_measurement(user)
12
+ waist_points = 0
13
+ waist_measurement = get_waist_measurement
14
+ if user[:gender] == 'female' && user[:ethnicity] == 'yes'
15
+ if waist_measurement < 80
16
+ waist_points += 0
17
+ elsif waist_measurement > 80 && waist_measurement <= 90
18
+ waist_points += 4
19
+ else waist_measurement > 90
20
+ waist_points += 7
21
+ end
22
+ elsif
23
+ if user[:gender] == 'female' && user[:ethnicity] == 'no'
24
+ if waist_measurement < 88
25
+ waist_points += 0
26
+ elsif waist_measurement > 88 && waist_measurement <= 100
27
+ waist_points += 4
28
+ else waist_measurement > 100
29
+ waist_points += 7
30
+ end
31
+ elsif
32
+ if user[:gender] == 'male' && user[:ethnicity] == 'no'
33
+ if waist_measurement < 102
34
+ waist_points += 0
35
+ elsif waist_measurement > 102 && waist_measurement <= 110
36
+ waist_points += 4
37
+ else waist_measurement > 110
38
+ waist_points += 7
39
+ end
40
+ if user[:gender] == 'male' && user[:ethnicity] == 'yes'
41
+ if waist_measurement < 90
42
+ waist_points += 0
43
+ elsif waist_measurement > 90 && waist_measurement <= 100
44
+ waist_points += 4
45
+ else waist_measurement > 100
46
+ waist_points += 7
47
+ end
48
+ user[:points_total] = (waist_points + user[:points_total])
49
+ end
50
+ end
51
+ end
52
+ end
53
+ user
54
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: susu_fast_track_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Susu Fung
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-10 00:00:00.000000000 Z
11
+ date: 2020-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -37,13 +37,29 @@ files:
37
37
  - ".travis.yml"
38
38
  - CODE_OF_CONDUCT.md
39
39
  - Gemfile
40
+ - Gemfile.lock
40
41
  - LICENSE.txt
41
42
  - README.md
42
43
  - Rakefile
43
44
  - bin/console
44
45
  - bin/setup
46
+ - lib/.DS_Store
47
+ - lib/Gender.rb
48
+ - lib/age_group.rb
49
+ - lib/ausdrisk.rb
50
+ - lib/birth_place.rb
51
+ - lib/ethnicity.rb
52
+ - lib/family.rb
53
+ - lib/glucose.rb
54
+ - lib/glucose_targets.rb
55
+ - lib/input.rb
56
+ - lib/lifestyle.rb
57
+ - lib/menu.rb
58
+ - lib/patient_data.csv
59
+ - lib/patient_history.rb
45
60
  - lib/susu_fast_track_gem.rb
46
61
  - lib/susu_fast_track_gem/version.rb
62
+ - lib/waist_measurement.rb
47
63
  - susu_fast_track_gem.gemspec
48
64
  homepage: https://github.com/ssfung/fast-track-gem.git
49
65
  licenses: