Digital Twin Patient Builder (ID: 208)
Function Overview
Build a "digital twin" model of a patient, integrating genotype, clinical history, and imaging data to test the efficacy and toxicity of different drug doses in a virtual environment.
Use Cases
- - Personalized drug treatment plan design
- Drug dose optimization
- Adverse reaction risk assessment
- Clinical trial virtual simulation
Input
| Data Type | Description | Format |
|---|
| INLINECODE0 | Patient genotype data (SNPs, CNVs) | JSON |
| INLINECODE1 |
Clinical history and laboratory indicators | JSON |
|
imaging_features | Imaging features (MRI, CT, etc.) | JSON |
Output
| Output Type | Description |
|---|
| INLINECODE3 | Efficacy prediction results |
| INLINECODE4 |
Toxicity reaction prediction |
|
optimal_dose | Optimal dose recommendation |
Usage
Command Line Usage
CODEBLOCK0
Parameters
| Parameter | Type | Default | Required | Description |
|---|
| INLINECODE6 | string | - | Yes | Path to patient data JSON file |
| INLINECODE7 |
string | - | Yes | Path to drug profile JSON file |
|
--doses | string | - | Yes | Dose range to test (JSON array format) |
|
--output,
-o | string | - | No | Output file path for simulation results |
|
--simulation-days | int | 30 | No | Number of days to simulate |
|
--timestep | float | 0.5 | No | Simulation timestep in days |
Python API
CODEBLOCK1
Technical Architecture
CODEBLOCK2
Dependencies
- - numpy >= 1.21.0
- scipy >= 1.7.0
- pandas >= 1.3.0
Example Data Format
Patient Data (patient_data.json)
CODEBLOCK3
Drug Profile (drug_profile.json)
CODEBLOCK4
Model Principles
- 1. Genotype Modeling: Parse drug metabolizing enzyme genotypes to predict metabolic phenotypes (ultrarapid/normal/poor metabolizer)
- Physiological Modeling: Calculate personalized pharmacokinetic parameters based on age, weight, and organ function
- Imaging Modeling: Extract tumor features to predict drug responsiveness
- Integrated Model: Multi-modal data fusion to build a comprehensive digital twin
- Drug Simulation: PBPK (physiologically-based pharmacokinetics) + PD (pharmacodynamics) model
References
- - PBPK modeling guidelines (FDA, 2018)
- Pharmacogenomics in precision medicine (Nature Reviews, 2020)
Risk Assessment
| Risk Indicator | Assessment | Level |
|---|
| Code Execution | Python scripts with tools | High |
| Network Access |
External API calls | High |
| File System Access | Read/write data | Medium |
| Instruction Tampering | Standard prompt guidelines | Low |
| Data Exposure | Data handled securely | Medium |
Security Checklist
- - [ ] No hardcoded credentials or API keys
- [ ] No unauthorized file system access (../)
- [ ] Output does not expose sensitive information
- [ ] Prompt injection protections in place
- [ ] API requests use HTTPS only
- [ ] Input validated against allowed patterns
- [ ] API timeout and retry mechanisms implemented
- [ ] Output directory restricted to workspace
- [ ] Script execution in sandboxed environment
- [ ] Error messages sanitized (no internal paths exposed)
- [ ] Dependencies audited
- [ ] No exposure of internal service architecture
Prerequisites
CODEBLOCK5
Evaluation Criteria
Success Metrics
- - [ ] Successfully executes main functionality
- [ ] Output meets quality standards
- [ ] Handles edge cases gracefully
- [ ] Performance is acceptable
Test Cases
- 1. Basic Functionality: Standard input → Expected output
- Edge Case: Invalid input → Graceful error handling
- Performance: Large dataset → Acceptable processing time
Lifecycle Status
- - Current Stage: Draft
- Next Review Date: 2026-03-06
- Known Issues: None
- Planned Improvements:
- Performance optimization
- Additional feature support
数字孪生患者构建器 (ID: 208)
功能概述
构建患者的数字孪生模型,整合基因型、临床病史和影像数据,在虚拟环境中测试不同药物剂量的疗效和毒性。
应用场景
- - 个性化药物治疗方案设计
- 药物剂量优化
- 不良反应风险评估
- 临床试验虚拟仿真
输入
| 数据类型 | 描述 | 格式 |
|---|
| genotype | 患者基因型数据(SNPs、CNVs) | JSON |
| clinical_history |
临床病史和实验室指标 | JSON |
| imaging_features | 影像特征(MRI、CT等) | JSON |
输出
| 输出类型 | 描述 |
|---|
| efficacyprediction | 疗效预测结果 |
| toxicityprediction |
毒性反应预测 |
| optimal_dose | 最佳剂量推荐 |
使用方法
命令行使用
bash
python scripts/main.py --patient patientdata.json --drug drugprofile.json --doses [50, 100, 150]
参数
| 参数 | 类型 | 默认值 | 必需 | 描述 |
|---|
| --patient | 字符串 | - | 是 | 患者数据JSON文件路径 |
| --drug |
字符串 | - | 是 | 药物配置文件JSON文件路径 |
| --doses | 字符串 | - | 是 | 待测试剂量范围(JSON数组格式) |
| --output, -o | 字符串 | - | 否 | 模拟结果输出文件路径 |
| --simulation-days | 整数 | 30 | 否 | 模拟天数 |
| --timestep | 浮点数 | 0.5 | 否 | 模拟时间步长(天) |
Python API
python
from scripts.main import DigitalTwinBuilder
builder = DigitalTwinBuilder()
twin = builder.buildtwin(patientdata)
results = twin.simulatedrugregimen(drugprofile, doserange)
技术架构
digital-twin-patient-builder/
├── SKILL.md # 本文件
├── scripts/
│ └── main.py # 核心实现
│
├── 核心组件:
│ ├── PatientProfile # 患者档案管理
│ ├── GenotypeModel # 基因型建模
│ ├── ClinicalModel # 临床数据建模
│ ├── ImagingModel # 影像特征建模
│ ├── DigitalTwin # 数字孪生主类
│ ├── PharmacokineticModel # 药代动力学模型
│ └── DrugSimulator # 药物模拟器
依赖项
- - numpy >= 1.21.0
- scipy >= 1.7.0
- pandas >= 1.3.0
示例数据格式
患者数据 (patient_data.json)
json
{
patient_id: P001,
genotype: {
CYP2D6:
1/4,
TPMT:
1/3C,
SNPs: {rs12345: AG, rs67890: CC}
},
clinical: {
age: 58,
weight: 70.5,
height: 170,
lab_values: {creatinine: 1.2, alt: 45, ast: 38},
comorbidities: [hypertension, diabetes]
},
imaging: {
tumor_volume: 45.2,
perfusion_rate: 0.85,
texture_features: {entropy: 5.2, uniformity: 0.45}
}
}
药物配置文件 (drug_profile.json)
json
{
drug_name: ExampleDrug,
drug_class: chemotherapy,
metabolizing_enzymes: [CYP2D6, CYP3A4],
target_genes: [EGFR, KRAS],
pk_params: {
clearance: 15.5,
volume_distribution: 45.0,
half_life: 8.0
},
efficacy
biomarkers: [tumorreduction, survival_rate],
toxicity_markers: [neutropenia, hepatotoxicity]
}
模型原理
- 1. 基因型建模:解析药物代谢酶基因型以预测代谢表型(超快代谢/正常代谢/慢代谢)
- 生理建模:基于年龄、体重和器官功能计算个性化药代动力学参数
- 影像建模:提取肿瘤特征以预测药物反应性
- 集成模型:多模态数据融合构建综合数字孪生
- 药物模拟:PBPK(基于生理的药代动力学)+ PD(药效学)模型
参考文献
- - PBPK建模指南(FDA,2018)
- 精准医学中的药物基因组学(Nature Reviews,2020)
风险评估
| 风险指标 | 评估 | 等级 |
|---|
| 代码执行 | 带工具的Python脚本 | 高 |
| 网络访问 |
外部API调用 | 高 |
| 文件系统访问 | 读写数据 | 中 |
| 指令篡改 | 标准提示指南 | 低 |
| 数据泄露 | 安全处理数据 | 中 |
安全检查清单
- - [ ] 无硬编码的凭据或API密钥
- [ ] 无未经授权的文件系统访问(../)
- [ ] 输出不暴露敏感信息
- [ ] 已实施提示注入防护
- [ ] API请求仅使用HTTPS
- [ ] 输入已根据允许模式进行验证
- [ ] 已实现API超时和重试机制
- [ ] 输出目录限制在工作空间内
- [ ] 在沙盒环境中执行脚本
- [ ] 错误消息已清理(不暴露内部路径)
- [ ] 已审计依赖项
- [ ] 不暴露内部服务架构
前置条件
bash
Python依赖项
pip install -r requirements.txt
评估标准
成功指标
- - [ ] 成功执行主要功能
- [ ] 输出符合质量标准
- [ ] 优雅处理边界情况
- [ ] 性能可接受
测试用例
- 1. 基本功能:标准输入 → 预期输出
- 边界情况:无效输入 → 优雅的错误处理
- 性能:大数据集 → 可接受的处理时间
生命周期状态
- - 当前阶段:草稿
- 下次审核日期:2026-03-06
- 已知问题:无
- 计划改进:
- 性能优化
- 额外功能支持