-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
bug: Clinical Rules - logic issues in filter and target evaluations; divide by zero bug #7153
Comments
hi @hanksterr7 , Thanks for the detailed work. Are these logic failures happening in the rules that are built into OpenEMR (ie. the rules that are preinstalled) or the rules that are created with the editor or both? I ask this because the CDR engine was originally built by myself without a editor gui and the elements needed to be manually added to the database at that time (here is an example of them at https://www.open-emr.org/wiki/index.php/CDR_Rules_tables, although is outdated and most current sets are in the database.sql file in OpenEMR). Can check this page to get an idea of what was happening when the editor gui was then built by a different developer: https://www.open-emr.org/wiki/index.php/Clinical_Decision_Rules |
Been awhile since I have looked at this code (plan to re-educate myself while reviewing your PR :) ), but pretty sure the test_filter() date is needed when running the rules on historical data (for example, setting a target date when running report in OpenEMR at Report->Clinic->Standard Measures) |
Hi Brady. I have not tested the pre-installed rules. Just those created by the editor gui. In general though, I don't know of a valid use case for testing demographic filters against a date range. I would think demographic filters should be tested against the "patient", not against the patient's status during some time frame. It certainly makes sense to test rule targets against the three "intervals" related to the "due soon", "due" and "past due" time frames. If you can provide an example of a demographic filter that should be tested against a date range, please share your thoughts on that. test_filter() is used only when processing demographic filters, so I don't know of a use case that would require it to evaluate against a date range. Thanks |
Note, I have 7 topics that my code addresses (maybe 8 if I work on one more, but it is not yet in my updated code). Please advise as to the appropriate way for me to document this in github. Should I create 7 new issues (one for each topic), but link each (somehow) to the single PR that contains the code that fixes all of them? This issue #7153 is going to get very busy if all 7 are discussed in a single thread. Should I create separate PR's for each topic, with each PR containing the code that fixes each topic? Something else? I'm new to submitting PRs. Want to do this in the most helpful manner. Thanks |
I am going to use this issue #7153 to discuss my topic #7. This is the most complicated of my topics. I can create other issues for the other topics if that would be helpful. So here goes My overall topic list (#1 and #2 completed in separate PR): My topic #7 Example: Specify a patient as having an allergy to aspirin (as a text string, not a term lookup), and being a current tobacco user Create a custom target and action for the rule, and mention custom input: yes in the action definition, so you can see the status of rule evaluation against the patient Observe, using the released code base: Modify the filter criteria to create four tests: (1) neither, (2) the tobacco, (3) the allergy, or (4) both evaluate to true. This modification can be done by toggling between "aspirin" and "aspirinn" as the allergy filter value, and between "current" and "zcurrent" as the tobacco filter value. (note that "current" and "currentt" both look for a status of current tobacco user, but "zcurrent" does not) my version: Note that, in the current code base, the rule is showing as "Due", even though no instance of the target has been created. This is an incorrect status. It should show as "past due", with this status being modifiable if you create an instance of the action and vary the date of the instance. This status display is fixed in my topic #6 |
I created #7157 to continue the discussion of filter dates. Not sure how to link 7157 to the PR |
hi @hanksterr7, you can edit the PR and update what issue is fixed by the |
I believe I can provide a simplified description of the problem with the current code: |
Has any thought been put on how, if any, effect this will have on legacy? |
Still going through this, but don't see any negative impact on legacy rules at this time. |
Yes, I tried to ensure my changes would have no impact on existing rules (other than to maybe make them work properly, if any had been working incorrectly for certain patient-data situations). I don't believe my changes will cause any rules that were producing correct results to suddenly start producing incorrect or unexpected solutions. |
@hanksterr7 , No clinical rules testing in the automated testing. Would be awesome to incorporate CDR engine functions in the automated testing, although not simple task since need to get data into the database for the testing (just makes it a little more difficult). Can get an idea of the automated testing in the tests/Tests/ directory (and can see how they are run by checking out the functions in the easy dev docker). |
- improved handling of filters/targets for inclusion/exclusion flags, and where multiple filters/targets exist across classes of patient data - fixing right side of target interval used for target testing at value of $dateTarget passed to test_rules_clinic() instead of a value that floats with changes to left side of the interval - fix to divide by zero error in evaluating percent of passing rules more details at: openemr#7153 openemr#7157 openemr#7161
- improved handling of filters/targets for inclusion/exclusion flags, and where multiple filters/targets exist across classes of patient data - fixing right side of target interval used for target testing at value of $dateTarget passed to test_rules_clinic() instead of a value that floats with changes to left side of the interval - fix to divide by zero error in evaluating percent of passing rules more details at: openemr#7153 openemr#7157 openemr#7161
- improved handling of filters/targets for inclusion/exclusion flags, and where multiple filters/targets exist across classes of patient data - fixing right side of target interval used for target testing at value of $dateTarget passed to test_rules_clinic() instead of a value that floats with changes to left side of the interval - fix to divide by zero error in evaluating percent of passing rules more details at: openemr#7153 openemr#7157 openemr#7161
- improved handling of filters/targets for inclusion/exclusion flags, and where multiple filters/targets exist across classes of patient data - fixing right side of target interval used for target testing at value of $dateTarget passed to test_rules_clinic() instead of a value that floats with changes to left side of the interval - fix to divide by zero error in evaluating percent of passing rules more details at: openemr#7153 openemr#7157 openemr#7161
- improved handling of filters/targets for inclusion/exclusion flags, and where multiple filters/targets exist across classes of patient data - fixing right side of target interval used for target testing at value of $dateTarget passed to test_rules_clinic() instead of a value that floats with changes to left side of the interval - fix to divide by zero error in evaluating percent of passing rules more details at: openemr#7153 openemr#7157 openemr#7161
Entering this issue as part of pull request
I will create individual issues for these items in order to facilitate discussion, with more details in each issue. This is a summary issue for purposes of the PR
I am providing updated code to these files, in order to address several bugs and logic issues in
library\clinical_rules.php
Topics addressed:
-- divide by zero error in calculate_percentage()
-- Reminder Details page showing status of "not due" or "past due" but not "due soon" or "due".
-- Logic deficiencies in evaluating filters and targets:
-- -- logic does not properly handle results of criteria evaluation across categories of data, such as filters on both diagnoses and gender
-- -- logic inappropriately modified right-side boundary for target intervals when determining rule status, resulting in inappropriate rule conclusions
-- -- logic inappropriately applied date intervals during filter evaluation, and unnecessarily performs filter evaluation multiple times
The text was updated successfully, but these errors were encountered: