diff --git a/openhis-server/core-common/src/main/java/com/core/common/utils/DateUtils.java b/openhis-server/core-common/src/main/java/com/core/common/utils/DateUtils.java index d9f3dc90..ec740187 100644 --- a/openhis-server/core-common/src/main/java/com/core/common/utils/DateUtils.java +++ b/openhis-server/core-common/src/main/java/com/core/common/utils/DateUtils.java @@ -232,5 +232,50 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { return null; } + /** + * 判断日期是否为未来时间 + * + * @param dateString 字符串日期 + * @return 是/否 + */ + public static boolean isFuture(String dateString) { + // 创建 DateTimeFormatter 对象,并设置所需的日期时间格式 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); + + try { + // 解析字符串为 LocalDate 对象 + LocalDate dateToCheck = LocalDate.parse(dateString, formatter); + // 获取当前日期 + LocalDate currentDate = LocalDate.now(); + // 检查日期是否是未来的时间 + return dateToCheck.isAfter(currentDate); + } catch (Exception e) { + e.printStackTrace(); + // 解析失败或其他异常,返回 false 或根据需要处理异常 + return false; + } + } + + /** + * 从身份证号码中提取生日 + * + * @param idCard 身份证号 + * @return 出生日 + */ + public static Date extractBirthday(String idCard) { + if (idCard == null) { + // 身份证号码为空 + return null; + } + // 提取第7到14位作为生日字符串 + String birthdayStr = idCard.substring(6, 14); + // 将生日字符串转换为 LocalDate + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); + LocalDate date = LocalDate.parse(birthdayStr, formatter); + + // 将 LocalDate 转换为 java.util.Date + return Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant()); + } + } diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/chargemanage/appservice/IOutpatientRefundAppService.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/chargemanage/appservice/IOutpatientRefundAppService.java new file mode 100644 index 00000000..9386da1c --- /dev/null +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/chargemanage/appservice/IOutpatientRefundAppService.java @@ -0,0 +1,33 @@ +/* + * Copyright ©2023 CJB-CNIT Team. All rights reserved + */ +package com.openhis.web.chargemanage.appservice; + +import com.core.common.core.domain.R; + +import java.util.List; + +/** + * 门诊退费 service + * + * @author zwh + * @date 2025-03-15 + */ +public interface IOutpatientRefundAppService { + + /** + * 根据就诊id查询患者的账单 + * + * @param encounterId 就诊id + * @return 患者账单列表 + */ + R getEncounterPatientPayment(Long encounterId); + + /** + * 根据账单退费 + * + * @param paymentIdList 付费id列表 + * @return 操作结果 + */ + R refundPayment(List paymentIdList); +} diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/chargemanage/appservice/impl/OutpatientRefundAppServiceImpl.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/chargemanage/appservice/impl/OutpatientRefundAppServiceImpl.java new file mode 100644 index 00000000..33f8bbec --- /dev/null +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/chargemanage/appservice/impl/OutpatientRefundAppServiceImpl.java @@ -0,0 +1,58 @@ +/* + * Copyright ©2023 CJB-CNIT Team. All rights reserved + */ +package com.openhis.web.chargemanage.appservice.impl; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.core.common.core.domain.R; +import com.openhis.common.enums.PaymentStatus; +import com.openhis.web.chargemanage.appservice.IOutpatientRefundAppService; +import com.openhis.web.chargemanage.dto.EncounterPatientPaymentDto; +import com.openhis.web.chargemanage.mapper.OutpatientRefundAppMapper; + +/** + * 门诊退费 impl + * + * @author zwh + * @date 2025-03-15 + */ +@Service +public class OutpatientRefundAppServiceImpl implements IOutpatientRefundAppService { + + @Autowired + private OutpatientRefundAppMapper outpatientRefundAppMapper; + + /** + * 根据就诊id查询患者的账单 + * + * @param encounterId 就诊id + * @return 患者账单列表 + */ + @Override + public R getEncounterPatientPayment(Long encounterId) { + List patientPaymentList = + outpatientRefundAppMapper.selectEncounterPatientPayment(encounterId, PaymentStatus.SUCCESS.getValue(), + PaymentStatus.REFUND_ALL.getValue(), PaymentStatus.REFUND_PART.getValue()); + return R.ok(patientPaymentList); + } + + /** + * 根据账单退费 + * + * @param paymentIdList 付费id列表 + * @return 操作结果 + */ + @Override + public R refundPayment(List paymentIdList) { + + // 医生同意退费 + // 查询所有的chargeid,对应生成一个负的chargeitem + // 根据每个 chargeitem判断对应的服务,药品,耗材是否已发放执行 + // 若已发放/执行需要对应的发药人/执行人审批(药品耗材需要先退药) + return null; + } +} diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/chargemanage/controller/OutpatientRefundController.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/chargemanage/controller/OutpatientRefundController.java new file mode 100644 index 00000000..174d080b --- /dev/null +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/chargemanage/controller/OutpatientRefundController.java @@ -0,0 +1,54 @@ +/* + * Copyright ©2023 CJB-CNIT Team. All rights reserved + */ +package com.openhis.web.chargemanage.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import com.core.common.core.domain.R; +import com.openhis.web.chargemanage.appservice.IOutpatientRefundAppService; + +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +import java.util.List; + +/** + * 门诊退费 controller + * + * @author zwh + * @date 2025-03-15 + */ +@RestController +@RequestMapping("/charge-manage/refund") +@Slf4j +@AllArgsConstructor +public class OutpatientRefundController { + + @Autowired + private IOutpatientRefundAppService outpatientRefundAppService; + + /** + * 根据就诊id查询患者的账单 + * + * @param encounterId 就诊id + * @return 患者账单列表 + */ + @GetMapping(value = "/patient-payment") + public R getEncounterPatientPayment(@RequestParam Long encounterId) { + return R.ok(outpatientRefundAppService.getEncounterPatientPayment(encounterId)); + } + + /** + * 根据账单退费 + * + * @param paymentIdList 付费id列表 + * @return 操作结果 + */ + @PostMapping(value = "/refund-payment") + public R refundPayment(@RequestParam List paymentIdList) { + return R.ok(outpatientRefundAppService.refundPayment(paymentIdList)); + } + +} diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/chargemanage/dto/EncounterPatientPaymentDto.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/chargemanage/dto/EncounterPatientPaymentDto.java new file mode 100644 index 00000000..18a4365a --- /dev/null +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/chargemanage/dto/EncounterPatientPaymentDto.java @@ -0,0 +1,78 @@ +/* + * Copyright ©2023 CJB-CNIT Team. All rights reserved + */ +package com.openhis.web.chargemanage.dto; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import com.openhis.common.annotation.Dict; + +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 就诊患者账单 dto + * + * @author zwh + * @date 2025-03-17 + */ +@Data +@Accessors(chain = true) +public class EncounterPatientPaymentDto implements Serializable { + + private static final long serialVersionUID = 1L; + + /** ID */ + @TableId(type = IdType.ASSIGN_ID) + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + /** 就诊ID */ + private Long encounterId; + + /** 处方号 */ + private String prescriptionNo; + + /** 关联账户ID */ + private Long accountId; + + /** 状态 */ + private Integer statusEnum; + + /** 关联ID */ + private Long relationId; + + /** 支付的业务标识符 */ + private String paymentNo; + + /** 付款类别 */ + private Integer paymentEnum; + + /** 支付位置 */ + @Dict(dictTable = "adm_location", dictText = "name", dictCode = "id") + private Long locationId; + + /** 到期时间 */ + private Date expirationDate; + + /** 应收金额 */ + private BigDecimal tenderedAmount; + + /** 找零金额 */ + private BigDecimal returnedAmount; + + /** 付款总额 */ + private BigDecimal displayAmount; + + /** 合同编码 */ + private String contractNo; + + /** 处方号集合 */ + private String chargeItemIds; +} diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/chargemanage/mapper/OutpatientRefundAppMapper.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/chargemanage/mapper/OutpatientRefundAppMapper.java new file mode 100644 index 00000000..5d564943 --- /dev/null +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/chargemanage/mapper/OutpatientRefundAppMapper.java @@ -0,0 +1,34 @@ +/* + * Copyright ©2023 CJB-CNIT Team. All rights reserved + */ +package com.openhis.web.chargemanage.mapper; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import com.openhis.web.chargemanage.dto.EncounterPatientPaymentDto; + +/** + * 门诊退费 appMapper + * + * @author zwh + * @date 2025-03-15 + */ +@Repository +public interface OutpatientRefundAppMapper { + + /** + * 获取就诊患者账单列表 + * + * @param encounterId 就诊id + * @param success 支付状态:成功 + * @param refundAll 支付状态:全部退款 + * @param refundPart 支付状态:部分退款 + * @return 就诊患者账单列表 + */ + List selectEncounterPatientPayment(@Param("encounterId") Long encounterId, + @Param("success") Integer success, @Param("refundAll") Integer refundAll, + @Param("refundPart") Integer refundPart); +} diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/appservice/IOutpatientSkinTestRecordService.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/appservice/IOutpatientSkinTestRecordService.java index 6f0dcb0e..bc5bfd8f 100644 --- a/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/appservice/IOutpatientSkinTestRecordService.java +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/appservice/IOutpatientSkinTestRecordService.java @@ -31,26 +31,16 @@ public interface IOutpatientSkinTestRecordService { * @param outpatientSkinTestRecordSearchParam 查询条件 * @param pageNo 页码(默认为1) * @param pageSize 每页大小(默认为10) + * @return 获取门诊皮试记录列表 */ Page getSkinTestRecords( OutpatientSkinTestRecordSearchParam outpatientSkinTestRecordSearchParam, Integer pageNo, Integer pageSize); - /** - * 获取门诊皮试记录列表 - * - * @param outpatientSkinTestRecordSearchParam 门诊皮试记录查询参数 - * @param pageSize 页面大小 - * @param offset 跳过条数 - * @return 分页查询 - */ - List getOutpatientSkinTestRecord( - @Param("OutpatientSkinTestRecordSearchParam") OutpatientSkinTestRecordSearchParam outpatientSkinTestRecordSearchParam, - @Param("pageSize") Integer pageSize, @Param("offset") Integer offset); - /** * 护士确认执行皮试后,更新皮试记录信息(服务申请管理与过敏与不耐受的相关字段更新) * * @param outpatientSkinTestRecordDto 皮试记录信息 + * @return 更新结果 */ boolean editSkinTestRecord(OutpatientSkinTestRecordDto outpatientSkinTestRecordDto); @@ -58,8 +48,8 @@ public interface IOutpatientSkinTestRecordService { * 护士核对皮试结果后,确认签名(服务申请管理与过敏与不耐受的相关字段更新) * * @param outpatientSkinTestRecordDto 皮试记录信息 + * @return 更新结果 */ boolean nurseSignChkPs(OutpatientSkinTestRecordDto outpatientSkinTestRecordDto); - } diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/appservice/impl/OutpatientSkinTestRecordServiceImpl.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/appservice/impl/OutpatientSkinTestRecordServiceImpl.java index 5bec341a..e6cfcb5e 100644 --- a/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/appservice/impl/OutpatientSkinTestRecordServiceImpl.java +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/appservice/impl/OutpatientSkinTestRecordServiceImpl.java @@ -132,21 +132,6 @@ public class OutpatientSkinTestRecordServiceImpl implements IOutpatientSkinTestR return outpatientSkinTestRecordPage; } - /** - * 获取门诊皮试记录列表 - * - * @param outpatientSkinTestRecordSearchParam 门诊皮试记录查询参数 - * @param pageSize 页面大小 - * @param offset 跳过条数 - * @return 分页查询 - */ - @Override - public List getOutpatientSkinTestRecord( - OutpatientSkinTestRecordSearchParam outpatientSkinTestRecordSearchParam, Integer pageSize, Integer offset) { - return outpatientManageMapper.getOutpatientSkinTestRecord(outpatientSkinTestRecordSearchParam, pageSize, - offset); - } - /** * 护士确认执行皮试后,更新皮试记录信息(服务申请管理与过敏与不耐受的相关字段更新) * diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/patientmanage/appservice/IPatientInformationService.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/patientmanage/appservice/IPatientInformationService.java index 73eefdd9..daa23c8f 100644 --- a/openhis-server/openhis-application/src/main/java/com/openhis/web/patientmanage/appservice/IPatientInformationService.java +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/patientmanage/appservice/IPatientInformationService.java @@ -1,11 +1,17 @@ package com.openhis.web.patientmanage.appservice; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.core.common.core.domain.R; +import com.openhis.web.outpatientmanage.dto.OutpatientSkinTestRecordDto; import com.openhis.web.patientmanage.dto.PatientInfoInitDto; +import com.openhis.web.patientmanage.dto.PatientInformationDto; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; /** * 病人管理——病人信息 * - * @author Wuser + * @author liuhr * @date 2025/3/15 */ public interface IPatientInformationService { @@ -16,4 +22,39 @@ public interface IPatientInformationService { * @return 病人信息记录初期数据列表 */ PatientInfoInitDto getPatientInfoInit(); + + /** + * 分页查询病人信息 + * + * @param busNo 病人ID(可选) + * @param name 病人姓名(可选) + * @param pageNo 页码(默认为1) + * @param pageSize 每页大小(默认为10)) + * @return 分页查询 + */ + Page getPatient(String busNo, String name, Integer pageNo, Integer pageSize); + + /** + * 修改病人信息 + * + * @param patientInformationDto 病人信息 + * @return 更新结果 + */ + R editPatient(PatientInformationDto patientInformationDto); + + /** + * 添加病人信息 + * + * @param patientInformationDto 病人信息 + */ + R addPatient(PatientInformationDto patientInformationDto); + + /** + * 判断身份证号是否存在 + * + * @param idCard 身份证号 + * @return 是/否 + */ + boolean existsByIdCard(String idCard); + } diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/patientmanage/appservice/impl/PatientInformationServiceImpl.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/patientmanage/appservice/impl/PatientInformationServiceImpl.java index 4265493a..f4e96d23 100644 --- a/openhis-server/openhis-application/src/main/java/com/openhis/web/patientmanage/appservice/impl/PatientInformationServiceImpl.java +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/patientmanage/appservice/impl/PatientInformationServiceImpl.java @@ -4,10 +4,28 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; +import com.core.common.utils.MessageUtils; +import com.openhis.common.constant.PromptMsgConstant; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +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.DateUtils; +import com.core.common.utils.bean.BeanUtils; +import com.openhis.administration.domain.Patient; +import com.openhis.administration.mapper.PatientMapper; +import com.openhis.administration.service.IPatientService; import com.openhis.common.enums.*; +import com.openhis.common.utils.EnumUtils; import com.openhis.web.patientmanage.appservice.IPatientInformationService; import com.openhis.web.patientmanage.dto.PatientInfoInitDto; -import org.springframework.stereotype.Service; +import com.openhis.web.patientmanage.dto.PatientInformationDto; +import com.openhis.web.patientmanage.mapper.PatientManageMapper; /** * 门诊患者 @@ -18,6 +36,21 @@ import org.springframework.stereotype.Service; @Service public class PatientInformationServiceImpl implements IPatientInformationService { + @Autowired + PatientManageMapper patientManageMapper; + + @Autowired + PatientMapper patientMapper; + + @Autowired + IPatientService patientService; + + @Autowired(required = false) + AssignSeqUtil assignSeqUtil; + + // todo 暂且机构ID写死,后续从登录里取得 + private final Long organizationId = 91L; + /** * 获取病人信息记录初期数据列表 * @@ -65,4 +98,135 @@ public class PatientInformationServiceImpl implements IPatientInformationService return initDto; } + /** + * 分页查询病人信息 + * + * @param busNo 病人ID(可选) + * @param name 病人姓名(可选) + * @param pageNo 页码(默认为1) + * @param pageSize 每页大小(默认为10)) + * @return 分页查询 + */ + @Override + public Page getPatient(String busNo, String name, Integer pageNo, Integer pageSize) { + // 跳过的记录数 + Integer offset = (pageNo - 1) * pageSize; + // 连表查询患者信息 + List listPatients = patientManageMapper.getPatientPage(busNo, name, pageSize, offset); + // 查询总记录数 + long total = patientManageMapper.countPatients(busNo, name); + // 创建Page对象并设置属性 + Page patientInformationPage = new Page<>(pageNo, pageSize, total); + patientInformationPage.setRecords(listPatients); + patientInformationPage.getRecords().forEach(e -> { + // 性别枚举类回显赋值 + e.setGenderEnum_enumText(EnumUtils.getInfoByValue(AdministrativeGender.class, e.getGenderEnum())); + // 婚姻状态枚举类回显赋值 + e.setMaritalStatusEnum_enumText(EnumUtils.getInfoByValue(MaritalStatus.class, e.getMaritalStatusEnum())); + // 职业编码枚举类回显赋值 + e.setPrfsEnum_enumText(EnumUtils.getInfoByValue(OccupationType.class, e.getPrfsEnum())); + // 血型ABO枚举类回显赋值 + e.setBloodAbo_enumText(EnumUtils.getInfoByValue(BloodTypeABO.class, e.getBloodAbo())); + // 血型RH枚举类回显赋值 + e.setBloodRh_enumText(EnumUtils.getInfoByValue(BloodTypeRH.class, e.getBloodRh())); + // 家庭关系枚举类回显赋值 + e.setLinkRelationCode_enumText( + EnumUtils.getInfoByValue(FamilyRelationshipType.class, e.getLinkRelationCode())); + }); + return patientInformationPage; + } + + /** + * 修改病人信息 + * + * @param patientInformationDto 病人信息 + * @return 更新结果 + */ + @Override + public R editPatient(PatientInformationDto patientInformationDto) { + + Patient patient = new Patient(); + BeanUtils.copyProperties(patientInformationDto, patient); + + // 设置生日 + patient.setBirthDate(DateUtils.extractBirthday(patient.getIdCard())); + // 设置拼音首拼 + patient.setPyStr(ChineseConvertUtils.toPinyinFirstLetter(patient.getName())); + // 设置五笔首拼 + patient.setWbStr(ChineseConvertUtils.toWBFirstLetter(patient.getName())); + // 设置死亡时间,死亡时间未来时报错 + if (DateUtils.isFuture(patientInformationDto.getDeceasedDate())) { + return R.fail("死亡时间未来时间是未来时间!"); + } + patient.setDeceasedDate(DateUtils.parseDate(patientInformationDto.getDeceasedDate())); + + // 调用服务层更新病人信息 + boolean result = patientService.updateById(patient); + if (result) { + return R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00001, new Object[] {"病人信息"})); + } else { + return R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00007, null)); + } + + } + + /** + * 添加病人信息 + * + * @param patientInformationDto 病人信息 + */ + @Override + public R addPatient(PatientInformationDto patientInformationDto) { + + Patient patient = new Patient(); + BeanUtils.copyProperties(patientInformationDto, patient); + + // 使用基础采番,设置病人ID + String code = assignSeqUtil.getSeq(AssignSeqEnum.PATIENT_NUM.getPrefix()); + patient.setBusNo(code); + + // 设置机构ID + patient.setOrganizationId(organizationId); + // 设置生日 + patient.setBirthDate(DateUtils.extractBirthday(patient.getIdCard())); + // 设置拼音首拼 + patient.setPyStr(ChineseConvertUtils.toPinyinFirstLetter(patient.getName())); + // 设置五笔首拼 + patient.setWbStr(ChineseConvertUtils.toWBFirstLetter(patient.getName())); + // 设置死亡时间,死亡时间未来时报错 + if (DateUtils.isFuture(patientInformationDto.getDeceasedDate())) { + return R.fail("死亡时间未来时间是未来时间!"); + } + // 身份证号存在check + if (existsByIdCard(patientInformationDto.getIdCard())) { + // 身份证号存在 + return R.fail("身份证号已存在!"); + } + patient.setDeceasedDate(DateUtils.parseDate(patientInformationDto.getDeceasedDate())); + + // 调用服务层保存病人信息 + boolean result = patientService.save(patient); + if (result) { + return R.ok("病人信息添加成功!"); + } else { + return R.fail("病人信息添加失败!"); + } + } + + /** + * 判断身份证号是否存在 + * + * @param idCard 身份证号 + * @return 是/否 + */ + public boolean existsByIdCard(String idCard) { + // 构造查询条件 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Patient::getIdCard, idCard); + if (patientMapper.selectOne(queryWrapper) == null) { + return false; + } + return true; + } + } diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/patientmanage/controller/PatientInformationController.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/patientmanage/controller/PatientInformationController.java index 52e02ced..4ef1b237 100644 --- a/openhis-server/openhis-application/src/main/java/com/openhis/web/patientmanage/controller/PatientInformationController.java +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/patientmanage/controller/PatientInformationController.java @@ -1,29 +1,14 @@ package com.openhis.web.patientmanage.controller; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import com.openhis.web.patientmanage.appservice.IPatientInformationService; -import lombok.AllArgsConstructor; 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.*; -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.common.enums.*; -import com.openhis.common.utils.EnumUtils; +import com.openhis.web.patientmanage.appservice.IPatientInformationService; import com.openhis.web.patientmanage.dto.PatientInformationDto; -import com.openhis.web.patientmanage.dto.PatientInfoInitDto; -import com.openhis.web.patientmanage.mapper.PatientManageMapper; +import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; /** @@ -38,24 +23,9 @@ import lombok.extern.slf4j.Slf4j; @AllArgsConstructor public class PatientInformationController { - @Autowired - private IPatientService patientService; - - @Autowired(required = false) - private AssignSeqUtil assignSeqUtil; - - @Autowired(required = false) - PatientManageMapper patientManageMapper; -// -// @Autowired(required = false) -// StringUtils stringUtils; - @Autowired IPatientInformationService patientInformationService; - // todo 暂且机构ID写死,后续从登录里取得 - private final Long organizationId = 91L; - /** * 病人信息记录初期数据列表 * @@ -72,38 +42,10 @@ public class PatientInformationController { * * @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); -// -// // 设置机构ID -// patient.setOrganizationId(organizationId); -// // 设置生日 -// patient.setBirthDate(patientService.extractBirthday(patient.getIdCard())); -// // 设置拼音首拼 -// patient.setPyStr(ChineseConvertUtils.toPinyinFirstLetter(patient.getName())); -// // 设置五笔首拼 -// patient.setWbStr(ChineseConvertUtils.toWBFirstLetter(patient.getName())); -// // 设置死亡时间 -// if (patientService.isFuture(patientInformationDto.getDeceasedDate())) { -// return R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00003, new Object[] {"死亡时间未来时"})); -// } -// patient.setDeceasedDate(DateUtils.parseDate(patientInformationDto.getDeceasedDate())); -// // 调用服务层保存病人信息 -// 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[] {"病人信息"})); -// } + @PostMapping("/patient-information") + public R addPatient(@Validated @RequestBody PatientInformationDto patientInformationDto) { + return patientInformationService.addPatient(patientInformationDto); + } /** * 修改病人信息 @@ -112,26 +54,8 @@ public class PatientInformationController { */ @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())); - // 设置死亡时间 - if (patientService.isFuture(patientInformationDto.getDeceasedDate())) { - return R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00007, new Object[] {"死亡时间未来时"})); - } - patient.setDeceasedDate(DateUtils.parseDate(patientInformationDto.getDeceasedDate())); - // 调用服务层更新病人信息 - return patientService.updateById(patient) - ? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00001, new Object[] {"病人信息"})) - : R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00007, null)); + return patientInformationService.editPatient(patientInformationDto); } @@ -148,31 +72,7 @@ public class PatientInformationController { @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { - // 跳过的记录数 - Integer offset = (pageNo - 1) * pageSize; - // 连表查询患者信息 - List listPatients = patientManageMapper.getPatientPage(busNo, name, pageSize, offset); - // 查询总记录数 - long total = patientManageMapper.countPatients(busNo, name); - // 创建Page对象并设置属性 - Page patientInformationPage = new Page<>(pageNo, pageSize, total); - patientInformationPage.setRecords(listPatients); - patientInformationPage.getRecords().forEach(e -> { - // 性别枚举类回显赋值 - e.setGenderEnum_enumText(EnumUtils.getInfoByValue(AdministrativeGender.class, e.getGenderEnum())); - // 婚姻状态枚举类回显赋值 - e.setMaritalStatusEnum_enumText(EnumUtils.getInfoByValue(MaritalStatus.class, e.getMaritalStatusEnum())); - // 职业编码枚举类回显赋值 - e.setPrfsEnum_enumText(EnumUtils.getInfoByValue(OccupationType.class, e.getPrfsEnum())); - // 血型ABO枚举类回显赋值 - e.setBloodAbo_enumText(EnumUtils.getInfoByValue(BloodTypeABO.class, e.getBloodAbo())); - // 血型RH枚举类回显赋值 - e.setBloodRh_enumText(EnumUtils.getInfoByValue(BloodTypeRH.class, e.getBloodRh())); - // 家庭关系枚举类回显赋值 - e.setLinkRelationCode_enumText( - EnumUtils.getInfoByValue(FamilyRelationshipType.class, e.getLinkRelationCode())); - }); - return R.ok(patientInformationPage); + return R.ok(patientInformationService.getPatient(busNo, name, pageNo, pageSize)); } } diff --git a/openhis-server/openhis-application/src/main/resources/mapper/chargemanage/OutpatientChargeAppMapper.xml b/openhis-server/openhis-application/src/main/resources/mapper/chargemanage/OutpatientChargeAppMapper.xml index ca811321..9595d9ab 100644 --- a/openhis-server/openhis-application/src/main/resources/mapper/chargemanage/OutpatientChargeAppMapper.xml +++ b/openhis-server/openhis-application/src/main/resources/mapper/chargemanage/OutpatientChargeAppMapper.xml @@ -72,6 +72,7 @@ ON T1.context_enum = #{device} AND T1.product_id = T4.id WHERE T1.encounter_id = #{encounterId} + AND T1.status_enum IN (1 , 2 , 5) AND T1.delete_flag = '0' \ No newline at end of file diff --git a/openhis-server/openhis-application/src/main/resources/mapper/chargemanage/OutpatientRefundAppMapper.xml b/openhis-server/openhis-application/src/main/resources/mapper/chargemanage/OutpatientRefundAppMapper.xml new file mode 100644 index 00000000..fe75422f --- /dev/null +++ b/openhis-server/openhis-application/src/main/resources/mapper/chargemanage/OutpatientRefundAppMapper.xml @@ -0,0 +1,27 @@ + + + + + + \ No newline at end of file diff --git a/openhis-server/openhis-application/src/main/resources/mapper/outpatientmanage/OutpatientManageMapper.xml b/openhis-server/openhis-application/src/main/resources/mapper/outpatientmanage/OutpatientManageMapper.xml index b13448f0..b53b9b59 100644 --- a/openhis-server/openhis-application/src/main/resources/mapper/outpatientmanage/OutpatientManageMapper.xml +++ b/openhis-server/openhis-application/src/main/resources/mapper/outpatientmanage/OutpatientManageMapper.xml @@ -3,7 +3,7 @@ -