# Aiding ICD-10 Encoding of Clinical Health Records Using Improved Text Cosine Similarity and PLM-ICD
## 4 Methodology
### Text Pre-Processing for Cosine Method  
For the Cosine method, preprocessing each EHR includes the removal of extra white spaces, leading spaces, stop words, punctuation, conversion to the base form and lower-case.  
A blacklist of words, such as \"patient\" and \"hospital\", was also created, because some words have high prevalence in some texts and they are irrelevant for the codification process. This is because some ICD-10 codes have for example the word \"patient\", such as \"Y92230-Patient room in hospital as the place of occurrence of the external cause\", or \"Z911-Patient's noncompliance with medical treatment and regimen\". Given the fact that those words are very prevalent in the EHRs, the Cosine method encodes them and they interfere with classification, despite the absence of meaning for the task.  
A NER model \"en_ner_bc5 cdr_md\", from scispaCy ([[https://allenai.github.io/scispacy/](https://allenai.github.io/scispacy/)]([https://allenai.github.io/scispacy/](https://allenai.github.io/scispacy/)), accessed on 10 October 2023), a library of clinical and biomedical specific components that integrate with spaCy, was also used to identify disease entities and exclude tokens that are not disease entities.  
The detection of clinical acronyms, using a regular expression and a dictionary containing its definitions, and replacement by its long form, was also used. Taking the example of EHR with subject ID \"10002443\" and hadm ID \"21329021\", the short form word \"afib\" is present in the text, but not in any ICD-10 code description. After the long form replacement of \"afib\" by \"atrial fibrillation\", the Cosine method could find the ICD-10 code \"I480-Paroxysmal atrial fibrillation\". The acronym dictionary built contains 256 pairs of acronyms and their long form.  
EHRs could contain recognized entities that are not present in ICD-10 code description. But some of those entities have synonyms, for example, \"dyslipidemia\" is an EHR disease entity that is not present in ICD-10 code description, but the synonym \"hyperlipidemia\" is. Hence, a dictionary was manually built in Python with entities and synonyms of those entities.  
The manual dictionary was created as a proof of concept, based on the observation that sometimes the keywords in the ICD-10 code description do not match the equivalent keywords in the EHR text, because synonyms are used. For example, in the EHR with subject ID \"1000017\" and hadm ID \"22927623\", the ICD-10 code \"K31819--Angiodysplasia of stomach and duodenum without bleeding\", the disease entity \"angiodysplasia\" was not present in the EHR text. The synonym \"angioectasia\" is present instead. For this reason, the Cosine method could not properly detect the code. After implementation of the dictionary of disease synonyms, containing the pair \"angiodysplasia/angioectasia\", the method was able to correctly detect the \"K31819\" ICD-10 code. The dictionary of synonyms, as a proof of concept, contains only four pairs of entities and their synonyms, and expansion is left for future work.