diff --git a/nirc_ehr/resources/data/treatment_frequency.tsv b/nirc_ehr/resources/data/treatment_frequency.tsv index 0a62bed3..bbf36e01 100644 --- a/nirc_ehr/resources/data/treatment_frequency.tsv +++ b/nirc_ehr/resources/data/treatment_frequency.tsv @@ -1,4 +1,4 @@ -Meaning Sort Order Week of Month Day of Month Day of Week Interval in Days Short Name Active? +Meaning Sort Order Week of Month Day of Month Day of Week Interval in Days Short Name Active? Week Days Monthly 30 true Weekly 7 true Alternating Days 2 true @@ -8,4 +8,5 @@ TID 1 true q7 days 7 true q14 days 14 true BID 1 true -Every 3 months 90 true \ No newline at end of file +Every 3 months 90 true +M-F (SID) 1 true 2,3,4,5,6 \ No newline at end of file diff --git a/nirc_ehr/resources/data/treatment_frequency_times.tsv b/nirc_ehr/resources/data/treatment_frequency_times.tsv index 92a33eb6..61fd3d61 100644 --- a/nirc_ehr/resources/data/treatment_frequency_times.tsv +++ b/nirc_ehr/resources/data/treatment_frequency_times.tsv @@ -14,4 +14,5 @@ BID 800 AM BID 1600 PM q7 days 800 AM q14 days 800 AM -Every 3 months 800 AM \ No newline at end of file +Every 3 months 800 AM +M-F (SID) 800 AM \ No newline at end of file diff --git a/nirc_ehr/resources/domain-templates/ehr_lookups.template.xml b/nirc_ehr/resources/domain-templates/ehr_lookups.template.xml index de1a7da9..36eb0f94 100644 --- a/nirc_ehr/resources/domain-templates/ehr_lookups.template.xml +++ b/nirc_ehr/resources/domain-templates/ehr_lookups.template.xml @@ -39,4 +39,14 @@ + + \ No newline at end of file diff --git a/nirc_ehr/resources/queries/study/observationOrdersByDate.sql b/nirc_ehr/resources/queries/study/observationOrdersByDate.sql index 4e4dcc5f..54f7017c 100644 --- a/nirc_ehr/resources/queries/study/observationOrdersByDate.sql +++ b/nirc_ehr/resources/queries/study/observationOrdersByDate.sql @@ -43,7 +43,9 @@ FROM (SELECT * FROM study.observation_order ORDER BY category) t1 ON (dr.dateOnly >= t1.dateOnly AND (dr.dateOnly <= t1.enddate OR t1.enddate IS NULL) AND --technically the first day of the treatment is day 1, not day 0 - ((mod(CAST(timestampdiff('SQL_TSI_DAY', CAST(t1.dateOnly AS timestamp), dr.dateOnly) AS integer), t1.frequency.intervalindays) = 0 AND t1.frequency.intervalindays IS NOT NULL AND t1.frequency.dayofweek IS NULL))) + ((mod(CAST(timestampdiff('SQL_TSI_DAY', CAST(t1.dateOnly AS timestamp), dr.dateOnly) AS integer), t1.frequency.intervalindays) = 0 AND t1.frequency.intervalindays IS NOT NULL AND t1.frequency.dayofweek IS NULL)) + AND (t1.frequency.weekDays IS NULL OR LOCATE(CAST(dr.DayOfWeek AS VARCHAR), t1.frequency.weekDays) > 0) + ) LEFT JOIN ehr_lookups.treatment_frequency_times ft ON ft.frequency = t1.frequency.meaning WHERE t1.date IS NOT NULL diff --git a/nirc_ehr/resources/queries/study/treatmentSchedule.sql b/nirc_ehr/resources/queries/study/treatmentSchedule.sql index 86825968..ea8384a9 100644 --- a/nirc_ehr/resources/queries/study/treatmentSchedule.sql +++ b/nirc_ehr/resources/queries/study/treatmentSchedule.sql @@ -54,7 +54,8 @@ JOIN( FROM nirc_ehr.dateRange dr JOIN study."Treatment Orders" t1 ON (dr.dateOnly >= t1.dateOnly AND --technically the first day of the treatment is day 1, not day 0 - ((mod(CAST(timestampdiff('SQL_TSI_DAY', CAST(t1.dateOnly AS timestamp), dr.dateOnly) AS integer), t1.frequency.intervalindays) = 0 AND t1.frequency.intervalindays IS NOT NULL AND t1.frequency.dayofweek IS NULL )) + ((mod(CAST(timestampdiff('SQL_TSI_DAY', CAST(t1.dateOnly AS timestamp), dr.dateOnly) AS integer), t1.frequency.intervalindays) = 0 AND t1.frequency.intervalindays IS NOT NULL AND t1.frequency.dayofweek IS NULL )) + AND (t1.frequency.weekDays IS NULL OR LOCATE(CAST(dr.DayOfWeek AS VARCHAR), t1.frequency.weekDays) > 0) ) LEFT JOIN ehr_lookups.treatment_frequency_times ft ON ft.frequency = t1.frequency.meaning --NOTE: if we run this report on a future interval, we want to include those treatments diff --git a/nirc_ehr/resources/web/nirc_ehr/model/sources/NIRCDefault.js b/nirc_ehr/resources/web/nirc_ehr/model/sources/NIRCDefault.js index 2f734dc3..e332da94 100644 --- a/nirc_ehr/resources/web/nirc_ehr/model/sources/NIRCDefault.js +++ b/nirc_ehr/resources/web/nirc_ehr/model/sources/NIRCDefault.js @@ -174,6 +174,16 @@ EHR.model.DataModelManager.registerMetadata('Default', { autoLoad: true } } + }, + frequency: { + columnConfig: { + width: 180 + }, + nullable: false, + allowBlank: true, + lookup: { + filterArray: [LABKEY.Filter.create('active', true, LABKEY.Filter.Types.EQUAL)] + }, } }, 'study.drug': { @@ -218,7 +228,10 @@ EHR.model.DataModelManager.registerMetadata('Default', { width: 180 }, nullable: false, - allowBlank: true + allowBlank: true, + lookup: { + filterArray: [LABKEY.Filter.create('active', true, LABKEY.Filter.Types.EQUAL)] + }, } }, 'study.pairings': {