Date Calculator
Calculates medical date windows.
Features
- - Gestational age
- Follow-up windows
- Visit scheduling
- Date adjustments
Parameters
| Parameter | Type | Default | Required | Description |
|---|
| INLINECODE0 , INLINECODE1 | string | - | Yes | Calculation type (gestational or followup) |
| INLINECODE2 , INLINECODE3 |
string | - | Yes | Date in YYYY-MM-DD format |
|
--weeks | int | 4 | No | Number of weeks for follow-up |
|
--window-days | int | 7 | No | Follow-up window size in days |
|
--output,
-o | string | - | No | Output JSON file path |
Usage
CODEBLOCK0
Output Format
Gestational calculation:
CODEBLOCK1
Follow-up calculation:
CODEBLOCK2
Risk Assessment
| Risk Indicator | Assessment | Level |
|---|
| Code Execution | Python/R scripts executed locally | Medium |
| Network Access |
No external API calls | Low |
| File System Access | Read input files, write output files | Medium |
| Instruction Tampering | Standard prompt guidelines | Low |
| Data Exposure | Output files saved to workspace | Low |
Security Checklist
- - [ ] No hardcoded credentials or API keys
- [ ] No unauthorized file system access (../)
- [ ] Output does not expose sensitive information
- [ ] Prompt injection protections in place
- [ ] Input file paths validated (no ../ traversal)
- [ ] Output directory restricted to workspace
- [ ] Script execution in sandboxed environment
- [ ] Error messages sanitized (no stack traces exposed)
- [ ] Dependencies audited
Prerequisites
No additional Python packages required.
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
日期计算器
计算医疗日期窗口。
功能特性
参数说明
| 参数 | 类型 | 默认值 | 必填 | 描述 |
|---|
| --type, -t | string | - | 是 | 计算类型(gestational 或 followup) |
| --date, -d |
string | - | 是 | 日期,格式为 YYYY-MM-DD |
| --weeks | int | 4 | 否 | 随访周数 |
| --window-days | int | 7 | 否 | 随访窗口天数 |
| --output, -o | string | - | 否 | 输出 JSON 文件路径 |
使用方法
bash
计算孕周
python scripts/main.py --type gestational --date 2024-01-15
计算4周随访窗口
python scripts/main.py --type followup --date 2024-03-01
计算自定义随访(6周)
python scripts/main.py --type followup --date 2024-03-01 --weeks 6
输出格式
孕周计算:
json
{
lmp_date: 2024-01-15,
gestational_age: 12周3天,
gestationalagedays: 87,
estimateddeliverydate: 2024-10-21,
calculation_date: 2024-04-12
}
随访计算:
json
{
start_date: 2024-03-01,
followup_weeks: 4,
window_start: 2024-03-29,
window_end: 2024-04-05,
window_range: 2024-03-29 至 2024-04-05
}
风险评估
| 风险指标 | 评估 | 等级 |
|---|
| 代码执行 | Python/R 脚本在本地执行 | 中 |
| 网络访问 |
无外部 API 调用 | 低 |
| 文件系统访问 | 读取输入文件,写入输出文件 | 中 |
| 指令篡改 | 标准提示词指南 | 低 |
| 数据泄露 | 输出文件保存至工作区 | 低 |
安全检查清单
- - [ ] 无硬编码凭据或 API 密钥
- [ ] 无未经授权的文件系统访问(../)
- [ ] 输出不暴露敏感信息
- [ ] 已实施提示注入防护
- [ ] 输入文件路径已验证(无 ../ 遍历)
- [ ] 输出目录限制在工作区
- [ ] 脚本在沙盒环境中执行
- [ ] 错误信息已清理(不暴露堆栈跟踪)
- [ ] 依赖项已审计
前置条件
无需额外 Python 包。
评估标准
成功指标
- - [ ] 成功执行主要功能
- [ ] 输出符合质量标准
- [ ] 优雅处理边界情况
- [ ] 性能可接受
测试用例
- 1. 基本功能:标准输入 → 预期输出
- 边界情况:无效输入 → 优雅错误处理
- 性能:大数据集 → 可接受的处理时间
生命周期状态
- - 当前阶段:草稿
- 下次审核日期:2026-03-06
- 已知问题:无
- 计划改进:
- 性能优化
- 新增功能支持