Class: Renalware::UKRDC::PatientPresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Renalware::UKRDC::PatientPresenter
- Defined in:
- app/presenters/renalware/ukrdc/patient_presenter.rb
Instance Attribute Summary collapse
-
#changes_since ⇒ Object
readonly
Returns the value of attribute changes_since.
-
#changes_up_until ⇒ Object
readonly
Returns the value of attribute changes_up_until.
Instance Method Summary collapse
- #allergies ⇒ Object
- #clinic_visits ⇒ Object
- #contact_details? ⇒ Boolean
- #current_modality_hd? ⇒ Boolean
- #current_registration_status_rr_code ⇒ Object
- #dead? ⇒ Boolean
- #finished_hd_sessions ⇒ Object
- #hospital_unit_code ⇒ Object
-
#initialize(patient, changes_since: nil) ⇒ PatientPresenter
constructor
A new instance of PatientPresenter.
- #letters ⇒ Object
- #observation_requests ⇒ Object
- #prescriptions ⇒ Object
- #smoking_history ⇒ Object
Constructor Details
#initialize(patient, changes_since: nil) ⇒ PatientPresenter
Returns a new instance of PatientPresenter.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/presenters/renalware/ukrdc/patient_presenter.rb', line 14 def initialize(patient, changes_since: nil) if changes_since.present? && changes_since.is_a?(String) changes_since = Time.zone.parse(changes_since) end @changes_since = changes_since || patient.sent_to_ukrdc_at if @changes_since.blank? raise( ArgumentError, "No date for comparison: patient#sent_to_ukrdc_at and changes_since are nil" ) end @changes_up_until = Time.zone.now super(patient) end |
Instance Attribute Details
#changes_since ⇒ Object (readonly)
Returns the value of attribute changes_since.
8 9 10 |
# File 'app/presenters/renalware/ukrdc/patient_presenter.rb', line 8 def changes_since @changes_since end |
#changes_up_until ⇒ Object (readonly)
Returns the value of attribute changes_up_until.
8 9 10 |
# File 'app/presenters/renalware/ukrdc/patient_presenter.rb', line 8 def changes_up_until @changes_up_until end |
Instance Method Details
#allergies ⇒ Object
74 75 76 77 78 |
# File 'app/presenters/renalware/ukrdc/patient_presenter.rb', line 74 def allergies clinical_patient .allergies .where("recorded_at >= ?", changes_since) end |
#clinic_visits ⇒ Object
80 81 82 83 84 85 |
# File 'app/presenters/renalware/ukrdc/patient_presenter.rb', line 80 def clinic_visits clinics_patient .clinic_visits .where("date >= ?", changes_since) .includes(:updated_by) end |
#contact_details? ⇒ Boolean
70 71 72 |
# File 'app/presenters/renalware/ukrdc/patient_presenter.rb', line 70 def contact_details? email || home_telephone || mobile_telephone end |
#current_modality_hd? ⇒ Boolean
33 34 35 36 |
# File 'app/presenters/renalware/ukrdc/patient_presenter.rb', line 33 def current_modality_hd? return false if current_modality.blank? current_modality.description.is_a?(Renalware::HD::ModalityDescription) end |
#current_registration_status_rr_code ⇒ Object
59 60 61 62 63 64 |
# File 'app/presenters/renalware/ukrdc/patient_presenter.rb', line 59 def current_registration_status_rr_code @current_registration_status_rr_code ||= begin status = transplant_patient.current_registration_status status&.description&.rr_code end end |
#dead? ⇒ Boolean
29 30 31 |
# File 'app/presenters/renalware/ukrdc/patient_presenter.rb', line 29 def dead? current_modality_death? end |
#finished_hd_sessions ⇒ Object
52 53 54 55 56 57 |
# File 'app/presenters/renalware/ukrdc/patient_presenter.rb', line 52 def finished_hd_sessions hd_patient .finished_hd_sessions .includes(:patient, :dialysate) .where("hd_sessions.updated_at > ?", changes_since) end |
#hospital_unit_code ⇒ Object
66 67 68 |
# File 'app/presenters/renalware/ukrdc/patient_presenter.rb', line 66 def hospital_unit_code letter_head.site_code end |
#letters ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'app/presenters/renalware/ukrdc/patient_presenter.rb', line 42 def letters CollectionPresenter.new( letters_patient .letters .approved .where("updated_at > ?", changes_since), Renalware::Letters::LetterPresenterFactory ) end |
#observation_requests ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 |
# File 'app/presenters/renalware/ukrdc/patient_presenter.rb', line 93 def observation_requests pathology_patient .observation_requests .eager_load( :description, observations: { description: :measurement_unit } ) .where(patient_id: id) .where("requested_at >= ?", changes_since) .where("loinc_code is not null") end |
#prescriptions ⇒ Object
87 88 89 90 91 |
# File 'app/presenters/renalware/ukrdc/patient_presenter.rb', line 87 def prescriptions __getobj__.prescriptions .includes(:termination, :medication_route, :drug) .where("updated_at > ?", changes_since) end |
#smoking_history ⇒ Object
38 39 40 |
# File 'app/presenters/renalware/ukrdc/patient_presenter.rb', line 38 def smoking_history @smoking_history ||= document.history&.smoking&.upcase end |