icd
icd copied to clipboard
Hierarchy in HCC is not respected
Hello!
In the following example Hierarchy is not respected for diabetes (with ICD10 codes as inputs):
pts <- data.frame( patient_id = c( "1", "1", "1" ),
icd_code = c( "E099", "E08638", "E13641" ),
date = as.Date(c("2019-01-01", "2019-01-01", "2019-01-01" ) ) )
pts
comorbid_hcc( pts )
Output:
patient_id date hcc
1 2019-01-01 17
1 2019-01-01 18
1 2019-01-01 19
#######################################
Update:
It is a bug somewhere in date
parameter of the function.
In the following example the hierarchy is working:
pts <- data.frame( patient_id = c( "1", "1", "1" ),
icd_code = c( "E099", "E08638", "E13641" ),
date = as.Date(c("2018-01-01", "2018-01-01", "2018-01-01" ) ) )
comorbid_hcc( pts )
# Output
patient_id date hcc
1 2018-01-01 17
I think the problem might be here:
https://github.com/jackwasey/icd/blob/e54bb247da2e4128c1ba91598767a18160cbff1d/R/hcc.R#L81
x$year
is set from the data without validation. Also if the dates are before 2014 or after 2019 you get an empty result.
There should be a way for the user to override the year auto-guessing and apply the same year for all visits because:
- When de-identifying health records it is a common practice to date-shift, therefore one cannot rely on the nominal date in the record to select the correct HCC version.
- One might wish to compare past records using a common HCC version.