コード例 #1
0
        public async Task<List<PubMedArticle>> GetPubMedArticlesAsync(string pmidList)
        {
            var publicationList = new List<PubMedArticle>();
            var parameters = GenerateSearchParameters(pmidList);
            var efetchClient = new EFetchClient(configuration.BaseUrl);
            var xml = await efetchClient.ExecuteXml(parameters);

            var xdoc = XDocument.Parse(xml);
            var root = xdoc.Root;

            if (root == null) return publicationList;

            foreach (var pubmedArticle in root.Elements("PubmedArticle"))
            {
                publicationList.Add(GetPublication(pubmedArticle, ""));
            }

            var idMappings = await pubMedIdConverter.GetPmcidsAsync(pmidList);
            foreach (var mapping in idMappings)
            {
                if (!mapping.Pmcid.IsNullOrEmpty())
                {
                    var article = publicationList.FirstOrDefault(x => x.PubMedId == mapping.Pmid);
                    if (article != null)
                    {
                        article.Pmcid = mapping.Pmcid;
                    }
                }
            }

            return publicationList;
        }
コード例 #2
0
        public async Task<string> GetPubMedArticleRawAsync(string pmid)
        {
            var parameters = GenerateSearchParameters(pmid);
            var efetchClient = new EFetchClient(configuration.BaseUrl);
            var xml = await efetchClient.ExecuteXml(parameters);

            return xml;
        }
コード例 #3
0
        public async Task<PubMedArticle> GetPubMedArticleAsync(string pmid)
        {
            PubMedArticle publication = null;
            var parameters = GenerateSearchParameters(pmid);
            var efetchClient = new EFetchClient(configuration.BaseUrl);
            var xml = await efetchClient.ExecuteXml(parameters);

            var xdoc = XDocument.Parse(xml);
            var root = xdoc.Root;

            if (root != null)
            {
                publication = GetPublication(root.GetElement("PubmedArticle", pmid), pmid);
                publication.Pmcid = await pubMedIdConverter.GetPmcidAsync(pmid);
            }

            return publication;
        }