Coding medical diagnosis in case mix databases is a time-consuming task as every information available in patient records has to be taken into account. We developed rules based on EHR data with the Drools rules engine in order to support diagnosis coding of chronic kidney disease (CKD) in our hospital. 520 patients had a GFR < 60 ml/min as estimated by the Cockroft-Gault formula and corresponded to 429 case mix database entries. We compared stays in which the patient was older than 12 and younger than 65 or 80 at the time of the stay. We concluded that our rules engine implementation may improve coding of CKD for 45.6% of patients with a GFR < 60 ml/min and younger than 65. When patients are older than 65 our rule engine may be less useful for suggesting missing codes of CKD because the estimation of GFR by the Cockroft-Gault formula becomes less reliable as patients get older.