Class: OpenehrRails::Fhir::ProfileGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/openehr_rails/fhir/profile_generator.rb

Overview

Generates HL7 FHIR R5 StructureDefinition profiles (as plain Hashes / JSON) from an openEHR Operational Template. One profile per ENTRY: the entry's RM type selects the base FHIR resource, and the leaf ELEMENTs constrain value (single leaf) or component slices (many).

Constant Summary collapse

FHIR_VERSION =
'5.0.0'
ARCHETYPE_SYSTEM =
'http://openehr.org/ckm/archetypes'
UCUM_SYSTEM =
'http://unitsofmeasure.org'
CANONICAL_BASE =
'urn:openehr'

Instance Method Summary collapse

Constructor Details

#initialize(template) ⇒ ProfileGenerator

Returns a new instance of ProfileGenerator.



18
19
20
21
# File 'lib/openehr_rails/fhir/profile_generator.rb', line 18

def initialize(template)
  @template = template
  @entries = OpenehrRails::Opt::FieldExtractor.new(template).entries
end

Instance Method Details

#profilesObject



23
24
25
# File 'lib/openehr_rails/fhir/profile_generator.rb', line 23

def profiles
  @entries.map { |entry| build_profile(entry) }
end

#to_json_filesObject



27
28
29
# File 'lib/openehr_rails/fhir/profile_generator.rb', line 27

def to_json_files
  profiles.to_h { |profile| [profile[:id], JSON.pretty_generate(profile)] }
end