Agreed...usually if a pilot leaves they have a flight attendant step inside the cockpit until the pilot returns.
Were there only two pilots on the flight deck on this aircraft? No others?
If the locked in pilot had a medical issue, did the airlines not think the other pilot could possibly be locked out?
I can’t believe this could be overlooked.
Sometimes they have a couple flight attendants barricade the aisle with a beverage cart and they leave the door ajar.