Scotland's chief medic sorry for lapse