Module: FHIR::VersionManagement

Included in:
Client, ClientReply
Defined in:
lib/fhir_client/version_management.rb

Instance Method Summary collapse

Instance Method Details

#versioned_format_class(format = nil) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fhir_client/version_management.rb', line 21

def versioned_format_class(format = nil)
  if @fhir_version == :dstu2
    case format
    when nil
      @default_format.include?('xml') ?
          FHIR::Formats::ResourceFormat::RESOURCE_XML_DSTU2 :
          FHIR::Formats::ResourceFormat::RESOURCE_JSON_DSTU2
    when :xml
      FHIR::Formats::ResourceFormat::RESOURCE_XML_DSTU2
    else
      FHIR::Formats::ResourceFormat::RESOURCE_JSON_DSTU2
    end
  else
    case format
    when nil
      @default_format.include?('xml') ?
          FHIR::Formats::ResourceFormat::RESOURCE_XML :
          FHIR::Formats::ResourceFormat::RESOURCE_JSON
    when :xml
      FHIR::Formats::ResourceFormat::RESOURCE_XML
    else
      FHIR::Formats::ResourceFormat::RESOURCE_JSON
    end
  end
end

#versioned_resource_class(klass = nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fhir_client/version_management.rb', line 4

def versioned_resource_class(klass = nil)
  mod = case @fhir_version
        when :stu3
          FHIR::STU3
        when :dstu2
          FHIR::DSTU2
        when :r4b
          FHIR::R4B
        when :r5
          FHIR::R5
        else
          FHIR
        end
  return mod if klass.nil?
  mod.const_get(klass)
end