Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not entire AQL which is defined in Criteria will be executed by Retrieve Data #348

Closed
smnrdln opened this issue Apr 29, 2022 · 6 comments
Closed

Comments

@smnrdln
Copy link

smnrdln commented Apr 29, 2022

Hi Guys,

we installed num-portal and num-portal-webapp at UKSH to experiment the features and getting connected to our current OpenEHR infrastructure.

Currently, we faced the following issue. After starting a project, by navigating to Data Retrieval and clicking on Retrieve Data, the filter which is defined at Criteria will not be applied correctly.

for example, although the AQL in Criteria is defined like this:

SELECT
  e1/data[at0001]/items[at0002]/value/defining_code/code_string as code
FROM
  EHR e
  contains COMPOSITION c0[openEHR-EHR-COMPOSITION.report.v1]
  contains EVALUATION e1[openEHR-EHR-EVALUATION.problem_diagnosis.v1]
WHERE
  (c0/archetype_details/template_id/value = 'KDS_Diagnose'
  AND e1/data[at0001]/items[at0002]/value/defining_code/code_string LIKE 'I50*')

the UI will send this AQL to num-portal:

SELECT
  c0 as KDS_Diagnose
FROM
  EHR e
  contains COMPOSITION c0[openEHR-EHR-COMPOSITION.report.v1]
WHERE
  c0/archetype_details/template_id/value = 'KDS_Diagnose'

which doesn't contain " code_string LIKE 'I50*' " part and all data will be shown which is not desired. For this example we defined a Criteria, and it will be used for defining a project. But after staring the project, all the data which contains a specific "template_id" (here KDS_Diagnose) will be returned and the other filters will be ignored.

Could you please let us know if this is the way it supposed to behave or where could be the problem.

Thanks!

@smnrdln smnrdln changed the title The entire AQL which is defined in Criteria won't be executed by Retrieve Data Not entire AQL which is defined in Criteria will be executed by Retrieve Data May 16, 2022
@Unaimend
Copy link

Hi I think we were able to find the specific line of code which does not work. It seems the AQL query gets passed correctly to the following method

https://github.com/NUM-Forschungsdatenplattform/num-portal/blob/d04f3b250f7ae067e1220f6bfe7a836073eb562a/src/main/java/de/vitagroup/num/service/ehrbase/EhrBaseService.java#L79

But after executing the following statement.
https://github.com/NUM-Forschungsdatenplattform/num-portal/blob/d04f3b250f7ae067e1220f6bfe7a836073eb562a/src/main/java/de/vitagroup/num/service/ehrbase/EhrBaseService.java#L81

You can see that the AqlDto-Object is not correct

image
Here you can see that the corresponding object only has one objects in it values list i.e. it does not contain the part after the AND in the following querry

SELECT
  e1/data[at0001]/items[at0002]/value/defining_code/code_string as code
FROM
  EHR e
  contains COMPOSITION c0[openEHR-EHR-COMPOSITION.report.v1]
  contains EVALUATION e1[openEHR-EHR-EVALUATION.problem_diagnosis.v1]
WHERE
  (c0/archetype_details/template_id/value = 'KDS_Diagnose'
  AND e1/data[at0001]/items[at0002]/value/defining_code/code_string LIKE 'I50*')

@ppazos
Copy link

ppazos commented Jul 19, 2022

I have checked, just in case, that the AQL was parsed correctly by the grammar.

java -jar antlr-4.10.1-complete.jar Aql.g4 -visitor
javac -classpath antlr-4.10.1-complete.jar [Aql*.java](http://Aql*.java)
java -classpath .:antlr-4.10.1-complete.jar org.antlr.v4.gui.TestRig Aql query -gui test.aql

The grammar is here https://github.com/ehrbase/ehrbase/blob/develop/service/src/main/antlr4/org/ehrbase/aql/parser/Aql.g4

test.aql is your original query

Output:

antlr4_parse_tree

Everything seems to be parsed correctly, it should be some transformation that happens after the parsing where the issue is located. Around here:

https://github.com/ehrbase/openEHR_SDK/blob/d448b0f6ea61d30527067249cad575dcd97b0164/aql/src/main/java/org/ehrbase/aql/parser/AqlToDtoParser.java#L34-L35

@smnrdln
Copy link
Author

smnrdln commented Jul 21, 2022

num-portal uses openEHR_SDK v1.5.0 but the lastest version is v1.19.0. Might an upgrade help to solve the problem?

@ppazos
Copy link

ppazos commented Jul 21, 2022

The only change between those versions in the method that seems to generate the issue is the error handler, I don't think that will solve this but you can try updating the dependency.

https://github.com/ehrbase/openEHR_SDK/blame/v1.19.0/aql/src/main/java/org/ehrbase/aql/parser/AqlToDtoParser.java

@smnrdln
Copy link
Author

smnrdln commented Aug 1, 2022

Yes, it seems the update doesn't change anything in this regard. I did that and there were some inconsistencies at different parts of the code. I just somehow managed to get it running again, but it didn't change anything regarding this issue. Should an issue be created in openEHR_SDK? This seems to be a high-priority bug if AQL Queries don't work properly.

@ppazos
Copy link

ppazos commented Aug 1, 2022

@smnrdln that seemed to me when I did the code review, the updates in the SDK don't seem to be related with this issue. Please raise an issue on the SDK repo, this query could be a good test case to add to the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants