<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2Fgenewiki%2Fgenerefbox</id>
	<title>Module:Sandbox/genewiki/generefbox - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2Fgenewiki%2Fgenerefbox"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/genewiki/generefbox&amp;action=history"/>
	<updated>2026-04-21T22:01:31Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Sandbox/genewiki/generefbox&amp;diff=146507&amp;oldid=prev</id>
		<title>imported&gt;Julialturner: added footer</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/genewiki/generefbox&amp;diff=146507&amp;oldid=prev"/>
		<updated>2016-05-25T06:34:14Z</updated>

		<summary type="html">&lt;p&gt;added footer&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = { }&lt;br /&gt;
&lt;br /&gt;
local navbar = require(&amp;#039;Module:Navbar&amp;#039;)._navbar&lt;br /&gt;
local infobox = require(&amp;#039;Module:Infobox3cols&amp;#039;).infobox&lt;br /&gt;
local infoboxImage = require(&amp;#039;Module:InfoboxImage&amp;#039;).InfoboxImage&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--on a page {{#invoke:Sandbox/genewiki/alllua|getTemplateData|QID=Q14865053}}&lt;br /&gt;
--in debug window &lt;br /&gt;
--frame = mw.getCurrentFrame()&lt;br /&gt;
--frame.args = {QID=&amp;quot;Q14865053&amp;quot;} Q18031325&lt;br /&gt;
--print(p.getTemplateData(frame))&lt;br /&gt;
p.getTemplateData = function(frame)&lt;br /&gt;
&lt;br /&gt;
	--make some guesses about whether the provided QID is a good one&lt;br /&gt;
	--could expand here if we had some kind of error handling framework&lt;br /&gt;
	--did we get it from the page&lt;br /&gt;
	local root_qid = mw.text.trim(frame.args[&amp;#039;QID&amp;#039;]  or &amp;quot;&amp;quot;) --try to get it from the args&lt;br /&gt;
	local mm_qid = &amp;quot;&amp;quot;&lt;br /&gt;
	--pull all the entity objects that we will need&lt;br /&gt;
	local	entity = {} &lt;br /&gt;
	local	entity_protein = {}&lt;br /&gt;
	local	entity_mouse = {}&lt;br /&gt;
	local	entity_mouse_protein = {}&lt;br /&gt;
	local	checkOrtholog = &amp;quot;&amp;quot; --flag used to see if mouse data avaliable&lt;br /&gt;
	&lt;br /&gt;
	local mouse_propertyID = &amp;quot;P684&amp;quot;&lt;br /&gt;
	local protein_propertyID = &amp;quot;P688&amp;quot; &lt;br /&gt;
&lt;br /&gt;
	--get root gene entity&lt;br /&gt;
	if root_qid == &amp;quot;&amp;quot; then&lt;br /&gt;
		entity = mw.wikibase.getEntityObject()&lt;br /&gt;
		if entity then root_qid = entity.id else root_qid = &amp;quot;&amp;quot; end&lt;br /&gt;
			&lt;br /&gt;
	else&lt;br /&gt;
		--assuming we think its good make one call to retrieve and store its wikidata representation&lt;br /&gt;
		entity = mw.wikibase.getEntity(root_qid)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
  	--need to figure out if it is protein or gene here&lt;br /&gt;
	local subclass = p.getValue(entity, &amp;quot;P279&amp;quot;) or &amp;quot;&amp;quot;&lt;br /&gt;
	if string.find(subclass, &amp;#039;protein&amp;#039;) then --if protein switch entity to gene&lt;br /&gt;
		if entity.claims then&lt;br /&gt;
	 		claims = entity.claims[&amp;quot;P702&amp;quot;] --encoded by&lt;br /&gt;
	 	end&lt;br /&gt;
		if claims then&lt;br /&gt;
			--go through each index and reassign entity&lt;br /&gt;
			entity = {}&lt;br /&gt;
			if (claims[1] and claims[1].mainsnak.snaktype == &amp;quot;value&amp;quot; and claims[1].mainsnak.datavalue.type == &amp;quot;wikibase-entityid&amp;quot;) then&lt;br /&gt;
				for k, v in pairs(claims) do --this would be problematic if multiple genes for the protein&lt;br /&gt;
					local itemID = &amp;quot;Q&amp;quot; .. claims[#entity + 1].mainsnak.datavalue.value[&amp;quot;numeric-id&amp;quot;]&lt;br /&gt;
					entity[#entity + 1] = mw.wikibase.getEntity(itemID)&lt;br /&gt;
					root_qid = itemID&lt;br /&gt;
				end&lt;br /&gt;
				&lt;br /&gt;
			end --will return nothing if no claims are found&lt;br /&gt;
		end&lt;br /&gt;
		 entity = mw.wikibase.getEntity(root_qid) 	&lt;br /&gt;
	 end&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	--get the other related entities&lt;br /&gt;
	if entity then&lt;br /&gt;
		local claims = &amp;quot;&amp;quot;&lt;br /&gt;
	 	--get protein entity object&lt;br /&gt;
	 	if entity.claims then&lt;br /&gt;
	 		claims = entity.claims[protein_propertyID]&lt;br /&gt;
	 	end&lt;br /&gt;
		if claims then&lt;br /&gt;
			--go through each index and then make entity_protein indexed&lt;br /&gt;
			if (claims[1] and claims[1].mainsnak.snaktype == &amp;quot;value&amp;quot; and claims[1].mainsnak.datavalue.type == &amp;quot;wikibase-entityid&amp;quot;) then&lt;br /&gt;
				for k, v in pairs(claims) do&lt;br /&gt;
					local protein_itemID = &amp;quot;Q&amp;quot; .. claims[#entity_protein + 1].mainsnak.datavalue.value[&amp;quot;numeric-id&amp;quot;]&lt;br /&gt;
					entity_protein[#entity_protein + 1] = mw.wikibase.getEntity(protein_itemID)&lt;br /&gt;
				end&lt;br /&gt;
				&lt;br /&gt;
			end --will return nothing if no claims are found&lt;br /&gt;
		end&lt;br /&gt;
	&lt;br /&gt;
	 	--get mouse entity object&lt;br /&gt;
	 	if entity.claims then&lt;br /&gt;
			claims = entity.claims[mouse_propertyID]&lt;br /&gt;
		end&lt;br /&gt;
		if claims then&lt;br /&gt;
			if (claims[1] and claims[1].mainsnak.snaktype == &amp;quot;value&amp;quot; and claims[1].mainsnak.datavalue.type == &amp;quot;wikibase-entityid&amp;quot;) then&lt;br /&gt;
				local mouse_itemID = &amp;quot;Q&amp;quot; .. claims[1].mainsnak.datavalue.value[&amp;quot;numeric-id&amp;quot;]&lt;br /&gt;
				mm_qid = mouse_itemID &lt;br /&gt;
				entity_mouse = mw.wikibase.getEntity(mouse_itemID)&lt;br /&gt;
				checkOrtholog = 1 &lt;br /&gt;
			end --will return nothing if no claims are found&lt;br /&gt;
		else&lt;br /&gt;
			checkOrtholog = 0&lt;br /&gt;
		end&lt;br /&gt;
	&lt;br /&gt;
	 	--get mouse protein entity object&lt;br /&gt;
	 	if entity_mouse and entity_mouse.claims then&lt;br /&gt;
			claims = entity_mouse.claims[protein_propertyID]&lt;br /&gt;
		end&lt;br /&gt;
	 	if claims then&lt;br /&gt;
	 		if (claims[1] and claims[1].mainsnak.snaktype == &amp;quot;value&amp;quot; and claims[1].mainsnak.datavalue.type == &amp;quot;wikibase-entityid&amp;quot;) then&lt;br /&gt;
				for k, v in pairs(claims) do&lt;br /&gt;
					local protein_itemID = &amp;quot;Q&amp;quot; .. claims[#entity_mouse_protein + 1].mainsnak.datavalue.value[&amp;quot;numeric-id&amp;quot;]&lt;br /&gt;
					entity_mouse_protein[#entity_mouse_protein + 1] = mw.wikibase.getEntity(protein_itemID)&lt;br /&gt;
				end&lt;br /&gt;
			end --will return nothing if no claims are found&lt;br /&gt;
	 	end	&lt;br /&gt;
	&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	if entity then --only require the main gene entity&lt;br /&gt;
		--a list variables of all the data in the info box&lt;br /&gt;
		local name = p.getLabel(entity)&lt;br /&gt;
		local disease, dis_ref = p.getDisease(entity, &amp;quot;P2293&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		--define Global Color Scheme&lt;br /&gt;
		rowBGcolor = &amp;#039;#eee&amp;#039;&lt;br /&gt;
		titleBGcolor = &amp;#039;#ddd&amp;#039;&lt;br /&gt;
		sideTitleBGcolor = &amp;#039;#c3fdb8&amp;#039;&lt;br /&gt;
&lt;br /&gt;
		p.createTable()&lt;br /&gt;
		p.renderUpperTitle(name)&lt;br /&gt;
		if (disease ~= &amp;quot;&amp;quot; and dis_ref ~= &amp;quot;&amp;quot;) then --removes section from those items without disease info&lt;br /&gt;
			p.renderDiseases(disease, dis_ref, root_qid)&lt;br /&gt;
		end&lt;br /&gt;
		p.renderFooter()&lt;br /&gt;
   		&lt;br /&gt;
		return tostring(root)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	else return &amp;quot;An Error has occurred retrieving Wikidata item for infobox&amp;quot;&lt;br /&gt;
	end	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.createTable = function(subbox)&lt;br /&gt;
&lt;br /&gt;
    if subbox == &amp;#039;sub&amp;#039; then --doesn&amp;#039;t work &lt;br /&gt;
    	 root&lt;br /&gt;
        	:tag(&amp;#039;table&amp;#039;) &lt;br /&gt;
            :css(&amp;#039;padding&amp;#039;, &amp;#039;0&amp;#039;)&lt;br /&gt;
            :css(&amp;#039;border&amp;#039;, &amp;#039;none&amp;#039;)&lt;br /&gt;
            :css(&amp;#039;margin&amp;#039;, &amp;#039;0&amp;#039;)&lt;br /&gt;
            :css(&amp;#039;width&amp;#039;, &amp;#039;auto&amp;#039;)&lt;br /&gt;
            :css(&amp;#039;min-width&amp;#039;, &amp;#039;100%&amp;#039;)&lt;br /&gt;
            :css(&amp;#039;font-size&amp;#039;, &amp;#039;100%&amp;#039;)&lt;br /&gt;
            :css(&amp;#039;clear&amp;#039;, &amp;#039;none&amp;#039;)&lt;br /&gt;
            :css(&amp;#039;float&amp;#039;, &amp;#039;none&amp;#039;)&lt;br /&gt;
            :css(&amp;#039;background-color&amp;#039;, &amp;#039;transparent&amp;#039;)&lt;br /&gt;
           &lt;br /&gt;
    else&lt;br /&gt;
    	root = mw.html.create(&amp;#039;table&amp;#039;)&lt;br /&gt;
    	root&lt;br /&gt;
    		:addClass(&amp;#039;infobox&amp;#039;)&lt;br /&gt;
        	:css(&amp;#039;width&amp;#039;, &amp;#039;26.4em&amp;#039;)&lt;br /&gt;
        	 :newline()&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- look into entity object&lt;br /&gt;
p.getLabel = function(entity)&lt;br /&gt;
	local data = entity&lt;br /&gt;
&lt;br /&gt;
	local f = {&amp;#039;labels&amp;#039;,&amp;#039;en&amp;#039;,&amp;#039;value&amp;#039;}&lt;br /&gt;
&lt;br /&gt;
	local i = 1&lt;br /&gt;
	while true do&lt;br /&gt;
		local index = f[i]&lt;br /&gt;
		if not index then&lt;br /&gt;
			if type(data) == &amp;quot;table&amp;quot; then&lt;br /&gt;
				return mw.text.jsonEncode(data, mw.text.JSON_PRESERVE_KEYS + mw.text.JSON_PRETTY)&lt;br /&gt;
			else&lt;br /&gt;
				return tostring(data)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		data = data[index] or data[tonumber(index)]&lt;br /&gt;
		if not data then&lt;br /&gt;
			return&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		i = i + 1&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--Title above image&lt;br /&gt;
p.renderUpperTitle = function(name)&lt;br /&gt;
	local title = name&lt;br /&gt;
    if not title then return &amp;quot;error: failed to get label&amp;quot;; end&lt;br /&gt;
    &lt;br /&gt;
    root&lt;br /&gt;
        :tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
            :tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
                :attr(&amp;#039;colspan&amp;#039;, 4)&lt;br /&gt;
                :css(&amp;#039;text-align&amp;#039;, &amp;#039;center&amp;#039;)&lt;br /&gt;
                :css(&amp;#039;font-size&amp;#039;, &amp;#039;125%&amp;#039;)&lt;br /&gt;
                :css(&amp;#039;font-weight&amp;#039;, &amp;#039;bold&amp;#039;)&lt;br /&gt;
                :wikitext(title)&lt;br /&gt;
                :newline()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.renderDiseases = function(disease, dis_ref, Qid) &lt;br /&gt;
	local title = &amp;quot;Genetically Related Diseases&amp;quot;&lt;br /&gt;
	local disease_title = &amp;quot;Disease Name&amp;quot;&lt;br /&gt;
	local source_title = &amp;quot;&amp;#039;&amp;#039;&amp;#039;References&amp;#039;&amp;#039;&amp;#039;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	local ref_flag = {} --check each disease for a reference&lt;br /&gt;
	local ref_flag_all = &amp;quot;true&amp;quot; --not used in this code&lt;br /&gt;
&lt;br /&gt;
    if ref_flag_all == &amp;quot;true&amp;quot; then --header section&lt;br /&gt;
    	root&lt;br /&gt;
		:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
			:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
   				:attr(&amp;#039;colspan&amp;#039;, 4)&lt;br /&gt;
            	:css(&amp;#039;text-align&amp;#039;, &amp;#039;center&amp;#039;)&lt;br /&gt;
            	:css(&amp;#039;background-color&amp;#039;, rowBGcolor)&lt;br /&gt;
            	:newline()&lt;br /&gt;
		&lt;br /&gt;
		:tag(&amp;#039;tr&amp;#039;) --create title bar&lt;br /&gt;
			:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
			:attr(&amp;#039;colspan&amp;#039;, &amp;#039;3&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;text-align&amp;#039;, &amp;#039;center&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;background-color&amp;#039;, titleBGcolor)&lt;br /&gt;
			:wikitext(title)&lt;br /&gt;
			:done()&lt;br /&gt;
			:newline()&lt;br /&gt;
		:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
			:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;background-color&amp;#039;, sideTitleBGcolor)&lt;br /&gt;
				:attr(&amp;#039;colspan&amp;#039;, &amp;#039;2&amp;#039;)&lt;br /&gt;
				:wikitext(disease_title)&lt;br /&gt;
				:done()&lt;br /&gt;
				:newline()&lt;br /&gt;
			:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;background-color&amp;#039;, sideTitleBGcolor)&lt;br /&gt;
				:attr(&amp;#039;colspan&amp;#039;, &amp;#039;2&amp;#039;)&lt;br /&gt;
				:wikitext(source_title)&lt;br /&gt;
				:done()&lt;br /&gt;
				:newline()&lt;br /&gt;
				:done()&lt;br /&gt;
	end&lt;br /&gt;
			for index,value in ipairs(disease) do --loop through each disease &lt;br /&gt;
				local i = 0&lt;br /&gt;
				local ref_collapse = &amp;quot;&amp;quot;&lt;br /&gt;
				local ref_default = &amp;quot;&amp;quot;&lt;br /&gt;
				local ref_link = &amp;quot;&amp;quot;&lt;br /&gt;
				local ref_link_list = {}&lt;br /&gt;
				--check to see if the reference exists if not provide link to wikidata item to add reference&lt;br /&gt;
				if (dis_ref[index] == nil or dis_ref[index] == &amp;#039;&amp;#039;) then&lt;br /&gt;
					 table.insert(ref_link_list, &amp;quot;[[:d:&amp;quot;..Qid..&amp;quot;#P2293|click to add reference]]&amp;quot;)&lt;br /&gt;
				else&lt;br /&gt;
			    	ref_link_list =	mw.text.split(dis_ref[index], &amp;quot;,&amp;quot;)&lt;br /&gt;
			    end&lt;br /&gt;
					&lt;br /&gt;
&lt;br /&gt;
					--if less than 4 don&amp;#039;t create collapsible list&lt;br /&gt;
					if  table.getn(ref_link_list) &amp;lt; 5 then&lt;br /&gt;
						ref_collapse = &amp;quot;none&amp;quot;&lt;br /&gt;
					else	&lt;br /&gt;
						ref_collapse = &amp;quot;collapsible collapsed&amp;quot;&lt;br /&gt;
						for i =1, 5 do --get at most 4 elements to display&lt;br /&gt;
		     				ref_default = ref_default..table.remove(ref_link_list, 1) .. &amp;#039; &amp;#039;&lt;br /&gt;
						end&lt;br /&gt;
						local br_count = 0&lt;br /&gt;
						for i =1, table.getn(ref_link_list) do --get at most 4 elements to display&lt;br /&gt;
		     				ref_link = ref_link..table.remove(ref_link_list, 1) .. &amp;#039; &amp;#039;&lt;br /&gt;
		     &lt;br /&gt;
		     				if br_count &amp;lt; 5 then&lt;br /&gt;
		     					br_count = br_count + 1&lt;br /&gt;
		     				else&lt;br /&gt;
		     					br_count = 0&lt;br /&gt;
		     					ref_link = ref_link ..&amp;#039;&amp;lt;br&amp;gt;&amp;#039;&lt;br /&gt;
		     				end&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
	&lt;br /&gt;
					if ref_link_list[#ref_link_list] then&lt;br /&gt;
						ref_link = table.concat(ref_link_list, &amp;quot; &amp;quot;)&lt;br /&gt;
					end&lt;br /&gt;
			  	root&lt;br /&gt;
			    	:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
   					:attr(&amp;#039;colspan&amp;#039;, 4)&lt;br /&gt;
            		:css(&amp;#039;text-align&amp;#039;, &amp;#039;center&amp;#039;)&lt;br /&gt;
            		:css(&amp;#039;background-color&amp;#039;, rowBGcolor)&lt;br /&gt;
            		:newline()&lt;br /&gt;
            	&lt;br /&gt;
					:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
							:css(&amp;#039;background-color&amp;#039;, rowBGcolor)&lt;br /&gt;
								:attr(&amp;#039;scope&amp;#039;, &amp;#039;row&amp;#039;)&lt;br /&gt;
								:attr(&amp;#039;colspan&amp;#039;, &amp;#039;2&amp;#039;)&lt;br /&gt;
								:wikitext(value)&lt;br /&gt;
								:done()&lt;br /&gt;
								:newline()&lt;br /&gt;
					:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
						:tag(&amp;#039;span&amp;#039;)&lt;br /&gt;
						:attr(&amp;#039;colspan&amp;#039;, &amp;#039;2&amp;#039;)&lt;br /&gt;
					&lt;br /&gt;
        				:tag(&amp;#039;table&amp;#039;)&lt;br /&gt;
            				:attr(&amp;#039;class&amp;#039;, ref_collapse)&lt;br /&gt;
            				:css(&amp;#039;padding&amp;#039;, &amp;#039;0&amp;#039;)&lt;br /&gt;
            				:css(&amp;#039;border&amp;#039;, &amp;#039;none&amp;#039;)&lt;br /&gt;
            				:css(&amp;#039;margin&amp;#039;, &amp;#039;0&amp;#039;)&lt;br /&gt;
            				:css(&amp;#039;width&amp;#039;, &amp;#039;100%&amp;#039;)&lt;br /&gt;
            				:css(&amp;#039;text-align&amp;#039;, &amp;#039;right&amp;#039;)&lt;br /&gt;
            				:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
            					:newline()&lt;br /&gt;
            					:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
            						:attr(&amp;#039;colspan&amp;#039;, &amp;#039;1&amp;#039;)&lt;br /&gt;
            						:tag(&amp;#039;span&amp;#039;)&lt;br /&gt;
            							:attr(&amp;#039;class&amp;#039;, &amp;#039;plainlinks&amp;#039;)&lt;br /&gt;
            							:wikitext(ref_default)&lt;br /&gt;
            						:done()&lt;br /&gt;
            					:done()&lt;br /&gt;
            					:newline()&lt;br /&gt;
            				:done()&lt;br /&gt;
            				:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
            				:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
            					:attr(&amp;#039;colspan&amp;#039;, &amp;#039;1&amp;#039;)&lt;br /&gt;
            				:newline()&lt;br /&gt;
            				:tag(&amp;#039;p&amp;#039;)&lt;br /&gt;
            					:attr(&amp;#039;class&amp;#039;, &amp;#039;plainlinks&amp;#039;)&lt;br /&gt;
            					:wikitext(ref_link)&lt;br /&gt;
            				 	:newline()&lt;br /&gt;
            					:done()&lt;br /&gt;
            				:done()&lt;br /&gt;
            			:done()&lt;br /&gt;
            		:done()&lt;br /&gt;
        			:newline()&lt;br /&gt;
    			end	&lt;br /&gt;
    &lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getReference(qID, index, entity, property_id, ref_index)&lt;br /&gt;
	local f = {&amp;quot;claims&amp;quot;,property_id,index,&amp;quot;references&amp;quot;,ref_index,&amp;quot;snaks&amp;quot;,&amp;quot;P854&amp;quot;,1,&amp;quot;datavalue&amp;quot;,&amp;quot;value&amp;quot;} &lt;br /&gt;
	local id = qID&lt;br /&gt;
	--if id and (#id == 0) then&lt;br /&gt;
	--	id = nil&lt;br /&gt;
	--end&lt;br /&gt;
	local data = entity&lt;br /&gt;
	if not data then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
    &lt;br /&gt;
	local i = 1&lt;br /&gt;
	while true do&lt;br /&gt;
		local index = f[i]&lt;br /&gt;
		if not index then&lt;br /&gt;
			if type(data) == &amp;quot;table&amp;quot; then&lt;br /&gt;
				return mw.text.jsonEncode(data, mw.text.JSON_PRESERVE_KEYS + mw.text.JSON_PRETTY)&lt;br /&gt;
			else&lt;br /&gt;
				return tostring(data)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		data = data[index] or data[tonumber(index)]&lt;br /&gt;
		if not data then&lt;br /&gt;
			return &amp;quot;&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
		i = i + 1&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--general function to get value given an entity and property&lt;br /&gt;
p.getValue = function(entity, propertyID, return_val)&lt;br /&gt;
&lt;br /&gt;
	local claims&lt;br /&gt;
	if return_val == nil then return_val = &amp;quot;&amp;quot; end&lt;br /&gt;
    local sep = &amp;quot; &amp;quot; --could ad as input parameter if need be&lt;br /&gt;
	if entity and entity.claims then&lt;br /&gt;
		claims = entity.claims[propertyID]&lt;br /&gt;
	end&lt;br /&gt;
	if claims then&lt;br /&gt;
		-- if wiki-linked value output as link if possible&lt;br /&gt;
		if (claims[1] and claims[1].mainsnak.snaktype == &amp;quot;value&amp;quot; and claims[1].mainsnak.datavalue.type == &amp;quot;wikibase-entityid&amp;quot;) then&lt;br /&gt;
			local out = {}&lt;br /&gt;
			for k, v in pairs(claims) do&lt;br /&gt;
				local datav = mw.wikibase.label(&amp;quot;Q&amp;quot; .. v.mainsnak.datavalue.value[&amp;quot;numeric-id&amp;quot;])&lt;br /&gt;
				if datav == nil then datav = &amp;quot; &amp;quot; end &lt;br /&gt;
				out[#out + 1] = datav			&lt;br /&gt;
			end&lt;br /&gt;
			return table.concat(out, sep)&lt;br /&gt;
		else&lt;br /&gt;
		-- just return best values&lt;br /&gt;
			return entity:formatPropertyValues(propertyID).value&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		return return_val&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.getDisease= function(entity, propertyID)&lt;br /&gt;
    local claims&lt;br /&gt;
	if return_val == nil then return_val = &amp;quot;&amp;quot; end&lt;br /&gt;
	if entity and entity.claims then&lt;br /&gt;
		claims = entity.claims[propertyID]&lt;br /&gt;
	end&lt;br /&gt;
	if claims then&lt;br /&gt;
		-- if wiki-linked value output as link if possible&lt;br /&gt;
		&lt;br /&gt;
		if (claims[1] and claims[1].mainsnak.snaktype == &amp;quot;value&amp;quot; and claims[1].mainsnak.datavalue.type == &amp;quot;wikibase-entityid&amp;quot;) then&lt;br /&gt;
			local out = {}&lt;br /&gt;
			local datasource = {}&lt;br /&gt;
			--{{#invoke:Wikidata |ViewSomething |id=Q18023174 |claims|P2293|1|references|1|snaks|P854|1|datavalue|value}}&lt;br /&gt;
			--maybe there is a more direct way to find this than looping through the json object&lt;br /&gt;
			&lt;br /&gt;
			for k, v in pairs(claims) do&lt;br /&gt;
				local datav = mw.wikibase.label(&amp;quot;Q&amp;quot; .. v.mainsnak.datavalue.value[&amp;quot;numeric-id&amp;quot;])&lt;br /&gt;
				&lt;br /&gt;
				if datav == nil then datav = &amp;quot; &amp;quot; end &lt;br /&gt;
			   &lt;br /&gt;
				local id = &amp;quot;Q&amp;quot; .. v.mainsnak.datavalue.value[&amp;quot;numeric-id&amp;quot;]&lt;br /&gt;
				local linkTarget = mw.wikibase.sitelink(id)&lt;br /&gt;
				local refLink = &amp;quot;&amp;quot;&lt;br /&gt;
				local i &lt;br /&gt;
				for i=1,100 do --limits to 100 references displayed&lt;br /&gt;
				  local ref = &amp;quot;&amp;quot;&lt;br /&gt;
				  ref = getReference(&amp;quot;&amp;quot;, k, entity, &amp;quot;P2293&amp;quot;, i)&lt;br /&gt;
				  if (ref ~= nil and ref ~= &amp;#039;&amp;#039;) then&lt;br /&gt;
				     refLink = refLink..&amp;quot;,[&amp;quot;..ref..&amp;quot;]&amp;quot;&lt;br /&gt;
				  --else&lt;br /&gt;
				  --	 refLink = &amp;quot;[[:d:&amp;quot;..Qid..&amp;quot;#P2293|click to add reference]]&amp;quot; --link to disease association section to add reference&lt;br /&gt;
				  end&lt;br /&gt;
				end&lt;br /&gt;
                --if refLink = &amp;quot;&amp;quot; then --skip if there isn&amp;#039;t a reference found&lt;br /&gt;
				datasource[#out + 1] = refLink&lt;br /&gt;
				if linkTarget then&lt;br /&gt;
					out[#out + 1] = &amp;quot;[[&amp;quot;..datav..&amp;quot;|&amp;quot;..datav..&amp;quot;]]&amp;quot;&lt;br /&gt;
				else&lt;br /&gt;
					out[#out + 1] = &amp;quot;[[:d:&amp;quot; .. id .. &amp;quot;|&amp;quot; .. datav .. &amp;quot;]]&amp;quot;&lt;br /&gt;
				end&lt;br /&gt;
				--end				&lt;br /&gt;
			end&lt;br /&gt;
			return out, datasource&lt;br /&gt;
		else&lt;br /&gt;
		-- just return best values&lt;br /&gt;
			--return entity:formatPropertyValues(propertyID).value&lt;br /&gt;
			return return_val, return_val&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		return return_val&lt;br /&gt;
	end	&lt;br /&gt;
   return return_val&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.renderFooter = function()&lt;br /&gt;
 local text = &amp;quot;[[Module:Sandbox/genewiki/generefbox|Module:Sandbox/genewiki/generefbox]]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 root&lt;br /&gt;
 	:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
 		:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
 		:attr(&amp;#039;colspan&amp;#039;, &amp;#039;4&amp;#039;)&lt;br /&gt;
 		:css(&amp;#039;text-align&amp;#039;, &amp;#039;center&amp;#039;)&lt;br /&gt;
 		:css(&amp;#039;font-size&amp;#039;,&amp;#039;small&amp;#039;)&lt;br /&gt;
 		:css(&amp;#039;background-color&amp;#039;, rowBGcolor)&lt;br /&gt;
 		:wikitext(&amp;#039;The alternate rendering for the references can be found at line 252 in this source module &amp;#039;)&lt;br /&gt;
 		:wikitext(text)&lt;br /&gt;
 		:done()&lt;br /&gt;
 		:newline()&lt;br /&gt;
		:done()&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Julialturner</name></author>
	</entry>
</feed>