def get_pubmed(pmid: str) -> Mapping[str, Any]:
pubmed_url = PUBMED_TMPL.replace("<STR_LIT>", str(pmid))<EOL>r = get_url(pubmed_url)<EOL>log.info(f"<STR_LIT>")<EOL>try:<EOL><INDENT>root = etree.fromstring(r.content)<EOL>doc = {"<STR_LIT>": "<STR_LIT>"}<EOL>doc["<STR_LIT>"] = root.xpath("<STR_LIT>")[<NUM_LIT:0>]<EOL>doc["<STR_LIT:title>"] = next(iter(root.xpath("<STR_LIT>")), "<STR_LIT>")<EOL>atext = next(iter(root.xpath("<STR_LIT>")), "<STR_LIT>")<EOL>print("<STR_LIT>", atext)<EOL>for abstracttext in root.xpath("<STR_LIT>"):<EOL><INDENT>abstext = node_text(abstracttext)<EOL>label = abstracttext.get("<STR_LIT>", None)<EOL>if label:<EOL><INDENT>doc["<STR_LIT>"] += f"<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>doc["<STR_LIT>"] += f"<STR_LIT>"<EOL><DEDENT><DEDENT>doc["<STR_LIT>"] = doc["<STR_LIT>"].rstrip()<EOL>doc["<STR_LIT>"] = []<EOL>for author in root.xpath("<STR_LIT>"):<EOL><INDENT>last_name = next(iter(author.xpath("<STR_LIT>")), "<STR_LIT>")<EOL>first_name = next(iter(author.xpath("<STR_LIT>")), "<STR_LIT>")<EOL>initials = next(iter(author.xpath("<STR_LIT>")), "<STR_LIT>")<EOL>if not first_name and initials:<EOL><INDENT>first_name = initials<EOL><DEDENT>doc["<STR_LIT>"].append(f"<STR_LIT>")<EOL><DEDENT>pub_year = next(<EOL>iter(root.xpath("<STR_LIT>")), None<EOL>)<EOL>pub_mon = next(<EOL>iter(root.xpath("<STR_LIT>")), "<STR_LIT>"<EOL>)<EOL>pub_day = next(<EOL>iter(root.xpath("<STR_LIT>")), "<STR_LIT>"<EOL>)<EOL>pub_date = process_pub_date(pub_year, pub_mon, pub_day)<EOL>doc["<STR_LIT>"] = pub_date<EOL>doc["<STR_LIT>"] = next(iter(root.xpath("<STR_LIT>")), "<STR_LIT>")<EOL>doc["<STR_LIT>"] = next(<EOL>iter(root.xpath("<STR_LIT>")), "<STR_LIT>"<EOL>)<EOL>doc["<STR_LIT>"] = next(iter(root.xpath('<STR_LIT>')), None)<EOL>doc["<STR_LIT>"] = []<EOL>for chem in root.xpath("<STR_LIT>"):<EOL><INDENT>chem_id = chem.get("<STR_LIT>")<EOL>doc["<STR_LIT>"].append({"<STR_LIT:id>": f"<STR_LIT>", "<STR_LIT:name>": chem.text})<EOL><DEDENT>compounds = [cmpd["<STR_LIT:id>"] for cmpd in doc["<STR_LIT>"]]<EOL>doc["<STR_LIT>"] = []<EOL>for mesh in root.xpath("<STR_LIT>"):<EOL><INDENT>mesh_id = f"<STR_LIT>"<EOL>if mesh_id in compounds:<EOL><INDENT>continue<EOL><DEDENT>doc["<STR_LIT>"].append({"<STR_LIT:id>": mesh_id, "<STR_LIT:name>": mesh.text})<EOL><DEDENT>return doc<EOL><DEDENT>except Exception as e:<EOL><INDENT>log.error(<EOL>f"<STR_LIT>",<EOL>url=f'<STR_LIT>',<EOL>)<EOL>return {"<STR_LIT:message>": f"<STR_LIT>"}<EOL><DEDENT>
Get pubmed xml for pmid and convert to JSON

    Remove MESH terms if they are duplicated in the compound term set

    ArticleDate vs PubDate gets complicated: https://www.nlm.nih.gov/bsd/licensee/elements_descriptions.html see <ArticleDate> and <PubDate>
    Only getting pub_year at this point from the <PubDate> element.

    Args:
        pmid: pubmed id number as a string

    Returns:
        pubmed json