Module: OpenehrRails::Fhir::TypeMap
- Defined in:
- lib/openehr_rails/fhir/type_map.rb
Overview
Static mapping from openEHR Reference Model types to HL7 FHIR R5. Drives both StructureDefinition generation (M2) and the REST serializer/deserializer (M3).
Constant Summary collapse
- FHIR_BASE_URL =
'http://hl7.org/fhir/StructureDefinition'- ENTRY_RESOURCES =
openEHR ENTRY type => FHIR R5 resource type.
{ 'OBSERVATION' => 'Observation', 'EVALUATION' => 'Condition', 'INSTRUCTION' => 'ServiceRequest', 'ACTION' => 'Procedure', 'ADMIN_ENTRY' => 'Encounter' }.freeze
- DATA_VALUE_TYPES =
openEHR data value type => FHIR R5 element type (value suffix / datatype name) used in StructureDefinition element constraints.
{ 'DV_QUANTITY' => 'Quantity', 'DV_COUNT' => 'integer', 'DV_PROPORTION' => 'Ratio', 'DV_ORDINAL' => 'CodeableConcept', 'DV_TEXT' => 'string', 'DV_CODED_TEXT' => 'CodeableConcept', 'DV_IDENTIFIER' => 'Identifier', 'DV_URI' => 'url', 'DV_BOOLEAN' => 'boolean', 'DV_DATE' => 'date', 'DV_TIME' => 'time', 'DV_DATE_TIME' => 'dateTime', 'DV_DURATION' => 'Duration', 'DV_MULTIMEDIA' => 'Attachment' }.freeze
Class Method Summary collapse
- .base_definition_for_entry(rm_type) ⇒ Object
- .datatype_for(rm_type) ⇒ Object
- .resource_for_entry(rm_type) ⇒ Object
-
.value_element(resource_type) ⇒ Object
Element on the base resource whose value an openEHR leaf maps to.
Class Method Details
.base_definition_for_entry(rm_type) ⇒ Object
49 50 51 |
# File 'lib/openehr_rails/fhir/type_map.rb', line 49 def base_definition_for_entry(rm_type) "#{FHIR_BASE_URL}/#{resource_for_entry(rm_type)}" end |
.datatype_for(rm_type) ⇒ Object
45 46 47 |
# File 'lib/openehr_rails/fhir/type_map.rb', line 45 def datatype_for(rm_type) DATA_VALUE_TYPES.fetch(rm_type, 'string') end |
.resource_for_entry(rm_type) ⇒ Object
41 42 43 |
# File 'lib/openehr_rails/fhir/type_map.rb', line 41 def resource_for_entry(rm_type) ENTRY_RESOURCES.fetch(rm_type, 'Observation') end |
.value_element(resource_type) ⇒ Object
Element on the base resource whose value an openEHR leaf maps to. Single-leaf Observations use value; everything else hangs off a component (handled by the profile/serializer per resource).
56 57 58 |
# File 'lib/openehr_rails/fhir/type_map.rb', line 56 def value_element(resource_type) resource_type == 'Observation' ? 'value[x]' : 'value[x]' end |