19 changed files with 1097 additions and 17 deletions
@ -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())); |
|||
} |
|||
} |
@ -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()); |
|||
} |
|||
|
|||
|
|||
} |
@ -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( |
|||
"汉族", |
|||
"蒙古族", |
|||
"回族", |
|||
"藏族", |
|||
"维吾尔族", |
|||
"苗族", |
|||
"彝族", |
|||
"壮族", |
|||
"布依族", |
|||
"朝鲜族", |
|||
"满族", |
|||
"侗族", |
|||
"瑶族", |
|||
"白族", |
|||
"土家族", |
|||
"哈尼族", |
|||
"哈萨克族", |
|||
"傣族", |
|||
"黎族", |
|||
"傈僳族", |
|||
"佤族", |
|||
"畲族", |
|||
"高山族", |
|||
"拉祜族", |
|||
"水族", |
|||
"东乡族", |
|||
"纳西族", |
|||
"景颇族", |
|||
"柯尔克孜族", |
|||
"土族", |
|||
"达斡尔族", |
|||
"仫佬族", |
|||
"羌族", |
|||
"布朗族", |
|||
"撒拉族", |
|||
"毛南族", |
|||
"仡佬族", |
|||
"锡伯族", |
|||
"阿昌族", |
|||
"普米族", |
|||
"塔吉克族", |
|||
"怒族", |
|||
"乌孜别克族", |
|||
"俄罗斯族", |
|||
"鄂温克族", |
|||
"崩龙族", |
|||
"保安族", |
|||
"裕固族", |
|||
"京族", |
|||
"塔塔尔族", |
|||
"独龙族", |
|||
"鄂伦春族", |
|||
"赫哲族", |
|||
"门巴族", |
|||
"珞巴族", |
|||
"基诺族" |
|||
); |
|||
} |
|||
} |
@ -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; |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
|||
} |
@ -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);
|
|||
} |
@ -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); |
|||
} |
@ -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; |
|||
} |
|||
} |
@ -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 >= #{query.startAge} |
|||
</if> |
|||
<if test="query.endAge != null"> |
|||
AND age <= #{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…
Reference in new issue