This particular Catholic doctrine comes straight out of 1 Corinthians 11:23-30.
Then it is improperly enforced by the RC church, for it says clearly "every man should examine himself before he eats the bread and drinks of the cup", not a priest should decide or some other church authority.