Yes it is true that events won't be triggered when you are using the excel importer. The same applies to database replication and xml mapping(modeler) or any custom Java action that uses Batches to process the imported objects.
Batches are created whit the purpose to process objects as fast as possible, this is achieved by caching the objects and storing them with a single sql query. Speaking for the excel importer and db replication: All data is being cached, during the import the actual entity is never available. So when the objects are created or stored there is no entity, no entity information, therefore the entity events are unknown and can't be executed.
You've already found the workaround, it is explained in the link you provided in your commend (see below), maybe or R&D department will make it possible to execute events while still using an create or change batch. But for now the only solution is using the workaround below....
Or run a microflow after import that does the trick. The link from Jasper requires in-depth Mendix knowledge.
Create a before commit event in the entity that does the calculation when YearOfBirth is empty. Hoping that the excelimporter triggers that event.
You can use a virtual attribute to calculate the yearofbirth from existing attributes
(it doesn't seem completely clear from your question where this value comes from. Is the dayofbirth something you can use to calculate the yearofbirth or does yearofbirth come from somewhere else?)
to clearify. YearOfBirth is also an attribute of the Patient-entity. This entity contains an attribute DateOfBirth AND YearOfBirth (which is extracted from the DateOfBirth entity).
@Chris, Can you explain in more detail what you mean. I have a Microflow which will fill the attribute YearOfBirth and it is working fine. But I have to trigger it manually. I'm just looking for a way to execute it automatically.