Tuesday, May 13, 2014

T's OBGYN Patient Intake App - My Very First App!

My first personal project at gSchool was a very simple Sinatra + PostgreSQL app for my lady.  She had been complaining that she had to type out these ridiculously long text messages to her team every time she took in a new patient in triage, and that her life would be so much simpler if technology could do it for her.  Lucky her!  I happened to know exactly how to do it :)

So I made a simple form, styled with Bootstrap, that took all the required inputs, formatted them, saved them to a database (in case she wanted needed the data in the future), then gave her the option to: a) text the results to herself or someone else, or b) copy and paste the results.



There's a lot of fields to this form, but it kept her from having to manually type each one.   A little bit of background on its purpose.  She's an OBGYN and every time a new patient comes in, she has to get a history for each patient including such things as: how many times they've been pregnant, number of miscarriages, successful births, results of various tests, the weight of previous children at birth, the current baby's weight, etc.  Luckily, all of the information is anonymous, in that there is no identifying information that could possibly link this info to patient, so no need to worry about HIPAA.  Anyway, when the information is gathered, it's sent out to the team on call so everyone is aware of the current patients, their history, and possible complications.

Since all of the fields above are attributes of a single patient, I put them all in the patient class, which was ugly... nearly 20 instance variables!  Luckily there's a way to make that look decent:

1:  require 'patient_repository'  
2:    
3:  class Patient  
4:    
5:   ATTRIBUTES = [  
6:     :age, :g, :p, :at_weeks, :at_days, :by_weeks, :by_days, :ultrasound, :prenatal_care,  
7:     :placenta, :group_b_strep, :one_hr_diabetes, :three_hr_diabetes, :history, :times_delivery_type,  
8:     :largest_baby_birthed, :estimated_fetal_weight_lbs, :estimated_fetal_weight_oz, :efw_by,  
9:     :sterile_vaginal_exam_time, :sve_dilation, :sve_effacement, :sve_station, :comment, :time  
10:   ]  
11:    
12:   attr_accessor *ATTRIBUTES  
13:    
14:   def initialize(options)  
15:    ATTRIBUTES.each do |attr|  
16:     instance_variable_set(:"@#{attr}", options[attr])  
17:    end  
18:   end  
19:    
20:   def attributes  
21:    Hash[ATTRIBUTES.map { |name| [name, instance_variable_get("@#{name}")] }]  
22:   end  
23:    
24:   def validate  
25:    ATTRIBUTES.each do |attribute|  
26:     replace_attribute = ['', '--'].include?(instance_variable_get("@#{attribute}"))  
27:     instance_variable_set("@#{attribute}", nil) if replace_attribute  
28:    end  
29:   end  
30:  end  

Instead of initializing ~20 instance variables, I put them into an attributes array and iterated through the array in the initialize method.  This did two things, solved a potential security vulnerability and also made the class look a ton cleaner.

Also, since not all the values were required and the database wasn't too keen on taking empty strings or '--' values in integer cells, I made a validate method that checked the form inputs for these and replaced them with nil.

Below is a screenshot of what the database:




After all the values have been input and submitted, below is the results.  What really made my day was being told that this little app now saves my darling about hour per day!  Nothing like producing software (in my first month of gSchool) that is actually used in a professional setting :)


If there are any OBGYN's out there that think this would be useful for them, feel free to use it: 

http://www.tiare.herokupapp.com

It's optimized for mobile, and kind of looks poopy on desktop.  But hey, it was my first app, ever!

As a PS, I looked all over GitHub for a for an active gem that allowed sending text messages through Google Voice.  Unfortunately, there weren't any active gems... so I had use some code from a blog I read and repurpose it for my app.  I'll have to scour Google SERPs for the blog (because he deserves the credit) and add it later, since I didn't bookmark it.


1:  class TextMessage  
2:    
3:   attr_accessor :data, :phone_number  
4:    
5:   def initialize(data, phone_number)  
6:    @data = data  
7:    @phone_number = phone_number  
8:   end  
9:    
10:    
11:   def text_message  
12:    login_response = ''  
13:    
14:    url = URI.parse('https://www.google.com/accounts/ClientLogin')  
15:    login_req = Net::HTTP::Post.new(url.path)  
16:    login_req.form_data = {'accountType' => 'GOOGLE', 'Email' => 'pt.intake.generator@gmail.com', 'Passwd' => '****************', 'service' => 'grandcentral', 'source' => 'tiare.herokuapp.com'}  
17:    login_con = Net::HTTP.new(url.host, url.port)  
18:    login_con.use_ssl = true  
19:    login_con.start { |http| login_response = http.request(login_req) }  
20:    
21:    url = URI.parse('https://www.google.com/voice/sms/send/')  
22:    req = Net::HTTP::Post.new(url.path, {'Content-type' => 'application/x-www-form-urlencoded', 'Authorization' => 'GoogleLogin auth='+login_response.body.match("Auth\=(.*)")[0].gsub("Auth=", "")})  
23:    
24:    req.form_data = {'id' => '', 'phoneNumber' => @phone_number, 'text' => @data, '_rnr_se' => '********************'}  
25:    con = Net::HTTP.new(url.host, url.port)  
26:    con.use_ssl = true  
27:    con.start { |http| response = http.request(req) }  
28:   end  
29:    
30:  end  

I totally lied...

A while back ... my last post... I stated that I was going to make my own blog from scratch.  Needless to say, my ambitions got the best of me.  I had no idea what I was in for at gSchool.  No one told me that the ability to program was like a super power and once you know (even a little) how to program, you'll want to take over the planet with all the ideas that cross your mind.   At least that's what happened to me.   Anyway, I'm not making a new blog, yet.  This will do while I work on more interesting projects.  

In my next post, I'll show off a couple apps I've made recently:  A patient intake generator that takes input, generates a formatted output and allows you to text it via SMS (through a Google Voice hack) that I made for my significant other; and a StubHub inventory manager that utilizes StubHub's API to present inventory and sales in a better format and also ties in with PayPal's API to verify that StubHub sale has been paid.  

Maybe I'll do a rant on gSchool, too. :)

Tuesday, March 18, 2014

Silence

Hey all, I just wanted to update everyone... I've been silent, because I've been slammed with gSchool work.  I'm planning on moving to a blog created by me and not hosted on blogspot... so stay tuned :)  More to come, I promise!

Monday, January 13, 2014

gSchool Prep



It's time to prep!  gSchool has sent out the list of things to accomplish prior to the first day, and here's what it's looking like:

Typing
  • Watch a 1-minute video by a master coder/typist {complete}
  • Spend 20-30 minutes/day on Typing.io
Reading
  • Extreme Programming Explained by Kent Beck
  • How to Count by Steven Frank
  • The 5 Elements of Effective Thinking by Edward B. Burger
Coding
  • Codecademy Web Fundamentals {complete}
  • Codecademy JavaScript
  • Codecademy Ruby {complete}
Not so bad, eh?  The only thing I'm dreading is doing the JavaScript lessons and Typing.io lesson.  I've been avoiding it, but as this list gets closer and closer to completion... the more I have to do it.  Ughhh.

Typing.io is a pretty cool web app.  I was pleasantly surprised at my typing (code) ability.  My average over ~22,500 is 52 WPM, though lately I've been consistently in the 60's and even in the low 70's.  What's even more cool is that it shows you the amount of useless keystrokes (10% currently), and your total time spent practicing.  The biggest issue I'm having now is finding out how to effectively reach for the special characters and get back to the home row.  That's been killing my accuracy and speed.  I should add, these stats are mostly for Ruby.  When I do JavaScript lessons, my WPM drops like a rock, somewhere in the low 40's.

On another note, I've tweeted with a few soon-to-be fellow students.  Interestingly, two of the four I've connected with have also lived in Japan and one seems to speak fairly fluently.  This should be an interesting class!  gSchool just opened up the Google Group for the incoming class, so I'm really looking forward to connecting with the others. :)

Completely off the topic of gSchool, I met with another person who recently finished DevBootCamp - one of San Francisco's oldest and most respected code bootcamps - and picked his brain about his experience.  He said that it was a great program, but because of how short it was and the hours required (~80hrs/wk), he felt like the biggest downfall was that you didn't have time to work on your own projects.  He said that's important because when you're interviewing, it helps a ton to have stuff on GitHub that you've done from start to finish.  That little bit of feedback has caused me to set a goal for myself:  while in gSchool, have a personal project that I can complete by the end of the course.  I've already got one in mind, but I'm not sure if it's too complicated to do on my own and with the little time I will have over the next 6 months.


Friday, January 3, 2014

Brick Wall

So I've been knocking out Codecademy.com's tutorials... I've finished Web Fundamentals and Ruby, and am now working on JavaScript.  I really enjoyed Web Fundamentals (HTML5/CSS3) and Ruby, but have found JavaScript to be a like a nagging girlfriend (luckily I haven't a nagging girlfriend in years).  Uhhhh! It's so picky and forces my attention to detail to be nothing but perfect.  I've been working on a rock, paper, scissors game that's been kicking my butt, all these curly braces and semi-colons are driving me nuts!

I read another person's blog that talked about the brick walls we hit while learning programming, and how overcoming those brick walls is what makes the difference between someone who will succeed in programming and someone who will ultimately give up or fail.  That's what keeps me trudging away... the obstacle of JavaScript will be overcome!  But I must say, I am not a huge fan of JavaScript, the syntax is nowhere near as enjoyable as Ruby.

On another note, I dropped off my $1,000 deposit at gSchool!  I'm in... now all I have to do is come up with another $4,000 before the start of class.  I took some money out of my Roth IRA and am driving for Lyft in my spare time to come up with it.  And, my parents offered to co-sign on a loan if I need more money to make this happen.  According to my interviewers, the problem most students have at gSchool is living expenses for the 6 months of school, since you can't work outside of school.  Luckily one of my companies makes money with minimal time investment on my part.  Things are well on their way!  Hopefully by September of this year I will be a Junior Developer at some awesome startup.  

Saturday, December 28, 2013

Paths

My Path as an Aspiring Developer

How many times have you given up a path you had a passion for because: a) life got in the way and you lost sight of what you enjoyed; b) you believed something else to be more important at that moment; or c) you just gave up because you didn't believe you were good enough?

I've been guilty of each.  One more than one occasion. I've followed many paths that brought me to where I am now, 32 years old and feeling like I've been intentionally and repeatedly picking the short straw in life.  I've been a Apple sales rep (before Apple stores), a US Navy sailor, an air traffic controller, a student, an entrepreneur, and too many other professions to list.  I loved some of my jobs, hated others, but found that for one reason or another I couldn't make a career out of it.  Not always by my own choice.  Yet, here I am, 32 years old and looking to make a career change.

Why did I choose software and web development?

It all started in 1993 when after much nagging, my parents finally agreed to buy me a computer.  An Apple Macintosh Performa 405.  The first thing I did was play Microsoft Flight Simulator, then Sim City, then Pirates! Gold.  But games weren't what really interested me.  I found myself getting bored easily and needed more of a challenge.  I needed to feel like I was creating, repairing, or even destroying something.  So I started taking the computer apart, which my parents didn't like, but I always put it back together.  Later I moved on to writing HyperCard scripts with Apple's HyperTalk scripting language.  A friend and I taught ourselves about networking and soon were linking our computers together and having competitions to see who could crack each other's computer first, ultimately to lock the other person out.  This was as a pre-teen and young teen.  My first job, in 1997, was selling Apple Macintosh computers at CompUSA... I love that job, mainly because I loved Apple.

But life took me on another path.  I joined the US Navy and served six years as an air traffic controller.  I traveled the world, lived Tokyo for a few years and ultimately forgot about how much I loved hacking away on the computer.  After leaving the Navy I went university and studied Political Science... it just seemed like the right thing to do.  I had ambitions of law school, briefly.  Fast forward to today.  20 years since I started hacking away on my Macintosh... 20 years.

As I've gotten older, I've realized how much I want to love what I do and truly be good at a it.  I've realized how much I want to create things that I find useful, and hopefully others will too.  So why not go back to my first love?  Hacking away on computers.  Actually, that's a lie, my first love was flying airplanes... but it doesn't make financial sense to spend tens of thousands of dollars to make $25,000/year as a pilot.  I'll save that as a hobby, when I can afford it.

So begins my journey to become a software/web developer, at the ripe (old) age of 32.

Why Ruby/Ruby on Rails?

Over the past few years, I've tried a few languages, just to get the hang of them.  I researched Python, JavaScript, and Ruby.  I found JavaScript to be too limiting as it's mainly web-based front end language (though frameworks like Meteor.js are changing that), Python offers the back end and a little bit of front end through frameworks, but no one in my community uses it. And finally, Ruby, which most of my friends use and through my research has proven to be a very versatile and powerful language that is currently in demand (and hopefully stays that way).  I have asked my friends on numerous occasions which language I should pursue and they gave me many different answers.  The ones that stick out the most are that I should pursue a language that offers flexibility I seek, ease of learning, and most importantly has a strong community around it so that I can learn from others when I encounter roadblocks.  Well, Ruby happens to fit that bill.  Rails provides Ruby with a plethora of web-based applications, frameworks like MacRuby and RubyMotion provide the opportunity to develop native applications on MacOS and iOS, and most importantly (to me), most of my current community are Ruby advocates.

Next Steps

I'm just about done with Codecademy.com's Ruby tutorials and I've applied, interviewed, and been accepted into Galvanize's gSchool Ruby Intensive course/bootcamp starting March 3rd, 2014.  gSchool is a 5 ½ month full-time 'crash course' or technical school that aims to prepare students for a junior software developer / engineer position.  Pretty much exactly what I'm looking for.

Who is this for?

Anyone thinking about or currently on a similar path.  My friends, my family, and Tiare (though as a first year resident physician, I don't think she'll have any time to read this - I'll just give her the Cliff's Notes version in our daily conversations).

So there you have it.  What brought me to this point and why I chose Ruby.  This shall be the last major course correction in my path of life.