From 048557d4d1f108812ef69f40442f7f38dddbd35f Mon Sep 17 00:00:00 2001 From: gered Date: Mon, 8 Sep 2014 15:12:58 -0400 Subject: [PATCH] minor refactoring --- src/clj_hl7_fhir/core.clj | 15 +++------------ src/clj_hl7_fhir/util.clj | 8 ++++++++ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/clj_hl7_fhir/core.clj b/src/clj_hl7_fhir/core.clj index cd19bc5..c81ec33 100644 --- a/src/clj_hl7_fhir/core.clj +++ b/src/clj_hl7_fhir/core.clj @@ -461,10 +461,7 @@ (apply join-paths url-components) :params (merge {:_id id} - (apply hash-map (if (and (seq? params) - (= 1 (count params))) - (first params) - params)))))) + (build-params-map params))))) (defn history "returns a bundle containing the history of a single FHIR resource. note that this history can @@ -484,10 +481,7 @@ (fhir-request :get base-url (apply join-paths url-components) - :params (apply hash-map (if (and (seq? params) - (= 1 (count params))) - (first params) - params))))) + :params (build-params-map params)))) (defn search "searches for resources on a FHIR server. multiple parameters are ANDed together. use of the search @@ -510,10 +504,7 @@ :params-as-body? true :params (merge (search-params->query-map where) - (apply hash-map (if (and (seq? params) - (= 1 (count params))) - (first params) - params)))))) + (build-params-map params))))) (defn search-and-fetch "same as search, but automatically fetches all pages of resources returning a single bundle diff --git a/src/clj_hl7_fhir/util.clj b/src/clj_hl7_fhir/util.clj index 54614e2..5afd225 100644 --- a/src/clj_hl7_fhir/util.clj +++ b/src/clj_hl7_fhir/util.clj @@ -73,6 +73,14 @@ (flatten) (apply str))) +(defn build-params-map [m] + (apply + hash-map + (if (and (seq? m) + (= 1 (count m))) + (first m) + m))) + (defn join-paths [& paths] (as-> paths x (remove nil? x)