Answer:
It's not very scary, because it happens more often then you would think. A problem like this that is not corrected is a sign of a lack of communication, and it has the potential for losing your job/license, or a lawsuit. This would likely not be a jailable offense.
Explanation:
Before reading my answer, know that I am a medical assistant, not a doctor. Medical assistants are typically the ones to write up prescriptions, and they are signed off by the doctor before being sent to the pharmacy.
Giving someone the wrong medication is typically not a big deal because the doctor will catch the problem if the MA does not. If the wrong prescription went through, this would be a potentially big deal. This is something that should be caught by the billing department as a last resort, and if not, it is unlikely that the completely wrong prescription is given.
What I mean by that is giving someone a light painkiller like an NSAID is not likely going to be mixed up with say, an antibiotic. The person writing the prescription would have to be very ignorant to do that, and the doctor would have to forget the patient's information or nonchalantly sign off a prescription to allow it to happen. Additionally, the billing department would have to be ignorant as well for this to go through. Big mistakes like this are almost always caught in any functional workplace.
Usually the only wrongly prescribed medications would be like giving someone 500mg ibuprofin instead of 800mg, or vice versa. This kind of mistake is usually not dangerous, but they happen.
For disciplinary action to be taken, you would have to repeat the mistake or have proof that you were trying to hurt the patient intentionally. Doctors are protected by laws, so remember that while looking into your profession. These will change depending on your state, but you can find information for each state pretty easily.
Hope this helps!