client-py icon indicating copy to clipboard operation
client-py copied to clipboard

Broken example on readme

Open KBlansit opened this issue 8 years ago • 5 comments
trafficstars

I was trying to go through the read me instructions, but I got an error after passing the first information.

`from fhirclient import client settings = { 'app_id': 'my_web_app', 'api_base': 'https://fhir-open-api-dstu2.smarthealthit.org' } smart = client.FHIRClient(settings=settings)

import fhirclient.models.patient as p patient = p.Patient.read('hca-pat-1', smart.server) ` I received the following error.

screenshot

Is the dstu-2 site not available?

KBlansit avatar May 14 '17 21:05 KBlansit

The DSTU-2 sandbox is now here: https://sb-fhir-dstu2.smarthealthit.org/api/smartdstu2/open/

p2 avatar May 14 '17 22:05 p2

I put 'https://sb-fhir-dstu2.smarthealthit.org/api/smartdstu2/open/' into 'api_base' as well as trying what I think my local sandbox base is 'http://localhost:9071/api/smartdstu2/open' but I get the following error:

Traceback (most recent call last):
  File "/Users/kurtwiersma/.virtualenvs/fhir-client-flask/lib/python3.6/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/kurtwiersma/.virtualenvs/fhir-client-flask/lib/python3.6/site-packages/beaker/middleware.py", line 155, in __call__
    return self.wrap_app(environ, session_start_response)
  File "/Users/kurtwiersma/.virtualenvs/fhir-client-flask/lib/python3.6/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/Users/kurtwiersma/.virtualenvs/fhir-client-flask/lib/python3.6/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/kurtwiersma/.virtualenvs/fhir-client-flask/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/Users/kurtwiersma/.virtualenvs/fhir-client-flask/lib/python3.6/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/kurtwiersma/.virtualenvs/fhir-client-flask/lib/python3.6/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/kurtwiersma/.virtualenvs/fhir-client-flask/lib/python3.6/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/kurtwiersma/.virtualenvs/fhir-client-flask/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/Users/kurtwiersma/.virtualenvs/fhir-client-flask/lib/python3.6/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/kurtwiersma/.virtualenvs/fhir-client-flask/lib/python3.6/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/kurtwiersma/Projects/pyro/client-py/flask_app.py", line 75, in index
    auth_url = smart.authorize_url
  File "/Users/kurtwiersma/Projects/pyro/client-py/fhirclient/client.py", line 124, in authorize_url
    return self.server.authorize_uri if self.server is not None else None
  File "/Users/kurtwiersma/Projects/pyro/client-py/fhirclient/server.py", line 114, in authorize_uri
    self.get_capability()
  File "/Users/kurtwiersma/Projects/pyro/client-py/fhirclient/server.py", line 82, in get_capability
    conf = capabilitystatement.CapabilityStatement.read_from('metadata', self)
  File "/Users/kurtwiersma/Projects/pyro/client-py/fhirclient/models/fhirabstractresource.py", line 103, in read_from
    instance = cls(jsondict=ret)
  File "/Users/kurtwiersma/Projects/pyro/client-py/fhirclient/models/capabilitystatement.py", line 137, in __init__
    super(CapabilityStatement, self).__init__(jsondict=jsondict, strict=strict)
  File "/Users/kurtwiersma/Projects/pyro/client-py/fhirclient/models/domainresource.py", line 42, in __init__
    super(DomainResource, self).__init__(jsondict=jsondict, strict=strict)
  File "/Users/kurtwiersma/Projects/pyro/client-py/fhirclient/models/resource.py", line 42, in __init__
    super(Resource, self).__init__(jsondict=jsondict, strict=strict)
  File "/Users/kurtwiersma/Projects/pyro/client-py/fhirclient/models/fhirabstractresource.py", line 23, in __init__
    .format(self.__class__, jsondict['resourceType']))
Exception: Attempting to instantiate <class 'models.capabilitystatement.CapabilityStatement'> with resource data that defines a resourceType of "Conformance

Is there a different 'api_base' value I should using? Do you know what the value should be for a local sandbox (via https://github.com/smart-on-fhir/installer) ?

kwiersma avatar Jan 04 '18 19:01 kwiersma

What's a proper value for api_base ?

https://sb-fhir-stu3.smarthealthit.org/smartstu3/data is not responding.

z3ugma avatar Feb 12 '19 21:02 z3ugma

@p2 do you know where we can find an updated value for api_base?

z3ugma avatar Feb 24 '19 20:02 z3ugma

Here are some public test servers you can use: http://wiki.hl7.org/index.php?title=Publicly_Available_FHIR_Servers_for_testing

p2-apple avatar Feb 25 '19 18:02 p2-apple