@aehrc/sdc-template-extract

中文文档
1.0.16发布于 2026/09/10Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 4.3万

Performs template-based extraction from the HL7 FHIR SDC (Structured Data Capture) specification: https://build.fhir.org/ig/HL7/sdc/extraction.html#template-based-extraction

原始使用文档
文档目录4 节
  1. Usage
  2. Using it in a web app
  3. Using it in a backend service
  4. Local development notes

SDC-Template-based Extract

A Typescript reference implementation of the $extract operation from the HL7 FHIR Structured Data Capture Specification. This only covers template-based extraction.

Usage

There are two ways to use this package:

  1. Using it in a web app
  2. Using it in a backend service e.g. ExpressJS

Using it in a web app

It is recommended to use inAppExtraction(), which performs an in-app extraction. This means that the app is not sending data to an external server, but rather using JavaScript to perform the extraction in the browser.

const responseToExtract = structuredClone(savedResponse); // Good practice to deep clone the response to prevent mutating the original response
const inAppExtractOutput = await inAppExtract(
  responseToExtract,
  sourceQuestionnaire
);

const { extractResult, extractSuccess } = inAppExtractOutput;

// Extraction is successful
if (extractSuccess && !extractResultIsOperationOutcome(extractResult)) {
  const extractedBundle = extractResult.extractedBundle;

  // Do things with the successfully extracted transaction bundle...
}

Available parameters for inAppExtract():

ParameterDescription
questionnaireResponseQuestionnaireResponse to extract data from
questionnaireOrCallbackEither a Questionnaire resource or a fetch/callback configuration for dynamic retrieval (if module making the inAppExtract() call does not have access to the Questionnaire resource).
comparisonSourceResponseAn optional QuestionnaireResponse used for comparison when extracting. If this is provided, only "modified" items will be extracted. In most cases, this likely is the pre-populated response.

Using it in a backend service

Using this library in a backend service requires more pre-configuration. Due to how the $extract works, you will need to provide a Parameters resource defining the input parameters conforming to the extract() function.

sdc-template-extract allows you to specify custom questionnaire and comparison-source-response parameters, allowing you to pass their respective resources directly to the extract() function. A library function createInputParameters() is provided to help you create the Parameters resource.

There is no sample implementation of using the extract() function in a backend service as of now.

Local development notes

It's recommended to run this library within a web app or a service if you're doing local development. This library compiles to both CommonJS and ES Modules, so there is no problems in using it across web frameworks and Node-based backends.

To compile the code, use npm run compile. To watch for changes, use npm run watch.

Note: Do not use tsc or tsc -w as it will only compile to ES Modules, which means it will not work with CommonJS-based implementations.

版本与发布记录

@aehrc/sdc-template-extract 共发布 19 个版本,首次发布于 2025/05/22;过去 12 个月发布了 2 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.0.16latest2026/09/101 个月前
1.0.152026/01/139 个月前
1.0.142025/10/231 年前
1.0.132025/10/171.1 年前
1.0.122025/10/031.1 年前
1.0.112025/10/021.1 年前

关于 @aehrc/sdc-template-extract 的常见问题

@aehrc/sdc-template-extract 是什么?

Performs template-based extraction from the HL7 FHIR SDC (Structured Data Capture) specification: https://build.fhir.org/ig/HL7/sdc/extraction.html#template-based-extraction

如何安装 @aehrc/sdc-template-extract?

在项目目录运行 npm install @aehrc/sdc-template-extract,或使用 pnpm add / yarn add / bun add。

@aehrc/sdc-template-extract 支持 TypeScript 吗?

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

@aehrc/sdc-template-extract 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@aehrc/sdc-template-extract 可以商用吗?

@aehrc/sdc-template-extract 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@aehrc/sdc-template-extract 的下载量有多少?

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

@aehrc/sdc-template-extract 还在维护吗?

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