Module: FHIR::CommonDefinitions::ClassMethods
- Extended by:
- Deprecate
- Defined in:
- lib/fhir_models/bootstrap/common_definitions.rb
Class Method Summary collapse
-
.search_parameters(type_name) ⇒ Object
—————————————————————- Search Params —————————————————————-.
Instance Method Summary collapse
-
#basetype(uri) ⇒ Object
Get the basetype (String) for a given profile or extension.
- #cache ⇒ Object
- #complex_types ⇒ Object
- #create_structure_definition(definition) ⇒ Object
- #extension_definition(extension_name) ⇒ Object
- #find_structure_definition(structure_defs, target_name) ⇒ Object
- #get_codes(url) ⇒ Object
-
#get_display(system, code) ⇒ Object
Why do we have this function?.
- #ig_resources ⇒ Object
-
#load_igs(ig_file_name) ⇒ Object
This method actually just sets up lazy loading to avoid having to load everything at start time.
-
#primitive_types ⇒ Object
# —————————————————————- # Types # —————————————————————-.
-
#profile(profile_url) ⇒ Object
Get the StructureDefinition for a given profile.
- #profiles_for_resource(resource_name) ⇒ Object
- #resource_definition(resource_name) ⇒ Object
-
#resource_definitions ⇒ Object
—————————————————————- Resources, Profiles, Extensions —————————————————————-.
- #type_definition(type_name) ⇒ Object
-
#valuesets ⇒ Object
—————————————————————- ValueSet Code Expansions —————————————————————-.
Methods included from Deprecate
Class Method Details
.search_parameters(type_name) ⇒ Object
Search Params
142 143 144 |
# File 'lib/fhir_models/bootstrap/common_definitions.rb', line 142 def self.search_parameters(type_name) ig_resources.get_search_parameters(type_name) end |
Instance Method Details
#basetype(uri) ⇒ Object
Get the basetype (String) for a given profile or extension.
84 85 86 87 88 89 90 91 |
# File 'lib/fhir_models/bootstrap/common_definitions.rb', line 84 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 } return nil if defn.nil? defn['type'] end |
#cache ⇒ Object
17 18 19 |
# File 'lib/fhir_models/bootstrap/common_definitions.rb', line 17 def cache @cache ||= {} end |
#complex_types ⇒ Object
54 55 56 |
# File 'lib/fhir_models/bootstrap/common_definitions.rb', line 54 def complex_types ig_resources.complex_types end |
#create_structure_definition(definition) ⇒ Object
39 40 41 42 43 |
# File 'lib/fhir_models/bootstrap/common_definitions.rb', line 39 def create_structure_definition(definition) return nil if definition.nil? versioned_fhir_module::StructureDefinition.new(definition) end |
#extension_definition(extension_name) ⇒ Object
78 79 80 |
# File 'lib/fhir_models/bootstrap/common_definitions.rb', line 78 def extension_definition(extension_name) find_structure_definition(ig_resources.extension_definitions, extension_name) end |
#find_structure_definition(structure_defs, target_name) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fhir_models/bootstrap/common_definitions.rb', line 27 def find_structure_definition(structure_defs, target_name) return nil if target_name.nil? 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] end |
#get_codes(url) ⇒ Object
115 116 117 |
# File 'lib/fhir_models/bootstrap/common_definitions.rb', line 115 def get_codes(url) ig_resources.get_codes(url) end |
#get_display(system, code) ⇒ Object
Why do we have this function?
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/fhir_models/bootstrap/common_definitions.rb', line 120 def get_display(system, code) return nil if system.nil? || code.nil? 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 end elsif value_set['compose'] && value_set['compose']['include'] value_set['compose']['include'].each do |include_element| if include_element['system'] == system && include_element['concept'] include_element['concept'].each { |concept| reutrn concept['display'] if concept['code'] == code } end end end end end |
#ig_resources ⇒ Object
13 14 15 |
# File 'lib/fhir_models/bootstrap/common_definitions.rb', line 13 def ig_resources @ig_resources ||= @ig_loader.load end |
#load_igs(ig_file_name) ⇒ Object
This method actually just sets up lazy loading to avoid having to load everything at start time.
23 24 25 |
# File 'lib/fhir_models/bootstrap/common_definitions.rb', line 23 def load_igs(ig_file_name) @ig_loader = FHIR::Generator::IGLoader.new(ig_file_name) end |
#primitive_types ⇒ Object
# —————————————————————- # Types # —————————————————————-
49 50 51 |
# File 'lib/fhir_models/bootstrap/common_definitions.rb', line 49 def primitive_types ig_resources.primitive_types end |
#profile(profile_url) ⇒ Object
Get the StructureDefinition for a given profile.
95 96 97 |
# File 'lib/fhir_models/bootstrap/common_definitions.rb', line 95 def profile(profile_url) find_structure_definition(ig_resources.profiles, profile_url) end |
#profiles_for_resource(resource_name) ⇒ Object
100 101 102 103 104 |
# File 'lib/fhir_models/bootstrap/common_definitions.rb', line 100 def profiles_for_resource(resource_name) return nil if resource_name.nil? ig_resources.profiles.select { |x| x['type'] == resource_name } end |
#resource_definition(resource_name) ⇒ Object
73 74 75 |
# File 'lib/fhir_models/bootstrap/common_definitions.rb', line 73 def resource_definition(resource_name) find_structure_definition(resource_definitions, resource_name) end |
#resource_definitions ⇒ Object
Resources, Profiles, Extensions
68 69 70 |
# File 'lib/fhir_models/bootstrap/common_definitions.rb', line 68 def resource_definitions ig_resources.resource_definitions end |
#type_definition(type_name) ⇒ Object
59 60 61 |
# File 'lib/fhir_models/bootstrap/common_definitions.rb', line 59 def type_definition(type_name) find_structure_definition(primitive_types + complex_types, type_name) end |
#valuesets ⇒ Object
111 112 113 |
# File 'lib/fhir_models/bootstrap/common_definitions.rb', line 111 def valuesets ig_resources.get_value_sets end |