well you're either looking at a legal battle or changing school/country of residence. I don't think Spanish CAA have a right to refuse your medical based on a previous assessment without giving you a chance to redo the examination. Best advice I can give is - contact someone in EASA headquarters and see if they can help.
https://www.easa.europa.eu/can-we-help-you
the system in Spain might be bureaucratic, but the rules are the same for all