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

Process treatment_orders with a NULL enddate #1197

Merged
merged 9 commits into from
Dec 26, 2024

Conversation

brentlogan
Copy link
Collaborator

@brentlogan brentlogan commented Dec 2, 2024

Rationale

Treatment orders with NULL end dates can be entered into PRIMe.

study.treatmentSchedule.sql queries study.treatment_orders over a time range defined by "dependee" query ehr_looksup.dateRange. It doesn't return results of treatment orders where:

  • enddate is NULL, or
  • enddate is NULL AND a dateRange date is in the future.

study.treatmentSchedule.sql is used by printable report Clinical Medications and in the EHR animal history, Daily Reports > Clinical Medications Schedule. The animal history reports run for today's date (setting the start date of "dependee" query ehr_looksup.dateRange to today's date with a length of one). The printable report can be run for user-selected dates, including future dates and date ranges greater than one.

study.treatmentScheduleUpdate is used for the TreatmentToDrug ETL, using today's date and range of 1 for the dateRange.

Related Pull Requests

#1111

Changes

  • The check for dr.dateOnly (all dates within dateRange) must be <= the treatment order's end date (if it exists).
  • The check for date before enddate now returns TRUE if enddate is NULL.

Copy link

github-actions bot commented Dec 2, 2024

ERROR: A pull request from 23.11_fb_allowTreatmentNullEnddate is expected to target release23.11-SNAPSHOT, not develop

@brentlogan brentlogan changed the base branch from develop to release23.11-SNAPSHOT December 2, 2024 15:47
@brentlogan brentlogan changed the title Allow treatment_orders to have a null enddate Process treatment_orders with a NULL enddate Dec 2, 2024
@brentlogan brentlogan self-assigned this Dec 2, 2024
Copy link
Collaborator

@jonesgaohsu jonesgaohsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code meets the objective and is written as was discussed

@brentlogan
Copy link
Collaborator Author

We received feedback that the first commit didn't fully fix the issue. The printed report Clinical Medications failed to produce the desired results for treatment orders having no end date when the report's date was in the future. I reviewed study.treatmentSchedule and realized this results in no overlap between t1.date to t1.enddateCoalesced and the range defined by dr (which is the future date with a range of 1 day), and thus, the treatment order doesn't show in the report.

This latest commit modifies only study.treatmentSchedule and not study.treatmentScheduleUpdate, which might need to be updated.

@brentlogan brentlogan marked this pull request as draft December 13, 2024 21:04
@brentlogan brentlogan requested a review from bbimber December 13, 2024 21:04
@brentlogan
Copy link
Collaborator Author

@bbimber please take a look at this pull request. I've determined that allowing treatment orders to have NULL end dates breaks the two queries currently in the pull request. I believe these two proposed changes won't impact the rest of PRIMe, but I'd like your feedback. It might make more sense to require end dates for all treatment orders to avoid this issue.

Should you agree that these changes are fine, I propose making similar changes to the other study.treatmentScheduleX queries that are only slight modifications of treatmentSchedule. I'd also add the second change to study.treatmentScheduleUpdate (which has only one change in this pull request in its current form).

Thanks!

Copy link
Collaborator

@bbimber bbimber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one minor comment, but i think this will work. I'm approving since the suggestion isnt required for the code to work

Adopt Ben Bimber's suggestion to modify both enddate comparisons to the same solution and use the one that is transparent about the problem being solved.
@brentlogan brentlogan requested a review from kollil December 19, 2024 14:31
@brentlogan brentlogan marked this pull request as ready for review December 20, 2024 19:32
Copy link
Collaborator

@jonesgaohsu jonesgaohsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed changes with Brent and this is ready for production

@brentlogan brentlogan merged commit 36896af into release23.11-SNAPSHOT Dec 26, 2024
3 checks passed
@brentlogan brentlogan deleted the 23.11_fb_allowTreatmentNullEnddate branch December 26, 2024 21:00
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

Successfully merging this pull request may close these issues.

3 participants