As WP says, that really depends on your country.
As a general rule, your state of license issue has to match your state of medical issue. However, nothing stops you to swap the foreign JAA medical for your local JAA medical. Most countries free, I think the UK CAA takes GBP20.
This swap will be signed by the head of your aeromedical section, so if he / she denied your medical previously, he may have a very close look and double check that you ticked the box in this other JAA state confirming that you were denied a class 1 previously... Very careful!
Once we know which state this is about, we may be able to help more...
cheers, IP