Doctor would not refill medicine making me have to go to hospital, after being off of medicine for for days
Your question leaves out too much to give a comprehensive answer, such as what type of medicine it is, what reason the MD stated for not refilling, what the condition is, etc. E.g., if this is a pain medication, which susceptible to abuse, the MD may worry that you're becoming addicted or abusing the meds, and need closer evaluation to justify refilling. The MD may have an obligation NOT to refill the meds in that case.
You may wish to a) talk to your MD to get a clear answer for why no refill; b) talk to another MD in the medical specialty that covers this condition/these meds to see what the potential for abuse and side-effects are that might give your MD concern; c) talk to the treating MD at the hospital you went to after no refill to ask why that was necessary; d) all of the above.
MDs have a fine line to walk with medication prescriptions, especially those subject to abuse, addiction or with serious side-effects, between proper administration to benefit patients and looking for misuse or abuse of the meds. MDs seldom withhold refills for no good reason.