From 244b0ae5cfa5d0366aaa31e80a7d0a2c1dc68ac4 Mon Sep 17 00:00:00 2001 From: zhizhi wu <2377881365@qq.com> Date: Wed, 2 Mar 2022 16:43:44 +0800 Subject: [PATCH] =?UTF-8?q?question=20=E6=9F=A5=E8=AF=A2=E6=8A=A5=E5=91=8A?= =?UTF-8?q?=E5=8D=95=E5=92=8C=E7=94=9F=E6=88=90=E6=8A=A5=E5=91=8A=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../question/api/PatientReportController.java | 6 +- .../question/bean/dto/PatientReportDto.java | 4 ++ .../question/bean/po/HtPatientReport.java | 11 ++++ .../bean/po/HtPatientReportExample.java | 60 +++++++++++++++++++ .../persist/dao/HtPatientReportDao.java | 10 +++- .../service/PatientReportService.java | 31 ++++++---- .../mapper_dao/HtPatientReportDao.xml | 18 +++++- .../mapper_raw/HtPatientReportMapper.xml | 55 ++++++++++------- 8 files changed, 159 insertions(+), 36 deletions(-) diff --git a/question/src/main/java/com/ccsens/question/api/PatientReportController.java b/question/src/main/java/com/ccsens/question/api/PatientReportController.java index 0001a722..6011fab5 100644 --- a/question/src/main/java/com/ccsens/question/api/PatientReportController.java +++ b/question/src/main/java/com/ccsens/question/api/PatientReportController.java @@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import javax.annotation.Resource; import javax.validation.Valid; import java.io.IOException; import java.util.List; @@ -35,7 +36,7 @@ import java.util.List; @RestController public class PatientReportController { - @Autowired + @Resource private IPatientReportService patientReportService; @MustLogin @@ -93,7 +94,6 @@ public class PatientReportController { if (patientReport == null || patientReport.getPatientId() == null || patientReport.getPatientId() == 0) { return JsonResponse.newInstance().ok(CodeEnum.PARAM_NULL); } - //TODO 判断病友是否和当前医院绑定,未绑定,进行绑定 JsonResponse response = patientReportService.generatePatientReport(patientReport, dto.getUserId()); log.info("生成病友报告单返回:{}", response); return response; @@ -115,7 +115,7 @@ public class PatientReportController { } @MustLogin - @ApiOperation(value = "查询报告单列表",notes = "根据病人ID/医生ID查询报告单列表") + @ApiOperation(value = "查询报告单列表",notes = "根据病人ID查询报告单列表") @ApiImplicitParams({ @ApiImplicitParam(name = "json", value = "编辑报告单信息", required = true) }) diff --git a/question/src/main/java/com/ccsens/question/bean/dto/PatientReportDto.java b/question/src/main/java/com/ccsens/question/bean/dto/PatientReportDto.java index 0424b014..373a6f11 100644 --- a/question/src/main/java/com/ccsens/question/bean/dto/PatientReportDto.java +++ b/question/src/main/java/com/ccsens/question/bean/dto/PatientReportDto.java @@ -45,6 +45,8 @@ public class PatientReportDto { private Long patientId; @ApiModelProperty("病案号") private String serialNumber; + @ApiModelProperty("第几天 0 14 90") + private byte times = 0; } @ApiModel("PatientReportDtoEdit") @@ -81,6 +83,8 @@ public class PatientReportDto { public static class QueryReports{ @ApiModelProperty("病人ID") private Long patientId; + @ApiModelProperty("第几天 0 14 90") + private byte times = 0; @ApiModelProperty("第几页") @Min(value = 1) private int pageNum = 1; diff --git a/question/src/main/java/com/ccsens/question/bean/po/HtPatientReport.java b/question/src/main/java/com/ccsens/question/bean/po/HtPatientReport.java index 28d042b2..e80b4cac 100644 --- a/question/src/main/java/com/ccsens/question/bean/po/HtPatientReport.java +++ b/question/src/main/java/com/ccsens/question/bean/po/HtPatientReport.java @@ -10,6 +10,8 @@ public class HtPatientReport implements Serializable { private Long patientId; + private Byte times; + private String patientIdcard; private Byte patientAge; @@ -80,6 +82,14 @@ public class HtPatientReport implements Serializable { this.patientId = patientId; } + public Byte getTimes() { + return times; + } + + public void setTimes(Byte times) { + this.times = times; + } + public String getPatientIdcard() { return patientIdcard; } @@ -265,6 +275,7 @@ public class HtPatientReport implements Serializable { sb.append(", id=").append(id); sb.append(", name=").append(name); sb.append(", patientId=").append(patientId); + sb.append(", times=").append(times); sb.append(", patientIdcard=").append(patientIdcard); sb.append(", patientAge=").append(patientAge); sb.append(", doctorId=").append(doctorId); diff --git a/question/src/main/java/com/ccsens/question/bean/po/HtPatientReportExample.java b/question/src/main/java/com/ccsens/question/bean/po/HtPatientReportExample.java index 88359356..5b8c32c3 100644 --- a/question/src/main/java/com/ccsens/question/bean/po/HtPatientReportExample.java +++ b/question/src/main/java/com/ccsens/question/bean/po/HtPatientReportExample.java @@ -295,6 +295,66 @@ public class HtPatientReportExample { return (Criteria) this; } + public Criteria andTimesIsNull() { + addCriterion("times is null"); + return (Criteria) this; + } + + public Criteria andTimesIsNotNull() { + addCriterion("times is not null"); + return (Criteria) this; + } + + public Criteria andTimesEqualTo(Byte value) { + addCriterion("times =", value, "times"); + return (Criteria) this; + } + + public Criteria andTimesNotEqualTo(Byte value) { + addCriterion("times <>", value, "times"); + return (Criteria) this; + } + + public Criteria andTimesGreaterThan(Byte value) { + addCriterion("times >", value, "times"); + return (Criteria) this; + } + + public Criteria andTimesGreaterThanOrEqualTo(Byte value) { + addCriterion("times >=", value, "times"); + return (Criteria) this; + } + + public Criteria andTimesLessThan(Byte value) { + addCriterion("times <", value, "times"); + return (Criteria) this; + } + + public Criteria andTimesLessThanOrEqualTo(Byte value) { + addCriterion("times <=", value, "times"); + return (Criteria) this; + } + + public Criteria andTimesIn(List values) { + addCriterion("times in", values, "times"); + return (Criteria) this; + } + + public Criteria andTimesNotIn(List values) { + addCriterion("times not in", values, "times"); + return (Criteria) this; + } + + public Criteria andTimesBetween(Byte value1, Byte value2) { + addCriterion("times between", value1, value2, "times"); + return (Criteria) this; + } + + public Criteria andTimesNotBetween(Byte value1, Byte value2) { + addCriterion("times not between", value1, value2, "times"); + return (Criteria) this; + } + public Criteria andPatientIdcardIsNull() { addCriterion("patient_idcard is null"); return (Criteria) this; diff --git a/question/src/main/java/com/ccsens/question/persist/dao/HtPatientReportDao.java b/question/src/main/java/com/ccsens/question/persist/dao/HtPatientReportDao.java index f054f87f..4794438b 100644 --- a/question/src/main/java/com/ccsens/question/persist/dao/HtPatientReportDao.java +++ b/question/src/main/java/com/ccsens/question/persist/dao/HtPatientReportDao.java @@ -56,11 +56,17 @@ public interface HtPatientReportDao extends HtPatientReportMapper { /** * 查询报告单名字(ID,名字,导出路径) - * @param doctorId 医生ID * @param patientId 病人ID + * @param times 第几天 + * @return + */ + List queryReportNameByPatient( @Param("patientId") Long patientId, @Param("times") byte times); +/** + * 查询报告单名字(ID,名字,导出路径) + * @param doctorId 医生ID * @return */ - List queryReportName(@Param("doctorId") Long doctorId, @Param("patientId") Long patientId); + List queryReportNameByDoctor(@Param("doctorId") Long doctorId); /** * 管理员查询报告单 diff --git a/question/src/main/java/com/ccsens/question/service/PatientReportService.java b/question/src/main/java/com/ccsens/question/service/PatientReportService.java index 5d88d849..76ff1acb 100644 --- a/question/src/main/java/com/ccsens/question/service/PatientReportService.java +++ b/question/src/main/java/com/ccsens/question/service/PatientReportService.java @@ -82,7 +82,22 @@ public class PatientReportService implements IPatientReportService { // return JsonResponse.newInstance().ok(CodeEnum.PARAM_ERROR); // } - + // 判断患者+第几次的报告单是否存在,存在,直接返回ID,否则新建 + HtPatientReportExample reportExample = new HtPatientReportExample(); + reportExample.createCriteria().andPatientIdEqualTo(generate.getPatientId()) + .andTimesEqualTo(generate.getTimes()); + reportExample.setOrderByClause("id desc limit 1"); + List htPatientReports = htPatientReportDao.selectByExample(reportExample); + log.info("有无报告单:{}", htPatientReports); + // 已添加 + if (CollectionUtil.isNotEmpty(htPatientReports)) { + HtPatientReport report = htPatientReports.get(0); + PatientReportVo.Generate generateVo = new PatientReportVo.Generate(); + generateVo.setId(report.getId()); + generateVo.setName(report.getName()); + return JsonResponse.newInstance().ok(generateVo); + } + // 未添加 HtPatientReport htPatientReport = new HtPatientReport(); htPatientReport.setId(snowflake.nextId()); // htPatientReport.setDoctorId(doctors.get(0).getId()); @@ -93,6 +108,7 @@ public class PatientReportService implements IPatientReportService { htPatientReport.setEvaluationCode(Constant.Ht.Report.PARENT_CODE); htPatientReport.setName(Constant.Ht.Report.PARENT_NAME + DateUtil.today()); htPatientReport.setReportTime(System.currentTimeMillis()); + htPatientReport.setTimes(generate.getTimes()); // 查询医院信息 // String hospital = htPositionDao.queryHospital(doctors.get(0).getPositionId()); // htPatientReport.setHospital(hospital); @@ -174,19 +190,17 @@ public class PatientReportService implements IPatientReportService { List doctors = htDoctorDao.selectByExample(doctorExample); log.info("当前用户是否为医生:{}", CollectionUtil.isNotEmpty(doctors)); // 获取医生ID和病人ID - Long patientId = null; - Long doctorId = null; + Long patientId; + if (query.getPatientId() != null) { patientId = query.getPatientId(); - } else if (CollectionUtil.isNotEmpty(doctors)) { - doctorId = doctors.get(0).getId(); } else { log.info("既无病人信息,有无医生信息,不允许查询"); throw new BaseException(CodeEnum.PARAM_ERROR); } //分页查询报告单列表 PageHelper.startPage(query.getPageNum(), query.getPageSize()); - List reportVos = htPatientReportDao.queryReportName(doctorId, patientId); + List reportVos = htPatientReportDao.queryReportNameByPatient(patientId, query.getTimes()); // if (CollectionUtils.isEmpty(reportVos)) { // return new PageInfo<>(reportVos); // } @@ -484,10 +498,7 @@ public class PatientReportService implements IPatientReportService { } // 查询该医生报告单 PageHelper.startPage(param.getPageNum(), param.getPageSize()); - HtPatientReportExample reportExample = new HtPatientReportExample(); - reportExample.createCriteria().andDoctorIdEqualTo(param.getId()).andShowStatusEqualTo(Constant.Ht.Report.SHOW_HISTORY); - reportExample.setOrderByClause("create_time desc"); - List reports = htPatientReportDao.queryReportName(param.getId(), null); + List reports = htPatientReportDao.queryReportNameByDoctor(param.getId()); if (CollectionUtils.isEmpty(reports)) { log.info("未查询到报告单"); return new PageInfo<>(reports); diff --git a/question/src/main/resources/mapper_dao/HtPatientReportDao.xml b/question/src/main/resources/mapper_dao/HtPatientReportDao.xml index d513f507..1b8f76e2 100644 --- a/question/src/main/resources/mapper_dao/HtPatientReportDao.xml +++ b/question/src/main/resources/mapper_dao/HtPatientReportDao.xml @@ -87,7 +87,20 @@ where id = #{id, jdbcType=BIGINT} and complete_status = 0 and is_del = 0 and doctor_id in (select doctor_id from t_ht_doctor where user_id = #{userId, jdbcType=BIGINT} and audit_state = 1 and is_del = 0) - + select id, name, url, doctor_id as doctorId, 0 as authority from t_ht_patient_report + + + and patient_id = #{patientId, jdbcType=BIGINT} + + + and times = #{times} + + and is_del = 0 + + order by create_time desc + + select @@ -124,23 +125,23 @@ insert into t_ht_patient_report (id, name, patient_id, - patient_idcard, patient_age, doctor_id, - serial_number, initial_impression, clinical_diagnosis, - pasi, department, bed_number, - report_time, check_time, evaluation_code, - url, qr_code_url, remark, - create_time, update_time, is_del, - show_status, hospital, complete_status, - user_id) + times, patient_idcard, patient_age, + doctor_id, serial_number, initial_impression, + clinical_diagnosis, pasi, department, + bed_number, report_time, check_time, + evaluation_code, url, qr_code_url, + remark, create_time, update_time, + is_del, show_status, hospital, + complete_status, user_id) values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{patientId,jdbcType=BIGINT}, - #{patientIdcard,jdbcType=VARCHAR}, #{patientAge,jdbcType=TINYINT}, #{doctorId,jdbcType=BIGINT}, - #{serialNumber,jdbcType=VARCHAR}, #{initialImpression,jdbcType=VARCHAR}, #{clinicalDiagnosis,jdbcType=VARCHAR}, - #{pasi,jdbcType=TINYINT}, #{department,jdbcType=VARCHAR}, #{bedNumber,jdbcType=VARCHAR}, - #{reportTime,jdbcType=BIGINT}, #{checkTime,jdbcType=BIGINT}, #{evaluationCode,jdbcType=VARCHAR}, - #{url,jdbcType=VARCHAR}, #{qrCodeUrl,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, - #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{isDel,jdbcType=TINYINT}, - #{showStatus,jdbcType=TINYINT}, #{hospital,jdbcType=VARCHAR}, #{completeStatus,jdbcType=TINYINT}, - #{userId,jdbcType=BIGINT}) + #{times,jdbcType=TINYINT}, #{patientIdcard,jdbcType=VARCHAR}, #{patientAge,jdbcType=TINYINT}, + #{doctorId,jdbcType=BIGINT}, #{serialNumber,jdbcType=VARCHAR}, #{initialImpression,jdbcType=VARCHAR}, + #{clinicalDiagnosis,jdbcType=VARCHAR}, #{pasi,jdbcType=TINYINT}, #{department,jdbcType=VARCHAR}, + #{bedNumber,jdbcType=VARCHAR}, #{reportTime,jdbcType=BIGINT}, #{checkTime,jdbcType=BIGINT}, + #{evaluationCode,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{qrCodeUrl,jdbcType=VARCHAR}, + #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, + #{isDel,jdbcType=TINYINT}, #{showStatus,jdbcType=TINYINT}, #{hospital,jdbcType=VARCHAR}, + #{completeStatus,jdbcType=TINYINT}, #{userId,jdbcType=BIGINT}) insert into t_ht_patient_report @@ -154,6 +155,9 @@ patient_id, + + times, + patient_idcard, @@ -231,6 +235,9 @@ #{patientId,jdbcType=BIGINT}, + + #{times,jdbcType=TINYINT}, + #{patientIdcard,jdbcType=VARCHAR}, @@ -317,6 +324,9 @@ patient_id = #{record.patientId,jdbcType=BIGINT}, + + times = #{record.times,jdbcType=TINYINT}, + patient_idcard = #{record.patientIdcard,jdbcType=VARCHAR}, @@ -393,6 +403,7 @@ set id = #{record.id,jdbcType=BIGINT}, name = #{record.name,jdbcType=VARCHAR}, patient_id = #{record.patientId,jdbcType=BIGINT}, + times = #{record.times,jdbcType=TINYINT}, patient_idcard = #{record.patientIdcard,jdbcType=VARCHAR}, patient_age = #{record.patientAge,jdbcType=TINYINT}, doctor_id = #{record.doctorId,jdbcType=BIGINT}, @@ -428,6 +439,9 @@ patient_id = #{patientId,jdbcType=BIGINT}, + + times = #{times,jdbcType=TINYINT}, + patient_idcard = #{patientIdcard,jdbcType=VARCHAR}, @@ -501,6 +515,7 @@ update t_ht_patient_report set name = #{name,jdbcType=VARCHAR}, patient_id = #{patientId,jdbcType=BIGINT}, + times = #{times,jdbcType=TINYINT}, patient_idcard = #{patientIdcard,jdbcType=VARCHAR}, patient_age = #{patientAge,jdbcType=TINYINT}, doctor_id = #{doctorId,jdbcType=BIGINT},