yinyitong-zhongyuyuan-dll-s.../src/main/java/com/dpkj/modules/chs/controller/HispayController.java

138 lines
4.5 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.dpkj.modules.chs.controller;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.dpkj.common.vo.Result;
import com.dpkj.common.vo.ResultData;
import com.dpkj.modules.chs.constant.ChsPayStateConst;
import com.dpkj.modules.chs.service.IHispayService;
import com.dpkj.modules.chs.vo.OutpatientBeginModel;
import com.dpkj.modules.chs.vo.OutpatientFinalModel;
import lombok.AllArgsConstructor;
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;
/**
* @Auther: 萧道子
* @Date: 2025/3/22 16:25
* @Description: 医保模块-HIS医保
*/
@Slf4j
@AllArgsConstructor
@RestController
@RequestMapping("/chs/hispay")
public class HispayController {
private final IHispayService hispayService;
/**
* 通过医保卡或医保电子凭证读卡
*
* @return com.dpkj.common.vo.Result<?>
* @author 萧道子 2025/5/20
*/
@PostMapping("findReadCode")
public Result<?> findReadCode() {
try {
JSONObject res = hispayService.readCode();
return Result.ok("成功", res);
} catch (Exception e) {
e.printStackTrace();
log.error("[HispayController][getPatientInfo][按医保电子凭证读卡] ERR{}", e.getMessage());
return Result.error(e.getMessage());
}
}
/**
* 通过医保卡获取患者信息
*
* @param data :
* @return com.dpkj.common.vo.Result<?>
* @author 萧道子 2025/5/28
*/
@PostMapping("findReadCard")
public Result<?> findReadCard(@RequestBody JSONObject data) {
try {
String password = data.getString("password");
if (StrUtil.isEmpty(password)) {
throw new RuntimeException("密码不可为空");
}
JSONObject res = hispayService.readCard(password);
return Result.ok("成功", res);
} catch (Exception e) {
e.printStackTrace();
log.error("[HispayController][readCardByCard][按医保卡读卡] ERR{}", e.getMessage());
return Result.error(e.getMessage());
}
}
/**
* 门诊缴费-预算
*
* @param data :
* @return com.dpkj.common.vo.Result<?>
* @author 萧道子 2025/5/27
*/
@PostMapping("chsCodeAsOutpatientBegin")
public Result<?> chsCodeAsOutpatientBegin(@RequestBody @Validated OutpatientBeginModel data) {
try {
// 清空状态常量
ChsPayStateConst.clear();
log.info("[HispayController][chsCodeAsOutpatientBegin][门诊缴费-预算-电子医保凭证] 参数:{}", data);
ResultData res = hispayService.chsCodeAsOutpatientBegin(data);
return Result.ok("成功", res);
} catch (Exception e) {
e.printStackTrace();
log.info("[HispayController][chsCodeAsOutpatientBegin][门诊缴费-预算-电子医保凭证] 失败:{}", e.getMessage());
return Result.error(e.getMessage());
}
}
/**
* 门诊缴费-结算
*
* @param data :
* @return com.dpkj.common.vo.Result<?>
* @author 萧道子 2025/5/27
*/
@PostMapping("chsCodeAsOutpatientFinal")
public Result<?> chsCodeAsOutpatientFinal(@RequestBody @Validated OutpatientFinalModel data) {
try {
log.info("[HispayController][chsCodeAsOutpatientFinal][门诊缴费-结算-电子医保凭证] 参数:{}", data);
ResultData res = hispayService.chsCodeAsOutpatientFinal(data);
return Result.ok("成功", res);
} catch (Exception e) {
e.printStackTrace();
log.info("[HispayController][chsCodeAsOutpatientFinal][门诊缴费-结算-电子医保凭证] 失败:{}", e.getMessage());
return Result.error(e.getMessage());
}
}
/**
* 获取医保支付状态
*
* @return com.dpkj.common.vo.Result<?>
* @author 萧道子 2025/6/18
*/
@PostMapping("getChsPayState")
public Result<?> getChsPayState(@RequestBody OutpatientBeginModel data) {
String no = data.getPrescriptionNo();
if (StrUtil.isEmpty(no)) {
return Result.error("收据号不可为空");
}
Integer num = ChsPayStateConst.get(no);
return Result.ok("成功", num);
}
}