From 270d0a9d64198dddfec300567799bf0d8f763be1 Mon Sep 17 00:00:00 2001 From: zzc Date: Tue, 11 Feb 2025 16:43:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=8A=E7=96=97=E6=A1=A3=E6=A1=88=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- acupuncture-admin/pom.xml | 6 + .../controller/web/PmsPatientController.java | 31 +++- .../web/PmsTreatmentController.java | 79 ++++++++ .../web/controller/web/SysController.java | 33 ++++ .../src/main/resources/application-stage.yml | 4 +- .../common/constant/UserConstants.java | 5 + .../acupuncture/common/utils/NotionUtils.java | 73 ++++++++ acupuncture-system/pom.xml | 6 + .../system/domain/dto/PmsPatientDto.java | 18 +- .../system/domain/dto/PmsTreatmentDto.java | 170 +++++++++++++++++ .../system/domain/vo/PmsTreatmentVo.java | 136 ++++++++++++++ .../system/persist/dao/PmsPatientDao.java | 6 +- .../system/persist/dao/PmsTreatmentDao.java | 26 +++ .../system/service/PmsPatientService.java | 8 +- .../system/service/PmsTreatmentService.java | 44 +++++ .../service/impl/PmsPatientServiceImpl.java | 147 ++++++++++++++- .../service/impl/PmsTreatmentServiceImpl.java | 173 ++++++++++++++++++ .../resources/mapper/dao/PmsPatientDao.xml | 42 ++++- .../resources/mapper/dao/PmsTreatmentDao.xml | 107 +++++++++++ 19 files changed, 1097 insertions(+), 17 deletions(-) create mode 100644 acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/PmsTreatmentController.java create mode 100644 acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/SysController.java create mode 100644 acupuncture-common/src/main/java/com/acupuncture/common/utils/NotionUtils.java create mode 100644 acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/PmsTreatmentDto.java create mode 100644 acupuncture-system/src/main/java/com/acupuncture/system/domain/vo/PmsTreatmentVo.java create mode 100644 acupuncture-system/src/main/java/com/acupuncture/system/persist/dao/PmsTreatmentDao.java create mode 100644 acupuncture-system/src/main/java/com/acupuncture/system/service/PmsTreatmentService.java create mode 100644 acupuncture-system/src/main/java/com/acupuncture/system/service/impl/PmsTreatmentServiceImpl.java create mode 100644 acupuncture-system/src/main/resources/mapper/dao/PmsTreatmentDao.xml diff --git a/acupuncture-admin/pom.xml b/acupuncture-admin/pom.xml index f9786c87..4663ac2f 100644 --- a/acupuncture-admin/pom.xml +++ b/acupuncture-admin/pom.xml @@ -28,6 +28,12 @@ io.springfox springfox-boot-starter + + + swagger-annotations + io.swagger + + diff --git a/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/PmsPatientController.java b/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/PmsPatientController.java index 395f5bd1..27e3a02f 100644 --- a/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/PmsPatientController.java +++ b/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 add(@RequestBody @Validated PmsPatientDto.PatientAdd dto){ - pmsPatientService.add(dto); - return JsonResponse.ok(); + public JsonResponse add(@RequestBody @Validated PmsPatientDto.PatientAdd dto){ + return JsonResponse.ok(pmsPatientService.add(dto)); } @ApiOperation("修改患者信息") @PostMapping("/upd") public JsonResponse upd(@RequestBody @Validated PmsPatientDto.PatientUpd dto){ - pmsPatientService.upd(dto); - return JsonResponse.ok(); + return JsonResponse.ok(pmsPatientService.upd(dto)); } @ApiOperation("删除患者信息") @PostMapping("/del") public JsonResponse 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> query(@RequestBody @Validated BaseDto 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 exportPatient(HttpServletResponse response, @RequestBody @Validated PmsPatientDto.PatientQuery dto){ + pmsPatientService.exportPatient(response, dto); + return JsonResponse.ok(); + } + + @ApiOperation("导入患者信息") + @PostMapping("/import") + public JsonResponse importPatient(MultipartFile file) throws IOException{ + pmsPatientService.importPatient(file); + return JsonResponse.ok(); + } + } diff --git a/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/PmsTreatmentController.java b/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/PmsTreatmentController.java new file mode 100644 index 00000000..8d8c06fa --- /dev/null +++ b/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 addTreatment(@RequestBody @Validated PmsTreatmentDto.TreatmentAdd dto){ + treatmentService.addTreatment(dto); + return JsonResponse.ok(); + } + + @ApiOperation("修改诊疗档案") + @PostMapping("/upd") + public JsonResponse updateTreatment(@RequestBody @Validated PmsTreatmentDto.TreatmentUpdateDTO dto){ + treatmentService.updateTreatment(dto); + return JsonResponse.ok(); + } + + @ApiOperation("删除诊疗档案") + @PostMapping("/del") + public JsonResponse deleteTreatment(@RequestBody @Validated PmsTreatmentDto.DeleteDto dto){ + treatmentService.deleteTreatment(dto.getIdList()); + return JsonResponse.ok(); + } + + @ApiOperation("查询诊疗档案") + @PostMapping("/list") + public JsonResponse> listTreatment(@RequestBody @Validated BaseDto 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 saveAidRecord(@RequestBody @Validated PmsTreatmentDto.SaveAidRecord dto){ + treatmentService.saveAidRecord(dto); + return JsonResponse.ok(); + } + + @ApiOperation("查询诊疗档案数据") + @PostMapping("/queryRecord") + public JsonResponse queryRecord(@RequestBody @Validated PmsTreatmentDto.QueryRecord dto){ + return JsonResponse.ok(treatmentService.queryRecord(dto.getTreatmentId(), dto.getCodeList())); + } +} diff --git a/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/SysController.java b/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/SysController.java new file mode 100644 index 00000000..bef1d95f --- /dev/null +++ b/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> listNation() { + return JsonResponse.ok(NotionUtils.getNotionList()); + } + + +} diff --git a/acupuncture-admin/src/main/resources/application-stage.yml b/acupuncture-admin/src/main/resources/application-stage.yml index f108e725..392aafe2 100644 --- a/acupuncture-admin/src/main/resources/application-stage.yml +++ b/acupuncture-admin/src/main/resources/application-stage.yml @@ -58,4 +58,6 @@ spring: merge-sql: true wall: config: - multi-statement-allow: true \ No newline at end of file + multi-statement-allow: true +file: + PatientTemplate: C:\Users\zzc16\Desktop\PatientTemplate.xlsx \ No newline at end of file diff --git a/acupuncture-common/src/main/java/com/acupuncture/common/constant/UserConstants.java b/acupuncture-common/src/main/java/com/acupuncture/common/constant/UserConstants.java index 537ba32c..f6dc2955 100644 --- a/acupuncture-common/src/main/java/com/acupuncture/common/constant/UserConstants.java +++ b/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 = "!@#"; } diff --git a/acupuncture-common/src/main/java/com/acupuncture/common/utils/NotionUtils.java b/acupuncture-common/src/main/java/com/acupuncture/common/utils/NotionUtils.java new file mode 100644 index 00000000..77fcc77d --- /dev/null +++ b/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 getNotionList(){ + return CollectionUtil.newArrayList( + "汉族", + "蒙古族", + "回族", + "藏族", + "维吾尔族", + "苗族", + "彝族", + "壮族", + "布依族", + "朝鲜族", + "满族", + "侗族", + "瑶族", + "白族", + "土家族", + "哈尼族", + "哈萨克族", + "傣族", + "黎族", + "傈僳族", + "佤族", + "畲族", + "高山族", + "拉祜族", + "水族", + "东乡族", + "纳西族", + "景颇族", + "柯尔克孜族", + "土族", + "达斡尔族", + "仫佬族", + "羌族", + "布朗族", + "撒拉族", + "毛南族", + "仡佬族", + "锡伯族", + "阿昌族", + "普米族", + "塔吉克族", + "怒族", + "乌孜别克族", + "俄罗斯族", + "鄂温克族", + "崩龙族", + "保安族", + "裕固族", + "京族", + "塔塔尔族", + "独龙族", + "鄂伦春族", + "赫哲族", + "门巴族", + "珞巴族", + "基诺族" + ); + } +} diff --git a/acupuncture-system/pom.xml b/acupuncture-system/pom.xml index 601b0140..8c194b0a 100644 --- a/acupuncture-system/pom.xml +++ b/acupuncture-system/pom.xml @@ -31,6 +31,12 @@ hutool-all 5.8.24 + + + io.github.biezhi + TinyPinyin + 2.0.3.RELEASE + io.swagger swagger-annotations diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/PmsPatientDto.java b/acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/PmsPatientDto.java index ad37dcba..c7163006 100644 --- a/acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/PmsPatientDto.java +++ b/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 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 currentIllnessHistory; + + public String getCurrentIllnessHistory() { + return currentIllnessHistory.stream().collect(Collectors.joining(",")); + } } @Data diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/PmsTreatmentDto.java b/acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/PmsTreatmentDto.java new file mode 100644 index 00000000..7efc710b --- /dev/null +++ b/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 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 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 codeAndAnswerList; + @ApiModelProperty("数据来源") + private String source; + + } + + @Data + public static class QueryRecord{ + @NotNull(message = "诊疗Id不能为空") + @ApiModelProperty("诊疗Id") + private Long treatmentId; + @ApiModelProperty("code集合") + private List codeList; + } +} diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/domain/vo/PmsTreatmentVo.java b/acupuncture-system/src/main/java/com/acupuncture/system/domain/vo/PmsTreatmentVo.java new file mode 100644 index 00000000..b580069f --- /dev/null +++ b/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 validRecordValDict; + @ApiModelProperty("code和答案列表") + private Map> 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 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 getAnswer() { + if (StrUtil.isEmpty(answerString)) { + return Collections.emptyList(); + } + return StrUtil.split(answerString, UserConstants.ANSWER_JOIN_STRING); + } + } +} diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/persist/dao/PmsPatientDao.java b/acupuncture-system/src/main/java/com/acupuncture/system/persist/dao/PmsPatientDao.java index a5ef1f96..eb39e54d 100644 --- a/acupuncture-system/src/main/java/com/acupuncture/system/persist/dao/PmsPatientDao.java +++ b/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 query(PmsPatientDto.PatientQuery dto); + List query(@Param("query") PmsPatientDto.PatientQuery query); + void batchInsert(@Param("pmsPatientList") List pmsPatientList); } diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/persist/dao/PmsTreatmentDao.java b/acupuncture-system/src/main/java/com/acupuncture/system/persist/dao/PmsTreatmentDao.java new file mode 100644 index 00000000..fe894345 --- /dev/null +++ b/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 query(@Param("query") PmsTreatmentDto.TreatmentQueryDTO query); + + void batchInsertRecord(List subList); + + List selectRecord(@Param("treatmentId") Long treatmentId, + @Param("codeList") List codeList); + +// void batchInsert(@Param("pmsPatientList") List pmsPatientList); +} diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/service/PmsPatientService.java b/acupuncture-system/src/main/java/com/acupuncture/system/service/PmsPatientService.java index beea39b1..68ae3e08 100644 --- a/acupuncture-system/src/main/java/com/acupuncture/system/service/PmsPatientService.java +++ b/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 query(PmsPatientDto.PatientQuery dto); + void exportPatient(HttpServletResponse response, PmsPatientDto.PatientQuery dto); + + void importPatient(MultipartFile file) throws IOException; } diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/service/PmsTreatmentService.java b/acupuncture-system/src/main/java/com/acupuncture/system/service/PmsTreatmentService.java new file mode 100644 index 00000000..1e872ed4 --- /dev/null +++ b/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 idList); + + /** + * 查询诊疗档案 + * @param queryDTO + * @return + */ + List listTreatment(PmsTreatmentDto.TreatmentQueryDTO queryDTO); + + void saveAidRecord(PmsTreatmentDto.SaveAidRecord dto); + + PmsTreatmentVo.TreatmentRecordVO queryRecord(Long treatmentId, List codeList); +} diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/PmsPatientServiceImpl.java b/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/PmsPatientServiceImpl.java index 94580e08..aa4a7969 100644 --- a/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/PmsPatientServiceImpl.java +++ b/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 query(PmsPatientDto.PatientQuery dto) { return pmsPatientDao.query(dto); } + + @Override + public void exportPatient(HttpServletResponse response, PmsPatientDto.PatientQuery dto) { + List 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 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 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(); + } + } diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/PmsTreatmentServiceImpl.java b/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/PmsTreatmentServiceImpl.java new file mode 100644 index 00000000..a1c7dd8e --- /dev/null +++ b/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 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 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 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 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 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 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 codeList) { + PmsTreatment pmsTreatment = treatmentMapper.selectByPrimaryKey(treatmentId); + if (pmsTreatment == null) { + throw new BaseException("诊疗信息不存在"); + } + PmsTreatmentVo.TreatmentRecordVO treatmentRecordVO = new PmsTreatmentVo.TreatmentRecordVO(pmsTreatment); + List treatmentRecords = pmsTreatmentDao.selectRecord(treatmentId, codeList); + //按照code分组 + Map> 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; + } +} diff --git a/acupuncture-system/src/main/resources/mapper/dao/PmsPatientDao.xml b/acupuncture-system/src/main/resources/mapper/dao/PmsPatientDao.xml index 59b6245f..40954fc3 100644 --- a/acupuncture-system/src/main/resources/mapper/dao/PmsPatientDao.xml +++ b/acupuncture-system/src/main/resources/mapper/dao/PmsPatientDao.xml @@ -34,7 +34,7 @@ AND id_card = #{query.idCard} - + AND source = #{query.source} @@ -52,4 +52,44 @@ + + + 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 + + ( + #{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} + ) + + diff --git a/acupuncture-system/src/main/resources/mapper/dao/PmsTreatmentDao.xml b/acupuncture-system/src/main/resources/mapper/dao/PmsTreatmentDao.xml new file mode 100644 index 00000000..f8a9ee05 --- /dev/null +++ b/acupuncture-system/src/main/resources/mapper/dao/PmsTreatmentDao.xml @@ -0,0 +1,107 @@ + + + + + + + + insert into pms_treatment_record + ( + id, + treatment_id, + question_code, + answer, + time, + source_id, + create_by, + create_time + ) + values + + ( + #{item.id}, + #{item.treatmentId}, + #{item.questionCode}, + #{item.answer}, + #{item.time}, + #{item.sourceId}, + #{item.createBy}, + #{item.createTime} + ) + + + + +