Stream: implementers
Topic: AuditEvent search parameters 'patient' expression R4
Angus Millar (Sep 17 2018 at 09:22):
I was digging into why a Patient compartment search was not working for AuditEvent search, on a server implementation, this search:
[base]/Patient/FCC-PAT-00001/AuditEvent
where I knew I had an AuditEvent for this patient 'FCC-PAT-00001'
It turned out that the 'patient' search parameter was never being indexed based on the FHIR path expression for the search parameter. That Search parameter being 'patient' on the AuditEvent resource. The expression in the FHIR R4 spec definitions.xml file SearchParameters resource for this parameter was this:
Expression = AuditEvent.agent.who.where(resolve() is Patient) | AuditEvent.entity.what.where(resolve() is Patient)
In the FHIR .NET API that expression fails on 'resolve()'. I'm no FHIR path expert but I think 'resolve()' means got get the resource the ResourceReference points to. That's never going to happen in this context, well not for me. I feel that the expression should be this, which then works for me .
Expression = AuditEvent.entity.what.where(reference.startsWith('Patient')) | AuditEvent.agent.who.where(reference.startsWith('Patient'))
Does anyone else agree with me that the currect expression in the R4 Spec is wrong? It can be found here: http://hl7.org/fhir/2018Sep/auditevent.html#search
Grahame Grieve (Sep 17 2018 at 09:25):
not it's not wrong. I understand why you don't like it, but the change you propose would only be right if only local references are allowed
Grahame Grieve (Sep 17 2018 at 09:25):
we've actually removed this in R4
Angus Millar (Sep 17 2018 at 09:30):
not it's not wrong. I understand why you don't like it, but the change you propose would only be right if only local references are allowed
Humm, good point did not think of that. Still, don't understand how it works as it is though.
Actualy I now feel the issue lies with the .NET R4 FHIR Path expression implementation. The FHIR Path spec says this for resolve():
"The items in the collection may also represent a Reference, in which case the Reference.reference is resolved."
That appears to not happen.
Grahame Grieve (Sep 17 2018 at 12:26):
then you can make a task but I think actually it is implemented but you need to implement some kind of service (@Brian Postlethwaite )
Brian Postlethwaite (Sep 17 2018 at 12:30):
I'm not sure on that one.
Brian Postlethwaite (Sep 17 2018 at 12:31):
In my server I'm going to be reprocessing those specific fhirpath queries with specific code so that it dowant actually resolve, but checks that it is a patient reference.
Brian Postlethwaite (Sep 17 2018 at 12:32):
Haven't done it yet though
Angus Millar (Sep 17 2018 at 13:05):
Well it is a little ugly but I can't see how it will fail unless someone creates a server base with '/Patient/' within. So I chnanged the expression to this:
Expression = $"AuditEvent.entity.what.where(reference.startsWith('Patient/') or reference.contains('/Patient/')) | AuditEvent.agent.who.where(reference.startsWith('Patient/') or reference.contains('/Patient/'))";
Brian Postlethwaite (Sep 17 2018 at 13:11):
And don't need to hit the DB either, and read the whole resource just to find out if it is a patient.
Angus Millar (Sep 17 2018 at 14:02):
Yeah exsactly ,that was what I never wanted to do and yet that older expression was implying that is what was to happen.
John Moehrke (Sep 17 2018 at 14:05):
are the patterns intended to be literal? Or instructional? I expected a system could optimize the query parameters in many ways based on their technology.
John Moehrke (Sep 17 2018 at 14:08):
where is it that you see the specific language you have shown? In the AuditEvent there is only AuditEvent.agent.who.where(resolve() is Patient) | AuditEvent.entity.what.where(resolve() is Patient)
Angus Millar (Sep 17 2018 at 14:30):
I changed the FHIR Path in the specification, as you have posted, to a different FHIR Path expression for my use case as I posted. The issue I have with the one in the spec is that it tries to resolve to a Patient resource instance rather than a ResourceReferance to a Patient resource. Given the expression is in a SearchParameterDefinition Resource and that search paramter is defined as a search type 'reference' I would personaly expect the FHIR Path expression to resolve to a ResourceReferance and not a Resource instance.
Angus Millar (Sep 17 2018 at 14:32):
As a server implementation I expected the SearchParameterDefinition expressions to be literal as I process them programaticaly to create search indexes. Personaly I though that was the intent.
John Moehrke (Sep 17 2018 at 15:04):
I am happy to entertain an improvement submitted as a change request. You are likely correct in that this expression was written before Reference changed to include identifier... so I am not sure what would be a proper expression today. Happy to see recommendations.
Grahame Grieve (Sep 19 2018 at 00:59):
@Angus Millar I'm confused by this:
Grahame Grieve (Sep 19 2018 at 00:59):
The issue I have with the one in the spec is that it tries to resolve to a Patient resource instance rather than a ResourceReferance to a Patient resource. Given the expression is in a SearchParameterDefinition Resource and that search paramter is defined as a search type 'reference' I would personaly expect the FHIR Path expression to resolve to a ResourceReferance and not a Resource instance
Grahame Grieve (Sep 19 2018 at 00:59):
it does
Grahame Grieve (Sep 19 2018 at 01:00):
resolve to a reference, that is. Unless you mean something different by "ResourceReference"
Angus Millar (Sep 19 2018 at 01:24):
Lookig again Graham you are correct, the .where(resolve() is Patient)
portion should retun a Reference.reference as is stated by the FHIR Path specification for resolve() as below. So my root problem is that the .NET FHIR API FHIR Path is not handleing resolve for me as documented. I will try address that in the dotnet stream.
B.3.3. resolve() : collection For each item in the collection, if it is a string, locate the target of the reference, and add it to the resulting collection. If the item is not a string, the item is ignored and nothing is added to the output collection. The items in the collection may also represent a Reference, in which case the Reference.reference is resolved. If fetching the resource fails, the failure message is added to the output collection.
Last updated: Apr 12 2022 at 19:14 UTC