Open granadacoder opened 3 years ago
To generate that specific query pattern, this is the only way with the generic client:
client
.search()
.forResource("Patient")
.where(IAnyResource.RES_ID
.exactly()
.codes(
"b24ee88c-a396-4bdc-8352-7a2bc392e08d",
"0712b251-1071-4d77-93a5-4cc37c0d314e",
"a5325ff2-b6a1-4379-ae3f-fbc097e1e508"))
.returnBundle(Bundle.class)
.execute();
TokenParam is intended to model a single value, it can't be used for multiple values. TokenOrListParam and TokenAndListParam are the comma-seaparated list equivalents. Unfortunately there isn't a way to pass that class into the client currently (it's only used in the server side).
PR to add support would gladly be considered...
Ok. Thanks for the hint (code you showed) as a non-string-magic workaround.
I will try to find time to work on a PR.
As we've heard in the conferences, it was like "What is Fhir?", "What is Fhir?", "What is Fhir?"...........and then "WHY AREN'T ALL OUR SYSTEMS FHIR SYSTEMS???!!".
Thanks.
So the _id parameter. Most implementations seem to support multiple values.
Below examples have 3 comma separated values (and actually brings back results when I wrote this)
http://hapi.fhir.org/baseR4/Patient?_id=b24ee88c-a396-4bdc-8352-7a2bc392e08d,0712b251-1071-4d77-93a5-4cc37c0d314e,a5325ff2-b6a1-4379-ae3f-fbc097e1e508
https://vonk.fire.ly/R4/Patient?_id=111,222,223
http://wildfhir4.aegis.net/fhir4-0-0/Patient/?_id=99b1a3a8-b871-41a8-bd6b-65eec2d6cdc4&_id=54cd03d31c704327aae493302b6cde88&_id=bac66735217842a0b839fed35a7a1fc4&_id=500377072fa14833bf38b55dfbab37cf
I am unable to get this kind of query using IQueryParameterType
I tried this:
The gives me:
Patient?_id=99b1a3a8-b871-41a8-bd6b-65eec2d6cdc4&_id=54cd03d31c704327aae493302b6cde88&_id=bac66735217842a0b839fed35a7a1fc4&_id=500377072fa14833bf38b55dfbab37cf
(the above result is kinda expected of course..........but does not do the _id=111,222,223 thing.)
===
Then I tried a comma sep list (csv).
The above gives me:
Patient?_id=54cd03d31c704327aae493302b6cde88%5C%2Cbac66735217842a0b839fed35a7a1fc4%5C%2C500377072fa14833bf38b55dfbab37cf
or vonk-ints
https://server.fire.ly/R4/Patient?_id=111**%5C**,222**%5C**,223
(The above ones go hay wire :) with the result (500) )
If there is an existing way to do it, and I just did not figure out the syntax sugar, my apologies.
I looked through the other classes off of:
Interface IQueryParameterType
All Known Implementing Classes: BaseCodingDt, BaseIdentifierDt, BaseParam, BaseParamWithPrefix, BaseQuantityDt, CompositeParam, DateParam, HasParam, InternalCodingDt, MarkdownDt, NumberParam, QuantityParam, ReferenceParam, SpecialParam, StringDt, StringParam, TimeDt, TokenParam, UriParam
I don't see another candidate in the above for _id. But I'm still a learning-newbie with IGenericClient.
=====
Append
I tried this.
String csvIds = StringUtils.join(ids, "%2C");
No go there.
stringMagic
Above code using the below version(s).
APPEND
Ok, with a little digging into the code....below are some breadcrumbs.
And that tracks down to
public class StringParam extends BaseParam implements IQueryParameterType {
And (Ding Ding Ding)
and because you/someone left a good comment...I see the "tension"
(start HL7 quote)
3.1.1.4.19 Escaping Search Parameters In the rules described above, special rules are defined for the characters $, ,, and |. As a consequence, if these characters appear in an actual parameter value, they must be differentiated from their use as separator characters. When any of these characters appear in an actual parameter value, they must be prepended by the character \, which also must be used to prepend itself. Therefore, param=xxx$xxx indicates that it is a composite parameter, while param=xx\$xx indicates that the parameter has the literal value xx$xx. The parameter value xx\xx is illegal, and the parameter value param=xx\xx indicates a literal value of xx\xx. This means that:
GET [base]/Observation?code=a,b is a request for any Observation that has a code of either a or b, whereas:
GET [base]/Observation?code=a\,b is a request for any Observation that has a code of a,b.
(end HL7 quote)
Hmmm.
Would adding a
boolean useExactValue (for StringParam) be a possibility for this tension point?
or is that short sighted in some regard?