Emotions and thoughts can trigger problems sleeping. Stress, anxiety, sadness, depression can keep you from getting the sleep you need.  Most times when the emotional trigger (i.e.: situation, hormone imbalance) goes away, you can sleep better. Sometimes the trigger does not go away and interferes with your quality of life and daily activities.
Insomnia can happen despite adequate opportunity and absence of stressful situations and it can cause distress and affect day-to-day functioning. Chronic insomnia happens when someone has sleep problems three or more times per week for more than one month. 
Other medical conditions such as chronic pain, sleep apnea or restless leg syndrome can also affect your sleep. Your physician can assess if you have these symptoms.
The quantity of food or type of drink (caffeine or alcohol) if taken at the end of the day can affect the amount and quality of your sleep. 
Some cancer patients are at high risk for sleeping problems/insomnia because:
- the cancer itself may cause problems like nausea, shortness of breath or pain
 
 
- your body chemistry may be altered - such as with hormone fluctuations
 
 
- cancer-related medications like corticosteroids, pain medications or side effects of chemotherapy can affect your ability to sleep
 
 
- fears and worries  about coping and support
 
 
- trouble falling asleep at bed-time, 
 
 
- night-time waking, 
 
 
- waking too early, 
 
 
- not feeling refreshed upon waking
 
 
- daytime problems with memory, attention and fatigue
 
 
- Emotional: distress, anxiety, irritability, depression, decreased pleasure and social activities
 
 
- Physical: fatigue, increased day-time sleepiness, pain intolerance 
 
 
- Cognitive: problems with concentration, memory and judgment 
 
 
- Compromised role: difficulty doing your normal social or occupational functions