Skip to content

Commit db2ab65

Browse files
Add M-F SID frequency (#594)
* Add week days extensible column to ehr_lookups.treatment_frequency * Update observation and treatment schedule queries * Update frequency to respect active column in ehr_lookups.treatment_frequency
1 parent 3e6911e commit db2ab65

6 files changed

Lines changed: 34 additions & 6 deletions

File tree

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Meaning Sort Order Week of Month Day of Month Day of Week Interval in Days Short Name Active?
1+
Meaning Sort Order Week of Month Day of Month Day of Week Interval in Days Short Name Active? Week Days
22
Monthly 30 true
33
Weekly 7 true
44
Alternating Days 2 true
@@ -8,4 +8,5 @@ TID 1 true
88
q7 days 7 true
99
q14 days 14 true
1010
BID 1 true
11-
Every 3 months 90 true
11+
Every 3 months 90 true
12+
M-F (SID) 1 true 2,3,4,5,6

nirc_ehr/resources/data/treatment_frequency_times.tsv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ BID 800 AM
1414
BID 1600 PM
1515
q7 days 800 AM
1616
q14 days 800 AM
17-
Every 3 months 800 AM
17+
Every 3 months 800 AM
18+
M-F (SID) 800 AM

nirc_ehr/resources/domain-templates/ehr_lookups.template.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,14 @@
3939
</table>
4040
</template>
4141

42+
<template xsi:type="EHRLookupsTemplateType">
43+
<table tableName="treatment_frequency" tableDbType="TABLE">
44+
<dat:columns>
45+
<dat:column columnName="weekDays">
46+
<dat:rangeURI>string</dat:rangeURI>
47+
</dat:column>
48+
</dat:columns>
49+
</table>
50+
</template>
51+
4252
</templates>

nirc_ehr/resources/queries/study/observationOrdersByDate.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ FROM
4343
(SELECT * FROM study.observation_order ORDER BY category) t1
4444
ON (dr.dateOnly >= t1.dateOnly AND (dr.dateOnly <= t1.enddate OR t1.enddate IS NULL) AND
4545
--technically the first day of the treatment is day 1, not day 0
46-
((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)))
46+
((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))
47+
AND (t1.frequency.weekDays IS NULL OR LOCATE(CAST(dr.DayOfWeek AS VARCHAR), t1.frequency.weekDays) > 0)
48+
)
4749
LEFT JOIN ehr_lookups.treatment_frequency_times ft ON ft.frequency = t1.frequency.meaning
4850
WHERE t1.date IS NOT NULL
4951

nirc_ehr/resources/queries/study/treatmentSchedule.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ JOIN(
5454
FROM nirc_ehr.dateRange dr
5555
JOIN study."Treatment Orders" t1 ON (dr.dateOnly >= t1.dateOnly AND
5656
--technically the first day of the treatment is day 1, not day 0
57-
((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 ))
57+
((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 ))
58+
AND (t1.frequency.weekDays IS NULL OR LOCATE(CAST(dr.DayOfWeek AS VARCHAR), t1.frequency.weekDays) > 0)
5859
)
5960
LEFT JOIN ehr_lookups.treatment_frequency_times ft ON ft.frequency = t1.frequency.meaning
6061
--NOTE: if we run this report on a future interval, we want to include those treatments

nirc_ehr/resources/web/nirc_ehr/model/sources/NIRCDefault.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@ EHR.model.DataModelManager.registerMetadata('Default', {
174174
autoLoad: true
175175
}
176176
}
177+
},
178+
frequency: {
179+
columnConfig: {
180+
width: 180
181+
},
182+
nullable: false,
183+
allowBlank: true,
184+
lookup: {
185+
filterArray: [LABKEY.Filter.create('active', true, LABKEY.Filter.Types.EQUAL)]
186+
},
177187
}
178188
},
179189
'study.drug': {
@@ -218,7 +228,10 @@ EHR.model.DataModelManager.registerMetadata('Default', {
218228
width: 180
219229
},
220230
nullable: false,
221-
allowBlank: true
231+
allowBlank: true,
232+
lookup: {
233+
filterArray: [LABKEY.Filter.create('active', true, LABKEY.Filter.Types.EQUAL)]
234+
},
222235
}
223236
},
224237
'study.pairings': {

0 commit comments

Comments
 (0)