# FHIR 沙盒：私有的 FHIR R4 测试服务器

> 一个免费的 FHIR R4 沙盒，包含 30 位合成患者：基础 URL、身份验证、稳定身份 ID、重置、限制和首次请求 — 以及它与公共测试服务器的区别。

Source: https://developers.anpheros.com/zh/guides/fhir-sandbox

**FHIR 沙盒是一个支持 HL7 FHIR API 的测试服务器，开发者可以在其中创建、读取和搜索资源，而无需接触真实患者。** Anpheros FHIR 沙盒对您的项目是私有的：一个 FHIR R4 端点（位于 `https://platform.anpheros.com/fhir/R4`），30 位合成患者（每位患者有六个月的历史记录），与生产环境相同的身份验证，以及一个重置按钮。它是免费的，只需一次点击即可获取。

<!-- visual:sandbox-stats -->

## 沙盒详情

| | |
|---|---|
| FHIR 基础 URL | `https://platform.anpheros.com/fhir/R4` (密钥决定沙盒或生产环境) |
| FHIR 版本 | R4 (4.0.1)，26 种资源类型；公共 CapabilityStatement 位于 `/fhir/R4/metadata` |
| 身份验证 | `Authorization: Bearer sk_test_…`，或 SMART 应用的 OAuth 2.1 令牌 |
| 测试数据 | 30 名合成患者：成人、儿童和老人，包含 ICD-10 病症、ATC 药物、过敏史、LOINC 实验室检查和生命体征 |
| 稳定的 Persona ID | 标识符系统 `https://anpheros.com/fhir/sid/sandbox-persona`，值 `p01`–`p30`：即使重置后也是同一个人 |
| 重置 | 在仪表板中一键操作即可恢复 30 名患者（使用新 ID）；您创建的患者不受影响 |
| 限制 | 每天 10,000 次资源写入，50 名您自己的患者，250 MB 文档 |
| 价格 | 免费，无需信用卡 |

## 首次请求

```bash
export KEY=sk_test_...        # from the dashboard: Get a sandbox key
BASE=https://platform.anpheros.com/fhir/R4

# the server's capabilities (no key needed)
curl -s $BASE/metadata | head -c 400

# three synthetic patients
curl -s "$BASE/Patient?_count=3" -H "Authorization: Bearer $KEY"

# one persona by its stable identifier
curl -s "$BASE/Patient?identifier=https://anpheros.com/fhir/sid/sandbox-persona|p02" -H "Authorization: Bearer $KEY"

# that patient's lab results, newest first
curl -s "$BASE/Observation?patient=$PID&category=laboratory&_sort=-date" -H "Authorization: Bearer $KEY"

# the whole record, and an International Patient Summary
curl -s "$BASE/Patient/$PID/\$everything" -H "Authorization: Bearer $KEY"
curl -s "$BASE/Patient/$PID/\$summary" -H "Authorization: Bearer $KEY"
```

## 私有沙盒还是公共测试服务器？

<!-- visual:sandbox-vs-public -->

## 常见问题解答

### 有免费的 FHIR 沙盒吗？
是的。Anpheros FHIR R4 沙盒是免费且自助服务的：使用 Google 登录仪表板，按“获取沙盒密钥”并使用它进行调用 `/fhir/R4`。

### FHIR 沙盒的 URL 是什么？
`https://platform.anpheros.com/fhir/R4`。沙盒和生产环境共享地址；一个 `sk_test_` 密钥仅访问沙盒数据。

### 沙盒中有测试患者吗？
是的，每个项目有 30 名合成患者，每位患者大约有六个月的病史、用药、过敏、实验室结果和生命体征。每个角色在重置后保持稳定的标识符。

### 我可以在沙盒中测试 SMART on FHIR 和 OAuth 吗？
是的。沙盒支持 OAuth 2.1 with PKCE、SMART v2 患者范围和同意页面，因此可以在生产环境之前对应用程序进行端到端测试。

### 我可以将真实的患者数据放入沙盒吗？
不可以。沙盒仅用于合成数据。真实患者数据属于生产环境，这是一个为经过验证的组织准备的独立数据库，需要签署数据处理协议。

<!-- visual:cta-sandbox -->

## 相关资源

- [免费 FHIR 数据库和沙盒](https://developers.anpheros.com/zh/guides/free-fhir-database)：何时选择托管 FHIR 数据库
- [免费沙盒中的 FHIR 概念验证](https://developers.anpheros.com/zh/guides/fhir-proof-of-concept)：试点项目应展示的内容
- [用于测试的合成患者数据](https://developers.anpheros.com/zh/guides/synthetic-patient-data)
- [FHIR 平台](https://developers.anpheros.com/zh/guides/fhir)
- [入门](https://developers.anpheros.com/zh/guides/getting-started)
- [限制](https://developers.anpheros.com/zh/guides/limits)
