Sha256: 284f9f4213fc91045a4413b6a28267cb05dcbfd8413d945f8b8c3084b7682724

Contents?: true

Size: 1.83 KB

Versions: 12

Compression:

Stored size: 1.83 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[:search] && options[:search][:flag]
                  post resource_url(options), nil, fhir_headers(options)
                else
                  get resource_url(options), fhir_headers(options)
                end
        # reply = get resource_url(options), fhir_headers(options)
        reply.resource = parse_reply(klass, format, reply)
        reply.resource_class = klass
        reply
      end

      def search_existing(klass, id, options = {}, format = @default_format)
        options.merge!(resource: klass, id: id, format: format)
        # if options[:search][:flag]
        reply = if options[:search] && options[:search][:flag]
                  post resource_url(options), nil, fhir_headers(options)
                else
                  get resource_url(options), fhir_headers(options)
                end
        reply.resource = parse_reply(klass, format, reply)
        reply.resource_class = klass
        reply
      end

      def search_all(options = {}, format = @default_format)
        options[:format] = format
        reply = if options[:search] && options[:search][:flag]
                  post resource_url(options), nil, fhir_headers(options)
                else
                  get resource_url(options), fhir_headers(options)
                end
        reply.resource = parse_reply(nil, format, reply)
        reply.resource_class = nil
        reply
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
fhir_client-3.0.7 lib/fhir_client/sections/search.rb
fhir_client-3.0.6 lib/fhir_client/sections/search.rb
fhir_client-3.0.5 lib/fhir_client/sections/search.rb
fhir_client-3.0.4 lib/fhir_client/sections/search.rb
fhir_client-3.0.3 lib/fhir_client/sections/search.rb
fhir_client-3.0.2 lib/fhir_client/sections/search.rb
fhir_client-3.0.1 lib/fhir_client/sections/search.rb
fhir_client-1.8.0 lib/fhir_client/sections/search.rb
fhir_client-1.6.10 lib/fhir_client/sections/search.rb
fhir_client-1.6.9 lib/fhir_client/sections/search.rb
fhir_client-1.6.8 lib/fhir_client/sections/search.rb
fhir_client-1.6.7 lib/fhir_client/sections/search.rb