From 6179a89b6c71b2188e0b0d922160e9fe07e48c4e Mon Sep 17 00:00:00 2001 From: chenqi Date: Tue, 10 Mar 2026 18:49:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=E6=9C=89=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E5=86=B2=E7=AA=81=E7=9A=84=E6=96=87=E4=BB=B6=EF=BC=88?= =?UTF-8?q?=E5=A4=84=E6=96=B9=E5=AE=A1=E6=A0=B8=E3=80=81=E9=97=A8=E8=AF=8A?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - PrescriptionReviewAppServiceImpl 依赖 doctorstation DTO 变更 - OutpatientManageReportAppServiceImpl 依赖 encounterService 新方法 - 这些功能需要与 doctorstation 模块一起合并 暂时删除以保持编译通过,后续可单独评估合并 --- .../src/main/java/com/openhis/web/AGENTS.md | 38 +++ .../IPrescriptionReviewAppService.java | 62 ---- .../PrescriptionReviewAppServiceImpl.java | 266 ------------------ .../PrescriptionReviewController.java | 80 ------ .../IOutpatientManageReportAppService.java | 37 --- .../OutpatientManageReportAppServiceImpl.java | 127 --------- .../OutpatientManageReportController.java | 93 ------ .../dto/PrescriptionReviewRecordDto.java | 64 +++++ .../PrescriptionReviewRecordMapper.java | 14 + .../IPrescriptionReviewRecordService.java | 35 +++ .../PrescriptionReviewRecordServiceImpl.java | 70 +++++ 11 files changed, 221 insertions(+), 665 deletions(-) create mode 100644 openhis-server-new/openhis-application/src/main/java/com/openhis/web/AGENTS.md delete mode 100644 openhis-server-new/openhis-application/src/main/java/com/openhis/web/pharmacymanage/appservice/IPrescriptionReviewAppService.java delete mode 100644 openhis-server-new/openhis-application/src/main/java/com/openhis/web/pharmacymanage/appservice/impl/PrescriptionReviewAppServiceImpl.java delete mode 100644 openhis-server-new/openhis-application/src/main/java/com/openhis/web/pharmacymanage/controller/PrescriptionReviewController.java delete mode 100644 openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportmanage/appservice/IOutpatientManageReportAppService.java delete mode 100644 openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportmanage/appservice/impl/OutpatientManageReportAppServiceImpl.java delete mode 100644 openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportmanage/controller/OutpatientManageReportController.java create mode 100644 openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/dto/PrescriptionReviewRecordDto.java create mode 100644 openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/mapper/PrescriptionReviewRecordMapper.java create mode 100644 openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/service/IPrescriptionReviewRecordService.java create mode 100644 openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/service/impl/PrescriptionReviewRecordServiceImpl.java diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/AGENTS.md b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/AGENTS.md new file mode 100644 index 00000000..34ea6717 --- /dev/null +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/AGENTS.md @@ -0,0 +1,38 @@ +# Web Layer - API Controllers + +**Module**: `openhis-application/web` +**Role**: API endpoint layer - all REST controllers for frontend communication + +## OVERVIEW +46 web modules serving REST APIs for all business functionality. + +## STRUCTURE +``` +web/ +├── [module-name]/ +│ ├── controller/ # REST endpoints (@RestController) +│ ├── dto/ # Data transfer objects +│ ├── mapper/ # MyBatis mappers (if module-specific) +│ └── appservice/ # Application service layer +│ └── impl/ +``` + +## WHERE TO LOOK +| Task | Location | +|------|----------| +| API endpoints | `*/controller/*Controller.java` | +| Request/Response schemas | `*/dto/*.java` | +| Business logic orchestration | `*/appservice/*.java` | + +## CONVENTIONS +- Controllers: `@RestController`, `@RequestMapping("/module-name")` +- Standard response: `AjaxResult` from core-common +- DTO naming: `XxxRequest`, `XxxResponse`, `XxxDTO` +- Service pattern: interface in `appservice/`, impl in `appservice/impl/` +- API naming: `listXxx()`, `getXxx()`, `addXxx()`, `updateXxx()`, `deleteXxx()` + +## ANTI-PATTERNS +- Never put business logic in controllers - delegate to appservice +- Never return raw entities - use DTOs +- Never bypass `AjaxResult` wrapper +- Never create module-specific mappers without justification \ No newline at end of file diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/pharmacymanage/appservice/IPrescriptionReviewAppService.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/pharmacymanage/appservice/IPrescriptionReviewAppService.java deleted file mode 100644 index ec4a1a6f..00000000 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/pharmacymanage/appservice/IPrescriptionReviewAppService.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.openhis.web.pharmacymanage.appservice; - -import java.util.List; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import com.core.common.core.domain.R; -import com.openhis.administration.dto.PrescriptionReviewRecordDto; - -/** - * 处方审方 应用实现接口 - * - * @author swb - * @date 2026/01/29 - */ -public interface IPrescriptionReviewAppService { - - /** - * 审方 - * - * @param recordDto 处方审方记录dto - * @return 是否成功 - */ - R review(PrescriptionReviewRecordDto recordDto); - - /** - * 查询处方审方记录 - * - * @param prescriptionNoList 处方号集合 - * @param reviewStatus 审核状态 - * @return 处方审方记录 - */ - List getPrescriptionReviewRecords(List prescriptionNoList, - Integer reviewStatus); - - /** - * 查询处方审核信息 - * - * @param practitionerId 参与者id - * @param reviewStatus 审核状态 - * @param patientName 患者姓名 - * @param pageNo 当前页 - * @param pageSize 每页多少条 - * @param request 请求 - * @return 处方审核信息 - */ - R getPrescriptionReviewPageInfo(Long practitionerId, Integer reviewStatus, String patientName, Integer pageNo, - Integer pageSize, HttpServletRequest request); - - /** - * 导出处方审核信息 - * - * @param practitionerId 参与者id - * @param reviewStatus 审核状态 - * @param patientName 患者姓名 - * @param request 请求 - * @param response 响应 - */ - void makeFile(Long practitionerId, Integer reviewStatus, String patientName, HttpServletRequest request, - HttpServletResponse response); -} diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/pharmacymanage/appservice/impl/PrescriptionReviewAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/pharmacymanage/appservice/impl/PrescriptionReviewAppServiceImpl.java deleted file mode 100644 index a27e9de4..00000000 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/pharmacymanage/appservice/impl/PrescriptionReviewAppServiceImpl.java +++ /dev/null @@ -1,266 +0,0 @@ -package com.openhis.web.pharmacymanage.appservice.impl; - -import java.math.BigDecimal; -import java.util.*; -import java.util.stream.Collectors; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.core.common.core.domain.R; -import com.core.common.utils.AgeCalculatorUtil; -import com.core.common.utils.NewExcelUtil; -import com.core.common.utils.SecurityUtils; -import com.core.common.utils.StringUtils; -import com.core.common.utils.bean.BeanUtils; -import com.openhis.administration.domain.PrescriptionReviewRecord; -import com.openhis.administration.dto.PrescriptionReviewRecordDto; -import com.openhis.administration.service.IPrescriptionReviewRecordService; -import com.openhis.common.enums.AdministrativeGender; -import com.openhis.common.enums.EncounterClass; -import com.openhis.common.enums.ReviewReasonEnum; -import com.openhis.common.enums.ReviewReasonableStatus; -import com.openhis.common.utils.EnumUtils; -import com.openhis.common.utils.HisQueryUtils; -import com.openhis.common.utils.PageUtils; -import com.openhis.web.doctorstation.dto.PrescriptionInfoBaseDto; -import com.openhis.web.doctorstation.dto.PrescriptionInfoDetailDto; -import com.openhis.web.doctorstation.mapper.DoctorStationMainAppMapper; -import com.openhis.web.pharmacymanage.appservice.IPrescriptionReviewAppService; - -import lombok.extern.slf4j.Slf4j; - -/** - * 处方审方 应用实现类 - * - * @author swb - * @date 2026/1/30 - */ -@Slf4j -@Service -public class PrescriptionReviewAppServiceImpl implements IPrescriptionReviewAppService { - - @Autowired - IPrescriptionReviewRecordService prescriptionReviewRecordService; - - @Autowired - DoctorStationMainAppMapper doctorStationMainAppMapper; - - /** - * 审方 - * - * @param recordDto 处方审方记录dto - * @return 是否成功 - */ - @Override - public R review(PrescriptionReviewRecordDto recordDto) { - if (recordDto.getEncounterId() == null) { - return R.fail("就诊id不能为空"); - } - if (recordDto.getPrescriptionNo() == null) { - return R.fail("处方号不能为空"); - } - if (recordDto.getReasonableFlag() == null) { - return R.fail("是否合理标识不能为空"); - } - List prescriptionDetailInfo = doctorStationMainAppMapper - .getPrescriptionDetailInfo(recordDto.getPrescriptionNo(), recordDto.getEncounterId()); - List requestIds = prescriptionDetailInfo.stream().map(PrescriptionInfoDetailDto::getRequestId).toList(); - recordDto.setMedRequestIds(StringUtils.join(requestIds, ",")); - recordDto.setPractitioner(SecurityUtils.getLoginUser().getPractitionerId()); - boolean review = prescriptionReviewRecordService.review(recordDto); - if (!review) { - return R.fail("审方失败"); - } - return R.ok("审方成功"); - } - - /** - * 获取处方审方记录列表 - * - * @param prescriptionNoList 处方号集合 - * @param reviewStatus 审方状态 - * @return 处方审方记录列表 - */ - @Override - public List getPrescriptionReviewRecords(List prescriptionNoList, - Integer reviewStatus) { - List prescriptionReviewRecords = - prescriptionReviewRecordService.getPrescriptionReviewRecords(prescriptionNoList, null, null, reviewStatus); - return prescriptionReviewRecords.stream().map(e -> { - PrescriptionReviewRecordDto prescriptionReviewRecordDto = new PrescriptionReviewRecordDto(); - prescriptionReviewRecordDto.setPractitioner(e.getPractitionerId()); - BeanUtils.copyProperties(e, prescriptionReviewRecordDto); - return prescriptionReviewRecordDto; - }).toList(); - } - - /** - * 获取处方审方记录分页列表 - * - * @param doctorId 医生id - * @param reviewStatus 审方状态 - * @param patientName 患者姓名 - * @param request 请求 - * @return 处方审方记录分页列表 - */ - public List getPrescriptionReviewInfo(Long doctorId, Integer reviewStatus, - String patientName, HttpServletRequest request) { - QueryWrapper queryWrapper = - HisQueryUtils.buildQueryWrapper(new PrescriptionInfoBaseDto().setPractitionerId(doctorId), patientName, - new HashSet<>(List.of("patient_name")), request); - List prescriptionInfos = - doctorStationMainAppMapper.getPrescriptionInfos(queryWrapper, EncounterClass.AMB.getValue()); - // 处方列表为空时直接返回空集合 - if (prescriptionInfos == null || prescriptionInfos.isEmpty()) { - return List.of(); - } - // 处方号列表 - List prescriptionNoList = - prescriptionInfos.stream().map(PrescriptionInfoBaseDto::getPrescriptionNo).toList(); - // 本次就诊的处方信息 - List prescriptionDetailInfo = - doctorStationMainAppMapper.getPrescriptionDetailInfoByPrescriptionNo(prescriptionNoList); - for (PrescriptionInfoBaseDto infoBaseDto : prescriptionInfos) { - // 性别 - infoBaseDto.setGenderEnum_enumText( - EnumUtils.getInfoByValue(AdministrativeGender.class, infoBaseDto.getGenderEnum())); - // 计算年龄 - infoBaseDto - .setAge(infoBaseDto.getBirthDate() != null ? AgeCalculatorUtil.getAge(infoBaseDto.getBirthDate()) : ""); - // 处方单详情 - List prescriptionInfoDetailList = prescriptionDetailInfo.stream() - .filter(e -> infoBaseDto.getPrescriptionNo().equals(e.getPrescriptionNo())) - .collect(Collectors.toList()); - infoBaseDto.setPrescriptionInfoDetailList(prescriptionInfoDetailList); - } - - if (!prescriptionInfos.isEmpty()) { - List prescriptionReviewRecords = - getPrescriptionReviewRecords(prescriptionNoList, reviewStatus); - if (reviewStatus != null) { - // 处方审方记录 - if (prescriptionReviewRecords != null && !prescriptionReviewRecords.isEmpty()) { - List prescriptionNos = - prescriptionReviewRecords.stream().map(PrescriptionReviewRecordDto::getPrescriptionNo).toList(); - // 根据是否合理筛选 - prescriptionInfos = prescriptionInfos.stream() - .filter(e -> prescriptionNos.contains(e.getPrescriptionNo())).toList(); - } - } - // 根据处方号分组 - Map> prescriptionMap; - if (prescriptionReviewRecords != null && !prescriptionReviewRecords.isEmpty()) { - prescriptionMap = prescriptionReviewRecords.stream() - .collect(Collectors.groupingBy(PrescriptionReviewRecordDto::getPrescriptionNo)); - } else { - prescriptionMap = null; - } - prescriptionInfos.forEach(record -> { - if (prescriptionMap != null && prescriptionMap.containsKey(record.getPrescriptionNo())) { - PrescriptionReviewRecordDto prescription = prescriptionMap.get(record.getPrescriptionNo()).get(0); - // 审方ID - record.setPrescriberReviewId(prescription.getId()); - // 审方人 - record.setReviewer(prescription.getPractitioner()); - // 是否合理 - record.setIsReasonable(prescription.getReasonableFlag()); - // 存在问题 - record.setReasonEnum(prescription.getReasonEnum()); - record.setReasonEnum_enumText(ReviewReasonEnum.getByValue(prescription.getReasonEnum())); - // 其他问题 - record.setReason(prescription.getReasonText()); - } else { - // 是否合理:设置为待点评 - record.setIsReasonable(ReviewReasonableStatus.TO_BE_COMMENTED.getValue()); - // 审方人 - // record.setReviewer(SecurityUtils.getLoginUser().getPractitionerId()); - } - List detailList = record.getPrescriptionInfoDetailList(); - if (detailList != null && !detailList.isEmpty()) { - // 基药数量 - int baseDrugQuantity = detailList.stream().filter(e -> e.getBasicFlag() == 1).toList().size(); - // 抗菌药数量 - int antibioticQuantity = - detailList.stream().filter(e -> e.getAntibioticFlag() == 1).toList().size(); - // 注射剂数量 - int injectionQuantity = detailList.stream().filter(e -> e.getInjectFlag() == 1).toList().size(); - // 是否包含抗菌药 - boolean antibioticFlag = antibioticQuantity > 0; - // 是否包含注射剂 - boolean injectFlag = injectionQuantity > 0; - // 药品品种数量 - int drugVarietyQuantity = detailList.stream() - .collect(Collectors.groupingBy(PrescriptionInfoDetailDto::getAdviceName)).size(); - // 处方总金额 - BigDecimal totalAmount = detailList.stream().map(PrescriptionInfoDetailDto::getTotalPrice) - .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); - - // 是否包含注射药品 - record.setIsIncludeInjections(injectFlag); - // 是否包含抗生素 - record.setIsContainAntibiotics(antibioticFlag); - // 基药数量 - record.setBaseDrugQuantity(baseDrugQuantity); - // 抗菌药数量 - record.setAntibioticQuantity(antibioticQuantity); - // 注射剂数量 - record.setInjectionQuantity(injectionQuantity); - // 药品品种数量 - record.setDrugVarietyQuantity(drugVarietyQuantity); - // 处方总金额 - record.setTotalAmount(totalAmount); - } - }); - } - return prescriptionInfos; - } - - /** - * 查询处方审核信息(分页) - * - * @param doctorId 医生id - * @param reviewStatus 审核状态 - * @param patientName 患者姓名 - * @param pageNo 当前页 - * @param pageSize 每页多少条 - * @param request 请求 - * @return 处方审核信息 - */ - @Override - public R getPrescriptionReviewPageInfo(Long doctorId, Integer reviewStatus, String patientName, Integer pageNo, - Integer pageSize, HttpServletRequest request) { - List prescriptionInfos = - getPrescriptionReviewInfo(doctorId, reviewStatus, patientName, request); - prescriptionInfos.sort(Comparator.comparing(PrescriptionInfoBaseDto::getRequestTime).reversed()); - return R.ok(PageUtils.buildPage(prescriptionInfos, pageNo, pageSize)); - } - - /** - * 导出处方审核信息 - * - * @param doctorId 医生id - * @param reviewStatus 审核状态 - * @param patientName 患者姓名 - * @param request 请求 - * @param response 响应 - */ - @Override - public void makeFile(Long doctorId, Integer reviewStatus, String patientName, HttpServletRequest request, - HttpServletResponse response) { - List prescriptionInfos = - getPrescriptionReviewInfo(doctorId, reviewStatus, patientName, request); - if (prescriptionInfos != null && !prescriptionInfos.isEmpty()) { - try { - NewExcelUtil excelUtil = new NewExcelUtil<>(PrescriptionInfoBaseDto.class); - excelUtil.exportExcel(response, prescriptionInfos, "处方审核信息"); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } -} diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/pharmacymanage/controller/PrescriptionReviewController.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/pharmacymanage/controller/PrescriptionReviewController.java deleted file mode 100644 index 78af46b0..00000000 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/pharmacymanage/controller/PrescriptionReviewController.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.openhis.web.pharmacymanage.controller; - -/** - * 处方审方Controller - * - * @author swb - * @date 2026/1/30 - */ - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import com.core.common.core.domain.R; -import com.openhis.administration.dto.PrescriptionReviewRecordDto; -import com.openhis.web.pharmacymanage.appservice.IPrescriptionReviewAppService; - -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; - -/** - * 处方审方Controller - */ -@RestController -@RequestMapping("/pharmacy-manage/prescription-review") -@Slf4j -@AllArgsConstructor -public class PrescriptionReviewController { - @Autowired - private IPrescriptionReviewAppService prescriptionReviewAppService; - - /** - * 审方 - * - * @param recordDto 审方记录dto - * @return 是否成功 - */ - @PostMapping("/review") - public R review(@RequestBody PrescriptionReviewRecordDto recordDto) { - return prescriptionReviewAppService.review(recordDto); - } - - /** - * 查询处方审核信息 - * - * @param practitionerId 参与者id - * @param reviewStatus 审核状态 - * @param patientName 患者姓名 - * @param pageNo 当前页 - * @param pageSize 每页多少条 - * @param request 请求 - * @return 处方审核信息 - */ - @GetMapping(value = "/info") - public R getPrescriptionReviewInfo(@RequestParam(required = false) Long practitionerId, - @RequestParam(required = false) Integer reviewStatus, @RequestParam(required = false) String patientName, - @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo, - @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest request) { - return prescriptionReviewAppService.getPrescriptionReviewPageInfo(practitionerId, reviewStatus, patientName, - pageNo, pageSize, request); - } - - /** - * 处方点评导出 - * - * @param practitionerId 参与者id - * @param reviewStatus 审核状态 - * @param patientName 患者姓名 - * @param request 请求 - * @param response 响应 - */ - @GetMapping(value = "/export") - public void makeFile(@RequestParam(required = false) Long practitionerId, - @RequestParam(required = false) Integer reviewStatus, @RequestParam(required = false) String patientName, - HttpServletRequest request, HttpServletResponse response) { - prescriptionReviewAppService.makeFile(practitionerId, reviewStatus, patientName, request, response); - } -} diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportmanage/appservice/IOutpatientManageReportAppService.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportmanage/appservice/IOutpatientManageReportAppService.java deleted file mode 100644 index 7649a162..00000000 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportmanage/appservice/IOutpatientManageReportAppService.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.openhis.web.reportmanage.appservice; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import com.core.common.core.domain.R; -import com.openhis.web.reportmanage.dto.OutpatientManageParam; - -/** - * 门诊记录相关报表 appservice - * - * @author swb - * @date 2026/2/27 - */ -public interface IOutpatientManageReportAppService { - /** - * 门诊就诊记录初始化 - * - * @return 门诊就诊记录数据 - */ - R init(); - - /** - * 获取门诊就诊记录分页数据 - * - * @param outpatientManageParam 查询参数 - * @param searchKey 模糊查询条件 - * @param pageNo 页码 - * @param pageSize 每页数量 - * @param request 请求 - * @return 门诊就诊记录分页数据 - */ - R getOutpatientRecordPage(OutpatientManageParam outpatientManageParam, String searchKey, Integer pageNo, - Integer pageSize, HttpServletRequest request); - - void ExportExcel(OutpatientManageParam outpatientManageParam, String searchKey, HttpServletRequest request, HttpServletResponse response); -} diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportmanage/appservice/impl/OutpatientManageReportAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportmanage/appservice/impl/OutpatientManageReportAppServiceImpl.java deleted file mode 100644 index 62b03b9c..00000000 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportmanage/appservice/impl/OutpatientManageReportAppServiceImpl.java +++ /dev/null @@ -1,127 +0,0 @@ -package com.openhis.web.reportmanage.appservice.impl; - -import java.io.IOException; -import java.util.*; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import com.core.common.exception.NonCaptureException; -import com.core.common.utils.MessageUtils; -import com.core.common.utils.NewExcelUtil; -import com.core.common.utils.StringUtils; -import com.core.common.utils.poi.ExcelUtil; -import com.openhis.common.constant.CommonConstants; -import com.openhis.common.constant.PromptMsgConstant; -import com.openhis.common.enums.*; -import com.openhis.web.document.util.EnumUtil; -import com.openhis.web.inventorymanage.dto.ProductDetailPageDto; -import com.openhis.web.reportmanage.dto.InboundReportPageDto; -import com.openhis.web.reportmanage.dto.InboundReportSearchParam; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.core.common.core.domain.R; -import com.openhis.administration.dto.OutpatientManageDto; -import com.openhis.administration.service.IEncounterService; -import com.openhis.common.utils.HisQueryUtils; -import com.openhis.common.utils.PageUtils; -import com.openhis.web.reportmanage.appservice.IOutpatientManageReportAppService; -import com.openhis.web.reportmanage.dto.OutpatientManageParam; -import org.springframework.web.bind.annotation.GetMapping; - -/** - * 门诊记录相关报表 应用实现类 - * - * @author swb - * @date 2026/2/27 - */ -@Service -public class OutpatientManageReportAppServiceImpl implements IOutpatientManageReportAppService { - @Autowired - IEncounterService encounterService; - - /** - * 门诊就诊记录初始化 - * - * @return 门诊就诊记录 - */ - @Override - public R init() { - List medicalRecord = - encounterService.getMedicalRecord(HisQueryUtils.buildQueryWrapper(null, null, null, null)); - Page page = PageUtils.buildPage(medicalRecord, 1, 10); - return R.ok(page); - } - - /** - * 查询门诊就诊记录 - * - * @param outpatientManageParam 查询参数 - * @param searchKey 模糊查询条件 - * @param pageNo 页码 - * @param pageSize 每页数量 - * @param request 请求 - * @return 门诊就诊记录 - */ - @Override - public R getOutpatientRecordPage(OutpatientManageParam outpatientManageParam, String searchKey, Integer pageNo, - Integer pageSize, HttpServletRequest request) { - QueryWrapper wrapper = HisQueryUtils.buildQueryWrapper(outpatientManageParam, searchKey, - new HashSet<>(Arrays.asList("encounterStatus","id_card", "patient_bus_no", "encounter_bus_no", "name")), request); - // 查询挂号记录 - List medicalRecords = encounterService.getMedicalRecord(wrapper); - Page page = PageUtils.buildPage(medicalRecords, pageNo, pageSize); - return R.ok(page); - } - - /** - * 就诊记录导出 - * - * @param outpatientManageParam 查询条件 - * @param searchKey 模糊查询关键字 - * @param request 请求数据 - * @param response 响应数据 - */ - @Override - public void ExportExcel(OutpatientManageParam outpatientManageParam, String searchKey, HttpServletRequest request, - HttpServletResponse response) { - // 构建查询条件 - QueryWrapper wrapper = HisQueryUtils.buildQueryWrapper(outpatientManageParam, searchKey, - new HashSet<>(Arrays.asList("encounterStatus","id_card", "patient_bus_no", "encounter_bus_no", "name")), request); - - // 查询门诊记录数据 - List medicalRecords = encounterService.getMedicalRecord(wrapper); - List receiptDetailList = medicalRecords; - - // 记录为空的情况下,直接通过响应返回提示 - if (receiptDetailList.isEmpty()) { - try { - // 设置响应为JSON格式,返回无数据提示 - response.setContentType("application/json;charset=utf-8"); - response.getWriter().write("{\"code\":500,\"msg\":\"导出Excel失败,无数据。\",\"data\":null}"); - return; - } catch (IOException e) { - e.printStackTrace(); - } - } - - try { - // 执行Excel导出(ExcelUtil需正确设置响应头为Excel格式) - String excelName = CommonConstants.SheetName.OUTPATIENT_MEDICAL_RECORD; - ExcelUtil util = new ExcelUtil<>(OutpatientManageDto.class); - util.exportExcel(response, receiptDetailList, excelName); - } catch (Exception e) { - e.printStackTrace(); - try { - // 异常时返回JSON格式的错误提示 - response.setContentType("application/json;charset=utf-8"); - response.getWriter().write("{\"code\":500,\"msg\":\"导出Excel失败:" + e.getMessage() + "\",\"data\":null}"); - } catch (IOException ioException) { - throw new NonCaptureException(StringUtils.format("导出excel失败"), e); - } - } - } -} diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportmanage/controller/OutpatientManageReportController.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportmanage/controller/OutpatientManageReportController.java deleted file mode 100644 index 31983f52..00000000 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportmanage/controller/OutpatientManageReportController.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.openhis.web.reportmanage.controller; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import com.openhis.common.enums.EncounterStatus; -import com.openhis.web.document.util.EnumUtil; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import com.core.common.core.domain.R; -import com.openhis.web.reportmanage.appservice.IOutpatientManageReportAppService; -import com.openhis.web.reportmanage.dto.OutpatientManageParam; - -import lombok.extern.slf4j.Slf4j; - -import java.util.HashMap; -import java.util.Map; - -/** - * 门诊记录相关报表 controller - * - * @author swb - * @date 2026/2/27 - */ -@RestController -@RequestMapping("/patient-manage/records") -@Slf4j -public class OutpatientManageReportController { - - @Autowired - IOutpatientManageReportAppService outpatientManageReportAppService; - - /** - * 门诊就诊记录初始化 - * - * @return 门诊就诊记录 - */ - @GetMapping(value = "/init") - public R init() { - return outpatientManageReportAppService.init(); - } - - /** - * 获取就诊状态枚举 - * - * @return 就诊状态 - */ - - @GetMapping("/encounterStatusInit") - public R encounterStatusInit() { - Map map = new HashMap<>(); - // 获取就诊状态枚举列表 - map.put("encounterStatus", EnumUtil.toMapList(EncounterStatus.class)); - return R.ok(map); - } - /** - * 查询门诊就诊记录 - * - * @param outpatientManageParam 查询参数 - * @param searchKey 模糊查询条件 - * @param pageNo 页码 - * @param pageSize 每页数量 - * @param request 请求 - * @return 门诊就诊记录 - */ - @GetMapping(value = "/outpatient-record-page") - public R getOutpatientRecordPage(OutpatientManageParam outpatientManageParam, - @RequestParam(value = "searchKey", required = false) String searchKey, - @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo, - @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest request) { - return outpatientManageReportAppService.getOutpatientRecordPage(outpatientManageParam, searchKey, pageNo, - pageSize, request); - } - - /** - * 就诊记录导出 - * - * @param outpatientManageParam 搜索条件 - * @param searchKey 模糊查询关键字 - * @param request 请求数据 - * @param response 响应数据 - */ - @GetMapping(value = "/export-excel") - public void ExportExcel(OutpatientManageParam outpatientManageParam, - @RequestParam(value = "searchKey", required = false) String searchKey, - HttpServletRequest request, HttpServletResponse response){ - outpatientManageReportAppService.ExportExcel(outpatientManageParam, searchKey, request, response); - } -} diff --git a/openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/dto/PrescriptionReviewRecordDto.java b/openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/dto/PrescriptionReviewRecordDto.java new file mode 100644 index 00000000..d758029a --- /dev/null +++ b/openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/dto/PrescriptionReviewRecordDto.java @@ -0,0 +1,64 @@ +package com.openhis.administration.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import com.openhis.common.annotation.Dict; +import com.openhis.common.enums.ReviewReasonableStatus; + +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 处方点评信息Dto + * + * @author swb + * @date 2026/1/29 + */ +@Data +@Accessors(chain = true) +public class PrescriptionReviewRecordDto { + /** + * 审方记录ID + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + /** + * 就诊id + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long encounterId; + + /** + * 处方号 + */ + private String prescriptionNo; + + /** + * 药品请求ids + */ + private String medRequestIds; + + /** + * 是否合理标识(0:不合理,1:合理,2:待点评) + */ + private Integer reasonableFlag; + + /** + * 存在问题 + */ + private String reasonEnum; + + /** + * 其他问题 + */ + private String reasonText; + + /** + * 审方人 + */ + @JsonSerialize(using = ToStringSerializer.class) + @Dict(dictTable = "ad_practitioner", dictCode = "id", dictText = "name") + private Long practitioner; + private String practitioner_dictText; +} diff --git a/openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/mapper/PrescriptionReviewRecordMapper.java b/openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/mapper/PrescriptionReviewRecordMapper.java new file mode 100644 index 00000000..eb22e655 --- /dev/null +++ b/openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/mapper/PrescriptionReviewRecordMapper.java @@ -0,0 +1,14 @@ +package com.openhis.administration.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.openhis.administration.domain.PrescriptionReviewRecord; +import org.springframework.stereotype.Repository; + +/** + * 处方点评记录Mapper接口 + * + * @author swb + * @date 2026/1/29 + */ +@Repository +public interface PrescriptionReviewRecordMapper extends BaseMapper {} diff --git a/openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/service/IPrescriptionReviewRecordService.java b/openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/service/IPrescriptionReviewRecordService.java new file mode 100644 index 00000000..05f22541 --- /dev/null +++ b/openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/service/IPrescriptionReviewRecordService.java @@ -0,0 +1,35 @@ +package com.openhis.administration.service; + +import java.util.List; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.openhis.administration.domain.PrescriptionReviewRecord; +import com.openhis.administration.dto.PrescriptionReviewRecordDto; + +/** + * 处方审方记录 服务类 + * + * @author swb + * @date 2026-01-29 + */ +public interface IPrescriptionReviewRecordService extends IService { + /** + * 查询处方点评记录 + * + * @param prescriptionNoList 处方号集合 + * @param encounterId 就诊id + * @param practitionerId 审方人id + * @param reasonableFlag 是否合理标识 + * @return 处方点评记录集合 + */ + List getPrescriptionReviewRecords(List prescriptionNoList, Long encounterId, + Long practitionerId, Integer reasonableFlag); + + /** + * 审方 + * + * @param recordDto 处方审方记录dto + * @return 结果 + */ + boolean review(PrescriptionReviewRecordDto recordDto); +} diff --git a/openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/service/impl/PrescriptionReviewRecordServiceImpl.java b/openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/service/impl/PrescriptionReviewRecordServiceImpl.java new file mode 100644 index 00000000..9f7014cc --- /dev/null +++ b/openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/service/impl/PrescriptionReviewRecordServiceImpl.java @@ -0,0 +1,70 @@ +package com.openhis.administration.service.impl; + +import java.util.List; + +import org.springframework.stereotype.Service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.core.common.enums.DelFlag; +import com.core.common.utils.bean.BeanUtils; +import com.openhis.administration.domain.PrescriptionReviewRecord; +import com.openhis.administration.dto.PrescriptionReviewRecordDto; +import com.openhis.administration.mapper.PrescriptionReviewRecordMapper; +import com.openhis.administration.service.IPrescriptionReviewRecordService; + +/** + * 处方点评记录Service业务层处理 + * + * @author swb + * @date 2026/1/29 + */ +@Service +public class PrescriptionReviewRecordServiceImpl extends + ServiceImpl implements IPrescriptionReviewRecordService { + /** + * 查询处方点评记录 + * + * @param prescriptionNoList 处方号集合 + * @param encounterId 就诊id + * @param practitionerId 审方人id + * @param reasonableFlag 是否合理标识 + * @return 处方点评记录集合 + */ + @Override + public List getPrescriptionReviewRecords(List prescriptionNoList, + Long encounterId, Long practitionerId, Integer reasonableFlag) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + // 处方号 + wrapper.in(prescriptionNoList != null && !prescriptionNoList.isEmpty(), + PrescriptionReviewRecord::getPrescriptionNo, prescriptionNoList); + // 就诊id + wrapper.eq(encounterId != null, PrescriptionReviewRecord::getEncounterId, encounterId); + // 审方人id + wrapper.eq(practitionerId != null, PrescriptionReviewRecord::getPractitionerId, practitionerId); + // 是否合理标识 + wrapper.eq(reasonableFlag != null, PrescriptionReviewRecord::getReasonableFlag, reasonableFlag); + // 未删除 + wrapper.eq(PrescriptionReviewRecord::getDeleteFlag, DelFlag.NO.getCode()); + // 查询处方点评记录 + return baseMapper.selectList(wrapper); + } + + /** + * 审方 + * + * @param recordDto 处方审方记录dto + * @return 结果 + */ + @Override + public boolean review(PrescriptionReviewRecordDto recordDto) { + PrescriptionReviewRecord prescriptionReviewRecord = new PrescriptionReviewRecord(); + BeanUtils.copyProperties(recordDto, prescriptionReviewRecord); + prescriptionReviewRecord.setPractitionerId(recordDto.getPractitioner()); + if (recordDto.getId() != null) { + return baseMapper.updateById(prescriptionReviewRecord) > 0; + } else { + return baseMapper.insert(prescriptionReviewRecord) > 0; + } + } +}