Description Usage Arguments Details Value Examples
View source: R/extract_medical_history-function.R
This function spread medical histories into different columns.
1 | extract_medical_history(population, n_batch = 50, cl = 1)
|
population |
Target population data, a data frame with rows for visits
and standardized columns (please see Details below). If only a single
healthcare provider, then make |
n_batch |
Number of batch, a non-negative integer of number of batch in which a number of subjects per provider are grouped. This is intended to ensure the computation fits to the memory. |
cl |
Parallel cluster, a non-negative integer of number of CPU cluster used for computation in parallel. Set to 1 if no parallelism is expected. |
Target population data consisted visit_id
,subject_id
,
healthcare_id
, admission_date
, code
, and
db_start_date
. Columns of visit_id
,subject_id
, and
healthcare_id
are characters of identification numbers identifying
respectively unique visits, subjects, and healthcare providers. Columns of
admission_date
and db_start_date
are dates of subject admission
in a visit and database start of recording period, respectively. Column of
code
is a character of ICD-10 code for either diagnosis or procedure
regardless the number of digit or k-mer.
Target population data, a data frame with rows for visits
and standardized columns (please see Details above), except code
.
Each code are spread as a column consisting the number of days from the
latest admission_date
on which this code have ever been encountered to
admission_date
of each visit. If no encounter is found, then the value
returns NA to denote censored data. This is because the code may be
encountered before db_start_date
. If the latest date and that of each
visit are the same, then the value returns 0.
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 | ## Create input example
data(visit_cap)
data(visit_ffs)
data(visit_drg)
data(diagnosis)
population=
list(visit_cap,visit_ffs,visit_drg) %>%
lapply(select,visit_id,subject_id,healthcare_id,admission_date) %>%
do.call(rbind,.) %>%
left_join(diagnosis,by='visit_id') %>%
filter(!code_type%in%c('Admission diagnosis')) %>%
select(-code_type) %>%
mutate(db_start_date=as.Date('2015-01-01')) %>%
.[!duplicated(.),]
## Extract outcome of subjects and sample some of them
outcome=
extract_outcome(population,'O1[4-5]',min,-1,'Z3[3-7]',max,0) %>%
group_by(outcome) %>%
slice(sample(seq(n()),ceiling(n()*0.0125),F)) %>%
ungroup()
## Filter medical history before the date of either event or non-event
input=
outcome %>%
right_join(population,by='subject_id') %>%
select(visit_id, everything()) %>%
filter(admission_date<latest_date) %>%
select(-outcome,-latest_date)
## Extract medical history of subjects per healthcare provider
mh_table=extract_medical_history(input)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.