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?)

5 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?

I understand @marcusbaw has been asking the Discourse gurus about what is needed to get AQL and ADL formatting supported. Personally not too bothered by ADL as we rarely post that.

Is anyone up for providing a bit of input?

2 Likes

Started a topic on this requirement.

(I think that having a JS-based AQL/ADL syntax highlighter would also mean the same highlight code would work in Electron-based code editors like VSCode and Atom.)

1 Like

Maybe we could use some from from the VSCode adl/AQL language server.