-
Notifications
You must be signed in to change notification settings - Fork 0
/
suicide_cost_step1.R
46 lines (45 loc) · 1.92 KB
/
suicide_cost_step1.R
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
if(Sys.info()[4] %in% c("LAZ-ID1",
"LAZ-ID2",
"LAZ-DEID1",
"LAZ-DEID2")){
setwd("E:/CT_APCD/Sai/suicide_cost")
}
library(methods)
source("utils.R")
need_pkgs <- c("data.table", "bit64", "tools", "touch",
"dplyr", "lubridate", "tidyverse", "matrixStats")
need.packages(need_pkgs)
source("get_suicide_attempts.R")
# dgxcols <- c("MEDICAL_CLAIM_SERVICE_LINE_ID",
# "ICD_VERSION_IND", "DIAGNOSIS_CODE")
cols <- c("first_service_dt", "INTERNAL_MEMBER_ID",
"ICD_VERSION_IND", "DIAGNOSIS_CODE",
"MEDICAL_CLAIM_SERVICE_LINE_ID")
# elig_pt <- fread(paste0("E:/CT_APCD/shared/intermediate_data/",
# "APCD_modified/eligibility/By_Fiscal_Year/",
# "medical_elig_all.csv"),
# colClasses = "character",
# select = c("INTERNAL_MEMBER_ID",
# "birth_dt",
# "FiscalYR")) %>% unique(use.key = FALSE)
for (yr in 2013:2017){
cat(paste0("begin ", yr, " at ", Sys.time(), "\n"))
# mcpt <- fread(paste0("E:/CT_APCD/shared/intermediate_data/",
# "APCD_modified/medicare_medicare_ad_patients/",
# "fy", yr, "all_ages.csv"),
# colClasses = "character")
# elig_pt1 <- elig_pt[FiscalYR == yr]
mc <- fread(paste0("E:/CT_APCD/Sai/intermediate_data/",
"cost_measure_intermediate_data/",
"medical_fiscalyear_", yr, ".csv"),
colClasses = "character",
select = cols)
dgx <- fread(paste0("output/dgx_", yr, ".csv"),
colClasses = "character")
mc_dgx <- rbind(dgx, mc) %>% unique(use.key = FALSE)
fwrite(mc_dgx, file = paste0("output/mc_dgx_unique_",
yr, ".csv"))
rm(mc, dgx, mc_dgx)
gc()
cat(paste0(yr, " done at ", Sys.time(), "\n"))
}