load_mic: Loads microbiology results into R.

View source: R/load_mic.R

load_micR Documentation

Loads microbiology results into R.

Description

Loads microbiology results into the R environment.

Usage

load_mic(
  file,
  merge_id = "EMPI",
  sep = ":",
  id_length = "standard",
  perc = 0.6,
  na = TRUE,
  identical = TRUE,
  nThread = parallel::detectCores() - 1,
  mrn_type = FALSE,
  format_orig = FALSE
)

Arguments

file

string, full file path to Mic.txt

merge_id

string, column name to use to create ID_MERGE column used to merge different datasets. Defaults to EPIC_PMRN, as it is the preferred MRN in the RPDR system.

sep

string, divider between hospital ID and MRN. Defaults to :.

id_length

string, indicating whether to modify MRN length based-on required values id_length = standard, or to keep lengths as is id_length = asis. If id_length = standard then in case of MGH, BWH, MCL, EMPI and PMRN the length of the MRNs are corrected accordingly by adding zeros, or removing numeral from the beginning. In other cases the lengths are unchanged. Defaults to standard.

perc

numeric, a number between 0-1 indicating which parsed ID columns to keep. Data present in perc x 100% of patients are kept.

na

boolean, whether to remove columns with only NA values. Defaults to TRUE.

identical

boolean, whether to remove columns with identical values. Defaults to TRUE.

nThread

integer, number of threads to use to load data.

mrn_type

boolean, should data in MRN_Type and MRN be parsed. Defaults to FALSE, as it is not advised to parse these for all data sources as it takes considerable time.

format_orig

boolean, should report be returned in its original formatting or should white spaces used for formatting be removed. Defaults to FALSE.

Value

data table, with microbiology information.

ID_MERGE

numeric, defined IDs by merge_id, used for merging later.

ID_mic_EMPI

string, Unique Partners-wide identifier assigned to the patient used to consolidate patient information from mic datasource, corresponds to EMPI in RPDR. Data is formatted using pretty_mrn().

ID_mic_PMRN

string, Epic medical record number. This value is unique across Epic instances within the Partners network from mic datasource, corresponds to EPIC_PMRN in RPDR. Data is formatted using pretty_mrn().

ID_mic_loc

string, if mrn_type == TRUE, then the data in MRN_Type and MRN are parsed into IDs corresponding to locations (loc). Data is formatted using pretty_mrn().

time_mic

POSIXct, Date when the specimen was received by the laboratory, corresponds to Microbiology_Date_Time in RPDR. Converted to POSIXct format.

mic_org_code

string, Internal identifier for the organism used by the source system, corresponds to Organism_Code in RPDR.

mic_org_name

string, Name of the organism identified or tested, corresponds to Organism_Name in RPDR.

mic_org_text

string, Full narrative text of the test and results, including sensitivities, corresponds to Organism_Text in RPDR.

mic_org_comment

string, Free-text information about the organism or result, corresponds to Organism_Comment in RPDR.

mic_test_code

string, Internal identifier for the test used by the source system, corresponds to Test_Code in RPDR.

mic_test_name

string, Name of the assay to be performed, or the results of a culture, corresponds to Test_Name in RPDR.

mic_test_status

string, Status of the results, i.e. preliminary or final, corresponds to Test_Status in RPDR.

mic_test_comment

string, Free-text information about the test and results, corresponds to Test_Comments in RPDR.

mic_spec

string, Type of specimen collected to perform the test, corresponds to Specimen_Type in RPDR.

mic_spec_txt

string, Free-text information about the specimen, its collection or its integrity, corresponds to Specimen_Comments in RPDR.

mic_accession

string, Internal tracking number assigned to the specimen for identification in the microbiology lab, corresponds to Microbiology_Number in RPDR.

Examples

## Not run: 
#Using defaults
d_mic <- load_mic(file = "test_Mic.txt")

#Use sequential processing
d_mic <- load_mic(file = "test_Mic.txt", nThread = 1)

#Use parallel processing and parse data in MRN_Type and MRN columns and keep all IDs
d_mic <- load_mic(file = "test_Mic.txt", nThread = 20, mrn_type = TRUE, perc = 1)

## End(Not run)

parseRPDR documentation built on March 31, 2023, 11:36 p.m.