Reputation: 41
I'm using hapi-fhir and want to sort a list of procedures by their patients lastname.
As far as I understand, a suitable serchParameter is required in order to do this.
The documentation says chaining is also supported for searchParameter, if it is of type reference.
And there is a field "chain" in the searchParameter (0..*) string, "Chained names supported") but I have no clue how to use it and I havn't found any examples.
I think this approach is a litte bit naiv and wont work:
"description": "Search by patients lastname",
"code": "function",
"base": [
"Procedure"
],
"type": "reference",
"expression": "Procedure.subject.name.family",
"xpath": "f:Procedure/f:subject/f:name/f:family",
"xpathUsage": "normal",
"multipleOr": true,
"multipleAnd": true,
"comparator": [
"eq",
"ne"
]
Does anyone can give some explanation or provide a sample ?
Thanks in advance Chris
Upvotes: 2
Views: 1223
Reputation: 2299
You are correct that you will need a valid search parameter to use in the sort, but as far as I know it cannot be a chain. See https://chat.fhir.org/#narrow/stream/179166-implementers/topic/_sort.20-.20sorting.20on.20refs for a discussion about that.
For a normal search you can use a chain, and the search parameters you mention are already in the specification. So a GET <hapi>/Procedure?patient.family=Chalmers
will work, but GET <hapi>/Procedure?_sort=patient.family
gives an error.
The expression in your search parameter is not correct, since it points to the name field within the subject field, but that does not exist. The patient's name is not part of the Procedure resource, but resides in the Patient resource. You would have to first resolve the link from Procedure to Patient, so you can then look at the name of the second. I don't know of any example in a search parameter expression that does something like that, but you could look at the FHIRPath specification for expression syntax. Whether a server can automatically support such a sort will be another thing to test.
Upvotes: 1