电子健康卡和医共体id同步调整

debug
王绍全 2 weeks ago
parent 8d8b77d460
commit f808cb2f81
  1. 267
      src/main/java/com/ynxbd/common/action/HealthCardAction.java
  2. 3
      src/main/java/com/ynxbd/common/action/HealthCodeAction.java
  3. 18
      src/main/java/com/ynxbd/common/action/PatientAction.java
  4. 3
      src/main/java/com/ynxbd/common/action/RecipeAction.java
  5. 5
      src/main/java/com/ynxbd/common/action/pay/PayAction.java
  6. 2
      src/main/java/com/ynxbd/common/action/test/TestAction.java
  7. 2
      src/main/java/com/ynxbd/common/bean/HisRecipe.java
  8. 18
      src/main/java/com/ynxbd/common/config/HealthCardConfig.java
  9. 67
      src/main/java/com/ynxbd/common/dao/PatientDao.java
  10. 3
      src/main/java/com/ynxbd/common/dao/his/HisAccountDao.java
  11. 426
      src/main/java/com/ynxbd/common/helper/HealthCardHelper.java
  12. 10
      src/main/java/com/ynxbd/common/helper/common/ValidHelper.java
  13. 142
      src/main/java/com/ynxbd/common/service/HCodeService.java
  14. 78
      src/main/java/com/ynxbd/common/service/HealthCardService.java
  15. 4
      src/main/java/com/ynxbd/common/service/HealthUploadService.java
  16. 8
      src/main/java/com/ynxbd/wx/config/MessagePushConfig.java
  17. 1
      src/main/java/com/ynxbd/wx/servlet/QServlet.java
  18. 2
      src/main/resources/hcode.properties

@ -2,24 +2,279 @@ package com.ynxbd.common.action;
import com.alibaba.fastjson.JSONObject;
import com.ynxbd.common.action.base.BaseAction;
import com.ynxbd.common.bean.Patient;
import com.ynxbd.common.bean.User;
import com.ynxbd.common.bean.enums.HCardTypeEnum;
import com.ynxbd.common.bean.enums.HealthCardRespCodeEnum;
import com.ynxbd.common.config.interceptor.AesDecode;
import com.ynxbd.common.dao.PatientDao;
import com.ynxbd.common.helper.HealthCardHelper;
import com.ynxbd.common.helper.common.DateHelper;
import com.ynxbd.common.helper.common.IDNumberHelper;
import com.ynxbd.common.helper.common.ValidHelper;
import com.ynxbd.common.result.Result;
import com.ynxbd.common.service.HCodeService;
import com.ynxbd.wx.config.WeChatConfig;
import com.ynxbd.common.result.ResultEnum;
import com.ynxbd.common.service.PatientService;
import com.ynxbd.wx.wxfactory.WxCacheHelper;
import lombok.extern.slf4j.Slf4j;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.ehcache.Cache;
@Slf4j
@Namespace("/hc")
@Namespace("/health_card")
public class HealthCardAction extends BaseAction {
/**
* [电子健康卡]绑卡验证授权
*/
@Action("registerHealthCardPreAuth")
public Result registerHealthCardPreAuth(Boolean isMiniApp, String wechatCode, String healthCode, String openId) {
log.info("[电子健康卡]绑卡验证授权 isMiniApp={}, wechatCode={}, healthCode={}, openId={}", isMiniApp, wechatCode, healthCode, openId);
JSONObject result = HCodeService.registerHealthCardPreAuth(isMiniApp, false, wechatCode, healthCode, openId);
public Result registerHealthCardPreAuth(Boolean isMiniApp, @AesDecode String openid, String wechatCode) {
log.info("[电子健康卡]绑卡验证授权 isMiniApp={}, wechatCode={}, openid={}", isMiniApp, wechatCode, openid);
JSONObject result = new HealthCardHelper().registerHealthCardPreAuth(isMiniApp, false, wechatCode);
if (result == null) {
return Result.error();
}
return Result.success(result);
}
/**
* [电子健康卡]验证注册/绑卡接口
*/
@Action("registerHealthCardPreFill")
public Result registerHealthCardPreFill(Boolean isMiniApp, @AesDecode String openid, String authCode, String name, String gender, String nation, String birthday, String idNumber, String phone) {
log.info("[电子健康卡]验证注册/绑卡接口 isMiniApp={}, authCode={}, name={}, openid={}", isMiniApp, authCode, name, openid);
JSONObject result = new HealthCardHelper().registerHealthCardPreFill(isMiniApp, authCode, name, gender, nation, birthday,
idNumber, HCardTypeEnum._01, phone);
if (result == null) {
return Result.error();
}
return Result.success(result);
}
/**
* [电子健康卡]健康卡授权码获取健康卡信息
*/
@Action("getHealthCardByHealthCode")
public Result getHealthCardByHealthCode(Boolean isMiniApp, @AesDecode String openid, String healthCode) {
try {
log.info("[电子健康卡]健康卡授权码获取健康卡信息 isMiniApp={}, openid={}, 健康卡授权码={}", isMiniApp, openid, healthCode);
Patient patient = HealthCardHelper.getHealthCardByHealthCode(isMiniApp, healthCode);
return Result.success(patient);
} catch (Exception e) {
return Result.error(e);
}
}
/**
* [电子健康卡]获取建档信息接口[]
*/
@Action("getRegInfoByCode")
public Result getRegInfoByCode(Boolean isMiniApp, @AesDecode String openid, String regInfoCode) {
try {
log.info("[电子健康卡]获取建档信息接口 isMiniApp={}, openid={}, 建档授权码={}", isMiniApp, openid, regInfoCode);
Patient patient = HealthCardHelper.getRegInfoByCode(isMiniApp, regInfoCode);
return Result.success(patient);
} catch (Exception e) {
return Result.error(e);
}
}
/**
* [电子健康卡]身份证识别
*/
@Action("orcInfo")
public Result orcInfo(@AesDecode String openid, String image) {
try {
System.out.println("[电子健康卡]身份证识别...");
if (image == null) {
return Result.error(ResultEnum.PARAM_IS_DEFECT);
}
Patient patient = HealthCardHelper.orcInfo(image);
return Result.success(patient);
} catch (Exception e) {
return Result.error(e);
}
}
/**
* 获取健康卡二维码
*
* @param isMiniApp isMiniApp
* @param idCardNo 证件号码
* @param healthCardId 健康卡ID
*/
@Action("getDynamicQRCode")
public Result getDynamicQRCode(Boolean isMiniApp, @AesDecode String idCardNo, String healthCardId) {
log.info("[电子健康卡]获取二维码 healthCardId={}", healthCardId);
if (healthCardId == null || idCardNo == null) {
return Result.error(ResultEnum.PARAM_IS_DEFECT); // 参数缺失
}
JSONObject result = HealthCardHelper.getDynamicQRCode(isMiniApp, healthCardId, idCardNo, "0");
return result == null ? Result.error() : Result.success(result);
}
/**
* [电子健康卡]身份绑定成人
*/
@Action("bindCard")
public Result bindCard(@AesDecode String openid, Boolean isEnableHC, String healthCardId, boolean isAreaCode, String address, String areaCode, String areaAddress, String tel, String sex, String name, String nation, String birthday, String idCardNo, String cardType, String enUnionId, String enGmcOpenId) {
log.info("[电子健康卡]身份绑定 openid={}, isEnableHC={} healthCardId={}, name={}, sex={}, nation={}, birthday={}, tel={}, address={}, areaCode={}, areaAddress={}, cardType={}, enUnionId={}, enGmcOpenId={}",
openid, isEnableHC, healthCardId, name, sex, nation, birthday, tel, address, areaCode, areaAddress, cardType, enUnionId, enGmcOpenId);
if (tel == null || sex == null || birthday == null || name == null) {
return Result.error(ResultEnum.PARAM_IS_DEFECT);
}
if (address == null || areaCode == null) {
log.info("[电子健康卡]地址参数缺失 areaCode={}, address={}", areaCode, address);
return Result.error(ResultEnum.PARAM_ADDRESS_ERROR);
}
if (openid == null) {
return Result.error(ResultEnum.PARAM_IS_INVALID);
}
if (cardType == null) cardType = HCardTypeEnum._01.WX_CODE;
HCardTypeEnum cardTypeEnum = HCardTypeEnum.toTypeByWxCode(cardType);
if (cardTypeEnum == null) {
return Result.error(ResultEnum.CARD_TYPE_NOT_FOUNT);
}
if (!ValidHelper.isValidTel(tel)) {
log.info("[电子健康卡]电话号码错误 name={}, tel={}, idCardNo={}", name, tel, idCardNo);
return Result.error(ResultEnum.TEL_ERROR);
}
if (!ValidHelper.isValidIdCard(idCardNo)) {
log.info("[电子健康卡]身份证错误 name={}, tel={}, idCardNo={}", name, tel, idCardNo);
return Result.error(ResultEnum.ID_CARD_ERROR);
}
if (!ValidHelper.isValidNation(nation)) {
return Result.error(ResultEnum.NATION_ERROR);
}
if (!DateHelper.isValidDate(birthday)) { // 生日异常
return Result.error(ResultEnum.PARAM_DATE_ERROR);
}
Patient info = new Patient();
info.setOpenid(openid);
info.setHealthCardId(healthCardId);
info.setName(name);
info.setSex(sex);
info.setIdCardNo(idCardNo);
info.setCardTypeEnum(cardTypeEnum);
info.setTel(tel);
info.setBirthday(birthday);
info.setNation(nation);
info.setAddress(address);
info.setAreaCode(areaCode);
info.setAreaAddress(areaAddress);
//
info.setEnUnionId(enUnionId);
info.setEnGmcOpenId(enGmcOpenId);
return new PatientService().bindCard(request, false, isAreaCode, info);
}
/**
* [升级绑定]-->已在HIS绑定-->注册健康卡
*
* @param wechatCode wechatCode
* @param id id
* @param idCardNo idCardNo
* @param cardType cardType
* @param openid openid
* @param tel tel
* @param name name
* @param nation nation
* @param patientId patientId
* @param address address
*/
@Action("upBindCard")
public Result upBindCard(String wechatCode, Integer id, @AesDecode String idCardNo, @AesDecode String patientId, String cardType, String openid, String tel, String name, String nation, String address) {
log.info("[电子健康卡]升级绑定 id={}, name={}, address={}, nation={}, patientId={}, tel={}, idType={}, wechatCode={}", id, name, address, nation, patientId, tel, cardType, wechatCode);
if (wechatCode == null || openid == null || patientId == null || name == null || idCardNo == null || tel == null || address == null || nation == null) {
return Result.error(ResultEnum.PARAM_IS_DEFECT);
}
if (cardType == null) cardType = HCardTypeEnum._01.WX_CODE;
HCardTypeEnum cardTypeEnum = HCardTypeEnum.toTypeByWxCode(cardType);
if (cardTypeEnum == null) {
return Result.error(ResultEnum.CARD_TYPE_NOT_FOUNT);
}
if (!ValidHelper.isValidNation(nation)) {
return Result.error(ResultEnum.NATION_ERROR);
}
String sex = IDNumberHelper.getSex(idCardNo);
String birthday = IDNumberHelper.getBirthday(idCardNo);
if (sex == null || birthday == null) { // 身份证解析数据错误
log.info("[电子健康卡]升级绑失败,身份证解析数据错误 sex={} birthday={}", sex, birthday);
return Result.error(ResultEnum.PARAM_TYPE_ERROR);
}
// 先注册,后修改-->先获取健康卡ID
JSONObject rspObj = HealthCardHelper.registerHealthCard(false, patientId, wechatCode, birthday, cardTypeEnum, address, null, sex, nation, name, idCardNo, tel);
if (rspObj == null) {
log.info("[电子健康卡]升级绑定失败, 响应内容为空");
return Result.error("[电子健康卡]升级绑定失败, 响应内容为空");
}
String healthCardId = rspObj.getString("healthCardId");
if (healthCardId == null) {
// 响应处理
String errMsg = rspObj.getString("errMsg");
String resultCode = rspObj.getString("resultCode");
HealthCardRespCodeEnum healthCardRespCodeEnum = HealthCardRespCodeEnum.findEnumByResultCode(resultCode);
log.info("[电子健康卡]升级绑定失败原因 resultCode={}, errMsg={}, statusMsg={}", resultCode, errMsg, healthCardRespCodeEnum.MESSAGE);
return Result.error(healthCardRespCodeEnum.MESSAGE);
}
Patient bindInfo = new Patient();
bindInfo.setOpenid(openid);
bindInfo.setPatientId(patientId);
bindInfo.setIdCardNo(idCardNo);
bindInfo.setHealthCardId(healthCardId);
bindInfo.setName(name);
bindInfo.setNation(nation);
bindInfo.setTel(tel);
bindInfo.setAddress(address);
boolean isUpdate = new PatientDao().updateInfo(bindInfo, id);
if (isUpdate) {
Cache<String, User> cache = WxCacheHelper.getUserCacheManager();
cache.remove(openid);
return Result.success();
}
return Result.error();
}
/**
* [电子健康卡]获取卡包订单ID
*/
@Action("getCardOrderId")
public Result getCardOrderId(Boolean isMiniApp, @AesDecode String idCardNo, String healthCardId) {
log.info("[电子健康卡]获取卡包订单ID healthCardId={}, idCardNo={}", healthCardId, idCardNo);
if (healthCardId == null || idCardNo == null) {
return Result.error(ResultEnum.PARAM_IS_DEFECT); // 参数缺失
}
String qrCodeText = HealthCardHelper.getQRCodeText(isMiniApp, healthCardId, idCardNo);
if (qrCodeText == null) {
return Result.error(ResultEnum.PARAM_IS_DEFECT); // qrCodeText参数缺失
}
JSONObject result = HealthCardHelper.getOrderIdByOutAppId(isMiniApp, qrCodeText);
if (result == null) {
return Result.error();
}
return Result.success(result);
}

@ -68,7 +68,7 @@ public class HealthCodeAction extends BaseAction {
}
// @Action("appBindHealthCard")
// @Action("appBindHealthCard")
// public Result appBindHealthCard(String openid, String healthCode) {
// log.info("[新版电子健康卡]H5嵌入链接绑卡-通过healthCode获取健康卡数据 healthCode={}, openid={}", healthCode, openid);
// if (healthCode == null || openid == null) return Result.error(ResultEnum.PARAM_IS_DEFECT); // 参数为空
@ -184,7 +184,6 @@ public class HealthCodeAction extends BaseAction {
return Result.success();
}
/**
* [电子健康卡]患者绑定成人
*/

@ -317,20 +317,20 @@ public class PatientAction extends BaseAction {
@Action("unBind")
public Result unBind(@AesDecode String openid, @AesDecode String patientId) {
log.info("[患者解绑] openid={}, patientId={}", openid, patientId);
if (openid == null || patientId == null) {
public Result unBind(@AesDecode String openid, @AesDecode String epId) {
log.info("[患者解绑] openid={}, epId={}", openid, epId);
if (openid == null || epId == null) {
return Result.error(ResultEnum.PARAM_IS_DEFECT);
}
try {
if (WeChatConfig.IS_ENABLE_GMC && !WeChatConfig.IS_GMC_SERVER) { // 开启医共体 && 不是医共体主体
boolean isOK = new GMCService().unBindGmcServer(request, openid, patientId);
boolean isOK = new GMCService().unBindGmcServer(request, openid, epId);
return Result.success(isOK);
}
Patient patient = new PatientDao().selectByOpenidAndPatientId(openid, patientId);
Patient patient = new PatientDao().selectByOpenidAndEPId(openid, epId);
if (patient == null) {
log.info("[患者解绑]失败,库中不存在该患者 patientId={}", patientId);
log.info("[患者解绑]失败,库中不存在该患者 epId={}", epId);
return Result.error(ResultEnum.PATIENT_NOT_FOUND);
}
@ -345,18 +345,18 @@ public class PatientAction extends BaseAction {
}
if (idCardNo == null) {
log.info("身份证为空不允许解绑 openid={}, patientId={}", openid, patientId);
log.info("身份证为空不允许解绑 openid={}, epId={}", openid, epId);
return Result.error(ResultEnum.PATIENT_UN_BIND_ERROR);
}
JsonResult jsonResult = new HisPatientDao().unBindHis(idCardNo, cardType);
if (jsonResult.success()) {
return new PatientService().removePatient(openid, patientId, idCardNo);
return new PatientService().removePatient(openid, epId, idCardNo);
}
String message = jsonResult.getMessage();
if (message.contains("未注册或已解绑")) {
return new PatientService().removePatient(openid, patientId, idCardNo);
return new PatientService().removePatient(openid, epId, idCardNo);
}
return Result.error(message);

@ -97,6 +97,7 @@ public class RecipeAction extends BaseAction {
List<HisRecipe> resultList = new ArrayList<>();
for (HisRecipe hisRecipe : hisRecipes) {
hisRecipe.setPid(patientId);
hisRecipe.setTreatNum(hisRecipe.getMzNum());
if (hisRecipe.getDate() != null && DateHelper.inDateRange(begDate, endDate, hisRecipe.getDate(), DateHelper.DateEnum.yyyy_MM_dd)
&& !"1".equals(hisRecipe.getSTDFlag()) && (!"1".equals(hisRecipe.getInternetHospFlag()) || "1".equals(hisRecipe.getYJSAuditFlag()))) {
@ -277,7 +278,7 @@ public class RecipeAction extends BaseAction {
return Result.error(ResultEnum.PARAM_IS_DEFECT);
}
Patient patient = new PatientDao().selectByOpenidAndPatientId(openid, patientId);
Patient patient = new PatientDao().selectByOpenidAndEPId(openid, patientId);
if (patient == null) {
return Result.error(ResultEnum.PATIENT_NOT_FOUND);
}

@ -7,6 +7,7 @@ import com.ynxbd.common.bean.RecipeHelp;
import com.ynxbd.common.bean.SelfHelp;
import com.ynxbd.common.bean.enums.MerchantEnum;
import com.ynxbd.common.bean.pay.*;
import com.ynxbd.common.config.interceptor.AesDecode;
import com.ynxbd.common.dao.SelfHelpDao;
import com.ynxbd.common.dao.his.HisRecipeDao;
import com.ynxbd.common.dao.sys.SysUserDao;
@ -673,8 +674,8 @@ public class PayAction extends BaseAction {
* @param code 页码标识是否两张申请单
*/
@Action("createSelfHelp")
public Result createSelfHelp(String code, String cardNo, String patientId, String openid) {
if (patientId == null || code == null || openid == null) {
public Result createSelfHelp(String code, @AesDecode String openid, @AesDecode String patientId, String cardNo) {
if (code == null || openid == null || patientId == null) {
return Result.error(ResultEnum.PARAM_IS_DEFECT);
}

@ -34,7 +34,7 @@ public class TestAction extends BaseAction {
public synchronized void refund_handle() {
if (i == 0) {
i++;
WxPayHelper.refund(null, "", "", new BigDecimal(" 6.230 "), new BigDecimal(" 6.230 "), " 手动退费 ");
WxPayHelper.refund(null, "", "", new BigDecimal(""), new BigDecimal(""), "系统繁忙缴费失败");
}
}

@ -26,6 +26,8 @@ public class HisRecipe {
private String id;
// 处方名称
private String name;
// 患者id|医共体id
private String pid;
// 执行科室编码
private String deptCode;
// 执行科室名称

@ -5,6 +5,7 @@ import com.tencent.healthcard.impl.HealthCardServerImpl;
import com.tencent.healthcard.model.CommonIn;
import com.ynxbd.common.helper.ProperHelper;
import com.ynxbd.common.helper.common.ErrorHelper;
import com.ynxbd.common.helper.common.JsonHelper;
import com.ynxbd.wx.config.WeChatConfig;
import lombok.Getter;
import lombok.NoArgsConstructor;
@ -31,6 +32,7 @@ public class HealthCardConfig {
private static final boolean IS_ENABLE; // 是否启用电子健康卡(true:启用, false:禁用)
public static final boolean IS_UPLOAD_DATA; // 是否允许上传数据(true:启用, false:禁用)
public static final boolean IS_LOG_REPORT; // 是否打印上报日志(true:启用, false:禁用)
// 健康码
public static final String H_APP_ID;
@ -51,12 +53,13 @@ public class HealthCardConfig {
public static final String WE_CHART_CODE = "73EFA6796D3869FF82FAE7E81E9814B7";
// 公众号不用传,小程序内嵌必传,具体传参请联系平台对接人员分配
public static final int domainChannel = 0;
public static final int DOMAIN_CHANNEL = 0;
static {
ProperHelper config = new ProperHelper().read("hcode.properties");
IS_ENABLE = config.getBoolean("is_enable", false);
IS_UPLOAD_DATA = config.getBoolean("h.is_upload_data", true);
IS_LOG_REPORT = config.getBoolean("h.is_log_report", false);
// 不用对config设置开关,不开启时也需要用到参数
H_APP_ID = config.getString("h.app_id");
H_APP_SECRET = config.getString("h.app_secret");
@ -170,8 +173,17 @@ public class HealthCardConfig {
private JSONObject commonOut;
private JSONObject rsp;
private String resultCode;
private String errMsg;
public boolean isOk;
public String getJsonCommon() {
return JsonHelper.toJsonString(this.commonOut);
}
public String getErrMsg() {
return this.errMsg == null ? "" : this.errMsg;
}
public HCardResult(JSONObject resultJsonObj) {
if (resultJsonObj == null) {
return;
@ -183,6 +195,10 @@ public class HealthCardConfig {
}
this.resultCode = commonOut.getString("resultCode");
this.isOk = "0".equals(this.resultCode);
if (!this.isOk) {
this.errMsg = commonOut.getString("errMsg");
}
}
}
}

@ -82,8 +82,8 @@ public class PatientDao {
/**
* 根据openid查询患者 部分信息 用作外部对接 不回传openId
*
* @param openid
* @return
* @param openid openid
* @return list
*/
public List<PatientLink> selectPatientsByEncOpenid(String openid) {
String sql = "select PatientID,Name,Sex,IDCardNo,Age,Birthday,Address,Nation from patientBase where openid = ? and deletedState = 0 order by isDefault desc";
@ -94,14 +94,10 @@ public class PatientDao {
/**
* 根据身份证查询患者
*
* @param openid openid
* @param patientId 患者ID
* @return 患者信息
* 是否有该患者
*/
public boolean hasPatient(String openid, String patientId) {
return selectByOpenidAndPatientId(openid, patientId) != null;
public boolean hasPatient(String openid, String epId) {
return selectByOpenidAndEPId(openid, epId) != null;
}
@ -121,21 +117,46 @@ public class PatientDao {
/**
* 根据身份证查询患者
* 查询患者
*
* @param openid openid
* @param patientId 患者ID
* @param openid openid
* @param epId 医共体id|本院id
* @return 患者信息
*/
public Patient selectByOpenidAndPatientId(String openid, String patientId) {
String sql = "select * from patientBase where openid= ? and patientId= ? and deletedState = 0";
public Patient selectByOpenidAndEPId(String openid, String epId) {
String sql;
if (WeChatConfig.IS_ENABLE_GMC) {
sql = "select * from patientBase where openid= ? and empiId= ? and deletedState = 0";
} else {
sql = "select * from patientBase where openid= ? and patientId= ? and deletedState = 0";
}
List<Patient> dataList = DataBase.select(sql, Patient.class, ps -> {
ps.setString(1, openid);
ps.setString(2, patientId);
ps.setString(2, epId);
});
return !dataList.isEmpty() ? dataList.get(0) : null;
}
/**
* 健康卡解绑
*
* @param openid openid
* @param epId 医共体id|本院id
* @return 是否成功
*/
public boolean removePatient(String openid, String epId) {
String sql;
if (WeChatConfig.IS_ENABLE_GMC) {
sql = "update patientBase set updateTime=now(), age=null, deletedState=1 where openid=? and empiId=?";
} else {
sql = "update patientBase set updateTime=now(), age=null, deletedState=1 where openid=? and patientId=?";
}
return DataBase.update(sql, ps -> {
ps.setString(1, openid);
ps.setString(2, epId);
}) > 0;
}
/**
* 查询患者本人
@ -144,26 +165,12 @@ public class PatientDao {
* @return 患者信息
*/
public List<Patient> selectPatientsByOpenId(String openId) {
String sql = "select patientId, name, sex, birthday, idCardNo, tel from patientBase where openId= ? and deletedState = 0 order by isDefault desc, id asc";
String sql = "select empiId, patientId, name, sex, birthday, idCardNo, tel from patientBase where openId= ? and deletedState = 0 order by isDefault desc, id asc";
return DataBase.select(sql, Patient.class, ps -> {
ps.setString(1, openId);
});
}
/**
* 健康卡解绑
*
* @param openid openid
* @param patientId 身份证号
* @return 是否成功
*/
public boolean removePatient(String openid, String patientId) {
String sql = "update patientBase set updateTime=now(), age=null, deletedState=1 where openid=? and patientId=?";
return DataBase.update(sql, ps -> {
ps.setString(1, openid);
ps.setString(2, patientId);
}) > 0;
}
/**
* 根据身份证查询患者

@ -5,6 +5,7 @@ import com.ynxbd.common.helper.his.HisHelper;
import com.ynxbd.common.result.JsonResult;
import java.util.HashMap;
import java.util.Map;
/**
* @Author wsq
@ -24,7 +25,7 @@ public class HisAccountDao {
return HisHelper.createErrorResult("时间范围为空");
}
HashMap<String, Object> params = new HashMap<>();
Map<String, Object> params = new HashMap<>();
params.put("StartTime", begTime);
params.put("EndTime", endTime);

@ -0,0 +1,426 @@
package com.ynxbd.common.helper;
import com.alibaba.fastjson.JSONObject;
import com.tencent.healthcard.model.CommonIn;
import com.tencent.healthcard.model.HealthCardInfo;
import com.ynxbd.common.bean.Patient;
import com.ynxbd.common.bean.enums.HCardTypeEnum;
import com.ynxbd.common.config.HealthCardConfig;
import com.ynxbd.common.helper.common.ErrorHelper;
import com.ynxbd.common.helper.common.JsonHelper;
import com.ynxbd.common.helper.common.URLHelper;
import com.ynxbd.common.result.ServiceException;
import com.ynxbd.wx.config.WeChatConfig;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import java.util.UUID;
@Slf4j
public class HealthCardHelper {
/**
* 绑卡验证授权
*
* @param wechatCode 微信身份码
*/
public static JSONObject registerHealthCardPreAuth(Boolean isMiniApp, Boolean isHCBindUI, String wechatCode) {
try {
if (isMiniApp == null) {
isMiniApp = false;
}
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp);
if (commonIn == null) {
return null;
}
String domain = WeChatConfig.getDomain(false);
String webURL = WeChatConfig.getWebReqURL();
// 授权成功回调页
String successRedirectUrl = isMiniApp ? "mini:/path/to/isvpage?healthCode=${healthCode}" : (webURL + "health-card-form.html?healthCode=${healthCode}");
// 授权失败回调
String failRedirectUrl = isMiniApp ? "/path/to/isvpage?regInfoCode=${regInfoCode}" : (webURL + "health-card-form.html?regInfoCode=${regInfoCode}");
/*
* 用户手动填写信息建卡可选两种方式二选一
* 服务商自行提供建卡页可以是H5或小程序需增加authCode占位符示例如下
* H5: https://xxx.xxx.xx/path/to/isvpage?authCode=${authCode} |小程序: mini:/path/to/isvpage?authCode=${authCode}
* 使用开放平台的H5绑卡组件页需增加authCode占位符示例如下
* https://h5-health.tengmed.com/h5/tencent/open/card/regist?hospitalId=${hospitalId}&redirect_uri=${redirect_uri}&fail_redirect_uri=${fail_redirect_uri}&authCode=${authCode}小程序需修改该域名地址为已配置的业务域名
* ${hospitalId}必传为开放平台分配的医院ID(hospitalId)
* ${redirect_uri}必传为建卡成功后的回跳服务商页面必须要对该URL进行UrlEncode编码
* ${fail_redirect_uri}必传为建卡失败后的回跳服务商页面必须要对该URL进行UrlEncode编码
* 小程序内嵌仍以 mini 协议开头且需要UrlEncode编码
*/
String hcBindUIUrl = String.format("%s/h5/tencent/open/card/regist?hospitalId=%s&redirect_uri=%s&fail_redirect_uri=%s&authCode=%s",
(isMiniApp ? domain : "https://h5-health.tengmed.com"),
HealthCardConfig.H_HOSPITAL_ID,
URLHelper.encodeURL(successRedirectUrl),
URLHelper.encodeURL(failRedirectUrl),
wechatCode);
String userFormPageUrl = isHCBindUI
? hcBindUIUrl
: (webURL + "health-card-form.html?authCode=${authCode}");
// 小程序内嵌必传(固定为小程序路径,不需要加“mini:”前缀)示例: /path/to/facePage
String faceUrl = isMiniApp ? "/path/to/facePage" : null;
// 放弃验证回调页
String verifyFailRedirectUrl = isMiniApp ? "mini:/path/to/isvpage" : (webURL + "health-card-fail.html?code=-1");
int patientType = 0; // 0-新患者 1-老患者(针对就诊卡升级健康卡);不传默认为0
JSONObject resultJson = HealthCardConfig.createHealthCardService().registerHealthCardPreAuth(commonIn,
wechatCode,
patientType,
successRedirectUrl,
failRedirectUrl,
userFormPageUrl,
faceUrl,
verifyFailRedirectUrl,
HealthCardConfig.DOMAIN_CHANNEL);
log.info("[电子健康卡]绑卡验证授权 resp={}", JsonHelper.toJsonString(resultJson));
HealthCardConfig.HCardResult result = new HealthCardConfig.HCardResult(resultJson);
if (!result.isOk) {
log.info("[电子健康卡]绑卡验证授权-失败: {}", result.getErrMsg());
return result.getCommonOut();
}
return result.getRsp();
} catch (Exception e) {
ErrorHelper.println(e);
}
return null;
}
/**
* 验证注册/绑卡接口
*
*/
public static JSONObject registerHealthCardPreFill(Boolean isMiniApp, String authCode, String name, String gender, String nation, String birthday,
String idNumber, HCardTypeEnum cardTypeEnum, String phone1) {
try {
if (isMiniApp == null) {
isMiniApp = false;
}
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp);
if (commonIn == null) {
return null;
}
String webURL = WeChatConfig.getWebReqURL();
// 授权成功回调页
String successRedirectUrl = isMiniApp ? "mini:/path/to/isvpage?healthCode=${healthCode}" : (webURL + "health-card-form.html?healthCode=${healthCode}");
// 授权失败回调
String failRedirectUrl = isMiniApp ? "/path/to/isvpage??regInfoCode=${regInfoCode}" : (webURL + "health-card-form.html?regInfoCode=${regInfoCode}");
// 小程序内嵌必传(固定为小程序路径,不需要加“mini:”前缀)示例: /path/to/facePage
String faceUrl = isMiniApp ? "/path/to/facePage" : null;
// 放弃验证回调页
String verifyFailRedirectUrl = isMiniApp ? "mini:/path/to/isvpage" : (webURL + "health-card-fail.html?code=-2");
if (!nation.contains("族")) {
nation = nation + "族";
}
HealthCardInfo req = new HealthCardInfo();
req.setName(name);
req.setGender(gender);
req.setNation(nation);
req.setBirthday(birthday);
req.setIdNumber(idNumber);
req.setIdType(cardTypeEnum.WX_CODE);
req.setPhone1(phone1);
JSONObject resultJson = HealthCardConfig.createHealthCardService().registerHealthCardPreFill(commonIn,
req,
authCode,
successRedirectUrl,
failRedirectUrl,
faceUrl,
verifyFailRedirectUrl,
HealthCardConfig.DOMAIN_CHANNEL);
HealthCardConfig.HCardResult result = new HealthCardConfig.HCardResult(resultJson);
log.info("[电子健康卡]验证注册/绑卡接口 resp: {}", JsonHelper.toJsonString(resultJson));
if (!result.isOk) {
log.info("[电子健康卡]验证注册/绑卡接口-失败: {}", result.getErrMsg());
return result.getCommonOut();
}
return result.getRsp();
} catch (Exception e) {
ErrorHelper.println(e);
}
return null;
}
/**
* 健康卡授权码获取健康卡信息
*
* @param healthCode 健康卡授权码
*/
public static Patient getHealthCardByHealthCode(Boolean isMiniApp, String healthCode) throws ServiceException {
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp);
if (commonIn == null) {
throw new ServiceException("[电子健康卡]健康卡授权码获取健康卡信息-请求参数缺失");
}
JSONObject resultJson = HealthCardConfig.createHealthCardService().getHealthCardByHealthCode(commonIn, healthCode);
HealthCardConfig.HCardResult result = new HealthCardConfig.HCardResult(resultJson);
JSONObject respJson = result.getRsp();
if (!result.isOk || respJson == null) {
throw new ServiceException("[电子健康卡]健康卡授权码获取健康卡信息-失败:" + result.getJsonCommon());
}
JSONObject card = respJson.getJSONObject("card");
if (card == null) {
throw new ServiceException("[电子健康卡]健康卡授权码获取健康卡信息-数据解析失败");
}
Patient patient = new Patient();
String phone1 = card.getString("phone1");
patient.setTel(ObjectUtils.isEmpty(phone1) ? card.getString("phone2") : phone1);
patient.setHealthCardId(card.getString("healthCardId")); // 关键参数
patient.setName(card.getString("name"));
patient.setSex(card.getString("gender"));
patient.setCardType(card.getString("idType"));
patient.setIdCardNo(card.getString("idNumber"));
patient.setNation(card.getString("nation"));
// 非必定返回参数
patient.setAddress(card.getString("address"));
patient.setBirthday(card.getString("birthday"));
patient.setIsMyself(card.getBoolean("isSelf"));
log.info("[电子健康卡]健康卡授权码获取健康卡信息 info:{}", JsonHelper.toJsonString(patient));
return patient;
}
/**
* 身份证识别
*
* @param imageContent 身份证正面照片的base64编码数据头部信息需要删除如image/png;base64image/jpeg/png;base64等并且数据量建议压缩到百K级别上传
* @return 身份证信息
*/
public static Patient orcInfo(String imageContent) throws ServiceException {
if (ObjectUtils.isEmpty(imageContent)) {
throw new ServiceException("[电子健康卡]图片数据不能为空");
}
int index = imageContent.indexOf(",");
if (index != -1) {
imageContent = imageContent.substring(index + 1);
}
Patient patient = new Patient();
if (!HealthCardConfig.isEnable()) { // 判断是否禁用电子健康卡
throw new ServiceException("[电子健康卡]功能未开启");
}
CommonIn commonIn = new CommonIn(HealthCardConfig.getAppToken(false, false), UUID.randomUUID().toString().replaceAll("-", ""), HealthCardConfig.H_HOSPITAL_ID, 0, null, null);
JSONObject resultJson = HealthCardConfig.createHealthCardService().ocrInfo(commonIn, imageContent);
HealthCardConfig.HCardResult result = new HealthCardConfig.HCardResult(resultJson);
if (!result.isOk) {
throw new ServiceException("[电子健康卡]身份证识别-失败: " + JsonHelper.toJsonString(resultJson));
}
JSONObject rsp = result.getRsp();
if (rsp == null) {
throw new ServiceException("[电子健康卡]身份证识别-未查询到数据");
}
JSONObject cardInfo = rsp.getJSONObject("cardInfo");
if (cardInfo == null) {
throw new ServiceException("[电子健康卡]身份证识别-数据解析失败");
}
// 读取信息
String idNumber = cardInfo.getString("id");
patient.setIdCardNo(idNumber == null ? null : idNumber.toUpperCase());
patient.setName(cardInfo.getString("name"));
patient.setSex(cardInfo.getString("gender"));
patient.setAddress(cardInfo.getString("address"));
patient.setNation(cardInfo.getString("nation"));
patient.setBirthday(cardInfo.getString("birth"));
// if (!"".equals(idNumber)) {
// FileHelper.saveBase64Image("data:image/png;base64," + imageContent, "idCard", (idNumber + ".png"), true, false);
// }
return patient;
}
/**
* 注册健康卡
*
* @param wechatCode 微信身份码
* @param birthday 出生年月日
* @param cardTypeEnum 证件类型01-居民身份证其他参考证件类型表
* @param areaAddress 区域地址
* @param address 地址
* @param sex 性别
* @param nation 民族
* @param name 姓名
* @param idCardNo 证件号码
* @param phone1 联系方式1
*/
public static JSONObject registerHealthCard(Boolean isMiniApp, String patientId, String wechatCode,
String birthday, HCardTypeEnum cardTypeEnum, String address, String areaAddress,
String sex, String nation, String name, String idCardNo, String phone1) {
try {
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp);
if (commonIn == null) {
return null;
}
if (cardTypeEnum == null) {
cardTypeEnum = HCardTypeEnum._01; // 居民身份证
}
if (ObjectUtils.isEmpty(areaAddress)) {
areaAddress = "";
}
HealthCardInfo req = new HealthCardInfo();
req.setAddress(areaAddress + address);
req.setBirthday(birthday);
req.setGender(sex);
req.setIdNumber(idCardNo);
req.setIdType(cardTypeEnum.WX_CODE);
req.setNation(nation);
req.setName(name);
req.setPhone1(phone1);
req.setWechatCode(wechatCode);
req.setPatid(patientId);
JSONObject resultJson = HealthCardConfig.createHealthCardService().registerHealthCard(commonIn, req);
HealthCardConfig.HCardResult result = new HealthCardConfig.HCardResult(resultJson);
if (!result.isOk) {
log.info("[电子健康卡]注册失败: {}", resultJson);
return result.getCommonOut();
}
return result.getRsp();
} catch (Exception e) {
ErrorHelper.println(e);
}
return null;
}
/**
* 获取建档信息
*
* @param regInfoCode 建档授权码
*/
public static Patient getRegInfoByCode(Boolean isMiniApp, String regInfoCode) throws ServiceException {
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp);
if (commonIn == null) {
throw new ServiceException("[电子健康卡]获取建档信息-请求参数缺失");
}
JSONObject resultJson = HealthCardConfig.createHealthCardService().getRegInfoByCode(commonIn, regInfoCode);
HealthCardConfig.HCardResult result = new HealthCardConfig.HCardResult(resultJson);
JSONObject respJsonObj = result.getRsp();
if (!result.isOk || respJsonObj == null) {
throw new ServiceException("[电子健康卡]获取建档信息-失败:" + result.getJsonCommon());
}
JSONObject card = respJsonObj.getJSONObject("card");
if (card == null) {
throw new ServiceException("[电子健康卡]获取建档信息-数据解析失败");
}
Patient patient = new Patient();
String phone1 = card.getString("phone1");
patient.setTel(ObjectUtils.isEmpty(phone1) ? card.getString("phone2") : phone1);
patient.setName(card.getString("name"));
patient.setSex(card.getString("gender"));
patient.setCardType(card.getString("idType"));
patient.setIdCardNo(card.getString("idNumber"));
// 非必定返回参数
patient.setNation(card.getString("nation"));
patient.setAddress(card.getString("address"));
patient.setBirthday(card.getString("birthday"));
patient.setIsMyself(card.getBoolean("isSelf"));
patient.setHealthCardId(card.getString("healthCardId"));
log.info("[电子健康卡]获取建档信息 info:{}", JsonHelper.toJsonString(patient));
return patient;
}
/**
* 获取健康卡二维码
*
* @param healthCardId 健康卡ID
* @param idCardNo 证件号码
* @param codeType 传0或者10返回动态码1返回静态码
*/
public static JSONObject getDynamicQRCode(Boolean isMiniApp, String healthCardId, String idCardNo, String codeType) {
if (healthCardId == null || idCardNo == null || codeType == null) {
log.info("[电子健康卡]获取健康卡二维码-参数缺失 healthCardId={}, idCardNo={}, codeType={}", healthCardId, idCardNo, codeType);
return null;
}
try {
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp);
if (commonIn == null) {
return null;
}
JSONObject resultJson = HealthCardConfig.createHealthCardService().getDynamicQRCode(commonIn, healthCardId, "01", idCardNo, codeType);
HealthCardConfig.HCardResult result = new HealthCardConfig.HCardResult(resultJson);
if (!result.isOk) {
log.info("[电子健康卡]获取健康卡二维码失败: {}", resultJson);
return null;
}
return result.getRsp();
} catch (Exception e) {
ErrorHelper.println(e);
}
return null;
}
/**
* 根据健康卡ID获取动态二维码
*
* @param healthCardId 健康卡ID
* @param idCardNo 身份证号
* @return 动态二维码
*/
public static String getQRCodeText(Boolean isMiniApp, String healthCardId, String idCardNo) {
JSONObject QRResult = getDynamicQRCode(isMiniApp, healthCardId, idCardNo, "0");
if (QRResult == null) {
log.info("[电子健康卡]用卡数据监测接口-获取二维码失败");
return null;
}
String qrCodeText = QRResult.getString("qrCodeText");
if (ObjectUtils.isEmpty(qrCodeText)) {
log.info("[电子健康卡]用卡数据监测接口-获取qrCodeText失败");
return null;
}
return qrCodeText;
}
/**
* 获取卡包订单ID
*
* @param qrCodeText 二维码编码
*/
public static JSONObject getOrderIdByOutAppId(Boolean isMiniApp, String qrCodeText) {
try {
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp);
if (commonIn == null) {
return null;
}
//调用接口
JSONObject resultJson = HealthCardConfig.createHealthCardService().getOrderIdByOutAppId(commonIn, WeChatConfig.APP_ID, qrCodeText);
HealthCardConfig.HCardResult result = new HealthCardConfig.HCardResult(resultJson);
if (!result.isOk) {
log.info("[电子健康卡]获取卡包订单ID 失败: {}", result.getJsonCommon());
return null;
}
return result.getRsp();
} catch (Exception e) {
ErrorHelper.println(e);
}
return null;
}
}

@ -1,6 +1,7 @@
package com.ynxbd.common.helper.common;
import org.apache.commons.lang3.ObjectUtils;
import java.util.Arrays;
import java.util.List;
@ -10,7 +11,7 @@ public class ValidHelper {
"侗族", "瑶族", "土家族", "哈萨克族", "黎族", "傈僳族", "佤族", "畲族", "高山族", "拉祜族", "水族", "东乡族", "纳西族", "景颇族",
"柯尔克孜族", "土族", "达斡尔族", "仫佬族", "羌族", "布朗族", "撒拉族", "毛南族", "仡佬族", "锡伯族", "阿昌族", "普米族",
"塔吉克族", "怒族", "乌孜别克族", "俄罗斯族", "鄂温克族", "德昂族", "保安族", "裕固族", "京族", "塔塔尔族", "独龙族",
"鄂伦春族", "赫哲族", "门巴族", "珞巴族", "基诺族", "穿青人");
"鄂伦春族", "赫哲族", "门巴族", "珞巴族", "基诺族", "穿青人");
/**
* 是否存在民族
@ -21,12 +22,13 @@ public class ValidHelper {
if (ObjectUtils.isEmpty(nation)) {
return false;
}
if (nation.equals("穿青人")) {
return true;
if (nation.equals("未知")) {
return false;
}
if(nation.equals("未知")) {
if (nation.equals("穿青人")) {
return true;
}
if (!nation.contains("族")) {
nation += "族";
}

@ -2,7 +2,6 @@ package com.ynxbd.common.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.tencent.healthcard.impl.HealthCardServerImpl;
import com.tencent.healthcard.model.CommonIn;
import com.tencent.healthcard.model.HealthCardInfo;
import com.tencent.healthcard.model.ReportHISData;
@ -10,20 +9,12 @@ import com.ynxbd.common.bean.Patient;
import com.ynxbd.common.bean.enums.HCardTypeEnum;
import com.ynxbd.common.bean.enums.HealthCardEnum;
import com.ynxbd.common.bean.enums.HealthCardSceneEnum;
import com.ynxbd.common.config.EhCacheConfig;
import com.ynxbd.common.config.HealthCardConfig;
import com.ynxbd.common.helper.ProperHelper;
import com.ynxbd.common.helper.common.ErrorHelper;
import com.ynxbd.common.helper.common.JsonHelper;
import com.ynxbd.common.helper.common.URLHelper;
import com.ynxbd.wx.config.WeChatConfig;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.ehcache.Cache;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -524,6 +515,9 @@ public class HCodeService {
//调用接口
JSONObject resultJson = HealthCardConfig.createHealthCardService().reportHISData(commonIn, req);
HealthCardConfig.HCardResult result = new HealthCardConfig.HCardResult(resultJson);
if (HealthCardConfig.IS_LOG_REPORT) {
log.info("[电子健康卡]用卡数据监测接口 req={}, resp={}", JsonHelper.toJsonString(req), JsonHelper.toJsonString(resultJson));
}
if (!result.isOk) {
log.info("[电子健康卡]用卡数据监测接口 {}", resultJson);
return null;
@ -581,134 +575,4 @@ public class HCodeService {
return null;
}
/**
* 绑卡验证授权
*
* @param wechatCode 微信身份码
*/
public static JSONObject registerHealthCardPreAuth(Boolean isMiniApp, Boolean isHCBindUI, String wechatCode, String healthCode, String openid) {
try {
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp);
if (commonIn == null) {
return null;
}
String domain = WeChatConfig.getDomain(false);
String webURL = WeChatConfig.getWebReqURL();
System.out.println(webURL);
// 成功回调页
String successRedirectUrl = (isMiniApp ? "mini:/path/to/isvpage?healthCode=" : (webURL + "/hc-ok.html")) + healthCode;
// 失败回调页
String failRedirectUrl = (isMiniApp ? "/path/to/isvpage?regInfoCode=" : (webURL + "/hc-fail.html")) + healthCode;
/*
* 用户手动填写信息建卡可选两种方式二选一
* 服务商自行提供建卡页可以是H5或小程序需增加authCode占位符示例如下
* H5: https://xxx.xxx.xx/path/to/isvpage?authCode=${authCode} |小程序: mini:/path/to/isvpage?authCode=${authCode}
* 使用开放平台的H5绑卡组件页需增加authCode占位符示例如下
* https://h5-health.tengmed.com/h5/tencent/open/card/regist?hospitalId=${hospitalId}&redirect_uri=${redirect_uri}&fail_redirect_uri=${fail_redirect_uri}&authCode=${authCode}小程序需修改该域名地址为已配置的业务域名
* ${hospitalId}必传为开放平台分配的医院ID(hospitalId)
* ${redirect_uri}必传为建卡成功后的回跳服务商页面必须要对该URL进行UrlEncode编码
* ${fail_redirect_uri}必传为建卡失败后的回跳服务商页面必须要对该URL进行UrlEncode编码
* 小程序内嵌仍以 mini 协议开头且需要UrlEncode编码
*/
String hcBindUIUrl = String.format("%s/h5/tencent/open/card/regist?hospitalId=%s&redirect_uri=%s&fail_redirect_uri=%s&authCode=%s",
(isMiniApp ? domain : "https://h5-health.tengmed.com"),
HealthCardConfig.H_HOSPITAL_ID,
URLHelper.encodeURL(successRedirectUrl),
URLHelper.encodeURL(failRedirectUrl),
wechatCode);
String userFormPageUrl = !isHCBindUI
? (WeChatConfig.getWebReqURL() + "?authCode=" + wechatCode)
: hcBindUIUrl;
// 小程序内嵌必传(固定为小程序路径,不需要加“mini:”前缀)示例: /path/to/facePage
String faceUrl = isMiniApp ? "/path/to/facePage" : null;
// 放弃验证回调页
String verifyFailRedirectUrl = isMiniApp ? "mini:/path/to/isvpage" : (domain + "/path/to/isvpage");
int patientType = 0; // 0-新患者 1-老患者(针对就诊卡升级健康卡);不传默认为0
JSONObject resultJson = HealthCardConfig.createHealthCardService().registerHealthCardPreAuth(commonIn,
wechatCode,
patientType,
successRedirectUrl,
failRedirectUrl,
userFormPageUrl,
faceUrl,
verifyFailRedirectUrl,
HealthCardConfig.domainChannel);
log.info("[电子健康卡]绑卡验证授权 resp={}", JsonHelper.toJsonString(resultJson));
HealthCardConfig.HCardResult result = new HealthCardConfig.HCardResult(resultJson);
if (!result.isOk) {
log.info("[电子健康卡]绑卡验证授权-失败: {}", resultJson);
return result.getCommonOut();
}
return result.getRsp();
} catch (Exception e) {
ErrorHelper.println(e);
}
return null;
}
/**
* 提交建卡相关信息
*
* @param wechatCode 微信身份码
* @param openId openId
*/
public JSONObject registerHealthCardPreFill(Boolean isMiniApp, String wechatCode, String authCode, String openId, String patientId,
String birthday, HCardTypeEnum cardTypeEnum, String address, String areaAddress,
String sex, String nation, String name, String idCardNo, String phone1) {
try {
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp);
if (commonIn == null) {
return null;
}
// 成功回调页,需增加healthCode 占位符,示例如下:H5: https://xxx.xxx.xx/path/to/isvpage?healthCode=${healthCode} | 小程序: mini:/path/to/isvpage?healthCode=${healthCode}
String successRedirectUrl = "";
// 失败回调页,需增加regInfoCode占位符,示例如下: H5: https://xxx.xxx.xx/path/to/isvpage?regInfoCode=${regInfoCode}|小程序: mini:/path/to/isvpage?regInfoCode=${regInfoCode}
String failRedirectUrl = "";
// 小程序内嵌必传(固定为小程序路径,不需要加“mini:”前缀)示例: /path/to/facePage
String faceUrl = "";
// 放弃验证回调页,无参数占位要求,示例如下: H5: https://xxx.xxx.xx/path/to/isvpage | 小程序: mini:/path/to/isvpage
String verifyFailRedirectUrl = "";
HealthCardInfo req = new HealthCardInfo();
req.setAddress(areaAddress + address);
req.setBirthday(birthday);
req.setGender(sex);
req.setIdNumber(idCardNo);
req.setIdType(cardTypeEnum.WX_CODE);
req.setNation(nation);
req.setName(name);
req.setPhone1(phone1);
req.setWechatCode(wechatCode);
req.setPatid(patientId);
JSONObject resultJson = HealthCardConfig.createHealthCardService().registerHealthCardPreFill(commonIn,
req,
authCode,
successRedirectUrl,
failRedirectUrl,
faceUrl,
verifyFailRedirectUrl,
HealthCardConfig.domainChannel);
HealthCardConfig.HCardResult result = new HealthCardConfig.HCardResult(resultJson);
if (!result.isOk) {
log.info("[电子健康卡]提交建卡相关信息-失败: {}", resultJson);
return result.getCommonOut();
}
return result.getRsp();
} catch (Exception e) {
ErrorHelper.println(e);
}
return null;
}
}

@ -1,78 +0,0 @@
package com.ynxbd.common.service;
import com.alibaba.fastjson.JSONObject;
import com.tencent.healthcard.model.CommonIn;
import com.ynxbd.common.config.HealthCardConfig;
import com.ynxbd.common.helper.common.ErrorHelper;
import com.ynxbd.common.helper.common.JsonHelper;
import com.ynxbd.common.helper.common.URLHelper;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class HealthCardService {
/**
* 绑卡验证授权
*
* @param wechatCode 微信身份码
* @param openId openId
*/
public static JSONObject registerHealthCardPreAuth(Boolean isMiniApp, String domain, String wechatCode, String healthCode, String openId) {
try {
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp);
if (commonIn == null) {
return null;
}
// 成功回调页
String successRedirectUrl = (isMiniApp ? "mini:/path/to/isvpage?healthCode=" : (domain + "/path/to/isvpage?healthCode=")) + wechatCode;
// 失败回调页
String failRedirectUrl = (isMiniApp ? "/path/to/isvpage?regInfoCode=" : (domain + "/path/to/isvpage?regInfoCode=")) + wechatCode;
/*
* 用户手动填写信息建卡可选两种方式二选一
* 服务商自行提供建卡页可以是H5或小程序需增加authCode占位符示例如下
* H5: https://xxx.xxx.xx/path/to/isvpage?authCode=${authCode} |小程序: mini:/path/to/isvpage?authCode=${authCode}
* 使用开放平台的H5绑卡组件页需增加authCode占位符示例如下
* https://h5-health.tengmed.com/h5/tencent/open/card/regist?hospitalId=${hospitalId}&redirect_uri=${redirect_uri}&fail_redirect_uri=${fail_redirect_uri}&authCode=${authCode}小程序需修改该域名地址为已配置的业务域名
* ${hospitalId}必传为开放平台分配的医院ID(hospitalId)
* ${redirect_uri}必传为建卡成功后的回跳服务商页面必须要对该URL进行UrlEncode编码
* ${fail_redirect_uri}必传为建卡失败后的回跳服务商页面必须要对该URL进行UrlEncode编码
* 小程序内嵌仍以 mini 协议开头且需要UrlEncode编码
*/
String userFormPageUrl = String.format("%s/h5/tencent/open/card/regist?hospitalId=%s&redirect_uri=%s&fail_redirect_uri=%s&authCode=%s",
(isMiniApp ? domain : " https://h5-health.tengmed.com"),
HealthCardConfig.H_HOSPITAL_ID,
URLHelper.encodeURL(successRedirectUrl),
URLHelper.encodeURL(failRedirectUrl),
wechatCode);
// 小程序内嵌必传(固定为小程序路径,不需要加“mini:”前缀)示例: /path/to/facePage
String faceUrl = isMiniApp ? "/path/to/facePage" : null;
// 放弃验证回调页
String verifyFailRedirectUrl = isMiniApp ? "mini:/path/to/isvpage" : (domain + "/path/to/isvpage");
int patientType = 0; // 0-新患者 1-老患者(针对就诊卡升级健康卡);不传默认为0
JSONObject resultJson = HealthCardConfig.createHealthCardService().registerHealthCardPreAuth(commonIn,
wechatCode,
patientType,
successRedirectUrl,
failRedirectUrl,
userFormPageUrl,
faceUrl,
verifyFailRedirectUrl,
HealthCardConfig.domainChannel);
log.info("[电子健康卡]绑卡验证授权 resp={}", JsonHelper.toJsonString(resultJson));
HealthCardConfig.HCardResult result = new HealthCardConfig.HCardResult(resultJson);
if (!result.isOk) {
log.info("[电子健康卡]绑卡验证授权-失败: {}", resultJson);
return result.getCommonOut();
}
return result.getRsp();
} catch (Exception e) {
ErrorHelper.println(e);
}
return null;
}
}

@ -39,7 +39,7 @@ public class HealthUploadService {
String today = format.format(new Date());
String scene = regDate.equals(today) ? HealthCardEnum.SCENE_REGISTER_SITE.STATUS : HealthCardEnum.SCENE_REGISTER_RESERVE.STATUS;
Patient patient = new PatientDao().selectByOpenidAndPatientId(openid, patientId);
Patient patient = new PatientDao().selectByOpenidAndEPId(openid, patientId);
if (patient == null) {
return;
}
@ -84,7 +84,7 @@ public class HealthUploadService {
return;
}
Patient patient = new PatientDao().selectByOpenidAndPatientId(openid, patientId);
Patient patient = new PatientDao().selectByOpenidAndEPId(openid, patientId);
if (patient == null) {
return;
}

@ -107,7 +107,7 @@ public class MessagePushConfig {
return;
}
Patient patient = new PatientDao().selectByOpenidAndPatientId(openid, patientId);
Patient patient = new PatientDao().selectByOpenidAndEPId(openid, patientId);
if (patient == null) {
log.warn("[推送]挂号导航通知失败,患者信息不存在~");
return;
@ -155,7 +155,7 @@ public class MessagePushConfig {
return;
}
Patient patient = new PatientDao().selectByOpenidAndPatientId(openid, patientId);
Patient patient = new PatientDao().selectByOpenidAndEPId(openid, patientId);
if (patient == null) {
log.warn("[推送]挂号通知失败,患者信息不存在");
return;
@ -333,7 +333,7 @@ public class MessagePushConfig {
return;
}
Patient patient = new PatientDao().selectByOpenidAndPatientId(openid, patientId);
Patient patient = new PatientDao().selectByOpenidAndEPId(openid, patientId);
if (patient == null) {
log.info("[推送]取消预约通知失败,患者信息不存在~");
return;
@ -380,7 +380,7 @@ public class MessagePushConfig {
}
}
Patient patient = new PatientDao().selectByOpenidAndPatientId(openid, patientId);
Patient patient = new PatientDao().selectByOpenidAndEPId(openid, patientId);
if (patient == null) {
return;
}

@ -53,7 +53,6 @@ public class QServlet extends HttpServlet {
}
}
String patientId = request.getParameter("p");
String cardNo = request.getParameter("t");
String groupTreatNum = request.getParameter("g");

@ -2,6 +2,8 @@
is_enable=true
# \u662F\u5426\u4E0A\u4F20\u6570\u636E(\u7B49\u7EA7\u672A\u5230\u8FBE\u65F6\u914D\u7F6E\u4E3Afalse[36626])
h.is_upload_data=false
# \u662F\u5426\u6253\u5370\u4E0A\u62A5\u6570\u636E\u65E5\u5FD7
h.is_log_report=false
#\u5FAE\u4FE1\u5F00\u653E\u5E73\u53F0\u8C03\u7528\u53C2\u6570
h.app_id=e4a05c13301f2f6a8b07b3de872dfe2d
h.app_secret=e5322dfd9bfab939851319812c30f9f1

Loading…
Cancel
Save