HIS医保
This commit is contained in:
parent
d8d53ebb22
commit
9c08c6e7d4
|
@ -19,9 +19,4 @@ public class ChsConfig {
|
||||||
*/
|
*/
|
||||||
private String orgcode;
|
private String orgcode;
|
||||||
|
|
||||||
/**
|
|
||||||
* 医保读卡之后保存信息的文件名
|
|
||||||
*/
|
|
||||||
private String fileName;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,12 @@ import org.springframework.web.method.annotation.MethodArgumentTypeMismatchExcep
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* controller控制器异常处理接口实现类
|
* controller控制器异常处理接口实现类
|
||||||
* <p>其它module可以集成此类进行controller层的异常处理</p>
|
* <p>其它module可以集成此类进行controller层的异常处理</p>
|
||||||
|
*
|
||||||
* @author <a href="https://gitee.com/shi-chongli">石头人</a>
|
* @author <a href="https://gitee.com/shi-chongli">石头人</a>
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@ -38,23 +40,18 @@ public class ControllerAdvice {
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(value = MethodArgumentNotValidException.class)
|
@ExceptionHandler(value = MethodArgumentNotValidException.class)
|
||||||
public Result<String> bindingException(MethodArgumentNotValidException e) {
|
public Result<String> bindingException(MethodArgumentNotValidException e) {
|
||||||
// 获得所有校验出错的返回集
|
String errMsg = e.getBindingResult()
|
||||||
BindingResult bindingResult = e.getBindingResult();
|
.getFieldErrors()
|
||||||
List<FieldError> fieldErrors = bindingResult.getFieldErrors();
|
.parallelStream()
|
||||||
// 循环获得所有校验异常的字段
|
.map(m -> /*m.getField() + ":" +*/ m.getDefaultMessage())
|
||||||
Map<String, String> fieldMap = new HashMap<>();
|
.collect(Collectors.joining(","));
|
||||||
for (FieldError fieldError : fieldErrors) {
|
log.error(e.getMessage(), e);
|
||||||
fieldMap.put(fieldError.getField(), fieldError.getDefaultMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
String errMsg = fieldMap.values().toString().replaceAll("]", "").replaceAll("\\[", "");
|
|
||||||
log.warn(errMsg);
|
|
||||||
// 返回给前端
|
|
||||||
return Result.error(errMsg);
|
return Result.error(errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理空指针异常
|
* 处理空指针异常
|
||||||
|
*
|
||||||
* @param nullPointerException 空指针异常
|
* @param nullPointerException 空指针异常
|
||||||
* @return Result
|
* @return Result
|
||||||
*/
|
*/
|
||||||
|
@ -66,13 +63,14 @@ public class ControllerAdvice {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 所有的运行时异常,抛出异常
|
* 所有的运行时异常,抛出异常
|
||||||
|
*
|
||||||
* @param throwable 异常
|
* @param throwable 异常
|
||||||
* @return Result
|
* @return Result
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(value = Throwable.class)
|
@ExceptionHandler(value = Throwable.class)
|
||||||
public Result<String> handleException(Throwable throwable) {
|
public Result<String> handleException(Throwable throwable) {
|
||||||
log.error("异常类型: {}, {}, 信息为: {}", throwable.getCause(), throwable.getClass(), throwable.getMessage());
|
log.error("异常类型: {}, {}, 信息为: {}", throwable.getCause(), throwable.getClass(), throwable.getMessage());
|
||||||
if (throwable instanceof RRException){
|
if (throwable instanceof RRException) {
|
||||||
RRException rrException = (RRException) throwable;
|
RRException rrException = (RRException) throwable;
|
||||||
return Result.error(rrException.getCode(), rrException.getMsg());
|
return Result.error(rrException.getCode(), rrException.getMsg());
|
||||||
}
|
}
|
||||||
|
@ -81,24 +79,26 @@ public class ControllerAdvice {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* http信息无可读
|
* http信息无可读
|
||||||
|
*
|
||||||
* @param e 异常
|
* @param e 异常
|
||||||
* @return Result
|
* @return Result
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(value = HttpMessageNotReadableException.class)
|
@ExceptionHandler(value = HttpMessageNotReadableException.class)
|
||||||
public Result<String> httpMessageNotReadAbleException(HttpMessageNotReadableException e){
|
public Result<String> httpMessageNotReadAbleException(HttpMessageNotReadableException e) {
|
||||||
log.warn("异常类型: {} 无可读信息: ", e.getClass(), e);
|
log.warn("异常类型: {} 无可读信息: ", e.getClass(), e);
|
||||||
return Result.error(ErrorEnum.HTTP_MESSAGE_NOT_READABLE_EXCEPTION);
|
return Result.error(ErrorEnum.HTTP_MESSAGE_NOT_READABLE_EXCEPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 运行时异常
|
* 运行时异常
|
||||||
|
*
|
||||||
* @param e 运行异常对象
|
* @param e 运行异常对象
|
||||||
* @return Result
|
* @return Result
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(value = RuntimeException.class)
|
@ExceptionHandler(value = RuntimeException.class)
|
||||||
public Result<String> runtimeException(RuntimeException e){
|
public Result<String> runtimeException(RuntimeException e) {
|
||||||
log.error("运行时异常:", e);
|
log.error("运行时异常:", e);
|
||||||
if (e instanceof RRException){
|
if (e instanceof RRException) {
|
||||||
RRException rrException = (RRException) e;
|
RRException rrException = (RRException) e;
|
||||||
return Result.error(rrException.getCode(), rrException.getMsg());
|
return Result.error(rrException.getCode(), rrException.getMsg());
|
||||||
}
|
}
|
||||||
|
@ -107,31 +107,34 @@ public class ControllerAdvice {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求不支持
|
* 请求不支持
|
||||||
|
*
|
||||||
* @return Result
|
* @return Result
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(value = HttpRequestMethodNotSupportedException.class)
|
@ExceptionHandler(value = HttpRequestMethodNotSupportedException.class)
|
||||||
public Result<String> httpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e){
|
public Result<String> httpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
|
||||||
log.warn("暂不支持该请求: ", e);
|
log.warn("暂不支持该请求: ", e);
|
||||||
return Result.error("暂不支持此请求方式");
|
return Result.error("暂不支持此请求方式");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数类型错误
|
* 参数类型错误
|
||||||
|
*
|
||||||
* @return Result
|
* @return Result
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
|
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
|
||||||
public Result<String> methodArgument(MethodArgumentTypeMismatchException e){
|
public Result<String> methodArgument(MethodArgumentTypeMismatchException e) {
|
||||||
log.warn("参数发生错误: ", e);
|
log.warn("参数发生错误: ", e);
|
||||||
return Result.error("参数发生错误");
|
return Result.error("参数发生错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缺少请求参数
|
* 缺少请求参数
|
||||||
|
*
|
||||||
* @param e 缺少请求参数异常
|
* @param e 缺少请求参数异常
|
||||||
* @return Result
|
* @return Result
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(MissingServletRequestParameterException.class)
|
@ExceptionHandler(MissingServletRequestParameterException.class)
|
||||||
public Result<String> exception(MissingServletRequestParameterException e){
|
public Result<String> exception(MissingServletRequestParameterException e) {
|
||||||
log.warn("缺少请求参数: ", e);
|
log.warn("缺少请求参数: ", e);
|
||||||
return Result.error("缺少请求参数");
|
return Result.error("缺少请求参数");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,16 @@
|
||||||
package com.dpkj.modules.chs.controller;
|
package com.dpkj.modules.chs.controller;
|
||||||
|
|
||||||
import cn.hutool.core.date.DatePattern;
|
|
||||||
import cn.hutool.core.date.DateUnit;
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import cn.hutool.core.lang.Console;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.dpkj.common.vo.Result;
|
import com.dpkj.common.vo.Result;
|
||||||
import com.dpkj.modules.chs.service.IHispayService;
|
import com.dpkj.modules.chs.service.IHispayService;
|
||||||
|
import com.dpkj.modules.chs.vo.OutpatientBudgetModel;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.Mapping;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,23 +30,88 @@ public class HispayController {
|
||||||
/**
|
/**
|
||||||
* 通过医保卡或医保电子凭证读卡
|
* 通过医保卡或医保电子凭证读卡
|
||||||
*
|
*
|
||||||
* @param data : type 1.就诊卡,2.医保卡,5.门诊号,6.患者姓名和电话号码,8.电子健康码/卡,9.医保电子凭证
|
|
||||||
* @return com.dpkj.common.vo.Result<?>
|
* @return com.dpkj.common.vo.Result<?>
|
||||||
* @author 萧道子 2025/5/20
|
* @author 萧道子 2025/5/20
|
||||||
*/
|
*/
|
||||||
|
@PostMapping("findReadCode")
|
||||||
|
public Result<?> findReadCode() {
|
||||||
|
try {
|
||||||
|
JSONObject res = iHispayService.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")
|
@PostMapping("findReadCard")
|
||||||
public Result<?> findReadCard(@RequestBody JSONObject data) {
|
public Result<?> findReadCard(@RequestBody JSONObject data) {
|
||||||
|
try {
|
||||||
|
String password = data.getString("password");
|
||||||
|
if (StrUtil.isEmpty(password)) {
|
||||||
|
throw new RuntimeException("密码不可为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject res = iHispayService.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("outpatientBudgetByCode")
|
||||||
|
public Result<?> outpatientBudgetByCode(@RequestBody @Validated OutpatientBudgetModel data) {
|
||||||
|
try {
|
||||||
|
log.info("[HispayController][outpatientBudgetByCode][门诊缴费-预算-电子医保凭证] 参数:{}", data);
|
||||||
|
JSONObject res = iHispayService.outpatientBudgetByCode(data);
|
||||||
|
return Result.ok("成功", res);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.info("[HispayController][outpatientBudgetByCode][门诊缴费-预算-电子医保凭证] 失败:{}", e.getMessage());
|
||||||
|
return Result.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 门诊缴费-结算
|
||||||
|
*
|
||||||
|
* @param data :
|
||||||
|
* @return com.dpkj.common.vo.Result<?>
|
||||||
|
* @author 萧道子 2025/5/27
|
||||||
|
*/
|
||||||
|
@PostMapping("doOutpatientPayment")
|
||||||
|
public Result<?> doRegistrationPayment(@RequestBody JSONObject data) {
|
||||||
try {
|
try {
|
||||||
String type = data.getString("type");
|
String type = data.getString("type");
|
||||||
if (StrUtil.isEmpty(type)) {
|
if (StrUtil.isEmpty(type)) {
|
||||||
throw new RuntimeException("参数缺失");
|
throw new RuntimeException("参数缺失");
|
||||||
}
|
}
|
||||||
log.info("[HispayController][getPatientInfo][医保读卡] 读卡类型:{}", type);
|
|
||||||
JSONObject res = iHispayService.getPatientInfo(type, null);
|
log.info("[HispayController][doRegistrationPayment][挂号-结算] 参数:{}", data);
|
||||||
return Result.ok("成功", res);
|
return Result.ok("成功", null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
log.error("[HispayController][getPatientInfo][医保读卡] :{}", e.getMessage());
|
log.info("[HispayController][doRegistrationPayment][挂号-结算] 失败:{}", e.getMessage());
|
||||||
return Result.error(e.getMessage());
|
return Result.error(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,45 @@
|
||||||
package com.dpkj.modules.chs.service;
|
package com.dpkj.modules.chs.service;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.dpkj.modules.chs.vo.OutpatientBudgetModel;
|
||||||
|
|
||||||
public interface IHispayService {
|
public interface IHispayService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 门诊病人读卡
|
* 通过医保电子凭证读卡
|
||||||
*
|
*
|
||||||
* @param type : 1.就诊卡,2.医保卡,5.门诊号,6.患者姓名和电话号码,8.电子健康码/卡,9.医保电子凭证
|
* @return com.alibaba.fastjson.JSONObject
|
||||||
* @param content : 医保卡: 密码 医保电子凭证:条码内容
|
* @author 萧道子 2025/5/28
|
||||||
* @return void
|
|
||||||
* @author 萧道子 2025/4/28
|
|
||||||
*/
|
*/
|
||||||
JSONObject getPatientInfo(String type, String content);
|
JSONObject readCode();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过医保卡-读卡
|
||||||
|
*
|
||||||
|
* @return com.alibaba.fastjson.JSONObject
|
||||||
|
* @author 萧道子 2025/5/28
|
||||||
|
*/
|
||||||
|
JSONObject readCard(String password);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 门诊缴费-预算 电子凭证支付
|
||||||
|
*
|
||||||
|
* @param data :
|
||||||
|
* @return com.dpkj.common.vo.Result<?>
|
||||||
|
* @author 萧道子 2025/5/27
|
||||||
|
*/
|
||||||
|
JSONObject outpatientBudgetByCode(OutpatientBudgetModel data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 门诊缴费-预算 医保卡支付
|
||||||
|
*
|
||||||
|
* @param data :
|
||||||
|
* @return com.dpkj.common.vo.Result<?>
|
||||||
|
* @author 萧道子 2025/5/27
|
||||||
|
*/
|
||||||
|
JSONObject outpatientBudgetByCard(OutpatientBudgetModel data);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
package com.dpkj.modules.chs.service.impl;
|
package com.dpkj.modules.chs.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.io.file.FileReader;
|
import cn.hutool.core.io.file.FileReader;
|
||||||
import cn.hutool.core.lang.Console;
|
import cn.hutool.core.lang.Console;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.core.util.XmlUtil;
|
import cn.hutool.core.util.XmlUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.dpkj.common.config.ChsConfig;
|
import com.dpkj.common.config.ChsConfig;
|
||||||
|
@ -12,6 +13,7 @@ import com.dpkj.common.config.HisConfig;
|
||||||
import com.dpkj.common.utils.IDGenerator;
|
import com.dpkj.common.utils.IDGenerator;
|
||||||
import com.dpkj.modules.chs.dll.HispayDll;
|
import com.dpkj.modules.chs.dll.HispayDll;
|
||||||
import com.dpkj.modules.chs.service.IHispayService;
|
import com.dpkj.modules.chs.service.IHispayService;
|
||||||
|
import com.dpkj.modules.chs.vo.OutpatientBudgetModel;
|
||||||
import com.jacob.activeX.ActiveXComponent;
|
import com.jacob.activeX.ActiveXComponent;
|
||||||
import com.jacob.com.ComThread;
|
import com.jacob.com.ComThread;
|
||||||
import com.jacob.com.Dispatch;
|
import com.jacob.com.Dispatch;
|
||||||
|
@ -19,13 +21,11 @@ import com.jacob.com.Variant;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,82 +42,13 @@ public class HispayServiceImpl implements IHispayService {
|
||||||
private final HisConfig hisConfig;
|
private final HisConfig hisConfig;
|
||||||
private final ChsConfig chsConfig;
|
private final ChsConfig chsConfig;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JSONObject getPatientInfo(String type, String content) {
|
|
||||||
Dispatch dispatch = instanceActive();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 1、删除保存HIS读卡内容的文件 避免读取到错误信息
|
|
||||||
*/
|
|
||||||
// 获取HIS-CHS医保库路径
|
|
||||||
String chsPath = System.getProperty("java.library.path");
|
|
||||||
String filePath = chsPath + "/" + chsConfig.getFileName();
|
|
||||||
// 删除文件
|
|
||||||
FileUtil.del(FileUtil.file(filePath));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 2、组装参数
|
|
||||||
*/
|
|
||||||
String soleid = IDGenerator.getSnowflakeIdToStr();
|
|
||||||
JSONObject req = new JSONObject() {{
|
|
||||||
put("timestamp", DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss")); // 请求发送时间
|
|
||||||
put("requestid", soleid); // 唯一请求id
|
|
||||||
put("operid", hisConfig.getOperationId()); // 调用者代码
|
|
||||||
put("password", content); // 密码
|
|
||||||
put("params", new JSONObject() {{
|
|
||||||
put("cardtype", type); // 1.就诊卡,2.医保卡,5.门诊号,6.患者姓名和电话号码,8.电子健康码/卡,9.医保电子凭证
|
|
||||||
put("cardno", ""); // 患者就诊卡号
|
|
||||||
put("sfzh", ""); // 身份证号
|
|
||||||
put("hzxm", ""); // 患者姓名
|
|
||||||
put("phone", ""); // 患者电话号码
|
|
||||||
}});
|
|
||||||
}};
|
|
||||||
Document document = XmlUtil.mapToXml(req, "request");
|
|
||||||
String params = XmlUtil.toStr(document, "UTF-8", false, true);
|
|
||||||
log.info("[HispayServiceImpl][getPatientInfo][医保读卡] 接口入参:{}", params);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 3、调用COM函数
|
|
||||||
*/
|
|
||||||
Variant rest = new Variant();
|
|
||||||
Variant call = Dispatch.call(dispatch, "fRun", "BMZXX010", params, rest);
|
|
||||||
log.info("[HispayServiceImpl][getPatientInfo][医保读卡] call返回值:{}", call);
|
|
||||||
|
|
||||||
// 释放资源
|
|
||||||
releaseActive();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 4、处理读卡结果
|
|
||||||
*/
|
|
||||||
// COM函数调用之后会生成新的文件 需要判断
|
|
||||||
File file = FileUtil.file(filePath);
|
|
||||||
if (!file.exists()) {
|
|
||||||
throw new RuntimeException("读卡失败:数据未读取");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取读卡结果
|
|
||||||
FileReader fileReader = new FileReader(file, "GBK");
|
|
||||||
String data = fileReader.readString();
|
|
||||||
|
|
||||||
JSONObject result;
|
|
||||||
try {
|
|
||||||
result = JSONObject.parseObject(data);
|
|
||||||
log.info("[HispayServiceImpl][getPatientInfo][医保读卡] 读卡值:{}", result);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("读卡失败:" + data);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取HIS医保实例
|
* 获取HIS医保实例
|
||||||
*
|
*
|
||||||
* @return com.jacob.activeX.ActiveXComponent
|
* @return com.jacob.activeX.ActiveXComponent
|
||||||
* @author 萧道子 2025/5/21
|
* @author 萧道子 2025/5/21
|
||||||
*/
|
*/
|
||||||
private Dispatch instanceActive() {
|
private ActiveXComponent instanceActive() {
|
||||||
try {
|
try {
|
||||||
// 初始化
|
// 初始化
|
||||||
ComThread.InitSTA();
|
ComThread.InitSTA();
|
||||||
|
@ -142,5 +73,227 @@ public class HispayServiceImpl implements IHispayService {
|
||||||
ComThread.Release();
|
ComThread.Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理参数
|
||||||
|
*
|
||||||
|
* @param params : 请求参数
|
||||||
|
* @param password : 密码
|
||||||
|
* @return java.lang.String
|
||||||
|
* @author 萧道子 2025/5/27
|
||||||
|
*/
|
||||||
|
private String processParameters(JSONObject params, String password) {
|
||||||
|
JSONObject req = new JSONObject() {{
|
||||||
|
put("timestamp", DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss")); // 请求发送时间
|
||||||
|
put("requestid", IDGenerator.getSnowflakeIdToStr()); // 唯一请求id
|
||||||
|
put("operid", hisConfig.getOperationId()); // 调用者代码
|
||||||
|
put("password", password); // 密码
|
||||||
|
put("params", params);
|
||||||
|
}};
|
||||||
|
Document document = XmlUtil.mapToXml(req, "request");
|
||||||
|
return XmlUtil.toStr(document, "UTF-8", false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验结果
|
||||||
|
*
|
||||||
|
* @param resStr :
|
||||||
|
* @return com.alibaba.fastjson.JSONObject
|
||||||
|
* @author 萧道子 2025/5/28
|
||||||
|
*/
|
||||||
|
private JSONObject verifyResult(String resStr) {
|
||||||
|
|
||||||
|
if (StrUtil.isBlank(resStr)) {
|
||||||
|
throw new RuntimeException("信息获取失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> resMap = XmlUtil.xmlToMap(resStr);
|
||||||
|
JSONObject resJson = new JSONObject(resMap);
|
||||||
|
|
||||||
|
if (StrUtil.equals(resJson.getString("resultCode"), "1")) {
|
||||||
|
throw new RuntimeException(resJson.getString("resultMessage"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!resJson.containsKey("result")) {
|
||||||
|
throw new RuntimeException("result数据为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
return resJson.getJSONObject("result");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject readCode() {
|
||||||
|
// 加载资源
|
||||||
|
Dispatch dispatch = instanceActive();
|
||||||
|
|
||||||
|
/** 1、组装参数 */
|
||||||
|
JSONObject val = new JSONObject()
|
||||||
|
.fluentPut("cardtype", "9") // 1.就诊卡,2.医保卡,5.门诊号,6.患者姓名和电话号码,8.电子健康码/卡,9.医保电子凭证
|
||||||
|
.fluentPut("cardno", "") // 患者就诊卡号
|
||||||
|
.fluentPut("sfzh", "") // 身份证号
|
||||||
|
.fluentPut("hzxm", "") // 患者姓名
|
||||||
|
.fluentPut("phone", ""); // 患者电话号码
|
||||||
|
String params = processParameters(val, null);
|
||||||
|
log.info("[HispayServiceImpl][readCode][医保读卡-电子凭证] 接口入参:{}", params);
|
||||||
|
|
||||||
|
/** 2、调用COM函数 */
|
||||||
|
Variant vres = new Variant("", true);
|
||||||
|
Variant call = Dispatch.call(dispatch, "fRun", "BMZXX010", params, vres);
|
||||||
|
|
||||||
|
String resStr = vres.getStringRef();
|
||||||
|
log.info("[HispayServiceImpl][readCode][医保读卡-电子凭证] call返回值:{} 结果:{}", call, resStr);
|
||||||
|
|
||||||
|
// 释放资源
|
||||||
|
releaseActive();
|
||||||
|
|
||||||
|
/** 3、处理读卡结果 */
|
||||||
|
JSONObject result = verifyResult(resStr);
|
||||||
|
if (!result.containsKey("item")) {
|
||||||
|
throw new RuntimeException("item数据为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.getJSONObject("item");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject readCard(String password) {
|
||||||
|
// 加载资源
|
||||||
|
Dispatch dispatch = instanceActive();
|
||||||
|
|
||||||
|
/** 1、组装参数 */
|
||||||
|
JSONObject val = new JSONObject()
|
||||||
|
.fluentPut("cardtype", "2") // 1.就诊卡,2.医保卡,5.门诊号,6.患者姓名和电话号码,8.电子健康码/卡,9.医保电子凭证
|
||||||
|
.fluentPut("cardno", "") // 患者就诊卡号
|
||||||
|
.fluentPut("sfzh", "") // 身份证号
|
||||||
|
.fluentPut("hzxm", "") // 患者姓名
|
||||||
|
.fluentPut("phone", ""); // 患者电话号码
|
||||||
|
String params = processParameters(val, password);
|
||||||
|
log.info("[HispayServiceImpl][readCard][医保读卡-医保卡] 接口入参:{}", params);
|
||||||
|
|
||||||
|
/** 2、调用COM函数 */
|
||||||
|
Variant vres = new Variant("", true);
|
||||||
|
Variant call = Dispatch.call(dispatch, "fRun", "BMZXX010", params, vres);
|
||||||
|
|
||||||
|
String resStr = vres.getStringRef();
|
||||||
|
log.info("[HispayServiceImpl][readCard][医保读卡-医保卡] call返回值:{} 结果:{}", call, resStr);
|
||||||
|
|
||||||
|
// 释放资源
|
||||||
|
releaseActive();
|
||||||
|
|
||||||
|
/** 3、处理读卡结果 */
|
||||||
|
JSONObject result = verifyResult(resStr);
|
||||||
|
if (!result.containsKey("item")) {
|
||||||
|
throw new RuntimeException("item数据为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.getJSONObject("item");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// public JSONObject getPatientInfo_old(String type, String content) {
|
||||||
|
// Dispatch dispatch = instanceActive();
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 1、删除保存HIS读卡内容的文件 避免读取到错误信息
|
||||||
|
// */
|
||||||
|
// // 获取HIS-CHS医保库路径
|
||||||
|
// String chsPath = System.getProperty("java.library.path");
|
||||||
|
// String filePath = chsPath + "/" + chsConfig.getFileName();
|
||||||
|
// // 删除文件
|
||||||
|
// FileUtil.del(FileUtil.file(filePath));
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 2、组装参数
|
||||||
|
// */
|
||||||
|
// JSONObject val = new JSONObject()
|
||||||
|
// .fluentPut("cardtype", type) // 1.就诊卡,2.医保卡,5.门诊号,6.患者姓名和电话号码,8.电子健康码/卡,9.医保电子凭证
|
||||||
|
// .fluentPut("cardno", "") // 患者就诊卡号
|
||||||
|
// .fluentPut("sfzh", "") // 身份证号
|
||||||
|
// .fluentPut("hzxm", "") // 患者姓名
|
||||||
|
// .fluentPut("phone", ""); // 患者电话号码
|
||||||
|
// String params = processParameters(val, content);
|
||||||
|
// log.info("[HispayServiceImpl][getPatientInfo][医保读卡] 接口入参:{}", params);
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 3、调用COM函数
|
||||||
|
// */
|
||||||
|
// Variant rest = new Variant();
|
||||||
|
// Variant call = Dispatch.call(dispatch, "fRun", "BMZXX010", params, rest);
|
||||||
|
// log.info("[HispayServiceImpl][getPatientInfo][医保读卡] call返回值:{}", call);
|
||||||
|
//
|
||||||
|
// // 释放资源
|
||||||
|
// releaseActive();
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 4、处理读卡结果
|
||||||
|
// */
|
||||||
|
// // COM函数调用之后会生成新的文件 需要判断
|
||||||
|
// File file = FileUtil.file(filePath);
|
||||||
|
// if (!file.exists()) {
|
||||||
|
// throw new RuntimeException("读卡失败:数据未读取");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 获取读卡结果
|
||||||
|
// FileReader fileReader = new FileReader(file, "GBK");
|
||||||
|
// String data = fileReader.readString();
|
||||||
|
//
|
||||||
|
// JSONObject result;
|
||||||
|
// try {
|
||||||
|
// result = JSONObject.parseObject(data);
|
||||||
|
// log.info("[HispayServiceImpl][getPatientInfo][医保读卡] 读卡值:{}", result);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// throw new RuntimeException("读卡失败:" + data);
|
||||||
|
// }
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
private JSONObject outpatientBudget(OutpatientBudgetModel data) {
|
||||||
|
// 加载资源
|
||||||
|
ActiveXComponent dispatch = instanceActive();
|
||||||
|
|
||||||
|
/** 1、组装参数 */
|
||||||
|
JSONObject val = new JSONObject()
|
||||||
|
.fluentPut("patid", data.getPatientId()) // 病人ID
|
||||||
|
.fluentPut("cfxhhj", data.getPrescriptionNo()) // 划价单据,格式:单据1,单据2,单据3
|
||||||
|
.fluentPut("czksfbz", "0") // 是否扣院内账户,0不使用院内账户,1使用院内账户(默认不使用院内账户)
|
||||||
|
.fluentPut("zfjsbz", "0") // 是否自费结算,0根据医保代码缴费,1自费结算(默认自费结算)
|
||||||
|
.fluentPut("ybrc", ""); // 医保入参,xml节点
|
||||||
|
String params = processParameters(val, data.getPassword());
|
||||||
|
log.info("[HispayServiceImpl][outpatientBudget][门诊缴费-预算] 接口入参:{}", params);
|
||||||
|
|
||||||
|
/** 2、调用COM函数 */
|
||||||
|
Variant resVariant = new Variant("", true);
|
||||||
|
Variant call = Dispatch.call(dispatch, "fRun", "BMZJF001", params, resVariant);
|
||||||
|
|
||||||
|
String resStr = resVariant.getStringRef();
|
||||||
|
log.info("[HispayServiceImpl][outpatientBudget][门诊缴费-预算] call返回值:{} 结果:{}", call, resStr);
|
||||||
|
|
||||||
|
// 释放资源
|
||||||
|
releaseActive();
|
||||||
|
|
||||||
|
/** 3、处理结果 */
|
||||||
|
return verifyResult(resStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject outpatientBudgetByCode(OutpatientBudgetModel data) {
|
||||||
|
JSONObject userInfo = readCode();
|
||||||
|
|
||||||
|
String patientId = userInfo.getString("patid");
|
||||||
|
data.setPatientId(patientId);
|
||||||
|
JSONObject result = outpatientBudget(data);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject outpatientBudgetByCard(OutpatientBudgetModel data) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.dpkj.modules.chs.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Auther: 萧道子
|
||||||
|
* @Date: 2025/5/27 16:52
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class OutpatientBudgetModel implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 病人ID
|
||||||
|
*/
|
||||||
|
// @NotEmpty(message = "患者ID不可为空!")
|
||||||
|
private String patientId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处方单号 - 多个逗号拼接
|
||||||
|
*/
|
||||||
|
@NotEmpty(message = "处方单号不可为空!")
|
||||||
|
private String prescriptionNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 病人ID
|
||||||
|
*/
|
||||||
|
// @NotEmpty(message = "密码不可为空!")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
}
|
|
@ -9,8 +9,6 @@ dpkj:
|
||||||
chs:
|
chs:
|
||||||
# 医保机构编码
|
# 医保机构编码
|
||||||
orgcode: H53082800070
|
orgcode: H53082800070
|
||||||
# 医保读卡之后保存信息的文件名
|
|
||||||
file-name: outfile1191.txt
|
|
||||||
file:
|
file:
|
||||||
# 文件保存地址
|
# 文件保存地址
|
||||||
path: D:\Project\Express\upload
|
path: D:\Project\Express\upload
|
||||||
|
|
Loading…
Reference in New Issue