eug48 / fhir

FHIR Server using MongoDB and Go - now with proper transactions support! Aims to start quickly, have modest resource requirements and good performance.
Apache License 2.0
69 stars 16 forks source link

/Patient/nonexistentid/$everything returns 200 #7

Open 0xmichalis opened 5 years ago

0xmichalis commented 5 years ago

When querying a non-existent ID with the patient ID as the last part of the path, 404 is returned correctly but when $everything is added in the end, 200 is returned instead of 404.

$ curl -vvv localhost:3001/Patient/X32824200X
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 3001 (#0)
> GET /Patient/X32824200X HTTP/1.1
> Host: localhost:3001
> User-Agent: curl/7.54.0
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< Vary: Origin
< X-Mutex-Used: 0
< Date: Sun, 13 Oct 2019 20:05:38 GMT
< Content-Length: 0
< 
* Connection #0 to host localhost left intact

$ curl -vvv localhost:3001/Patient/X32824200X/\$everything
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 3001 (#0)
> GET /Patient/X32824200X/$everything HTTP/1.1
> Host: localhost:3001
> User-Agent: curl/7.54.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Content-Type: application/fhir+json; charset=utf-8
< Vary: Origin
< X-Mutex-Used: 0
< Date: Sun, 13 Oct 2019 20:06:05 GMT
< Content-Length: 378
< 
* Connection #0 to host localhost left intact
{"resourceType":"Bundle","meta":{"lastUpdated":"2019-10-13T20:06:05Z"},"type":"searchset","id":"5da383adfeec7576da2c0455","link":[{"relation":"self","url":"http://localhost:3001/Patient?_id=X32824200X&_offset=0&_count=100&_include=%2A&_revinclude=%2A"},{"relation":"first","url":"http://localhost:3001/Patient?_id=X32824200X&_offset=0&_count=100&_include=%2A&_revinclude=%2A"}]}

server log:

[GIN] 2019/10/13 - 20:05:44 | 404 |       7.187µs |      172.17.0.1 | GET      /Patient/X32824200X
[GIN] 2019/10/13 - 20:06:05 | 200 |    9.484635ms |      172.17.0.1 | GET      /Patient/X32824200X/$everything
eug48 commented 5 years ago

I can't see the FHIR specification definitively stating that 404 should be returned, so your code probably shouldn't rely on a 404 (http://www.hl7.org/fhir/patient-operation-everything.html). However I'd be happy to match HAPI's behaviour of returning a 404. A patch would be welcome.