Template:MedicationDose: Difference between revisions

(Update documentation: replace link=subject with mainlabel=- in example query to fix broken subobject fragment links)
(Update documentation: change broadtable to table format for better TOC coexistence)
 
Line 136: Line 136:
  |?Has Route=Route
  |?Has Route=Route
  |?Has Population=Population
  |?Has Population=Population
  |format=broadtable
  |format=table
  |headers=plain
  |headers=plain
  |mainlabel=-
  |mainlabel=-

Latest revision as of 22:00, 20 March 2026

MedicationDose Template

This template is the single source of truth for non-antibiotic medication dosing on WikEM. It serves two purposes simultaneously:

  1. Displays the drug name, dose, and clinical details as visible bullet-point text on disease/condition pages
  2. Creates SMW (Semantic MediaWiki) subobjects that link medications to their clinical indications, enabling dynamic "Indications by Condition" tables on individual drug pages

This means when a dose is updated on a disease page, every drug page referencing that medication updates automatically — no manual synchronization needed.

For antibiotic dosing, use {{AntibioticDose}} instead. The two systems are separate but follow the same single-source-of-truth philosophy.

How It Works

  1. An editor adds [[]] calls to a disease/condition page (e.g., Rapid sequence intubation, Status epilepticus)
  2. Each call displays the dose as a bullet point AND creates a hidden SMW subobject with structured data
  3. On each drug page (e.g., Ketamine, Epinephrine), an SMW #ask query automatically pulls in every condition where that drug is used, with doses, routes, and context
  4. If a dose changes on the disease page, the drug page table updates automatically on the next page load

The SMW subobject is only created when:

  • The template is used on a main namespace page (not on Template: pages)
  • The current page name matches the indication parameter exactly (prevents duplicate subobjects when a template is transcluded on multiple pages)

Parameters

Parameter Required Description Example
drug Yes The canonical medication page name on WikEM. Must match the drug's actual page title (not a redirect). Ketamine, Norepinephrine
dose Yes The dosing text. Do NOT include the route here (use the route parameter instead) to avoid duplication in display. 1-2 mg/kg, 0.1 mg/kg (max 4 mg)
context Yes The clinical role or context for this medication in the given indication. This appears in the SMW table. Induction agent, 1st line vasopressor, Paralytic
indication Yes The exact page name of the disease/condition page where this dose applies. Must match MedicationDose of the transcluding page for the SMW subobject to be created. Rapid sequence intubation, Status epilepticus
population No Adult or Pediatric. Defaults to Adult if omitted. Adult, Pediatric
route Recommended Route of administration. Displayed in parentheses after the dose. IV, IM, IN, IV drip, PO, PR, SQ, Nebulized
onset No Onset of action. Displayed as "onset X" in parentheses. 1 min, 45 sec, 30-60 sec
duration No Duration of action. Displayed as "duration Y" in parentheses. 10-20 min, 3-8 min, 6-12 hr
max_dose No Maximum dose. Displayed as "(max Z)" after the dose. 4 mg, 300 mg
display No Custom display text for the drug link. If omitted, the drug value is used as the link text. Epi (1:1000) when drug is Epinephrine
link No Set to no to suppress the drug link and show only dose text. Useful for secondary mentions or grouped entries. no
notes No Brief clinical note displayed in italics after the dose. Keep concise. 1st line for septic shock (SSC 2021)

Usage Examples

Basic usage on a disease page

==Management==
===Medications===
====Adults====
*{{MedicationDose|drug=Ketamine|dose=1-2 mg/kg|route=IV|context=Induction agent|indication=Rapid sequence intubation|population=Adult|onset=1 min|duration=10-20 min}}
*{{MedicationDose|drug=Succinylcholine|dose=1.5 mg/kg|route=IV|context=Depolarizing paralytic|indication=Rapid sequence intubation|population=Adult|onset=45 sec|duration=6-10 min}}
====Pediatrics====
*{{MedicationDose|drug=Ketamine|dose=1-2 mg/kg|route=IV|context=Induction agent|indication=Rapid sequence intubation|population=Pediatric|onset=1 min|duration=10-20 min}}

Using display parameter for custom link text

*{{MedicationDose|drug=Epinephrine|display=Epinephrine (1:1000)|dose=0.3-0.5 mg|route=IM|context=1st line|indication=Anaphylaxis|population=Adult}}

Using link=no for dose-only display

*{{MedicationDose|drug=Midazolam|dose=0.2 mg/kg|route=IN|context=1st line benzodiazepine|indication=Status epilepticus|population=Pediatric|max_dose=10 mg|link=no}}

Using notes for clinical context

*{{MedicationDose|drug=Norepinephrine|dose=0.01-2 mcg/kg/min|route=IV drip|context=1st line vasopressor|indication=Vasopressors|population=Adult|notes=1st line for septic shock (SSC 2021)}}

For table-format pages (e.g., Vasopressors, Antihypertensives)

Some pages display medications in a comparison table rather than bullet lists. In these cases, keep the visible table for display and add a hidden div containing the MedicationDose calls to generate SMW subobjects:

<!-- Visible comparison table above -->
<div style="display:none">
{{MedicationDose|drug=Norepinephrine|dose=0.01-2 mcg/kg/min|route=IV drip|context=1st line vasopressor|indication=Vasopressors|population=Adult}}
{{MedicationDose|drug=Vasopressin|dose=0.04 units/min|route=IV drip|context=Adjunctive vasopressor|indication=Vasopressors|population=Adult}}
</div>

Output Format

Each template call renders as:

[[drug]] dose route (onset X, duration Y) (max Z) — notes

Only non-empty optional fields are displayed. For example:

  • With all fields: Ketamine 1-2 mg/kg IV (onset 1 min, duration 10-20 min)
  • Minimal: Lorazepam 0.1 mg/kg IV (max 4 mg)

SMW Integration

Subobject Properties

Each MedicationDose call creates an SMW subobject (when conditions are met) with the following properties:

SMW Property Source Parameter Description
Has DrugName drug Links to the drug page for queries
Has Indication indication The disease/condition page name
Has Dose dose Dosing text
Has Context context Clinical role/context
Has Population population Adult or Pediatric
Has Route route Route of administration
Has Onset onset Onset of action
Has Duration duration Duration of action
Has MaxDose max_dose Maximum dose

Drug Page Query (Indications by Condition)

On each drug page, add the following section to display a dynamic table of all conditions where the drug is used. This table updates automatically when MedicationDose entries are added or modified on disease pages.

==Indications by Condition==
''The following table is automatically generated from disease/condition pages across WikEM.''

{{#ask:[[Has DrugName::Ketamine]]
 |?Has Indication=Indication
 |?Has Dose=Dose
 |?Has Context=Context
 |?Has Route=Route
 |?Has Population=Population
 |format=table
 |headers=plain
 |mainlabel=-
 |sort=Has Indication
 |limit=50
}}

Replace Ketamine with the appropriate drug name. The drug name in the query must match the drug= value used in MedicationDose calls, which is the canonical page name (not a redirect).

Important Rules and Gotchas

1. Use canonical page names, not redirects

The drug and indication parameters must use the exact canonical page name, not a redirect. For example:

  • Use drug=Hydrocortisone, not drug=Hydrocortisone topical (the Hydrocortisone page redirects to Hydrocortisone topical, but the drug name in MedicationDose entries is Hydrocortisone)
  • Use drug=Unfractionated heparin, not drug=Heparin (if the canonical page is Unfractionated heparin)
  • Use indication=Rapid sequence intubation, not indication=RSI

2. Indication must match the page name exactly

The indication parameter must exactly match the MedicationDose of the page where the template is placed. If it doesn't match, the SMW subobject will NOT be created and the drug page query will be empty.

3. Do not include route in the dose parameter

Keep route separate to avoid duplication. The template displays both:

  • Wrong: dose=40-80 mg IV with route=IV → displays "40-80 mg IV IV"
  • Correct: dose=40-80 mg with route=IV → displays "40-80 mg IV"

4. Avoid translate extension tags

, , and tags from the MediaWiki Translate extension can block SMW subobject creation. If a page has these tags, they may need to be removed or the page re-marked for translation by an admin.

5. Drug pages with redirects need special query handling

Some drug pages are redirects. The SMW query on the target page must use the drug name as stored in Has DrugName:

  • Hydrocortisone redirects to Hydrocortisone topical — query on Hydrocortisone topical uses Hydrocortisone
  • Dextrose redirects to Dextrose-based products — query on Dextrose-based products uses Dextrose

6. Population defaults to Adult

If population is omitted, it defaults to Adult. Always explicitly set population=Pediatric for pediatric dosing entries.

Currently Converted Pages

The following disease/condition pages currently use MedicationDose (as of March 2026):

Disease/Condition Page # of Entries Categories
Rapid sequence intubation 14 Induction, paralytics, premedication
Procedural sedation ~15 Sedative/analgesic agents
Status epilepticus ~15 Benzodiazepines, 2nd/3rd line agents
Vasopressors 9 Vasopressors, inotropes
Pulseless arrest 7 ACLS medications
ACLS: Bradycardia 13 Chronotropes, vasopressors
Anaphylaxis 9 Epinephrine, adjuncts
Hypertensive emergency 10 Antihypertensives
Hyperkalemia 8 Stabilize, shift, eliminate
Eclampsia 3 Magnesium, antihypertensives
Acute pain management 17 Analgesics, adjuncts
Diabetic ketoacidosis 3 Insulin, fluids
Agitated or combative patient 7 Sedatives, antipsychotics
ACLS: Tachycardia 5 Antiarrhythmics
Acute asthma exacerbation 13 Bronchodilators, steroids
Ethanol withdrawal 10 Benzodiazepines, adjuncts
COPD exacerbation 3 Bronchodilators, steroids
Opioid toxicity 5 Naloxone
Thyroid storm 8 Antithyroid agents
Migraine headache 6 Abortive therapies
Atrial fibrillation 5 Rate/rhythm control
Adrenal crisis 2 Steroids
Pulmonary embolism 4 Anticoagulants, thrombolytics
Myxedema coma 2 Thyroid replacement
ST-segment elevation myocardial infarction 8 Antiplatelet, anticoagulation, fibrinolytics
Acetaminophen toxicity 3 NAC, activated charcoal
Croup 2 Steroids, epinephrine
Salicylate toxicity 2 Sodium bicarbonate
Digoxin toxicity 6 Digoxin immune fab, antiarrhythmics
Local anesthetic systemic toxicity 2 Intralipid
Calcium channel blocker toxicity 8 Calcium, vasopressors, insulin
Beta-blocker toxicity 6 Glucagon, calcium, vasopressors
Angioedema 7 Epinephrine, antihistamines, icatibant
Serotonin syndrome 2 Cyproheptadine, benzodiazepines
Malignant hyperthermia 2 Dantrolene
Neuroleptic malignant syndrome 4 Dantrolene, bromocriptine
Congestive heart failure 6 Diuretics, vasodilators, inotropes
Paroxysmal supraventricular tachycardia 6 Adenosine, calcium channel blockers
Hypoglycemia 4 Dextrose, glucagon

110 drug pages have been updated with "Indications by Condition" SMW query tables.

Relationship with AntibioticDose

WikEM uses two parallel template systems for medication dosing:

  • {{AntibioticDose}} — For antibiotics on disease-specific antibiotic template pages (e.g., Template:Pneumonia antibiotics)
  • {{MedicationDose}} — For all other medications (sedatives, vasopressors, analgesics, antiarrhythmics, toxicology agents, etc.)

Both follow the same single-source-of-truth philosophy: doses are defined once on disease pages and dynamically appear on drug pages via SMW queries.

Troubleshooting

Problem Likely Cause Solution
Drug page "Indications by Condition" table is empty SMW subobjects not created Verify: (1) the indication parameter exactly matches the disease page name, (2) the page is in the main namespace, (3) no translate tags are blocking subobject creation
Dose appears twice (e.g., "40 mg IV IV") Route included in both dose and route parameters Remove the route from the dose parameter
Drug name doesn't link correctly Using a redirect name instead of canonical name Use the actual page title (check by navigating to the drug page and noting the title in the URL)
Subobject created on wrong page Template transcluded from a different page Ensure indication matches the page where the template is used, not a parent page that transcludes it
SMW data shows but is stale MediaWiki caching Purge the page cache by adding ?action=purge to the URL, or edit and save the page

See Also