Class: Renalware::UKRDC::PathologyObservationPresenter

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
app/presenters/renalware/ukrdc/pathology_observation_presenter.rb

Overview

Assumes the thing being passed to the ctor is of type Pathology::ObservationPresenter hence responds to #description_code

Constant Summary collapse

INTERPRETATION_CODE_MAP =
{
  "positive" => "POS",
  "negative" => "NEG"
}.freeze
DEFAULT_INTERPRETATION_CODE =
"UNK"

Instance Method Summary collapse

Instance Method Details

#codeObject



39
40
41
# File 'app/presenters/renalware/ukrdc/pathology_observation_presenter.rb', line 39

def code
  description_loinc_code.presence || description_code
end

#coding_standardObject



33
34
35
36
37
# File 'app/presenters/renalware/ukrdc/pathology_observation_presenter.rb', line 33

def coding_standard
  return if description_rr_coding_standard.blank?

  description_rr_coding_standard.to_s.upcase
end

#interpretation_codeObject



43
44
45
46
47
# File 'app/presenters/renalware/ukrdc/pathology_observation_presenter.rb', line 43

def interpretation_code
  sanitized_result = result&.downcase&.strip

  INTERPRETATION_CODE_MAP.fetch(sanitized_result, DEFAULT_INTERPRETATION_CODE)
end

#pre_post(patient_is_on_hd:) ⇒ Object

The PrePost element in ResultItem For HD patients, all bloods are PRE except the post dialysis urea, For non-HD patients, all the tests are NA



19
20
21
22
23
24
25
# File 'app/presenters/renalware/ukrdc/pathology_observation_presenter.rb', line 19

def pre_post(patient_is_on_hd:)
  if patient_is_on_hd
    description_code.casecmp("UREP").zero? ? "POST" : "PRE"
  else
    "NA"
  end
end

#resultObject

Truncate long result text to satisfy XSD validation - it might be notes like eg “No recent Urea result”



29
30
31
# File 'app/presenters/renalware/ukrdc/pathology_observation_presenter.rb', line 29

def result
  (super || "")[0..19]
end