added permission queries for doctor and patient