Module: FHIR::Sections::Operations

Included in:
Client
Defined in:
lib/fhir_client/sections/operations.rb

Instance Method Summary collapse

Instance Method Details

#closure_table_maintenance(params = {}, format = @default_format) ⇒ Object

ConceptMap Closure Table Maintenance



85
86
87
88
89
# File 'lib/fhir_client/sections/operations.rb', line 85

def closure_table_maintenance(params = {}, format = @default_format)
  options = { operation: { name: :closure_table_maintenance } }
  options.deep_merge!(params)
  terminology_operation(options, format)
end

#code_system_lookup(params = {}, format = @default_format) ⇒ Object

Concept Look Up [base]/CodeSystem/$lookup



71
72
73
74
75
# File 'lib/fhir_client/sections/operations.rb', line 71

def code_system_lookup(params = {}, format = @default_format)
  options = { resource: FHIR::CodeSystem, operation: { name: :code_system_lookup } }
  options.deep_merge!(params)
  terminology_operation(options, format)
end

#concept_map_translate(params = {}, format = @default_format) ⇒ Object

ConceptMap Translation



78
79
80
81
82
# File 'lib/fhir_client/sections/operations.rb', line 78

def concept_map_translate(params = {}, format = @default_format)
  options = { resource: FHIR::ConceptMap, operation: { name: :concept_map_translate } }
  options.deep_merge!(params)
  terminology_operation(options, format)
end

#fetch_encounter_record(id = nil, method = 'GET', format = @default_format) ⇒ Object



17
18
19
# File 'lib/fhir_client/sections/operations.rb', line 17

def fetch_encounter_record(id = nil, method = 'GET', format = @default_format)
  fetch_record(id, [nil, nil], method, FHIR::Encounter, format)
end

#fetch_patient_record(id = nil, startTime = nil, endTime = nil, method = 'GET', format = @default_format) ⇒ Object

Fetch Patient Record [base]/Patient/$everything | [base]/Patient//$everything hl7.org/implement/standards/FHIR-Develop/patient-operations.html#everything Fetches resources for a given patient record, scoped by a start and end time, and returns a Bundle of results



13
14
15
# File 'lib/fhir_client/sections/operations.rb', line 13

def fetch_patient_record(id = nil, startTime = nil, endTime = nil, method = 'GET', format = @default_format)
  fetch_record(id, [startTime, endTime], method, FHIR::Patient, format)
end

#fetch_record(id = nil, time = [nil, nil], method = 'GET', klass = FHIR::Patient, format = @default_format) ⇒ 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
46
# File 'lib/fhir_client/sections/operations.rb', line 21

def fetch_record(id = nil, time = [nil, nil], method = 'GET', klass = FHIR::Patient, format = @default_format)
  options = { resource: klass, format: format, operation: { name: :fetch_patient_record, method: method } }
  options.deep_merge!(id: id) unless id.nil?
  options[:operation][:parameters] = {} if options[:operation][:parameters].nil?
  options[:operation][:parameters][:start] = { type: 'Date', value: time.first } unless time.first.nil?
  options[:operation][:parameters][:end] = { type: 'Date', value: time.last } unless time.last.nil?

  if options[:operation][:method] == 'GET'
    reply = get resource_url(options), fhir_headers(options)
  else
    # create Parameters body
    if options[:operation] && options[:operation][:parameters]
      p = FHIR::Parameters.new
      options[:operation][:parameters].each do |key, value|
        parameter = FHIR::Parameters::Parameter.new.from_hash(name: key.to_s)
        parameter.method("value#{value[:type]}=").call(value[:value])
        p.parameter << parameter
      end
    end
    reply = post resource_url(options), p, fhir_headers(options)
  end

  reply.resource = parse_reply(FHIR::Bundle, format, reply)
  reply.resource_class = options[:resource]
  reply
end

#terminology_operation(params = {}, format = @default_format) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/fhir_client/sections/operations.rb', line 91

def terminology_operation(params = {}, format = @default_format)
  options = { format: format }
  # params = [id, code, system, version, display, coding, codeableConcept, date, abstract]
  options.deep_merge!(params)

  if options[:operation][:method] == 'GET'
    reply = get resource_url(options), fhir_headers(options)
  else
    # create Parameters body
    if options[:operation] && options[:operation][:parameters]
      p = FHIR::Parameters.new
      options[:operation][:parameters].each do |key, value|
        parameter = FHIR::Parameters::Parameter.new.from_hash(name: key.to_s)
        parameter.method("value#{value[:type]}=").call(value[:value])
        p.parameter << parameter
      end
    end
    reply = post resource_url(options), p, fhir_headers(options)
  end

  reply.resource = parse_reply(options[:resource], format, reply)
  reply.resource_class = options[:resource]
  reply
end

#value_set_code_validation(params = {}, format = @default_format) ⇒ Object

Value Set based Validation [base]/ValueSet/$validate | [base]/ValueSet//$validate hl7.org/implement/standards/FHIR-Develop/valueset-operations.html#validate Validate that a coded value is in the set of codes allowed by a value set.



64
65
66
67
68
# File 'lib/fhir_client/sections/operations.rb', line 64

def value_set_code_validation(params = {}, format = @default_format)
  options = { resource: FHIR::ValueSet, operation: { name: :value_set_based_validation } }
  options.deep_merge!(params)
  terminology_operation(options, format)
end

#value_set_expansion(params = {}, format = @default_format) ⇒ Object

Value Set Expansion [base]/ValueSet/$expand | [base]/ValueSet//$expand hl7.org/implement/standards/FHIR-Develop/valueset-operations.html#expand The definition of a value set is used to create a simple collection of codes suitable for use for data entry or validation.



55
56
57
58
59
# File 'lib/fhir_client/sections/operations.rb', line 55

def value_set_expansion(params = {}, format = @default_format)
  options = { resource: FHIR::ValueSet, operation: { name: :value_set_expansion } }
  options.deep_merge!(params)
  terminology_operation(options, format)
end