The freetext matching algorithm: a computer program to extract diagnoses and causes of death from unstructured text in electronic health records