Class: Renalware::MDMPresenter
- Inherits:
-
Object
- Object
- Renalware::MDMPresenter
show all
- Defined in:
- app/presenters/renalware/mdm_presenter.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(patient:, view_context:) ⇒ MDMPresenter
Returns a new instance of MDMPresenter.
10
11
12
13
|
# File 'app/presenters/renalware/mdm_presenter.rb', line 10
def initialize(patient:, view_context:)
@patient = patient
@view_context = view_context
end
|
Instance Attribute Details
#patient ⇒ Object
Returns the value of attribute patient.
8
9
10
|
# File 'app/presenters/renalware/mdm_presenter.rb', line 8
def patient
@patient
end
|
#view_context ⇒ Object
Returns the value of attribute view_context.
8
9
10
|
# File 'app/presenters/renalware/mdm_presenter.rb', line 8
def view_context
@view_context
end
|
Instance Method Details
#clinic_visits(limit: 6) ⇒ Object
28
29
30
31
32
33
34
|
# File 'app/presenters/renalware/mdm_presenter.rb', line 28
def clinic_visits(limit: 6)
@clinic_visits ||= Clinics::ClinicVisit.for_patient(patient)
.includes(:clinic)
.with_created_by
.ordered
.limit(limit)
end
|
#clinic_visits_having_measurements(limit: 3) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'app/presenters/renalware/mdm_presenter.rb', line 36
def clinic_visits_having_measurements(limit: 3)
@clinic_visits_having_measurements ||= begin
Clinics::ClinicVisit
.for_patient(patient)
.where("height is not null "\
"or weight is not null "\
"or systolic_bp is not null "\
"or diastolic_bp is not null")
.ordered
.limit(limit)
end
end
|
#current_immunosuppressant_prescriptions ⇒ Object
59
60
61
62
63
64
65
|
# File 'app/presenters/renalware/mdm_presenter.rb', line 59
def current_immunosuppressant_prescriptions
@current_immunosuppressant_prescriptions ||= begin
execute_prescriptions_query(
patient.prescriptions.having_drug_of_type(:immunosuppressant).current
)
end
end
|
#current_prescriptions ⇒ Object
53
54
55
56
57
|
# File 'app/presenters/renalware/mdm_presenter.rb', line 53
def current_prescriptions
@current_prescriptions ||= begin
execute_prescriptions_query(patient.prescriptions.current)
end
end
|
#current_problems ⇒ Object
86
87
88
|
# File 'app/presenters/renalware/mdm_presenter.rb', line 86
def current_problems
@current_problems ||= patient.problems.current.limit(6).with_created_by.ordered
end
|
#esa_prescriptions ⇒ Object
Note we sort prescriptions by prescribed_on desc here manually because the prescriptions query is currently too complex to add another sql sort into (defaults) to sorting by drug name
78
79
80
81
82
83
84
|
# File 'app/presenters/renalware/mdm_presenter.rb', line 78
def esa_prescriptions
@esa_prescriptions ||= begin
execute_prescriptions_query(
patient.prescriptions.having_drug_of_type("esa")
).sort_by(&:prescribed_on).reverse!
end
end
|
#events_of_type(type: nil) ⇒ Object
Also known as:
events
rubocop:disable Lint/UnusedMethodArgument
91
92
93
|
# File 'app/presenters/renalware/mdm_presenter.rb', line 91
def events_of_type(type: nil)
Events::Event.for_patient(patient).includes([:created_by, :event_type]).limit(6).ordered
end
|
#historical_immunosuppressant_prescriptions ⇒ Object
67
68
69
70
71
72
73
|
# File 'app/presenters/renalware/mdm_presenter.rb', line 67
def historical_immunosuppressant_prescriptions
@historical_immunosuppressant_prescriptions ||= begin
execute_prescriptions_query(
patient.prescriptions.having_drug_of_type(:immunosuppressant)
)
end
end
|
#historical_prescriptions ⇒ Object
49
50
51
|
# File 'app/presenters/renalware/mdm_presenter.rb', line 49
def historical_prescriptions
@historical_prescriptions ||= execute_prescriptions_query(patient.prescriptions)
end
|
#pathology ⇒ Object
15
16
17
|
# File 'app/presenters/renalware/mdm_presenter.rb', line 15
def pathology
@pathology ||= pathology_for_codes
end
|
#pathology_for_codes(codes = nil) ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'app/presenters/renalware/mdm_presenter.rb', line 19
def pathology_for_codes(codes = nil)
Pathology::CreateObservationsGroupedByDateTable.new(
patient: patient,
observation_descriptions: pathology_descriptions_for_codes(codes),
page: 1,
per_page: 10
).call
end
|