|
|
|
@ -1,12 +1,11 @@ |
|
|
|
package com.ynxbd.common.healthcard; |
|
|
|
package com.ynxbd.common.healthcard; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.google.gson.*; |
|
|
|
|
|
|
|
import com.ynxbd.common.bean.Patient; |
|
|
|
import com.ynxbd.common.bean.Patient; |
|
|
|
import com.ynxbd.common.bean.enums.MerchantEnum; |
|
|
|
import com.ynxbd.common.bean.enums.MerchantEnum; |
|
|
|
import com.ynxbd.common.bean.pay.Register; |
|
|
|
import com.ynxbd.common.bean.pay.Register; |
|
|
|
import com.ynxbd.common.bean.sms.SmsTemplate; |
|
|
|
|
|
|
|
import com.ynxbd.common.healthcard.config.HCPreConsultConfig; |
|
|
|
import com.ynxbd.common.healthcard.config.HCPreConsultConfig; |
|
|
|
|
|
|
|
import com.ynxbd.common.healthcard.config.HCReportConfig; |
|
|
|
import com.ynxbd.common.helper.common.CodeHelper; |
|
|
|
import com.ynxbd.common.helper.common.CodeHelper; |
|
|
|
import com.ynxbd.common.helper.common.JsonHelper; |
|
|
|
import com.ynxbd.common.helper.common.JsonHelper; |
|
|
|
import com.ynxbd.common.helper.http.OkHttpHelper; |
|
|
|
import com.ynxbd.common.helper.http.OkHttpHelper; |
|
|
|
@ -16,10 +15,7 @@ import com.ynxbd.wx.config.WeChatConfig; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import okhttp3.Headers; |
|
|
|
import okhttp3.Headers; |
|
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
|
import org.ehcache.Cache; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
|
|
|
|
import java.security.MessageDigest; |
|
|
|
|
|
|
|
import java.time.Instant; |
|
|
|
import java.time.Instant; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
|
@ -38,7 +34,7 @@ public class HCPreConsultHelper { |
|
|
|
|
|
|
|
|
|
|
|
headers.add("Th-Auth-Type", "Th-Auth-Hc"); |
|
|
|
headers.add("Th-Auth-Type", "Th-Auth-Hc"); |
|
|
|
headers.add("Th-Auth-Hc-App-Token", token); |
|
|
|
headers.add("Th-Auth-Hc-App-Token", token); |
|
|
|
headers.add("Th-Auth-Hc-HospitalId", HCPreConsultConfig.APP_HOSP_ID); |
|
|
|
headers.add("Th-Auth-Hc-HospitalId", HCPreConsultConfig.H_HOSP_ID); |
|
|
|
headers.add("Th-Auth-Hc-Timestamp", timestamp); |
|
|
|
headers.add("Th-Auth-Hc-Timestamp", timestamp); |
|
|
|
if (sign != null) { |
|
|
|
if (sign != null) { |
|
|
|
headers.add("Th-Auth-Hc-Sign", sign); |
|
|
|
headers.add("Th-Auth-Hc-Sign", sign); |
|
|
|
@ -99,7 +95,7 @@ public class HCPreConsultHelper { |
|
|
|
? "https://med-biz-pre.wecity.qq.com/api/report/PushSubscribeMessage/" |
|
|
|
? "https://med-biz-pre.wecity.qq.com/api/report/PushSubscribeMessage/" |
|
|
|
: "https://med-biz.wecity.qq.com/api/report/PushSubscribeMessage/"; |
|
|
|
: "https://med-biz.wecity.qq.com/api/report/PushSubscribeMessage/"; |
|
|
|
|
|
|
|
|
|
|
|
HCSignHelper config = HCPreConsultConfig.createSign(); |
|
|
|
HCSignHelper config = HCReportConfig.createSign(); // 报告配置生成签名
|
|
|
|
String requestId = config.getRequestId(); |
|
|
|
String requestId = config.getRequestId(); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> reqHead = new HashMap<>(); |
|
|
|
Map<String, Object> reqHead = new HashMap<>(); |
|
|
|
@ -107,17 +103,17 @@ public class HCPreConsultHelper { |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> sceneData = new HashMap<>(); |
|
|
|
Map<String, Object> sceneData = new HashMap<>(); |
|
|
|
sceneData.put("registerId", registerId); |
|
|
|
sceneData.put("registerId", registerId); |
|
|
|
sceneData.put("registerIdSign", HCPreConsultConfig.toHmacSha256Example(HCPreConsultConfig.SECRET_KEY, HCPreConsultConfig.HOSP_ID + registerId)); |
|
|
|
sceneData.put("registerIdSign", HCPreConsultConfig.createRegisterSign(registerId)); |
|
|
|
|
|
|
|
|
|
|
|
sceneData.put("encounterDate", regDate + " " + begTime); // yyyy-MM-dd HH:mm:ss
|
|
|
|
sceneData.put("encounterDate", regDate + " " + begTime); // yyyy-MM-dd HH:mm:ss
|
|
|
|
sceneData.put("partnerAppId", HCPreConsultConfig.APP_ID); // 开发者ID(AppID),在管理>开发商接入 下查询
|
|
|
|
sceneData.put("partnerAppId", HCPreConsultConfig.APP_ID); // 开发者ID(AppID),在管理>开发商接入 下查询
|
|
|
|
sceneData.put("partnerId", HCPreConsultConfig.SCENE_PARTNER_ID); |
|
|
|
sceneData.put("partnerId", HCPreConsultConfig.PARTNER_ID); |
|
|
|
|
|
|
|
|
|
|
|
// partnerId:合作方ID 腾讯健康提供
|
|
|
|
// partnerId:注意这里使用的是报告配置的-PARTNER_ID
|
|
|
|
JSONObject respJson = post(url + HCPreConsultConfig.PARTNER_ID, req -> { |
|
|
|
JSONObject respJson = post(url + HCReportConfig.PARTNER_ID, req -> { |
|
|
|
req.put("reqHead", reqHead); |
|
|
|
req.put("reqHead", reqHead); |
|
|
|
req.put("appId", WeChatConfig.APP_ID); |
|
|
|
req.put("appId", WeChatConfig.APP_ID); |
|
|
|
req.put("hospitalId", HCPreConsultConfig.APP_HOSP_ID); |
|
|
|
req.put("hospitalId", HCPreConsultConfig.H_HOSP_ID); |
|
|
|
|
|
|
|
|
|
|
|
req.put("openId", openid); |
|
|
|
req.put("openId", openid); |
|
|
|
req.put("healthCardId", ObjectUtils.isEmpty(patient.getHealthCardId()) ? "" : patient.getHealthCardId()); |
|
|
|
req.put("healthCardId", ObjectUtils.isEmpty(patient.getHealthCardId()) ? "" : patient.getHealthCardId()); |
|
|
|
@ -137,14 +133,13 @@ public class HCPreConsultHelper { |
|
|
|
headers.add("god-portal-request-id", requestId); |
|
|
|
headers.add("god-portal-request-id", requestId); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
log.info("[预问诊]resp={}", JsonHelper.toJsonString(respJson)); |
|
|
|
log.warn("[预问诊]上传挂号数据 resp={}", JsonHelper.toJsonString(respJson)); |
|
|
|
String code = respJson.getString("code"); |
|
|
|
String code = respJson.getString("code"); |
|
|
|
String message = respJson.getString("msg"); |
|
|
|
String message = respJson.getString("msg"); |
|
|
|
if (!"0".equals(code)) { |
|
|
|
if (!"0".equals(code)) { |
|
|
|
log.error("[预问诊]上传挂号数据-失败:{}", message); |
|
|
|
log.error("[预问诊]上传挂号数据-失败:{}", message); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
log.info("[预问诊]上传挂号数据-成功"); |
|
|
|
log.info("[预问诊]上传挂号数据-成功"); |
|
|
|
// MessagePushConfig.regEndPreConsult(merchantEnum, order);
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -192,7 +187,7 @@ public class HCPreConsultHelper { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 7.2 接入方式一:打开完整页面 |
|
|
|
* 7.2 接入方式一:打开完整页面 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static String getH5DoctorURL(String openId, String registerId, String departmentId, String departmentName, String doctorId, String doctorName, String redirectUrl) throws ServiceException { |
|
|
|
public static String getH5DoctorURL(String registerId, String departmentId, String departmentName, String doctorId, String doctorName, String redirectUrl) throws ServiceException { |
|
|
|
String token = getH5DoctorLoginToken(doctorId, doctorName); |
|
|
|
String token = getH5DoctorLoginToken(doctorId, doctorName); |
|
|
|
if (ObjectUtils.isEmpty(token)) { |
|
|
|
if (ObjectUtils.isEmpty(token)) { |
|
|
|
throw new ServiceException("token获取失败"); |
|
|
|
throw new ServiceException("token获取失败"); |
|
|
|
@ -215,12 +210,12 @@ public class HCPreConsultHelper { |
|
|
|
String url = "https://aimedical.wecity.qq.com/cgi-bin/v1/Diagnosis/RationalDrugServer/RationalDrugServant/HisToolLogin"; |
|
|
|
String url = "https://aimedical.wecity.qq.com/cgi-bin/v1/Diagnosis/RationalDrugServer/RationalDrugServant/HisToolLogin"; |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> data = new HashMap<>(); |
|
|
|
Map<String, Object> data = new HashMap<>(); |
|
|
|
data.put("partner_id", HCPreConsultConfig.SCENE_PARTNER_ID); |
|
|
|
data.put("partner_id", HCPreConsultConfig.PARTNER_ID); |
|
|
|
data.put("doctor_id", doctorId); |
|
|
|
data.put("doctor_id", doctorId); |
|
|
|
data.put("doctor_name", doctorName); |
|
|
|
data.put("doctor_name", doctorName); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> header = new HashMap<>(); |
|
|
|
Map<String, Object> header = new HashMap<>(); |
|
|
|
header.put("hospital_id", HCPreConsultConfig.DOCTOR_PC_HOSP_ID); |
|
|
|
header.put("hospital_id", HCPreConsultConfig.HOSP_ID); |
|
|
|
header.put("sub_hospital_id", ""); |
|
|
|
header.put("sub_hospital_id", ""); |
|
|
|
|
|
|
|
|
|
|
|
JSONObject resultJson = post(url, params -> { |
|
|
|
JSONObject resultJson = post(url, params -> { |
|
|
|
@ -229,7 +224,7 @@ public class HCPreConsultHelper { |
|
|
|
log.info("[7.2.1 通过 HisToolLoginIn接口获取 token] 入参:{}", JsonHelper.toJsonString(params)); |
|
|
|
log.info("[7.2.1 通过 HisToolLoginIn接口获取 token] 入参:{}", JsonHelper.toJsonString(params)); |
|
|
|
}, headers -> { |
|
|
|
}, headers -> { |
|
|
|
String timestamp = String.valueOf(System.currentTimeMillis()); |
|
|
|
String timestamp = String.valueOf(System.currentTimeMillis()); |
|
|
|
headers.add("god-portal-signature", HCPreConsultConfig.toHmacSha256Example(HCPreConsultConfig.DOCTOR_PC_SECRET_KEY, HCPreConsultConfig.DOCTOR_PC_HOSP_ID + timestamp)); |
|
|
|
headers.add("god-portal-signature", HCPreConsultConfig.toHmacSha256Example(HCPreConsultConfig.SECRET_KEY, HCPreConsultConfig.HOSP_ID + timestamp)); |
|
|
|
headers.add("god-portal-timestamp", timestamp); |
|
|
|
headers.add("god-portal-timestamp", timestamp); |
|
|
|
headers.add("god-portal-request-id", CodeHelper.get32UUID()); |
|
|
|
headers.add("god-portal-request-id", CodeHelper.get32UUID()); |
|
|
|
}); |
|
|
|
}); |
|
|
|
@ -359,7 +354,7 @@ public class HCPreConsultHelper { |
|
|
|
String sign = HCPreConsultConfig.calculateSign(timestamp); |
|
|
|
String sign = HCPreConsultConfig.calculateSign(timestamp); |
|
|
|
|
|
|
|
|
|
|
|
headers.set("Th-Auth-Type", "Th-Auth-Hc"); |
|
|
|
headers.set("Th-Auth-Type", "Th-Auth-Hc"); |
|
|
|
headers.set("Th-Auth-Hc-HospitalId", HCPreConsultConfig.APP_HOSP_ID); |
|
|
|
headers.set("Th-Auth-Hc-HospitalId", HCPreConsultConfig.H_HOSP_ID); |
|
|
|
headers.set("Th-Auth-Hc-Timestamp", timestamp); |
|
|
|
headers.set("Th-Auth-Hc-Timestamp", timestamp); |
|
|
|
headers.set("Th-Auth-Hc-ChannelNum", "0"); |
|
|
|
headers.set("Th-Auth-Hc-ChannelNum", "0"); |
|
|
|
// headers.set("Th-Auth-Hc-Relate-AppId", WeChatConfig.APP_ID);
|
|
|
|
// headers.set("Th-Auth-Hc-Relate-AppId", WeChatConfig.APP_ID);
|
|
|
|
@ -368,7 +363,7 @@ public class HCPreConsultHelper { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
log.warn("[预问诊-医生端]获取token appId={}, headers={\"Th-Auth-Type\": \"{}\", \"Th-Auth-Hc-HospitalId\": \"{}\", \"Th-Auth-Hc-Timestamp\": \"{}\", \"Th-Auth-Hc-ChannelNum\": \"0\", \"Th-Auth-Hc-Sign\":\"{}\"}", |
|
|
|
log.warn("[预问诊-医生端]获取token appId={}, headers={\"Th-Auth-Type\": \"{}\", \"Th-Auth-Hc-HospitalId\": \"{}\", \"Th-Auth-Hc-Timestamp\": \"{}\", \"Th-Auth-Hc-ChannelNum\": \"0\", \"Th-Auth-Hc-Sign\":\"{}\"}", |
|
|
|
HCPreConsultConfig.APP_ID, "Th-Auth-Hc", HCPreConsultConfig.APP_HOSP_ID, timestamp, sign); |
|
|
|
HCPreConsultConfig.APP_ID, "Th-Auth-Hc", HCPreConsultConfig.H_HOSP_ID, timestamp, sign); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
log.warn("[预问诊-医生端]获取token 响应数据:{}", JsonHelper.toJsonString(resultJson)); |
|
|
|
log.warn("[预问诊-医生端]获取token 响应数据:{}", JsonHelper.toJsonString(resultJson)); |
|
|
|
|