Hospitals can convert the pharmacies into compounding pharmacies. The pharmacist is licensed to mix materials together to make medications. None of that can happen without the raw materials and amounts to mix which can come from manufacturers. But, if the problem is making enough medications for patients, pharmacists that can obtain the raw materials and mix their own. The doses would probably come in envelopes or as injections rather than pill form. They can do this with IV fluid such as normal saline, etc. too. There has to be a dedicated sterile area as when mixing hyperalimentation.
Compounding pharmacies can assist in this task if they are reliable and can get the supplies.