Prescription with medication schedule
A printed prescription and patient schedule from your EHR
- Template
- DOCX
- Export as
- PDF, DOCX, ODT, HTML, PNG +25 more
- Carbone
- 5.16+
- Loop
- Count
- Aggregation
- Condition
- Number format
- HTML
- Date
- Header and footer
Generate printed prescriptions from your EHR or e-prescribing software
EHR, e-prescribing and practice management software send prescriptions to the pharmacy electronically, in the NCPDP SCRIPT standard. They still print one when the patient asks for paper, when the pharmacy cannot receive it or when the network is down, and they print an after-visit summary with the medication schedule at the end of each visit. Your application sends the visit to the Carbone API as JSON and gets both pages back in one PDF. When patient data must stay in your infrastructure, Carbone On-Premise renders it on your own servers.
In this example, Fernhollow Health, a family medicine clinic in Columbus, Ohio, prints a prescription for three non-controlled medicines, then the patient's medication schedule. The clinic, the prescriber and the patient are fictional, the header carries a specimen tag, and the NPI fails the CMS check digit, so it can never belong to a real prescriber.
In this example, you will:
- Number and count the prescriptions with
:countand:aggCount - Print the quantities and the refills in numbers and in words with
:toWord - Print "Substitution permitted" or "Dispense as written" with an inline condition
- Fill a schedule with morning, noon, evening and bedtime columns
- Calculate the age of the patient and the end of each supply
- Repeat paragraphs for the next steps and render patient advice from HTML
The fields of a printed prescription
The clinic is in Ohio, so the prescription follows the rules of the Ohio Board of Pharmacy and the federal rules that apply in every state. The patient page follows the Universal Medication Schedule.
| Field | Rule | In the template |
|---|---|---|
| Prescriber full name, title, practice address and phone | Ohio Adm.Code 4729:5-5-15 (B)(2) and (B)(3) | Prescriber box |
| Patient full name and residential address | 4729:5-5-15 (B)(4) | Patient box, with the date of birth and the allergies |
| Date of issue | 4729:5-5-15 (B)(1) | Title block and signature block |
| Drug name and strength, quantity, explicit directions | 4729:5-5-15 (B)(5) to (B)(7) | One block per prescription, with the dosage form and the days supply |
| Refills, never beyond one year after the date of issue | 4729:5-5-15 (B)(8) and (B)(11) | Refills in numbers and in words |
| "Dispense as written" handwritten or displayed by the prescriber, never preprinted | Ohio Rev.Code 4729.38, 4729:5-5-15 (F)(1) | The prescriber's choice for each drug, from the data |
| At most three non-controlled prescriptions on a computer-generated form | Ohio Adm.Code 4729:5-5-05 | Three prescriptions, counted on the form, then "No entries follow" |
| Manual signature on the day of issue | 4729:5-5-15 | Signature line, printed name and date |
| Active and valid NPI of the prescriber on Medicare Part D claims | 42 CFR 423.120(c)(5) | Prescriber box |
| Four standard times: morning, noon, evening, bedtime | NCPDP Universal Medication Schedule | Directions on page 1, schedule on page 2 |
A printed or faxed prescription needs the handwritten signature of the prescriber: a mention such as "electronically signed" does not replace it. The template leaves a signature line and never prints a signature image.
The example prescribes non-controlled medicines only. A controlled substance adds the DEA registration number of the prescriber (21 CFR 1306.05), and Ohio requires an electronic prescription for Schedule II drugs (Ohio Rev.Code 3719.06).
For a patient covered by Medicaid, a written prescription must carry at least one tamper-resistant feature in each of three categories: copying, erasure or modification, and counterfeit forms. CMS accepts prescriptions printed from an EHR on plain paper when they carry these features, such as microprinting or a "void" pantograph. Prescriptions sent electronically or by fax are exempt. This specimen carries none of these features: print it on the tamper-resistant paper approved by your compliance team.
How to build the prescription in Word
1. Set Up the Header and the Footer
- Open the File menu, select Page Setup and choose the US Letter paper size.
- In the header, add the clinic logo, the clinic
{d.clinic.name}, {d.clinic.department}, its address{d.clinic.street}, {d.clinic.city},{d.clinic.phone}and{d.clinic.fax}. - In the footer, repeat the patient name and date of birth on every page,
{d.patient.name} · DOB {d.patient.birthDate:formatD(L)}, then the prescription ID{d.rxId}and the page number as "Page X of Y".
2. Fill the Prescriber and Patient Boxes
- Prescriber:
{d.prescriber.name}, {d.prescriber.credentials},{d.prescriber.specialty}and{d.prescriber.npi}. - Patient:
{d.patient.name},{d.patient.street},{d.patient.city}and{d.patient.allergies}. - :formatD prints the date of birth:
{d.patient.birthDate:formatD(L)}gives 05/09/1966 with theen-uslanguage. - :diffD calculates the age on the date of issue:
{d.patient.birthDate:diffD(d.issueDate, 'years')}.
3. List the Prescriptions
The JSON data contains a medications array. Each prescription is a table row with four paragraphs: the drug, the directions (sig), the quantities and the indication. Add the loop tags:
- In the first paragraph:
{d.medications[i].drug:count()}, a tab, then{d.medications[i].drug} {d.medications[i].strength} {d.medications[i].form}. :count numbers the prescriptions from 1. - Below it:
{d.medications[i].sig},{d.medications[i].daysSupply}and{d.medications[i].indication}. - In the next row:
{d.medications[i+1]}to end the loop.
The heading row counts the prescriptions with :aggCount: {d.medications[].drug:aggCount}. Ohio allows three non-controlled prescriptions on a computer-generated form: split a longer list into several forms.
4. Write the Quantities in Words
The quantity and the refills appear in numbers and in words, so a changed figure stands out. The :toWord formatter spells out a number in the language of the report:
{d.medications[i].quantity} ({d.medications[i].quantity:toWord}) {d.medications[i].unit}
{d.medications[i].refills} ({d.medications[i].refills:toWord})With the "lang": "en-us" option, Carbone prints "180 (one hundred eighty) tablets" and "1 (one)". The heading uses the same formatter after the count: {d.medications[].drug:aggCount:toWord}.
5. Print the Substitution Choice
The prescriber chooses in the EHR whether the pharmacist may dispense a generic equivalent. An inline condition prints the choice for each drug:
{d.medications[i].dispenseAsWritten:ifEQ(true):show('Dispense as written'):elseShow('Substitution permitted')}6. Leave the Signature to the Prescriber
Below the prescriptions, a table holds the signature line, the printed name {d.prescriber.name}, {d.prescriber.credentials} and the date of issue {d.issueDate:formatD(L)}. The prescriber signs the printed page by hand.
7. Build the Medication Schedule
Page 2 is the after-visit summary of the patient. It starts with {d.patient.name}, {d.patient.birthDate:formatD(LL)}, {d.visit.date:formatD(LL)} and a sentence that counts the new medicines: {d.medications[].drug:aggCount:toWord} prints "three".
The schedule is a table with the columns Medicine, Morning, Noon, Evening and Bedtime. The data gives the number of doses at each time, and dose holds the amount of one dose. In the Morning column:
{d.medications[i].morning:ifGT(0):show(.dose):elseShow()}When the patient takes a dose in the morning, :show(.dose) prints "1 tablet": .dose is a dynamic parameter relative to the current medication. Otherwise :elseShow() leaves the cell empty. Use the same tag with .noon, .evening and .bedtime.
8. Calculate the End of Each Supply
The How to take them table repeats {d.medications[i].name} and {d.medications[i].instructions}, then the date when the supply runs out, with :addD:
{d.medications[i].orderedAt:addD(.daysSupply, 'day'):formatD(LL)}orderedAt is the time when the prescriber signed the order in the EHR, with its UTC offset: 2026-11-10T10:42:00-05:00. :addD(.daysSupply, 'day') adds the 90 days of the supply. Render with the "timezone": "America/New_York" option, the time zone of the clinic.
9. Repeat the Next Steps and Render the Advice
- The next steps are paragraphs in a table cell:
{d.followUps[i].date:formatD('ddd, MMM D')},{d.followUps[i].title}and{d.followUps[i].details}, then{d.followUps[i+1]}in the next paragraph. Carbone repeats the three paragraphs for each step. - The advice comes from the patient education content of the EHR, in HTML. The :html formatter renders it with its bold text and paragraphs:
{d.helpHtml:html}.
Save the DOCX template, send the JSON of each visit with the lang and timezone options, and Carbone returns the prescription and the medication schedule in one PDF.
Related Examples
Trusted by 800+ paid customers in 40+ countries














