convert2regex: Create "REGEXP_LIKE" SQL commands

Description Usage Arguments Details Value See Also Examples

Description

This function creates a series of "REGEXP_LIKE" SQL commands, given a set of starting strings of ICD codes and a starting pattern to match.

Usage

1
convert2regex(nm, str, colName, add.periods = FALSE)

Arguments

nm

A character vector of starting strings of ICD10 codes.

str

A specific starting string that is used to match the ones in nm. Only the matching ones in nm are considered to create the output SQL commands.

colName

The corresponding column name to put in "REGEXP_LIKE" commands.

add.periods

A logical value controlling whether or not to add periods after the third character of ICD codes.

Details

str is usually a very short string. The function first extracts all the strings in nm that start with str. Then those strings are divided into groups that share the first 1, 2, or 3 letters, with only the last letter being different. For each of these groups, a SQL command like this is created, "OR REGEXP_LIKE (DX_CD,'^I0[1,2,5,6,7,8]','im')".

Value

A character string of a series of "REGEXP_LIKE" SQL commands.

See Also

writeSQL

Examples

1
2
3
4
5
6
7
8
9
bpExclICD9 <- c(1400:2089,2300:2399,8000:8399,8500:8549,8600:8699,
                9050:9099,92611,92612,929,9520:9529,9580:9599,3040:3042,
                3044,3054:3057,34460,7292,4210,4211,4219,0380:0389,01,
                7300:7309,7832,78079,7808,2859)
bpExclICD10 <- getICD10(bpExclICD9)
codeList <- convertToLike(codes = bpExclICD10, dict = ICD9to10$ICD10,2,4)
nm <- names(codeList$LIKE)

cat(convert2regex(nm,'C',colName = 'DX_CD'))

songxh0424/MPrOVE-package documentation built on May 19, 2019, 4:18 p.m.