I changed the annotation map from (internal code -> hpo) to (code -> hpo). Because the internal code is enum I could not figure out a better way to generalize it. The new implementation passed the tests and will be able to handle FHIR observations that have a coded value (such as snomed "S. aureus" is detected). But unfortunately it is a little more complicated than your original code, so I am not sure whether you will like it. Feel free to reject.
I changed the annotation map from (internal code -> hpo) to (code -> hpo). Because the internal code is enum I could not figure out a better way to generalize it. The new implementation passed the tests and will be able to handle FHIR observations that have a coded value (such as snomed "S. aureus" is detected). But unfortunately it is a little more complicated than your original code, so I am not sure whether you will like it. Feel free to reject.