A Jewish doctor who is treating a "Holeh She’yesh Bo Sakana" – a patient in a life-threatening condition – may and must do whatever is necessary to cure the patient, even if this entails violating Shabbat prohibitions. The Torah’s laws are (generally speaking) suspended when human life is at stake, and thus a doctor tending to a dangerously ill patient may even transgress Torah prohibitions in order to treat such a patient.
At first glance, this Halacha would apply as well to writing a prescription for medication. Writing two letters on Shabbat constitutes a Torah violation, but seemingly, this should be permissible for the sake of treating a gravely ill patient. However, Rav Shlomo Zalman Auerbach (Jerusalem, 1910-1995), as cited in the work Nishmat Abraham, ruled that Torah prohibitions are suspended only for direct treatment. Writing a prescription does not directly help cure the patient, but rather enables him or her to obtain the required medications. Such measures, Rav Shlomo Zalman maintained, do not override Torah prohibitions. Therefore, a doctor who must write a prescription for a seriously ill patient on Shabbat should write it with a Shinui – some deviation from the normal manner of writing – as writing abnormally is forbidden only on the level of Rabbinic enactment. Rabbinic prohibitions are waived for the sake of even indirect treatment of a seriously ill patient, and thus a doctor is allowed to – and must – write a prescription in an abnormal manner for such a patient. This would mean either writing with his left hand (if he is right-handed), or writing in an abbreviated form. This is also the ruling of Rav Moshe Feinstein (Russia-New York, 1895-1986), in Iggerot Moshe (Eben Ha’ezer, vol. 4, 73:4), and of Hacham Ovadia Yosef, in Hazon Ovadia (vol. 3, p. 253; listen to audio recording for precise citation).
If a doctor is treating a "Holeh She’en Bo Sakana" – a patient whose condition is not life-threatening – he may not write a prescription, even in an abnormal manner. However, the Halachic authorities addressed the possibility of allowing physicians to write prescriptions using special pens with ink that disappears within 24 hours. Different views exist in this regard. Rav Yitzhak Weiss (1901-1989), in his Minhat Yitzhak, ruled that if the ink lasts throughout the remainder of Shabbat, then the pen may not be used. His ruling is based upon the view of the Rambam (Rabbi Moshe Maimonides, Spain-Egypt, 1135-1204), as understood by the Sha’ar Siyun (Siman 303), that an act whose effects last throughout the remainder of Shabbat qualifies as a Torah prohibition.
Others, however, disagree, noting that Rashi (Rabbi Shelomo Yitzhaki of Troyes, France, 1040-1105) understood the Gemara as saying that a Torah violation is committed only if the effects are permanent, and last forever. The Rashba (Rabbi Shelomo Ben Aderet of Bercelona, 1235-1310) adopted a different view, claiming that the Torah prohibition requires that the effects last the normal, anticipated duration for the act in question. In the case of writing, the normal expected duration of the effects is certainly much longer than 24 hours. According to both Rashi and the Rashba, then, it would be permissible to write a prescription with ink that disappears within 24 hours. On this basis, the work Shemirat Shabbat Ke’hilchatah (Rav Yehoshua Neubert, contemporary), citing Rav Shlomo Zalman Auerbach, allows the use of these pens on Shabbat for writing prescriptions, even for patients whose condition is not life-threatening, and this is the accepted Halacha.
Summary: A doctor treating a seriously ill patient on Shabbat may write a prescription for the patient, as long as he does so in an unusual manner, such as by using his weaker hand. In the case of a patient whose condition is not life-threatening, the doctor may write a prescription only if he uses a pen whose ink disappears within 24 hours.