Skip to content

Instantly share code, notes, and snippets.

@eedrummer
Created July 13, 2009 19:46
Show Gist options
  • Save eedrummer/146388 to your computer and use it in GitHub Desktop.
Save eedrummer/146388 to your computer and use it in GitHub Desktop.
# this class will have to parse strings like "Data=B/P^122/82^^^^^^^" to get back a blood pressure of 122 over 82
class VitalSign
attr_accessor :kind, :value
def initialize(kind, value)
@kind, @value = kind, value
end
def self.create_vital_sign_from_vista_string(vista_string)
case vista_string
when /Data=B\/P\^(\d+)\/(\d+).*/
VitalSign.new(:blood_pressure, {:systolic => $1, :diastolic => $2})
when /Data=Ht\.\^(\d+)\^(cm|in).*/
VitalSign.new(:height, {:value => $1, :unit => $2})
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment