|
|
|
|
@ -48,8 +48,7 @@ public class HCodeService { |
|
|
|
|
static { |
|
|
|
|
ProperHelper config = new ProperHelper().read("hcode.properties"); |
|
|
|
|
IS_ENABLE = config.getBoolean("is_enable", false); |
|
|
|
|
config.setIsEnable(IS_ENABLE); |
|
|
|
|
|
|
|
|
|
// 不用对config设置开关,不开启时也需要用到参数
|
|
|
|
|
H_APP_ID = config.getString("h.app_id"); |
|
|
|
|
H_APP_SECRET = config.getString("h.app_secret"); |
|
|
|
|
CARD_APP_ID = config.getString("h.card_app_id"); |
|
|
|
|
@ -72,6 +71,12 @@ public class HCodeService { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private CommonIn createCommonIn(String appToken) { |
|
|
|
|
String requestId = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase(); |
|
|
|
|
int channelNum = 0; |
|
|
|
|
return new CommonIn(appToken, requestId, H_HOSPITAL_ID, channelNum); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 判断是否使用电子健康卡 |
|
|
|
|
* |
|
|
|
|
@ -84,14 +89,17 @@ public class HCodeService { |
|
|
|
|
return IS_ENABLE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getAppToken() { |
|
|
|
|
return getAppToken(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取token |
|
|
|
|
* |
|
|
|
|
* @return token |
|
|
|
|
*/ |
|
|
|
|
public String getAppToken() { |
|
|
|
|
if (!isEnableHCode()) { |
|
|
|
|
public String getAppToken(boolean isEnTokenSwitch) { |
|
|
|
|
if (isEnTokenSwitch && !isEnableHCode()) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -107,25 +115,19 @@ public class HCodeService { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
HealthCardServerImpl healthCard = new HealthCardServerImpl(H_APP_SECRET, 5, 10); |
|
|
|
|
String requestId = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase(); |
|
|
|
|
int channelNum = 0; |
|
|
|
|
CommonIn commonIn = new CommonIn("", requestId, H_HOSPITAL_ID, channelNum); |
|
|
|
|
//调用接口
|
|
|
|
|
JSONObject appTokenObj = healthCard.getAppToken(commonIn, H_APP_ID); |
|
|
|
|
|
|
|
|
|
//调用接口
|
|
|
|
|
JSONObject resultObj = healthCard.getAppToken(commonIn, H_APP_ID); |
|
|
|
|
JSONObject resultObj = new HealthCardServerImpl(H_APP_SECRET, 5, 10) |
|
|
|
|
.getAppToken(createCommonIn(""), H_APP_ID); |
|
|
|
|
JSONObject commonOut = resultObj.getJSONObject("commonOut"); |
|
|
|
|
if (!"0".equals(commonOut.getString("resultCode"))) { |
|
|
|
|
log.info("[电子健康卡]获取appToken失败: {}", resultObj); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JSONObject respJson = appTokenObj.getJSONObject("rsp"); |
|
|
|
|
JSONObject respJson = resultObj.getJSONObject("rsp"); |
|
|
|
|
appToken = respJson.getString("appToken"); |
|
|
|
|
|
|
|
|
|
if (CACHE != null && appToken != null && !"".equals(appToken)) { |
|
|
|
|
if (CACHE != null && !ObjectUtils.isEmpty(appToken)) { |
|
|
|
|
CACHE.put("appToken", appToken); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -148,10 +150,9 @@ public class HCodeService { |
|
|
|
|
if (appToken == null) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
HealthCardServerImpl healthCard = new HealthCardServerImpl(H_APP_SECRET); |
|
|
|
|
String requestId = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase(); |
|
|
|
|
CommonIn commonIn = new CommonIn(appToken, requestId, H_HOSPITAL_ID, 0); |
|
|
|
|
JSONObject resultObj = healthCard.getHealthCardByHealthCode(commonIn, healthCode); |
|
|
|
|
CommonIn commonIn = createCommonIn(appToken); |
|
|
|
|
|
|
|
|
|
JSONObject resultObj = new HealthCardServerImpl(H_APP_SECRET).getHealthCardByHealthCode(commonIn, healthCode); |
|
|
|
|
JSONObject rspObj = resultObj.getJSONObject("rsp"); |
|
|
|
|
JSONObject cardJson = rspObj.getJSONObject("card"); |
|
|
|
|
Patient patient = new Patient(); |
|
|
|
|
@ -199,11 +200,8 @@ public class HCodeService { |
|
|
|
|
areaAddress = ""; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HealthCardServerImpl healthCard = new HealthCardServerImpl(H_APP_SECRET); |
|
|
|
|
CommonIn commonIn = createCommonIn(appToken); |
|
|
|
|
|
|
|
|
|
// 构造公共输入参数commonIn
|
|
|
|
|
String requestId = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase(); |
|
|
|
|
CommonIn commonIn = new CommonIn(appToken, requestId, H_HOSPITAL_ID, 0); |
|
|
|
|
HealthCardInfo healthCardInfoReq = new HealthCardInfo(); |
|
|
|
|
healthCardInfoReq.setAddress(areaAddress + address); |
|
|
|
|
healthCardInfoReq.setBirthday(birthday); |
|
|
|
|
@ -216,7 +214,7 @@ public class HCodeService { |
|
|
|
|
healthCardInfoReq.setWechatCode(wechatCode); |
|
|
|
|
healthCardInfoReq.setPatid(patientId); |
|
|
|
|
//调用接口
|
|
|
|
|
JSONObject resultObj = healthCard.registerHealthCard(commonIn, healthCardInfoReq); |
|
|
|
|
JSONObject resultObj = new HealthCardServerImpl(H_APP_SECRET).registerHealthCard(commonIn, healthCardInfoReq); |
|
|
|
|
JSONObject commonOut = resultObj.getJSONObject("commonOut"); |
|
|
|
|
if (!"0".equals(commonOut.getString("resultCode"))) { |
|
|
|
|
log.info("[电子健康卡]注册失败: {}", resultObj); |
|
|
|
|
@ -237,15 +235,13 @@ public class HCodeService { |
|
|
|
|
*/ |
|
|
|
|
public Patient getInfoByHealthCode(String healthCode) { |
|
|
|
|
try { |
|
|
|
|
String appToken = getAppToken(); |
|
|
|
|
String appToken = getAppToken(false); |
|
|
|
|
if (appToken == null) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
HealthCardServerImpl healthCard = new HealthCardServerImpl(H_APP_SECRET); |
|
|
|
|
String requestId = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase(); |
|
|
|
|
CommonIn commonIn = new CommonIn(appToken, requestId, H_HOSPITAL_ID, 0); |
|
|
|
|
CommonIn commonIn = createCommonIn(appToken); |
|
|
|
|
//调用接口
|
|
|
|
|
JSONObject resultObj = healthCard.getHealthCardByHealthCode(commonIn, healthCode); |
|
|
|
|
JSONObject resultObj = new HealthCardServerImpl(H_APP_SECRET).getHealthCardByHealthCode(commonIn, healthCode); |
|
|
|
|
JSONObject commonOut = resultObj.getJSONObject("commonOut"); |
|
|
|
|
JSONObject rspObj = resultObj.getJSONObject("rsp"); |
|
|
|
|
if (!"0".equals(commonOut.getString("resultCode")) || rspObj == null) { |
|
|
|
|
@ -298,11 +294,9 @@ public class HCodeService { |
|
|
|
|
if (appToken == null) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
HealthCardServerImpl healthCard = new HealthCardServerImpl(H_APP_SECRET); |
|
|
|
|
String requestId = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase(); |
|
|
|
|
CommonIn commonIn = new CommonIn(appToken, requestId, H_HOSPITAL_ID, 0); |
|
|
|
|
CommonIn commonIn = createCommonIn(appToken); |
|
|
|
|
//调用接口
|
|
|
|
|
JSONObject resultObj = healthCard.getHealthCardByQRCode(commonIn, qrCode); |
|
|
|
|
JSONObject resultObj = new HealthCardServerImpl(H_APP_SECRET).getHealthCardByQRCode(commonIn, qrCode); |
|
|
|
|
JSONObject commonOut = resultObj.getJSONObject("commonOut"); |
|
|
|
|
if (!"0".equals(commonOut.getString("resultCode"))) { |
|
|
|
|
log.info("[电子健康卡]二维码获取健康卡失败: {}", resultObj); |
|
|
|
|
@ -348,11 +342,13 @@ public class HCodeService { |
|
|
|
|
if (appToken == null) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
HealthCardServerImpl healthCard = new HealthCardServerImpl(H_APP_SECRET); |
|
|
|
|
String requestId = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase(); |
|
|
|
|
CommonIn commonIn = new CommonIn(appToken, requestId, H_HOSPITAL_ID, 0); |
|
|
|
|
CommonIn commonIn = createCommonIn(appToken); |
|
|
|
|
//调用接口
|
|
|
|
|
JSONObject resultJson = healthCard.registerUniformVerifyOrder(commonIn, idCardNo, "01", name, wechatCode); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String okURL = WeChatConfig.getWebUrl() + "/health-card-bind.html"; |
|
|
|
|
|
|
|
|
|
JSONObject resultJson = new HealthCardServerImpl(H_APP_SECRET).registerUniformVerifyOrder(commonIn, idCardNo, "01", name, wechatCode); |
|
|
|
|
JSONObject commonOut = resultJson.getJSONObject("commonOut"); |
|
|
|
|
if (!"0".equals(commonOut.getString("resultCode"))) { |
|
|
|
|
log.info("[电子健康卡]实人认证生成orderId接口失败: {}", resultJson); |
|
|
|
|
@ -383,11 +379,9 @@ public class HCodeService { |
|
|
|
|
if (appToken == null) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
HealthCardServerImpl healthCard = new HealthCardServerImpl(H_APP_SECRET); |
|
|
|
|
String requestId = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase(); |
|
|
|
|
CommonIn commonIn = new CommonIn(appToken, requestId, H_HOSPITAL_ID, 0); |
|
|
|
|
CommonIn commonIn = createCommonIn(appToken); |
|
|
|
|
//调用接口
|
|
|
|
|
JSONObject resultJson = healthCard.checkUniformVerifyResult(commonIn, verifyOrderId, registerOrderId); |
|
|
|
|
JSONObject resultJson = new HealthCardServerImpl(H_APP_SECRET).checkUniformVerifyResult(commonIn, verifyOrderId, registerOrderId); |
|
|
|
|
JSONObject commonOut = resultJson.getJSONObject("commonOut"); |
|
|
|
|
if (!"0".equals(commonOut.getString("resultCode"))) { |
|
|
|
|
log.info("[电子健康卡]实人认证结果查询失败: {}", resultJson); |
|
|
|
|
@ -418,11 +412,9 @@ public class HCodeService { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HealthCardServerImpl healthCard = new HealthCardServerImpl(H_APP_SECRET); |
|
|
|
|
String requestId = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase(); |
|
|
|
|
CommonIn commonIn = new CommonIn(appToken, requestId, H_HOSPITAL_ID, 0); |
|
|
|
|
CommonIn commonIn = createCommonIn(appToken); |
|
|
|
|
//调用接口
|
|
|
|
|
JSONObject resultObj = healthCard.getOrderIdByOutAppId(commonIn, WeChatConfig.APP_ID, qrCodeText); |
|
|
|
|
JSONObject resultObj = new HealthCardServerImpl(H_APP_SECRET).getOrderIdByOutAppId(commonIn, WeChatConfig.APP_ID, qrCodeText); |
|
|
|
|
JSONObject commonOut = resultObj.getJSONObject("commonOut"); |
|
|
|
|
if (!"0".equals(commonOut.getString("resultCode"))) { |
|
|
|
|
log.info("[电子健康卡]获取卡包订单ID 失败: {}", resultObj); |
|
|
|
|
@ -458,8 +450,7 @@ public class HCodeService { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HealthCardServerImpl healthCard = new HealthCardServerImpl(H_APP_SECRET); |
|
|
|
|
String requestId = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase(); |
|
|
|
|
CommonIn commonIn = new CommonIn(appToken, requestId, H_HOSPITAL_ID, 0); |
|
|
|
|
CommonIn commonIn = createCommonIn(appToken); |
|
|
|
|
//构造请求参数req
|
|
|
|
|
ReportHISData reportHISData = new ReportHISData(); |
|
|
|
|
reportHISData.setQrCodeText(qrCodeText); |
|
|
|
|
@ -511,11 +502,9 @@ public class HCodeService { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HealthCardServerImpl healthCard = new HealthCardServerImpl(H_APP_SECRET); |
|
|
|
|
String requestId = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase(); |
|
|
|
|
CommonIn commonIn = new CommonIn(appToken, requestId, H_HOSPITAL_ID, 0); |
|
|
|
|
CommonIn commonIn = createCommonIn(appToken); |
|
|
|
|
//调用接口
|
|
|
|
|
JSONObject resultObj = healthCard.getDynamicQRCode(commonIn, healthCardId, "01", idCardNo, codeType); |
|
|
|
|
JSONObject resultObj = new HealthCardServerImpl(H_APP_SECRET).getDynamicQRCode(commonIn, healthCardId, "01", idCardNo, codeType); |
|
|
|
|
JSONObject commonOut = resultObj.getJSONObject("commonOut"); |
|
|
|
|
if (!"0".equals(commonOut.getString("resultCode"))) { |
|
|
|
|
log.info("获取健康卡二维码失败: {}", resultObj); |
|
|
|
|
@ -546,12 +535,8 @@ public class HCodeService { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HealthCardServerImpl healthCard = new HealthCardServerImpl(H_APP_SECRET); |
|
|
|
|
//构造公共输入参数commonIn
|
|
|
|
|
String requestId = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase(); |
|
|
|
|
|
|
|
|
|
CommonIn commonIn = new CommonIn(appToken, requestId, H_HOSPITAL_ID, 0); |
|
|
|
|
JSONObject resultObj = healthCard.bindCardRelation(commonIn, patientId, qrCodeText); |
|
|
|
|
CommonIn commonIn = createCommonIn(appToken); |
|
|
|
|
JSONObject resultObj = new HealthCardServerImpl(H_APP_SECRET).bindCardRelation(commonIn, patientId, qrCodeText); |
|
|
|
|
JSONObject commonOut = resultObj.getJSONObject("commonOut"); |
|
|
|
|
if (!"0".equals(commonOut.getString("resultCode"))) { |
|
|
|
|
log.info("[电子健康卡]绑定健康卡和医院关系失败: {}", resultObj); |
|
|
|
|
@ -662,18 +647,14 @@ public class HCodeService { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String appToken = getAppToken(); |
|
|
|
|
String appToken = getAppToken(false); // 未开启功能时也能获取token
|
|
|
|
|
if (appToken == null) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HealthCardServerImpl healthCard = new HealthCardServerImpl(H_APP_SECRET); |
|
|
|
|
//构造公共输入参数commonIn
|
|
|
|
|
String requestId = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase(); |
|
|
|
|
int channelNum = 0; |
|
|
|
|
CommonIn commonIn = new CommonIn(appToken, requestId, H_HOSPITAL_ID, channelNum); |
|
|
|
|
CommonIn commonIn = createCommonIn(appToken); |
|
|
|
|
//调用接口
|
|
|
|
|
JSONObject resultObj = healthCard.ocrInfo(commonIn, imageContent); |
|
|
|
|
JSONObject resultObj = new HealthCardServerImpl(H_APP_SECRET).ocrInfo(commonIn, imageContent); |
|
|
|
|
JSONObject commonOut = resultObj.getJSONObject("commonOut"); |
|
|
|
|
if (!"0".equals(commonOut.getString("resultCode"))) { |
|
|
|
|
log.info("[电子健康卡]身份证识别失败: {}", resultObj); |
|
|
|
|
@ -759,12 +740,10 @@ public class HCodeService { |
|
|
|
|
* @return json |
|
|
|
|
*/ |
|
|
|
|
public JSONArray batchUpdate(List<Patient> lstPatient) { |
|
|
|
|
HealthCardServerImpl healthCard = new HealthCardServerImpl(H_APP_SECRET); |
|
|
|
|
//构造公共输入参数commonIn
|
|
|
|
|
String appToken = getAppToken(); |
|
|
|
|
String requestId = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase(); |
|
|
|
|
int channelNum = 0; |
|
|
|
|
CommonIn commonIn = new CommonIn(appToken, requestId, H_HOSPITAL_ID, channelNum); |
|
|
|
|
CommonIn commonIn = createCommonIn(appToken); |
|
|
|
|
|
|
|
|
|
List<HealthCardInfo> lstHealthCard = new ArrayList<>(); |
|
|
|
|
for (Patient patient : lstPatient) { |
|
|
|
|
HealthCardInfo healthCardInfo = new HealthCardInfo(); |
|
|
|
|
@ -783,7 +762,7 @@ public class HCodeService { |
|
|
|
|
lstHealthCard.add(healthCardInfo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JSONObject healthCardInfosRsp = healthCard.registerBatchHealthCard(commonIn, lstHealthCard); |
|
|
|
|
JSONObject healthCardInfosRsp = new HealthCardServerImpl(H_APP_SECRET).registerBatchHealthCard(commonIn, lstHealthCard); |
|
|
|
|
JSONObject commonOut = healthCardInfosRsp.getJSONObject("commonOut"); |
|
|
|
|
JSONObject rspObj = healthCardInfosRsp.getJSONObject("rsp"); |
|
|
|
|
if (!"0".equals(commonOut.getString("resultCode")) || rspObj == null) { |
|
|
|
|
|