Skip to content

Instantly share code, notes, and snippets.

@v-fedorov
Created May 31, 2013 15:34
Show Gist options
  • Save v-fedorov/5685807 to your computer and use it in GitHub Desktop.
Save v-fedorov/5685807 to your computer and use it in GitHub Desktop.
#Mild score
score = "breathlessness=6&cough=0&nasal_congestion=0&peak_flow_measurement=699&sore_throat=0&sputum_color=0&sputum_consistency=0&sputum_quantity=0&status=0&temp_over_100=0&wheeze=0"
report(score, 34)
#Moderate score
score = "breathlessness=6&cough=0&nasal_congestion=0&peak_flow_measurement=66&sore_throat=0&sputum_color=0&sputum_consistency=0&sputum_quantity=0&status=0&temp_over_100=0&wheeze=0"
report(score, 34)
#Severe score
score = "breathlessness=10&cough=1&nasal_congestion=1&peak_flow_measurement=66&sore_throat=1&sputum_color=3&sputum_consistency=2&sputum_quantity=2&status=0&temp_over_100=1&wheeze=1"
report(score, 34)
def report!(scoreBody, userID)
require 'net/http'
require 'uri'
reports = []
Escalation.all.each do |esc|
treatment = user.treatments.new
treatment.med_section_item = esc.med_section_item
treatment.med_dosage = esc.med_dosage
treatment.med_duration = esc.med_duration
treatment.med_frequency = esc.med_frequency
treatment.start_date = Time.now
user.treatmentmedications = LegacyTreatment.to_legacy_hash(treatment)
user.save!
// POST report with scoreBody for user.
url = URI.parse("http://38.104.114.222/api/v2/users/#{userID}/reports/?t=JGp0fvqRPLt7tgmGVhnGMyLYM9U=&u=doctor1&ts=1369422226.583920&key=test")
reportJSON = Net::HTTP::Post.new(url.path, scoreBody)
report = JSON.parse(reportJSON || '[]')
log("Escalating:" + LegacyTreatment.humanize_legacy_hash(treatment) + "=>" + report.treatments)
reports << report
end
reports
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment