thomabig
05/08/2026, 9:48 PMAndy
05/11/2026, 11:30 PMstatus field of a linked resource, you should be able to use the _has chained search, as that allows you to filter Patients based on properties of resources that reference them. More details on using _has can be found [here](https://www.medplum.com/docs/search/chained-search#reverse-chained-search).
As for the extension issue–what specific values are you querying on within the extension field? This would impact the best solution.thomabig
05/12/2026, 12:56 PMAndy
05/12/2026, 10:39 PM_filter and construct a query that accomplishes something similar to _has using search parameters, though it'll be a bit more involved to write up the logic. As far as your question about external DB use–this might work, but it sort of defeats much of the purpose of using Medplum as a compliant data store. I would say this should be a last resort move (if it comes to this, we have some data warehouse work in progress that might make the porting of data a bit easier). With that being said, here are two alternative options for your two examples:
**Example 1**–Run the same query you sent along, sorting the Procedure resources by _lastUpdated, but also add a limit to the count so that you're not getting every procedure returned to the client. Then perform client side sorting on the lastUpdated field. This will require you to retrieve all Patient records at once, so client side operations could become tough if you're working with thousands of patients.
Example 2-Use the meta.tag field to store whether it's URGENT or not within the patient. This allows you to filter directly on the Patient resource using the _tag filter. If the extension you mentioned lives on the patient resource, you could accomplish this by simply adding the field wherever you create your Patient resources. However, if it's in an extension of another resource, you'll want to setup a Bot + Subscription to make updates to the Patient's meta.tag anytime that resource or value changes. You'll also have to update this on past Patient resources retroactively.
I hope this helps!