Jump to content

Module:Infobox medical intervention

Ón Vicipéid, an chiclipéid shaor.

Documentation for this module may be created at Module:Infobox medical intervention/doc

--[[
For translation of this module, you must customize:
Module:Infobox medical intervention/i18n
Module:Infotable images/i18n
Module:Medical infotable items/i18n

--]]
local p = {}

local SA	= require "Module:SimpleArgs"
local SD	= require "Module:SimpleDebug"
local WD	= require "Module:Wikidata"
local MLMT	= require "Module:Multilang module tools"
local GIBT	= require "Module:Global infobox tools"
local GIBTi	= require "Module:Global infobox tools/items"
local MII	= require "Module:Medical infobox items"
local MIIi	= require "Module:Medical infobox items/items"
local IMIi	= require "Module:Infobox medical intervention/items"
local GIBTi18n
local IMIi18n

local ModuleName = 'Infobox medical intervention'
local rs = { --reserved keys and their modified values for infobox configuration
	--for default stored values of the other options look at list with allitems=list
}
local cat = { --tracking categories
	[GIBTi.rk.rs_cat_arg_error]	= "_Q56486184", -- specific category: "_Q90499106",
}	
local items = { --used key names 
	[MLMT.k.Args] = { --parameter key, its name/s (as parameter) and optional Wikidata qualifiers/properties
		[GIBTi.rk.name]			= {{"Name",
									"name"},		"",}, --allways required
		[IMIi.k.ICD10]			= {"ICD10",         "_P1690",},
		[IMIi.k.ICD9]			= {"ICD9",          {property="P1692",
													formatting='{{ICD9proc|$1}}',}},
		[IMIi.k.ICD9u]			= {"ICD9unlinked",  "_P493",},
		[IMIi.k.OPS]			= {"OPS301",        "_P1691",},
		[IMIi.k.LOINC]			= {"LOINC",         {property="P4338",
													formatting='{{LOINC|$1}}',}},
		[IMIi.k.Other]			= {{"other_codes",
									"OtherCodes"},	"",},
		[IMIi.k.Medline]		= {"MedlinePlus",   {property="P604",
													 formatting='[https://medlineplus.gov/ency/article/$1.htm $1]'}},
		[IMIi.k.HCPCS]			= {"HCPCSlevel2",   "",},
		[IMIi.k.CPT]			= {"CPT",           "_P7410",},
	},
	[MLMT.k.Labels] = { --label or header (hd_) key, and its value as Wikidata qualifier or property to read (or text)
		[IMIi.k.ICD10]			= "_Q9006342",
		[IMIi.k.ICD9]			= "_Q5737131",
		[IMIi.k.ICD9u]			= "_Q14067712",
		[IMIi.k.OPS]			= "_Q2026515",
		[IMIi.k.LOINC]			= "_Q502480",
		[IMIi.k.Other] 			= "Other [[procedure codes|codes]]",
		[IMIi.k.Medline]		= "_Q557919",
		[IMIi.k.HCPCS] 			= "_Q5629114",
		[IMIi.k.CPT] 			= "_Q964984",
	},	
}

function p.infobox(frame)
	local args, NArgs = SA.GetArgs (frame)
	MLMT.SetLang (args)
	GIBTi18n = require (SA.I18nName ("Global infobox tools"))
	IMIi18n  = require (SA.I18nName ("Infobox medical intervention"))
	GIBT.SetColorsAndIcon (ModuleName,
		GIBTi18n.lcol.science, --group color
		GIBTi18n.licon.medical_intervention)
	items, IMIi18n.items = GIBT.CheckArgLabLua (ModuleName, items, IMIi18n.items, IMIi18n.omit_params)
	IMIi.idx = GIBT.CheckIdx_arglabLua (ModuleName, IMIi.idx, IMIi18n.new_idx)
	args = GIBT.SetRsv_1ToArgs (ModuleName, frame, args, rs, IMIi18n.rs_val, cat)
	local itemsM = GIBT.tableMerge (ModuleName, items, IMIi18n.items)
	GIBT.i_LoadI18n ()
	MII.LoadI18n ()
	MLMT.IniLang (frame, args)
	SA.Error.handle = true
	--END INITIALIZATION
	
	function ArgMMI (option, key)
		return MII.arg_items (option, key)
	end	
	function load_show_key (key)
		GIBT.load_show_key (args, itemsM, key, IMIi.arg_lims)
	end	
	
	--BEGIN--
	local res = GIBT.ItemList_or_TempData (args, 'IMI', ModuleName, items, IMIi18n.items, IMIi.idx, IMIi.arg_lims, 
		{{'', MII.arglab_items},}, {{'', ArgMMI},})
	if res == nil then
		GIBT.IniLua (args, itemsM)
		local n_last_capt = GIBT.i_main (frame, args)
		load_show_key (IMIi.k.ICD10)
		load_show_key (IMIi.k.ICD9)
		load_show_key (IMIi.k.ICD9u)
		MII.mesh (frame, args)
		load_show_key (IMIi.k.OPS)
		load_show_key (IMIi.k.LOINC)
		load_show_key (IMIi.k.Other)
		load_show_key (IMIi.k.Medline) 
		MII.eMedicine (args)
		load_show_key (IMIi.k.HCPCS)
		load_show_key (IMIi.k.CPT)
		GIBT.ExecFuncs_SetHeaders (frame, itemsM, nil, n_last_capt)
		return GIBT.CheckShowParams (
				frame, args, 
				--allowed parameters:
				{itemsM, --current module specific arguments
				GIBT.i_itemsM, --image module specific arguments
				MII.itemsM[MIIi.k.Mesh], MII.itemsM[MIIi.k.eMed]} --Medical infotable items arguments
				)..
		    GIBT.InfoboxWithItsValues() 
	else
		return res
	end	
end --infobox

return p