local p = {}
local WikidataCrossValidation = require('Module:WikidataCrossValidation')
local PropertyLink = require('Module:PropertyLink')
local function getWikidataValue(entity, property, series, yearsOnly)
if entity == nil or property==nil then return end
local res = nil
local propertyVals
if series ~= nil then
propertyVals = mw.wikibase.getBestStatements( entity, series )
if propertyVals and #propertyVals>0 then
local seriesId = propertyVals[1] and propertyVals[1].mainsnak and propertyVals[1].mainsnak.datavalue
seriesId = seriesId and seriesId.value and seriesId.value.id
if seriesId==nil then return end
local qualifierVal = propertyVals[1].qualifiers and propertyVals[1].qualifiers[property] and propertyVals[1].qualifiers[property][1]
qualifierVal = qualifierVal and qualifierVal.datavalue and qualifierVal.datavalue.value and qualifierVal.datavalue.value.id
if qualifierVal == nil then return end
res = PropertyLink.formatEntity(qualifierVal)
end