|
mapped9 <- grep(icd9map$ICD9[i],codeICD9) |
The current matching logic causes the ICD‑9 code “E950” to be incorrectly mapped not only to its intended phecode, but also to phecode “950” via substring matching.
To prevent this erroneous roll‑up, a from-start (^) matching strategy should be applied so that detailed ICD‑9 codes are matched strictly from the beginning of the code string and only rolled up when explicitly intended.
pattern <- paste0("^", gsub("([][{}()+*^$|\\?.])", "\\\1", icd9map$ICD9[i]))
mapped9 <- grep(pattern, codeICD9)
createUKBphenome/scripts/function.createUKBphenome.r
Line 97 in dcc06c8
The current matching logic causes the ICD‑9 code “E950” to be incorrectly mapped not only to its intended phecode, but also to phecode “950” via substring matching.
To prevent this erroneous roll‑up, a from-start (^) matching strategy should be applied so that detailed ICD‑9 codes are matched strictly from the beginning of the code string and only rolled up when explicitly intended.
pattern <- paste0("^", gsub("([][{}()+*^$|\\?.])", "\\\1", icd9map$ICD9[i]))
mapped9 <- grep(pattern, codeICD9)