Gender, psychosocial factors and the use of medical services: a longitudinal analysis