I'm testing out fhirclient 4.0.0
(Python 3.7
) with hapi R4 server
settings = {
'app_id': 'fhir',
# 'api_base': 'http://test.fhir.org/r4'
'api_base': 'http://hapi.fhir.org/baseR4'
}
smart = client.FHIRClient(settings=settings)
# capabilitystatement.CapabilityStatement.read_from('metadata', smart.server)
smart.prepare()
And I get this validation error
FHIRValidationError: {root}:
rest.0:
resource.70:
searchParam.14:
'Non-optional property "type" on <models.capabilitystatement.CapabilityStatementRestResourceSearchParam object at 0x7fe54cef1668> is missing'
Link to capability statement http://hapi.fhir.org/baseR4/metadata
Does anyone else facing this?
Below is the full trace of the error ..
---------------------------------------------------------------------------
FHIRValidationError Traceback (most recent call last)
<ipython-input-44-687512ba52eb> in <module>
7
8 # capabilitystatement.CapabilityStatement.read_from('metadata', sof.server)
----> 9 sof.prepare()
~/.virtualenvs/fhir/lib/python3.7/site-packages/fhirclient/client.py in prepare(self)
115 if self.server.ready:
116 return True
--> 117 return self.server.prepare()
118 return False
119
~/.virtualenvs/fhir/lib/python3.7/site-packages/fhirclient/server.py in prepare(self)
148 """
149 if self.auth is None:
--> 150 self.get_capability()
151 return self.auth.ready if self.auth is not None else False
152
~/.virtualenvs/fhir/lib/python3.7/site-packages/fhirclient/server.py in get_capability(self, force)
82 logger.info('Fetching CapabilityStatement from {0}'.format(self.base_uri))
83 from models import capabilitystatement
---> 84 conf = capabilitystatement.CapabilityStatement.read_from('metadata', self)
85 self._capability = conf
86
~/.virtualenvs/fhir/lib/python3.7/site-packages/fhirclient/models/fhirabstractresource.py in read_from(cls, path, server)
108
109 ret = server.request_json(path)
--> 110 instance = cls(jsondict=ret)
111 instance.origin_server = server
112 return instance
~/.virtualenvs/fhir/lib/python3.7/site-packages/fhirclient/models/capabilitystatement.py in __init__(self, jsondict, strict)
132 Type `str`. """
133
--> 134 super(CapabilityStatement, self).__init__(jsondict=jsondict, strict=strict)
135
136 def elementProperties(self):
~/.virtualenvs/fhir/lib/python3.7/site-packages/fhirclient/models/domainresource.py in __init__(self, jsondict, strict)
40 Type `Narrative` (represented as `dict` in JSON). """
41
---> 42 super(DomainResource, self).__init__(jsondict=jsondict, strict=strict)
43
44 def elementProperties(self):
~/.virtualenvs/fhir/lib/python3.7/site-packages/fhirclient/models/resource.py in __init__(self, jsondict, strict)
40 Type `Meta` (represented as `dict` in JSON). """
41
---> 42 super(Resource, self).__init__(jsondict=jsondict, strict=strict)
43
44 def elementProperties(self):
~/.virtualenvs/fhir/lib/python3.7/site-packages/fhirclient/models/fhirabstractresource.py in __init__(self, jsondict, strict)
23 .format(self.__class__, jsondict['resourceType']))
24
---> 25 super(FHIRAbstractResource, self).__init__(jsondict=jsondict, strict=strict)
26
27 @classmethod
~/.virtualenvs/fhir/lib/python3.7/site-packages/fhirclient/models/fhirabstractbase.py in __init__(self, jsondict, strict)
64 if jsondict is not None:
65 if strict:
---> 66 self.update_with_json(jsondict)
67 else:
68 try:
~/.virtualenvs/fhir/lib/python3.7/site-packages/fhirclient/models/fhirabstractbase.py in update_with_json(self, jsondict)
229
230 if len(errs) > 0:
--> 231 raise FHIRValidationError(errs)
232
233 def as_json(self):
FHIRValidationError: {root}:
rest.0:
resource.70:
searchParam.14:
'Non-optional property "type" on <models.capabilitystatement.CapabilityStatementRestResourceSearchParam object at 0x7fe54cef1668> is missing'
Github issue: https://github.com/smart-on-fhir/client-py/issues/79
The HAPI server returns an invalid CapabilityStatement resource, where the type of the searchParam 'near' for Location has not been filled in - I did some checking on that. So the bug is not in your client; actually it works perfectly by telling you what is wrong at the end of the trace, underneath "FHIRValidationError".
Your best option is to reach out to the HAPI server developers and ask them to correct their CapabilityStatement.