minor refactoring

This commit is contained in:
Gered 2014-09-08 15:12:58 -04:00
parent ed4d571cf5
commit 048557d4d1
2 changed files with 11 additions and 12 deletions

View file

@ -461,10 +461,7 @@
(apply join-paths url-components) (apply join-paths url-components)
:params (merge :params (merge
{:_id id} {:_id id}
(apply hash-map (if (and (seq? params) (build-params-map params)))))
(= 1 (count params)))
(first params)
params))))))
(defn history (defn history
"returns a bundle containing the history of a single FHIR resource. note that this history can "returns a bundle containing the history of a single FHIR resource. note that this history can
@ -484,10 +481,7 @@
(fhir-request :get (fhir-request :get
base-url base-url
(apply join-paths url-components) (apply join-paths url-components)
:params (apply hash-map (if (and (seq? params) :params (build-params-map params))))
(= 1 (count params)))
(first params)
params)))))
(defn search (defn search
"searches for resources on a FHIR server. multiple parameters are ANDed together. use of the 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-as-body? true
:params (merge :params (merge
(search-params->query-map where) (search-params->query-map where)
(apply hash-map (if (and (seq? params) (build-params-map params)))))
(= 1 (count params)))
(first params)
params))))))
(defn search-and-fetch (defn search-and-fetch
"same as search, but automatically fetches all pages of resources returning a single bundle "same as search, but automatically fetches all pages of resources returning a single bundle

View file

@ -73,6 +73,14 @@
(flatten) (flatten)
(apply str))) (apply str)))
(defn build-params-map [m]
(apply
hash-map
(if (and (seq? m)
(= 1 (count m)))
(first m)
m)))
(defn join-paths [& paths] (defn join-paths [& paths]
(as-> paths x (as-> paths x
(remove nil? x) (remove nil? x)