Question: FHIR date formats in JSON

Jan 4, 2013

Question:

I’m reading a bit about FHIR … and I was wondering why you choose to specify date/time as strings instead of the notation below that is commonly used in JSON and supported by e.g. MongoDB tools for queries on date values ?

e.g. “birthDate”: { “$date”: “1968-04-08T23:00:00.000Z” },

Answer:

When we considered the JSON date representation, we searched for any evidence that one of these date formats, of which there are several, was gaining real traction in the community. We could find no evidence that any one of these date formats was a clear winner, particularly in terms of support in common JSON parsing libraries.

As a consequence, we elected to use the same wire representation as all the other properties, and the same as in the XML - which happens to be, for full date times, exactly the same format you use above, though without the $date part. Note that the “$” part also causes problems for many json libraries as well - we tried to use that for something, and had to change away from that because several important platforms couldn’t work with that (I forget which ones).

JSON is real convenient for the users, but it’s very hard to use in a standard.

We’d be happy to receive solid feedback that the current solution doesn’t work with MongoDB - but note that a number of the implementers in the project team itself use MongoDB. Perhaps one of them might comment.