summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-03-15 15:12:19 -0600
committermo khan <mo.khan@gmail.com>2020-03-15 15:12:19 -0600
commit028f041d32cc39efcfd5ddec29e14fbd60a06fd6 (patch)
treeccf2fa88edb6d3accef0b72e6a90c5174d395771
parentdbaedf19ba9fb0901b7870b8518ec00d2049eae2 (diff)
Attach physician to consumption
-rw-r--r--rvh/app/models/consumption.rb1
-rw-r--r--rvh/db/migrate/20200315183903_create_consumptions.rb1
-rw-r--r--rvh/db/schema.rb3
3 files changed, 5 insertions, 0 deletions
diff --git a/rvh/app/models/consumption.rb b/rvh/app/models/consumption.rb
index bffa146..61a91dc 100644
--- a/rvh/app/models/consumption.rb
+++ b/rvh/app/models/consumption.rb
@@ -1,4 +1,5 @@
class Consumption < ApplicationRecord
belongs_to :patient
belongs_to :item
+ belongs_to :physician, class_name: Physician.name, foreign_key: :employee_id
end
diff --git a/rvh/db/migrate/20200315183903_create_consumptions.rb b/rvh/db/migrate/20200315183903_create_consumptions.rb
index 5da1833..f158275 100644
--- a/rvh/db/migrate/20200315183903_create_consumptions.rb
+++ b/rvh/db/migrate/20200315183903_create_consumptions.rb
@@ -2,6 +2,7 @@ class CreateConsumptions < ActiveRecord::Migration[6.0]
def change
create_table :consumptions do |t|
t.references :patient, null: false, foreign_key: true
+ t.references :employee, null: false, foreign_key: true
t.references :item, null: false, foreign_key: true
t.datetime :consumed_at, null: false
t.integer :quantity, null: false
diff --git a/rvh/db/schema.rb b/rvh/db/schema.rb
index d8c3627..1adcdb5 100644
--- a/rvh/db/schema.rb
+++ b/rvh/db/schema.rb
@@ -43,12 +43,14 @@ ActiveRecord::Schema.define(version: 2020_03_15_204511) do
create_table "consumptions", force: :cascade do |t|
t.integer "patient_id", null: false
+ t.integer "employee_id", null: false
t.integer "item_id", null: false
t.datetime "consumed_at", null: false
t.integer "quantity", null: false
t.decimal "total_cost", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
+ t.index ["employee_id"], name: "index_consumptions_on_employee_id"
t.index ["item_id"], name: "index_consumptions_on_item_id"
t.index ["patient_id"], name: "index_consumptions_on_patient_id"
end
@@ -131,6 +133,7 @@ ActiveRecord::Schema.define(version: 2020_03_15_204511) do
add_foreign_key "beds", "care_centres"
add_foreign_key "beds", "patients"
+ add_foreign_key "consumptions", "employees"
add_foreign_key "consumptions", "items"
add_foreign_key "consumptions", "patients"
add_foreign_key "employees", "accounts"