Skip to content

Instantly share code, notes, and snippets.

@mtrudel
Created August 10, 2009 17:34
Show Gist options
  • Save mtrudel/165298 to your computer and use it in GitHub Desktop.
Save mtrudel/165298 to your computer and use it in GitHub Desktop.
register_participant 'build_adherence_predicates' do |workitem|
# We do this separately, since we only care about
# its presence, and not its value
p = Patient.find workitem['patient_id']
[:bp, :pulse, :symptom, :weight].each do |parameter|
if (p.send("#{parameter}_readings").morning.during(Time.last(7.days)) == 0)
workitem["#{parameter}_today"] = 'no'
else
workitem["#{parameter}_today"] = 'yes'
end
end
if (p.ecg_readings.morning.during(Time.last(7.days)) == 0)
workitem['ecg_in_last_7_days'] = 'no'
else
workitem['ecg_in_last_7_days'] = 'yes'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment