Sha256: d6fa52663358e143613aa236a8b3c74f009b2e93366288028af31e8b6f32c385

Contents?: true

Size: 1.34 KB

Versions: 6

Compression:

Stored size: 1.34 KB

Contents

module FHIR
  module Sections
    module Search
      #
      # Search a set of resources of a given type.
      #
      # @param klass The type of resource to be searched.
      # @param options A hash of options used to construct the search query.
      # @return FHIR::ClientReply
      #
      def search(klass, options = {}, format = @default_format)
        options[:resource] = klass
        options[:format] = format

        reply = if options.dig(:search, :flag) != true && options.dig(:search, :body).nil?
                  get resource_url(options), fhir_headers
                else
                  options[:search][:flag] = true
                  post resource_url(options), options.dig(:search, :body), fhir_headers({content_type: 'application/x-www-form-urlencoded'})
                end

        reply.resource = parse_reply(klass, format, reply)
        reply.resource_class = klass
        reply
      end

      # It does not appear that this is part of the specification (any more?)
      # Investigate removing in next major version.
      def search_existing(klass, id, options = {}, format = @default_format)
        options[:id] = id
        search(klass, options, format)
      end

      def search_all(options = {}, format = @default_format)
        options[:format] = format
        search(nil, options, format)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fhir_client-6.0.0 lib/fhir_client/sections/search.rb
fhir_client-5.0.3 lib/fhir_client/sections/search.rb
fhir_client-5.0.2 lib/fhir_client/sections/search.rb
fhir_client-5.0.1 lib/fhir_client/sections/search.rb
fhir_client-5.0.0 lib/fhir_client/sections/search.rb
fhir_client-4.0.6 lib/fhir_client/sections/search.rb