View source: R/apportion_prior_healthcare.R
apportion_prior_healthcare | R Documentation |
The mandatory surveillance launched a new apportioning algorithm on 01/04/2017. This new apportioning algorithm takes into account prior healthcare interactions as recorded by trust users to apportion to one of four categories:
Healthcare onset - healthcare associated
Community onset - healthcare associated
Community onset - indeterminate association
Community onset - community associated
Records created prior to 01/04/2017 should not be apportioned.
apportion_prior_healthcare(
patient_location,
patient_category,
adm_date,
spec_date,
adm_3_mo,
adm_4_weeks,
adm_12_weeks,
date_record_created
)
patient_location |
The patient's location at time of sample |
patient_category |
The patient's category at time of sample |
adm_date |
Date of admission |
spec_date |
Date of specimen |
adm_3_mo |
Was the patient an inpatient at the trust in previous three months. String yes, no or don't know |
adm_4_weeks |
Was the patient admitted at any point 4 weeks prior to specimen. String yes or no |
adm_12_weeks |
Was the patient admitted at any point 12 weeks prior to specimen. String yes or no |
date_record_created |
Date record entered onto DCS |
A string variable giving the apportioning type; one of hoha, coha, coia or coca, all_blank if all of the prior healthcare exposures were NA, unknown_3_mo if prior health care in past three months was "Don't know" or NA if date record created < 01/04/2017
testdat <- data.frame(
patient_location = "NHS Acute Trust",
patient_category = "In-patient",
date_admitted = lubridate::dmy("01-01-2017"),
specimen_date = lubridate::dmy("05-01-2017"), admission_in_3 = "yes",
adm_4_wks = "yes", adm_12_wks = "yes",
date_entered = lubridate::dmy("01-04-2017"),
stringsAsFactors = FALSE)
testdat
testdat$apportioned_prior_hc <- apportion_prior_healthcare(
patient_location = testdat$patient_location,
patient_category = testdat$patient_category,
adm_date = testdat$date_admitted,
spec_date = testdat$specimen_date,
adm_3_mo = testdat$admission_in_3,
adm_4_weeks = testdat$adm_4_wks,
adm_12_weeks = testdat$adm_12_wks,
date_record_created = testdat$date_entered
)
testdat
## Not run:
testdat$apportioned_prior_hc <- NULL
testdat2 <- data.frame(
patient_location = rep("NHS Acute trust", 3),
patient_category = rep("In-patient", 3),
date_admitted = rep(lubridate::dmy("01-01-2017"), 3),
specimen_date = rep(lubridate::dmy("01-01-2017"), 3),
admission_in_3 = c("yes", "yes", "yes"),
adm_4_wks = c("yes", "no", "no"),
adm_12_wks = c("no", "yes", "no"),
date_entered = lubridate::dmy("01-04-2017"),
stringsAsFactors = FALSE)
testdat <- dplyr::bind_rows(testdat, testdat2)
testdat
testdat$apportioned_prior_hc <- apportion_prior_healthcare(
patient_location = testdat$patient_location,
patient_category = testdat$patient_category,
adm_date = testdat$date_admitted,
spec_date = testdat$specimen_date,
adm_3_mo = testdat$admission_in_3,
adm_4_weeks = testdat$adm_4_wks,
adm_12_weeks = testdat$adm_12_wks,
date_record_created = testdat$date_entered
)
testdat
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.