split up iso date formatting into 2 functions for timestamps and dates
This commit is contained in:
parent
5b2354fd0f
commit
5d8717c74c
|
@ -56,7 +56,7 @@
|
||||||
(str (:namespace value) "|" (format-search-value (:value value)))
|
(str (:namespace value) "|" (format-search-value (:value value)))
|
||||||
|
|
||||||
(instance? Date value)
|
(instance? Date value)
|
||||||
(->iso-date value)
|
(->iso-timestamp value)
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(-> value str escape-parameter)))
|
(-> value str escape-parameter)))
|
||||||
|
@ -187,3 +187,23 @@
|
||||||
(merge
|
(merge
|
||||||
(search-params->query-map where)
|
(search-params->query-map where)
|
||||||
(apply hash-map params)))))
|
(apply hash-map params)))))
|
||||||
|
|
||||||
|
;(def server-url "http://fhir.healthintersections.com.au/open")
|
||||||
|
;(def server-url "http://spark.furore.com/fhir")
|
||||||
|
(def server-url "http://uhnvesb01d.uhn.on.ca:25180/hapi-fhir-jpaserver/base")
|
||||||
|
|
||||||
|
;(get-resource server-url :patient 1)
|
||||||
|
|
||||||
|
;(get-resource server-url :patient 181)
|
||||||
|
|
||||||
|
;(search server-url :patient [(lt :birthdate "1984-12-13")])
|
||||||
|
|
||||||
|
;(search server-url :patient [(eq :birthdate "1985-01-01")])
|
||||||
|
|
||||||
|
;(search server-url :patient [(eq :birthdate "1925-08-27T00:00:00")])
|
||||||
|
;(search server-url :patient [(eq :birthdate (new Date 25 7 27))])
|
||||||
|
;(search server-url :patient [(eq :birthdate (new Date 90 0 1))])
|
||||||
|
|
||||||
|
;(search server-url :patient [(eq :name "king") (eq :age 1337)])
|
||||||
|
|
||||||
|
;(search-params->query-kvs [(eq :name "king") (eq :age 1337)])
|
||||||
|
|
|
@ -7,17 +7,25 @@
|
||||||
[cheshire.core :as json]))
|
[cheshire.core :as json]))
|
||||||
|
|
||||||
(def tz (TimeZone/getDefault))
|
(def tz (TimeZone/getDefault))
|
||||||
(def iso8601 "yyyy-MM-dd'T'HH:mm:ssZZ")
|
(def iso8601-timestamp "yyyy-MM-dd'T'HH:mm:ss")
|
||||||
|
(def iso8601-date "yyyy-MM-dd")
|
||||||
|
|
||||||
(defn ->iso-date
|
(defn format-date [^Date date ^String format]
|
||||||
"returns an ISO8601 formatted date/time string for the given date. this is the format
|
|
||||||
which FHIR expects all date/times to be in"
|
|
||||||
[^Date date]
|
|
||||||
(if date
|
(if date
|
||||||
(let [df (SimpleDateFormat. iso8601)]
|
(let [df (SimpleDateFormat. format)]
|
||||||
(.setTimeZone df tz)
|
(.setTimeZone df tz)
|
||||||
(.format df date))))
|
(.format df date))))
|
||||||
|
|
||||||
|
(defn ->iso-timestamp
|
||||||
|
"returns an ISO8601 formatted date/time string for the given date object"
|
||||||
|
[^Date date]
|
||||||
|
(format-date date iso8601-timestamp))
|
||||||
|
|
||||||
|
(defn ->iso-date
|
||||||
|
"returns an ISO8601 formatted date string for the given date object"
|
||||||
|
[^Date date]
|
||||||
|
(format-date date iso8601-date))
|
||||||
|
|
||||||
(defn map->query-string [m]
|
(defn map->query-string [m]
|
||||||
(->> m
|
(->> m
|
||||||
(reduce
|
(reduce
|
||||||
|
|
Reference in a new issue