ellessenne / comorbidity

An R package for computing comorbidity scores.
https://ellessenne.github.io/comorbidity/
GNU General Public License v3.0
80 stars 21 forks source link

Handling of mixed ICD-9 and ICD-10 #42

Closed janickweberpals closed 2 years ago

janickweberpals commented 3 years ago

Hi there, First of all, thanks for the great package which has worked for me like a charm so far. I was wondering if the comorbidity function can also handle if both ICD-9 and ICD-10 codes co-exist in the same column? From the documentation I assumed that this is supported (with the option to apply different mappings using the map parameter) but wanted to double check that this is correct. Thanks!

ellessenne commented 3 years ago

Hi, thanks for your kind words! Regarding your question, do you mean running the comorbidity() function with both ICD-9 and ICD-10 codes that are both used to determine conditions? If so, that is not supported – when using ICD-10 only ICD-10 codes are used, and viceversa; however, you can still pass the dataset, and only relevant codes will be picked up by default (unless there is some odd collision, but I don't think there is). If you want to use both coding systems, I would actually recommend running comorbidity() twice, once with ICD-9 and once with ICD-10, and then combine the results. Let me know if this makes sense, thanks!

abduazizR commented 3 years ago

Hi,

I have a follow-up question. Based on your advice to run comorbidity() twice to capture ICD-9 and ICD-10 systems, what is the correct way to calculate the total unweighted and weighted scores?

Thanks!

ellessenne commented 3 years ago

Hi, Sorry for the delayed response. Combining the scores would require quite a bit of data wrangling, I suspect you'd have to:

  1. First, combine the presence/absence of each condition;
  2. Then, apply the scoring algorithms (with or without weights).

I can't think of a single, straightforward way of doing that, sorry! Hope this helps,

Alessandro

davigood1 commented 1 year ago

I tried doing this with code below, following your advice. However, by combining/summarizing by personid, the dataframe loses its "comorbidity" property. Any advice on how to combine without losing this.

df.diagnoses.icd10 <- df.condition.icd10 %>% comorbidity(id = "personid", code = "condition_code_id", map = "elixhauser_icd10_quan", assign0 = FALSE)

df.diagnoses.icd9 <- df.condition.icd9 %>% comorbidity(id = "personid", code = "condition_code_id", map = "elixhauser_icd9_quan", assign0 = FALSE)

df.diagnoses.icd9_10 <- bind_rows(df.diagnoses.icd9, df.diagnoses.icd10)

df.diagnoses.icd9_10 <- df.diagnoses.icd9_10 %>% group_by(personid) %>% summarise(across(chf:depre, ~max(.))) %>% mutate(Elixhauser = score(x = ., weights = NULL, assign0 = FALSE))

ellessenne commented 1 year ago

Hi @davigood1, I think you have to to first run the score() function to df.diagnoses.icd10 and df.diagnoses.icd9, and then combine them using some logic similar to the one you use. I think it would be easy to combine comorbid conditions (just take the max), but I suspect you would have to be a bit more careful with the weighted scores.