From cc3b85a2b192dea740fa40d6ff4ebce5be4e0d17 Mon Sep 17 00:00:00 2001 From: gered Date: Tue, 8 Jul 2014 11:33:13 -0400 Subject: [PATCH] add convenience function 'search-and-fetch' --- src/clj_hl7_fhir/core.clj | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/clj_hl7_fhir/core.clj b/src/clj_hl7_fhir/core.clj index 2687d22..65166f9 100644 --- a/src/clj_hl7_fhir/core.clj +++ b/src/clj_hl7_fhir/core.clj @@ -212,7 +212,17 @@ (apply join-paths url-components) (merge (search-params->query-map where) - (apply hash-map params))))) + (apply hash-map (if (and (seq? params) + (= 1 (count params))) + (first params) + params)))))) + +(defn search-and-fetch + "same as search, but automatically fetches all pages of resources returning a single bundle + that contains all search results." + [base-url type where & params] + (fetch-all + (search base-url type where params))) ;(def server-url "http://fhir.healthintersections.com.au/open") ;(def server-url "http://spark.furore.com/fhir")