The past few weeks I’ve been wrangling some knotty algorithm that is to do with Elixhauser comorbidity calculations for the new 2022 rule set in the healthtech startup space. And the code I’ve written is very procedural, and hopefully easy to read, but also kind of like wading through thick mud in terms of understanding how values drop out of the bottom of the algorithm.
Let’s put it this way, this shit’s so arcane and weird that even the SAS code provided by the governing body that demonstrates the algorithm doesn’t adhere to the spec, and that point is even called out in the scant amount of documentation for the code. And let’s face it, SAS source code is bad enough as-is at the best of times, a 4GL language from the 1970’s that has grown warts in its old age, where any program written in SAS winds up looking like a 2,000 line DOS batch file, and I am thoroughly convinced that whoever wrote this particular chunk of SAS source code not only hates his job but also hates every person on this planet that doesn’t have to use SAS to get their job done.
Now once you explain the rules of how the Elixhauser algorithm works to someone, yourself having waded through three PDFs and the aforementioned SAS source code, the algorithm makes sense, in a roundabout fashion, but there’s still these “rules of exclusion” where “if the patient has this comorbidity, but it didn’t present on admittance, then this other rule applies instead.”
I think if I were implementing this multi-stage procedural algorithm all over again, I’d jettison all of my code that I’ve written over the past three weeks and implement the entire shebang as a filter trie, AKA a Bloom Filter Trie, about 25,000 inputs at the trie root, and about 7 outputs as the trie leafs.
I’ll say this, my years of studying the Dungeon Master’s Guide and Player’s Handbook across all the editions of D&D, looking for exploits and rules that could work in my favour, have gone some way to helping me decipher DRG (Diagnosis Related Groups) and Exlihauser algorithms over these past two months.