summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-03-29 12:23:44 -0600
committermo khan <mo.khan@gmail.com>2020-03-29 12:23:44 -0600
commit9a326cf651b74fe8a03aa6aadf1f52a7ae5be5ef (patch)
tree966e998d968df111aefad1cd764c1736f0533592
parent88ac674dd877e84fd6d78c855e5dfedccf35fde5 (diff)
Fix model
-rw-r--r--rvh/app/models/laboratory.rb2
-rw-r--r--rvh/app/models/physician.rb2
-rw-r--r--rvh/app/models/shift.rb2
-rw-r--r--rvh/db/migrate/20200315182410_create_shifts.rb2
-rw-r--r--rvh/db/migrate/mple_postgres0
-rw-r--r--rvh/db/schema.rb6
6 files changed, 7 insertions, 7 deletions
diff --git a/rvh/app/models/laboratory.rb b/rvh/app/models/laboratory.rb
index 5890c95..5270a28 100644
--- a/rvh/app/models/laboratory.rb
+++ b/rvh/app/models/laboratory.rb
@@ -1,3 +1,3 @@
class Laboratory < ApplicationRecord
- has_many :employees, -> { where(type: Technician.name) }
+ has_many :staff, -> { where(type: Technician.name) }
end
diff --git a/rvh/app/models/physician.rb b/rvh/app/models/physician.rb
index 85d6605..75b218f 100644
--- a/rvh/app/models/physician.rb
+++ b/rvh/app/models/physician.rb
@@ -1,4 +1,4 @@
class Physician < Staff
has_many :patients
- has_many :treatmeants, through: :patients
+ has_many :treatments, through: :patients
end
diff --git a/rvh/app/models/shift.rb b/rvh/app/models/shift.rb
index df7adc2..6e7e93a 100644
--- a/rvh/app/models/shift.rb
+++ b/rvh/app/models/shift.rb
@@ -1,4 +1,4 @@
class Shift < ApplicationRecord
belongs_to :care_centre
- belongs_to :employee
+ belongs_to :staff, polymorphic: true
end
diff --git a/rvh/db/migrate/20200315182410_create_shifts.rb b/rvh/db/migrate/20200315182410_create_shifts.rb
index 7a7cca5..2f89f30 100644
--- a/rvh/db/migrate/20200315182410_create_shifts.rb
+++ b/rvh/db/migrate/20200315182410_create_shifts.rb
@@ -2,7 +2,7 @@ class CreateShifts < ActiveRecord::Migration[6.0]
def change
create_table :shifts do |t|
t.references :care_centre, null: false, foreign_key: true
- t.references :employee, null: false, foreign_key: true
+ t.references :staff, polymorphic: true, null: false
t.datetime :started_at, null: false
t.datetime :ended_at
diff --git a/rvh/db/migrate/mple_postgres b/rvh/db/migrate/mple_postgres
deleted file mode 100644
index e69de29..0000000
--- a/rvh/db/migrate/mple_postgres
+++ /dev/null
diff --git a/rvh/db/schema.rb b/rvh/db/schema.rb
index 7e2d0b3..50828d5 100644
--- a/rvh/db/schema.rb
+++ b/rvh/db/schema.rb
@@ -86,13 +86,14 @@ ActiveRecord::Schema.define(version: 2020_03_15_190540) do
create_table "shifts", force: :cascade do |t|
t.bigint "care_centre_id", null: false
- t.bigint "employee_id", null: false
+ t.string "staff_type", null: false
+ t.bigint "staff_id", null: false
t.datetime "started_at", null: false
t.datetime "ended_at"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["care_centre_id"], name: "index_shifts_on_care_centre_id"
- t.index ["employee_id"], name: "index_shifts_on_employee_id"
+ t.index ["staff_type", "staff_id"], name: "index_shifts_on_staff_type_and_staff_id"
end
create_table "staff", force: :cascade do |t|
@@ -144,7 +145,6 @@ ActiveRecord::Schema.define(version: 2020_03_15_190540) do
add_foreign_key "patients", "staff", column: "physician_id"
add_foreign_key "patients", "staff", column: "referring_physician_id"
add_foreign_key "shifts", "care_centres"
- add_foreign_key "shifts", "staff"
add_foreign_key "staff", "accounts"
add_foreign_key "staff", "laboratories"
add_foreign_key "treatments", "patients"