getAbnormalMark generates a new column recorded abnormal values: high H and L.

getAbnormalMark(
  labData,
  idColName,
  labItemColName,
  valueColName,
  genderColName,
  genderTable,
  referenceTable = refLOINC
)

Arguments

labData

a file or dataframe of laboratory test data with at least 4 columns about patient ID, lab item, test value and test date, respectively.

idColName

the column name that records patient ID in labData.

labItemColName

the column name that records lab item in labData. If lab code is combined by multiple columns, then just simply add + operator between column names, e.g., A + B.

valueColName

the column name that records test value in labData. Only numeric value is acceptable.

genderColName

the column name that records gender of each patient. Gender should be coded as M or F.

referenceTable

a data table that records reference values of each lab item. Column names should be: LowerBound_Male, UpperBound_Male, LowerBound_Female, UpperBound_Female. The labItemColName of labData and refLOINC have to be the same.

Value

A data.table merged two tables.

Details

This step is optional but recommended. Reference ranges differ in different institutions, so a user-defined reference table is needed. The table should record the reference values for male and female separately. Lower bound can be expressed as <, ( (greater than) or <= , [ (great tham or euqal to), and the expression of upper bound is similar. If there is no upper bound or lower bound, just remain empty. After the new abnormal flag column generated, it can be used to do categorical analysis, or be used in the function: plotTimeSeriesLab.

Examples

loincSample <- mapLOINC(labData = labSample,
                       labItemColName = ITEMID,
                       mappingTable = mapSample)

#Use LONIC table (default)
getAbnormalMark(labData = loincSample,
               idColName = SUBJECT_ID,
               labItemColName = LOINC,
               valueColName = VALUENUM,
               genderColName = GENDER,
               genderTable = patientSample,
               referenceTable = refLOINC)
#>       ITEMID  ID  CHARTTIME Value VALUEUOM     FLAG
#>    1:  50861  36 2131-04-30   8.0     IU/L         
#>    2:  50861  36 2131-05-17  12.0     IU/L         
#>    3:  50861  36 2134-05-14  12.0     IU/L         
#>    4:  50861 109 2138-07-03  14.0     IU/L         
#>    5:  50861 109 2142-03-21  46.0     IU/L abnormal
#>   ---                                              
#> 1740:  51222 145 2145-02-17   9.8     g/dL abnormal
#> 1741:  51222 145 2144-05-04   9.1     g/dL abnormal
#> 1742:  51222 145 2144-05-26   9.0     g/dL abnormal
#> 1743:  51222 145 2144-04-13  11.2     g/dL abnormal
#> 1744:  51222 145 2144-04-29  10.5     g/dL abnormal
#>                                LABEL FLUID   CATEGORY  LOINC ABMark
#>    1: Alanine Aminotransferase (ALT) Blood  Chemistry 1742-6   <NA>
#>    2: Alanine Aminotransferase (ALT) Blood  Chemistry 1742-6   <NA>
#>    3: Alanine Aminotransferase (ALT) Blood  Chemistry 1742-6   <NA>
#>    4: Alanine Aminotransferase (ALT) Blood  Chemistry 1742-6   <NA>
#>    5: Alanine Aminotransferase (ALT) Blood  Chemistry 1742-6      H
#>   ---                                                              
#> 1740:                     Hemoglobin Blood Hematology  718-7      L
#> 1741:                     Hemoglobin Blood Hematology  718-7      L
#> 1742:                     Hemoglobin Blood Hematology  718-7      L
#> 1743:                     Hemoglobin Blood Hematology  718-7      L
#> 1744:                     Hemoglobin Blood Hematology  718-7      L

#Use user define table
getAbnormalMark(labData = labSample,
               idColName = SUBJECT_ID,
               labItemColName = ITEMID,
               valueColName = VALUENUM,
               genderColName = GENDER,
               genderTable = patientSample,
               referenceTable = refUserDefine)
#>        ID ITEMID  CHARTTIME Value VALUEUOM     FLAG ABMark
#>    1:  36  50811 2131-05-18  12.7     g/dL abnormal   <NA>
#>    2:  36  50811 2131-05-04  12.3     g/dL abnormal   <NA>
#>    3:  36  50811 2131-05-15  10.0     g/dL abnormal      L
#>    4:  36  50811 2131-05-17  11.7     g/dL abnormal      L
#>    5: 109  50811 2142-02-25   6.9     g/dL abnormal      L
#>   ---                                                     
#> 1740: 145  51222 2145-02-17   9.8     g/dL abnormal      L
#> 1741: 145  51222 2144-05-04   9.1     g/dL abnormal      L
#> 1742: 145  51222 2144-05-26   9.0     g/dL abnormal      L
#> 1743: 145  51222 2144-04-13  11.2     g/dL abnormal      L
#> 1744: 145  51222 2144-04-29  10.5     g/dL abnormal      L