mapLOINC is used for merging two tables together. One is lab data with local codes, and the other one is mapping table of local lab codes and LOINC.

mapLOINC(labData, labItemColName, mappingTable = NULL)

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.

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.

mappingTable

a data table with at least two columns: local lab item code and LOINC code. The local column name should be identical as labItemColName in labData.

Value

A data.table merged two tables.

Details

Since the lab item may be coded in local scheme, users can map it with LOINC by providing LOINC mapping table. This step is optional but recommended. After mapped, user can select desired laboratory tests by using function searchCases.

Examples

mapLOINC(labData = labSample,
        labItemColName = ITEMID,
        mappingTable = mapSample)
#>       ITEMID SUBJECT_ID  CHARTTIME VALUENUM VALUEUOM     FLAG      LABEL FLUID
#>    1:  50811         36 2131-05-18     12.7     g/dL abnormal Hemoglobin Blood
#>    2:  50811         36 2131-05-04     12.3     g/dL abnormal Hemoglobin Blood
#>    3:  50811         36 2131-05-15     10.0     g/dL abnormal Hemoglobin Blood
#>    4:  50811         36 2131-05-17     11.7     g/dL abnormal Hemoglobin Blood
#>    5:  50811        109 2142-02-25      6.9     g/dL abnormal Hemoglobin Blood
#>   ---                                                                         
#> 1740:  51222        143 2155-03-09     10.4     g/dL abnormal Hemoglobin Blood
#> 1741:  51222        143 2155-04-02     11.1     g/dL abnormal Hemoglobin Blood
#> 1742:  51222        145 2144-04-13     11.2     g/dL abnormal Hemoglobin Blood
#> 1743:  51222        145 2144-04-29     10.5     g/dL abnormal Hemoglobin Blood
#> 1744:  51222        143 2155-02-01     10.2     g/dL abnormal Hemoglobin Blood
#>         CATEGORY LOINC
#>    1:  Blood Gas 718-7
#>    2:  Blood Gas 718-7
#>    3:  Blood Gas 718-7
#>    4:  Blood Gas 718-7
#>    5:  Blood Gas 718-7
#>   ---                 
#> 1740: Hematology 718-7
#> 1741: Hematology 718-7
#> 1742: Hematology 718-7
#> 1743: Hematology 718-7
#> 1744: Hematology 718-7