Skip to content

Incorrect mapping due to lack of precise matching strategy #6

@FearlessNewbie

Description

@FearlessNewbie

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions