Module:ATC code to template name
Appearance
Translates an ATC code passed as an unnamed parameter to the function "translate" into the name of the navbox template associated with that ATC code on Wikipedia.
Use:
{{#invoke:ATC code to template name|translate|X00}}
The template returned does not have the Template: prefix.
-- this module provides a lookup from ATC codes to their associated navbox templates --
p = {}
local frame = mw.getCurrentFrame()
local input = tostring(frame.args[1])
p.lookuptable = {
{ code="A01", template="Stomatological preparations",},
{ code="A02A", template="Antacids", },
{ code="A02B", template="Drugs for peptic ulcer and GORD", },
{ code="A03", template="Drugs for functional gastrointestinal disorders", },
{ code="A04", template="Antiemetics", },
}
function p.translate ()
for k,v in pairs(p.lookuptable) do
if v.code == input then
p.out = v.template
end
end
if p.out == nil then
error("None")
end
frame:expandTemplate{ title = p.out }
return p.out
end
return p