Categorize resources for filtering
# support
m
Hi Medplum team, I'm working on modeling my system and I need to categorize my Patient resources into two types: caregivers and care recipients. My goal is to be able to easily filter patients by category — for example, retrieve all patients that are caregivers, or all that are care recipients. I tried storing this information as an extension with a valueCode, but I understand that it's not possible to filter by extension values in search queries (either REST or GraphQL). Is there a recommended way to implement this kind of categorization in Medplum? What would be the best approach to enable this kind of filtering? Thanks a lot in advance!
i
Hi @Mauricio . Can you expand on your use case here? How are the caregivers patients?
m
Hi @Ian Plunkett , thanks for the quick reply! In our model, both the caregiver and the care recipient can receive treatments. That’s why we’re modeling both of them as Patient resources. We’re using the link attribute to represent the relationship between the caregiver and the care recipient. What we need is a way to distinguish if a given Patient is acting as a caregiver or a care recipient, so we can filter them accordingly in our system (e.g., show only caregivers in some views). Thanks again!
i
will the patients always fall into the bucket of caregiver or care recipient?
If they do, you could use the
system
component of the
identifier
field to bucket them in the individual groups. You could then do searches like
Copy code
medplum get 'Patient?identifier:system=https://yoursystem/caregiver'
medplum get 'Patient?identifier:system=https://yoursystem/carerecipient'
That said, I would probably suggest modeling the caregivers as Practitioners when they aren't receiving treatment and then using a second Patient resource when they are receiving treatment
161 Views