String parameters on AQL queries

I was trying to do a call to a simple stored query based on the EHR_STATUS

SELECT c/uid/value as composition_id
FROM EHR e CONTAINS COMPOSITION c
WHERE e/ehr_status/subject/external_ref/id/value = $patient

Then launching the stored query

[base]/openehr/v1/query/samplequery?patient=idpat1

returns a “Not implemented: Only primitive operands are supported”

I also found this discussion so I tried to define the query with single quotes
WHERE e/ehr_status/subject/external_ref/id/value = '$patient'

this query returns a json, but the filter seems to not be working. Is there any obvious thing that I’m missing? are queries over ehr_status supported on ehrbase?

pinging @vidi42 @luis_marco :wink:

@yampeku I assume you are triggering the stored query via GET ( Query API openEHR specs )

[base]/openehr/v1/query/samplequery?patient=idpat1 This way, the query parameter in the URL will not be considered a query parameter for AQL.

You would need to do it like this GET openehr/v1/query/org.openehr::samplequery?query_parameters=patient=idpat1

Then you can see in the response the executed AQL

SELECT c/uid/value AS composition_id FROM EHR e CONTAINS (EHR_STATUS s AND COMPOSITION c) WHERE s/subject/external_ref/id/value = ‘idpat1’

Thank you! had just found it on another thread from @surfer , can confirm it works