AHRQ-CDS / AHRQ-CDS-Connect-Authoring-Tool

The CDS Authoring Tool is part of the CDS Connect project https://cds.ahrq.gov/, sponsored by the Agency for Healthcare Research and Quality (AHRQ), and developed under contract with AHRQ by MITRE's CAMH FFRDC.
https://cds.ahrq.gov/cdsconnect/authoring
Apache License 2.0
42 stars 19 forks source link

CQL execution failure #80

Closed fiona43 closed 1 year ago

fiona43 commented 1 year ago

Hi, I am able to edit CQL and upload patients, but when I run a test (Testing page: Execute CQL on Selected Patients ) I get: Execution failed. Error: Cannot read properties of undefined (reading 'content')

It seems like a JavaScript bug. Please can you provide a feedback on this? Thanks in advance.

cmoesel commented 1 year ago

Are you able to download your CQL from the Authoring Tool? Knowing if you can do that successfully will help me determine if the issue is the the CQL-to-ELM translation service or something else.

fiona43 commented 1 year ago

Yes, I downloaded it successfully.

cmoesel commented 1 year ago

OK, that helps narrow it down... A few more questions:

fiona43 commented 1 year ago

Thanks for your feedback. My replies here below.

cmoesel commented 1 year ago

Hi @fiona43. I have tried to reproduce this error, but I cannot. I am running the latest code and using the Edge browser. I've created a simple artifact with inclusion criteria like in your screenshot and a simple recommendation ("Do something"). I've uploaded the test patient that you provided and then run the test by:

When I do so, I get the following result:

image

I have also tried this in FireFox with the same results.

In addition, I've tested this on the AHRQ-hosted CDS Authoring Tool and it works there too. Do you have an account for the AHRQ-hosted CDS Authoring Tool? If so, have you tried it there? I'm wondering if it is something wrong with your local installation.

Since I cannot reproduce this, it is difficult to debug it. Do you know how to open the developer tools in your browser and look at the console? If so, can you look at that and post more specific errors and stack traces that you see there?

cmoesel commented 1 year ago

Hi @fiona43. I've done some more investigation and I think I know what the problem is. The error Cannot read properties of undefined (reading 'content') happens when the CDS Authoring Tool API backend is not configured to use the CQL Translation Service (which translates human-readable CQL to machine-friendly ELM JSON). Execution requires the ELM JSON representation of CQL, so when it is not there, execution fails.

I suspect you probably copied the minimal-example.json when you created your local.json configuration. The minimal example unfortunately has the CQL-to-ELM Translation Service turned off:

{
  "cqlToElm": {
    "active": false
  },
  // other config
}

You'll need to install and run a CQL Translation Service and then set that value to true in your config. If youre CQL Translation Service is running at a URL other than http://localhost:8080/cql/translator, you'll also need to set the url property. See example.json for a more complete configuration example.

Unfortunately, it looks like this repo's README is not very clear about the requirement for the CQL Translation Service or how to install and run it. I apologize for that. If you have Docker, then the easiest way to run it is as a Docker container like this:

docker run -d -p 8080:8080 --restart unless-stopped cqframework/cql-translation-service:latest

Otherwise, you can run it using Java by following the instructions in the CQL to ELM Translation Service README.

fiona43 commented 1 year ago

Hi @cmoesel, the CQL Translation Service works! Thanks.

The CQL Execution Results seems to not work properly. After a lot of tests, I tried to implement an extremely simple test aiming to evaluate the correctness of the observation's evaluation. Related to this purpose I focused my attention on the inclusion criteria (discarding all the question related to the recommendation). My tests can be summarised in three groups:

  1. existance of an observation with a specific code Screenshot (5)
  2. counting of observations with a specific code Screenshot (7)
  3. existance of a value related to an observation with a specific code Screenshot (3)
  4. comparison between a value related to an observation with a specific code and a reference value Screenshot (10) Only the test at point 1 finished successfully and patient was correctly included. Screenshot (6) All the other tests went wrong. Test 2 returns a 'red X' Screenshot (8) Test 3 and 4 return a 'No Value' Screenshot (11) Obviously the observation exists in the json bundle and its value is well initialized. I enclose the updated json that I used for the tests. test_json_2.txt

Thanks in advance.

cmoesel commented 1 year ago

Hi @fiona43. I'm glad you were able to get the Translation Service working. As for your other difficulties, there are a few things that aren't quite right.

1. http://loinc.org/ vs http://loinc.org

In your test data, the codes' system properties are set to http://loinc.org/. This is not the correct code system URI for LOINC. It should be http://loinc.org. Note that there is no trailing /. For correct code system URIs, see FHIR's code system table here.

This is the most important change you need to make, as it affects all of your other test queries.

2. is not null modifier

In your first example above, you applied the "Exists" modifier and then the "is not null" modifier. The "is not null" modifier is not helpful here. This is because the "Exists" modifier that is before it will always return true or false (and never null). Since "Exists" never returns null, the "is not null" modifier after it will always return true. You actually just want "Exists" by itself, because that tells you if the query returned any data (true) or if it resulted in an empty list (false).

The difference between "Exists" and "is not null" can be confusing. You did use "is not null" correctly in the 3rd example, so that's good!

Once you make those two changes above, I think you'll find that everything is working as expected.

fiona43 commented 1 year ago

@cmoesel, Thanks for your clarifications. Now it works properly!

During the tests I noticed that the performance, during the editing process (within the 'Subpopulation' tab), decreases as the number of created items increases. For instance I created an artifact with:

cmoesel commented 1 year ago

Hi @fiona43. I've seen this before, and as you noted, it often happens when there are a lot of sub-populations (or sometimes a lot of elements on other pages). In my experience, I haven't seen too many people use more than 5 sub-populations, so it's not a use case that we've optimized for.

That said, it's worth looking into, so I'm tagging @jafeltra for her awareness. For now, however, I'm not aware of any workarounds. I apologize for the inconvenience!

fiona43 commented 1 year ago

Hi @cmoesel, thanks for your feedback! Now the issue is clearer and I look forward to a possibile update from @jafeltra.

Have a nice day!

jafeltra commented 1 year ago

Hi @fiona43. This issue you're noticing in the Subpopulation tab is something we have seen before. We had worked on an initial fix to this issue a little while ago that I thought had helped to resolve this. The initial fix we had implemented should be included if you are using the latest changes in this repository. To check that you have the latest commit with the fix, you can run git log and check that the commit with hash dd51380 is your latest commit.

If you do have the latest changes locally and still see this issue, we will continue looking into ways to improve the performance of the app. It is also worth noting that the fix to this issue is not yet available on the hosted version of the tool at https://cds.ahrq.gov/authoring/ so you will likely still see this issue if you are authoring artifacts there.

cmoesel commented 1 year ago

Closing this issue since it appears to be resolved and there has been no activity for more than a year.