@atomic-ehr/fhirschema

中文文档
0.0.14发布于 2026/07/24MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 8787

TypeScript implementation of FHIRSchema converter and validator

原始使用文档
文档目录13 节
  1. Overview
  2. Installation
  3. Usage
  4. Converting StructureDefinition to FHIRSchema
  5. Validating FHIR Resources
  6. Development
  7. Running Tests
  8. Type Checking
  9. Building
  10. Project Structure
  11. Development
  12. Contributing
  13. License

FHIRSchema

npm canary npm version CI

TypeScript implementation of FHIRSchema converter and validator.

Overview

This project provides:

  • Converter: Transforms FHIR StructureDefinitions into FHIRSchema format
  • Validator: Validates FHIR resources against FHIRSchema definitions

Installation

npm install @atomic-ehr/fhirschema

Or install the latest canary version:

npm install @atomic-ehr/fhirschema@canary

Usage

Converting StructureDefinition to FHIRSchema

import { translate } from '@atomic-ehr/fhirschema';

const structureDefinition = {
  resourceType: 'StructureDefinition',
  name: 'Patient',
  // ... rest of the StructureDefinition
};

const fhirSchema = translate(structureDefinition);

Validating FHIR Resources

import { validate } from '@atomic-ehr/fhirschema';

const resource = {
  resourceType: 'Patient',
  // ... patient data
};

const schema = { /* FHIRSchema */ };
const context = { schemas: { Patient: schema } };

const result = validate(context, [], resource);
if (result.valid) {
  console.log('Resource is valid');
} else {
  console.log('Validation errors:', result.errors);
}

Development

Running Tests

bun test

Type Checking

bun run typecheck

Building

bun run build

Project Structure

├── src/
│   ├── converter/     # StructureDefinition to FHIRSchema converter
│   ├── validator/     # FHIRSchema validator
│   └── types.ts       # Shared TypeScript types
├── test/
│   ├── unit/          # Unit tests
│   └── golden/        # Golden tests with expected outputs
├── spec/              # Specifications and documentation
├── adr/               # Architecture Decision Records
└── tasks/             # Task management

Development

This project uses:

  • Bun as the runtime and test runner
  • TypeScript for type safety
  • GitHub Actions for CI/CD

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

[License information to be added]

版本与发布记录

@atomic-ehr/fhirschema 共发布 53 个版本,首次发布于 2025/07/31;过去 12 个月发布了 37 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.0.14latest2026/07/243 个月前
0.0.14-canary.20260724070511.ccc9885canary2026/07/243 个月前
0.0.13-canary.20260723121536.32bdc392026/07/233 个月前
0.0.132026/07/223 个月前
0.0.13-canary.20260722150102.35bd9122026/07/223 个月前
0.0.12-canary.20260722125017.bda8dd42026/07/223 个月前

关于 @atomic-ehr/fhirschema 的常见问题

@atomic-ehr/fhirschema 是什么?

TypeScript implementation of FHIRSchema converter and validator

如何安装 @atomic-ehr/fhirschema?

在项目目录运行 npm install @atomic-ehr/fhirschema,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:typescript(^5)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@atomic-ehr/fhirschema 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@atomic-ehr/fhirschema 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@atomic-ehr/fhirschema 可以商用吗?

@atomic-ehr/fhirschema 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@atomic-ehr/fhirschema 的下载量有多少?

根据 npm 官方下载统计,@atomic-ehr/fhirschema 在 2026/10/07 – 2026/11/05 这 30 天内被下载 8,787 次,日均约 293 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@atomic-ehr/fhirschema 还在维护吗?

最新版本 0.0.14 发布于 2026/07/24(3 个月前);至今共发布 53 个版本,其中过去 12 个月发布了 37 个;首次发布于 2025/07/31。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。