summaryrefslogtreecommitdiff
path: root/rvh/app
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-03-15 15:03:28 -0600
committermo khan <mo.khan@gmail.com>2020-03-15 15:03:28 -0600
commit0b9e665f1158bb31603f5ddd21bef7b46cb1d133 (patch)
tree22a6ba6c62592e3785ea944fc5ea7ae22bd584ad /rvh/app
parentedffd650265c6cccc7f359d2f6213447680b76c3 (diff)
Generate seed data
Diffstat (limited to 'rvh/app')
-rw-r--r--rvh/app/models/bed.rb2
-rw-r--r--rvh/app/models/care_centre.rb3
-rw-r--r--rvh/app/models/employee.rb11
-rw-r--r--rvh/app/models/laboratory.rb3
-rw-r--r--rvh/app/models/nurse.rb2
-rw-r--r--rvh/app/models/physician.rb2
-rw-r--r--rvh/app/models/technician.rb2
7 files changed, 16 insertions, 9 deletions
diff --git a/rvh/app/models/bed.rb b/rvh/app/models/bed.rb
index 5ef472e..0b0869e 100644
--- a/rvh/app/models/bed.rb
+++ b/rvh/app/models/bed.rb
@@ -2,6 +2,8 @@ class Bed < ApplicationRecord
belongs_to :care_centre
belongs_to :patient, optional: true
+ scope :available, -> { where(patient: nil) }
+
def available?
patient.blank?
end
diff --git a/rvh/app/models/care_centre.rb b/rvh/app/models/care_centre.rb
index 465952a..90bd3cc 100644
--- a/rvh/app/models/care_centre.rb
+++ b/rvh/app/models/care_centre.rb
@@ -1,3 +1,4 @@
class CareCentre < ApplicationRecord
- belongs_to :employee, optional: true
+ belongs_to :nurse_in_charge, class_name: Nurse.name, foreign_key: :employee_id
+ has_many :beds
end
diff --git a/rvh/app/models/employee.rb b/rvh/app/models/employee.rb
index f33a29a..89cba4c 100644
--- a/rvh/app/models/employee.rb
+++ b/rvh/app/models/employee.rb
@@ -2,13 +2,8 @@ class Employee < ApplicationRecord
belongs_to :account
has_many :treatments
serialize :qualifications, Array
-end
-
-class Nurse < Employee
-end
-
-class Physician < Employee
-end
-class Technician < Employee
+ delegate :name, to: :account
+ delegate :phone_number, to: :account
+ delegate :pager_number, to: :account
end
diff --git a/rvh/app/models/laboratory.rb b/rvh/app/models/laboratory.rb
new file mode 100644
index 0000000..5890c95
--- /dev/null
+++ b/rvh/app/models/laboratory.rb
@@ -0,0 +1,3 @@
+class Laboratory < ApplicationRecord
+ has_many :employees, -> { where(type: Technician.name) }
+end
diff --git a/rvh/app/models/nurse.rb b/rvh/app/models/nurse.rb
new file mode 100644
index 0000000..0c06dc1
--- /dev/null
+++ b/rvh/app/models/nurse.rb
@@ -0,0 +1,2 @@
+class Nurse < Employee
+end
diff --git a/rvh/app/models/physician.rb b/rvh/app/models/physician.rb
new file mode 100644
index 0000000..abec287
--- /dev/null
+++ b/rvh/app/models/physician.rb
@@ -0,0 +1,2 @@
+class Physician < Employee
+end
diff --git a/rvh/app/models/technician.rb b/rvh/app/models/technician.rb
new file mode 100644
index 0000000..b537f79
--- /dev/null
+++ b/rvh/app/models/technician.rb
@@ -0,0 +1,2 @@
+class Technician < Employee
+end