redguava / cliniko-api

The API for Cliniko
74 stars 39 forks source link

Invalid date time value in API response #350

Closed evorgevol closed 3 years ago

evorgevol commented 3 years ago

I'm getting the following value when calling the API to get patient data:

"date_of_birth": "195542-07-14"

How is it possible that it's an invalid date? I'm not sure what I'm supposed to do to try and parse this value as it's assumed in the code that the value we get back is a valid date. Please let me know if there's any more information I can give privately to help with this issue.

Thanks

hagen commented 3 years ago

That is odd indeed. Could you give us the patient ID and the shard, to have a looksee?

evorgevol commented 3 years ago

au1/72038971

hagen commented 3 years ago

Thanks for that!

On discussing with the team, 195542 is - albeit a very long way into the future - a valid year. Personally, I hadn't even considered that until someone else pointed it out. And it's a poignant reminder of the Y2K bug! Ultimately, there's no upper limit on what year a date of birth may contain.

I'm sure this one was somehow entered incorrectly, but that doesn't make it an invalid date of birth. We could look at putting some sort of sensible upper limit on the year of a DOB, but I'm not really sure what that would be. If we enforce an upper limit though, I'll reply back here 👍

evorgevol commented 3 years ago

Hi Hagen, I don't know how anyone can be born in the future, so although it's theoretically a valid date, it's not a valid date for a date of birth.

Also, according to your documentation here, it should be in the format YYYY-MM-DD, which this is not.

evorgevol commented 3 years ago

Also, a lot of programming languages, including .net that I'm using, don't support more than 4 digits for years, the DateTime.MaxValue is 31/12/9999. So I'm not sure what you expect consumers of the API to do?

hagen commented 3 years ago

DOB now has an upper limit of 2150 👍