forked from epinotes/InjuryEpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
drugs_icd10cm_WA_2016_time_series_monthly.Rmd
264 lines (153 loc) · 6.44 KB
/
drugs_icd10cm_WA_2016_time_series_monthly.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
---
title: "WA 2011-2016 Drug Overdose Hospitalization"
author: "Mamadou Ndiaye, Epidemiologist, WA DOH"
output:
bookdown::html_document2:
toc: true
toc_depth: 3
toc_float: true
css: tufte2.css
---
```{r, echo=F,message=FALSE, warning=FALSE}
library(tidyverse)
library(haven)
library(forcats)
library(caret)
library(Hmisc)
library(purrr)
library(knitr)
library(pander)
library(injuryepi)
library(highcharter)
library(forecast)
#library(ggplot2)
load("Y:/Confidential/HSQA/CHS/IVP-Epi/CHARS/.R_Cache/chars_pub2015diag_q4@.RData")
load("Y:/Confidential/HSQA/CHS/IVP-Epi/CHARS/.R_Cache/chars_pub2015diag_f@.RData")
load("Y:/Confidential/HSQA/CHS/IVP-Epi/CHARS/.R_Cache/chars_2016@.RData")
load("Y:/Confidential/HSQA/CHS/IVP-Epi/CHARS/.R_Cache/mat@.RData")
load("Y:/Confidential/HSQA/CHS/IVP-Epi/CHARS/.R_Cache/mat_op@.RData")
load("Y:/Confidential/HSQA/CHS/IVP-Epi/CHARS/.R_Cache/mat_nhop@.RData")
load("Y:/Confidential/HSQA/CHS/IVP-Epi/CHARS/.R_Cache/mat_hero@.RData")
# SOAR::Attach()
options(scipen = 12)
knitr::opts_chunk$set(
echo = TRUE,
comment = NA,
message = FALSE,
error = FALSE,
warning = FALSE)
```
The introduction of ICD-10 CM in October 2015 and the use of CDC proposed definitions may have artificially lead to an apparent steeper decrease of drug overdose. However a time series decomposition from 2011 to 2016 showed seasonal effects that manifested in a lower incidence of drug overdose in the first and fourth quaters over the years.
In addition this document contrasted the results between using the principal diagnosis only and any diagnosis field when capturing the opioid overdose codes for 2016.
# Finding All Drug Overdose
Based on the ICD-10 CM **T36-T50** in the principal diagnosis
```{r eval=F, echo=F}
library(tidyverse)
source("https://raw.githubusercontent.com/epinotes/InjuryEpi/master/add_drug_10cm")
source("https://raw.githubusercontent.com/epinotes/InjuryEpi/master/create_cond_diag")
source("https://raw.githubusercontent.com/epinotes/InjuryEpi/master/create_diag")
```
```{r, eval = F}
library(injuryepi)
chars_2016 <- chars_2016 %>% add_drug_10cm(., uid = "seq_no", main = "diag1")
```
__The results by quarters__:
```{r, echo=F}
pander(filter(chars_2016, drugs == 1) %>% group_by(quarters) %>% count,justify = "left")
```
# Finding All Opioid Overdose
Based on `.opioid_10cm = "^T40[01234]X|^T406[09]"`
## Opioid Principal Diagnosis Only
```{r, eval=F}
chars_2016 <- chars_2016 %>% mutate(opioid = create_cond_diag(.,expr = .opioid_10cm, colvec = 79, cond.var = drugs))
```
Count of opioid as main diagnosis by quarters:
```{r, echo=F}
pander(filter(chars_2016, opioid == 1) %>% group_by(quarters) %>% count,justify = "left")
```
## Opioid As any Diagnosis
```{r, eval=F}
d_m <- grep("^diag[0-9]|^ecode[0-9]", names(chars_2016), value = F)
chars_2016 <- chars_2016 %>% mutate(opioid_m = create_cond_diag(.,expr = .opioid_10cm, colvec = d_m, cond.var = drugs))
```
Count of opioid as any diagnosis by quarters:
```{r, echo=F}
pander(filter(chars_2016, opioid_m == 1) %>% group_by(quarters) %>% count,justify = "left")
```
# Finding Non- Heroin Opioid Overdose
Based on `.opioid_nh_10cm = "^T40[0234]X|^T406[09]"`
## Non- Heroin Principal Diagnosis Only
```{r, eval=F}
chars_2016 <- chars_2016 %>% mutate(opioid_nh = create_cond_diag(.,expr = .opioid_nh_10cm, colvec = 79, cond.var = drugs))
```
Count of Non-Heroin opioid as main diagnosis by quarters:
```{r, echo=F}
pander(filter(chars_2016, opioid_nh == 1) %>% group_by(quarters) %>% count,justify = "left")
```
## Non-Heroin Opioid As any Diagnosis
```{r, eval=F}
d_m <- grep("^diag[0-9]|^ecode[0-9]", names(chars_2016), value = F)
chars_2016 <- chars_2016 %>% mutate(opioid_nh_m = create_cond_diag(.,expr = .opioid_nh_10cm, colvec = d_m, cond.var = drugs))
```
Count of non-heroin opioid as any diagnosis by quarters:
```{r, echo=F}
pander(filter(chars_2016, opioid_nh_m == 1) %>% group_by(quarters) %>% count,justify = "left")
```
# Finding All Heroin Overdose
Based on `.heroin_10cm = "^T401X"`
## heroin Principal Diagnosis Only
```{r, eval=F}
chars_2016 <- chars_2016 %>% mutate(heroin = create_cond_diag(.,expr = .heroin_10cm, colvec = 79, cond.var = drugs))
```
Count of heroin as main diagnosis by quarters:
```{r, echo=F}
pander(filter(chars_2016, heroin == 1) %>% group_by(quarters) %>% count,justify = "left")
```
## heroin As any Diagnosis
```{r, eval=F}
d_m <- grep("^diag[0-9]|^ecode[0-9]", names(chars_2016), value = F)
chars_2016 <- chars_2016 %>% mutate(heroin_m = create_cond_diag(.,expr = .heroin_10cm, colvec = d_m, cond.var = drugs))
```
Count of heroin as any diagnosis by quarters:
```{r, echo=F}
pander(filter(chars_2016, heroin_m == 1) %>% group_by(quarters) %>% count,justify = "left")
```
# Monthly Time Series Decomposition from 2011 to 2016
The decomposition of the time series was done with the R function `stl()`(Seasonal Decomposition of Time Series by Loess). It displays the _original series_, and its decomposition into _seasonal_, _trend(smoothed with loess)_ and _remainder_.
The graphs were produced with _R packages_ `ggplot2` and `highcharter`
## Time series for all drugs
### __with ggplot2__:
```{r}
ggplot2::autoplot(stl(mat, s.window = "periodic", robust = TRUE))
```
### __With highcharter__ (allowing interactivity):
```{r}
highcharter::hchart(stl(mat, s.window = "periodic", robust = TRUE))
```
## Time series for all opioids
### __with ggplot2__:
```{r echo=F}
ggplot2::autoplot(stl(mat_op, s.window = "periodic", robust = TRUE))
```
### __With highcharter__ :
```{r echo=F}
highcharter::hchart(stl(mat_op, s.window = "periodic", robust = TRUE))
```
## Time series for non-heroin opioid
### __with ggplot2__:
```{r echo=F}
ggplot2::autoplot(stl(mat_nhop, s.window = "periodic", robust = TRUE))
```
### __With highcharter__ :
```{r echo=F}
highcharter::hchart(stl(mat_nhop, s.window = "periodic", robust = TRUE))
```
## Time series for heroin
### __with ggplot2__:
```{r echo=F}
ggplot2::autoplot(stl(mat_hero, s.window = "periodic", robust = TRUE))
```
### __With highcharter__ :
```{r echo=F}
highcharter::hchart(stl(mat_hero, s.window = "periodic", robust = TRUE))
```