跳转到主要内容

FHIR Core库

项目描述

FHIR® Core

https://img.shields.io/pypi/v/fhir-core.svg Supported Python Versions https://img.shields.io/travis/com/nazrulworld/fhir-core.svg Windows Build https://codecov.io/gh/nazrulworld/fhir.resources/branch/master/graph/badge.svg https://img.shields.io/badge/code%20style-black-000000.svg Downloads HL7® FHIR®

由Pydantic V2提供支持。此库是为支持fhir.resources库而开发的,但您也可以出于自己的目的使用它。它提供了一个抽象基类用于任何FHIR资源模型和原始数据类型,以及用于创建FHIR资源模型和其他复杂数据类型的工厂。

安装

只需简单地进行pip install fhir-core。但如果您想要开发版本,请从https://github.com/nazrulworld/fhir-core克隆,并执行pip install -e .[dev]

用法

示例:1:此示例创建了一个包含一些属性(id、active、name、address)的组织类

>>> from typing import List
>>> from pydantic import Field
>>> from fhir_core.fhirabstractmodel import FHIRAbstractModel
>>> from fhir_core.types import IdType, BooleanType, StringType
>>> data = {
...     "id": "f001",
...     "active": True,
...     "name": "Acme Corporation",
...     "address": ["Road 10": "Acme corporation", "2390", "USA"}]
... }
>>> class Organization(FHIRAbstractModel):
...     __resource_type__ = "Organization"
...     id: IdType = Field(None, title="Id", alias="id", json_schema_extra={"element_property": True})
...     active: BooleanType = Field(None, title="Active", alias="active", json_schema_extra={"element_property": True})
...     name: StringType = Field(None, title="Name", alias="name", json_schema_extra={"element_property": True})
...     address: ListType[StringType] = Field(None, title="Address lines", alias="address", json_schema_extra={"element_property": True})
...
...     @classmethod
        def elements_sequence(cls):
            return ["id", "active", "name", "address"]
...
>>> org = Organization.model_validate(data)
>>> org.active is True
True
>>> org_json_str = org.model_dump_json()
>>> Organization.model_validate_json(org_json_str).model_dump() == org.model_dump()
True

复杂示例

  1. https://github.com/nazrulworld/fhir-core/blob/main/tests/fixtures/resources/extension.py

  2. https://github.com/nazrulworld/fhir-core/blob/main/tests/fixtures/resources/fhirtypes.py

  3. https://github.com/nazrulworld/fhir-core/blob/main/tests/fixtures/resources/codesystem.py

版权所有:HL7®标志、FHIR®标志和火焰标志是Health Level Seven International的注册商标(访问链接)

历史记录

0.1.0b9 (2024-10-02)

修复

  • 问题:AttributeError: ‘NoneType’对象没有名为‘__resource_type__’的属性 (访问链接)

0.1.0b8 (2024-08-04)

  • FHIRAbstractModel中添加了YAML转储和验证选项。

0.1.0b7 (2024-07-31)

  • 为函数"create_fhir_type"和"create_fhir_element_or_resource_type"添加了类型提示。

0.1.0b6 (2024-07-30)

  • 类型《id》和《String》的核心配置来自约束模块。

  • 《id》的默认最大字符长度现在是255。

0.1.0b5 (2024-07-28)

  • 修复了检查is_primitive的函数,因为添加了缺少的字节和bytesarray。

  • 处理Base64Binary类型的编码。

0.1.0b4 (2024-07-28)

  • 修复了扩展序列化。

0.1.0b3 (2024-07-28)

  • 修复了检查is_primitive的函数。

  • 修复了Resource和Element类型的验证器。

0.1.0b2 (2024-07-27)

错误修复

  • 修复了一些原语类型的字符串模式,例如UriType。

  • 修复了模型序列化器。

0.1.0b1 (2024-07-26)

  • 第一个beta版本!但这个版本还不够稳定,不能用于生产。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解更多关于安装包的信息。

源分布

fhir_core-0.1.0b9.tar.gz (23.8 kB 查看哈希)

上传时间

构建分布

fhir_core-0.1.0b9-py2.py3-none-any.whl (21.4 kB 查看哈希)

上传时间 Python 2 Python 3

由以下提供支持