Browse Source

诊疗档案完成

newMaster
zzc 5 months ago
parent
commit
270d0a9d64
  1. 6
      acupuncture-admin/pom.xml
  2. 31
      acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/PmsPatientController.java
  3. 79
      acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/PmsTreatmentController.java
  4. 33
      acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/SysController.java
  5. 4
      acupuncture-admin/src/main/resources/application-stage.yml
  6. 5
      acupuncture-common/src/main/java/com/acupuncture/common/constant/UserConstants.java
  7. 73
      acupuncture-common/src/main/java/com/acupuncture/common/utils/NotionUtils.java
  8. 6
      acupuncture-system/pom.xml
  9. 18
      acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/PmsPatientDto.java
  10. 170
      acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/PmsTreatmentDto.java
  11. 136
      acupuncture-system/src/main/java/com/acupuncture/system/domain/vo/PmsTreatmentVo.java
  12. 6
      acupuncture-system/src/main/java/com/acupuncture/system/persist/dao/PmsPatientDao.java
  13. 26
      acupuncture-system/src/main/java/com/acupuncture/system/persist/dao/PmsTreatmentDao.java
  14. 8
      acupuncture-system/src/main/java/com/acupuncture/system/service/PmsPatientService.java
  15. 44
      acupuncture-system/src/main/java/com/acupuncture/system/service/PmsTreatmentService.java
  16. 147
      acupuncture-system/src/main/java/com/acupuncture/system/service/impl/PmsPatientServiceImpl.java
  17. 173
      acupuncture-system/src/main/java/com/acupuncture/system/service/impl/PmsTreatmentServiceImpl.java
  18. 42
      acupuncture-system/src/main/resources/mapper/dao/PmsPatientDao.xml
  19. 107
      acupuncture-system/src/main/resources/mapper/dao/PmsTreatmentDao.xml

6
acupuncture-admin/pom.xml

@ -28,6 +28,12 @@
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<exclusions>
<exclusion>
<artifactId>swagger-annotations</artifactId>
<groupId>io.swagger</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- 防止进入swagger页面报类型转换错误,排除3.0.0中的引用,手动增加1.6.2版本 -->

31
acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/PmsPatientController.java

@ -15,8 +15,11 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
@ -36,31 +39,43 @@ public class PmsPatientController {
@ApiOperation("添加患者信息")
@PostMapping("/add")
public JsonResponse<Integer> add(@RequestBody @Validated PmsPatientDto.PatientAdd dto){
pmsPatientService.add(dto);
return JsonResponse.ok();
public JsonResponse<Long> add(@RequestBody @Validated PmsPatientDto.PatientAdd dto){
return JsonResponse.ok(pmsPatientService.add(dto));
}
@ApiOperation("修改患者信息")
@PostMapping("/upd")
public JsonResponse<Integer> upd(@RequestBody @Validated PmsPatientDto.PatientUpd dto){
pmsPatientService.upd(dto);
return JsonResponse.ok();
return JsonResponse.ok(pmsPatientService.upd(dto));
}
@ApiOperation("删除患者信息")
@PostMapping("/del")
public JsonResponse<Integer> del(@RequestBody @Validated PmsPatientDto.Delete dto){
pmsPatientService.del(dto.getIdList());
return JsonResponse.ok();
return JsonResponse.ok(pmsPatientService.del(dto.getIdList()));
}
@ApiOperation("查询患者信息")
@PostMapping("/query")
@PostMapping("/list")
public JsonResponse<PageInfo<PmsPatientVo.PatientResult>> query(@RequestBody @Validated BaseDto<PmsPatientDto.PatientQuery> dto){
if (dto.getPageNum() > 0) {
PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
}
return JsonResponse.ok(new PageInfo<>(pmsPatientService.query(dto.getParam())));
}
@ApiOperation("导出患者信息")
@PostMapping("/export")
public JsonResponse<Integer> exportPatient(HttpServletResponse response, @RequestBody @Validated PmsPatientDto.PatientQuery dto){
pmsPatientService.exportPatient(response, dto);
return JsonResponse.ok();
}
@ApiOperation("导入患者信息")
@PostMapping("/import")
public JsonResponse<Integer> importPatient(MultipartFile file) throws IOException{
pmsPatientService.importPatient(file);
return JsonResponse.ok();
}
}

79
acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/PmsTreatmentController.java

@ -0,0 +1,79 @@
package com.acupuncture.web.controller.web;
import com.acupuncture.common.core.domain.BaseDto;
import com.acupuncture.common.core.domain.JsonResponse;
import com.acupuncture.system.domain.dto.PmsTreatmentDto;
import com.acupuncture.system.domain.vo.PmsTreatmentVo;
import com.acupuncture.system.service.PmsTreatmentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* @Author zzc
* @Package com.acupuncture.web.controller.web
* @Date 2025/2/11 14:55
* @description:
*/
@Slf4j
@Api(tags = "诊疗档案相关")
@RestController
@RequestMapping("/treatment")
public class PmsTreatmentController {
@Resource
private PmsTreatmentService treatmentService;
@ApiOperation("添加诊疗档案")
@PostMapping("/add")
public JsonResponse<Integer> addTreatment(@RequestBody @Validated PmsTreatmentDto.TreatmentAdd dto){
treatmentService.addTreatment(dto);
return JsonResponse.ok();
}
@ApiOperation("修改诊疗档案")
@PostMapping("/upd")
public JsonResponse<Integer> updateTreatment(@RequestBody @Validated PmsTreatmentDto.TreatmentUpdateDTO dto){
treatmentService.updateTreatment(dto);
return JsonResponse.ok();
}
@ApiOperation("删除诊疗档案")
@PostMapping("/del")
public JsonResponse<Integer> deleteTreatment(@RequestBody @Validated PmsTreatmentDto.DeleteDto dto){
treatmentService.deleteTreatment(dto.getIdList());
return JsonResponse.ok();
}
@ApiOperation("查询诊疗档案")
@PostMapping("/list")
public JsonResponse<PageInfo<PmsTreatmentVo.TreatmentVO>> listTreatment(@RequestBody @Validated BaseDto<PmsTreatmentDto.TreatmentQueryDTO> queryDTO){
if (queryDTO.getPageNum() > 0) {
PageHelper.startPage(queryDTO.getPageNum(), queryDTO.getPageSize());
}
return JsonResponse.ok(new PageInfo<>(treatmentService.listTreatment(queryDTO.getParam())));
}
@ApiOperation("新增诊疗档案数据")
@PostMapping("/saveAidRecord")
public JsonResponse<Integer> saveAidRecord(@RequestBody @Validated PmsTreatmentDto.SaveAidRecord dto){
treatmentService.saveAidRecord(dto);
return JsonResponse.ok();
}
@ApiOperation("查询诊疗档案数据")
@PostMapping("/queryRecord")
public JsonResponse<PmsTreatmentVo.TreatmentRecordVO> queryRecord(@RequestBody @Validated PmsTreatmentDto.QueryRecord dto){
return JsonResponse.ok(treatmentService.queryRecord(dto.getTreatmentId(), dto.getCodeList()));
}
}

33
acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/SysController.java

@ -0,0 +1,33 @@
package com.acupuncture.web.controller.web;
import com.acupuncture.common.core.domain.JsonResponse;
import com.acupuncture.common.utils.NotionUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @Author zzc
* @Package com.acupuncture.web.controller.web
* @Date 2025/2/11 15:17
* @description:
*/
@Api("基本接口")
@RestController
@RequestMapping("/sys")
@Slf4j
public class SysController {
@ApiOperation("获取【民族】列表")
@PostMapping("/nation/list")
public JsonResponse<List<String>> listNation() {
return JsonResponse.ok(NotionUtils.getNotionList());
}
}

4
acupuncture-admin/src/main/resources/application-stage.yml

@ -58,4 +58,6 @@ spring:
merge-sql: true
wall:
config:
multi-statement-allow: true
multi-statement-allow: true
file:
PatientTemplate: C:\Users\zzc16\Desktop\PatientTemplate.xlsx

5
acupuncture-common/src/main/java/com/acupuncture/common/constant/UserConstants.java

@ -80,4 +80,9 @@ public class UserConstants
public static final int PASSWORD_MAX_LENGTH = 20;
public static final String HEADER_KEY_TOKEN = "Authorization";
/**
* QuestionAnswer分隔符
*/
public static final String ANSWER_JOIN_STRING = "!@#";
}

73
acupuncture-common/src/main/java/com/acupuncture/common/utils/NotionUtils.java

@ -0,0 +1,73 @@
package com.acupuncture.common.utils;
import cn.hutool.core.collection.CollectionUtil;
import java.util.List;
/**
* 精确的浮点数运算
*
* @author cc
*/
public class NotionUtils {
public static List<String> getNotionList(){
return CollectionUtil.newArrayList(
"汉族",
"蒙古族",
"回族",
"藏族",
"维吾尔族",
"苗族",
"彝族",
"壮族",
"布依族",
"朝鲜族",
"满族",
"侗族",
"瑶族",
"白族",
"土家族",
"哈尼族",
"哈萨克族",
"傣族",
"黎族",
"傈僳族",
"佤族",
"畲族",
"高山族",
"拉祜族",
"水族",
"东乡族",
"纳西族",
"景颇族",
"柯尔克孜族",
"土族",
"达斡尔族",
"仫佬族",
"羌族",
"布朗族",
"撒拉族",
"毛南族",
"仡佬族",
"锡伯族",
"阿昌族",
"普米族",
"塔吉克族",
"怒族",
"乌孜别克族",
"俄罗斯族",
"鄂温克族",
"崩龙族",
"保安族",
"裕固族",
"京族",
"塔塔尔族",
"独龙族",
"鄂伦春族",
"赫哲族",
"门巴族",
"珞巴族",
"基诺族"
);
}
}

6
acupuncture-system/pom.xml

@ -31,6 +31,12 @@
<artifactId>hutool-all</artifactId>
<version>5.8.24</version>
</dependency>
<!-- hutool配套拼音工具包 -->
<dependency>
<groupId>io.github.biezhi</groupId>
<artifactId>TinyPinyin</artifactId>
<version>2.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>

18
acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/PmsPatientDto.java

@ -1,11 +1,13 @@
package com.acupuncture.system.domain.dto;
import com.acupuncture.system.domain.po.PmsPatient;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author zzc
@ -33,6 +35,7 @@ public class PmsPatientDto {
private Integer sourceId;
@ApiModelProperty("建档人")
private String createBy;
private String phone;
}
@Data
@ -41,6 +44,7 @@ public class PmsPatientDto {
private Byte gender;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date birthDate;
private String ethnicity;
@ -55,7 +59,11 @@ public class PmsPatientDto {
private Byte source;
private String currentIllnessHistory;
private List<String> currentIllnessHistory;
public String getCurrentIllnessHistory() {
return currentIllnessHistory.stream().collect(Collectors.joining(","));
}
}
@ -65,7 +73,7 @@ public class PmsPatientDto {
private String name;
private Byte gender;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date birthDate;
private String ethnicity;
@ -80,7 +88,11 @@ public class PmsPatientDto {
private Byte source;
private String currentIllnessHistory;
private List<String> currentIllnessHistory;
public String getCurrentIllnessHistory() {
return currentIllnessHistory.stream().collect(Collectors.joining(","));
}
}
@Data

170
acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/PmsTreatmentDto.java

@ -0,0 +1,170 @@
package com.acupuncture.system.domain.dto;
import cn.hutool.core.collection.CollectionUtil;
import com.acupuncture.common.constant.UserConstants;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* @Author zzc
* @Package com.acupuncture.system.domain.dto
* @Date 2025/2/11 15:05
* @description:
*/
public class PmsTreatmentDto {
@Data
public static class TreatmentAdd {
private String name;
private Integer gender;
private Integer age;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date birthDate;
private String ethnicity;
private Integer educationYears;
private String phone;
private Integer idCardType;
private String idCard;
private Integer visitType;
private String visitNumber;
private Date visitTime;
private Date dischargeTime;
private String doctor;
private String deptName;
private String diagnosisCode;
private String diagnosisName;
private Integer status;
private Long organizationId;
private String createBy;
private String remark;
}
@Data
public static class TreatmentUpdateDTO {
private Long id;
private String name;
private Integer gender;
private Integer age;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date birthDate;
private String ethnicity;
private Integer educationYears;
private String phone;
// private Integer idCardType;
// private String idCard;
private Integer visitType;
private String visitNumber;
private Date visitTime;
private Date dischargeTime;
private String doctor;
private String deptName;
private String diagnosisCode;
private String diagnosisName;
private Integer status;
private Long organizationId;
private String createBy;
private String remark;
private String updateBy;
}
// TreatmentQueryDTO.java (查询用)
@Data
public static class TreatmentQueryDTO {
private Long patientId;
private Integer visitType;
private String keywords;
private Integer gender;
private String doctor;
private Integer status;
private Integer startAge;
private Integer endAge;
private String sourceId;
private String phone;
}
@Data
public static class TreatmentRecordAddDTO {
private Long treatmentId;
private String questionCode;
private String answer;
private Date time;
private String sourceId;
private Long organizationId;
private String createBy;
private String remark;
}
@Data
public static class DeleteDto{
@NotNull(message = "id不能为空")
private List<Long> idList;
}
@Data
@ApiModel("FirstAidDto-SaveAidRecord")
public static class SaveAidRecord {
@Data
@ApiModel("题目code和答案")
public static class CodeAndAnswer {
@NotBlank
@ApiModelProperty("code")
private String questionCode;
@Size(max = 6, message = "答案不能超过6个")
@ApiModelProperty("答案")
private List<String> answer;
@ApiModelProperty("发生时间")
private Date time;
public String getAnswerString() {
if (CollectionUtil.isEmpty(answer)) {
return "";
}
return CollectionUtil.join(answer, UserConstants.ANSWER_JOIN_STRING);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CodeAndAnswer codeAndAnswer = (CodeAndAnswer) o;
return Objects.equals(questionCode, codeAndAnswer.questionCode);
}
@Override
public int hashCode() {
return Objects.hash(this.questionCode);
}
}
@NotNull(message = "诊疗Id不能为空")
@ApiModelProperty("诊疗Id")
private Long treatmentId;
@ApiModelProperty("code和答案")
private List<CodeAndAnswer> codeAndAnswerList;
@ApiModelProperty("数据来源")
private String source;
}
@Data
public static class QueryRecord{
@NotNull(message = "诊疗Id不能为空")
@ApiModelProperty("诊疗Id")
private Long treatmentId;
@ApiModelProperty("code集合")
private List<String> codeList;
}
}

136
acupuncture-system/src/main/java/com/acupuncture/system/domain/vo/PmsTreatmentVo.java

@ -0,0 +1,136 @@
package com.acupuncture.system.domain.vo;
import cn.hutool.core.util.StrUtil;
import com.acupuncture.common.constant.UserConstants;
import com.acupuncture.system.domain.po.PmsTreatment;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @Author zzc
* @Package com.acupuncture.system.domain.vo
* @Date 2025/2/11 15:08
* @description:
*/
public class PmsTreatmentVo {
@Data
public static class TreatmentVO {
private Long id;
private Long patientId;
private String name;
private Integer gender;
private Integer age;
private Date birthDate;
private String ethnicity;
private Integer educationYears;
private String phone;
private Integer idCardType;
private String idCard;
private Integer visitType;
private String visitNumber;
private Date visitTime;
private Date dischargeTime;
private String doctor;
private String deptName;
private String diagnosisCode;
private String diagnosisName;
private Integer status;
private Long organizationId;
private String createBy;
private Date createTime;
private String updateBy;
private Date updateTime;
private String remark;
}
@Data
public static class TreatmentRecordVO {
private Long id;
private Long treatmentId;
private String name;
private Byte gender;
private Integer age;
private Date birthDate;
private String ethnicity;
private Integer educationYears;
private String phone;
private Byte idCardType;
private String idCard;
private Byte visitType;
private String visitNumber;
private Date visitTime;
private Date dischargeTime;
private String doctor;
private String deptName;
private String diagnosisCode;
private String diagnosisName;
private Byte status;
private Long organizationId;
@ApiModelProperty("生效的code和答案字典")
private Map<String, TreatmentRecord> validRecordValDict;
@ApiModelProperty("code和答案列表")
private Map<String, List<TreatmentRecord>> recordValDict;
public TreatmentRecordVO() {
}
public TreatmentRecordVO(PmsTreatment pmsTreatment) {
this.treatmentId = pmsTreatment.getId();
this.name = pmsTreatment.getName();
this.gender = pmsTreatment.getGender();
this.age = pmsTreatment.getAge();
this.birthDate = pmsTreatment.getBirthDate();
this.ethnicity = pmsTreatment.getEthnicity();
this.educationYears = pmsTreatment.getEducationYears();
this.phone = pmsTreatment.getPhone();
this.idCardType = pmsTreatment.getIdCardType();
this.idCard = pmsTreatment.getIdCard();
this.visitType = pmsTreatment.getVisitType();
this.visitNumber = pmsTreatment.getVisitNumber();
this.visitTime = pmsTreatment.getVisitTime();
this.dischargeTime = pmsTreatment.getDischargeTime();
this.doctor = pmsTreatment.getDoctor();
this.deptName = pmsTreatment.getDeptName();
this.diagnosisCode = pmsTreatment.getDiagnosisCode();
this.diagnosisName = pmsTreatment.getDiagnosisName();
this.status = pmsTreatment.getStatus();
this.organizationId = pmsTreatment.getTenantId();
}
}
@Data
public static class TreatmentRecord {
@ApiModelProperty("问题CODE")
private String questionCode;
@ApiModelProperty("答案")
private List<String> answer;
@ApiModelProperty("数据来源类型")
private String sourceType;
@ApiModelProperty("数据来源ID")
private String sourceId;
@ApiModelProperty("发生时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
private Date time;
@JsonIgnore
private String answerString;
@ApiModelProperty("生效值")
private boolean valid;
public List<String> getAnswer() {
if (StrUtil.isEmpty(answerString)) {
return Collections.emptyList();
}
return StrUtil.split(answerString, UserConstants.ANSWER_JOIN_STRING);
}
}
}

6
acupuncture-system/src/main/java/com/acupuncture/system/persist/dao/PmsPatientDao.java

@ -1,7 +1,10 @@
package com.acupuncture.system.persist.dao;
import com.acupuncture.system.domain.dto.PmsPatientDto;
import com.acupuncture.system.domain.po.PmsPatient;
import com.acupuncture.system.domain.vo.PmsPatientVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.core.parameters.P;
import java.util.List;
@ -13,6 +16,7 @@ import java.util.List;
*/
public interface PmsPatientDao {
List<PmsPatientVo.PatientResult> query(PmsPatientDto.PatientQuery dto);
List<PmsPatientVo.PatientResult> query(@Param("query") PmsPatientDto.PatientQuery query);
void batchInsert(@Param("pmsPatientList") List<PmsPatient> pmsPatientList);
}

26
acupuncture-system/src/main/java/com/acupuncture/system/persist/dao/PmsTreatmentDao.java

@ -0,0 +1,26 @@
package com.acupuncture.system.persist.dao;
import com.acupuncture.system.domain.dto.PmsTreatmentDto;
import com.acupuncture.system.domain.po.PmsTreatmentRecord;
import com.acupuncture.system.domain.vo.PmsTreatmentVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Author zzc
* @Package com.acupuncture.system.persist.dao
* @Date 2025/2/10 17:55
* @description:
*/
public interface PmsTreatmentDao {
List<PmsTreatmentVo.TreatmentVO> query(@Param("query") PmsTreatmentDto.TreatmentQueryDTO query);
void batchInsertRecord(List<PmsTreatmentRecord> subList);
List<PmsTreatmentVo.TreatmentRecord> selectRecord(@Param("treatmentId") Long treatmentId,
@Param("codeList") List<String> codeList);
// void batchInsert(@Param("pmsPatientList") List<PmsPatient> pmsPatientList);
}

8
acupuncture-system/src/main/java/com/acupuncture/system/service/PmsPatientService.java

@ -4,7 +4,10 @@ import com.acupuncture.common.annotation.DataSource;
import com.acupuncture.common.enums.DataSourceType;
import com.acupuncture.system.domain.dto.PmsPatientDto;
import com.acupuncture.system.domain.vo.PmsPatientVo;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
@ -20,7 +23,7 @@ public interface PmsPatientService {
* @param dto
* @return
*/
int add(PmsPatientDto.PatientAdd dto);
Long add(PmsPatientDto.PatientAdd dto);
/**
* 修改患者信息
@ -43,5 +46,8 @@ public interface PmsPatientService {
*/
List<PmsPatientVo.PatientResult> query(PmsPatientDto.PatientQuery dto);
void exportPatient(HttpServletResponse response, PmsPatientDto.PatientQuery dto);
void importPatient(MultipartFile file) throws IOException;
}

44
acupuncture-system/src/main/java/com/acupuncture/system/service/PmsTreatmentService.java

@ -0,0 +1,44 @@
package com.acupuncture.system.service;
import com.acupuncture.system.domain.dto.PmsTreatmentDto;
import com.acupuncture.system.domain.vo.PmsTreatmentVo;
import java.util.List;
/**
* @Author zzc
* @Package com.acupuncture.system.service
* @Date 2025/2/11 14:55
* @description:
*/
public interface PmsTreatmentService {
/**
* 添加诊疗档案
* @param dto
*/
void addTreatment(PmsTreatmentDto.TreatmentAdd dto);
/**
* 修改诊疗档案
* @param dto
*/
void updateTreatment(PmsTreatmentDto.TreatmentUpdateDTO dto);
/**
* 删除诊疗档案
* @param idList
*/
void deleteTreatment(List<Long> idList);
/**
* 查询诊疗档案
* @param queryDTO
* @return
*/
List<PmsTreatmentVo.TreatmentVO> listTreatment(PmsTreatmentDto.TreatmentQueryDTO queryDTO);
void saveAidRecord(PmsTreatmentDto.SaveAidRecord dto);
PmsTreatmentVo.TreatmentRecordVO queryRecord(Long treatmentId, List<String> codeList);
}

147
acupuncture-system/src/main/java/com/acupuncture/system/service/impl/PmsPatientServiceImpl.java

@ -1,7 +1,17 @@
package com.acupuncture.system.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.IdcardUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.pinyin.PinyinUtil;
import cn.hutool.poi.excel.BigExcelWriter;
import cn.hutool.poi.excel.ExcelUtil;
import com.acupuncture.common.exception.base.BaseException;
import com.acupuncture.common.utils.ExceptionUtil;
import com.acupuncture.common.utils.SecurityUtils;
import com.acupuncture.system.domain.dto.PmsPatientDto;
import com.acupuncture.system.domain.po.PmsPatient;
@ -10,13 +20,20 @@ import com.acupuncture.system.domain.vo.PmsPatientVo;
import com.acupuncture.system.persist.dao.PmsPatientDao;
import com.acupuncture.system.persist.mapper.PmsPatientMapper;
import com.acupuncture.system.service.PmsPatientService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author zzc
@ -32,16 +49,19 @@ public class PmsPatientServiceImpl implements PmsPatientService {
private PmsPatientMapper pmsPatientMapper;
@Resource
private PmsPatientDao pmsPatientDao;
@Value("${file.PatientTemplate}")
private String patientTemplate;
@Override
public int add(PmsPatientDto.PatientAdd dto) {
public Long add(PmsPatientDto.PatientAdd dto) {
PmsPatient pmsPatient = BeanUtil.copyProperties(dto, PmsPatient.class);
pmsPatient.setId(IdUtil.getSnowflakeNextId());
pmsPatient.setCreateBy(SecurityUtils.getUsername());
pmsPatient.setDelFlag((byte) 0);
pmsPatient.setCreateTime(new Date());
pmsPatient.setTenantId(SecurityUtils.getTenantId());
return pmsPatientMapper.insertSelective(pmsPatient);
pmsPatientMapper.insertSelective(pmsPatient);
return pmsPatient.getId();
}
@Override
@ -65,4 +85,127 @@ public class PmsPatientServiceImpl implements PmsPatientService {
public List<PmsPatientVo.PatientResult> query(PmsPatientDto.PatientQuery dto) {
return pmsPatientDao.query(dto);
}
@Override
public void exportPatient(HttpServletResponse response, PmsPatientDto.PatientQuery dto) {
List<PmsPatientVo.PatientResult> patientList = query(dto);
if (CollectionUtil.isEmpty(patientList)) {
throw new BaseException("暂无数据");
}
BigExcelWriter writer = new BigExcelWriter(patientTemplate, "");
int row = 0;
for (int i = 0; i < patientList.size(); i++) {
row += 1;
writer.writeCellValue(0, row, DateUtil.format(patientList.get(i).getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
writer.writeCellValue(1, row, patientList.get(i).getName());
writer.writeCellValue(2, row, patientList.get(i).getGender() == null ? "未知" : patientList.get(i).getGender() == 0 ? "男" : "女");
writer.writeCellValue(3, row, DateUtil.format(patientList.get(i).getBirthDate(), "yyyy-MM-dd"));
writer.writeCellValue(4, row, patientList.get(i).getEthnicity());
writer.writeCellValue(5, row, patientList.get(i).getEducationYears());
writer.writeCellValue(6, row, patientList.get(i).getPhone());
Integer idCardType = patientList.get(i).getIdCardType();
if (idCardType != null) {
switch (idCardType) {
case 0:
writer.writeCellValue(7, row, "身份证");
break;
case 1:
writer.writeCellValue(7, row, "护照或外国人永居证");
break;
case 2:
writer.writeCellValue(7, row, "港澳居民来往内地通行证");
break;
case 3:
writer.writeCellValue(7, row, "其他");
}
}
writer.writeCellValue(8, row, patientList.get(i).getIdCard());
Integer source = patientList.get(i).getSource();
if (source != null) {
switch (source) {
case 0:
writer.writeCellValue(9, row, "筛查");
break;
case 1:
writer.writeCellValue(9, row, "录入");
break;
case 2:
writer.writeCellValue(9, row, "HIS");
}
}
writer.writeCellValue(10, row, patientList.get(i).getCurrentIllnessHistory());
}
String filename = StrUtil.format("患者档案-{}.xlsx", DateUtil.date().toString("yyyyMMdd"));
//response为HttpServletResponse对象
response.setContentType("application/vnd.ms-excel;charset=utf-8");
//test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
response.setHeader("Content-Disposition", "attachment;filename=" + filename);
ServletOutputStream out = null;
try {
out = response.getOutputStream();
writer.flush(out);
} catch (
IOException e) {
e.printStackTrace();
} finally {
// 关闭writer,释放内存
writer.close();
//此处记得关闭输出Servlet流
IoUtil.close(out);
}
}
@Override
public void importPatient(MultipartFile file) throws IOException {
//读取excel
List<PmsPatient> pmsPatientList = CollectionUtil.newArrayList();
ExcelUtil.readBySax(file.getInputStream(), 0, (sheetIndex, rowIndex, rowList) -> {
//中铝新材料有限公司电解厂2024年度职工健康体检统计表(非高温)
//序号 姓名 性别 出生日期 身份证号 婚姻状况 联系电话 部门 工号 工种 民族 国籍 防护措施 总工龄(年) 总工龄(月) 接害工龄(年) 接害工龄(月) 体检类别
try {
if (rowIndex < 1) {
return;
}
PmsPatient patient = new PmsPatient();
patient.setName(rowList.get(1).toString());
patient.setGender(rowList.get(2).toString().trim().equals("男") ? (byte) 0 : (byte) 1);
patient.setPinyinFull(PinyinUtil.getPinyin(patient.getName(), ""));
patient.setPinyinSimple(PinyinUtil.getFirstLetter(patient.getName(), ""));
patient.setBirthDate(DateUtil.parse(rowList.get(3).toString()));
patient.setEthnicity(rowList.get(4).toString());
patient.setEducationYears(Integer.parseInt(rowList.get(5).toString()));
patient.setPhone(rowList.get(6).toString());
patient.setIdCardType(rowList.get(7).toString().trim().equals("身份证") ? (byte) 0 : rowList.get(7).toString().trim().equals("护照或外国人永居证") ? (byte) 1: rowList.get(7).toString().trim().equals("港澳居民来往内地通行证") ? (byte) 2 : rowList.get(7).toString().trim().equals("台湾居民来往大陆通行证") ? (byte) 3 : (byte) 4);
patient.setIdCard(rowList.get(8).toString());
patient.setSource(rowList.get(9).toString().trim().equals("筛查")? (byte) 0 : rowList.get(9).toString().trim().equals("录入")? (byte) 1 : (byte) 2);
patient.setCurrentIllnessHistory(rowList.get(10).toString());
patient.setCreateBy(SecurityUtils.getUsername());
patient.setId(IdUtil.getSnowflakeNextId());
patient.setTenantId(SecurityUtils.getTenantId());
patient.setDelFlag((byte) 0);
patient.setCreateTime(new Date());
pmsPatientList.add(patient);
} catch (Exception e) {
e.printStackTrace();
throw new BaseException(StrUtil.format("导入患者信息错误:sheet:{},row:{}, {}",
sheetIndex + 1, rowIndex + 1, ExceptionUtil.getExceptionMessage(e)));
}
});
if (CollectionUtil.isNotEmpty(pmsPatientList)) {
//批量插入
batchSave(pmsPatientList);
}
}
public Integer batchSave(List<PmsPatient> list) {
int max = 2000;
for (int start = 0; start < list.size(); start += max) {
pmsPatientDao.batchInsert(list.subList(start,
start + (Math.min(list.size() - start, max)))
);
}
return list.size();
}
}

173
acupuncture-system/src/main/java/com/acupuncture/system/service/impl/PmsTreatmentServiceImpl.java

@ -0,0 +1,173 @@
package com.acupuncture.system.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.acupuncture.common.exception.base.BaseException;
import com.acupuncture.common.utils.SecurityUtils;
import com.acupuncture.system.domain.dto.PmsPatientDto;
import com.acupuncture.system.domain.dto.PmsTreatmentDto;
import com.acupuncture.system.domain.po.*;
import com.acupuncture.system.domain.vo.PmsTreatmentVo;
import com.acupuncture.system.persist.dao.PmsTreatmentDao;
import com.acupuncture.system.persist.mapper.PmsPatientMapper;
import com.acupuncture.system.persist.mapper.PmsTreatmentMapper;
import com.acupuncture.system.persist.mapper.PmsTreatmentRecordMapper;
import com.acupuncture.system.service.PmsPatientService;
import com.acupuncture.system.service.PmsTreatmentService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Author zzc
* @Package com.acupuncture.system.service.impl
* @Date 2025/2/11 14:55
* @description:
*/
@Service
public class PmsTreatmentServiceImpl implements PmsTreatmentService {
@Resource
private PmsTreatmentMapper treatmentMapper;
@Resource
private PmsPatientMapper pmsPatientMapper;
@Resource
private PmsPatientService pmsPatientService;
@Resource
private PmsTreatmentDao pmsTreatmentDao;
@Resource
private PmsTreatmentRecordMapper pmsTreatmentRecordMapper;
@Override
public void addTreatment(PmsTreatmentDto.TreatmentAdd dto) {
PmsTreatment pmsTreatment = BeanUtil.copyProperties(dto, PmsTreatment.class);
PmsPatientExample pmsPatientExample = new PmsPatientExample();
pmsPatientExample.createCriteria().andDelFlagEqualTo((byte) 0).andIdCardEqualTo(dto.getIdCard());
List<PmsPatient> pmsPatients = pmsPatientMapper.selectByExample(pmsPatientExample);
if (CollectionUtil.isEmpty(pmsPatients)) {
Long patientId = pmsPatientService.add(BeanUtil.copyProperties(dto, PmsPatientDto.PatientAdd.class));
pmsTreatment.setPatientId(patientId);
}else {
PmsPatient pmsPatient = pmsPatients.get(0);
pmsTreatment.setPatientId(pmsPatient.getId());
}
pmsTreatment.setId(IdUtil.getSnowflakeNextId());
pmsTreatment.setDelFlag((byte) 0);
pmsTreatment.setCreateBy(SecurityUtils.getUsername());
pmsTreatment.setCreateTime(new Date());
treatmentMapper.insertSelective(pmsTreatment);
}
@Override
public void updateTreatment(PmsTreatmentDto.TreatmentUpdateDTO dto) {
PmsTreatment pmsTreatment = BeanUtil.copyProperties(dto, PmsTreatment.class);
pmsTreatment.setUpdateBy(SecurityUtils.getUsername());
pmsTreatment.setUpdateTime(new Date());
treatmentMapper.updateByPrimaryKeySelective(pmsTreatment);
}
@Override
public void deleteTreatment(List<Long> idList) {
PmsTreatmentExample pmsTreatmentExample = new PmsTreatmentExample();
pmsTreatmentExample.createCriteria().andIdIn(idList).andDelFlagEqualTo((byte) 0);
PmsTreatment pmsTreatment = new PmsTreatment();
pmsTreatment.setDelFlag((byte) 1);
treatmentMapper.updateByExampleSelective(pmsTreatment, pmsTreatmentExample);
}
@Override
public List<PmsTreatmentVo.TreatmentVO> listTreatment(PmsTreatmentDto.TreatmentQueryDTO queryDTO) {
return pmsTreatmentDao.query(queryDTO);
}
@Override
public void saveAidRecord(PmsTreatmentDto.SaveAidRecord dto) {
PmsTreatment pmsTreatment = validateTreatmentWhenModified(dto.getTreatmentId());
//验证问题和答案
if (CollectionUtil.isEmpty(dto.getCodeAndAnswerList())) {
return;
}
List<PmsTreatmentRecord> willSavedFirstAidRecordList = CollectionUtil.newArrayList();
for (PmsTreatmentDto.SaveAidRecord.CodeAndAnswer codeAndAnswer : dto.getCodeAndAnswerList()) {
if (StrUtil.isEmpty(codeAndAnswer.getAnswerString()) || "null".equals(codeAndAnswer.getAnswerString())) {
continue;
}
//添加记录表,查找之前的记录,删除后重新添加
PmsTreatmentRecordExample pmsTreatmentRecordExample = new PmsTreatmentRecordExample();
pmsTreatmentRecordExample.createCriteria().andDelFlagEqualTo((byte) 0).andTreatmentIdEqualTo(dto.getTreatmentId()).andQuestionCodeEqualTo(codeAndAnswer.getQuestionCode());
List<PmsTreatmentRecord> pmsTreatmentRecords = pmsTreatmentRecordMapper.selectByExample(pmsTreatmentRecordExample);
if (CollectionUtil.isNotEmpty(pmsTreatmentRecords)) {
pmsTreatmentRecords.forEach(e -> {
PmsTreatmentRecord willDeletedRecord = new PmsTreatmentRecord();
willDeletedRecord.setId(e.getId());
willDeletedRecord.setDelFlag((byte) 1);
pmsTreatmentRecordMapper.updateByPrimaryKeySelective(willDeletedRecord);
});
}
Date now = new Date();
PmsTreatmentRecord willSavedRecord = new PmsTreatmentRecord();
willSavedRecord.setId(IdUtil.getSnowflakeNextId());
willSavedRecord.setTreatmentId(dto.getTreatmentId());
willSavedRecord.setQuestionCode(codeAndAnswer.getQuestionCode());
willSavedRecord.setAnswer(codeAndAnswer.getAnswerString());
willSavedRecord.setTime(codeAndAnswer.getTime() == null ? now : codeAndAnswer.getTime());
willSavedRecord.setSourceId(dto.getSource());
willSavedRecord.setCreateTime(now);
willSavedRecord.setCreateBy(SecurityUtils.getUsername());
willSavedFirstAidRecordList.add(willSavedRecord);
}
//批量保存
batchSave(willSavedFirstAidRecordList);
}
public void batchSave(List<PmsTreatmentRecord> list) {
int max = 2000;
for (int start = 0; start < list.size(); start += max) {
pmsTreatmentDao.batchInsertRecord(list.subList(start, start + (Math.min(list.size() - start, max))));
}
}
private PmsTreatment validateTreatmentWhenModified(Long treatmentId) {
//1. 验证诊疗信息
PmsTreatment pmsTreatment = treatmentMapper.selectByPrimaryKey(treatmentId);
if (pmsTreatment == null) {
throw new BaseException("诊疗信息不存在");
}
return pmsTreatment;
}
@Override
public PmsTreatmentVo.TreatmentRecordVO queryRecord(Long treatmentId, List<String> codeList) {
PmsTreatment pmsTreatment = treatmentMapper.selectByPrimaryKey(treatmentId);
if (pmsTreatment == null) {
throw new BaseException("诊疗信息不存在");
}
PmsTreatmentVo.TreatmentRecordVO treatmentRecordVO = new PmsTreatmentVo.TreatmentRecordVO(pmsTreatment);
List<PmsTreatmentVo.TreatmentRecord> treatmentRecords = pmsTreatmentDao.selectRecord(treatmentId, codeList);
//按照code分组
Map<String, List<PmsTreatmentVo.TreatmentRecord>> recordVoMap = null;
if (CollectionUtil.isNotEmpty(treatmentRecords)) {
recordVoMap = treatmentRecords.stream().collect(Collectors.groupingBy(PmsTreatmentVo.TreatmentRecord::getQuestionCode, HashMap::new, Collectors.collectingAndThen(Collectors.toList(), list -> {
//SQL中已经提前做好排序,将第一个赋值为valid
list.get(0).setValid(true);
return list;
})));
} else {
recordVoMap = MapUtil.newHashMap();
}
treatmentRecordVO.setRecordValDict(recordVoMap);
return treatmentRecordVO;
}
}

42
acupuncture-system/src/main/resources/mapper/dao/PmsPatientDao.xml

@ -34,7 +34,7 @@
<if test="query.idCard != null and query.idCard != ''">
AND id_card = #{query.idCard}
</if>
<if test="query.source != null">
<if test="query.sourceId != null">
AND source = #{query.source}
</if>
<if test="query.startAge != null">
@ -52,4 +52,44 @@
</if>
</where>
</select>
<insert id="batchInsert">
replace into pms_patient(
id,
name,
pinyin_full,
pinyin_simple,
gender,
birth_date,
ethnicity,
education_years,
phone,
id_card_type,
id_card,
source,
current_illness_history,
create_by,
create_time
)
values
<foreach collection="pmsPatientList" item="patient" separator=",">
(
#{patient.id},
#{patient.name},
#{patient.pinyinFull},
#{patient.pinyinSimple},
#{patient.gender},
#{patient.birthDate},
#{patient.ethnicity},
#{patient.educationYears},
#{patient.phone},
#{patient.idCardType},
#{patient.idCard},
#{patient.source},
#{patient.currentIllnessHistory},
#{patient.createBy},
#{patient.createTime}
)
</foreach>
</insert>
</mapper>

107
acupuncture-system/src/main/resources/mapper/dao/PmsTreatmentDao.xml

@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.acupuncture.system.persist.dao.PmsTreatmentDao">
<select id="query" resultType="com.acupuncture.system.domain.vo.PmsTreatmentVo$TreatmentVO"
parameterType="com.acupuncture.system.domain.dto.PmsTreatmentDto$TreatmentQueryDTO">
select
id,
patient_id as patientId,
name,
gender,
age,
birth_date as birthDate,
ethnicity,
education_years as educationYears,
phone,
id_card_type as idCardType,
id_card as idCard,
visit_type as visitType,
visit_number as visitNumber,
visit_time as visitTime,
discharge_time as dischargeTime,
doctor,
dept_name as deptName,
diagnosis_code as diagnosisCode,
diagnosis_name as diagnosisName,
status,
create_by as createBy,
create_time as createTime
from pms_treatment
where del_flag = 0
<if test="query.keywords != null and query.keywords != ''">
AND (
name LIKE CONCAT('%', #{query.keywords}, '%')
OR phone LIKE CONCAT('%', #{query.keywords}, '%')
OR diagnosis_name LIKE CONCAT('%', #{query.keywords}, '%')
)
</if>
<if test="query.patientId != null">
AND patient_id = #{query.patientId}
</if>
<if test="query.gender != null">
AND gender = #{query.gender}
</if>
<if test="query.phone != null and query.phone != ''">
AND phone = #{query.phone}
</if>
<if test="query.visitType != null">
AND visit_type = #{query.visitType}
</if>
<if test="query.startAge != null">
AND age &gt;= #{query.startAge}
</if>
<if test="query.endAge != null">
AND age &lt;= #{query.startAge}
</if>
</select>
<insert id="batchInsertRecord">
insert into pms_treatment_record
(
id,
treatment_id,
question_code,
answer,
time,
source_id,
create_by,
create_time
)
values
<foreach collection="list" item="item" index="index" separator="," open="" close="">
(
#{item.id},
#{item.treatmentId},
#{item.questionCode},
#{item.answer},
#{item.time},
#{item.sourceId},
#{item.createBy},
#{item.createTime}
)
</foreach>
</insert>
<select id="selectRecord" resultType="com.acupuncture.system.domain.vo.PmsTreatmentVo$TreatmentRecord">
select
id,
treatment_id as treatmentId,
question_code as questionCode,
answer as answerString,
time,
source_id as sourceId,
create_by as createBy,
create_time as createTime
from pms_treatment_record
where treatment_id = #{treatmentId}
<if test="codeList != null and codeList.size() > 0">
and question_code in
<foreach collection="codeList" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
order by source_id asc, id desc
</select>
</mapper>
Loading…
Cancel
Save