微算力 · API 导航与自营网关
API 接入 EN
未登录登录
🏥

临床编码一键标准化 · FHIR问卷智能生成

FHIR Questionnaire Designer · v0.2.4
专业技能 安全 B 级 作者 elmariachi111 公开目录收录
下载 1.4k 安装 0 收藏 3k 浏览 12
原始页面

简介

基于官方API将临床需求文档转换为FHIR标准问卷,内置LOINC/SNOMED CT编码查询,无需API密钥

原始描述

Helps creating FHIR conforming questionnaire definitions from plain requirement ideation docs. Contains scripts to look up LOINC and SNOMED CT codes for medical conditions, findings, observations, medications, procedures from a official coding APIs. No API keys required at the moment.

中文使用说明 来自收录源

核心功能

该技能专注于将临床需求文档转换为符合FHIR R4标准的Questionnaire资源,解决医疗信息化中最关键的编码标准化问题。

核心用法:

  1. 编码查询:通过 search_loinc.py 和 search_snomed.py 脚本实时查询官方术语服务器,获取临床问题、观察指标、疾病诊断的标准化代码
  2. 答案值集查询:query_valueset.py 自动获取LOINC配套的标准答案列表(如PHQ-9抑郁量表的应答选项)
  3. 问卷构建:基于模板(minimal/basic/advanced)快速搭建问卷结构,支持条件显示、重复组、标准/自定义答案列表等复杂逻辑
  4. 验证输出:validate_questionnaire.py 确保最终JSON符合FHIR规范

显著优点:

  • 编码权威性:强制通过API查询LOINC/SNOMED CT,杜绝AI"幻觉"生成虚假代码,这是临床系统互操作的生命线
  • 零配置成本:无需申请API密钥,直接访问NIH clinicaltables和tx.fhir.org公共端点
  • 临床场景全覆盖:从标准化量表(PHQ-9、GAD-7)到自定义机构问卷均有成熟工作流
  • 渐进式复杂度:inline answerOption(无系统)满足简单需求,可选Welshare命名空间支持跨问卷复用

潜在局限与风险:

  • 网络依赖性强:必须白名单访问clinicaltables.nlm.nih.gov和tx.fhir.org,离线环境完全失效
  • 术语服务器稳定性:公共FHIR术语服务器偶有超时,需配置备用端点(HAPI、CSIRO Ontoserver)
  • SNOMED CT语义标签限制:--semantic-tag过滤依赖服务器返回的显示名称,非标准化字段
  • 编码查询延迟:实时API调用可能拖慢交互速度,高频场景需考虑本地缓存

适合人群: 医疗信息化工程师、FHIR实施顾问、临床研究人员、EHR系统产品经理。特别适合需要快速将纸质量表/临床评估表数字化的团队,以及对互操作性标准有合规要求的医疗机构。

常规风险提醒:

  • 严禁依赖训练数据中的LOINC/SNOMED代码,必须通过脚本实时验证
  • 自定义编码系统URI为可选高级功能,默认应使用无系统的inline answerOption
  • 生产环境建议部署企业级FHIR术语服务器替代公共端点

技能正文


name: design-fhir-loinc-questionnaires description: Helps creating FHIR conforming questionnaire definitions from plain requirement ideation docs. Contains scripts to look up LOINC and SNOMED CT codes for medical conditions, findings, observations, medications, procedures from a official coding APIs. No API keys required at the moment. metadata: dependencies: python>=3.8, jsonschema>=4.0.0

FHIR Questionnaire Skill

⚠️ CRITICAL RULES - READ FIRST

NEVER suggest LOINC or SNOMED CT codes from memory or training data. ALWAYS use the search and query scripts in this skill.

When any clinical code is needed:

  1. For clinical questions/observations: ALWAYS run python scripts/search_loinc.py "search term" FIRST
  2. For clinical concepts/conditions: ALWAYS run python scripts/search_snomed.py "search term" FIRST
  3. ONLY use codes returned by the scripts
  4. If search fails or returns no results, DO NOT make up codes

Clinical codes from AI memory are highly unreliable and will cause incorrect clinical coding.

Network Access Requirements

Requires whitelisted network access:

  • clinicaltables.nlm.nih.gov (LOINC search)
  • tx.fhir.org (FHIR terminology server for LOINC answer lists and SNOMED CT search)

If network access fails, STOP. Do not suggest codes.

Essential Scripts (Use These Every Time)

1. Search LOINC Codes

ALWAYS run this before suggesting any LOINC code (clinical questions/observations):

python scripts/search_loinc.py "depression screening"
python scripts/search_loinc.py "blood pressure" --format fhir

2. Search SNOMED CT Codes

ALWAYS run this before suggesting any SNOMED CT code (clinical concepts/conditions):

python scripts/search_snomed.py "diabetes"
python scripts/search_snomed.py "hypertension" --format fhir
python scripts/search_snomed.py "diabetes mellitus" --semantic-tag "disorder"

Note: The --semantic-tag filter works best when the semantic tag appears in the display name (e.g., "Diabetes mellitus (disorder)").

3. Find Answer Options

For questions with standardized answers:

python scripts/query_valueset.py --loinc-code "72166-2"
python scripts/query_valueset.py --loinc-code "72166-2" --format fhir

4. Validate Questionnaire

Before finalizing:

python scripts/validate_questionnaire.py questionnaire.json

Templates

Start with assets/templates/:

  • minimal.json - Bare bones structure
  • basic.json - Simple questionnaire
  • advanced.json - Complex with conditional logic

Workflows

Standardized Clinical Instruments (PHQ-9, GAD-7, etc.)

# Step 1: Find panel code (NEVER skip this)
python scripts/search_loinc.py "PHQ-9 panel"

# Step 2: Find answer options
python scripts/query_valueset.py --loinc-code "FOUND-CODE" --format fhir

# Step 3: See examples/templates
# Check references/examples.md for complete implementations

Custom Organizational Questionnaires

# Step 1: Start with template
cp assets/templates/advanced.json my-questionnaire.json

# Step 2: For any clinical questions, search LOINC
python scripts/search_loinc.py "body weight"

# Step 3: Add answer options if available
python scripts/query_valueset.py --loinc-code "FOUND-CODE"

# Step 4: For custom questions without LOINC results, use inline answerOptions
# (no coding system needed - just code + display)

# Step 5: Validate
python scripts/validate_questionnaire.py my-questionnaire.json

Custom Answer Lists (When LOINC Has No Match)

When LOINC search returns no suitable answer list, use inline answerOption with system-less valueCoding by default. This is the simplest, spec-compliant approach for custom answer lists:

{
  "linkId": "sleep-quality",
  "type": "choice",
  "text": "How would you rate your sleep quality?",
  "answerOption": [
    {"valueCoding": {"code": "good", "display": "Good"}},
    {"valueCoding": {"code": "fair", "display": "Fair"}},
    {"valueCoding": {"code": "poor", "display": "Poor"}}
  ]
}

Do NOT invent a coding system URI. Omitting system is valid FHIR and signals that these are local, questionnaire-scoped codes.

Opt-in: Reusable Welshare Coding System

If the user explicitly requests reusable codes that can be shared across questionnaires, use the Welshare namespace (http://codes.welshare.app) via the helper script:

python scripts/create_custom_codesystem.py --interactive

This creates a CodeSystem + ValueSet pair. To convert an inline answer list to the reusable format, add "system": "http://codes.welshare.app/CodeSystem/<category>/<id>.json" to each valueCoding and optionally reference the ValueSet via answerValueSet. See references/loinc_guide.md for details.

Common Patterns

  • Conditional display: Use enableWhen to show/hide questions
  • Repeating groups: Set "repeats": true for medications, allergies, etc.
  • Standardized answers: Use query_valueset.py --loinc-code "CODE" for LOINC-backed answer lists
  • Custom answers: Use inline answerOption with valueCoding (no system) for non-standardized choices

See references/examples.md for complete working examples.

Script Reference

search_loinc.py - Find LOINC Codes

python scripts/search_loinc.py "blood pressure"
python scripts/search_loinc.py "depression" --limit 10 --format fhir

search_snomed.py - Find SNOMED CT Codes

python scripts/search_snomed.py "diabetes"
python scripts/search_snomed.py "hypertension" --limit 10 --format fhir
python scripts/search_snomed.py "asthma" --format table
python scripts/search_snomed.py "diabetes mellitus" --semantic-tag "disorder"

Formats: json (default), table, fhir Semantic tags (when present in results): disorder, finding, procedure, body structure, substance, organism Note: Semantic tag filtering only works when tags are included in the display name from the terminology server.

query_valueset.py - Find Answer Options

python scripts/query_valueset.py --loinc-code "72166-2"
python scripts/query_valueset.py --loinc-code "72166-2" --format fhir
python scripts/query_valueset.py --search "smoking"

Alternative servers (if tx.fhir.org fails):

  • --server https://hapi.fhir.org/baseR4
  • --server https://r4.ontoserver.csiro.au/fhir

validate_questionnaire.py - Validate Structure

python scripts/validate_questionnaire.py questionnaire.json
python scripts/validate_questionnaire.py questionnaire.json --verbose

extract_loinc_codes.py - Analyze Codes

python scripts/extract_loinc_codes.py questionnaire.json
python scripts/extract_loinc_codes.py questionnaire.json --validate

create_custom_codesystem.py - Reusable Custom Codes (Opt-in)

python scripts/create_custom_codesystem.py --interactive

Only use when the user explicitly requests reusable codes across questionnaires. Uses the Welshare namespace: http://codes.welshare.app. Default for custom answers is inline answerOption without a coding system.

Troubleshooting

  • No LOINC results: Use broader search terms (e.g., "depression" not "PHQ-9 question 1")
  • Network errors: Try alternative servers with --server flag
  • Validation errors: Check references/fhir_questionnaire_spec.md for requirements
  • No answer list found: Use inline answerOption with system-less valueCoding (code + display only). Do NOT fall back to a custom coding system unless the user explicitly requests it

Deep Knowledge References

We've assembled deep knowledge for you to consult on specific topics. Checkout the index file on See REFERENCE.md and drill down the knowledge path for highly detailed instructions on modelling questionnaires.

Reference Links

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

标签

fhirloincsnomed-ctclinical-terminologyhealthcare-interoperabilitymedical-codingquestionnaireehrhl7clinical-dataapi-integration

同类 Skill