Facing issue while executing AQL, where it has two templates with different archetypes. Used same ehr_id for composition insertions.
AQL:
SELECT
e/ehr_id/value
FROM ehr e CONTAINS
COMPOSITION c[openEHR-EHR-COMPOSITION.encounter.v1]
CONTAINS
(OBSERVATION o[openEHR-EHR-OBSERVATION.problem_screening.v1]
OR
OBSERVATION o1[openEHR-EHR-OBSERVATION.symptom_sign_screening.v0])
WHERE
(o/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0004]/value/value=âTestProblemScreening-1â
AND
o/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0005]/value/value=âYesâ)
OR
(o1/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0004]/value/value=âTest-signsymptom-2â
AND
o1/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0005]/value/value =âYesâ)"
Expected was ehr_id, but we are facing below error:
{
âerrorâ: âBad Requestâ,
âmessageâ: âCould not perform SQL query:org.postgresql.util.PSQLException: ERROR: column alias_117828109.1 does not exist\n Position: 38, AQL expression:selecte/ehr_id/valuefromehrecontainscompositionc[openEHR-EHR-COMPOSITION.encounter.v1]contains(observationo[openEHR-EHR-OBSERVATION.problem_screening.v1]orobservationo1[openEHR-EHR-OBSERVATION.symptom_sign_screening.v0])where(o/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0004]/value/value='TestProblemScreening-1âando/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0005]/value/value=âYesâ)or(o1/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0004]/value/value='Test-signsymptom-2âando1/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0005]/value/value=âYesâ), Translated SQL:select distinct on ("/ehr_id/value") "alias_117828109"."1" from (select 1) as "alias_117828109"â
}
Please Note CDR used is ehrbase
Any help would be highly appreciated.
Thanks in Advance.
As usual, it is really helpful for any AQL-related question, if you can clearly state the CDR product )I know it is tagged as Ehrbase), and include an operational template plus some example compositions to help test/reproduce the issue.
Not sure if this is discourseâs formatting but it seems itâs messing the quotes. Can you check you are using plain double or single quotes in your AQL, because those oblique quotes might be causing issues on the AQL parser.
Thanks but it is the .opt exports that we need, not the native JSON. The native json only contains the unique template level constraints and not he underlying archetypes. The .opt essentially âcompilesâ these together as a run-time artefact.
If you do want to send the full design-time package of native json plus individual archetypes, then use the Template Fileset .zip format. This will work but requires the recipient to set up a new repo and generate the .opt for upload to their CDR so a bit more cumbersome.