Stream: implementers
Topic: near & neardistance modifiers in fhir-client.min-js
Marcelo Cabello (Apr 08 2020 at 12:30):
Hi, recently we were wondering how to use :contains modifier trough fhir-client.min.js. We made a little change in this local library and all going well.
Now I'm wonder how should I write the syntax to use the modifier near and neardistance to perform the request {{url}}/Location?near=-32.74977:-70.708992&near-distance=110.20||km...
Our app is working along with a dstu3 fhir server. We try to avoid a direct request 'cause the structure of the code is ad-hoc to perform request through this library.
Maybe @Josh Mandel, @Abigail Watson , @Daniel Zsebedits could give us a suggestion?
Lloyd McKenzie (Apr 08 2020 at 14:14):
I think your separator for near should be '|', not ':'
Abbie Watson (Apr 08 2020 at 16:27):
Also, do check the CapabilityStatement and confirm the server supports the near
search operator. A near
operator is something of a specialized usecase, and requires either a dedicated geospatial mapping library on the server, or a geospatial index on the database (preferably both). There's quite a few sandboxes out there in the world that might have Rest enabled for the Location resources, but not have implemented the search operator yet.
Marcelo Cabello (Apr 09 2020 at 13:50):
That's rigth @Lloyd McKenzie , but the spec of dstu3 shows ":"
dstu3 -> Location?near=-83.694810:42.256500&near-distance=11.20||km...
r4 -> Location?near=-83.694810|42.256500|11.20|km...
Cheers!
Thanks @Abigail Watson , I always have to check in CapStatement for every new operation that I want to use. Fortunately, 4.2 from Hapi uses these modifiers.
The spec defines modifiers near/neardistance , but I guess algorithms which calculate distance belong to the implementation server. We developed a proof of concept using googlemaps api key, but regarding your advice, do you meant I MUST/SHOULD use another geospatial support ??
Marcelo Cabello (Apr 09 2020 at 14:02):
Hmmm... I was thinking: to calculate the distance between my position and Location resources could I use also the google api key or other similar to calculate distance and show that as a response through the near / neardistance modifiers.
@James Agnew could you tell how works the algorithms in hapi 4.2 to the use case "give me a list of locations near me inside 5 kms?" Can I simply take it and use it or do I need another support as Abigail mentioned?
Lloyd McKenzie (Apr 09 2020 at 15:13):
DSTU3 was in error, but given that it's a narrative issue, not something we'll be fixing.
Abbie Watson (Apr 09 2020 at 15:42):
If HAPI has them listed in the CapabilityStatement, you should be good to go. Just be aware that other servers might support Location REST endpoints, but not the near
search operator. So you may run into hiccups if you point your app at a different sandbox or production server.
We use the Mongo API and a specialized client side Minimongo library that supports in-memory $near
operations. So, rather than asking the server to calculate the nearest locations, we like to fetch the entire dataset when possible, and do our own proximity calculations.
James Agnew (Apr 09 2020 at 18:47):
@Marcelo Cabello near is supported in HAPI as of 4.2.0. We use a pretty naive "box" algorithm that simply draws a rectangular box around the point you gave and finds Locations within it (as opposed to a radius search, which we are also planning on implementing in the future)
Last updated: Apr 12 2022 at 19:14 UTC