hapifhir / hapi-fhir

🔥 HAPI FHIR - Java API for HL7 FHIR Clients and Servers
http://hapifhir.io
Apache License 2.0
2k stars 1.31k forks source link

Problem with filtering resources by date #2352

Open oleksii-donets opened 3 years ago

oleksii-donets commented 3 years ago

Describe the bug When I try to obtain FHIR resources with the following URL and specified Authentication token all works fine: https://api.logicahealth.org/dsdtest/data/Observation?patient=16852 After executing this request I get 22 resources.

But when I try to obtain FHIR resources with the following URL with date parameter and specified Authentication token then I found no resources: https://api.logicahealth.org/dsdtest/data/Observation?patient=16852&data=gt2010-01-01

The problem is all my resources were created after 2010-01-01. So data filter looks like works wrong. Also lt, ge, le doesn't work.

Environment (please complete the following information):

jamesagnew commented 3 years ago

Hi @oleksii-donets - Are you able to reproduce this issue on our public server ( hapi.fhir.org )?

oleksii-donets commented 3 years ago

Hello @jamesagnew I've just checked it.

DSTU2 version doesn't work as expected. http://hapi.fhir.org/baseDstu2/Observation?patient=200033 - return 45 resources with a date greater than 2010-01-01 http://hapi.fhir.org/baseDstu2/Observation?patient=200033&date=gt2010-01-01 - return 0 resources

R4 version works as expected: http://hapi.fhir.org/baseR4/Observation?patient=593321&date=gt2010-01-01

oleksii-donets commented 3 years ago

I found a more precise cause of the error: Hapi server DSTU2 doesn't work with the following date format: 2018-11-04 But it works with the following date format: 2018-11-04T00:00:00

Both of these date formats are valid due to DSTU2 specification: http://www.hl7.org/fhir/DSTU2/search.html#date

jamesagnew commented 3 years ago

Oh interesting.

Does that match what you see on the logica sandbox? (i.e. DSTU2 doesn't work, but R3+ does)

oleksii-donets commented 3 years ago

Yes, logica sandbox has the same wrong behavior.

By the way, logica sandbox under the hood uses Hapi Fhir server 5.2.0 | DSTU2. So it's a bug inside Hapi.