HIS医保刷脸支付
This commit is contained in:
@@ -30,7 +30,7 @@ public class HispayController {
|
||||
private final IHispayService hispayService;
|
||||
|
||||
/**
|
||||
* 通过医保卡或医保电子凭证读卡
|
||||
* 通过医保电子凭证获取患者信息
|
||||
*
|
||||
* @return com.dpkj.common.vo.Result<?>
|
||||
* @author 萧道子 2025/5/20
|
||||
@@ -42,7 +42,7 @@ public class HispayController {
|
||||
return Result.ok("成功", res);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("[HispayController][getPatientInfo][按医保电子凭证读卡] ERR:{}", e.getMessage());
|
||||
log.error("[HispayController][getPatientInfo][通过医保电子凭证获取患者信息] ERR:{}", e.getMessage());
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -62,12 +62,29 @@ public class HispayController {
|
||||
if (StrUtil.isEmpty(password)) {
|
||||
throw new RuntimeException("密码不可为空");
|
||||
}
|
||||
|
||||
JSONObject res = hispayService.getUserInfoByChsCard(password);
|
||||
return Result.ok("成功", res);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("[HispayController][readCardByCard][按医保卡读卡] ERR:{}", e.getMessage());
|
||||
log.error("[HispayController][readCardByCard][通过医保卡获取患者信息] ERR:{}", e.getMessage());
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过刷脸获取患者信息
|
||||
*
|
||||
* @return com.dpkj.common.vo.Result<?>
|
||||
* @author 萧道子 2025/10/27
|
||||
*/
|
||||
@PostMapping("getUserInfoByFace")
|
||||
public Result<?> getUserInfoByFace() {
|
||||
try {
|
||||
JSONObject res = hispayService.getUserInfoByFace();
|
||||
return Result.ok("成功", res);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("[HispayController][getUserInfoByFace][通过刷脸获取患者信息] ERR:{}", e.getMessage());
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,20 @@ public interface IHispayService {
|
||||
JSONObject getUserInfoByChsCode();
|
||||
|
||||
/**
|
||||
* 通过医保卡-取患者身份信息
|
||||
* 通过医保卡获取患者身份信息
|
||||
*
|
||||
* @return com.alibaba.fastjson.JSONObject
|
||||
* @author 萧道子 2025/5/28
|
||||
*/
|
||||
JSONObject getUserInfoByChsCard(String password);
|
||||
|
||||
/**
|
||||
* 通过刷脸获取患者身份信息
|
||||
* @return com.alibaba.fastjson.JSONObject
|
||||
* @author 萧道子 2025/10/27
|
||||
*/
|
||||
JSONObject getUserInfoByFace();
|
||||
|
||||
|
||||
/**
|
||||
* 门诊缴费-预算 电子凭证支付
|
||||
|
||||
@@ -11,12 +11,14 @@ import com.dpkj.modules.chs.hischs.service.IHispayService;
|
||||
import com.dpkj.modules.chs.hischs.vo.OutpatientBeginModel;
|
||||
import com.dpkj.modules.chs.hischs.vo.OutpatientFinalModel;
|
||||
import com.jacob.activeX.ActiveXComponent;
|
||||
import com.jacob.com.ComThread;
|
||||
import com.jacob.com.Dispatch;
|
||||
import com.jacob.com.Variant;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -58,77 +60,72 @@ public class HispayServiceImpl implements IHispayService {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*
|
||||
* @return void
|
||||
* @author 萧道子 2025/5/21
|
||||
*/
|
||||
private void init() {
|
||||
ComThread.InitSTA(); // 容易导致线程发生阻塞
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放资源
|
||||
*
|
||||
* @return void
|
||||
* @author 萧道子 2025/5/21
|
||||
*/
|
||||
private void releaseActive() {
|
||||
// ComThread.Release(); //容易导致线程发生阻塞
|
||||
private void release() {
|
||||
ComThread.Release(); // 容易导致线程发生阻塞
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JSONObject getUserInfoByChsCode() {
|
||||
/** 1、组装参数 */
|
||||
JSONObject params = new JSONObject()
|
||||
.fluentPut("cardtype", "9") // 1.就诊卡,2.医保卡,5.门诊号,6.患者姓名和电话号码,8.电子健康码/卡,9.医保电子凭证
|
||||
JSONObject params = new JSONObject().fluentPut("cardtype", "9") // 1.就诊卡,2.医保卡,5.门诊号,6.患者姓名和电话号码,8.电子健康码/卡,9.医保电子凭证,10.人脸识别
|
||||
.fluentPut("cardno", "") // 患者就诊卡号
|
||||
.fluentPut("sfzh", "") // 身份证号
|
||||
.fluentPut("hzxm", "") // 患者姓名
|
||||
.fluentPut("phone", ""); // 患者电话号码
|
||||
String paramsXml = this.handleParams(params);
|
||||
|
||||
/** 2、调用COM函数 */
|
||||
log.debug("[HispayServiceImpl][readCode][医保读卡-电子凭证] 接口入参:{}", paramsXml);
|
||||
Variant vres = new Variant("", true);
|
||||
Variant call = Dispatch.call(dispatch, "fRun", "BMZXX010", paramsXml, vres);
|
||||
String resStr = vres.getStringRef();
|
||||
log.debug("[HispayServiceImpl][readCode][医保读卡-电子凭证] call返回值:{} 结果:{}", call, resStr);
|
||||
|
||||
|
||||
/** 3、处理读卡结果 */
|
||||
JSONObject result = verifyResult(resStr);
|
||||
if (!result.containsKey("item")) {
|
||||
throw new RuntimeException("item数据为空");
|
||||
}
|
||||
|
||||
return result.getJSONObject("item");
|
||||
return getUserInfo(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getUserInfoByChsCard(String password) {
|
||||
/** 1、组装参数 */
|
||||
JSONObject params = new JSONObject()
|
||||
.fluentPut("cardtype", "2") // 1.就诊卡,2.医保卡,5.门诊号,6.患者姓名和电话号码,8.电子健康码/卡,9.医保电子凭证
|
||||
JSONObject params = new JSONObject().fluentPut("cardtype", "2") // 1.就诊卡,2.医保卡,5.门诊号,6.患者姓名和电话号码,8.电子健康码/卡,9.医保电子凭证,10.人脸识别
|
||||
.fluentPut("cardno", "") // 患者就诊卡号
|
||||
.fluentPut("sfzh", "") // 身份证号
|
||||
.fluentPut("hzxm", "") // 患者姓名
|
||||
.fluentPut("phone", "") // 患者电话号码
|
||||
.fluentPut("password", password);
|
||||
return getUserInfo(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getUserInfoByFace() {
|
||||
JSONObject params = new JSONObject().fluentPut("cardtype", "10") // 1.就诊卡,2.医保卡,5.门诊号,6.患者姓名和电话号码,8.电子健康码/卡,9.医保电子凭证,10.人脸识别
|
||||
.fluentPut("cardno", "") // 患者就诊卡号
|
||||
.fluentPut("sfzh", "") // 身份证号
|
||||
.fluentPut("hzxm", "") // 患者姓名
|
||||
.fluentPut("phone", ""); // 患者电话号码
|
||||
String paramsXml = this.handleParams(params, password);
|
||||
|
||||
/** 2、调用COM函数 */
|
||||
log.debug("[HispayServiceImpl][readCard][医保读卡-医保卡] 接口入参:{}", paramsXml);
|
||||
Variant vres = new Variant("", true);
|
||||
Variant call = Dispatch.call(dispatch, "fRun", "BMZXX010", paramsXml, vres);
|
||||
String resStr = vres.getStringRef();
|
||||
log.debug("[HispayServiceImpl][readCard][医保读卡-医保卡] call返回值:{} 结果:{}", call, resStr);
|
||||
|
||||
/** 3、处理读卡结果 */
|
||||
JSONObject result = this.verifyResult(resStr);
|
||||
if (!result.containsKey("item")) {
|
||||
throw new RuntimeException("item数据为空");
|
||||
return getUserInfo(params);
|
||||
}
|
||||
|
||||
return result.getJSONObject("item");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResultData chsCodeAsOutpatientBegin(OutpatientBeginModel data) {
|
||||
// 用户读卡-生成token
|
||||
JSONObject userInfo = this.getUserInfoByChsCode();
|
||||
JSONObject userInfo = new JSONObject();
|
||||
switch (data.getType()) {
|
||||
case "ELECTRONICPAY": // 医保电子凭证支付
|
||||
userInfo = this.getUserInfoByChsCode();
|
||||
break;
|
||||
case "CHSFACE": // 医保刷脸支付
|
||||
userInfo = this.getUserInfoByFace();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
String patientId = userInfo.getString("patid");
|
||||
data.setPatientId(patientId);
|
||||
|
||||
@@ -143,12 +140,9 @@ public class HispayServiceImpl implements IHispayService {
|
||||
/** 1、组装参数 */
|
||||
String requestTime = DateUtil.now();
|
||||
data.setPaytime(requestTime);
|
||||
JSONObject params = ((JSONObject) JSON.toJSON(data))
|
||||
.fluentPut("czksfbz", "0") // 是否扣院内账户,与预算保持一致
|
||||
JSONObject params = ((JSONObject) JSON.toJSON(data)).fluentPut("czksfbz", "0") // 是否扣院内账户,与预算保持一致
|
||||
.fluentPut("zfjsbz", "0") // 是否自费结算,与预算保持一致,0根据病人医保代码结算,1自费结算
|
||||
.fluentPut("ybrc", "")
|
||||
.fluentPut("ptlsh", "")
|
||||
.fluentPut("jysm", "");
|
||||
.fluentPut("ybrc", "").fluentPut("ptlsh", "").fluentPut("jysm", "");
|
||||
String paramsXml = this.handleParams(params);
|
||||
|
||||
/** 2、调用COM函数 */
|
||||
@@ -162,13 +156,7 @@ public class HispayServiceImpl implements IHispayService {
|
||||
/** 3、处理结果 */
|
||||
JSONObject result = verifyResult(resStr);
|
||||
|
||||
return new ResultData()
|
||||
.setRequestTime(requestTime)
|
||||
.setRequestContent(paramsXml)
|
||||
.setResponseTime(responseTime)
|
||||
.setPatientId(data.getPatid())
|
||||
.setResponseContent(resStr)
|
||||
.setResult(result);
|
||||
return new ResultData().setRequestTime(requestTime).setRequestContent(paramsXml).setResponseTime(responseTime).setPatientId(data.getPatid()).setResponseContent(resStr).setResult(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -181,8 +169,7 @@ public class HispayServiceImpl implements IHispayService {
|
||||
*/
|
||||
private ResultData outpatientBudget(OutpatientBeginModel data) {
|
||||
/** 1、组装参数 */
|
||||
JSONObject params = new JSONObject()
|
||||
.fluentPut("patid", data.getPatientId()) // 病人ID
|
||||
JSONObject params = new JSONObject().fluentPut("patid", data.getPatientId()) // 病人ID
|
||||
.fluentPut("cfxhhj", data.getPrescriptionNo()) // 划价单据,格式:单据1,单据2,单据3
|
||||
.fluentPut("czksfbz", "0") // 是否扣院内账户,0不使用院内账户,1使用院内账户(默认不使用院内账户)
|
||||
.fluentPut("zfjsbz", "0") // 是否自费结算,0根据医保代码缴费,1自费结算(默认自费结算)
|
||||
@@ -203,24 +190,47 @@ public class HispayServiceImpl implements IHispayService {
|
||||
/** 3、处理结果 */
|
||||
JSONObject result = verifyResult(resStr);
|
||||
|
||||
return new ResultData()
|
||||
.setRequestTime(requestTime)
|
||||
.setRequestContent(paramsXml)
|
||||
.setResponseTime(responseTime)
|
||||
.setPatientId(data.getPatientId())
|
||||
.setResponseContent(resStr)
|
||||
.setResult(result);
|
||||
return new ResultData().setRequestTime(requestTime).setRequestContent(paramsXml).setResponseTime(responseTime).setPatientId(data.getPatientId()).setResponseContent(resStr).setResult(result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取患者信息
|
||||
*
|
||||
* @param params :
|
||||
* @return com.alibaba.fastjson.JSONObject
|
||||
* @author 萧道子 2025/10/27
|
||||
*/
|
||||
private JSONObject getUserInfo(JSONObject params) {
|
||||
/** 1、组装参数 */
|
||||
String paramsXml = this.handleParams(params);
|
||||
|
||||
/** 2、调用COM函数 */
|
||||
log.debug("[HispayServiceImpl][getUserInfo][医保读卡-获取患者信息] 接口入参:{}", paramsXml);
|
||||
String buffer = ByteBuffer.allocate(1024 * 1024).toString();
|
||||
Variant outData = new Variant(buffer, true);
|
||||
Variant call = Dispatch.call(dispatch, "fRun", "BMZXX010", paramsXml, outData);
|
||||
String resStr = outData.getStringRef();
|
||||
log.debug("[HispayServiceImpl][getUserInfo][医保读卡-获取患者信息] call返回值:{} 结果:{}", call, resStr);
|
||||
|
||||
/** 3、处理读卡结果 */
|
||||
JSONObject result = verifyResult(resStr);
|
||||
if (!result.containsKey("item")) {
|
||||
throw new RuntimeException("item数据为空");
|
||||
}
|
||||
|
||||
return result.getJSONObject("item");
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理参数
|
||||
*
|
||||
* @param params : 请求参数
|
||||
* @param password : 密码
|
||||
* @return java.lang.String
|
||||
* @author 萧道子 2025/5/27
|
||||
*/
|
||||
private String handleParams(JSONObject params, String password) {
|
||||
private String handleParams(JSONObject params) {
|
||||
String password = params.getString("password"); // 密码
|
||||
JSONObject req = new JSONObject() {{
|
||||
put("timestamp", ""); // 请求发送时间 DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss")
|
||||
put("requestid", ""); // 唯一请求id IDGenerator.getSnowflakeIdToStr()
|
||||
@@ -228,13 +238,10 @@ public class HispayServiceImpl implements IHispayService {
|
||||
put("password", password); // 密码
|
||||
put("params", params);
|
||||
}};
|
||||
params.remove("password");
|
||||
return this.JsonObjectToXml(req);
|
||||
}
|
||||
|
||||
private String handleParams(JSONObject params) {
|
||||
return handleParams(params, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 校验结果
|
||||
|
||||
@@ -34,4 +34,10 @@ public class OutpatientBeginModel implements Serializable {
|
||||
// @NotEmpty(message = "密码不可为空!")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* ELECTRONICPAY 电子医保
|
||||
* CHSFACE 医保刷脸
|
||||
*/
|
||||
private String type;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user