Compute the number of routine bloodwork tests per encounter
n_routine_bloodwork.Rd
n_routine_bloodwork
returns the number of routine bloodwork (Sodium and
Hemoglobin tests) for each hospital admission. Sodium and Hemoglobin tests
are defined by OMOP codes. Sodium is the code 3019550. Hemoglobin is 3000963.
Arguments
- dbcon
(
DBIConnection
)
A database connection to any GEMINI database. OnlyDBI
connection is accepted asodbc
connection may cause connection issues in certain environment.- cohort
(
data.frame
ordata.table
) Cohort table with all relevant encounters of interest, where each row corresponds to a single encounter. Must contain GEMINI Encounter ID (genc_id
).- exclude_ed
(
logical
) Whether to exclude tests in emergency department. When set toTRUE
, tests performed in ED settings (testing time before admission time) will not be counted. When set toFALSE
, tests will not be filtered by time and all tests in lab table will be counted. Please be aware that this may include tests before triage time, tests after discharge time, and tests without testing time. Tests in ED are defined ascollection_date_time
earlier thanadmission_date_time
. Tests with missingcollection_date_time
will be excluded whenexclude_ed
is set toTRUE
.
Value
data.table object with the same number of rows as input "cohort", with additional derived numeric field labelled as "n_routine_bloodwork_derived"
Details
This function takes a list of admissions and an GEMINI databse connection to generate numeric fields counting the number of Sodium and Hemoglobin tests for each admission.
Lab table in the database should include field that classifies each test into a few different categories. Therefore, this function should be run after some standardization efforts on lab table (performed by GEMINI). Currently, the number of routine bloodwork tests is one of the performance metrics in MyPracticeReport.
Function does NOT removes tests without valid numeric result value to include all tests where blood was drawn from the patients.
Warning
Function returns data.table with id field genc_id
and one numeric field
indicating the number of bloodwork tests per encounter. By design,
function will not return any NA values. If a genc_id
does not have any
entries in the "lab" table, the admission gets assigned 0 number of tests.
User should check lab data coverage and decide whether the imputed 0
s are
appropriate or not.
When one tries to left-join the output of this function with another table
(another list of admissions in the left), make sure list of admissions (or
patient) aligns in both tables.
This function requires mappings by a Subject Matter Expert to ensure that all tests are mapped to 3019550 - Sodium (Moles/volume) in Serum or Plasma, and 3000963 - Hemoglobin (Mass/volume) in Blood