jackwasey / icd

Fast ICD-10 and ICD-9 comorbidities, decoding and validation in R. NB use main instead of master for default branch.
https://jackwasey.github.io/icd/
GNU General Public License v3.0
242 stars 60 forks source link

as.decimal_diag, as.icd_short_diag, as.short_diag functions outputing opposite results #176

Open lai1737 opened 5 years ago

lai1737 commented 5 years ago

test_data.txt

When I used the

  1. as.decimal_diag with my test data above in the decimal format, it spits out a FALSE,
  2. as.icd_short_diag with my test data above in the decimal format, it spits out a TRUE,
  3. as.short_diag with my test data above in the decimal format, it spits out a TRUE

Which is the opposite of what things should be...

patrickmdnet commented 4 years ago

The icd package does not detect which kind of ICD code (ICD-9 vs ICD-10) nor the format (decimal vs short.) Instead it allows you to get and set attributes on the icd object to mark the kind of ICD and the format. The as.* functions return the value of the "icd_short_diag" attribute.

So, as.decimal_diag sets the "icd_short_diag" attribute to FALSE, and as.short_diag sets the attribute to TRUE. In fact, the output does not depend on the ICD code that is passed in.