|
@@ -1,27 +1,34 @@
|
|
|
package com.zskk.pacsonline.modules.report.controller;
|
|
package com.zskk.pacsonline.modules.report.controller;
|
|
|
|
|
|
|
|
|
|
+import com.zskk.pacsonline.common.result.BaseDto;
|
|
|
import com.zskk.pacsonline.component.aop.SystemLogHandler;
|
|
import com.zskk.pacsonline.component.aop.SystemLogHandler;
|
|
|
import com.zskk.pacsonline.component.response.RestResult;
|
|
import com.zskk.pacsonline.component.response.RestResult;
|
|
|
import com.zskk.pacsonline.modules.report.dto.ReportDTO;
|
|
import com.zskk.pacsonline.modules.report.dto.ReportDTO;
|
|
|
import com.zskk.pacsonline.modules.report.dto.ReportDetailDTO;
|
|
import com.zskk.pacsonline.modules.report.dto.ReportDetailDTO;
|
|
|
|
|
+import com.zskk.pacsonline.modules.report.dto.ReportSearchDTO;
|
|
|
|
|
+import com.zskk.pacsonline.modules.report.entity.ReportTemp;
|
|
|
import com.zskk.pacsonline.modules.report.service.ReportDetailService;
|
|
import com.zskk.pacsonline.modules.report.service.ReportDetailService;
|
|
|
import com.zskk.pacsonline.modules.report.service.ReportService;
|
|
import com.zskk.pacsonline.modules.report.service.ReportService;
|
|
|
-import com.zskk.pacsonline.modules.report.vo.ReportCreateVO;
|
|
|
|
|
-import com.zskk.pacsonline.modules.report.vo.ReportDetailQueryVO;
|
|
|
|
|
-import com.zskk.pacsonline.modules.report.vo.ReportUpdateVO;
|
|
|
|
|
|
|
+import com.zskk.pacsonline.modules.report.service.ReportTempService;
|
|
|
|
|
+import com.zskk.pacsonline.modules.report.vo.*;
|
|
|
|
|
+import com.zskk.pacsonline.utils.JwtUtil;
|
|
|
|
|
+import com.zskk.pacsonline.utils.PageUtil;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
|
|
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
|
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
import javax.validation.constraints.NotBlank;
|
|
import javax.validation.constraints.NotBlank;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -44,6 +51,12 @@ public class ReportController {
|
|
|
@Resource
|
|
@Resource
|
|
|
private ReportDetailService reportDetailService;
|
|
private ReportDetailService reportDetailService;
|
|
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private ReportTempService reportTempService;
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private JwtUtil jwtUtil;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 创建报告
|
|
* 创建报告
|
|
|
*/
|
|
*/
|
|
@@ -190,4 +203,94 @@ public class ReportController {
|
|
|
return RestResult.error("查询失败:" + e.getMessage());
|
|
return RestResult.error("查询失败:" + e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 暂存报告
|
|
|
|
|
+ */
|
|
|
|
|
+ @Operation(
|
|
|
|
|
+ summary = "暂存报告",
|
|
|
|
|
+ description = "保存当前医生的报告草稿,本地/远程逻辑与旧版一致;未传报告ID时会自动创建"
|
|
|
|
|
+ )
|
|
|
|
|
+ @ApiResponses(value = {
|
|
|
|
|
+ @ApiResponse(responseCode = "200", description = "暂存成功"),
|
|
|
|
|
+ @ApiResponse(responseCode = "400", description = "参数错误"),
|
|
|
|
|
+ @ApiResponse(responseCode = "500", description = "服务器内部错误")
|
|
|
|
|
+ })
|
|
|
|
|
+ @SystemLogHandler("暂存报告|新增")
|
|
|
|
|
+ @PostMapping("/stage")
|
|
|
|
|
+ public RestResult<?> stageReport(
|
|
|
|
|
+ @Parameter(description = "暂存报告参数", required = true, schema = @Schema(implementation = ReportTempSaveVO.class))
|
|
|
|
|
+ @RequestBody @Valid ReportTempSaveVO saveVO) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ ReportTemp draft = reportTempService.saveTempReport(saveVO);
|
|
|
|
|
+ Map<String, String> result = new HashMap<>();
|
|
|
|
|
+ result.put("reportId", draft.getReportId());
|
|
|
|
|
+ result.put("tempId", draft.getId());
|
|
|
|
|
+ return RestResult.ok("暂存成功", result);
|
|
|
|
|
+ } catch (RuntimeException e) {
|
|
|
|
|
+ return RestResult.error(e.getMessage());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ return RestResult.error("暂存失败:" + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 报告关键字搜索(本地报告)
|
|
|
|
|
+ */
|
|
|
|
|
+ @Operation(
|
|
|
|
|
+ summary = "报告关键字搜索",
|
|
|
|
|
+ description = "按关键字模糊查询本地报告的印象/描述并高亮返回,机构ID从token获取"
|
|
|
|
|
+ )
|
|
|
|
|
+ @ApiResponses(value = {
|
|
|
|
|
+ @ApiResponse(responseCode = "200", description = "查询成功"),
|
|
|
|
|
+ @ApiResponse(responseCode = "400", description = "参数错误"),
|
|
|
|
|
+ @ApiResponse(responseCode = "401", description = "未授权"),
|
|
|
|
|
+ @ApiResponse(responseCode = "500", description = "服务器内部错误")
|
|
|
|
|
+ })
|
|
|
|
|
+ @SystemLogHandler("报告关键字搜索|查询")
|
|
|
|
|
+ @PostMapping("/search")
|
|
|
|
|
+ public RestResult<?> searchReport(
|
|
|
|
|
+ @Parameter(description = "关键字搜索参数", required = true, schema = @Schema(implementation = ReportKeywordQueryVO.class))
|
|
|
|
|
+ @RequestBody @Valid ReportKeywordQueryVO queryVO,
|
|
|
|
|
+ HttpServletRequest request) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ String token = getTokenFromRequest(request);
|
|
|
|
|
+ String institutionId = jwtUtil.getCurrentOrgFromToken(token);
|
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(institutionId)) {
|
|
|
|
|
+ return RestResult.error("无法获取机构信息");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<ReportSearchDTO> list = reportService.searchReportByKeyword(queryVO, institutionId);
|
|
|
|
|
+ highlightKeyword(list, queryVO.getFuzzySearch());
|
|
|
|
|
+ BaseDto result = PageUtil.listToBaseDto(list);
|
|
|
|
|
+ return RestResult.ok("查询成功", result);
|
|
|
|
|
+ } catch (RuntimeException e) {
|
|
|
|
|
+ return RestResult.error(e.getMessage());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ return RestResult.error("查询失败:" + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void highlightKeyword(List<ReportSearchDTO> list, String keyword) {
|
|
|
|
|
+ if (list == null || StringUtils.isBlank(keyword)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ String highlight = "<span style='color:red'>" + keyword + "</span>";
|
|
|
|
|
+ for (ReportSearchDTO dto : list) {
|
|
|
|
|
+ if (StringUtils.isNotBlank(dto.getImpression())) {
|
|
|
|
|
+ dto.setImpression(dto.getImpression().replace(keyword, highlight));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isNotBlank(dto.getDescription())) {
|
|
|
|
|
+ dto.setDescription(dto.getDescription().replace(keyword, highlight));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String getTokenFromRequest(HttpServletRequest request) {
|
|
|
|
|
+ String token = request.getHeader("Authorization");
|
|
|
|
|
+ if (StringUtils.isBlank(token)) {
|
|
|
|
|
+ token = request.getHeader("token");
|
|
|
|
|
+ }
|
|
|
|
|
+ return token;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|