Class: Renalware::Forms::Homecare::Args
- Inherits:
-
Object
- Object
- Renalware::Forms::Homecare::Args
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/renalware/forms/homecare/args.rb
Defined Under Namespace
Classes: Medication
Class Method Summary collapse
Instance Method Summary collapse
- #allergies_as_list ⇒ Object
- #format_address_array(add) ⇒ Object
- #formatted_address ⇒ Object
- #formatted_address_and_postcode ⇒ Object
- #formatted_hospital_address ⇒ Object
- #formatted_hospital_name_and_address ⇒ Object
- #formatted_prescription_date ⇒ Object
- #medications_are_present ⇒ Object
- #patient_name ⇒ Object
Class Method Details
.test_data(provider: :generic, version: 1) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/renalware/forms/homecare/args.rb', line 102 def self.test_data(provider: :generic, version: 1) new.tap do |args| args.provider = provider args.version = version args.title = "Mr" args.given_name = "Jack" args.family_name = "JONES" args.nhs_number = "0123456789" args.born_on = Date.parse("2001-01-01") args.telephone = "07000 000001" args.hospital_number = "ABC123" args.modality = "PD" args.address = ["line1", "", nil, "line2", "line3 "] args.postcode = "TW1 1UU" args.modality = "HD" args.prescriber_name = "Dr X Yz" args.prescription_date = Date.today.to_s args.consultant = "Dr Pepper" args.hospital_name = "THE ROYAL LONDON HOSPITAL" args.hospital_telephone = "0000 000001" args.hospital_department = "Renal" args.hospital_address = [ "The Royal London Hospital", "Barts Health NHS Trust", "Whitechapel", "LONDON", "E1 1FR", "UK", "Tel: 0800 00000000", "Another line" ] args.no_known_allergies = false args.allergies = ["Nuts", nil, "Penicillin", "Mown grass"] args.drug_type = "ESA" args.prescription_duration = "1 month" args.administration_device = "device?" args.po_number = "P123" args.generated_at = Time.now args.delivery_frequencies = ["1 week", "3 months", "6 months", "12 month"] args.prescription_durations = ["3 months", "6 months", "12 months"] args.selected_prescription_duration = "6 months" args.selected_delivery_frequency = "6 months" args.medications << Medication.new( date: Date.today, drug: "Example drug", dose: "1 unit", route: "PO", frequency: "3" ) raise ArgumentError, args.errors unless args.valid? end end |
Instance Method Details
#allergies_as_list ⇒ Object
98 99 100 |
# File 'lib/renalware/forms/homecare/args.rb', line 98 def allergies_as_list Array(allergies).uniq.compact.join("<br>") end |
#format_address_array(add) ⇒ Object
86 87 88 89 90 |
# File 'lib/renalware/forms/homecare/args.rb', line 86 def format_address_array(add) return unless add&.is_a?(Array) add.compact.reject { |line| line == "" }.uniq&.join("\n") end |
#formatted_address ⇒ Object
69 70 71 |
# File 'lib/renalware/forms/homecare/args.rb', line 69 def formatted_address format_address_array address end |
#formatted_address_and_postcode ⇒ Object
73 74 75 |
# File 'lib/renalware/forms/homecare/args.rb', line 73 def formatted_address_and_postcode format_address_array(address << postcode) end |
#formatted_hospital_address ⇒ Object
77 78 79 |
# File 'lib/renalware/forms/homecare/args.rb', line 77 def formatted_hospital_address format_address_array hospital_address end |
#formatted_hospital_name_and_address ⇒ Object
81 82 83 84 |
# File 'lib/renalware/forms/homecare/args.rb', line 81 def formatted_hospital_name_and_address arr = [hospital_name] + hospital_address format_address_array arr end |
#formatted_prescription_date ⇒ Object
92 93 94 95 96 |
# File 'lib/renalware/forms/homecare/args.rb', line 92 def formatted_prescription_date return unless prescription_date prescription_date end |
#medications_are_present ⇒ Object
158 159 160 161 162 |
# File 'lib/renalware/forms/homecare/args.rb', line 158 def medications_are_present if medications.size == 0 errors.add(:base, "There are no home delivery prescriptions for this drug type") end end |
#patient_name ⇒ Object
63 64 65 66 67 |
# File 'lib/renalware/forms/homecare/args.rb', line 63 def patient_name name = [family_name, given_name].compact.join(", ") name += " (#{title})" if title.to_s != "" name end |