This version completes generating training csv from database. It can assign patients according to the configuration.