Sounds like a bad connection somewhere. Have you tried to link out the switch? Sure someone will give you a better solution, its just a question of working through
the circuit to find the cause.
Maybe the switch is defunked and slamming the door vibrates the switch back into life for a short while?