Template:AntibioticDose: Difference between revisions
(Add disease parameter to AntibioticDose - captures indication from template name instead of PAGENAME to fix aggregation page issue) |
(Add PAGENAME==disease check: subobjects only created when page matches disease param - eliminates duplicates from aggregation pages) |
||
| Line 3: | Line 3: | ||
This template creates a single source of truth for antibiotic dosing on disease pages. It displays the drug name and dose as visible text, and simultaneously creates an SMW subobject linking the antibiotic to the disease. | This template creates a single source of truth for antibiotic dosing on disease pages. It displays the drug name and dose as visible text, and simultaneously creates an SMW subobject linking the antibiotic to the disease. | ||
The SMW subobject is '''only''' created when | 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 disease parameter (prevents duplicates from aggregation pages like "GI antibiotics") | |||
===Usage=== | ===Usage=== | ||
<pre> | <pre> | ||
{{AntibioticDose|drug=Ceftriaxone|dose=1-2g IV daily|context=Inpatient, CAP Non-ICU|disease= | {{AntibioticDose|drug=Ceftriaxone|dose=1-2g IV daily|context=Inpatient, CAP Non-ICU|disease=Pneumonia (main)|population=Adult}} | ||
{{AntibioticDose|drug=Ceftriaxone|dose=50-100mg/kg/day IV|context=CAP|disease=Pneumonia|population=Pediatric}} | {{AntibioticDose|drug=Ceftriaxone|dose=50-100mg/kg/day IV|context=CAP|disease=Pneumonia (main)|population=Pediatric}} | ||
</pre> | </pre> | ||
| Line 15: | Line 17: | ||
* '''dose''' (required): The dosing text (e.g., 1-2g IV daily, 500mg PO BID) | * '''dose''' (required): The dosing text (e.g., 1-2g IV daily, 500mg PO BID) | ||
* '''context''' (required): Clinical context (e.g., Outpatient Healthy, Inpatient CAP Non-ICU, ICU Low Risk) | * '''context''' (required): Clinical context (e.g., Outpatient Healthy, Inpatient CAP Non-ICU, ICU Low Risk) | ||
* '''disease''' (required): The disease page name this dosing is for (e.g., Pneumonia, Septic arthritis). This ensures the correct disease is recorded | * '''disease''' (required): The disease page name this dosing is for (e.g., Pneumonia (main), Septic arthritis). This ensures the correct disease is recorded and prevents duplicate subobjects from aggregation pages. | ||
* '''population''' (optional): "Adult" or "Pediatric". Defaults to "Adult" if omitted. | * '''population''' (optional): "Adult" or "Pediatric". Defaults to "Adult" if omitted. | ||
* '''display''' (optional): Custom display text for the drug link. If omitted, uses the drug name | * '''display''' (optional): Custom display text for the drug link. If omitted, uses the drug name | ||
| Line 23: | Line 25: | ||
Renders: [[drug|display]] dose (or just dose if link=no) | Renders: [[drug|display]] dose (or just dose if link=no) | ||
Creates SMW subobject (on main namespace | Creates SMW subobject (only on the matching disease page in main namespace) with: Has DrugName, Has Dose, Has Context, Treats disease, Has Population | ||
[[Category:Miscellaneous]] | [[Category:Miscellaneous]] | ||
</noinclude><includeonly>{{#ifeq:{{{link|yes}}}|no|{{{dose|}}}|[[{{{drug|}}}{{#if:{{{display|}}}|{{!}}{{{display|}}}}}]] {{{dose|}}}}}{{#ifeq:{{NAMESPACENUMBER}}|0|{{#subobject:{{{drug|}}} {{{context|}}} {{{population|Adult}}} | </noinclude><includeonly>{{#ifeq:{{{link|yes}}}|no|{{{dose|}}}|[[{{{drug|}}}{{#if:{{{display|}}}|{{!}}{{{display|}}}}}]] {{{dose|}}}}}{{#ifeq:{{NAMESPACENUMBER}}|0|{{#ifeq:{{PAGENAME}}|{{{disease|{{PAGENAME}}}}}|{{#subobject:{{{drug|}}} {{{context|}}} {{{population|Adult}}} | ||
|Has DrugName={{{drug|}}} | |Has DrugName={{{drug|}}} | ||
|Treats disease={{{disease|{{PAGENAME}}}}} | |Treats disease={{{disease|{{PAGENAME}}}}} | ||
| Line 32: | Line 34: | ||
|Has Context={{{context|}}} | |Has Context={{{context|}}} | ||
|Has Population={{{population|Adult}}} | |Has Population={{{population|Adult}}} | ||
}}|}}</includeonly> | }}}}|}}</includeonly> | ||
Revision as of 23:19, 19 March 2026
AntibioticDose Template
This template creates a single source of truth for antibiotic dosing on disease pages. It displays the drug name and dose as visible text, and simultaneously creates an SMW subobject linking the antibiotic to the disease.
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 disease parameter (prevents duplicates from aggregation pages like "GI antibiotics")
Usage
{{AntibioticDose|drug=Ceftriaxone|dose=1-2g IV daily|context=Inpatient, CAP Non-ICU|disease=Pneumonia (main)|population=Adult}}
{{AntibioticDose|drug=Ceftriaxone|dose=50-100mg/kg/day IV|context=CAP|disease=Pneumonia (main)|population=Pediatric}}
Parameters
- drug (required): The antibiotic page name (e.g., Ceftriaxone, Azithromycin)
- dose (required): The dosing text (e.g., 1-2g IV daily, 500mg PO BID)
- context (required): Clinical context (e.g., Outpatient Healthy, Inpatient CAP Non-ICU, ICU Low Risk)
- disease (required): The disease page name this dosing is for (e.g., Pneumonia (main), Septic arthritis). This ensures the correct disease is recorded and prevents duplicate subobjects from aggregation pages.
- population (optional): "Adult" or "Pediatric". Defaults to "Adult" if omitted.
- display (optional): Custom display text for the drug link. If omitted, uses the drug name
- link (optional): Set to "no" to show only the dose text without the drug link
Output
Renders: display dose (or just dose if link=no)
Creates SMW subobject (only on the matching disease page in main namespace) with: Has DrugName, Has Dose, Has Context, Treats disease, Has Population
