Class: Renalware::Feeds::HL7Message::Observation

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
app/models/renalware/feeds/hl7_message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cancelledObject (readonly)

Returns the value of attribute cancelled.



69
70
71
# File 'app/models/renalware/feeds/hl7_message.rb', line 69

def cancelled
  @cancelled
end

Instance Method Details

#commentObject

TODO: Implement comment extraction



83
84
85
# File 'app/models/renalware/feeds/hl7_message.rb', line 83

def comment
  @comment || ""
end

#identifierObject



74
75
76
# File 'app/models/renalware/feeds/hl7_message.rb', line 74

def identifier
  observation_id.split("^").first
end

#nameObject



78
79
80
# File 'app/models/renalware/feeds/hl7_message.rb', line 78

def name
  observation_id.split("^")[1]
end

#observation_valueObject

Some messages may come through with result text like

##TEST CANCELLED## Insufficient specimen received

in which case replace with something more concise. We could save the actual message somewhere



91
92
93
94
95
96
97
98
99
# File 'app/models/renalware/feeds/hl7_message.rb', line 91

def observation_value
  if super.upcase.at("CANCELLED")
    @comment = super
    @cancelled = true
    ""
  else
    super
  end
end

#unitsObject

Because some units of measurement, such as 10^12/L for WBC, contain a caret, the caret will initially have been encoded by Mirth as S\ (a Mirth escape sequence for ^ or whatever the mirth component separator character is configured to be) However in the 10^12/L example above, when encoded by Mirth, becomes ā€˜10S12/L` but the `12` within the message is interpreted as a `n` (form feed) by delayed_job when it is read into the yaml format string in the HL7 messages. While it might be possible to write out yaml into delayed_job using a format that will not un-escape on reading, the approach here is that the we have preprocessed the message using a trigger (at the point it is inserted into delayed_jobs) by replacing any instance of S\ with \S\ in the message. Thus the raw data for units in the database will look like `10\S\12/L`. When ever this string is loaded by Ruby it will un-escaped and become ā€œS" No `12` is not found and un-escaped to nā€ Note in the gsub here we double escape the 's



115
116
117
# File 'app/models/renalware/feeds/hl7_message.rb', line 115

def units
  super&.gsub("\\S\\", "^")
end