-- Functions for use in retrieving Wikidata for use in templates that deal with identifiers-- getIdentifierQualifier returns the value of a qualifier for an Identifierp={}-- getIdentifierQualifier returns the value of a qualifier for an Identifier-- such as 'Art UK artist ID', P1367-- the assumption is that one value exists for the property-- and only one qualifier exists for that value-- Constraint violations for P1367 are at:-- https://www.wikidata.org/wiki/Wikidata:Database_reports/Constraint_violations/P1367#Single_valuep.getIdentifierQualifier=function(frame)localpropertyID=mw.text.trim(frame.args[1]or"")-- The PropertyID of the qualifier-- whose value is to be returned is passed in named parameter |qual=localqualifierID=frame.args.qual-- Can take a named parameter |qid which is the Wikidata ID for the article.-- This will not normally be used because it's an expensive call.localqid=frame.args.qidifqidand(#qid==0)thenqid=nilendlocalentity=mw.wikibase.getEntityObject(qid)localpropsifentityandentity.claimsthenprops=entity.claims[propertyID]endifpropsthen-- Check that the first value of the property is an external idifprops[1].mainsnak.datatype=="external-id"then-- get any qualifiers of the first value of the propertylocalquals=props[1].qualifiersifqualsandquals[qualifierID]then-- check what the dataype of the first qualifier value is-- if it's quantity return the amountifquals[qualifierID][1].datatype=="quantity"thenreturntonumber(quals[qualifierID][1].datavalue.value.amount)end-- checks for other datatypes go here:endendendendreturnp