GithubHelp home page GithubHelp logo

yubin-park / pharmpy Goto Github PK

View Code? Open in Web Editor NEW
15.0 15.0 6.0 12.64 MB

pharmpy is an umbrella library for searching the FDA NDC directory, Established Pharmacologic Class (EPC), Anatomical Therapeutic Chemical (ATC) through RxNav, and some other APIs on RxNav.

License: Apache License 2.0

Python 100.00%

pharmpy's People

Contributors

yubin-park avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pharmpy's Issues

Init ATCEngine does not set RxCUIEngine root_url

When ATCEngine is initialized with root_url, the object does not pass root_url to the RxCUIEngine. Therefore, the incorrect url is queried instead and an error is raised.

Problematic line:

self.rce = RxCUIEngine(cache_only=cache_only)

Test script

    from pharmpy.atc import ATCEngine
    import unittest
    
    class ATCEngineTestCase(unittest.TestCase):
    
        def test_atc(self):
            ae = ATCEngine(root_url="http://host.docker.internal:4000/REST")
            print(vars(ae))
            out = ae.get_atc("50090347201")
            self.assertEqual(out[0]["id"], "A10BH")
            out = ae.get_atc(["50090347201"])
            self.assertEqual(out[0][0]["id"], "A10BH")
    
    if __name__=="__main__":
        unittest.main()

Partial output

    {'root_url': 'http://host.docker.internal:4000/REST', 'cache_fn': 'data/cache_atc.json', 'cache': {}, 'rce': <pharmpy.rxcui.RxCUIEngine object at 0x7f72b34ff358>, 'session': <requests.sessions.Session object at 0x7f72b34ff748>, 'cache_only': False}
    E
    ======================================================================
    ERROR: test_atc (__main__.ATCEngineTestCase)
    ----------------------------------------------------------------------
    
    Traceback (most recent call last):
      File "mederrata_stage1/scripts/dataformatting/shortscripts/atc_crosswalk_test.py", line 9, in test_atc
        out = ae.get_atc("50090347201")
      File "/usr/local/lib/python3.6/dist-packages/pharmpy/atc.py", line 77, in get_atc
        rxcui_lst = self.rce.get_rxcui(ndc_lst)
      File "/usr/local/lib/python3.6/dist-packages/pharmpy/rxcui.py", line 46, in get_rxcui
        r = self.session.get(url)
      File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 543, in get
        return self.request('GET', url, **kwargs)
      File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 530, in request
        resp = self.send(prep, **send_kwargs)
      File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 643, in send
        r = adapter.send(request, **kwargs)
      File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 516, in send
        raise ConnectionError(e, request=request)
    requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=4000): Max retries exceeded with url: /REST/ndcstatus.json?ndc=50090347201 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f72b34ff080>: Failed to establish a new connection: [Errno 111] Connection refused',))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.