Class: Oddb2xml::FHIR::Ingredient
- Inherits:
-
Object
- Object
- Oddb2xml::FHIR::Ingredient
- Defined in:
- lib/oddb2xml/fhir_support.rb
Instance Attribute Summary collapse
-
#quantity ⇒ Object
readonly
Returns the value of attribute quantity.
-
#substance_name ⇒ Object
readonly
Returns the value of attribute substance_name.
-
#unit ⇒ Object
readonly
Returns the value of attribute unit.
Instance Method Summary collapse
-
#initialize(resource) ⇒ Ingredient
constructor
A new instance of Ingredient.
- #quantity_text ⇒ Object
Constructor Details
#initialize(resource) ⇒ Ingredient
Returns a new instance of Ingredient.
372 373 374 375 376 377 378 379 380 |
# File 'lib/oddb2xml/fhir_support.rb', line 372 def initialize(resource) @substance_name = resource.dig("substance", "code", "concept", "text") strength = resource.dig("substance", "strength", 0) @quantity = strength&.dig("presentationQuantity", "value") @unit = strength&.dig("presentationQuantity", "unit") # Handle textPresentation for ranges like "340-660" @text_presentation = strength&.dig("textPresentation") end |
Instance Attribute Details
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity.
370 371 372 |
# File 'lib/oddb2xml/fhir_support.rb', line 370 def quantity @quantity end |
#substance_name ⇒ Object (readonly)
Returns the value of attribute substance_name.
370 371 372 |
# File 'lib/oddb2xml/fhir_support.rb', line 370 def substance_name @substance_name end |
#unit ⇒ Object (readonly)
Returns the value of attribute unit.
370 371 372 |
# File 'lib/oddb2xml/fhir_support.rb', line 370 def unit @unit end |
Instance Method Details
#quantity_text ⇒ Object
382 383 384 |
# File 'lib/oddb2xml/fhir_support.rb', line 382 def quantity_text @text_presentation || (@quantity ? "#{@quantity}" : "") end |