I think it would be better to check if the encounterProviders's list is null or empty or just remove this if clause, because it is possible to be editing an existing encounter with no provider, this can typically occur for implementations that upgraded from older versions