So, you have the obligation not to shorten your life per se or to harm yourself intentionally, but you can under certain circumstances licitly permit your death.
In this case, we must distinguish between ordinary care (supplying the needs of the body, etc, as much as possible) and extraordinary care (administering medical treatments) and the nature of the illness. Examples (simplified because I'm not writing a book here):
x. If your illness is treatable and curable, but refusing treatment will lead to death, then you are obligated to receive treatment to the degree that such treatment does not compete with equal or superior concerns. Can you afford treatment? Could it deprive you of the means to live anyhow? These considerations would make treatment an option, but not an obligation.
x. If your cancer is terminal (i.e., it is incurable), and you are able to absorb nutrients, you are obligated to take in nutrition, but not to receive treatment.
x. If you are unable to receive nutrition (or the offering of nutrition causes harm), then you are not obligated to receive nutrition.
x. If treatment causes disproportionate harm in relation to the disease, then treatment is not an obligation.