Модуль:MedResources/WDMedResources

Материал из Википедии — свободной энциклопедии
Перейти к навигации Перейти к поиску
Документация
local p = {}
local wikidata = require('Модуль:WDCommon')
local backend = require('Модуль:WDBackend')

function p.fetch(entity, source)
	local defaultLangObj = mw.getContentLanguage()
	local defaultLangCode = defaultLangObj:getCode()

	local f = backend.new(defaultLangCode)
	
	local langMap = {
		{
			name = 'lang',
			property = 'P407',
			isLocal = true,
		},
	}
	
	local resourceMap = {
		{
			name = 'lang',
			property = 'P407',
			isLocal = true,
		},
		{
			name = 'resourceName',
			getData = wikidata.nameData,
			isLocal = true,
		},
	}

	source = source or {}
	f:fetchEntity(source, entity, {
		{
			name = 'mesh',
			property = 'P486',
			forceGet = {
				{
					entity = 'P486',
					property = 'P9073',
					get = langMap,
				}
			},
		},
		{
			name = 'diseasesDb',
			property = 'P557',
			forceGet = {
				{
					entity = 'P557',
					property = 'P9073',
					get = langMap,
				}
			},
		},
		{
			name = 'icd9',
			property = 'P493',
			forceGet = {
				{
					entity = 'P493',
					property = 'P9073',
					get = langMap,
				}
			},
		},
		{
			name = 'icd10',
			property = 'P494',
			forceGet = {
				{
					entity = 'P494',
					property = 'P9073',
					get = langMap,
				}
			},
		},
		{
			name = 'icd11',
			property = 'P7329',
			forceGet = {
				{
					entity = 'P7329',
					property = 'P9073',
					get = langMap,
				}
			},
		},
		{
			name = 'icd11Foundation',
			property = 'P7807',
			max = 1,
			forceGet = {
				{
					entity = 'P7807',
					property = 'P9073',
					get = langMap,
				}
			},
		},
		{
			name = 'snomedCt',
			property = 'P5806',
			forceGet = {
				{
					entity = 'P5806',
					property = 'P9073',
					get = langMap,
				}
			},
		},
		{
			name = 'whoEml',
			property = 'P9635',
			forceGet = {
				{
					entity = 'P9635',
					property = 'P9073',
					get = resourceMap,
				}
			},
		},
		{
			name = 'orphanet',
			property = 'P1550',
			forceGet = {
				{
					entity = 'P1550',
					property = 'P9073',
					get = resourceMap,
				},
			},
		},
		{
			name = 'medlinePlus',
			property = 'P604',
			forceGet = {
				{
					entity = 'P604',
					property = 'P9073',
					get = resourceMap,
				},
			},
		},
		{
			name = 'patientUK',
			property = 'P1461',
			forceGet = {
				{
					entity = 'P1461',
					property = 'P9073',
					get = resourceMap,
				},
			},
		},
		{
			name = 'eMedicine',
			property = 'P673',
			qualifiers = {
				{
					name = 'title',
					property = 'P1810',
					max = 1,
					isLocal = true,
				},
			},
			forceGet = {
				{
					entity = 'P673',
					property = 'P9073',
					get = resourceMap,
				},
			},
		},
		{
			name = 'geneReviews',
			property = 'P668',
			qualifiers = {
				{
					name = 'title',
					property = 'P1810',
					max = 1,
					isLocal = true,
				},
			},
			forceGet = {
				{
					entity = 'P668',
					property = 'P9073',
					get = resourceMap,
				},
			},
		},
		{
			name = 'omim',
			property = 'P492',
			qualifiers = {
				{
					name = 'title',
					property = 'P1810',
					max = 1,
					isLocal = true,
				},
			},
			forceGet = {
				{
					entity = 'P492',
					property = 'P9073',
					get = resourceMap,
				},
			},
		},
	})

	return source
end

return p