Class: Renalware::Medications::Delivery::HomecareFormsAdapter
- Inherits:
-
Object
- Object
- Renalware::Medications::Delivery::HomecareFormsAdapter
- Defined in:
- app/models/renalware/medications/delivery/homecare_forms_adapter.rb
Overview
Takes
-
a patient
-
a homecare delivery_event
and build Args used to pass to Renalware::Forms::Homecare::Pdf.generate
Instance Method Summary collapse
Instance Method Details
#build_args ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'app/models/renalware/medications/delivery/homecare_forms_adapter.rb', line 24 def build_args args = Forms::Homecare::Args.new( provider: homecare_form.form_name, version: homecare_form.form_version, family_name: patient.family_name, given_name: patient.given_name, title: patient.title, born_on: patient.born_on, nhs_number: patient.nhs_number, telephone: patient.telephone1, hospital_number: patient.local_patient_id, address: [], modality: patient.current_modality&.description&.to_s, po_number: delivery_event.reference_number, drug_type: delivery_event.drug_type.name, selected_prescription_duration: selected_prescription_duration, prescription_durations: prescription_durations, consultant: patient.named_consultant&.to_s, generated_at: Time.zone.now, hospital_name: Renalware.config.hospital_name, hospital_address: hospital_address, hospital_department: Renalware.config.hospital_department, hospital_telephone: Renalware.config.telephone_on_homecare_delivery_forms ) if patient.current_address add = patient.current_address args.address = [ add.street_1, add.street_2, add.street_3, add.town ] args.postcode = add.postcode end prescriptions.each do |prescription| args.medications << Forms::Homecare::Args::Medication.new( date: prescription.prescribed_on, drug: prescription.drug.name, dose: "#{prescription.dose_amount} #{prescription.dose_unit}", route: prescription.medication_route&.name, frequency: prescription.frequency ) end clinical_patient = Clinical.cast_patient(patient) args.no_known_allergies = (clinical_patient.allergy_status == :no_known_allergies) args.allergies = Array(clinical_patient.allergies).map(&:description) args end |
#call ⇒ Object
16 17 18 |
# File 'app/models/renalware/medications/delivery/homecare_forms_adapter.rb', line 16 def call Forms::Homecare::Pdf.generate(build_args) end |
#valid?(args) ⇒ Boolean
20 21 22 |
# File 'app/models/renalware/medications/delivery/homecare_forms_adapter.rb', line 20 def valid?(args) Forms::Homecare::Pdf.valid?(args) end |