Class: Inferno::Repositories::IGs

Inherits:
InMemoryRepository show all
Includes:
Utils::IgDownloader
Defined in:
lib/inferno/repositories/igs.rb

Overview

Repository that deals with persistence for the IG entity.

Constant Summary

Constants included from Utils::IgDownloader

Utils::IgDownloader::FHIR_PACKAGE_NAME_REG_EX, Utils::IgDownloader::FILE_URI_REG_EX, Utils::IgDownloader::HTTP_URI_END_REG_EX, Utils::IgDownloader::HTTP_URI_REG_EX

Instance Method Summary collapse

Methods included from Utils::IgDownloader

#download_file, #ig_file, #ig_http_url, #ig_path, #ig_registry_url, #load_ig

Methods inherited from InMemoryRepository

all, #exists?, #find, #insert, #remove

Instance Method Details

#find_by_path(path) ⇒ Inferno::Entities::IG

Get the instance of the already-loaded IG specified by file path.

Parameters:

  • path (String)

    file path, eg “./igs/uscore.tgz”

Returns:



30
31
32
# File 'lib/inferno/repositories/igs.rb', line 30

def find_by_path(path)
  all.find { |ig| ig.source_path == path }
end

#find_or_load(id_or_path) ⇒ Inferno::Entities::IG

Get the instance of the IG specified by either identifier or file path. An in-memory instance will be returned if already loaded, otherwise the IG will be retrieved from the user package cache (~/.fhir/packages) or from the package server and then loaded into the repository.

Parameters:

  • id_or_path (String)

    either an identifier, eg “hl7.fhir.us.core#3.1.1” or a file path, eg “./igs/uscore.tgz”

Returns:



18
19
20
21
22
23
24
25
# File 'lib/inferno/repositories/igs.rb', line 18

def find_or_load(id_or_path)
  return find(id_or_path) if exists?(id_or_path)

  ig_by_path = find_by_path(id_or_path) || find_by_path(find_local_file(id_or_path))
  return ig_by_path if ig_by_path

  load(id_or_path)
end