From cdde0b47413fd3f18c6176403d900aec192cee87 Mon Sep 17 00:00:00 2001 From: ashankland Date: Thu, 2 Apr 2020 13:55:31 -0400 Subject: [PATCH 1/2] moved to new branch to avoid rebase error risk --- lib/fhir_client/sections/search.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/fhir_client/sections/search.rb b/lib/fhir_client/sections/search.rb index b28cf555..73c91015 100644 --- a/lib/fhir_client/sections/search.rb +++ b/lib/fhir_client/sections/search.rb @@ -6,6 +6,7 @@ module Search # # @param klass The type of resource to be searched. # @param options A hash of options used to construct the search query. + # @param headers A hash of headers used in the http request itself. # @return FHIR::ClientReply # def search(klass, options = {}, format = @default_format) @@ -29,7 +30,7 @@ def search_existing(klass, id, options = {}, format = @default_format) reply = if options[:search] && options[:search][:flag] post resource_url(options), nil, fhir_headers({content_type: 'application/x-www-form-urlencoded'}) else - get resource_url(options), fhir_headers + get resource_url(options), fhir_headers(headers) end reply.resource = parse_reply(klass, format, reply) reply.resource_class = klass @@ -41,7 +42,7 @@ def search_all(options = {}, format = @default_format) reply = if options[:search] && options[:search][:flag] post resource_url(options), nil, fhir_headers({content_type: 'application/x-www-form-urlencoded'}) else - get resource_url(options), fhir_headers + get resource_url(options), fhir_headers(headers) end reply.resource = parse_reply(nil, format, reply) reply.resource_class = nil From 006a1ffe4a3e84b3253626d144f10dd7b9bdb1f9 Mon Sep 17 00:00:00 2001 From: ashankland Date: Thu, 2 Apr 2020 14:02:05 -0400 Subject: [PATCH 2/2] re-added lost changes during branch migrate --- lib/fhir_client/sections/search.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/fhir_client/sections/search.rb b/lib/fhir_client/sections/search.rb index 73c91015..912b1972 100644 --- a/lib/fhir_client/sections/search.rb +++ b/lib/fhir_client/sections/search.rb @@ -1,3 +1,4 @@ + module FHIR module Sections module Search @@ -9,14 +10,15 @@ module Search # @param headers A hash of headers used in the http request itself. # @return FHIR::ClientReply # - def search(klass, options = {}, format = @default_format) + def search(klass, options = {}, format = @default_format, headers = {}) options[:resource] = klass options[:format] = format reply = if options[:search] && options[:search][:flag] - post resource_url(options), nil, fhir_headers({content_type: 'application/x-www-form-urlencoded'}) + headers[:content_type] = 'application/x-www-form-urlencoded' + post resource_url(options), nil, fhir_headers(headers) else - get resource_url(options), fhir_headers + get resource_url(options), fhir_headers(headers) end # reply = get resource_url(options), fhir_headers(options) reply.resource = parse_reply(klass, format, reply) @@ -24,11 +26,12 @@ def search(klass, options = {}, format = @default_format) reply end - def search_existing(klass, id, options = {}, format = @default_format) + def search_existing(klass, id, options = {}, format = @default_format, headers = {}) 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({content_type: 'application/x-www-form-urlencoded'}) + headers[:content_type] = 'application/x-www-form-urlencoded' + post resource_url(options), nil, fhir_headers(headers) else get resource_url(options), fhir_headers(headers) end @@ -37,10 +40,11 @@ def search_existing(klass, id, options = {}, format = @default_format) reply end - def search_all(options = {}, format = @default_format) + def search_all(options = {}, format = @default_format, headers = {}) options[:format] = format reply = if options[:search] && options[:search][:flag] - post resource_url(options), nil, fhir_headers({content_type: 'application/x-www-form-urlencoded'}) + headers[:content_type] = 'application/x-www-form-urlencoded' + post resource_url(options), nil, fhir_headers(headers) else get resource_url(options), fhir_headers(headers) end