提交 30fe4858 authored 作者: luzhangjian's avatar luzhangjian

feat:病例相关接口

上级 33292030
package com.ebaiyihui.family.doctor.common.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class InsertPatientMedicalRecordDTO {
@ApiModelProperty("签约id")
@NotBlank(message = "签约id不能为空")
private String admId;
@NotBlank(message = "患者id不能为空")
@ApiModelProperty("患者id")
private String patientId;
@NotBlank(message = "主诉不能为空")
@ApiModelProperty("主诉")
private String mainSuit;
@NotBlank(message = "诊断不能为空")
@ApiModelProperty("诊断")
private String diagnosis;
@ApiModelProperty("现病史")
private String currentHistory;
@ApiModelProperty("既往史")
private String pastHistory;
@ApiModelProperty("过敏史")
private String allergyHistory;
@ApiModelProperty("其他病史")
private String othersHistory;
@ApiModelProperty("其他")
private String remark;
}
package com.ebaiyihui.family.doctor.common.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class InvalidMedicalRecordDTO {
@NotBlank(message = "病历ID不能为空")
@ApiModelProperty("病历ID")
private String id;
}
package com.ebaiyihui.family.doctor.common.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class UpdatePatientMedicalRecordDTO {
@ApiModelProperty("病历ID")
@NotBlank(message = "病历ID不能为空")
private String id;
@NotBlank(message = "主诉不能为空")
@ApiModelProperty("主诉")
private String mainSuit;
@NotBlank(message = "诊断不能为空")
@ApiModelProperty("诊断")
private String diagnosis;
@ApiModelProperty("现病史")
private String currentHistory;
@ApiModelProperty("既往史")
private String pastHistory;
@ApiModelProperty("过敏史")
private String allergyHistory;
@ApiModelProperty("其他病史")
private String othersHistory;
@ApiModelProperty("其他")
private String remark;
}
package com.ebaiyihui.family.doctor.common.vo;
import lombok.Data;
@Data
public class InsertPatientMedicalRecordVO {
/**
* 新增病历ID
*/
private String recordId;
}
package com.ebaiyihui.family.doctor.common.vo;
import lombok.Data;
import java.util.Date;
@Data
public class PatientMedicalRecordVO {
/**
* 主键
*/
private String id;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 问诊id
*/
private String admId;
/**
* 患者id
*/
private String patientId;
/**
* 主述
*/
private String mainSuit;
/**
* 诊断
*/
private String diagnosis;
/**
* 现病史
*/
private String currentHistory;
/**
* 既往史
*/
private String pastHistory;
/**
* 过敏史
*/
private String allergyHistory;
/**
* 其他病史
*/
private String othersHistory;
/**
* 其他
*/
private String remark;
/**
* 病例状态 1生效/0失效
*/
private Integer recordStatus;
/**
* 患者医生科室信息
*/
private InfoVo infoVo;
@Data
public static class InfoVo{
private String doctorId;
private String doctorName;
private String deptId;
private String deptName;
private String patientUserId;
private String patientName;
private String patientNo;
private String patientGender;
private String patientPhone;
private String patientCredNo;
};
}
package com.ebaiyihui.family.doctor.server.controller;
import com.ebaiyihui.family.doctor.common.dto.InsertPatientMedicalRecordDTO;
import com.ebaiyihui.family.doctor.common.dto.InvalidMedicalRecordDTO;
import com.ebaiyihui.family.doctor.common.dto.UpdatePatientMedicalRecordDTO;
import com.ebaiyihui.family.doctor.common.vo.InsertPatientMedicalRecordVO;
import com.ebaiyihui.family.doctor.common.vo.PatientMedicalRecordVO;
import com.ebaiyihui.family.doctor.server.service.PatientMedicalRecordService;
import com.ebaiyihui.framework.response.BaseResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
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 java.util.Objects;
@RestController
@RequestMapping("/medicalRecord")
@Api(tags = "患者病历API")
public class PatientMedicalRecordController {
@Autowired
private PatientMedicalRecordService patientMedicalRecordService;
@PostMapping("/insert")
@ApiOperation(value = "新建复诊病历", notes = "医生开具复诊病历")
public BaseResponse<InsertPatientMedicalRecordVO> insert(@RequestBody @Validated InsertPatientMedicalRecordDTO dto,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return BaseResponse.error(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
}
return patientMedicalRecordService.insertPatientMedicalRecord(dto);
}
@PostMapping("/update")
@ApiOperation(value = "修改复诊病历", notes = "医生修改复诊病历")
public BaseResponse<InsertPatientMedicalRecordVO> update(@RequestBody @Validated UpdatePatientMedicalRecordDTO dto,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return BaseResponse.error(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
}
return patientMedicalRecordService.updatePatientMedicalRecord(dto);
}
@PostMapping("/invalid")
@ApiOperation(value = "开具处方失效病历", notes = "开具处方失效病历")
public BaseResponse<Objects> invalid(@RequestBody @Validated InvalidMedicalRecordDTO dto,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return BaseResponse.error(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
}
return patientMedicalRecordService.invalidMedicalRecord(dto);
}
@PostMapping("/detail")
@ApiOperation(value = "复诊病历详情", notes = "复诊病历详情")
public BaseResponse<PatientMedicalRecordVO> detail(@RequestBody @Validated InvalidMedicalRecordDTO dto,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return BaseResponse.error(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
}
return patientMedicalRecordService.detailMedicalRecord(dto);
}
}
package com.ebaiyihui.family.doctor.server.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
@Data
@TableName(value = "patient_medical_record")
public class PatientMedicalRecordEntity {
/**
* 主键
*/
private String id;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 签约id
*/
private String admId;
/**
* 患者id
*/
private String patientId;
/**
* 主述
*/
private String mainSuit;
/**
* 诊断
*/
private String diagnosis;
/**
* 现病史
*/
private String currentHistory;
/**
* 既往史
*/
private String pastHistory;
/**
* 过敏史
*/
private String allergyHistory;
/**
* 其他病史
*/
private String othersHistory;
/**
* 其他
*/
private String remark;
/**
* 病例状态 1生效/0失效
*/
private Integer recordStatus;
}
package com.ebaiyihui.family.doctor.server.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ebaiyihui.family.doctor.server.entity.PatientMedicalRecordEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
@Mapper
public interface PatientMedicalRecordMapper extends BaseMapper<PatientMedicalRecordEntity> {
@Select("select * from patient_medical_record where id = #{id} and record_status = #{status}")
PatientMedicalRecordEntity getByIdAndStatus(String id, int status);
}
...@@ -18,4 +18,6 @@ import java.util.List; ...@@ -18,4 +18,6 @@ import java.util.List;
public interface PatientSignMapper extends BaseMapper<PatientSignEntity> { public interface PatientSignMapper extends BaseMapper<PatientSignEntity> {
List<ImInfoListResVo> queryImInfoList(ImInfoListDocReqDTO param); List<ImInfoListResVo> queryImInfoList(ImInfoListDocReqDTO param);
PatientSignEntity queryByAdmId(String admId);
} }
package com.ebaiyihui.family.doctor.server.service;
import com.ebaiyihui.family.doctor.common.dto.InsertPatientMedicalRecordDTO;
import com.ebaiyihui.family.doctor.common.dto.InvalidMedicalRecordDTO;
import com.ebaiyihui.family.doctor.common.dto.UpdatePatientMedicalRecordDTO;
import com.ebaiyihui.family.doctor.common.vo.InsertPatientMedicalRecordVO;
import com.ebaiyihui.family.doctor.common.vo.PatientMedicalRecordVO;
import com.ebaiyihui.framework.response.BaseResponse;
import java.util.Objects;
/**
* 患者病历Service
*/
public interface PatientMedicalRecordService {
BaseResponse<InsertPatientMedicalRecordVO> insertPatientMedicalRecord(InsertPatientMedicalRecordDTO dto);
BaseResponse<InsertPatientMedicalRecordVO> updatePatientMedicalRecord(UpdatePatientMedicalRecordDTO dto);
BaseResponse<Objects> invalidMedicalRecord(InvalidMedicalRecordDTO dto);
BaseResponse<PatientMedicalRecordVO> detailMedicalRecord(InvalidMedicalRecordDTO dto);
}
package com.ebaiyihui.family.doctor.server.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ebaiyihui.family.doctor.common.dto.InsertPatientMedicalRecordDTO;
import com.ebaiyihui.family.doctor.common.dto.InvalidMedicalRecordDTO;
import com.ebaiyihui.family.doctor.common.dto.UpdatePatientMedicalRecordDTO;
import com.ebaiyihui.family.doctor.common.vo.InsertPatientMedicalRecordVO;
import com.ebaiyihui.family.doctor.common.vo.PatientInfoVo;
import com.ebaiyihui.family.doctor.common.vo.PatientMedicalRecordVO;
import com.ebaiyihui.family.doctor.server.entity.PatientEntity;
import com.ebaiyihui.family.doctor.server.entity.PatientMedicalRecordEntity;
import com.ebaiyihui.family.doctor.server.entity.PatientSignEntity;
import com.ebaiyihui.family.doctor.server.exception.BusinessException;
import com.ebaiyihui.family.doctor.server.mapper.PatientMapper;
import com.ebaiyihui.family.doctor.server.mapper.PatientMedicalRecordMapper;
import com.ebaiyihui.family.doctor.server.mapper.PatientSignMapper;
import com.ebaiyihui.family.doctor.server.service.PatientMedicalRecordService;
import com.ebaiyihui.family.doctor.server.util.IDCardUtil;
import com.ebaiyihui.family.doctor.server.util.UUIDUtil;
import com.ebaiyihui.framework.response.BaseResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Objects;
@Service
@Slf4j
public class PatientMedicalRecordServiceImpl implements PatientMedicalRecordService {
@Autowired
private PatientMedicalRecordMapper patientMedicalRecordMapper;
@Autowired
private PatientMapper patientMapper;
@Autowired
private PatientSignMapper patientSignMapper;
@Override
public BaseResponse<InsertPatientMedicalRecordVO> insertPatientMedicalRecord(InsertPatientMedicalRecordDTO dto) {
log.info("医生开具复诊病历入参:{}", dto.toString());
PatientMedicalRecordEntity entity = new PatientMedicalRecordEntity();
BeanUtils.copyProperties(dto, entity);
entity.setId(UUIDUtil.getUUID());
entity.setRecordStatus(1);
patientMedicalRecordMapper.insert(entity);
InsertPatientMedicalRecordVO vo = new InsertPatientMedicalRecordVO();
vo.setRecordId(String.valueOf(entity.getId()));
return BaseResponse.success(vo);
}
@Override
public BaseResponse<InsertPatientMedicalRecordVO> updatePatientMedicalRecord(UpdatePatientMedicalRecordDTO dto) {
log.info("医生修改复诊病历入参:{}", dto.toString());
if (StringUtils.isEmpty(dto.getId())){
throw new BusinessException("修改xid不能为空");
}
PatientMedicalRecordEntity recordEntity = patientMedicalRecordMapper.getByIdAndStatus(dto.getId(),1);
if (ObjectUtil.isNull(recordEntity)){
throw new BusinessException("未找到该病历,或病例失效");
}
PatientMedicalRecordEntity entity = new PatientMedicalRecordEntity();
BeanUtils.copyProperties(dto, entity);
patientMedicalRecordMapper.updateById(entity);
InsertPatientMedicalRecordVO vo = new InsertPatientMedicalRecordVO();
vo.setRecordId(String.valueOf(entity.getId()));
return BaseResponse.success(vo);
}
@Override
public BaseResponse<Objects> invalidMedicalRecord(InvalidMedicalRecordDTO dto) {
log.info("开具处方失效病历入参:{}", dto.toString());
if (StringUtils.isEmpty(dto.getId())){
throw new BusinessException("病历id不能未空");
}
PatientMedicalRecordEntity recordEntity = patientMedicalRecordMapper.getByIdAndStatus(dto.getId(),1);
if (ObjectUtil.isNull(recordEntity)){
throw new BusinessException("未找到该病历,或病例失效");
}
PatientMedicalRecordEntity entity = new PatientMedicalRecordEntity();
entity.setId(dto.getId());
entity.setRecordStatus(0);
patientMedicalRecordMapper.updateById(entity);
return BaseResponse.success();
}
@Override
public BaseResponse<PatientMedicalRecordVO> detailMedicalRecord(InvalidMedicalRecordDTO dto) {
log.info("病历详情入参:{}", dto.toString());
if (StringUtils.isEmpty(dto.getId())){
throw new BusinessException("病历id不能未空");
}
PatientMedicalRecordEntity entity = patientMedicalRecordMapper.getByIdAndStatus(dto.getId(),1);
if (ObjectUtil.isNull(entity)){
throw new BusinessException("未找到该病历,或病例失效");
}
PatientMedicalRecordVO vo = new PatientMedicalRecordVO();
BeanUtils.copyProperties(entity, vo);
// 查询患者,医生,科室信息
PatientMedicalRecordVO.InfoVo infoVo = new PatientMedicalRecordVO.InfoVo();
PatientEntity patientEntity = patientMapper.selectById(entity.getPatientId());
if (ObjectUtil.isNotNull(patientEntity)){
infoVo.setPatientName(patientEntity.getPatientName());
infoVo.setPatientGender(String.valueOf(patientEntity.getGender()));
infoVo.setPatientNo(patientEntity.getCredNo());
infoVo.setPatientPhone(patientEntity.getPhone());
infoVo.setPatientUserId(patientEntity.getUserId());
infoVo.setPatientCredNo(patientEntity.getCredNo());
}
PatientSignEntity patientSignEntity = patientSignMapper.queryByAdmId(entity.getAdmId());
if (ObjectUtil.isNotNull(patientSignEntity)){
infoVo.setDeptId(String.valueOf(patientSignEntity.getDeptId()));
infoVo.setDeptName(patientSignEntity.getDeptName());
infoVo.setDoctorId(String.valueOf(patientSignEntity.getDoctorId()));
infoVo.setDoctorName(patientSignEntity.getDoctorName());
}
vo.setInfoVo(infoVo);
return BaseResponse.success(vo);
}
}
...@@ -24,20 +24,25 @@ ...@@ -24,20 +24,25 @@
order by ps.create_time asc order by ps.create_time asc
LIMIT #{pageNum}, #{pageSize} LIMIT #{pageNum}, #{pageSize}
</select> </select>
<select id="queryByAdmId" resultType="com.ebaiyihui.family.doctor.server.entity.PatientSignEntity">
select *
from patient_sign ps
where ps.adm_id = #{admId}
</select>
<!-- <select id="getImInfoTotal" parameterType="com.ebaiyihui.family.doctor.common.dto.ImInfoListDocReqDTO"--> <!-- <select id="getImInfoTotal" parameterType="com.ebaiyihui.family.doctor.common.dto.ImInfoListDocReqDTO"-->
<!-- resultType="java.lang.Integer">--> <!-- resultType="java.lang.Integer">-->
<!-- select count(*)--> <!-- select count(*)-->
<!-- from patient_sign ps--> <!-- from patient_sign ps-->
<!-- where ps.doctor_id=#{doctorId}--> <!-- where ps.doctor_id=#{doctorId}-->
<!-- and ps.sign_status in(1,2) and ps.status = 2--> <!-- and ps.sign_status in(1,2) and ps.status = 2-->
<!-- <if test="keyWord!=null and keyWord!=''">--> <!-- <if test="keyWord!=null and keyWord!=''">-->
<!-- and ps.patient_name like concat('%',#{keyWord},'%')--> <!-- and ps.patient_name like concat('%',#{keyWord},'%')-->
<!-- </if>--> <!-- </if>-->
<!-- <if test="appCode!=null and appCode!=''">--> <!-- <if test="appCode!=null and appCode!=''">-->
<!-- and ps.app_code=#{appCode}--> <!-- and ps.app_code=#{appCode}-->
<!-- </if>--> <!-- </if>-->
<!-- </select>--> <!-- </select>-->
</mapper> </mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论