Class: Oddb2xml::FHIR::PreparationsParser
- Inherits:
-
Object
- Object
- Oddb2xml::FHIR::PreparationsParser
- Defined in:
- lib/oddb2xml/fhir_support.rb
Overview
Main parser class that provides compatibility with XML parser
Instance Attribute Summary collapse
-
#preparations ⇒ Object
readonly
Returns the value of attribute preparations.
Instance Method Summary collapse
-
#initialize(ndjson_file) ⇒ PreparationsParser
constructor
A new instance of PreparationsParser.
- #parse_file(ndjson_file) ⇒ Object
Constructor Details
#initialize(ndjson_file) ⇒ PreparationsParser
Returns a new instance of PreparationsParser.
434 435 436 437 |
# File 'lib/oddb2xml/fhir_support.rb', line 434 def initialize(ndjson_file) @preparations = [] parse_file(ndjson_file) end |
Instance Attribute Details
#preparations ⇒ Object (readonly)
Returns the value of attribute preparations.
432 433 434 |
# File 'lib/oddb2xml/fhir_support.rb', line 432 def preparations @preparations end |
Instance Method Details
#parse_file(ndjson_file) ⇒ Object
439 440 441 442 443 444 445 446 447 448 449 450 |
# File 'lib/oddb2xml/fhir_support.rb', line 439 def parse_file(ndjson_file) File.foreach(ndjson_file, encoding: 'UTF-8') do |line| next if line.strip.empty? bundle = Bundle.new(line) next unless bundle.medicinal_product # Create a preparation structure compatible with XML parser output prep = create_preparation(bundle) @preparations << prep if prep end end |