Resolved-Problem filtering on links using WHERE in AQL in EHRBase

Hi,

I have added the following composition that contains links to uids of problem/diagnosis entries in another composition

{
"ctx/language": "en",
"ctx/territory": "IN",
"ctx/time": "{{$isoTimestamp}}",
"ctx/setting": "secondary medical care",
"prescription/_name": "Medication Order",
"prescription/context/ehrn_metadata/care_context/display": "IP Consult",
"prescription/context/ehrn_metadata/care_context/encounterid": "Encounter/EncounterId",
"prescription/context/ehrn_metadata/abdm/documenttype|code": "440545006",
"prescription/context/ehrn_metadata/abdm/documenttype|value": "Prescription record",
"prescription/context/ehrn_metadata/abdm/documenttype|terminology": "SNOMED CT",
"prescription/context/_health_care_facility|name": "Organization Name",
"prescription/context/_health_care_facility|id": "Organization/{{OrganizationId}}",
"prescription/context/_health_care_facility|id_namespace": "network.ehr.dgs",
"prescription/context/_health_care_facility|id_scheme": "Organization",
 "prescription/medication_order:0/order:0/medication_item": "Dolo 650",
 "prescription/medication_order:0/order:0/medication_item/_uid": "{{$randomUUID}}",
"prescription/medication_order:0/order:0/medication_item/_link:0|type": "Problem",
"prescription/medication_order:0/order:0/medication_item/_link:0|meaning": "medication for",
"prescription/medication_order:0/order:0/medication_item/_link:0|target": "ehr://{{ehr_id}}/compositions/818d58e1-af0d-4192-8be8-b7beef5bd074/5b9e74bd-4a7c-4851-b1fb-73260d7dc7dc",

"prescription/medication_order:0/order:0/medication_details/strength_presentation/strength_numerator|magnitude": 650,
"prescription/medication_order:0/order:0/medication_details/strength_presentation/strength_numerator|unit": "mg",
"prescription/medication_order:0/order:0/medication_details/strength_presentation/strength_denominator|unit": "Tablet",  
"prescription/medication_order:0/order:0/medication_details/strength_presentation/strength_denominator|magnitude": 1, 
"prescription/medication_order:0/order:0/route": "Oral",
"prescription/medication_order:0/order:0/timing_-_daily/frequency|magnitude": 3,
"prescription/medication_order:0/order:0/timing_-_daily/frequency|unit": "1/d",
"prescription/medication_order:0/order:0/timing_-_daily/specific_event/event_name": "after meals",
"prescription/medication_order:0/order:0/timing_-_daily/specific_event/time_offset": "PT30M",
"prescription/medication_order:0/order:0/order_details/order_start_date_time": "{{$isoTimestamp}}",
"prescription/medication_order:0/order:0/order_details/order_stop_date_time": "{{$isoTimestamp}}",
"prescription/medication_order:0/order:0/clinical_indication:0": "Fever",
"prescription/medication_order:0/order:0/clinical_indication:1": "body ache",
"prescription/medication_order:0/order:0/therapeutic_intent:0": "temperature control",
"prescription/medication_order:0/order:0/therapeutic_intent:1": "reduce body ache",
"prescription/medication_order:0/order:0/order_details/medication_order_summary/order_status|value": "Active",
"prescription/medication_order:0/order:0/order_details/medication_order_summary/order_status|code": "at0021",
"prescription/medication_order:0/order:0/order_details/medication_order_summary/order_status|terminology": "local",
"prescription/medication_order:0/order:0/order_details/medication_order_summary/date_reported": "{{$isoTimestamp}}",
"prescription/medication_order:0/order:0/comment": "Remarks for Medication_order0",
"prescription/medication_order:0/order_identifier|id": "orderId for Medication_order0",
"prescription/medication_order:0/narrative": "overall narrative for Medication_order0",    "prescription/medication_order:0/order:0/therapeutic_direction/direction_duration/text_value": "5 days",
"prescription/medication_order:0/order:0/administration_method": "With Ghee/with warmwater/with honey",
"prescription/medication_order:0/order:0/therapeutic_direction/review_criterion/text_value": "when symptoms change",
"prescription/medication_order:0/order:0/additional_instruction": "start immediately",  

 "prescription/medication_order:0/order:1/medication_item": "Metzok 12.5 mg",
 "prescription/medication_order:0/order:1/medication_item/_uid": "{{$randomUUID}}",
"prescription/medication_order:0/order:1/medication_item/_link:0|type": "Problem",
"prescription/medication_order:0/order:1/medication_item/_link:0|meaning": "medication for",
"prescription/medication_order:0/order:1/medication_item/_link:0|target": "ehr://{{ehr_id}}/compositions/818d58e1-af0d-4192-8be8-b7beef5bd074/59d50cc9-8bcb-42e4-a8bf-e7d29ffef4f0",
"prescription/composer|id_namespace": "network.ehr.dgs",
"prescription/composer|id": "Practitioner/PractitionerId",
 "prescription/composer|id_scheme": "Practitioner",
 "prescription/composer|name": "Practitioner Name"
}

When I try to retrieve only medicines that are linked to a particular problem using the following aql, I am getting empty response.

{
"q": "SELECT c1/uid/value as compositionId,c2/activities[at0001]/description[at0002]/items[at0070]/uid/value as uid, c2/activities[at0001]/description[at0002]/items[at0070]/links/target/value as link FROM EHR e[ehr_id/value ='18af7da5-46fc-4cf6-9078-34c1261a3368'] CONTAINS COMPOSITION c1 CONTAINS INSTRUCTION c2[openEHR-EHR-INSTRUCTION.medication_order.v3] WHERE c2/activities[at0001]/description[at0002]/items[at0070]/links/target/value LIKE= 'ehr://18af7da5-46fc-4cf6-9078-34c1261a3368/compositions/818d58e1-af0d-4192-8be8-b7beef5bd074/5b9e74bd-4a7c-4851-b1fb-73260d7dc7d'" 
}

If I remove the WHERE clause, both the values are returned

It would be a great help if anyone can advise on how to get the aql working

regards

May be an extra = not required after the LIKE?

@ian.mcnicoll Thanks. But that is not the issue.

Tried all WHERE possibilities. Also The EHRBase version is 2.10.0. Not sure if this is not supported in this version

WHERE c2/activities[at0001]/description[at0002]/items[at0070]/links/target/value LIKE 'ehr://18af7da5-46fc-4cf6-9078-34c1261a3368/compositions/818d58e1-af0d-4192-8be8-b7beef5bd074/5b9e74bd-4a7c-4851-b1fb-73260d7dc7d'

WHERE c2/activities[at0001]/description[at0002]/items[at0070]/links/target/value='ehr://18af7da5-46fc-4cf6-9078-34c1261a3368/compositions/818d58e1-af0d-4192-8be8-b7beef5bd074/5b9e74bd-4a7c-4851-b1fb-73260d7dc7d'

WHERE c2/activities[at0001]/description[at0002]/items[at0070]/links/target/value MATCHES {'ehr://18af7da5-46fc-4cf6-9078-34c1261a3368/compositions/818d58e1-af0d-4192-8be8-b7beef5bd074/5b9e74bd-4a7c-4851-b1fb-73260d7dc7d'}

Resolved. There was a character missing in the query string.