# EMR管理模块与门诊/住院病历打通 Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use compose:subagent (recommended) or compose:execute to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** 打通电子病历管理(归档/修订/时效/检索/完整性检查)与门诊医生工作站、住院医生工作站的数据流,实现自动触发和关联查看。
**Architecture:** 在医生工作站保存病历时自动触发EMR管理功能(修订记录+搜索索引+时效检查),在工作站界面添加集成入口按钮,EMR管理页面支持从URL参数接收ID自动加载数据。
**Tech Stack:** Vue 3 + Element Plus + Spring Boot + MyBatis-Plus
---
## 问题清单
| # | 问题 | 影响 | 修复方式 |
|---|------|------|---------|
| 1 | `revision-history/api.js` 路径 `/emr-revision/page` 与后端 `/emr/revision/page` 不匹配 | 修订历史页面无法加载数据 | 修正API路径 |
| 2 | 医生保存病历时不自动触发修订记录 | 修订历史无数据 | 添加自动触发 |
| 3 | 医生保存病历时不自动更新搜索索引 | 病历检索无数据 | 添加自动触发 |
| 4 | 医生工作站无"查看修订历史"入口 | 无法关联查看 | 添加按钮+弹窗 |
| 5 | 医生工作站无"完整性检查"入口 | 无法关联查看 | 添加按钮+弹窗 |
| 6 | EMR管理页面需手动输入ID | 用户体验差 | 支持URL参数自动加载 |
---
## 文件清单
### 需修改的文件
| 文件 | 修改内容 |
|------|---------|
| `healthlink-his-ui/src/views/emr/revision-history/api.js` | 修正API路径 |
| `healthlink-his-server/.../emr/controller/EmrRevisionController.java` | 确认路径一致 |
| `healthlink-his-server/.../emr/controller/EmrSearchController.java` | 确认路径一致 |
| `healthlink-his-server/.../doctorstation/appservice/impl/DoctorStationEmrAppServiceImpl.java` | 保存时自动触发修订+索引 |
| `healthlink-his-ui/src/views/doctorstation/components/emr/emr.vue` | 添加集成入口按钮 |
| `healthlink-his-ui/src/views/emr/revision-history/index.vue` | 支持URL参数 |
| `healthlink-his-ui/src/views/emr/archive/index.vue` | 支持URL参数 |
| `healthlink-his-ui/src/views/emr/timeliness/index.vue` | 支持URL参数 |
| `healthlink-his-ui/src/views/emr/completeness-check/index.vue` | 支持URL参数 |
| `healthlink-his-ui/src/views/emrsearch/index.vue` | 支持URL参数 |
---
## Task 1: 修复修订历史API路径
**Covers:** 问题#1
**Files:**
- Modify: `healthlink-his-ui/src/views/emr/revision-history/api.js`
- [ ] **Step 1: 读取当前文件确认问题**
```javascript
// 当前错误路径
export function getRevisionPage(p){return request({url:'/emr-revision/page',method:'get',params:p})}
export function getRevisionList(p){return request({url:'/emr-revision/list',method:'get',params:p})}
export function recordRevision(d){return request({url:'/emr-revision/record',method:'post',data:d})}
export function compareRevisions(id1,id2){return request({url:'/emr-revision/compare',method:'get',params:{revisionId1:id1,revisionId2:id2}})}
```
- [ ] **Step 2: 修正API路径**
```javascript
import request from '@/utils/request'
export function getRevisionPage(p){return request({url:'/emr/revision/page',method:'get',params:p})}
export function getRevisionList(emrId){return request({url:'/emr/revision/list/'+emrId,method:'get'})}
export function recordRevision(d){return request({url:'/emr/revision/record',method:'post',data:d})}
export function compareRevisions(id1,id2){return request({url:'/emr/revision/compare',method:'get',params:{revisionId1:id1,revisionId2:id2}})}
```
- [ ] **Step 3: 验证后端路径一致**
确认 `EmrRevisionController.java` 中:
- `@RequestMapping("/emr/revision")` ✅
- `@GetMapping("/page")` → `/emr/revision/page` ✅
- `@GetMapping("/list/{emrId}")` → `/emr/revision/list/{emrId}` ✅
- `@PostMapping("/record")` → `/emr/revision/record` ✅
- `@GetMapping("/compare")` → `/emr/revision/compare` ✅
- [ ] **Step 4: Commit**
```bash
git add healthlink-his-ui/src/views/emr/revision-history/api.js
git commit -m "fix(emr): 修正修订历史API路径与后端对齐"
```
---
## Task 2: EMR管理页面支持URL参数自动加载
**Covers:** 问题#6
**Files:**
- Modify: `healthlink-his-ui/src/views/emr/revision-history/index.vue`
- Modify: `healthlink-his-ui/src/views/emr/archive/index.vue`
- Modify: `healthlink-his-ui/src/views/emr/timeliness/index.vue`
- Modify: `healthlink-his-ui/src/views/emr/completeness-check/index.vue`
- Modify: `healthlink-his-ui/src/views/emrsearch/index.vue`
- [ ] **Step 1: 修改 revision-history/index.vue 支持URL参数**
在 `
```
- [ ] **Step 3: 验证编译**
```bash
cd healthlink-his-ui && npm run build:dev
```
- [ ] **Step 4: Commit**
```bash
git add healthlink-his-ui/src/views/doctorstation/components/emr/emr.vue
git commit -m "feat(emr): 医生工作站添加修订历史/归档/完整性检查入口"
```
---
## Task 4: 住院医生工作站添加EMR集成入口
**Covers:** 问题#4, #5
**Files:**
- Modify: `healthlink-his-ui/src/views/inpatientDoctor/home/emr/index.vue`
- [ ] **Step 1: 读取住院EMR页面确认结构**
- [ ] **Step 2: 添加集成按钮**
```vue
修订历史
时效监控
完整性检查
```
- [ ] **Step 3: 验证编译**
```bash
cd healthlink-his-ui && npm run build:dev
```
- [ ] **Step 4: Commit**
```bash
git add healthlink-his-ui/src/views/inpatientDoctor/home/emr/index.vue
git commit -m "feat(emr): 住院医生工作站添加修订历史/时效/完整性检查入口"
```
---
## Task 5: 保存病历时自动触发修订记录
**Covers:** 问题#2
**Files:**
- Modify: `healthlink-his-server/.../doctorstation/appservice/impl/DoctorStationEmrAppServiceImpl.java`
- [ ] **Step 1: 读取现有保存逻辑**
找到 `saveEmr` 或类似方法,确认保存流程。
- [ ] **Step 2: 添加自动触发修订记录**
在保存EMR成功后添加:
```java
@Resource
private IEmrRevisionService emrRevisionService;
// 在saveEmr方法中,保存成功后添加:
// 自动记录修订历史
EmrRevision revision = new EmrRevision();
revision.setEmrId(savedEmr.getId());
revision.setEncounterId(savedEmr.getEncounterId());
revision.setOperatorName(operatorName); // 从SecurityUtils获取
revision.setOperationType("SAVE");
revision.setSnapshotContent(savedEmr.getContextJson());
revision.setCreateTime(new Date());
emrRevisionService.save(revision);
```
- [ ] **Step 3: 验证编译**
```bash
mvn clean compile -DskipTests -pl healthlink-his-application
```
- [ ] **Step 4: Commit**
```bash
git add healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/doctorstation/appservice/impl/DoctorStationEmrAppServiceImpl.java
git commit -m "feat(emr): 保存病历时自动创建修订记录"
```
---
## Task 6: 保存病历时自动更新搜索索引
**Covers:** 问题#3
**Files:**
- Modify: `healthlink-his-server/.../doctorstation/appservice/impl/DoctorStationEmrAppServiceImpl.java`
- [ ] **Step 1: 添加搜索索引服务注入**
```java
@Resource
private IEmrSearchIndexService emrSearchIndexService;
```
- [ ] **Step 2: 保存成功后自动更新索引**
```java
// 在saveEmr方法中,保存成功后添加:
// 自动更新搜索索引
EmrSearchIndex searchIndex = new EmrSearchIndex();
searchIndex.setEmrId(savedEmr.getId());
searchIndex.setEncounterId(savedEmr.getEncounterId());
searchIndex.setPatientName(patientName);
searchIndex.setEmrType(emrType);
searchIndex.setEmrTitle(title);
searchIndex.setDiagnosisText(diagnosis);
searchIndex.setDoctorName(doctorName);
searchIndex.setDepartmentName(departmentName);
searchIndex.setCreateTime(new Date());
// 检查是否已存在索引
LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
wrapper.eq(EmrSearchIndex::getEmrId, savedEmr.getId());
EmrSearchIndex existing = emrSearchIndexService.getOne(wrapper);
if (existing != null) {
existing.setPatientName(patientName);
existing.setEmrType(emrType);
existing.setEmrTitle(title);
existing.setDiagnosisText(diagnosis);
existing.setDoctorName(doctorName);
existing.setDepartmentName(departmentName);
existing.setUpdateTime(new Date());
emrSearchIndexService.updateById(existing);
} else {
emrSearchIndexService.save(searchIndex);
}
```
- [ ] **Step 3: 验证编译**
```bash
mvn clean compile -DskipTests -pl healthlink-his-application
```
- [ ] **Step 4: Commit**
```bash
git add healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/doctorstation/appservice/impl/DoctorStationEmrAppServiceImpl.java
git commit -m "feat(emr): 保存病历时自动更新搜索索引"
```
---
## Task 7: 全量验证
**Covers:** 全部问题
- [ ] **Step 1: 后端编译验证**
```bash
mvn clean compile -DskipTests
```
Expected: BUILD SUCCESS
- [ ] **Step 2: 前端编译验证**
```bash
cd healthlink-his-ui && npm run build:dev
```
Expected: Build successful
- [ ] **Step 3: 接口测试**
```bash
# 测试修订历史接口
curl http://localhost:18082/emr/revision/page?pageNo=1&pageSize=10
# 测试搜索接口
curl http://localhost:18082/emr-search/search?keyword=test
# 测试归档接口
curl http://localhost:18082/emr-archive/page?pageNo=1&pageSize=10
```
Expected: 返回 `{code:200, data:...}`
- [ ] **Step 4: 提交代码**
```bash
git add -A
git commit -m "feat(emr): 打通EMR管理模块与门诊/住院病历集成"
git push origin develop
```
---
## 验证检查清单
| 检查项 | 验证方式 | 预期结果 |
|--------|---------|---------|
| 修订历史API路径 | 访问 `/emr/revision/page` | 返回数据 |
| URL参数支持 | 访问 `/emr/revision-history?emrId=1` | 自动加载该病历修订记录 |
| 医生工作站入口 | 打开病历详情 | 显示修订历史/归档/完整性检查按钮 |
| 保存自动触发 | 保存病历后查询 `emr_revision` 表 | 有新记录 |
| 搜索索引更新 | 保存病历后查询 `emr_search_index` 表 | 有新记录 |
| 完整性检查 | 点击完整性检查按钮 | 显示检查结果 |
---
> **Plan Version:** v1.0
> **Created:** 2026-06-21
> **Estimated Effort:** 2-3小时