3

我正在使用 hapi R4 服务器测试fhirclient 4.0.0( )Python 3.7

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()

我得到了这个验证错误

FHIRValidationError: {root}:
  rest.0:
    resource.70:
      searchParam.14:
        'Non-optional property "type" on <models.capabilitystatement.CapabilityStatementRestResourceSearchParam object at 0x7fe54cef1668> is missing'

链接到能力声明http://hapi.fhir.org/baseR4/metadata

还有其他人面临这个吗?

以下是错误的完整跟踪..

---------------------------------------------------------------------------
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 问题:https ://github.com/smart-on-fhir/client-py/issues/79

4

2 回答 2

2

你确定,你正在使用fhirclient 4.0.0?虽然 4.0.0 可用一年多pip仍然有版本3.2.0.这里有一个问题:https ://github.com/smart-on-fhir/client-py/issues/70

针对当前版本的 HAPI使用fhirclient 3.2.0将导致类似的错误。您可以直接从他们的 github 克隆 fhirclient,也可以使用带有 DSTU3 的 HAPI 服务器。托管您自己的服务器时,您可以将配置更改hapi.propertiesfhir_version=DSTU3.

于 2020-04-09T19:07:13.830 回答
1

HAPI 服务器返回一个无效的 CapabilityStatement 资源,其中未填写位置的 searchParam 'near' 类型 - 我对此进行了一些检查。所以这个错误不在你的客户端;实际上,它通过在“FHIRValidationError”下方的跟踪末尾告诉您出了什么问题来完美地工作。

您最好的选择是联系 HAPI 服务器开发人员并要求他们更正他们的 CapabilityStatement。

于 2019-09-25T12:05:31.127 回答