病人信息
This commit is contained in:
@@ -0,0 +1,168 @@
|
||||
package com.openhis.web.patientmanage.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.core.common.enums.AssignSeqEnum;
|
||||
import com.core.common.utils.AssignSeqUtil;
|
||||
import com.core.common.utils.ChineseConvertUtils;
|
||||
import com.core.common.utils.MessageUtils;
|
||||
import com.core.common.utils.StringUtils;
|
||||
import com.core.common.utils.bean.BeanUtils;
|
||||
import com.openhis.administration.domain.Patient;
|
||||
import com.openhis.administration.service.IPatientService;
|
||||
import com.openhis.common.constant.PromptMsgConstant;
|
||||
import com.openhis.web.patientmanage.dto.PatientInformationDto;
|
||||
import com.openhis.web.patientmanage.mapper.PatientManageMapper;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 病人管理——病人信息
|
||||
*
|
||||
* @author liuhr
|
||||
* @date 2025/2/22
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/patientmanage/information")
|
||||
@Slf4j
|
||||
public class PatientInformationController {
|
||||
|
||||
@Autowired
|
||||
private IPatientService patientService;
|
||||
|
||||
@Autowired(required = false)
|
||||
private AssignSeqUtil assignSeqUtil;
|
||||
|
||||
@Autowired(required = false)
|
||||
PatientManageMapper patientManageMapper;
|
||||
|
||||
@Autowired(required = false)
|
||||
StringUtils stringUtils;
|
||||
|
||||
// todo 暂且机构ID写死,后续从登录里取得
|
||||
private final Long organizationId = 91L;
|
||||
|
||||
/**
|
||||
* 添加病人信息
|
||||
*
|
||||
* @param patientInformationDto 病人信息
|
||||
*/
|
||||
@PostMapping("/patient-information")
|
||||
public R<?> addPatient(@Validated @RequestBody PatientInformationDto patientInformationDto) {
|
||||
|
||||
Patient patient = new Patient();
|
||||
BeanUtils.copyProperties(patientInformationDto, patient);
|
||||
|
||||
// 使用基础采番,设置病人ID
|
||||
String code = assignSeqUtil.getSeq(AssignSeqEnum.PATIENT_NUM.getPrefix());
|
||||
patient.setBusNo(code);
|
||||
// 设置生日
|
||||
patient.setBirthDate(patientService.extractBirthday(patient.getIdCard()));
|
||||
// 设置机构ID
|
||||
patient.setOrganizationId(organizationId);
|
||||
// 设置拼音首拼
|
||||
patient.setPyStr(ChineseConvertUtils.toPinyinFirstLetter(patient.getName()));
|
||||
// 设置五笔首拼
|
||||
patient.setWbStr(ChineseConvertUtils.toWBFirstLetter(patient.getName()));
|
||||
// 设置地址
|
||||
String fullAddress = stringUtils.joinStrings(patient.getAddressProvince(), patient.getAddressCity(),
|
||||
patient.getAddressDistrict(), patient.getAddressStreet());
|
||||
patient.setAddress(fullAddress);
|
||||
|
||||
// 调用服务层保存病人信息
|
||||
boolean savePatientSuccess = patientService.save(patient);
|
||||
|
||||
if (!savePatientSuccess) {
|
||||
return R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00003, null));
|
||||
}
|
||||
|
||||
return R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00001, new Object[] {"病人信息"}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改病人信息
|
||||
*
|
||||
* @param patientInformationDto 病人信息
|
||||
*/
|
||||
@PutMapping("/patient-information")
|
||||
public R<?> editPatient(@Validated @RequestBody PatientInformationDto patientInformationDto) {
|
||||
|
||||
Patient patient = new Patient();
|
||||
BeanUtils.copyProperties(patientInformationDto, patient);
|
||||
|
||||
// 设置生日
|
||||
patient.setBirthDate(patientService.extractBirthday(patient.getIdCard()));
|
||||
// 设置拼音首拼
|
||||
patient.setPyStr(ChineseConvertUtils.toPinyinFirstLetter(patient.getName()));
|
||||
// 设置五笔首拼
|
||||
patient.setWbStr(ChineseConvertUtils.toWBFirstLetter(patient.getName()));
|
||||
// 设置地址
|
||||
String fullAddress = stringUtils.joinStrings(patient.getAddressProvince(), patient.getAddressCity(),
|
||||
patient.getAddressDistrict(), patient.getAddressStreet());
|
||||
patient.setAddress(fullAddress);
|
||||
|
||||
// 调用服务层更新病人信息
|
||||
boolean updateSuccess = patientService.updateById(patient);
|
||||
|
||||
if (!updateSuccess) {
|
||||
return R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00007, null));
|
||||
}
|
||||
|
||||
return R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00002, new Object[] {"病人信息"}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除病人信息
|
||||
*
|
||||
* @param id 主表id
|
||||
*/
|
||||
// todo 删除需要么?或者逻辑删除后续再改
|
||||
@DeleteMapping("/patient-information")
|
||||
public R<?> deletePatient(@RequestParam Long id) {
|
||||
|
||||
boolean deleteSuccess = patientService.removeById(id);
|
||||
|
||||
if (!deleteSuccess) {
|
||||
return R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00007, null));
|
||||
}
|
||||
|
||||
return R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00005, new Object[] {"病人信息"}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询病人信息,可选条件
|
||||
*
|
||||
* @param busNo 病人ID(可选)
|
||||
* @param name 病人姓名(可选)
|
||||
* @param pageNo 页码(默认为1)
|
||||
* @param pageSize 每页大小(默认为10)
|
||||
*/
|
||||
@GetMapping("/patient-information-page")
|
||||
public R<?> getPatient(@RequestParam(required = false) String busNo, @RequestParam(required = false) String name,
|
||||
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
|
||||
// 跳过的记录数
|
||||
Integer offset = (pageNo - 1) * pageSize;
|
||||
// 连表查询患者信息
|
||||
List<PatientInformationDto> listPatients = patientManageMapper.getPatientPage(busNo, name, pageSize, offset);
|
||||
// 查询总记录数
|
||||
long total = patientManageMapper.countPatients(busNo, name);
|
||||
// 创建Page对象并设置属性
|
||||
Page<PatientInformationDto> patientInformationPage = new Page<>(pageNo, pageSize, total);
|
||||
patientInformationPage.setRecords(listPatients);
|
||||
|
||||
if (patientInformationPage == null || patientInformationPage.getRecords().isEmpty()) {
|
||||
return R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00006, null));
|
||||
}
|
||||
return R.ok(patientInformationPage,
|
||||
MessageUtils.createMessage(PromptMsgConstant.Common.M00009, new Object[] {"病人信息"}));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.openhis.web.patientmanage.dto;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.openhis.common.enums.AdministrativeGender;
|
||||
import com.openhis.common.enums.MaritalStatus;
|
||||
import com.openhis.common.enums.OccupationType;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 病人信息Dto
|
||||
*
|
||||
* @author liuhr
|
||||
* @date 2025/2/22
|
||||
*/
|
||||
@Data
|
||||
public class PatientInformationDto {
|
||||
|
||||
private Long id;
|
||||
|
||||
/** 活动标记 */
|
||||
private Integer activeFlag;
|
||||
|
||||
/** 临时标识 */
|
||||
private Integer tempFlag;
|
||||
|
||||
/** 患者姓名 */
|
||||
private String name;
|
||||
|
||||
/** 患者其他名称 */
|
||||
private String nameJson;
|
||||
|
||||
/** 患者院内编码/病历号 */
|
||||
private String busNo;
|
||||
|
||||
/** 性别编码 */
|
||||
private AdministrativeGender genderEnum;
|
||||
|
||||
/** 生日 */
|
||||
private Date birthDate;
|
||||
|
||||
/** 死亡时间 */
|
||||
private Date deceasedDate;
|
||||
|
||||
/** 婚姻状态 */
|
||||
private MaritalStatus maritalStatusEnum;
|
||||
|
||||
/** 职业编码 */
|
||||
private OccupationType prfsEnum;
|
||||
|
||||
/** 电话 */
|
||||
private String phone;
|
||||
|
||||
/** 地址 */
|
||||
private String address;
|
||||
|
||||
/** 地址省 */
|
||||
private String addressProvince;
|
||||
|
||||
/** 地址市 */
|
||||
private String addressCity;
|
||||
|
||||
/** 地址区 */
|
||||
private String addressDistrict;
|
||||
|
||||
/** 地址街道 */
|
||||
private String addressStreet;
|
||||
|
||||
/** 患者其他地址 */
|
||||
private String addressJson;
|
||||
|
||||
/** 民族 */
|
||||
private String nationalityCode;
|
||||
|
||||
/** 身份证号 */
|
||||
private String idCard;
|
||||
|
||||
/** 拼音码 */
|
||||
private String pyStr;
|
||||
|
||||
/** 五笔码 */
|
||||
private String wbStr;
|
||||
|
||||
/** 血型ABO */
|
||||
private String bloodAbo;
|
||||
|
||||
/** 血型RH */
|
||||
private String bloodRh;
|
||||
|
||||
/** 工作单位 */
|
||||
private String workCompany;
|
||||
|
||||
/** 籍贯 */
|
||||
private String nativePlace;
|
||||
|
||||
/** 国家编码 */
|
||||
private String countryCode;
|
||||
|
||||
/** 联系人 */
|
||||
private String linkName;
|
||||
|
||||
/** 联系人关系 */
|
||||
private Integer linkRelationCode;
|
||||
|
||||
/** 联系人电话 */
|
||||
private String linkTelcom;
|
||||
|
||||
/** 其他联系人 */
|
||||
private String linkJsons;
|
||||
|
||||
/** 机构Id */
|
||||
private Long organizationId;
|
||||
|
||||
/** 机构名 */
|
||||
private String organizationName;
|
||||
|
||||
/** 创建时间 */
|
||||
private Date createTime;
|
||||
|
||||
/** 删除标识 */
|
||||
// 0 为未删除,1 为删除
|
||||
private String deleteFlag;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.openhis.web.patientmanage.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.openhis.administration.domain.Patient;
|
||||
import com.openhis.web.patientmanage.dto.PatientInformationDto;
|
||||
|
||||
/**
|
||||
* 病人信息管理
|
||||
*
|
||||
* @author Wuser
|
||||
* @date 2025/2/25
|
||||
*/
|
||||
@Repository
|
||||
public interface PatientManageMapper extends BaseMapper<Patient> {
|
||||
|
||||
/**
|
||||
* 病人信息分页查询
|
||||
*
|
||||
* @param busNo 病人ID
|
||||
* @param name 病人姓名
|
||||
* @param pageSize 页面大小
|
||||
* @param offset 跳过条数
|
||||
* @return 分页查询
|
||||
*/
|
||||
List<PatientInformationDto> getPatientPage(@Param("busNo") String busNo, @Param("name") String name,
|
||||
@Param("pageSize") Integer pageSize, @Param("offset") Integer offset);
|
||||
|
||||
/**
|
||||
* 统计总记录数的方法
|
||||
*
|
||||
* @param busNo 病人ID
|
||||
* @param name 病人姓名
|
||||
* @return 分页查询
|
||||
*/
|
||||
long countPatients(@Param("busNo") String busNo, @Param("name") String name);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?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.openhis.web.patientmanage.mapper.PatientManageMapper">
|
||||
<select id="getPatientPage" resultType="com.openhis.web.patientmanage.dto.PatientInformationDto">
|
||||
SELECT
|
||||
pt.id,
|
||||
pt.active_flag,
|
||||
pt.temp_flag,
|
||||
pt.name,
|
||||
pt.name_json,
|
||||
pt.bus_no,
|
||||
pt.gender_enum,
|
||||
pt.birth_date,
|
||||
pt.deceased_date,
|
||||
pt.marital_status_enum,
|
||||
pt.prfs_enum,
|
||||
pt.phone,
|
||||
pt.address,
|
||||
pt.address_province,
|
||||
pt.address_city,
|
||||
pt.address_district,
|
||||
pt.address_street,
|
||||
pt.address_json,
|
||||
pt.nationality_code,
|
||||
pt.id_card,
|
||||
pt.py_str,
|
||||
pt.wb_str,
|
||||
pt.blood_abo,
|
||||
pt.blood_rh,
|
||||
pt.work_company,
|
||||
pt.native_place,
|
||||
pt.country_code,
|
||||
pt.link_name,
|
||||
pt.link_relation_code,
|
||||
pt.link_telcom,
|
||||
pt.link_jsons,
|
||||
pt.organization_id,
|
||||
pt.create_time
|
||||
FROM adm_patient pt
|
||||
<!-- 类型不一致,把organization_id转换成字符串类型-->
|
||||
LEFT JOIN adm_organization ogt ON CAST(pt.organization_id AS VARCHAR) = ogt.bus_no
|
||||
<where>
|
||||
<!-- 如果传入busNo参数,且不为空 -->
|
||||
<if test="busNo != null and busNo != ''">
|
||||
AND busNo LIKE CONCAT(#{busNo}, '%')
|
||||
</if>
|
||||
|
||||
<!-- 如果传入name参数,且不为空 -->
|
||||
<if test="name != null and name != ''">
|
||||
AND name LIKE CONCAT(#{name}, '%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY pt.bus_no
|
||||
LIMIT #{pageSize} OFFSET #{offset}
|
||||
</select>
|
||||
|
||||
<select id="countPatients" resultType="long">
|
||||
SELECT COUNT(*)
|
||||
FROM adm_patient pt
|
||||
<!-- 类型不一致,把organization_id转换成字符串类型-->
|
||||
LEFT JOIN adm_organization ogt ON CAST(pt.organization_id AS VARCHAR) = ogt.bus_no
|
||||
<where>
|
||||
<!-- 如果传入busNo参数,且不为空 -->
|
||||
<if test="busNo != null and busNo != ''">
|
||||
AND busNo LIKE CONCAT(#{busNo}, '%')
|
||||
</if>
|
||||
|
||||
<!-- 如果传入name参数,且不为空 -->
|
||||
<if test="name != null and name != ''">
|
||||
AND name LIKE CONCAT(#{name}, '%')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user