Fork me on GitHub
#datomic
<
2019-01-19
>
dpsutton04:01:23

in a query, i want to find things by year and month and i plan to pass this to frequencies. here ?start is an instant. Can someone help me unify ?date-string with the string concatenation of the year and month? I'm stumbling for some reason

(d/q '[:find ?date-string
             :in $ ?encounter
             :where
             [?encounter :fhir.Encounter/period ?period]
             [?period :fhir.Period/start ?start]
             [?date-string (str (.getYear ?start) "-" (.getMonth ?start))]] 
          db encounter-id)

dpsutton04:01:25

if anyone has the same problem, its because i was doing way too much work in one unification clause. split the get years and string concatenation and bob's your uncle

favila05:01:30

You have the parts of the clause backwards

favila05:01:19

[(str (.getYear ?start) "-" (.getMonth ?start)) ?date-string]

favila05:01:52

Also you will need a :with if you want a count of dates. (Remember the results are a set unless you use with)

favila05:01:08

Or you can do this instead:

favila05:01:45

:find ?date-string (count ?encounter-id)

favila05:01:53

Now you don’t need frequencies