The use of marijuana is intrinsically evil in virtue of the fact that it compromises our reason. This is in the same order as drunkenness due to alcohol. Medical marijuana uses it for a particularly different end.
In the case of a cancer patient, their reason may already be compromised in virtue of chemotherapy, their illness and many other factors. Medical marijuana then aids in removing some of the serious suffering and helps patients to take in and keep down food for the preservation of their life. It is licit in so far as reason is already compromised by pain in addition to adding the basic necessities of life in maintaining nutrition.
This is analogous to a person who drinks heavily before an amputation without anesthetic. The end sought is not drunkenness in itself, but the relief of the severe pain that will entire impair his reason in any case. The purpose of medical marijuana is not the impairment of our faculties, but relief after our faculties have already been compromised through illness and even the preservation of our life by inhibiting vomiting resulting from the chemotherapy.