Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FI-3180 Remove examples, schema, and expansions from gem package #116

Merged
merged 4 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions fhir_models.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ Gem::Specification.new do |spec|
spec.description = %q{A Gem for handling FHIR models in ruby}
spec.homepage = 'https://github.com/fhir-crucible/fhir_models'

spec.files = `git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^(test|spec|features)/})
end
spec.files = `git ls-files -z lib LICENSE`.split("\x0")
spec.files.reject! { |file| file =~ /lib\/fhir_models\/examples|lib\/fhir_models\/definitions/}
spec.files.reject! { |file| file =~ /lib\/fhir_models\/igs\/hl7.fhir..*\.core\/package_supplement\/expansions.json/}
spec.bindir = 'exe'
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']
Expand Down
42 changes: 25 additions & 17 deletions lib/fhir_models/bootstrap/common_definitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,30 @@ def self.included(base)
module ClassMethods
extend FHIR::Deprecate

def ig_resources
@ig_resources ||= @ig_loader.load
end

def cache
@cache ||= {}
end

# This method actually just sets up lazy loading to avoid having to load
# everything at start time.
def load_igs(ig_file_name)
ig_loader = FHIR::Generator::IGLoader.new(ig_file_name)
@ig_resources = ig_loader.load
@cache = {}
@ig_loader = FHIR::Generator::IGLoader.new(ig_file_name)
end

def find_structure_definition(structure_defs, target_name)
return nil if target_name.nil?
return @cache[target_name] if @cache[target_name]
return cache[target_name] if cache[target_name]

definition = structure_defs.find do |sd|
sd['id'] == target_name || sd['name'] == target_name || sd['url'] == target_name
end

@cache[target_name] = create_structure_definition(definition) if definition
@cache[target_name]
cache[target_name] = create_structure_definition(definition) if definition
cache[target_name]
end

def create_structure_definition(definition)
Expand All @@ -39,12 +47,12 @@ def create_structure_definition(definition)
# # ----------------------------------------------------------------

def primitive_types
@ig_resources.primitive_types
ig_resources.primitive_types
end
deprecate :get_primitive_types, :primitive_types

def complex_types
@ig_resources.complex_types
ig_resources.complex_types
end
deprecate :get_complex_types, :complex_types

Expand All @@ -58,7 +66,7 @@ def type_definition(type_name)
# ----------------------------------------------------------------

def resource_definitions
@ig_resources.resource_definitions
ig_resources.resource_definitions
end
deprecate :get_resource_definitions, :resource_definitions

Expand All @@ -68,15 +76,15 @@ def resource_definition(resource_name)
deprecate :get_resource_definition, :resource_definition

def extension_definition(extension_name)
find_structure_definition(@ig_resources.extension_definitions, extension_name)
find_structure_definition(ig_resources.extension_definitions, extension_name)
end
deprecate :get_extension_definition, :extension_definition

# Get the basetype (String) for a given profile or extension.
def basetype(uri)
return nil if uri.nil?

defn = @ig_resources.profiles.detect { |x| x['url'] == uri } || @ig_resources.extension_definitions.detect { |x| x['url'] == uri }
defn = ig_resources.profiles.detect { |x| x['url'] == uri } || ig_resources.extension_definitions.detect { |x| x['url'] == uri }
return nil if defn.nil?

defn['type']
Expand All @@ -85,14 +93,14 @@ def basetype(uri)

# Get the StructureDefinition for a given profile.
def profile(profile_url)
find_structure_definition(@ig_resources.profiles, profile_url)
find_structure_definition(ig_resources.profiles, profile_url)
end
deprecate :get_profile, :profile

def profiles_for_resource(resource_name)
return nil if resource_name.nil?

@ig_resources.profiles.select { |x| x['type'] == resource_name }
ig_resources.profiles.select { |x| x['type'] == resource_name }
end
deprecate :get_profiles_for_resource, :profile_for_resource

Expand All @@ -101,18 +109,18 @@ def profiles_for_resource(resource_name)
# ----------------------------------------------------------------

def valuesets
@ig_resources.get_value_sets
ig_resources.get_value_sets
end

def get_codes(url)
@ig_resources.get_codes(url)
ig_resources.get_codes(url)
end

# Why do we have this function?
def get_display(system, code)
return nil if system.nil? || code.nil?

@ig_resources.get_value_sets.each do |value_set|
ig_resources.get_value_sets.each do |value_set|
if value_set['expansion'] && value_set['expansion']['contains']
value_set['expansion']['contains'].each do |contain|
return contain['display'] if contain['system'] == system && contain['code'] == code
Expand All @@ -132,7 +140,7 @@ def get_display(system, code)
# ----------------------------------------------------------------

def self.search_parameters(type_name)
@ig_resources.get_search_parameters(type_name)
ig_resources.get_search_parameters(type_name)
end
deprecate :get_search_parameters, :search_parameters
end
Expand Down
Loading