In essence in order to protect the integrity of the flight deck a double door system would seem the only secure way of ensuring two qualified pilots have permanent access to the flight deck. Built in logic would only allow the outer door to be locked when using the toilet, the outer door only being closed prior to the inner door being opened.
Highly impracticable to retrofit but certainly possible the design stage.