Skip to content

Instantly share code, notes, and snippets.

@klippx
klippx / pouch_order.rb
Created July 2, 2015 06:49
1. Original version
# A pouch order is ordered to a ward for a patient from a prescriber. These
# will be produces as pouches through the HD-Medi system.
class PouchOrder < ActiveRecord::Base
include Workflow
belongs_to :ward
belongs_to :patient
belongs_to :file, class_name: 'MachineFile', foreign_key: 'machine_file_id'
belongs_to :transport_label
@klippx
klippx / delete_pol.log
Created June 4, 2015 14:25
Deletear pouch order lines
2202 I, [2015-06-04T13:51:11.230236 #8457] INFO -- : Started GET "/labels/232.pdf" for 213.180.87.134 at 2015-06-04 13:51:11 +0200
2203 I, [2015-06-04T13:51:11.237208 #8457] INFO -- : Processing by LabelsController#show as PDF
2204 I, [2015-06-04T13:51:11.237313 #8457] INFO -- : Parameters: {"id"=>"232"}
2205 D, [2015-06-04T13:51:11.240117 #8457] DEBUG -- : User Load (0.7ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 42 ORDER BY `users`.`id` ASC LIMIT 1
2206 D, [2015-06-04T13:51:11.261844 #8457] DEBUG -- : TransportLabel Load (16.6ms) SELECT `transport_labels`.* FROM `transport_labels` WHERE `transport_labels`.`id` = 232 LIMIT 1
2207 D, [2015-06-04T13:51:11.277864 #8457] DEBUG -- : Address Load (0.7ms) SELECT `addresses`.* FROM `addresses` WHERE `addresses`.`owner_id` = 232 AND `addresses`.`owner_type` = 'TransportLabel' LIMIT 1
2208 I, [2015-06-04T13:51:11.297387 #8457] INFO -- : ***************WICKED***************
2209 D, [2015-06-04T13:51:11.461020 #8457]
@klippx
klippx / development.log
Created June 1, 2015 09:53
Sample output of Api::PouchOrdersController#index
=> Booting Thin
=> Rails 4.2.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Thin web server (v1.6.3 codename Protein Powder)
Maximum connections set to 1024
Listening on localhost:3000, CTRL+C to stop
Started GET "/" for 127.0.0.1 at 2015-06-01 11:49:34 +0200
@klippx
klippx / diagnoses_belongs_to_me.rb
Created August 27, 2014 13:40
All your diagnoses are belong to me
def diagnoses_belongs_to_me
diagnoses_ids = []
rows_array = form.rows.to_a[0...self.position - 1].reverse
rows_array.each do |r|
next if r.id == self.id
break if r.kind_of?(Journal::FormRow::ItemRow) or (r.kind_of?(Journal::FormRow::LabSampleRow) and r.billing_record_rows.any?)
if r.kind_of?(Journal::FormRow::DiagnosisRow) && r.diagnosis_id
diagnoses_ids << r.diagnosis_id
@klippx
klippx / detect_bad_item_rows
Last active August 29, 2015 13:59
detect offline sync up item rows that may need to be deleted
def detect_bad_item_rows(input)
ids = []
input.each_with_index do |data, i|
if source = data["source_attributes"]
if rows = source["row_attributes"]
rows.each_with_index do |r, j|
if r["type"] == "ItemRow" && r["mandatory"] == false && r.keys.count == 3
ids << {array_index: i, row_attributes_index: j}
end
end