Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions nirc_ehr/resources/data/treatment_frequency.tsv
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -8,4 +8,5 @@ TID 1 true
q7 days 7 true
q14 days 14 true
BID 1 true
Every 3 months 90 true
Every 3 months 90 true
M-F (SID) 1 true 2,3,4,5,6
3 changes: 2 additions & 1 deletion nirc_ehr/resources/data/treatment_frequency_times.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ BID 800 AM
BID 1600 PM
q7 days 800 AM
q14 days 800 AM
Every 3 months 800 AM
Every 3 months 800 AM
M-F (SID) 800 AM
10 changes: 10 additions & 0 deletions nirc_ehr/resources/domain-templates/ehr_lookups.template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,14 @@
</table>
</template>

<template xsi:type="EHRLookupsTemplateType">
<table tableName="treatment_frequency" tableDbType="TABLE">
<dat:columns>
<dat:column columnName="weekDays">
<dat:rangeURI>string</dat:rangeURI>
</dat:column>
</dat:columns>
</table>
</template>

</templates>
4 changes: 3 additions & 1 deletion nirc_ehr/resources/queries/study/observationOrdersByDate.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion nirc_ehr/resources/queries/study/treatmentSchedule.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion nirc_ehr/resources/web/nirc_ehr/model/sources/NIRCDefault.js
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand Down Expand Up @@ -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': {
Expand Down