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.
391 392 393 394 |
# File 'lib/oddb2xml/fhir_support.rb', line 391 def initialize(ndjson_file) @preparations = [] parse_file(ndjson_file) end |
Instance Attribute Details
#preparations ⇒ Object (readonly)
Returns the value of attribute preparations.
389 390 391 |
# File 'lib/oddb2xml/fhir_support.rb', line 389 def preparations @preparations end |
Instance Method Details
#parse_file(ndjson_file) ⇒ Object
396 397 398 399 400 401 402 403 404 405 406 407 |
# File 'lib/oddb2xml/fhir_support.rb', line 396 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 |