可用于患者管理PDF医学报告,支持OCR文本提取和AI分析。基于FastAPI开发,包含用户管理、报告上传存储、OCR提取、AI数据分析及报告查询管理功能。【此简介由AI生成】
Access rate limit exceeded. Please log in to continue.
Report Manager 002
一个用于患者管理PDF医学报告的Python API项目,支持OCR文本提取和AI分析功能。
项目介绍
Report Manager 002是一个基于FastAPI框架开发的医学报告管理系统,主要功能包括:
- 用户管理(注册、登录、CRUD操作)
- PDF医学报告上传和存储
- OCR文本提取
- AI医学数据分析
- 医学报告查询和管理
技术栈
- 框架: FastAPI
- 数据库: PostgreSQL 16
- 文件存储: MinIO
- OCR: PyPDF2 + pytesseract
- AI分析: Silicon Flow API
- ORM: SQLAlchemy
- API文档: Swagger UI
主要功能
1. 用户管理
- 用户注册和登录
- 用户信息管理
- 权限控制
2. 医学报告管理
- PDF报告上传
- 报告查询和检索
- 报告详情查看
- 报告删除
3. OCR文本提取
- 从PDF中提取文本内容
- 支持扫描版PDF
- 支持多页PDF
4. AI医学数据分析
从医学报告中提取以下数据项:
- D4Z4 重复数
- 甲基化值
- 前锯肌脂肪化等级
- 三角肌、肱二头肌、肱三头肌、肱四头肌的肌力评估
- 肝功能、肌酸激酶
- 楼梯测试结果
安装和运行
1. 克隆仓库
git clone https://gitcode.com/guotiecheng/report_manager_002.git
cd report_manager_002
2. 安装依赖
pip install -r requirements.txt
3. 配置环境
创建.env文件,配置数据库和MinIO连接信息:
# 数据库配置
DATABASE_URL=postgresql://postgres:postgres@192.168.56.102:5432/report_manager
# MinIO配置
MINIO_ENDPOINT=192.168.56.1:9000
MINIO_ACCESS_KEY=minioadmin
MINIO_SECRET_KEY=minioadmin12345678
MINIO_BUCKET_NAME=medical-reports
MINIO_USE_HTTPS=false
# AI API配置
AI_API_KEY=sk-nuunkglayranyngxncwtrrgqmyqeswvantrwahdgtclmzukr
AI_API_URL=https://api.siliconflow.cn/v1/chat/completions
4. 初始化数据库
# 使用SQL脚本初始化数据库
psql -h 192.168.56.102 -U postgres -f db_init_script.sql
# 或使用Python脚本初始化
python init_db.py
5. 初始化MinIO
python minio_init_script.py
6. 启动应用
python -m uvicorn main:app --reload --port 8000
应用将在 http://127.0.0.1:8000 运行
API文档
启动应用后,访问以下地址查看完整的API文档:
http://127.0.0.1:8000/swagger
主要API端点
用户管理
POST /api/users/- 创建用户POST /api/users/login/- 用户登录GET /api/users/- 获取所有用户GET /api/users/{user_id}- 获取用户详情PUT /api/users/{user_id}- 更新用户信息DELETE /api/users/{user_id}- 删除用户
医学报告管理
POST /api/reports/- 上传医学报告POST /api/reports/upload-and-analyze- 上传并分析医学报告(集成OCR和AI分析)GET /api/reports/- 获取所有报告GET /api/reports/{report_id}- 获取报告详情GET /api/reports/user/{user_id}- 获取用户的所有报告PUT /api/reports/{report_id}- 更新报告信息DELETE /api/reports/{report_id}- 删除报告GET /api/reports/{report_id}/file- 获取报告文件URL
使用示例
1. 用户注册
curl -X POST "http://127.0.0.1:8000/api/users/" -H "accept: application/json" -H "Content-Type: application/json" -d '{"username":"test_user","password":"test_password","email":"test@example.com","full_name":"Test User"}'
2. 上传并分析医学报告
curl -X POST "http://127.0.0.1:8000/api/reports/upload-and-analyze" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "file=@path/to/your/report.pdf" -F "report_name=Test Report" -F "user_id=1"
3. 获取用户报告列表
curl -X GET "http://127.0.0.1:8000/api/reports/user/1" -H "accept: application/json"
项目结构
report_manager_002/
├── app/
│ ├── dependencies/ # 依赖注入
│ ├── models/ # 数据库模型
│ ├── routes/ # API路由
│ └── services/ # 业务逻辑层
├── config.py # 配置文件
├── main.py # 应用入口
├── requirements.txt # 依赖列表
├── init_db.py # 数据库初始化脚本
├── db_init_script.sql # PostgreSQL SQL脚本
├── minio_init_script.py # MinIO初始化脚本
└── README.md # 项目文档
配置说明
数据库配置
在config.py中配置PostgreSQL连接:
SQLALCHEMY_DATABASE_URI = 'postgresql://postgres:postgres@192.168.56.102:5432/report_manager'
MinIO配置
在config.py中配置MinIO连接:
MINIO_ENDPOINT = '192.168.56.1:9000'
MINIO_ACCESS_KEY = 'minioadmin'
MINIO_SECRET_KEY = 'minioadmin12345678'
MINIO_BUCKET_NAME = 'medical-reports'
MINIO_USE_HTTPS = False
AI API配置
在config.py中配置Silicon Flow API:
AI_API_KEY = 'your_api_key'
AI_API_URL = 'https://api.siliconflow.cn/v1/chat/completions'
开发和贡献
安装开发依赖
pip install -r requirements.txt
运行测试
pytest
代码风格检查
black .
flake8
许可证
MIT License
联系方式
如有问题或建议,请联系:
- 邮箱: seanguo_007@163.com
- GitCode: https://gitcode.com/guotiecheng
更新日志
v1.0.0 (2026-01-19)
- 初始版本发布
- 实现用户管理功能
- 实现医学报告上传和管理
- 实现OCR文本提取
- 实现AI医学数据分析
- 集成Swagger API文档
Introduction
可用于患者管理PDF医学报告,支持OCR文本提取和AI分析。基于FastAPI开发,包含用户管理、报告上传存储、OCR提取、AI数据分析及报告查询管理功能。【此简介由AI生成】
Customize your domain