hospitalizations_last_n_days calculates the number of hospitalizations a patient had within the last n days. Similar to readmission, we should apply a buffer window, but (as opposed to readmission), the buffer needs to be applied at the start of the data availability timeline. Specifically, if a genc_id was admitted during the first 30 days of data (e.g., admission_date_time = "2015-04-10 00:00"), by definition, we can't check for any hospitalizations within the previous 30 days, so those genc_ids should be returned as n_hospitalizations = NA.
The issue is if users pre-filter the cohort (e.g., to check for previous hospitalizations with the same diagnosis category, so their cohort would only include encounters that meet a diagnosis inclusion criterion): In that case, the earliest date in the cohort input might not align with the actual earliest date that is available in our DB (i.e., the buffer would be too conservative). I think the best way to handle this might be for users to provide a dbcon input and the function could then check for the earliest available discharge date-time in admdad and then apply the buffer based on that (note: that's basically how this is handled in the readmission function).
Please note that the buffer should be applied by hospital_num (see readmission function) to make sure phase-1 vs. phase-2 sites are handled correctly (and in case there will be differences in data timelines across hospitals in future DB versions).
New Feature Request
hospitalizations_last_n_days
calculates the number of hospitalizations a patient had within the lastn
days. Similar toreadmission
, we should apply a buffer window, but (as opposed to readmission), the buffer needs to be applied at the start of the data availability timeline. Specifically, if agenc_id
was admitted during the first 30 days of data (e.g.,admission_date_time = "2015-04-10 00:00"
), by definition, we can't check for any hospitalizations within the previous 30 days, so thosegenc_ids
should be returned asn_hospitalizations = NA
.The issue is if users pre-filter the cohort (e.g., to check for previous hospitalizations with the same diagnosis category, so their cohort would only include encounters that meet a diagnosis inclusion criterion): In that case, the earliest date in the
cohort
input might not align with the actual earliest date that is available in our DB (i.e., the buffer would be too conservative). I think the best way to handle this might be for users to provide adbcon
input and the function could then check for the earliest available discharge date-time inadmdad
and then apply the buffer based on that (note: that's basically how this is handled in the readmission function).Please note that the buffer should be applied by
hospital_num
(seereadmission
function) to make sure phase-1 vs. phase-2 sites are handled correctly (and in case there will be differences in data timelines across hospitals in future DB versions).