FHIR seach with reverse chaining

Hi,

I’m using fhir’s search and i want to seach for a appointment with some enconter’s attributes. We decided to use a reverse chaining and i dont know if we are doing the seach correctly, for example:

  1. Appoitments with encounter finished
    –Search: /Appointment/?_has:Encounter:status:text=finished

  2. Appoitments with encounter finished and any type code
    –Search /Appointment/?_has:Encounter:status:text=finished&_has:Encounter:type:code=xxxXXXxx

We are in the right way or have we done something wrong?

Still talking about reverse chaining, how to search the appoitments with encounter’s type especifying code and system together? Should it be something like this /Appointment/?_has:Encounter:status:text=finished&_has:Encounter:type:code=xxxXXXxx&_has:Encounter:type:system=xxxXXXxx?

Thanks.

There shouldn’t be a ‘/’ before the ‘?’. Also, why are you saying status:text? status is a code, so it’ll never have a display name or text to match against. What you should have is:
[base]/Appointment?_has:Encounter:appointment:status=finished

i.e. Find Encounters whose ‘appointment’ search criteria matches on this appointment and that have a status of finished.

Your second example would be:
[base]/Appointment?_has:Encounter:appointment:status=finished&_has:Encounter:appointment:type=xxxXXXxx

Keep in mind though that there’s no requirement that the Encounters that satisfy each of those ‘has’ clauses be the same. So long as you presume that only one Encounter can point to a given appointment you’re fine, but if it’s possible there could be more than one, you’ll get a match if one is finished and the other has a matching type.