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

MPA alert enddate fix #1163

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions onprc_ehr/resources/queries/study/treatmentScheduleMPA.sql
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,24 @@ FROM study.demographics h JOIN (
s.startdate, s.enddate, s.dayselapsed, s.category, s.code, s.volume, s.vol_units, s.concentration, s.conc_units,
s.amountWithUnits, s.amountAndVolume, s.dosage, s.dosage_units, s.frequency, s.route, s.reason, s.remark, s.performedby
FROM (

SELECT
t1.objectid,
t1.id as animalid,
(coalesce(tt.time, ft.hourofday, (hour(t1.date) * 100)) / 100) as hours,

CASE
WHEN (tt.time IS NOT NULL OR ft.hourofday IS NOT NULL) THEN (((coalesce(tt.time, ft.hourofday) / 100.0) - floor(coalesce(tt.time, ft.hourofday) / 100)) * 100)
ELSE minute(t1.date)
END as minutes,
dr.date as origDate,

CASE
WHEN snomed.code IS NOT NULL THEN 'Post Op Meds'
ELSE t1.category
END as category,

t1.date as startDate,
timestampdiff('SQL_TSI_DAY', cast(t1.dateOnly as timestamp), dr.dateOnly) + 1 as daysElapsed,
t1.enddate, t1.code, t1.volume, t1.vol_units, t1.concentration, t1.conc_units, t1.amountWithUnits,
t1.amountAndVolume, t1.dosage, t1.dosage_units, t1.frequency.meaning + ' (' + t1.frequency.times + ')' as frequency, t1.route,
t1.reason, t1.performedby, t1.remark, t1.qcstate.label as TreatmentStatus

FROM ehr_lookups.dateRange dr

Join study."Treatment Orders" t1
Expand Down Expand Up @@ -95,4 +90,6 @@ FROM study.demographics h JOIN (
) s ON (s.animalid = h.id)
WHERE h.calculated_status = 'Alive'
--account for date/time in schedule
and s.date >= s.startDate and s.date <= s.enddate
--and s.date >= s.startDate and s.date <= s.enddate
--Added the enddate = null clause by Kollil, 10/25/24. Refer to ticket #11471
and s.date >= s.startDate and (s.date <= s.enddate or s.enddate is null)