I want to get the 30 patients who most-recently signed a contract. (If there are 1000 patients total, I don’t want the other 970 patients who signed contracts less-recently to be returned.)
Here is a query to get all Patients, with their Contracts and QuestionnaireResponses:
is it now possible to sort the result by
how about filtering? Is it possible to filter by
I can’t just get all results and post-process, because the number of patients is too large to hold in memory.
I’m aware that I could do this:
But I’d rather not because this is part of a larger application that needs to sort by various values on either Patient, QuestionnaireResponse or Contract. If possible, I’d prefer to write a single query with varying parameters for each type of sorting, rather than 3 separate queries depending on what is being sorted on. Plus then I’d need references from Contract to QuestionnaireResponse as well.