Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[bioontology-support] [EXTERNAL] Re: Access Code Notations via REST API

Zak Raicik ZRaicik at jhancock.com
Mon Jun 29 11:04:26 PDT 2020


Hey Michael-

Thanks for the response. My confusion is coming from the fact that I don’t see the field “notation” as a key in the returning JSON.

I attached my code below. Do you mind taking a quick look?

import urllib.request, urllib.error, urllib.parse
import json
import os
import pandas as pd

from tqdm.notebook import tqdm

REST_URL = http://data.bioontology.org

def get_json(url):
    opener = urllib.request.build_opener()
    opener.addheaders = [('Authorization', 'apikey token=' + api_key)]
    return json.loads(opener.open(url).read())

ontologies = get_json(REST_URL+"/ontologies")
url = [x['links']['classes'] for x in ontologies if 'icd10' in x['acronym'].lower()][2]

codes = pd.DataFrame()
page = get_json(url)
NumberPages0 = page['pageCount']
EntriesPerPage = len([x for x in page['collection']])

for PageNumber in tqdm(range(NumberPages0)):
    NextPage = page['links']['nextPage']
   for entry in range(EntriesPerPage):
        Id = page['collection'][entry]['@id']
        code = Id.rsplit('/', 1)[-1]
        desc = page['collection'][entry]['prefLabel']
        data = {"Code": code, "Description": desc}
        codes = codes.append(data,ignore_index=True)
    if NextPage is not None:
        page = get_json(NextPage)
        EntriesPerPage = len([x for x in page['collection']])

Zak Raicik, FSA
Director, Data Science
Manulife

From: Michael Dorf <mdorf at stanford.edu>
Date: Monday, June 29, 2020 at 1:38 PM
To: Zak Raicik <ZRaicik at jhancock.com>
Cc: "support at bioontology.org" <support at bioontology.org>
Subject: [EXTERNAL] Re: [bioontology-support] Access Code Notations via REST API


CAUTION This email is from an external sender, be cautious with links and attachments.
Hi Zak,

Thank you for contacting us. You can retrieve this info programmatically in one of these two ways:

1. Using the /classes endpoint:

http://data.bioontology.org/ontologies/ICD10/classes?display=prefLabel,synonym,definition,notation,cui,semanticType,properties&no_links=true&no_context=true&page=1

OR

2. Using the /search endpoint:

http://data.bioontology.org/search?ontologies=ICD10&sort=prefLabel&display=prefLabel,synonym,definition,notation,cui,semanticType,properties&no_links=true&no_context=true&page=1

In the latter example, the results are being sorted by the prefLabel alphabetically. In your Python script, you can iterate over ALL ontology terms by processing the results one page at a time and incrementing the “page=1” parameter on each subsequent call.

The ICD10 code is stored in the field “notation”.

For the actual Python code, you can use some of the examples below as your starting point:

https://github.com/ncbo/ncbo_rest_sample_code/tree/master/python

Let us know if you have additional questions.

Michael



On Jun 29, 2020, at 6:11 AM, Zak Raicik <ZRaicik at jhancock.com<mailto:ZRaicik at jhancock.com>> wrote:

Hi –

Is there any way to use the REST API to get a comprehensive listing off all codes/notations within a given class?

For example, if I want to get a complete listing of all possible ICD10 codes from the API using python- is that possible?

Thanks,
Zak Raicik, FSA
Director, Data Science
Manulife

STATEMENT OF CONFIDENTIALITY The information contained in this email message and any attachments may be confidential and legally privileged and is intended for the use of the addressee(s) only. If you are not an intended recipient, please: (1) notify me immediately by replying to this message; (2) do not use, disseminate, distribute or reproduce any part of the message or any attachment; and (3) destroy all copies of this message and any attachments.
_______________________________________________
bioontology-support mailing list
bioontology-support at lists.stanford.edu<mailto:bioontology-support at lists.stanford.edu>
https://mailman.stanford.edu/mailman/listinfo/bioontology-support


STATEMENT OF CONFIDENTIALITY The information contained in this email message and any attachments may be confidential and legally privileged and is intended for the use of the addressee(s) only. If you are not an intended recipient, please: (1) notify me immediately by replying to this message; (2) do not use, disseminate, distribute or reproduce any part of the message or any attachment; and (3) destroy all copies of this message and any attachments.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/bioontology-support/attachments/20200629/d1271d81/attachment-0001.html>


More information about the bioontology-support mailing list