public MedicalEvent resolveEntity(EntityManager em) {
HealthRecord healthRecord = entity.getHealthRecord();
if (healthRecord != null) {
entity.setHealthRecord(em.getReference(HealthRecord.class, healthRecord.getHealthRecordId()));
}
DataSource dataSource = entity.getDataSource();
if (dataSource != null) {
entity.setDataSource(em.getReference(DataSource.class, dataSource.getDataSourceId()));
}
return entity;
}