From c965afecf17784894658c899f864949526bd1bda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AD=A6?= <吴æ武慧娟> Date: Fri, 20 Dec 2019 17:10:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ccsens/ht/api/DoctorController.java | 2 +- .../ht/api/PatientReportController.java | 19 ++ .../com/ccsens/ht/bean/dto/PatientDto.java | 21 +-- .../ccsens/ht/bean/dto/PatientReportDto.java | 5 +- .../ccsens/ht/bean/vo/PatientReportVo.java | 174 +++++++++++++++++- .../com/ccsens/ht/bean/vo/QuestionVo.java | 19 +- .../ht/persist/dao/HtPatientReportDao.java | 2 +- .../ht/service/PatientReportService.java | 22 ++- .../com/ccsens/ht/service/PatientService.java | 9 +- .../ccsens/ht/service/QuestionService.java | 58 ++++-- ht/src/main/resources/application-dev.yml | 2 +- ht/src/main/resources/application-test.yml | 2 +- util/pom.xml | 18 ++ .../main/java/com/ccsens/util/CodeEnum.java | 2 + .../main/java/com/ccsens/util/PdfUtil.java | 164 +++++++++++++++++ .../java/com/ccsens/util/PdfUtilTest.java | 42 +++++ .../test/java/com/ccsens/util/ZipTest.java | 2 + 17 files changed, 517 insertions(+), 46 deletions(-) create mode 100644 util/src/main/java/com/ccsens/util/PdfUtil.java create mode 100644 util/src/test/java/com/ccsens/util/PdfUtilTest.java diff --git a/ht/src/main/java/com/ccsens/ht/api/DoctorController.java b/ht/src/main/java/com/ccsens/ht/api/DoctorController.java index 78013c56..2f33d9d4 100644 --- a/ht/src/main/java/com/ccsens/ht/api/DoctorController.java +++ b/ht/src/main/java/com/ccsens/ht/api/DoctorController.java @@ -90,7 +90,7 @@ public class DoctorController { log.info("资格认证列表:{}", params); DoctorVo.Query dtos = doctorService.queryDoctorStatus(params.getUserId()); if (dtos == null) { - JsonResponse.newInstance().ok(CodeEnum.DOCTOR_NOT_SUBMIT); + return JsonResponse.newInstance().ok(CodeEnum.DOCTOR_NOT_SUBMIT); } return JsonResponse.newInstance().ok(dtos); } diff --git a/ht/src/main/java/com/ccsens/ht/api/PatientReportController.java b/ht/src/main/java/com/ccsens/ht/api/PatientReportController.java index 3f4edb8d..792344cd 100644 --- a/ht/src/main/java/com/ccsens/ht/api/PatientReportController.java +++ b/ht/src/main/java/com/ccsens/ht/api/PatientReportController.java @@ -9,6 +9,8 @@ import com.ccsens.ht.bean.vo.PatientReportVo; import com.ccsens.ht.service.IPatientReportService; import com.ccsens.util.CodeEnum; import com.ccsens.util.JsonResponse; +import com.ccsens.util.PdfUtil; +import com.ccsens.util.PropUtil; import com.github.pagehelper.PageInfo; import io.swagger.annotations.*; import lombok.extern.slf4j.Slf4j; @@ -109,4 +111,21 @@ public class PatientReportController { log.info("查询医生对报告单的权限结果:{}", authority); return JsonResponse.newInstance().ok(authority); } + +// @ApiOperation(value = "导出报告单",notes = "导出报告单") +// @ApiImplicitParams({ +// @ApiImplicitParam(name = "json", value = "导出报告单", required = true) +// }) +// @RequestMapping(value="/exportReport", method = RequestMethod.POST) +// public JsonResponse exportReport(@RequestBody @ApiParam @Valid QueryDto param){ +// //查询报告单信息 +// log.info("查询报告单详情:{}", param); +// PatientReportVo.ReprotDetail detail = patientReportService.queryReportDetail(param.getParam(), param.getUserId()); +// if (detail == null) { +// return JsonResponse.newInstance().ok(CodeEnum.); +// } +// PdfUtil.credatePdf(PropUtil.path, detail.getPatient().getName(), detail.getPatient().toPdfRow(), ) +// log.info("查询报告单详情结果:{}", detail); +// return JsonResponse.newInstance().ok(detail); +// } } diff --git a/ht/src/main/java/com/ccsens/ht/bean/dto/PatientDto.java b/ht/src/main/java/com/ccsens/ht/bean/dto/PatientDto.java index 52da784c..a49b7bbc 100644 --- a/ht/src/main/java/com/ccsens/ht/bean/dto/PatientDto.java +++ b/ht/src/main/java/com/ccsens/ht/bean/dto/PatientDto.java @@ -55,45 +55,44 @@ public class PatientDto { private Long id; @ApiModelProperty("病人用户id") private Long userId; - @NotNull + @NotNull(message = "请填写名字") @ApiModelProperty("病人名字") private String name; @ApiModelProperty("病人门诊号") private String patientNumber; @ApiModelProperty("病人住院号") private String hospitalNumber; - @NotNull + @NotNull(message="请填写身份证号") @ApiModelProperty("病人身份证号") - @NotNull(message="身份证信息不能为空") private String idcard; - @NotNull + @NotNull(message = "请选择性别") @ApiModelProperty("性别(0:男 1:女)") private Byte sex; - @NotNull + @NotNull(message = "请选择婚姻状况") @ApiModelProperty("婚姻状况(1:未婚2:已婚 3:离异 4:分居 5:丧偶 6:同居 7:其他 )") private Byte maritalStatus; - @NotNull + @NotNull(message = "请选择教育程度") @ApiModelProperty("教育程度(1:文盲 2:小学 3:初中 4:高中 5:大学 6:大学以上 7:其他)") private Byte educationalStatus; - @NotNull + @NotNull(message = "请选择受教育时间") @ApiModelProperty("受教育时间(年或月)") private String educationalStatusUnit; @ApiModelProperty("民族") private String nation; @ApiModelProperty("籍贯") private String nativePlace; - @NotNull + @NotNull(message="请选择职业") @ApiModelProperty("职业(1:农林牧渔水利生产人员 2:教师 3:医务工作者 4:专业技术人员 5:生产、运输设备操作人员及有关人员6:商业、服务业人员7:国家机关、事业单位、企业负责人8:国家机关、事业单位、企业办事人员和有关人员9:军人 10:媒体、文体类工作人员 11:在校学生 12:未就业 13:家务 14:其他") private Byte career; - @NotNull + @NotNull(message="请填写生育数量") @ApiModelProperty("生育数量") private Integer birthNumber; @ApiModelProperty("绝经年龄(女)") private Integer menopauseAge; - @NotNull + @NotNull(message="请填写联系人") @ApiModelProperty("联系人") private String contact; - @NotNull + @NotNull(message = "请填写手机") @ApiModelProperty("手机") private String mobile; @ApiModelProperty("电话") diff --git a/ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java b/ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java index 50a33da0..6d241b62 100644 --- a/ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java +++ b/ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java @@ -41,10 +41,8 @@ public class PatientReportDto { @ApiModelProperty("病人年龄 ") private Byte patientAge; @ApiModelProperty("严重程度(1:轻度 2:中度 3:重度) ") - @NotNull(message = "严重程度不能为空") - private Long pasi; + private Byte pasi; @ApiModelProperty("科别") - @NotNull(message = "科别不允许为空") private String department; @ApiModelProperty("病人报告单ID") @NotNull(message = "报告单ID不允许为空") @@ -62,7 +60,6 @@ public class PatientReportDto { @Data public static class QueryReports{ @ApiModelProperty("病人ID") - @NotNull(message = "病人ID不能为空") private Long patientId; @ApiModelProperty("第几页") @Min(value = 1) diff --git a/ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java b/ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java index 3896ff58..5c88d090 100644 --- a/ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java +++ b/ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java @@ -1,13 +1,15 @@ package com.ccsens.ht.bean.vo; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; +import com.ccsens.util.PdfUtil; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.springframework.beans.factory.annotation.Autowired; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.util.*; /** * @program: ptpro @@ -95,6 +97,60 @@ public class PatientReportVo { private String educationalStatusUnit; @ApiModelProperty("职业") private Byte career; + + public List toPdfRow(){ + Map careerMap = new HashMap<>(); + String careerMsg = "1:农林牧渔水利生产人员 2:教师 3:医务工作者 4:专业技术人员 5:生产、运输设备操作人员及有关人员 6:商业、服务业人员 7:国家机关、事业单位、企业负责人 8:国家机关、事业单位、企业办事人员和有关人员 9:军人 10:媒体、文体类工作人员 11:在校学生 12:未就业 13:家务 14:其他"; + for (String careerOne: careerMsg.split(" ")) { + careerMap.put(Byte.parseByte(careerOne.split(":")[0]), careerOne.split(":")[1]); + } + + + List rows = new ArrayList<>(); + //第一栏 + rows.add( + fillRow( + "姓名:" + this.patientName, + "性别:" + (this.sex == 0 ? "男" : "女"), + "年龄:" + this.patientAge + " 岁") + ); + //第二栏 + rows.add( + fillRow( + "文化程度(年或月):" + this.educationalStatusUnit, + "编号:" + this.serialNumber, + "职业:" + careerMap.get(this.career)) + ); + //第三栏 + rows.add( + fillRow( + "科别:" + this.department, + "床号:" + this.bedNumber, + "病案号:" + this.hospitalNumber) + ); + //第四栏 + Date date = new Date(); + date.setTime(this.reportTime); + rows.add( + fillRow( + "临床诊断:" + this.clinicalDiagnosis, + "检查日期:" + DateUtil.format(date, "yyyy-MM-dd")) + ); + + return rows; + } + + private PdfUtil.Row fillRow(String... params) { + PdfUtil.Row row = new PdfUtil.Row(); + for (String param: params) { + PdfUtil.Cell cell = new PdfUtil.Cell(); + cell.setContent(param); + cell.setBorder(0); + row.addCell(cell); + } + + return row; + } } /**分数类型*/ @@ -123,6 +179,111 @@ public class PatientReportVo { public void addSub(ReportScore score) { this.subReport.add(score); } + + public List toRow() { + List rows = new ArrayList<>(); + if (CollectionUtil.isEmpty(subReport)) { + PdfUtil.Row row = new PdfUtil.Row(); + PdfUtil.Cell cell1 = new PdfUtil.Cell(); + cell1.setContent(this.name + (StrUtil.isBlank(this.remark) ? "" : "("+this.remark+")")); + PdfUtil.Cell cell2 = new PdfUtil.Cell(); + cell2.setContent(this.score == null ? "" : this.score + (this.totalScore > 0 ? "/" + this.totalScore : "")); + row.addCell(cell1); + row.addCell(cell2); + rows.add(row); + return rows; + } else { + String mmse = "MMSE"; + String npi = "NPI"; + if (mmse.equalsIgnoreCase(this.code) || npi.equalsIgnoreCase(this.code)) { + PdfUtil.Row row1 = new PdfUtil.Row(); + PdfUtil.Cell cell = new PdfUtil.Cell(); + cell.setContent(this.name + (StrUtil.isBlank(this.remark) ? "" : "("+this.remark+")")); + cell.setRowSpan(2); + row1.addCell(cell); + PdfUtil.Row row2 = new PdfUtil.Row(); + this.subReport.forEach(reportScore -> { + fillRow(row1,row2, reportScore.getName(), reportScore.score == null ? "" : reportScore.score + (reportScore.totalScore > 0 ? "/" + reportScore.totalScore : "")); + }); + + if (mmse.equalsIgnoreCase(this.code)) { + fillRow(row1,row2, "总分", this.score == null ? "" : this.score + (this.totalScore > 0 ? "/" + this.totalScore : "")); + } + rows.add(row1); + rows.add(row2); + } else { + //moca + int firstIndex = 6; + PdfUtil.Row row1 = new PdfUtil.Row(); + PdfUtil.Cell cell = new PdfUtil.Cell(); + cell.setContent(this.name + (StrUtil.isBlank(this.remark) ? "" : "("+this.remark+")")); + cell.setRowSpan(5); + row1.addCell(cell); + PdfUtil.Row row2 = new PdfUtil.Row(); + for (int i = 0; i < firstIndex; i++) { + ReportScore reportScore = this.subReport.get(i); + String jy = "JY"; + if (jy.equalsIgnoreCase(reportScore.getCode())) { + fillRow(row1, row2, reportScore.getName(), ""); + } else { + fillRow(row1, row2, reportScore.getName(), reportScore.score == null ? "" : reportScore.score + (reportScore.totalScore > 0 ? "/" + reportScore.totalScore : "")); + } + } + PdfUtil.Cell scoreNameCell = new PdfUtil.Cell(); + scoreNameCell.setContent("总分"); + row1.addCell(scoreNameCell); + PdfUtil.Cell scoreCell = new PdfUtil.Cell(); + scoreNameCell.setContent("总分"); + row1.addCell(scoreNameCell); + + + for (ReportScore score: this.subReport) { + + + + if (firstIndex == 6) { + //设置总分 + PdfUtil.Cell scoreTitleCell = new PdfUtil.Cell(); + scoreTitleCell.setContent("总分"); + row1.addCell(scoreTitleCell); + PdfUtil.Cell scoreScoreCell = new PdfUtil.Cell(); + scoreScoreCell.setContent(this.score == null ? "" : this.score + (this.totalScore > 0 ? "/" + this.totalScore : "")); + scoreScoreCell.setRowSpan(4); + row2.addCell(scoreScoreCell); + rows.add(row1); + rows.add(row2); + //换行 + row1 = new PdfUtil.Row(); + row2 = new PdfUtil.Row(); + } + firstIndex++; + } + rows.add(row1); + rows.add(row2); + } + + + + + } + PdfUtil.Row row = new PdfUtil.Row(); + PdfUtil.Cell cell = new PdfUtil.Cell(); + cell.setContent(this.description); + + + return rows; + } + + private void fillRow(PdfUtil.Row row1, PdfUtil.Row row2, String name, String score){ + //名称 + PdfUtil.Cell cell1 = new PdfUtil.Cell(); + cell1.setContent(name); + row1.addCell(cell1); + //分数 + PdfUtil.Cell cell2 = new PdfUtil.Cell(); + cell2.setContent(score); + row2.addCell(cell2); + } } /**医生对报告单权限*/ @@ -136,4 +297,11 @@ public class PatientReportVo { public static final int READ_WRITE = 1; public static final int CHECK = 2; } + + @ApiModel("PatientReportVoExport") + @Data + public static class Export{ + @ApiModelProperty("路径") + private String path; + } } diff --git a/ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java b/ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java index 222ad1ff..47efe904 100644 --- a/ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java +++ b/ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil; import com.ccsens.ht.bean.po.HtPatientQuestionRecord; import com.ccsens.ht.bean.po.HtQuestion; import com.ccsens.ht.bean.po.HtQuestionIntroducer; +import com.ccsens.ht.bean.po.HtQuestionOption; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -78,6 +79,22 @@ public class QuestionVo { private String name; } + @Data + @ApiModel("QuestionOption") + public static class QuestionOption{ + @ApiModelProperty("试题") + private Question question; + @ApiModelProperty("选项") + private List