FHIR资源作为模型类
项目描述
FHIR®资源 (R5, R4B, STU3, DSTU2)
FHIR (快速健康信息互操作性资源) 是一种用于电子交换健康信息的规范。它旨在促进不同健康系统和应用程序之间的数据交换,通常用于构建健康数据的API(应用程序编程接口)。它基于现代网络技术,旨在易于使用和实现。它采用模块化方法,包含一组“资源”,代表不同类型的健康数据(如患者、观察和诊断)。这些资源可以根据需要组合和扩展,以支持广泛的健康用例。
这个“fhir.resources”包由pydantic驱动,因此在性能上更快,并可选地包含了orjson支持作为性能提升!显然,它是用现代Python编写的,并且内置了数据验证。它提供了用于FHIR规范中定义的所有FHIR资源的工具和类,并允许您在Python中创建和操作FHIR资源。然后您可以使用这些资源来构建基于FHIR的API或以其他方式处理FHIR数据。
实验性的XML和YAML序列化和反序列化支持。请参阅[高级用法]部分!
FHIR®版本信息
FHIR®(默认为R5版本,版本5.0.0)。还提供作为Python子包的先前版本(每个发布名称字符串成为子包名称,例如R4B)。从fhir.resources版本7.0.0开始;没有FHIR R4,而是以R4B作为子包提供。
可用先前版本:
R4B (4.3.0)
STU3 (3.0.2)
DSTU2(1.0.2)[参见问题#13][没有完整的测试覆盖率]
安装
只需简单的pip install fhir.resources或easy_install fhir.resources即可。但若要获取开发版本,请从https://github.com/nazrulworld/fhir.resources克隆,然后执行pip install -e .[dev]。
用法
示例:1:此示例创建一个新的组织资源,并包含一些其属性(id、active、name、address)
>>> from fhir.resources.organization import Organization >>> from fhir.resources.address import Address >>> data = { ... "id": "f001", ... "active": True, ... "name": "Acme Corporation", ... "address": [{"country": "Switzerland"}] ... } >>> org = Organization(**data) >>> org.resource_type == "Organization" True >>> isinstance(org.address[0], Address) True >>> org.address[0].country == "Switzerland" True >>> org.dict()['active'] is True True
示例:2:此示例从json字符串创建一个新的组织资源
>>> from fhir.resources.organization import Organization >>> from fhir.resources.address import Address >>> json_str = '''{"resourceType": "Organization", ... "id": "f001", ... "active": True, ... "name": "Acme Corporation", ... "address": [{"country": "Switzerland"}] ... }''' >>> org = Organization.parse_raw(json_str) >>> isinstance(org.address[0], Address) True >>> org.address[0].country == "Switzerland" True >>> org.dict()['active'] is True True
示例:3:此示例从json对象(py字典)创建一个新的患者资源
>>> from fhir.resources.patient import Patient >>> from fhir.resources.humanname import HumanName >>> from datetime import date >>> json_obj = {"resourceType": "Patient", ... "id": "p001", ... "active": True, ... "name": [ ... {"text": "Adam Smith"} ... ], ... "birthDate": "1985-06-12" ... } >>> pat = Patient.parse_obj(json_obj) >>> isinstance(pat.name[0], HumanName) True >>> pat.birthDate == date(year=1985, month=6, day=12) True >>> pat.active is True True
示例:4:此示例从json文件创建一个新的患者资源
>>> from fhir.resources.patient import Patient >>> import os >>> import pathlib >>> filename = pathlib.Path("foo/bar.json") >>> pat = Patient.parse_file(filename) >>> pat.resource_type == "Patient" True
示例:5:此示例以Python方式创建一个新的组织资源
>>> from fhir.resources.organization import Organization >>> from fhir.resources.address import Address >>> json_obj = {"resourceType": "Organization", ... "id": "f001", ... "active": True, ... "name": "Acme Corporation", ... "address": [{"country": "Switzerland"}] ... } >>> org = Organization.construct() >>> org.id = "f001" >>> org.active = True >>> org.name = "Acme Corporation" >>> org.address = list() >>> address = Address.construct() >>> address.country = "Switzerland" >>> org.address.append(address) >>> org.dict() == json_obj True
示例:4:此示例使用资源工厂函数创建新的组织资源
>>> from fhir.resources import construct_fhir_element >>> json_dict = {"resourceType": "Organization", ... "id": "mmanu", ... "active": True, ... "name": "Acme Corporation", ... "address": [{"country": "Switzerland"}] ... } >>> org = construct_fhir_element('Organization', json_dict) >>> org.address[0].country == "Switzerland" True >>> org.dict()['active'] is True True
示例:5:提供错误数据类型时的自动验证
>>> try: ... org = Organization({"id": "fmk", "address": ["i am wrong type"]}) ... raise AssertionError("Code should not come here") ... except ValueError: ... pass
高级用法
FHIR注释(JSON)
可以在JSON中添加注释,类似于XML,但需要遵循一些约定,由Grahame Grieve提出;在此实现了。
还可以生成不带注释的json字符串输出。
示例
>>> observation_str = b"""{ ... "resourceType": "Observation", ... "id": "f001", ... "fhir_comments": [ ... " a specimen identifier - e.g. assigned when the specimen was taken by the orderer/placer use the accession number for the filling lab ", ... " Placer ID " ... ], ... "text": { ... "fhir_comments": [ ... " a specimen identifier - e.g. assigned when the specimen was taken by the orderer/placer use the accession number for the filling lab ", ... " Placer ID " ... ], ... "status": "generated", ... "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">.........</div>" ... }, ... "identifier": [ ... { ... "use": "official", ... "system": "http://www.bmc.nl/zorgportal/identifiers/observations", ... "value": "6323" ... } ... ], ... "status": "final", ... "_status": { ... "fhir_comments": [ ... " EH: Note to balloters - lots of choices for whole blood I chose this. " ... ] ... }, ... "code": { ... "coding": [ ... { ... "system": "http://loinc.org", ... "code": "15074-8", ... "display": "Glucose [Moles/volume] in Blood" ... } ... ] ... }, ... "subject": { ... "reference": "Patient/f001", ... "display": "P. van de Heuvel" ... }, ... "effectivePeriod": { ... "start": "2013-04-02T09:30:10+01:00" ... }, ... "issued": "2013-04-03T15:30:10+01:00", ... "performer": [ ... { ... "reference": "Practitioner/f005", ... "display": "A. Langeveld" ... } ... ], ... "valueQuantity": { ... "value": 6.3, ... "unit": "mmol/l", ... "system": "http://unitsofmeasure.org", ... "code": "mmol/L" ... }, ... "interpretation": [ ... { ... "coding": [ ... { ... "system": "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", ... "code": "H", ... "display": "High" ... } ... ] ... } ... ], ... "referenceRange": [ ... { ... "low": { ... "value": 3.1, ... "unit": "mmol/l", ... "system": "http://unitsofmeasure.org", ... "code": "mmol/L" ... }, ... "high": { ... "value": 6.2, ... "unit": "mmol/l", ... "system": "http://unitsofmeasure.org", ... "code": "mmol/L" ... } ... } ... ] ... }""" >>> from fhir.resources.observation import Observation >>> obj = Observation.parse_raw(observation_str) >>> "fhir_comments" in obj.json() >>> # Test comments filtering >>> "fhir_comments" not in obj.json(exclude_comments=True)
特殊情况:缺少数据
在某些情况下,实现者可能会发现他们没有适合最小基数=1的元素的正确数据。[在此情况下,元素必须存在,除非资源或其配置文件已将原始数据类型的实际值设置为必填,否则可以提供扩展来解释为什么原始值不存在。例如(必需的intent元素缺失,但仍然有效,因为扩展)
>>> json_str = b"""{ ... "resourceType": "MedicationRequest", ... "id": "1620518", ... "meta": { ... "versionId": "1", ... "lastUpdated": "2020-10-27T11:04:42.215+00:00", ... "source": "#z072VeAlQWM94jpc", ... "tag": [ ... { ... "system": "http://www.alpha.alp/use-case", ... "code": "EX20" ... } ... ] ... }, ... "status": "completed", ... "_intent": { ... "extension": [ ... { ... "url": "http://hl7.org/fhir/StructureDefinition/data-absent-reason", ... "valueCode": "unknown" ... } ... ] ... }, ... "medicationReference": { ... "reference": "Medication/1620516", ... "display": "Erythromycin 250 MG Oral Tablet" ... }, ... "subject": { ... "reference": "Patient/1620472" ... }, ... "encounter": { ... "reference": "Encounter/1620506", ... "display": "Follow up encounter" ... }, ... "authoredOn": "2018-06-16", ... "requester": { ... "reference": "Practitioner/1620502", ... "display": "Dr. Harold Hippocrates" ... }, ... "reasonReference": [ ... { ... "reference": "Condition/1620514", ... "display": "Otitis Media" ... } ... ], ... "dosageInstruction": [ ... { ... "text": "250 mg 4 times per day for 10 days", ... "timing": { ... "repeat": { ... "boundsDuration": { ... "value": 10, ... "unit": "day", ... "system": "http://unitsofmeasure.org", ... "code": "d" ... }, ... "frequency": 4, ... "period": 1, ... "periodUnit": "d" ... } ... }, ... "doseAndRate": [ ... { ... "doseQuantity": { ... "value": 250, ... "unit": "mg", ... "system": "http://unitsofmeasure.org", ... "code": "mg" ... } ... } ... ] ... } ... ], ... "priorPrescription": { ... "reference": "MedicationRequest/1620517", ... "display": "Amoxicillin prescription" ... } ... }""" >>> from fhir.resources.medicationrequest import MedicationRequest >>> obj = MedicationRequest.parse_raw(json_str) >>> "intent" not in obj.dict()
自定义验证器
《fhir.resources》提供广泛的API,用于将自定义验证器附加到任何模型。有关更多信息,请参阅关于根验证器。在创建根验证器时,您需要遵循一些约定。
参数数量是固定的,名称也是固定的。例如 (cls, values)。
应该返回 values,除非需要引发异常。
验证器只能为单个模型附加一次。更新:从现在起,无法在同一类上多次附加相同名称的验证器。
示例1:Patient验证器
from typing import Dict from fhir.resources.patient import Patient import datetime def validate_birthdate(cls, values: Dict): if not values: return values if "birthDate" not in values: raise ValueError("Patient's ``birthDate`` is required.") minimum_date = datetime.date(2002, 1, 1) if values["birthDate"] > minimum_date: raise ValueError("Minimum 18 years patient is allowed to use this system.") return values # we want this validator to execute after data evaluating by individual field validators. Patient.add_root_validator(validate_gender, pre=False)
示例2:从验证器类创建的Patient验证器
from typing import Dict from fhir.resources.patient import Patient import datetime class MyValidator: @classmethod def validate_birthdate(cls, values: Dict): if not values: return values if "birthDate" not in values: raise ValueError("Patient's ``birthDate`` is required.") minimum_date = datetime.date(2002, 1, 1) if values["birthDate"] > minimum_date: raise ValueError("Minimum 18 years patient is allowed to use this system.") return values # we want this validator to execute after data evaluating by individual field validators. Patient.add_root_validator(MyValidator.validate_gender, pre=False)
重要提示 可以将根验证器添加到任何基类,如 DomainResource。在这种情况下,您必须确保在导入派生类之前将根验证器附加到其中,否则验证器将不会触发(如果导入在先),这是出于自然原因。
ENUM验证器
《fhir.resources》为每个字段(如果适用)提供枚举约束的API,但它本身并不强制执行基于枚举的验证!请参阅此处讨论。如果您想强制执行枚举约束,您必须创建一个验证器。
示例:性别枚举
from typing import Dict from fhir.resources.patient import Patient def validate_gender(cls, values: Dict): if not values: return values enums = cls.__fields__["gender"].field_info.extra["enum_values"] if "gender" in values and values["gender"] not in enums: raise ValueError("write your message") return values Patient.add_root_validator(validate_gender, pre=True)
引用验证器
《fhir.resources》还通过字段属性 enum_reference_types 提供类似枚举的允许资源类型列表。您可以通过以下方式获取该列表(枚举)方法 resource_types = cls.__fields__["managingOrganization"].field_info.extra["enum_reference_types"]
orjson的使用
orjson 是最快的Python JSON库之一,比标准json库更正确(根据他们的文档)。好消息是 fhir.resource 对 orjson 有广泛的支持,并且启用它非常简单。您需要做的只是将 orjson 作为您的项目依赖项!
pydantic字段类型支持
所有可用的fhir资源(类型)都可以用作 pydantic 字段的价值类型。请参阅问题#46 对FastAPI pydantic响应模型的支持。模块 fhirtypes.py 包含所有fhir资源相关类型,并应自动触发验证器。
Resource.id 即 fhirtypes.Id 约束可扩展性
在此有许多关于 Resource.Id 的值长度的讨论。基于这些讨论,我们建议将您的 Resource.Id 尺寸保持在64个字母以内(为了与第三方系统的互操作性),但我们也在尊重其他意见的同时提供了关于Id长度的自由度,即64个字符的长度不足。 fhirtypes.Id.configure_constraints() 提供了根据您的需求自定义的功能。
- 示例:
>>> from fhir.resources.fhirtypes import Id >>> Id.configure_constraints(min_length=16, max_length=128)
注意:当您更改此行为时,它将影响您的整个项目。
XML支持
除了JSON字符串导出之外,还可以导出为XML字符串!在使用此功能之前,请确保已安装相关的依赖库。使用 fhir.resources[xml] 或 fhir.resources[all] 作为您的项目要求。
XML模式验证器! 在从文件或字符串加载时,可以提供自定义xmlparser,这意味着您可以针对FHIR XML模式(和/或您的自定义模式)验证数据。
- 示例-1 导出:
>>> from fhir.resources.patient import Patient >>> data = {"active": True, "gender": "male", "birthDate": "2000-09-18", "name": [{"text": "Primal Kons"}]} >>> patient_obj = Patient(**data) >>> xml_str = patient_obj.xml(pretty_print=True) >>> print(xml_str) <?xml version='1.0' encoding='utf-8'?> <Patient xmlns="http://hl7.org/fhir"> <active value="true"/> <name> <text value="Primal Kons"/> </name> <gender value="male"/> <birthDate value="2000-09-18"/> </Patient>
- 示例-2 从字符串导入:
>>> from fhir.resources.patient import Patient >>> data = {"active": True, "gender": "male", "birthDate": "2000-09-18", "name": [{"text": "Primal Kons"}]} >>> patient_obj = Patient(**data) >>> xml_str = patient_obj.xml(pretty_print=True) >>> print(xml_str) >>> data = b"""<?xml version='1.0' encoding='utf-8'?> ... <Patient xmlns="http://hl7.org/fhir"> ... <active value="true"/> ... <name> ... <text value="Primal Kons"/> ... </name> ... <gender value="male"/> ... <birthDate value="2000-09-18"/> ... </Patient>""" >>> patient = Patient.parse_raw(data, content_type="text/xml") >>> print(patient.json(indent=2)) { "resourceType": "Patient", "active": true, "name": [ { "text": "Primal Kons", "family": "Kons", "given": [ "Primal" ] } ], "gender": "male", "birthDate": "2000-09-18" }
>>> with xml parser >>> import lxml >>> schema = lxml.etree.XMLSchema(file=str(FHIR_XSD_DIR / "patient.xsd")) >>> xmlparser = lxml.etree.XMLParser(schema=schema) >>> patient2 = Patient.parse_raw(data, content_type="text/xml", xmlparser=xmlparser) >>> patient2 == patient True
- 示例-3 从文件导入:
>>> patient3 = Patient.parse_file("Patient.xml") >>> patient3 == patient and patient3 == patient2 True
XML常见问题解答
尽管在测试中对生成的XML进行了对FHIR/patient.xsd和FHIR/observation.xsd的验证,但我们建议您检查生产数据的输出。
包含注释功能,但我们在复杂的使用中建议您进行检查。
YAML支持
尽管FHIR规范中没有记录官方对YAML的支持,但作为一个实验性功能,我们添加了此支持。现在可以导出/导入YAML字符串。在使用此功能之前,请确保已安装相关的依赖库。根据您的项目需求使用fhir.resources[yaml]或fhir.resources[all]。
- 示例-1 导出:
>>> from fhir.resources.patient import Patient >>> data = {"active": True, "gender": "male", "birthDate": "2000-09-18", "name": [{"text": "Primal Kons", "family": "Kons", "given": ["Primal"]}]} >>> patient_obj = Patient(**data) >>> yml_str = patient_obj.yaml(indent=True) >>> print(yml_str) resourceType: Patient active: true name: - text: Primal Kons family: Kons given: - Primal gender: male birthDate: 2000-09-18
- 示例-2 从YAML字符串导入:
>>> from fhir.resources.patient import Patient >>> data = b""" ... resourceType: Patient ... active: true ... name: ... - text: Primal Kons ... family: Kons ... given: ... - Primal ... gender: male ... birthDate: 2000-09-18 ... """ >>> patient_obj = Patient.parse_raw(data, content_type="text/yaml") >>> json_str = patient_obj.json(indent=True) >>> print(json_str) { "resourceType": "Patient", "active": true, "name": [ { "text": "Primal Kons", "family": "Kons", "given": [ "Primal" ] } ], "gender": "male", "birthDate": "2000-09-18" }
- 示例-3 从YAML文件导入:
>>> from fhir.resources.patient import Patient >>> patient_obj = Patient.parse_file("Patient.yml") >>> json_str = patient_obj.json(indent=True) >>> print(json_str) { "resourceType": "Patient", "active": true, "name": [ { "text": "Primal Kons", "family": "Kons", "given": [ "Primal" ] } ], "gender": "male", "birthDate": "2000-09-18" }
YAML常见问题解答
我们使用https://pyyaml.org/ PyYAML库进行序列化和反序列化,但如果我们找到更快的库,我们可能会使用它。欢迎您提供您的建议。
尚不支持基于YAML的注释,而是使用json注释语法!当然,此注释功能也在我们的待办事项列表中。
允许空字符串
尽管允许空字符串值对FHIR基本数据类型String不是好的实践。但在现实生活中,有时这是不可避免的。
- 示例:
请将此代码放在您的__init__.py模块或任何位置,以确保此代码片段在运行时执行。
>>> from fhir.resources.fhirtypes import String >>> String.configure_empty_str(allow=True)
FHIR版本R4B高于R4
FHIR版本R4B与R4相比变化不大。因此,我们决定不为R4创建单独的子包,而是与现有的R4重叠。这也意味着在未来,当我们开始处理R5时,将会有R4B的子包,而没有R4。我们建议您制定计划升级到R4B。您可以在此找到相关信息处理策略-R4-R4B。
您可以在这里找到完整的讨论https://github.com/nazrulworld/fhir.resources/discussions/116
迁移(从6.X.X到7.0.X)
首先,如果您希望继续使用FHIR版本R4B或R4,就必须更正所有导入路径,因为那些资源已经移动到名为R4B的子包下。然后,如果您希望使用当前的R5版本,请仔细阅读以下文档。
查看完整更改历史 -> https://build.fhir.org/history.html
查看R5和R4B之间的完整差异列表 -> https://hl7.org/fhir/R5/diff.html
如果您计划直接从版本R4迁移,那么查看R4B和R4之间的差异非常重要 -> https://hl7.org/fhir/R4B/diff.html
迁移(从晚于6.X.X)
本迁移指南说明了从晚于6.X.X版本开始的一些API底层更改和替换,这些更改是常用到的。
fhir.resources.fhirelementfactory.FHIRElementFactory::instantiate
替换: fhir.resources.construct_fhir_element
第一个参数的值与之前相同,即资源名称。
第二个参数比之前的更灵活!不仅可以提供json字典,还可以提供json字符串或json文件路径。
没有第三个参数,与之前的版本相同。
fhir.resources.fhirabstractbase.FHIRAbstractBase::__init__
替换: fhir.resources.fhirabstractmodel.FHIRAbstractModel::parse_obj<classmethod>
第一个参数的值与之前相同,即json字典。
没有第二个参数,与之前的版本相同。
fhir.resources.fhirabstractbase.FHIRAbstractBase::as_json
替换: fhir.resources.fhirabstractmodel.FHIRAbstractModel::dict
输出几乎与之前相同,但在某些日期类型方面有一些差异,例如Python中的日期、datetime和Decimal都是对象表示。
当需要json字符串时,可以使用fhir.resources.fhirabstractmodel.FHIRAbstractModel::json作为替换(因此不需要进一步从字典中进行json序列化)。
注意
所有资源/类都源自fhir.resources.fhirabstractmodel.FHIRAbstractModel,之前源自fhir.resources.fhirabstractbase.FHIRAbstractBase。
发布和版本策略
从版本5.0.0开始,我们遵循自己的发布策略,尽管遵循类似于FHIR®版本的语义版本控制方案,但现在发布不再依赖于FHIR®。
删除的声明
本包遵循FHIR®发布和版本策略,例如,FHIR发布下一个版本4.0.1,我们在这里也发布相同的版本。
致谢
所有FHIR®资源(Python类)都是使用fhir-parser生成的,该工具是从https://github.com/smart-on-fhir/fhir-parser.git分叉的。
此包骨架是用Cookiecutter和audreyr/cookiecutter-pypackage项目模板创建的。
© 版权所有HL7®标志、FHIR®标志和火焰标志是Health Level Seven International的注册商标。
历史
7.1.0 (2023-12-14)
重大更改
停止支持Python 3.6。
停止支持pydantic v1。
改进
7.0.2 (2023-07-03)
问题124 2.x pydantic发布后的pydantic最大版本限制已添加。
7.0.1 (2023-05-29)
修复
问题#129 urn在Url中不受支持
7.0.0 (2023-04-08)
新功能
在根包下已添加对FHIR版本R5的支持。
重大更改
所有根资源(FHIR版本R4B)都已移动到子包R4B下。请参阅迁移指南。
6.5.0 (2023-01-01)
重大更改
FHIR R4B发布与当前的R4作为默认发布重叠。请参阅变更(发布R4B:2022年5月28日)http://hl7.org/fhir/R4B/history.html。更多详细信息请参阅http://hl7.org/fhir/R4B/diff.html
改进
问题#90 将日志级别从警告降级为调试。
原始类型URL现在接受不带前缀“/”的相对路径。
6.4.0 (2022-05-11)
错误修复
修复,如果原始字段值为null,则不会包含原始扩展。[nazrulworld]
改进
问题 #97 现在接受null值作为String列表的成员。
原始数据类型URL现在接受相对路径。
重大更改
Element.id & Resource.id 没有任何扩展。请参阅 https://chat.fhir.org/#narrow/stream/179166-implementers/topic/Resource.2Eid.20and.20primitive.20extension。
6.2.2 (2022-04-02)
问题 #96,修复了 YAML 中 datetime 的 ISO 格式表示。[nazrulworld]
6.2.1 (2022-01-14)
6.2.0 (2022-01-01)
错误修复
问题 #88 修复了错别字。资源名称常量错误。[nazrulworld]
6.2.0b3(2021-06-26)
新功能
字符串类型类现在是可配置的,现在可以允许空字符串值。
错误修复
问题 #75 从安装的包中删除“tests”。
问题 #74 Falsy 值何时被评估为 None?
修复了 DSTU2 的某些问题 https://github.com/nazrulworld/fhir.resources/pull/71 & https://github.com/nazrulworld/fhir.resources/pull/70 [ItayGoren]
6.2.0b2(2021-04-05)
新功能
解析 YAML 文件或字符串/字节内容时,现在接受额外的 loader 类参数。
现在支持从 XML 文件或字符串/字节内容解析。可以提供 xmlparser 以进行模式验证。
错误修复
将正确的 fhir 版本名称添加到 STU3 和 DSTU2 的 Primitive Type Base 类中。
6.2.0b1(2021-03-31)
新功能
重大更改
FHIRAbstractModel.json() 和 FHIRAbstractModel.dict() 的参数签名更符合 FHIR,并删除了附加参数(pydantic 特定的)。
错误修复
为 FHIRPrimitiveExtension 类添加了缺少的 element_property 字段属性。
6.1.0 (2021-02-13)
破坏/修复:PR#48 Resource.id 类型已从 fhirtypes.String 替换为 fhirtypes.Id(仅适用于 R4)[ItayGoren]
修复:fhirtypes 的约束正则表达式 Id、Code、Integer、Decimal、UnsignedInt、PositiveInt 等。[nazrulworld]
6.0.0 (2020-12-17)
问题 #21 添加了剩余的资源。[iatechicken]
6.0.0b11(2020-11-25)
修复:将 ClaimResponseAddItemAdjudicationType 资源类型名称错误地放入 DTSU2 中。
6.0.0b10(2020-11-15)
改进
FHIRAbstractModel::add_root_validator 在适当的验证方面得到了改进和实用,现在可以提供类方法作为根验证器。
错误修复
问题 #41 pydantic.errors.ConfigError:重复的验证器函数。
6.0.0b9(2020-11-05)
改进
现在自动支持 simplejson(取决于可导入性),与 orjson 和默认 json 库一起。JSON 序列化器的顺序可用(orjson -> simplejson(作为后备)-> json(作为默认))。
重大更改
orjson 默认不可用,必须使用 extra_require orjson 来启用它。
6.0.0b8(2020-11-02)
pydantic 的最小版本已设置为 1.7.2。
6.0.0b7(2020-10-31)
如果您遇到导入错误 ``from pydantic.utils import ROOT_KEY``,请将您的 pydnatic 版本升级到 <1.7。
修复
问题 #39 添加了与 pydantic 版本 1.6.x 到 1.7.x 的兼容性。[nazrulworld]
改进
问题 #40 如果提供了扩展值,则使 fhir 原始元素字段可选。
6.0.0b6 (2020-10-24)
改进
FHIRAbstractModel::json 现在接受额外的参数 return_bytes,表示 json 字符串将作为字节。 [nazrulworld]
问题#38 添加了对 FHIR 注释的支持。根据来自 Grahame Grieve 的 json 中注释的建议,现在接受 fhir_comments。[nazrulworld]
在 FHIRAbstractModel::json 中添加了 FHIR 注释过滤器选项,这意味着可以通过提供参数 exclude_comments 的值,在生成 json 字符串时排除任何注释。[nazrulworld]
添加了更多的 FHIR DSTU2 资源。[Itay Goren]
6.0.0b5 (2020-10-04)
改进
visionprescription 和 supplyrequest 资源已添加到 DSTU2。[iatechicken]
修复
6.0.0b4 (2020-09-24)
改进
orjson 作为 Model 的默认 json dumps 和 loads 支持。
FHIRAbstractModel::get_json_encoder 类方法现在可用,它返回与 pydantic 兼容的 json 编码器可调用对象,可用于任何 json 序列化器。
添加了更多的 DSTU2 FHIR 资源,https://github.com/nazrulworld/fhir.resources/issues/21。感谢 [mmabey]。[mmabey]
修复
修复了在将原始类型用作 URL(在 StructureDefinition 中允许)时 URL 验证的问题。[simonvadee]
修复了 问题#19 获取没有意义的验证错误。[simonvadee]
6.0.0b3 (2020-08-07)
FHIRAbstractModel::get_resource_type 类方法现在可用,它返回资源的名称。[simonvadee]
6.0.0b2 (2020-07-09)
FHIRAbstractModel::element_properties 类方法现在可用,它返回 ModelField 的生成器,这些是资源的元素。[simonvadee]
对 enum_values 进行了小的修复。[simonvadee]
6.0.0b1 (2020-07-05)
进行了革命性的进化,现在完全使用现代 Python 重新编写,底层 API(几乎所有)都已更改。请查看说明部分,了解如何操作。[simonvadee]
改进
重大更改
停止支持 Python 2.7。
5.1.0 (2020-04-11)
改进
FHIR STU3 发布版本已从 3.0.1 升级到 3.0.2,请在此处找到变更历史记录 https://www.hl7.org/fhir/history.html。
FHIR R4 发布版本已从 4.0.0 升级到 4.0.1,请在此处找到变更历史记录 https://www.hl7.org/fhir/history.html。
5.0.1 (2019-07-18)
错误修复
问题#5 混乱的错误信息“名称 ‘self’ 未定义” [nazrulworld]
5.0.0 (2019-06-08)
只有发布稳定版本。[nazrulworld]
5.0.0b3 (2019-05-14)
新功能
Isuue#1 添加 DSTU2 支持
5.0.0b2 (2019-05-13)
破坏性或改进
元素属性:元素现在具有额外的属性 type_name。现在格式如下 (name, json_name, type, type_name, is_list, "of_many", not_optional)。 type_name 指的是 FHIR 结构定义中的原始类型名称(代码),在执行 FHIR 搜索、FHIRpath 导航时非常有帮助。
5.0.0b1 (2019-01-19)
新功能
实现了自己的构建策略,现在之前版本的 FHIR® 资源可以作为 Python 子包提供。
构建信息
默认版本是 R4(请参阅 4.0.0b1 (2019-01-13) 节中的版本信息)
STU3(请参阅 3.0.1 (2019-01-13) 节中的版本信息)
4.0.0 (2019-01-14)
请参阅 4.0.0b1 节中的版本信息。
4.0.0b1 (2019-01-13)
[FHIR] FhirVersion=4.0.0-a53ec6ee1b version=4.0.0 buildId=a53ec6ee1b date=20181227223754
3.0.1 (2019-01-13)
[FHIR] FhirVersion=3.0.1.11917 version=3.0.1 revision=11917 date=20170419074443
项目详情
fhir.resources-7.1.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | fae2d43c03dacf85a9f9fbce3b62148f3166fe297471cd43b74d91abbf69f818 |
|
MD5 | 99759ef0d62ecdae4e31fbf831f38abd |
|
BLAKE2b-256 | 2fcf3ce9e45ec0b5bddade9d06dfafc91108d6841649ec70057bda785556c1d5 |
fhir.resources-7.1.0-py2.py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 4d37c3aadb3afbabad28ca7701b87323680468a13f6a6426bb6c282d4efd5c62 |
|
MD5 | e4521a199568bceb1213579fc9cb3981 |
|
BLAKE2b-256 | 155800b50d32c9669acfeaac2c60989a9b49e7bde79c1a8d31801be61ee558e1 |