I'd like to make a custom SearchParameter that allows me to search Specimens on the Patient's age at the time the Specimen was collected.
I've tried several permutations, but the general idea is something like this:
{
"resourceType" : "SearchParameter",
<...snip...>
"type" : "quantity",
"expression": "Specimen.iif(collection.collectedDateTime.exists(), collection.collectedDateTime - subject.resolve().birthDate, Specimen.iif(receivedTime.exists(), receivedDateTime - subject.resolve().birthDate, ''))"
}
While HAPI gladly accepts this SearchParameter, it doesn't actually seem to give any results for a search: Specimen?subjectage=gt20%7C%7Cyears
Is my FHIRPath flawed, is my understanding of how to query a duration in time incorrect, or both?