Hello guys i am new to python and coding.
I want to group following medications(ICD10 coding) :
A00 - B99 1
C00 - D49 2
D50 - D89 3
E00 - E89 4
I have created the dictionary for mapping which looks like :
dict_ICD_10 = {"A":1,"B":1,"C":2,"D":2,"E":3}
but anyhow this looks incorrect because D50 - D89 are in class 3 but according to my encoding it is coming under class 2. I am scratching my head from morning but not able to figure out.Is there a way to do this coding from a diffrent way.
Thanks in advance
Assuming these are always 3 digits, you can take advantage of alphanumeric sorting, and write something like this:
Note that this will return
Noneif there is no match, and you may also want to enforce a valid 3-character code first (for exampleget_class('A1')returns 1, but probably should not). Also,get_class('D90')returnsNonebut may not immediately be obvious why (although maybe in that field it is obvious). Depending on the application you may want to do something different if a code falls in between one of these "holes".