diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/pc/TPatientController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/pc/TPatientController.java index 3c0f3b5..c7ed6a0 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/pc/TPatientController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/pc/TPatientController.java @@ -60,10 +60,11 @@ public class TPatientController extends BaseController @ApiOperation("导出患者信息列表") @Log(title = "患者信息", businessType = BusinessType.EXPORT) @PostMapping("/export") - public void export(HttpServletResponse response, TPatient tPatient) + public void export(HttpServletResponse response, @RequestBody @Validated PcTPatintQueryByPageReq pcTPatintQueryByPageReq) { - List list = tPatientService.selectTPatientList(tPatient); - ExcelUtil util = new ExcelUtil(TPatient.class); + List list = tPatientService.queryByPage(pcTPatintQueryByPageReq); + //List list = tPatientService.selectTPatientList(tPatient); + ExcelUtil util = new ExcelUtil(PcTPatientQueryByPageResp.class); util.exportExcel(response, list, "患者信息数据"); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/PcTPatintQueryByPageReq.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/PcTPatintQueryByPageReq.java index b1040f3..013f76a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/PcTPatintQueryByPageReq.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/PcTPatintQueryByPageReq.java @@ -37,6 +37,22 @@ public class PcTPatintQueryByPageReq { @ApiModelProperty("名称") private String name; + /** 名称 */ + @ApiModelProperty("医生名称") + private String doctorName; + + /** 删除标志(0代表存在 2代表删除) */ + @ApiModelProperty("删除标志(0代表存在 2代表删除) ") + private String delFlag; + + public String getDelFlag() { + return delFlag; + } + + public void setDelFlag(String delFlag) { + this.delFlag = delFlag; + } + public Long getHospitalId() { return hospitalId; } @@ -84,4 +100,12 @@ public class PcTPatintQueryByPageReq { public void setName(String name) { this.name = name; } + + public String getDoctorName() { + return doctorName; + } + + public void setDoctorName(String doctorName) { + this.doctorName = doctorName; + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/resp/PcTPatientQueryByPageResp.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/resp/PcTPatientQueryByPageResp.java index 5838bc9..7b6637a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/resp/PcTPatientQueryByPageResp.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/resp/PcTPatientQueryByPageResp.java @@ -1,6 +1,7 @@ package com.ruoyi.system.domain.resp; import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -23,14 +24,17 @@ public class PcTPatientQueryByPageResp { /** 编号 */ @ApiModelProperty("编号") + @Excel(name = "档案号") private String identifier; /** 名称 */ @ApiModelProperty("名称") + @Excel(name = "名称") private String name; /** 电话 */ @ApiModelProperty("电话") + @Excel(name = "电话") private String phone; /** 用户性别(0男 1女 2未知) */ @@ -39,6 +43,7 @@ public class PcTPatientQueryByPageResp { /** 年龄 */ @ApiModelProperty("年龄") + @Excel(name = "年龄") private Integer age; /** 身高 */ @@ -55,6 +60,7 @@ public class PcTPatientQueryByPageResp { /** 基础疾病 */ @ApiModelProperty("基础疾病") + @Excel(name = "基础疾病") private String disease; /** 删除标志(0代表存在 2代表删除) */ @@ -71,6 +77,29 @@ public class PcTPatientQueryByPageResp { @ApiModelProperty("更新时间") private Date updateTime; + /** 最后一次就诊时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty("最后诊断时间") + @Excel(name = "最后诊断时间") + private Date latestTime; + + @ApiModelProperty("诊断次数") + @Excel(name = "诊断次数") + private int countRecords; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty("初次就诊时间") + @Excel(name = "初次就诊时间") + private Date firstTime; + + /** 基础疾病 */ + @ApiModelProperty("诊断医生") + @Excel(name = "诊断医生") + private String doctorName; +// +// +// List recordList; + public Long getId() { return id; } @@ -183,23 +212,27 @@ public class PcTPatientQueryByPageResp { this.updateTime = updateTime; } - @Override - public String toString() { - return "PcTPatientQueryByPageResp{" + - "id=" + id + - ", openId='" + openId + '\'' + - ", identifier='" + identifier + '\'' + - ", name='" + name + '\'' + - ", phone='" + phone + '\'' + - ", sex='" + sex + '\'' + - ", age=" + age + - ", height=" + height + - ", weight=" + weight + - ", marriage='" + marriage + '\'' + - ", disease='" + disease + '\'' + - ", delFlag='" + delFlag + '\'' + - ", createTime=" + createTime + - ", updateTime=" + updateTime + - '}'; + public Date getLatestTime() { + return latestTime; + } + + public void setLatestTime(Date latestTime) { + this.latestTime = latestTime; + } + + public int getCountRecords() { + return countRecords; + } + + public void setCountRecords(int countRecords) { + this.countRecords = countRecords; + } + + public Date getFirstTime() { + return firstTime; + } + + public void setFirstTime(Date firstTime) { + this.firstTime = firstTime; } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TRecordMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TRecordMapper.java index f27f503..6147914 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TRecordMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TRecordMapper.java @@ -88,7 +88,7 @@ public interface TRecordMapper * @param tRecord * @return */ - public List selectTRecordDoctorFirst(TRecord tRecord); + public List selectTRecordDoctorPatientFirst(TRecord tRecord); /** diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TDoctorServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TDoctorServiceImpl.java index e0ee9d1..bd1583e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TDoctorServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TDoctorServiceImpl.java @@ -111,7 +111,7 @@ public class TDoctorServiceImpl implements ITDoctorService List pcTDoctorQueryByPageResps = tDoctorMapper.queryByPage(pcTDoctorQueryByPageReq); pcTDoctorQueryByPageResps.stream().forEach(a ->{ record.setDoctorId(a.getId()); - List tRecords = tRecordMapper.selectTRecordDoctorFirst(record); + List tRecords = tRecordMapper.selectTRecordDoctorPatientFirst(record); //最近一次就诊时间 if (!ObjectUtils.isEmpty(tRecords)){ a.setLatestTime(tRecords.get(0).getCreateTime()); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TPatientServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TPatientServiceImpl.java index 2a1c529..eaafadf 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TPatientServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TPatientServiceImpl.java @@ -4,13 +4,16 @@ import java.util.List; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.system.domain.TRecord; import com.ruoyi.system.domain.req.PcTPatintQueryByPageReq; import com.ruoyi.system.domain.resp.PcTPatientQueryByPageResp; +import com.ruoyi.system.mapper.TRecordMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.system.mapper.TPatientMapper; import com.ruoyi.system.domain.TPatient; import com.ruoyi.system.service.ITPatientService; +import org.springframework.util.ObjectUtils; /** * 患者信息Service业务层处理 @@ -24,6 +27,8 @@ public class TPatientServiceImpl implements ITPatientService @Autowired private TPatientMapper tPatientMapper; + @Autowired + private TRecordMapper tRecordMapper; /** * 查询患者信息 * @@ -100,7 +105,23 @@ public class TPatientServiceImpl implements ITPatientService @Override public List queryByPage(PcTPatintQueryByPageReq pcTPatintQueryByPageReq) { - return tPatientMapper.queryByPage(pcTPatintQueryByPageReq); + Long hospitalId = pcTPatintQueryByPageReq.getHospitalId(); + TRecord record = new TRecord(); + record.setStatus("1"); + record.setHospitalId(hospitalId); + List pcTPatientQueryByPageResps = tPatientMapper.queryByPage(pcTPatintQueryByPageReq); + pcTPatientQueryByPageResps.stream().forEach(a ->{ + record.setPatientId(a.getId()); + List tRecords = tRecordMapper.selectTRecordDoctorPatientFirst(record); + //最后一次/初次就诊时间 + if (!ObjectUtils.isEmpty(tRecords)){ + a.setLatestTime(tRecords.get(0).getCreateTime()); + a.setFirstTime(tRecords.get(tRecords.size()-1).getCreateTime()); + } + //诊断次数 + a.setCountRecords(tRecords.size()); + }); + return pcTPatientQueryByPageResps; } @Override diff --git a/ruoyi-system/src/main/resources/mapper/system/TPatientMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TPatientMapper.xml index 57e8590..d36e7a8 100644 --- a/ruoyi-system/src/main/resources/mapper/system/TPatientMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/TPatientMapper.xml @@ -133,10 +133,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" a.marriage, a.disease, a.create_time as createTime, - a.update_time as updateTime + a.update_time as updateTime, + d.`name` as doctorName, from t_patient a left join t_patient_hospital_doctor b on a.id = b.patient_id + left join t_hospital c on b.hospital_id = c.id + left join t_doctor d on b.doctor_id = d.id - a.del_flag = '0' + + and del_flag = #{delFlag} + AND a.create_time between DATE_FORMAT(#{startTime},'%Y-%m-%d %H:%i:%s') and DATE_FORMAT(#{endTime},'%Y-%m-%d %H:%i:%s') @@ -149,7 +154,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and b.doctor_d = #{doctorId} + + and d.name = like concat('%', #{doctorName}, '%') + + GROUP BY a.id order by a.create_time desc diff --git a/ruoyi-system/src/main/resources/mapper/system/TRecordMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TRecordMapper.xml index 8504bc3..603fe5b 100644 --- a/ruoyi-system/src/main/resources/mapper/system/TRecordMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/TRecordMapper.xml @@ -159,9 +159,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + and patient_id = #{patientId} and doctor_id = #{doctorId} and hospital_id = #{hospitalId} and status = #{status}