class Oddb2xml::FHIR::Bundle

Bundle represents one line in the NDJSON file

def cud_text_by_id

the RegulatedAuthorization rather than inline.
Used to resolve limitation texts that are stored as a reference on
Lookup map: CUD id (e.g. "NORDIMET" or "GLIVEC.01") => indication text.
def cud_text_by_id
  @cud_text_by_id ||= @clinical_use_definitions.each_with_object({}) do |cud, acc|
    next unless cud.id && cud.text
    acc[cud.id] = cud.text
  end
end

def initialize(json_line)

def initialize(json_line)
  data = JSON.parse(json_line)
  @entries = data["entry"] || []
  parse_entries
end

def parse_entries

def parse_entries
  @medicinal_product = nil
  @packages = []
  @authorizations = []
  @ingredients = []
  @clinical_use_definitions = []
  @entries.each do |entry|
    resource = entry["resource"]
    case resource["resourceType"]
    when "MedicinalProductDefinition"
      @medicinal_product = MedicinalProduct.new(resource)
    when "PackagedProductDefinition"
      @packages << Package.new(resource)
    when "RegulatedAuthorization"
      @authorizations << Authorization.new(resource)
    when "Ingredient"
      @ingredients << Ingredient.new(resource)
    when "ClinicalUseDefinition"
      @clinical_use_definitions << ClinicalUseDefinition.new(resource)
    end
  end
end