Filtering Tasks by owner type
# support
s
in the HL7 spec here: https://www.hl7.org/fhir/search_filter.html there is support for querying by nested fields eg. subject.name within an Observation - I have been unable to get this to work. I'm trying to filter TaskList by owner.type. small sample code:
Copy code
query get_tasks_list {
    TaskList(_filter: "not (owner.type eq 'HealthcareService' )") {
      id
      owner {
        display
        reference
        type
        identifier {
          id
        }
      }
    }
  }
`
this fails because owner.type is an "Unknown search parameter". Is this expected behavior? and if it is, is there another way to do what I'm wanting here?
r
Hi @stefant1707 , the feature you're referencing wrt. Observation.subject.name is called "chaining" (http://hl7.org/fhir/R4/search.html#chaining). Unfortunately, Medplum doesn't currently support chaining, but it is on our roadmap https://github.com/medplum/medplum/issues/1975
For you specific use case, I'd actually recommend enhancing your data model to annotate Tasks with your performer type (https://www.medplum.com/docs/careplans/tasks#task-assignment)
This will give you finer grained search over your Tasks by role. Instead of just filtering by resourceType (e..g Practitioner vs. HealthcareService), you can filter by the type of practitioner
s
thanks @rahul1 ! performer type will help as well - but it does come to mind, now I need to migrate all tasks to have a performer type, how do you all usually handle migrations like that?
r
That's a good question! We don't have an out-of-the-box solution for that right now, but it's something we're investigating. Usually, we either use the Medplum CLI or write a short typescript script to make the updates. Some best practices: 1. Use PATCH operations to make surgical changes, to avoid read/write race conditions (https://www.medplum.com/docs/sdk/classes/MedplumClient#patchresource) 2. Use FHIR Batch requests: http://hl7.org/fhir/R4/http.html#transaction. We actually have a constructor param for
MedplumClient
called autoBatchTime that will automatically construct batches for requests inside a specified time window
s
makes sense, thanks!
164 Views