Formatting AQL in new topics

Could we add to the description of this category the suggestion to format all posted AQL queries before posting a new topic? This way it’s much easier for people to read and respond to the question.

Example:

SELECT c FROM COMPOSITION c[openEHR-EHR-COMPOSITION.report.v1] CONTAINS EVALUATION d[openEHR-EHR-EVALUATION.problem_diagnosis.v1] WHERE d/name/value = 'Primary diagnosis' AND (d/data[at0001]/items[at0002 and name/value='Diagnosis']/value/defining_code/code_string = 'C50' OR d/data[at0001]/items[at0002 and name/value='Diagnosis']/value/defining_code/code_string = 'C18')

vs

SELECT
    c
FROM
    COMPOSITION c[openEHR-EHR-COMPOSITION.report.v1]
        CONTAINS EVALUATION d[openEHR-EHR-EVALUATION.problem_diagnosis.v1]
WHERE
    d/name/value = 'Primary diagnosis'
    AND (d/data[at0001]/items[at0002 and name/value='Diagnosis']/value/defining_code/code_string = 'C50'
    OR d/data[at0001]/items[at0002 and name/value='Diagnosis']/value/defining_code/code_string = 'C18')

(Also, is it possible to add ADL and AQL syntax highlighting to Discourse?)

4 Likes

Thanks Silje for the suggestion/request!
I fully support and subscribe to it, and was about to right the same for, as reading AQL-in-json {q:“select …”} is a similar problem and is getting very annoying. :+1:

1 Like
SELECT
    c
FROM
    COMPOSITION c[openEHR-EHR-COMPOSITION.report.v1]
        CONTAINS EVALUATION d[openEHR-EHR-EVALUATION.problem_diagnosis.v1]
WHERE
    d/name/value = 'Primary diagnosis'
    AND (d/data[at0001]/items[at0002 and name/value='Diagnosis']/value/defining_code/code_string = 'C50'
    OR d/data[at0001]/items[at0002 and name/value='Diagnosis']/value/defining_code/code_string = 'C18')

If you add sql to the codeblock i.e. ```sql it looks a little better, and definitely add the name of the CDR. Ideally examples of the template(s) used and a couple of compositions instance examples would make the process much faster for a response.

1 Like

an alternative to Ian’s suggestion, is to use sqllint.com

1 Like

Also this if someone can stand it up as a wee service?