Rescuing referral failures during automated diagnosis of domain-shifted medical images