|
|
|
|
@ -12,6 +12,7 @@ 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.ResultEnum; |
|
|
|
|
import com.ynxbd.common.result.ServiceException; |
|
|
|
|
import com.ynxbd.wx.config.WeChatConfig; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
@ -19,7 +20,6 @@ import org.apache.commons.lang3.ObjectUtils; |
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.UUID; |
|
|
|
|
|
|
|
|
|
@Slf4j |
|
|
|
|
public class HealthCardHelper { |
|
|
|
|
@ -29,13 +29,13 @@ public class HealthCardHelper { |
|
|
|
|
* |
|
|
|
|
* @param wechatCode 微信身份码 |
|
|
|
|
*/ |
|
|
|
|
public static JSONObject registerHealthCardPreAuth(Boolean isMiniApp, Boolean isHCBindUI, Integer patientType, String wechatCode, String enHisPatientId) throws ServiceException { |
|
|
|
|
public static JSONObject registerHealthCardPreAuth(Boolean isMiniApp, String openid, Boolean isHCBindUI, Integer patientType, String wechatCode, String enHisPatientId) throws ServiceException { |
|
|
|
|
if (isMiniApp == null) { |
|
|
|
|
isMiniApp = false; |
|
|
|
|
} |
|
|
|
|
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp); |
|
|
|
|
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp, openid); |
|
|
|
|
if (commonIn == null) { |
|
|
|
|
throw new ServiceException("[电子健康卡]健康卡授权码获取健康卡信息-请求参数缺失"); |
|
|
|
|
throw new ServiceException("[电子健康卡]健康卡授权码获取健康卡信息-请求体CommonIn缺失"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String domain = WeChatConfig.getDomain(false); |
|
|
|
|
@ -57,19 +57,21 @@ public class HealthCardHelper { |
|
|
|
|
* 小程序内嵌,仍以 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); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enHisPatientId = ObjectUtils.isEmpty(enHisPatientId) ? "" : "&enHisPatientId=" + enHisPatientId; |
|
|
|
|
String userFormPageUrl; |
|
|
|
|
if (isHCBindUI) { // 服务商页面
|
|
|
|
|
userFormPageUrl = String.format("%s/h5/tencent/open/card/regist?hospitalId=%s&redirect_uri=%s&fail_redirect_uri=%s&authCode=%s", |
|
|
|
|
(isMiniApp ? ("mini:" + domain) : "https://h5-health.tengmed.com"), |
|
|
|
|
HealthCardConfig.H_HOSPITAL_ID, |
|
|
|
|
URLHelper.encodeURL(successRedirectUrl), |
|
|
|
|
URLHelper.encodeURL(failRedirectUrl), |
|
|
|
|
wechatCode); |
|
|
|
|
} else { |
|
|
|
|
userFormPageUrl = isMiniApp |
|
|
|
|
? "mini:/path/to/isvpage?authCode=${authCode}" |
|
|
|
|
: (webURL + "health-card-form.html?authCode=${authCode}" + (ObjectUtils.isEmpty(enHisPatientId) ? "" : "&enHisPatientId=" + enHisPatientId)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String userFormPageUrl = isHCBindUI |
|
|
|
|
? hcBindUIUrl |
|
|
|
|
: (webURL + "health-card-form.html?authCode=${authCode}" + enHisPatientId); |
|
|
|
|
System.out.println("[userFormPageUrl]=" + userFormPageUrl); |
|
|
|
|
|
|
|
|
|
// 小程序内嵌必传(固定为小程序路径,不需要加“mini:”前缀)示例: /path/to/facePage
|
|
|
|
|
String faceUrl = isMiniApp ? "/path/to/facePage" : null; |
|
|
|
|
@ -102,13 +104,13 @@ public class HealthCardHelper { |
|
|
|
|
* 验证注册/绑卡接口 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
public static JSONObject registerHealthCardPreFill(Boolean isMiniApp, String authCode, String name, String gender, String nation, String birthday, |
|
|
|
|
public static JSONObject registerHealthCardPreFill(Boolean isMiniApp, String openid, 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); |
|
|
|
|
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp, openid); |
|
|
|
|
if (commonIn == null) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
@ -160,15 +162,66 @@ public class HealthCardHelper { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* [电子健康卡]通过二维码获取健康卡数据 |
|
|
|
|
* |
|
|
|
|
* @param qrCode 二维码 |
|
|
|
|
*/ |
|
|
|
|
public static Patient getHealthCardByQrCode(Boolean isMiniApp, String openid, String qrCode) { |
|
|
|
|
try { |
|
|
|
|
log.info("[电子健康卡]查询健康卡信息 qrCode={}", qrCode); |
|
|
|
|
if (ObjectUtils.isEmpty(qrCode)) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp, openid); |
|
|
|
|
if (commonIn == null) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JSONObject resultJson = HealthCardConfig.createHealthCardService().getHealthCardByQRCode(commonIn, qrCode); |
|
|
|
|
HealthCardConfig.HCardResult result = new HealthCardConfig.HCardResult(resultJson); |
|
|
|
|
if (!result.isOk) { |
|
|
|
|
log.info("[电子健康卡]二维码获取健康卡失败: {}", resultJson); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
JSONObject respJson = result.getRsp(); |
|
|
|
|
if (respJson == null) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
JSONObject cardJson = respJson.getJSONObject("card"); |
|
|
|
|
if (cardJson == null) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
Patient patient = new Patient(); |
|
|
|
|
patient.setSex(cardJson.getString("gender")); // 性别
|
|
|
|
|
patient.setName(cardJson.getString("name")); |
|
|
|
|
patient.setNation(cardJson.getString("nation")); |
|
|
|
|
patient.setCardType(cardJson.getString("idType")); |
|
|
|
|
patient.setIdCardNo(cardJson.getString("idNumber")); |
|
|
|
|
patient.setBirthday(cardJson.getString("birthday")); |
|
|
|
|
patient.setAddress(cardJson.getString("address")); |
|
|
|
|
String phone1 = cardJson.getString("phone1"); |
|
|
|
|
String phone2 = cardJson.getString("phone2"); |
|
|
|
|
patient.setTel(ObjectUtils.isEmpty(phone1) ? phone2 : phone1); |
|
|
|
|
return patient; |
|
|
|
|
} 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); |
|
|
|
|
public static Patient getHealthCardByHealthCode(Boolean isMiniApp, String openid, String healthCode) throws ServiceException { |
|
|
|
|
if (ObjectUtils.isEmpty(openid) || ObjectUtils.isEmpty(healthCode)) { |
|
|
|
|
throw new ServiceException(ResultEnum.PARAM_IS_DEFECT); |
|
|
|
|
} |
|
|
|
|
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp, openid); |
|
|
|
|
if (commonIn == null) { |
|
|
|
|
throw new ServiceException("[电子健康卡]健康卡授权码获取健康卡信息-请求参数缺失"); |
|
|
|
|
throw new ServiceException("[电子健康卡]健康卡授权码获取健康卡信息-请求体CommonIn缺失"); |
|
|
|
|
} |
|
|
|
|
JSONObject resultJson = HealthCardConfig.createHealthCardService().getHealthCardByHealthCode(commonIn, healthCode); |
|
|
|
|
HealthCardConfig.HCardResult result = new HealthCardConfig.HCardResult(resultJson); |
|
|
|
|
@ -207,7 +260,7 @@ public class HealthCardHelper { |
|
|
|
|
* @param imageContent 身份证正面照片的base64编码数据,头部信息需要删除,如image/png;base64、image/jpeg/png;base64等,并且数据量建议压缩到百K级别上传。 |
|
|
|
|
* @return 身份证信息 |
|
|
|
|
*/ |
|
|
|
|
public static Patient orcInfo(String imageContent) throws ServiceException { |
|
|
|
|
public static Patient orcInfo(String openid, String imageContent) throws ServiceException { |
|
|
|
|
if (ObjectUtils.isEmpty(imageContent)) { |
|
|
|
|
throw new ServiceException("[电子健康卡]图片数据不能为空"); |
|
|
|
|
} |
|
|
|
|
@ -221,8 +274,12 @@ public class HealthCardHelper { |
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
CommonIn commonIn = HealthCardConfig.createCommonInOrcInfo(false, openid); |
|
|
|
|
if (commonIn == null) { |
|
|
|
|
throw new ServiceException("[电子健康卡]身份证识别-请求体CommonIn缺失"); |
|
|
|
|
} |
|
|
|
|
JSONObject resultJson = HealthCardConfig.createHealthCardService().ocrInfo(commonIn, imageContent, 15, 15, false); // 禁止打印日志
|
|
|
|
|
HealthCardConfig.HCardResult result = new HealthCardConfig.HCardResult(resultJson); |
|
|
|
|
if (!result.isOk) { |
|
|
|
|
throw new ServiceException("[电子健康卡]身份证识别-失败: " + JsonHelper.toJsonString(resultJson)); |
|
|
|
|
@ -251,72 +308,20 @@ public class HealthCardHelper { |
|
|
|
|
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); |
|
|
|
|
public static Patient getRegInfoByCode(Boolean isMiniApp, String openid, String regInfoCode) throws ServiceException { |
|
|
|
|
if (ObjectUtils.isEmpty(openid) || ObjectUtils.isEmpty(regInfoCode)) { |
|
|
|
|
throw new ServiceException(ResultEnum.PARAM_IS_DEFECT); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp, openid); |
|
|
|
|
if (commonIn == null) { |
|
|
|
|
throw new ServiceException("[电子健康卡]获取建档信息-请求参数缺失"); |
|
|
|
|
throw new ServiceException("[电子健康卡]获取建档信息-请求体CommonIn缺失"); |
|
|
|
|
} |
|
|
|
|
JSONObject resultJson = HealthCardConfig.createHealthCardService().getRegInfoByCode(commonIn, regInfoCode); |
|
|
|
|
HealthCardConfig.HCardResult result = new HealthCardConfig.HCardResult(resultJson); |
|
|
|
|
@ -356,29 +361,27 @@ public class HealthCardHelper { |
|
|
|
|
* @param idCardNo 证件号码 |
|
|
|
|
* @param codeType 传0或者1,0返回动态码,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; |
|
|
|
|
public static JSONObject getDynamicQRCode(Boolean isMiniApp, String openid, String healthCardId, String idCardNo, String codeType) throws ServiceException { |
|
|
|
|
if (openid == null || healthCardId == null || idCardNo == null || codeType == null) { |
|
|
|
|
throw new ServiceException(ResultEnum.PARAM_IS_INVALID); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp); |
|
|
|
|
if (commonIn == null) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp, openid); |
|
|
|
|
if (commonIn == null) { |
|
|
|
|
throw new ServiceException("[电子健康卡]获取健康卡二维码-请求体CommonIn缺失"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
JSONObject resultJson = HealthCardConfig.createHealthCardService().getDynamicQRCode(commonIn, healthCardId, "01", idCardNo, codeType); |
|
|
|
|
HealthCardConfig.HCardResult result = new HealthCardConfig.HCardResult(resultJson); |
|
|
|
|
if (!result.isOk) { |
|
|
|
|
throw new ServiceException("[电子健康卡]获取健康卡二维码-失败" + result.getJsonCommon()); |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
JSONObject data = result.getRsp(); |
|
|
|
|
if (data == null) { |
|
|
|
|
throw new ServiceException("[电子健康卡]获取健康卡二维码-返回数据为空"); |
|
|
|
|
} |
|
|
|
|
return data; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -388,17 +391,15 @@ public class HealthCardHelper { |
|
|
|
|
* @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; |
|
|
|
|
public static String getQRCodeText(Boolean isMiniApp, String openid, String healthCardId, String idCardNo) throws ServiceException { |
|
|
|
|
if (healthCardId == null || idCardNo == null) { |
|
|
|
|
throw new ServiceException(ResultEnum.PARAM_IS_DEFECT); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JSONObject QRResult = getDynamicQRCode(isMiniApp, openid, healthCardId, idCardNo, "0"); |
|
|
|
|
String qrCodeText = QRResult.getString("qrCodeText"); |
|
|
|
|
if (ObjectUtils.isEmpty(qrCodeText)) { |
|
|
|
|
log.info("[电子健康卡]用卡数据监测接口-获取qrCodeText失败"); |
|
|
|
|
return null; |
|
|
|
|
throw new ServiceException("[电子健康卡]根据健康卡ID获取动态二维码-获取qrCodeText失败"); |
|
|
|
|
} |
|
|
|
|
return qrCodeText; |
|
|
|
|
} |
|
|
|
|
@ -408,86 +409,84 @@ public class HealthCardHelper { |
|
|
|
|
* |
|
|
|
|
* @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); |
|
|
|
|
public static JSONObject getOrderIdByOutAppId(Boolean isMiniApp, String openid, String qrCodeText) throws ServiceException { |
|
|
|
|
if (ObjectUtils.isEmpty(qrCodeText)) { |
|
|
|
|
throw new ServiceException("[电子健康卡]获取卡包订单ID-qrCodeText获取失败"); |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp, openid); |
|
|
|
|
if (commonIn == null) { |
|
|
|
|
throw new ServiceException("[电子健康卡]获取卡包订单ID-请求体CommonIn缺失"); |
|
|
|
|
} |
|
|
|
|
//调用接口
|
|
|
|
|
JSONObject resultJson = HealthCardConfig.createHealthCardService().getOrderIdByOutAppId(commonIn, WeChatConfig.APP_ID, qrCodeText); |
|
|
|
|
HealthCardConfig.HCardResult result = new HealthCardConfig.HCardResult(resultJson); |
|
|
|
|
if (!result.isOk) { |
|
|
|
|
throw new ServiceException("[电子健康卡]获取卡包订单ID-失败" + result.getJsonCommon()); |
|
|
|
|
} |
|
|
|
|
return result.getRsp(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 实人认证生成orderId |
|
|
|
|
*/ |
|
|
|
|
public static JSONObject registerUniformVerifyOrder(Boolean isMiniApp, String wechatCode, HealthCardSceneEnum sceneEnum, String name, String idCardNo) { |
|
|
|
|
try { |
|
|
|
|
log.info("[电子健康卡]实人认证生成orderId idCardNo={}, name={}", idCardNo, name); |
|
|
|
|
if (ObjectUtils.isEmpty(idCardNo) || ObjectUtils.isEmpty(name)) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp); |
|
|
|
|
if (commonIn == null) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
public static JSONObject registerUniformVerifyOrder(Boolean isMiniApp, String openid, String wechatCode, HealthCardSceneEnum sceneEnum, String name, String idCardNo, String redirectPage, String redirectHash) throws ServiceException { |
|
|
|
|
if (ObjectUtils.isEmpty(name) || ObjectUtils.isEmpty(idCardNo)) { |
|
|
|
|
throw new ServiceException(ResultEnum.PARAM_IS_DEFECT); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String webURL = WeChatConfig.getWebReqURL(); |
|
|
|
|
String verifySuccessRedirectUrl = webURL + "hc-ok.html?registerOrderId=${registerOrderId}"; |
|
|
|
|
String verifyFailRedirectUrl = webURL + "health-card-fail.html?code=-3"; |
|
|
|
|
|
|
|
|
|
JSONObject resultJson = HealthCardConfig.createHealthCardService().registerUniformVerifyOrder(commonIn, |
|
|
|
|
idCardNo, |
|
|
|
|
"01", |
|
|
|
|
name, |
|
|
|
|
wechatCode, |
|
|
|
|
null, |
|
|
|
|
(sceneEnum == null ? null : sceneEnum.CODE), |
|
|
|
|
null, |
|
|
|
|
HealthCardEnum.CARD_TYPE_ID_CARD.STATUS, |
|
|
|
|
null, |
|
|
|
|
verifySuccessRedirectUrl, |
|
|
|
|
verifyFailRedirectUrl, |
|
|
|
|
null, |
|
|
|
|
0); |
|
|
|
|
HealthCardConfig.HCardResult result = new HealthCardConfig.HCardResult(resultJson); |
|
|
|
|
// JSONObject resultJson = new HealthCardServerImpl(H_APP_SECRET).registerUniformVerifyOrder(commonIn, idCardNo, "01", name, wechatCode);
|
|
|
|
|
if (!result.isOk) { |
|
|
|
|
log.info("[电子健康卡]实人认证生成orderId接口失败: {}", resultJson); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
JSONObject respJson = result.getRsp(); |
|
|
|
|
if (respJson == null) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
return respJson; |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
ErrorHelper.println(e); |
|
|
|
|
if (ObjectUtils.isEmpty(redirectPage) || !redirectPage.contains(".html")) { |
|
|
|
|
throw new ServiceException(ResultEnum.PARAM_IS_INVALID); |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
if (ObjectUtils.isEmpty(redirectHash)) { |
|
|
|
|
redirectHash = ""; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp, openid); |
|
|
|
|
if (commonIn == null) { |
|
|
|
|
throw new ServiceException("[电子健康卡]实人认证生成orderId-请求体CommonIn缺失"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String webURL = WeChatConfig.getWebReqURL(); |
|
|
|
|
String verifySuccessRedirectUrl = webURL + redirectPage + "?registerOrderId=${registerOrderId}" + redirectHash; |
|
|
|
|
String verifyFailRedirectUrl = webURL + "health-card-fail.html?code=-3"; |
|
|
|
|
|
|
|
|
|
JSONObject resultJson = HealthCardConfig.createHealthCardService().registerUniformVerifyOrder(commonIn, |
|
|
|
|
idCardNo, |
|
|
|
|
"01", |
|
|
|
|
name, |
|
|
|
|
wechatCode, |
|
|
|
|
null, |
|
|
|
|
(sceneEnum == null ? null : sceneEnum.CODE), |
|
|
|
|
null, |
|
|
|
|
HealthCardEnum.CARD_TYPE_ID_CARD.STATUS, |
|
|
|
|
null, |
|
|
|
|
verifySuccessRedirectUrl, |
|
|
|
|
verifyFailRedirectUrl, |
|
|
|
|
null, |
|
|
|
|
0); |
|
|
|
|
HealthCardConfig.HCardResult result = new HealthCardConfig.HCardResult(resultJson); |
|
|
|
|
log.info("[电子健康卡]实人认证生成orderId resp: {}", JsonHelper.toJsonString(resultJson)); |
|
|
|
|
if (!result.isOk) { |
|
|
|
|
throw new ServiceException("[电子健康卡]实人认证生成orderId-失败:" + result.getJsonCommon()); |
|
|
|
|
} |
|
|
|
|
JSONObject respJson = result.getRsp(); |
|
|
|
|
if (respJson == null) { |
|
|
|
|
throw new ServiceException("[电子健康卡]实人认证生成orderId-响应数据为空"); |
|
|
|
|
} |
|
|
|
|
return respJson; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* [电子健康卡]实人认证结果查询 |
|
|
|
|
*/ |
|
|
|
|
public static boolean checkUniformVerifyResult(Boolean isMiniApp, String verifyOrderId, String registerOrderId) { |
|
|
|
|
public static boolean checkUniformVerifyResult(Boolean isMiniApp, String openid, String verifyOrderId, String registerOrderId) { |
|
|
|
|
try { |
|
|
|
|
log.info("[电子健康卡]实人认证结果查询 verifyOrderId={}, registerOrderId={}", verifyOrderId, registerOrderId); |
|
|
|
|
if (ObjectUtils.isEmpty(verifyOrderId) || ObjectUtils.isEmpty(registerOrderId)) { |
|
|
|
|
log.info("[电子健康卡]实人认证结果查询 openid={}, verifyOrderId={}, registerOrderId={}", openid, verifyOrderId, registerOrderId); |
|
|
|
|
if (ObjectUtils.isEmpty(openid) || ObjectUtils.isEmpty(verifyOrderId) || ObjectUtils.isEmpty(registerOrderId)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp); |
|
|
|
|
CommonIn commonIn = HealthCardConfig.createCommonIn(isMiniApp, openid); |
|
|
|
|
if (commonIn == null) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
@ -509,27 +508,41 @@ public class HealthCardHelper { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 电子健康卡用卡数据监测接口 |
|
|
|
|
* [电子健康卡]用卡数据监测接口 |
|
|
|
|
* |
|
|
|
|
* @param qrCodeText 动态二维码 |
|
|
|
|
* @param deptName 科室名 |
|
|
|
|
* @param scene 上报类型 scene |
|
|
|
|
* @param cardType 卡类型 |
|
|
|
|
* @return JSONObject |
|
|
|
|
* @param openid openid |
|
|
|
|
* @param healthCardId 健康卡id |
|
|
|
|
* @param idCardNo 证件号 |
|
|
|
|
* @param scene 场景 |
|
|
|
|
* @param deptName 科室名 |
|
|
|
|
* @param cardCostType 费用类别 |
|
|
|
|
* @return json |
|
|
|
|
*/ |
|
|
|
|
public static JSONObject reportHISData(String qrCodeText, String deptName, String scene, String cardType, String cardCostType) { |
|
|
|
|
if (!HealthCardConfig.IS_UPLOAD_DATA) { // 禁止数据上传
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
public static JSONObject reportHISData(String openid, String healthCardId, String idCardNo, String scene, String deptName, HealthCardEnum cardCostType) { |
|
|
|
|
try { |
|
|
|
|
log.info("[电子健康卡]用卡数据监测接口 scene={}", scene); |
|
|
|
|
if (!HealthCardConfig.IS_UPLOAD_DATA) { // 禁止数据上传
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (ObjectUtils.isEmpty(qrCodeText) || scene == null || cardType == null) { |
|
|
|
|
log.info("[电子健康卡]用卡数据监测接口,参数为空"); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
if (ObjectUtils.isEmpty(openid) || ObjectUtils.isEmpty(healthCardId) || ObjectUtils.isEmpty(idCardNo) || ObjectUtils.isEmpty(scene)) { |
|
|
|
|
log.error("[电子健康卡]用卡数据监测,参数为空"); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
CommonIn commonIn = HealthCardConfig.createCommonIn(false); |
|
|
|
|
String qrCodeText = HealthCardHelper.getQRCodeText(false, openid, healthCardId, idCardNo); |
|
|
|
|
if (qrCodeText == null) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (ObjectUtils.isEmpty(qrCodeText)) { |
|
|
|
|
log.error("[电子健康卡]用卡数据监测,qrCodeText为空"); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CommonIn commonIn = HealthCardConfig.createCommonIn(false, openid); |
|
|
|
|
if (commonIn == null) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
@ -542,28 +555,86 @@ public class HealthCardHelper { |
|
|
|
|
req.setHospitalCode(HealthCardConfig.H_HOSPITAL_ID); |
|
|
|
|
// 010101 挂号
|
|
|
|
|
req.setScene(scene); |
|
|
|
|
req.setDepartment(deptName); // 科室代码
|
|
|
|
|
req.setDepartment(ObjectUtils.isEmpty(deptName) ? null : deptName); // 科室代码
|
|
|
|
|
req.setCardChannel(HealthCardEnum.CARD_CHANNEL_WX_CHANNEL.STATUS); // 微信渠道
|
|
|
|
|
|
|
|
|
|
req.setCardType(cardType); |
|
|
|
|
req.setCardType(HealthCardEnum.CARD_TYPE_HEALTH_CARD.STATUS); // 电子健康卡
|
|
|
|
|
|
|
|
|
|
// 自费:0100,医保:0200,公费:0300,其他:0000
|
|
|
|
|
req.setCardCostTypes(cardCostType); |
|
|
|
|
//调用接口
|
|
|
|
|
req.setCardCostTypes(cardCostType == null ? null : cardCostType.STATUS); |
|
|
|
|
|
|
|
|
|
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)); |
|
|
|
|
log.info("[电子健康卡]用卡数据监测 req={}, resp={}", JsonHelper.toJsonString(req), JsonHelper.toJsonString(resultJson)); |
|
|
|
|
} |
|
|
|
|
if (!result.isOk) { |
|
|
|
|
log.info("[电子健康卡]用卡数据监测接口 {}", resultJson); |
|
|
|
|
log.error("[电子健康卡]用卡数据监测-上传失败 {}", result.getJsonCommon()); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
return result.getRsp(); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
ErrorHelper.println(e); |
|
|
|
|
log.error("[电子健康卡]用卡数据监测-上传异常 {}", e.getMessage()); |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// /**
|
|
|
|
|
// * 电子健康卡用卡数据监测接口
|
|
|
|
|
// *
|
|
|
|
|
// * @param qrCodeText 动态二维码
|
|
|
|
|
// * @param deptName 科室名
|
|
|
|
|
// * @param scene 上报类型 scene
|
|
|
|
|
// * @param cardType 卡类型
|
|
|
|
|
// * @return JSONObject
|
|
|
|
|
// */
|
|
|
|
|
// public static JSONObject reportHISData(String qrCodeText, String deptName, String scene, String cardType, String cardCostType) {
|
|
|
|
|
// if (!HealthCardConfig.IS_UPLOAD_DATA) { // 禁止数据上传
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (ObjectUtils.isEmpty(qrCodeText) || scene == null || cardType == null) {
|
|
|
|
|
// log.info("[电子健康卡]用卡数据监测接口,参数为空");
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// try {
|
|
|
|
|
// CommonIn commonIn = HealthCardConfig.createCommonIn(false);
|
|
|
|
|
// if (commonIn == null) {
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// ReportHISData req = new ReportHISData();
|
|
|
|
|
// req.setQrCodeText(qrCodeText);
|
|
|
|
|
// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
// req.setTime(format.format(new Date()));
|
|
|
|
|
//
|
|
|
|
|
// req.setHospitalCode(HealthCardConfig.H_HOSPITAL_ID);
|
|
|
|
|
// // 010101 挂号
|
|
|
|
|
// req.setScene(scene);
|
|
|
|
|
// req.setDepartment(deptName); // 科室代码
|
|
|
|
|
// req.setCardChannel(HealthCardEnum.CARD_CHANNEL_WX_CHANNEL.STATUS); // 微信渠道
|
|
|
|
|
//
|
|
|
|
|
// req.setCardType(cardType);
|
|
|
|
|
//
|
|
|
|
|
// // 自费:0100,医保:0200,公费:0300,其他:0000
|
|
|
|
|
// req.setCardCostTypes(cardCostType);
|
|
|
|
|
// //调用接口
|
|
|
|
|
// 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;
|
|
|
|
|
// }
|
|
|
|
|
// return result.getRsp();
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// ErrorHelper.println(e);
|
|
|
|
|
// }
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|