return nil if the resource could not be found (http 404)
This commit is contained in:
parent
23a4bce89c
commit
f360199e0c
|
@ -1,5 +1,6 @@
|
||||||
(ns clj-hl7-fhir.core
|
(ns clj-hl7-fhir.core
|
||||||
(:import (java.util Date))
|
(:import (java.util Date)
|
||||||
|
(clojure.lang ExceptionInfo))
|
||||||
(:require [clojure.string :as str]
|
(:require [clojure.string :as str]
|
||||||
[clj-http.client :as http]
|
[clj-http.client :as http]
|
||||||
[cheshire.core :as json])
|
[cheshire.core :as json])
|
||||||
|
@ -67,9 +68,13 @@
|
||||||
url-components (if version
|
url-components (if version
|
||||||
["/" resource-name id "_history" version]
|
["/" resource-name id "_history" version]
|
||||||
["/" resource-name id])]
|
["/" resource-name id])]
|
||||||
(fhir-get-request
|
(try
|
||||||
base-url
|
(fhir-get-request
|
||||||
(apply join-paths url-components))))
|
base-url
|
||||||
|
(apply join-paths url-components))
|
||||||
|
(catch ExceptionInfo ex
|
||||||
|
(if (not= 404 (get-in (ex-data ex) [:object :status]))
|
||||||
|
(throw ex))))))
|
||||||
|
|
||||||
(defn get-resource-bundle
|
(defn get-resource-bundle
|
||||||
"gets a single resource from a FHIR server that is contained in a bundle."
|
"gets a single resource from a FHIR server that is contained in a bundle."
|
||||||
|
|
Reference in a new issue