1、优化:医共体患者信息同步算法优化,防止推送查询患者信息时没有找到数据,加入缓存。

2、调整:德宏州中医院短信预约内容调整,部分模版和签名需补充医院法人信息和管理员信息。
3、新增:新增HIS门诊病历查询接口。
debug
王绍全 23 hours ago
parent 14ac702e7b
commit 6e64a4eade
  1. 17
      src/main/java/com/ynxbd/common/action/AliAction.java
  2. 36
      src/main/java/com/ynxbd/common/action/MedicalRecordAction.java
  3. 51
      src/main/java/com/ynxbd/common/action/PatientAction.java
  4. 2
      src/main/java/com/ynxbd/common/action/test/TestAction.java
  5. 19
      src/main/java/com/ynxbd/common/bean/HisMedicalRecord.java
  6. 116
      src/main/java/com/ynxbd/common/bean/Patient.java
  7. 4
      src/main/java/com/ynxbd/common/bean/sms/SmsTempEnum.java
  8. 201
      src/main/java/com/ynxbd/common/dao/PatientDao.java
  9. 38
      src/main/java/com/ynxbd/common/dao/his/HisMedicalRecordDao.java
  10. 20
      src/main/java/com/ynxbd/common/dao/his/HisPatientDao.java
  11. 12
      src/main/java/com/ynxbd/common/helper/common/URLHelper.java
  12. 3
      src/main/java/com/ynxbd/common/helper/his/HisEnum.java
  13. 135
      src/main/java/com/ynxbd/common/service/GMCService.java
  14. 8
      src/main/java/com/ynxbd/common/service/HCodeService.java
  15. 48
      src/main/java/com/ynxbd/common/service/HealthUploadService.java
  16. 123
      src/main/java/com/ynxbd/common/service/PatientService.java
  17. 1
      src/main/java/com/ynxbd/common/service/RegService.java
  18. 2
      src/main/java/com/ynxbd/common/service/SmsService.java
  19. 2
      src/main/java/com/ynxbd/wx/wxfactory/AesWxHelper.java
  20. 92
      src/main/java/com/ynxbd/wx/wxfactory/WxAuthHelper.java
  21. 5
      src/main/resources/hcode.properties
  22. 2
      src/main/resources/webservice.properties

@ -21,6 +21,7 @@ import org.apache.struts2.convention.annotation.Namespace;
import org.ehcache.Cache;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -66,9 +67,15 @@ public class AliAction extends BaseAction {
user.setOpenid(openid);
}
} else {
List<Patient> patients;
try {
patients = new PatientService().queryPatientList(null, openid, null, true);
} catch (Exception e) {
return Result.error(e);
}
user = new User();
user.setOpenid(openid);
user.setPatientList(new PatientService().queryPatientList(null, openid, null, true));
user.setPatientList(patients);
cache.put(openid, user);
}
@ -82,7 +89,13 @@ public class AliAction extends BaseAction {
}
if (user.getPatientList() == null) {
user.setPatientList(new PatientService().queryPatientList(null, openid, null, true));
List<Patient> patients;
try {
patients = new PatientService().queryPatientList(null, openid, null, true);
} catch (Exception e) {
return Result.error(e);
}
user.setPatientList(patients);
}
AliCacheHelper.setUserAccessToken(scopes, user, accessToken);

@ -0,0 +1,36 @@
package com.ynxbd.common.action;
import com.ynxbd.common.action.base.BaseAction;
import com.ynxbd.common.bean.HisMedicalRecord;
import com.ynxbd.common.config.interceptor.AesDecode;
import com.ynxbd.common.dao.his.HisMedicalRecordDao;
import com.ynxbd.common.result.Result;
import com.ynxbd.common.result.ResultEnum;
import lombok.extern.slf4j.Slf4j;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import java.util.List;
// 病历
@Slf4j
@Action
@Namespace("/medicalRecord")
public class MedicalRecordAction extends BaseAction {
@Action("getMedicalRecord")
public Result getMedicalRecord(@AesDecode String treatNum, @AesDecode String openId) {
try {
log.info("[病历]查询门诊病历 treatNum={}, openId={}", treatNum, openId);
if (treatNum == null || openId == null) {
return Result.error(ResultEnum.PARAM_IS_DEFECT);
}
List<HisMedicalRecord> dataList = new HisMedicalRecordDao().queryMedicalRecordByTreatNum(treatNum);
return Result.success(dataList);
} catch (Exception e) {
return Result.error(e);
}
}
}

@ -28,18 +28,40 @@ import java.util.UUID;
@Namespace("/patient")
public class PatientAction extends BaseAction {
// /**
// * [患者]根据patientId查询信息
// */
// @Action("getHisInfoByPatientId")
// public Result getHisInfoByPatientId(@AesDecode String patientId) {
// try {
// log.info("[HIS患者]根据patientId查询HIS信息 patientId={}", patientId);
// if (patientId == null) {
// return Result.error(ResultEnum.PARAM_IS_BLANK);
// }
//
// Patient patient = new PatientService().queryPatientByPatientId(patientId);
// String encode = Base64Helper.encode(patient, true);
// if (encode == null) {
// return Result.error();
// }
// return Result.success(patient);
// } catch (ServiceException e) {
// return Result.error(e);
// }
// }
/**
* [患者]根据patientId查询信息
* [HIS患者]根据证件号查询信息
*/
@Action("getHisInfoByPatientId")
public Result getHisInfoByPatientId(@AesDecode String patientId) {
@Action("getHisInfoByCardNo")
public Result getHisInfoByCardNo(@AesDecode String openId, @AesDecode String cardNo) {
try {
log.info("[患者]根据patientId查询HIS信息 patientId={}", patientId);
if (patientId == null) {
return Result.error(ResultEnum.PARAM_IS_BLANK);
log.info("[HIS患者]根据证件号查询信息 openId={}, cardNo={}", openId, cardNo);
if (cardNo == null || openId == null) {
return Result.error(ResultEnum.PARAM_IS_DEFECT);
}
Patient patient = new PatientService().queryPatientByPatientId(patientId);
Patient patient = new PatientService().queryPatientByCardNo(cardNo);
String encode = Base64Helper.encode(patient, true);
if (encode == null) {
return Result.error();
@ -319,7 +341,7 @@ public class PatientAction extends BaseAction {
return Result.error(ResultEnum.PATIENT_UN_BIND_ERROR);
}
JsonResult jsonResult = new HisPatientDao().hisUnBind(idCardNo, cardType);
JsonResult jsonResult = new HisPatientDao().unBindHis(idCardNo, cardType);
if (jsonResult.success()) {
return new PatientService().removePatient(openid, patientId, idCardNo);
}
@ -351,10 +373,21 @@ public class PatientAction extends BaseAction {
User user = WxCacheHelper.getCacheUser(openId);
List<Patient> patients;
if (user == null) {
patients = new PatientService().queryPatientList(request, openId, null, true);
try {
patients = new PatientService().queryPatientList(request, openId, null, true);
} catch (Exception e) {
return Result.error(e);
}
} else {
patients = user.getPatientList();
}
return Result.success(patients);
}
@Action("wh_gmc")
public Result wh_gmc(String callNo) {
new PatientService().wh_gmc_patient_ids();
return Result.success();
}
}

@ -106,7 +106,7 @@ public class TestAction extends BaseAction {
@Action("sms_test")
public Result sms_test() throws ServiceException {
if (WeChatConfig.IS_DEV) {
SmsHelper.sendCode(SmsTempEnum.SMS_257021489.TEMP_CODE, "15559603353");
SmsHelper.sendCode(SmsTempEnum.SMS_164268358, "", "123456");
}
return Result.success();
}

@ -0,0 +1,19 @@
package com.ynxbd.common.bean;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
// HIS门诊病历信息
@Setter
@Getter
@ToString
@NoArgsConstructor
public class HisMedicalRecord implements Serializable {
private String htmlContent;
private String textContent;
}

@ -22,16 +22,30 @@ import java.io.Serializable;
@NoArgsConstructor
public class Patient implements Serializable {
private static final long serialVersionUID = 9966666612123151L;
private Long id;
private Integer id;
private String unionId;
private String enUnionId;
// 唯一id
private String openid;
private String enOpenId;
// 患者id
private String patientId;
private String enPatientId;
private String name;
private String sex;
private String age;
// 证件号码
private String idCardNo;
private String enCardNo;
private String showCardNo;
private String birthday;
// 电话
private String tel;
private String enTel;
private String showTel;
private String address;
private String bindDate;
private String hisTransNo;
@ -59,39 +73,32 @@ public class Patient implements Serializable {
private String updateTime;
// 自己
private Boolean isMyself;
// 是否默认
private Boolean isDefault;
// 删除状态
private Integer deletedState;
// 加密后的患者id
private String enPatientId;
// 加密后的证件号码
private String enCardNo;
// 加密后的电话
private String enTel;
// 显示的身份证号码
private String showCardNo;
// 显示的电话号码
private String showTel;
// 地区编码
private String areaCode;
// 地区
private String areaAddress;
// 表内唯一ID
private String uniqueId;
// 医共体子公众号的AppId
private String hospAppId;
private String enHospAppId;
// 医共体主体认证id
private String gmcOpenId;
// 医共体主体患者UUID
private String enGmcOpenId;
// 记录非医共体绑定的HIS患者id
private String hisPatientId;
// 医共体患者唯一id
private String gmcUniqueId;
// 子公众号的AppId
private String hospAppId;
//
// 是否为医共体绑定[1:是]
private Integer gmcBindState;
// 认证加密openid
private String enUnionId;
private String enOpenId;
private String enGmcOpenId;
private String enHospAppId;
// BindingFlag:值为1时,说明患者尚未绑定或建档
// HIS[BindingFlag:值为1时,说明患者尚未绑定或建档]
private String bindingFlag;
private HCardTypeEnum cardTypeEnum;
@ -142,4 +149,71 @@ public class Patient implements Serializable {
this.idCardNo = null;
}
}
private boolean equalsData(String data1, String data2) {
if (data1 == null && data2 == null) {
return true;
}
return data1 != null && data1.equals(data2);
}
private boolean equalsData(Boolean data1, Boolean data2) {
if (data1 == null && data2 == null) {
return true;
}
return data1 != null && data1.equals(data2);
}
public boolean equalsPatient(Patient copy) {
if (copy == null) {
return false;
}
if (!equalsData(this.cardType, copy.getCardType())) {
return false;
}
if (!equalsData(this.idCardNo, copy.getIdCardNo())) {
return false;
}
if (!equalsData(this.name, copy.getName())) {
return false;
}
if (!equalsData(this.birthday, copy.getBirthday())) {
return false;
}
if (!equalsData(this.sex, copy.getSex())) {
return false;
}
if (!equalsData(this.nation, copy.getNation())) {
return false;
}
if (!equalsData(this.tel, copy.getTel())) {
return false;
}
if (!equalsData(this.areaCode, copy.getAreaCode())) {
return false;
}
if (!equalsData(this.address, copy.getAddress())) {
return false;
}
if (!equalsData(this.isMyself, copy.getIsMyself())) {
return false;
}
if (!equalsData(this.isDefault, copy.getIsDefault())) {
return false;
}
return true;
}
}

@ -7,7 +7,9 @@ public enum SmsTempEnum {
SMS_257021489("SMS_257021489", "短信验证码通用"), // 您的验证码${code},您正进行身份验证,该验证码5分钟内有效,请勿泄漏于他人!
SMS_475980406("SMS_475980406", "德宏州中医医院(预约通知)第四版-去掉门诊版"), // 您已预约${time}的${deptName}的:${doctorName}医生,就诊序号为${seq}号,就诊地址:${address},请您根据就诊时间${hosp_tip}。注意:同一天内,只能预约一次,多次预约会自动退款。如有疑问请致电${hosp_tel}咨询。祝您健康!
// SMS_475980406("SMS_475980406", "德宏州中医医院(预约通知)第四版-去掉门诊版"),
SMS_501641217("SMS_501641217", "德宏州中医医院(预约通知)第5版-签到"), // 您已预约${time}的${deptName}的:${doctorName}医生,就诊地址:${address},请您根据就诊时间提前15分钟在医院公众号个人信息在线签到或到医院门诊各导医服务台签到后排队候诊。注意:同一天内,只能预约一次,多次预约会自动退款。如有疑问请致电0692-2991794咨询。祝您健康
SMS_173475681("SMS_173475681", "德宏州中医医院(东软自助机)"), // 您的校验码:${code},您正在使用自助机注册,感谢您的支持!

@ -5,18 +5,23 @@ import com.ynxbd.common.bean.PatientLink;
import com.ynxbd.common.bean.enums.HCardTypeEnum;
import com.ynxbd.common.config.db.DataBase;
import com.ynxbd.common.helper.common.CodeHelper;
import com.ynxbd.wx.config.WeChatConfig;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
import java.util.List;
/**
* 患者表操作
*
* @Author wsq
* @Date 2020/9/25 11:08
* @Copyright @ 2020 云南新八达科技有限公司 All rights reserved.
*/
@Slf4j
public class PatientDao {
/**
@ -42,7 +47,7 @@ public class PatientDao {
if (ObjectUtils.isEmpty(unionId)) {
return selectListByOpenid(openid);
}
String sql = "select * from patientBase where openid = ? and deletedState = 0 order by isDefault desc";
String sql = "select * from patientBase where openid= ? and deletedState = 0 order by isDefault desc";
return DataBase.select(sql, Patient.class, ps -> {
ps.setString(1, openid);
});
@ -183,10 +188,14 @@ public class PatientDao {
* @return 是否成功
*/
public boolean updateInfo(Patient bindInfo) {
String sql = "update patientBase set deletedState=0, healthCardId=?, name=?, nation=?, tel=?, address=?, uuid=?, areaCode=?, areaAddress=?, patientId=?, " +
String sql = "update patientBase set deletedState=0, healthCardId=?, name=?, nation=?, tel=?, address=?, uuid=?, areaCode=?, areaAddress=?, patientId=?, hisPatientId=?, gmcBindState=?, " +
" uniqueId=if(uniqueId is null or uniqueId = '', ?, uniqueId), " +
" gmcUniqueId=if(gmcUniqueId is null or gmcUniqueId = '', ?, gmcUniqueId) " +
" where openid=? and idCardNo=?";
bindInfo.setGmcBindState(WeChatConfig.IS_ENABLE_GMC ? 1 : null);
bindInfo.setHisPatientId(WeChatConfig.IS_ENABLE_GMC ? null : bindInfo.getPatientId());
return DataBase.update(sql, ps -> {
ps.setString(1, bindInfo.getHealthCardId());
ps.setString(2, bindInfo.getName());
@ -197,11 +206,13 @@ public class PatientDao {
ps.setString(7, bindInfo.getAreaCode());
ps.setString(8, bindInfo.getAreaAddress());
ps.setString(9, bindInfo.getPatientId());
ps.setString(10, CodeHelper.get32UUID());
ps.setString(11, bindInfo.getGmcUniqueId());
ps.setString(10, bindInfo.getHisPatientId());
ps.setInt(11, bindInfo.getGmcBindState());
ps.setString(12, CodeHelper.get32UUID());
ps.setString(13, bindInfo.getGmcUniqueId());
// 条件
ps.setString(12, bindInfo.getOpenid());
ps.setString(13, bindInfo.getIdCardNo());
ps.setString(14, bindInfo.getOpenid());
ps.setString(15, bindInfo.getIdCardNo());
}) > 0;
}
@ -223,45 +234,93 @@ public class PatientDao {
* @return bool
*/
public boolean insert(boolean isMyself, Patient bindData) {
String sql = "insert into patientBase(bindDate, openid, patientId, hisTransNo, name, sex, idCardNo, tel, birthday, nation, healthCardId, age, uuid, fatherName, fatherTel, fatherIDCardNo, motherName, motherTel, motherIDCardNo, address, areaCode, areaAddress, isMyself, cardType, unionId, hospAppId, gmcUniqueId, uniqueId) " +
" values(now(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
HCardTypeEnum cardTypeEnum = bindData.getCardTypeEnum();
bindData.setIsMyself(isMyself);
String sql = "insert into patientBase(bindDate, openid, patientId, hisTransNo, name, sex, idCardNo, tel, birthday, nation, healthCardId, age, uuid, fatherName, fatherTel, fatherIDCardNo, motherName, motherTel, motherIDCardNo, address, areaCode, areaAddress, isMyself, cardType, unionId, uniqueId, hisPatientId, gmcUniqueId, gmcBindState) " +
" values(now(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
return DataBase.insert(sql, ps -> {
ps.setString(1, bindData.getOpenid());
ps.setString(2, bindData.getPatientId());
ps.setString(3, bindData.getHisTransNo());
ps.setString(4, bindData.getName());
ps.setString(5, bindData.getSex());
ps.setString(6, bindData.getIdCardNo());
ps.setString(7, bindData.getTel());
ps.setString(8, bindData.getBirthday());
ps.setString(9, bindData.getNation());
ps.setString(10, bindData.getHealthCardId());
ps.setString(11, bindData.getAge());
ps.setString(12, bindData.getUuid());
//
ps.setString(13, bindData.getFatherName());
ps.setString(14, bindData.getFatherTel());
ps.setString(15, bindData.getFatherIdCardNo());
ps.setString(16, bindData.getMotherName());
ps.setString(17, bindData.getMotherTel());
ps.setString(18, bindData.getMotherIdCardNo());
ps.setString(19, bindData.getAddress());
ps.setString(20, bindData.getAreaCode());
ps.setString(21, bindData.getAreaAddress());
ps.setBoolean(22, isMyself);
ps.setString(23, cardTypeEnum == null ? HCardTypeEnum._01.WX_CODE : cardTypeEnum.WX_CODE);
ps.setString(24, bindData.getUnionId());
ps.setString(25, bindData.getHospAppId());
ps.setString(26, bindData.getGmcUniqueId());
ps.setString(27, CodeHelper.get32UUID());
setInsertPs(ps, bindData);
}) > 0;
}
/**
* [患者]绑定身份证
*
* @param dataList 绑定数据
* @return bool
*/
public int insertBatch(List<Patient> dataList) {
String sql = "insert into patientBase(bindDate, openid, patientId, hisTransNo, name, sex, idCardNo, tel, birthday, nation, healthCardId, age, uuid, fatherName, fatherTel, fatherIDCardNo, motherName, motherTel, motherIDCardNo, address, areaCode, areaAddress, isMyself, cardType, unionId, uniqueId, hisPatientId, gmcUniqueId, gmcBindState %s) " +
" values(now(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? %s)";
List<Patient> hasIdList = new ArrayList<>();
List<Patient> noneIdList = new ArrayList<>();
for (Patient item : dataList) {
if (item.getId() == null) {
noneIdList.add(item);
} else {
hasIdList.add(item);
}
}
int noneIdRows = noneIdList.isEmpty() ? 0 : DataBase.insertBatch(String.format(sql, "", ""), ps -> {
for (Patient item : noneIdList) {
setInsertPs(ps, item);
ps.addBatch();
}
});
int hasIdRows = hasIdList.isEmpty() ? 0 : DataBase.insertBatch(String.format(sql, ",id", ",?"), ps -> {
for (Patient item : hasIdList) {
setInsertPs(ps, item);
ps.setInt(29, item.getId()); // 此处需注意修改
ps.addBatch();
}
});
return noneIdRows + hasIdRows;
}
// 设置插入的占位符
private void setInsertPs(PreparedStatement ps, Patient item) throws SQLException {
item.setGmcBindState(WeChatConfig.IS_ENABLE_GMC ? 1 : item.getGmcBindState());
item.setHisPatientId(WeChatConfig.IS_ENABLE_GMC ? null : item.getPatientId());
HCardTypeEnum cardTypeEnum = item.getCardTypeEnum();
ps.setString(1, item.getOpenid());
ps.setString(2, item.getPatientId());
ps.setString(3, item.getHisTransNo());
ps.setString(4, item.getName());
ps.setString(5, item.getSex());
ps.setString(6, item.getIdCardNo());
ps.setString(7, item.getTel());
ps.setString(8, item.getBirthday());
ps.setString(9, item.getNation());
ps.setString(10, item.getHealthCardId());
ps.setString(11, item.getAge());
ps.setString(12, item.getUuid());
//
ps.setString(13, item.getFatherName());
ps.setString(14, item.getFatherTel());
ps.setString(15, item.getFatherIdCardNo());
ps.setString(16, item.getMotherName());
ps.setString(17, item.getMotherTel());
ps.setString(18, item.getMotherIdCardNo());
ps.setString(19, item.getAddress());
ps.setString(20, item.getAreaCode());
ps.setString(21, item.getAreaAddress());
ps.setBoolean(22, item.getIsMyself());
ps.setString(23, cardTypeEnum == null ? HCardTypeEnum._01.WX_CODE : cardTypeEnum.WX_CODE);
ps.setString(24, item.getUnionId());
ps.setString(25, CodeHelper.get32UUID());
// 医共体
ps.setString(26, item.getHisPatientId());
ps.setString(27, item.getGmcUniqueId());
ps.setObject(28, item.getGmcBindState(), Types.INTEGER);
}
/**
* 查询所有未领取健康卡的用户信息民族电话不能为空,一次读取15条信息
*/
@ -290,7 +349,7 @@ public class PatientDao {
* 批量领卡调用标记领取成功与否都更新为1
*
* @param idCardNo 身份证
* @return
* @return bool
*/
public boolean updateCallFlag(String idCardNo) {
String sql = "update patientBase set callFlag = 1 where idCardNo = ?";
@ -330,7 +389,6 @@ public class PatientDao {
return new ArrayList<>();
}
return dataList;
}
public boolean updateMyself(Patient bindInfo) {
@ -359,4 +417,63 @@ public class PatientDao {
ps.setString(7, bindInfo.getOpenid());
}) > 0;
}
public int delByIds(String openId, List<Integer> idList) {
if (idList.isEmpty()) {
return 0;
}
StringBuilder sb = new StringBuilder();
for (Integer id : idList) {
if (ObjectUtils.isEmpty(id)) {
continue;
}
sb.append(id).append(",");
}
String idStr = sb.toString();
if (ObjectUtils.isEmpty(idStr)) {
return 0;
}
String ids = idStr.substring(0, idStr.length() - 1);
String sql = "delete from patientBase where openid=? and id in(?)";
return DataBase.delete(sql, ps -> {
ps.setString(1, openId);
ps.setString(2, ids);
});
}
/**
* 查询不是医共体的患者
*
* @return list
*/
public List<Patient> selectNoneGmcList() {
if (!WeChatConfig.IS_ENABLE_GMC) {
log.warn("[医共体]功能未开启-禁止查询不是医共体的用户信息");
return new ArrayList<>();
}
String sql = "select * from patientBase where (gmcBindState is null or gmcBindState != 1)";
return DataBase.select(sql, Patient.class, null);
}
public boolean updateGmcInfo(Integer id, String cardNo, String cardType, String gmcPatientId, String hisPatientId) {
if (ObjectUtils.isEmpty(cardNo) && HCardTypeEnum.NO_CARD.WX_CODE.equals(cardType)) { // 无证绑定->标记为已删除
String sql = "update patientBase set deletedState= 1 where id=? and cardType=?";
return DataBase.update(sql, ps -> {
ps.setLong(1, id);
ps.setString(2, HCardTypeEnum.NO_CARD.WX_CODE);
}) > 0;
}
if (ObjectUtils.isEmpty(gmcPatientId)) {
return false;
}
String sql = "update patientBase set gmcBindState= 1, patientId=?, hisPatientId=? where id=? and idCardNo= ?";
return DataBase.update(sql, ps -> {
ps.setString(1, gmcPatientId);
ps.setString(2, hisPatientId);
// 条件
ps.setLong(3, id);
ps.setString(4, cardNo);
}) > 0;
}
}

@ -0,0 +1,38 @@
package com.ynxbd.common.dao.his;
import com.ynxbd.common.bean.HisMedicalRecord;
import com.ynxbd.common.helper.his.HisEnum;
import com.ynxbd.common.helper.his.HisHelper;
import com.ynxbd.common.result.JsonResult;
import com.ynxbd.common.result.ResultEnum;
import com.ynxbd.common.result.ServiceException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
public class HisMedicalRecordDao {
/**
* 查询门诊病历在公司的192.168.12.10:8888可以测试测试门诊号2343640|2343574 |2343602
*
*/
public List<HisMedicalRecord> queryMedicalRecordByTreatNum(String treatNum) throws ServiceException {
if (ObjectUtils.isEmpty(treatNum)) {
throw new ServiceException(ResultEnum.PARAM_IS_DEFECT);
}
Map<String, Object> params = new HashMap<>();
params.put("MZNum", treatNum);
JsonResult jsonResult = HisHelper.getJsonResult(HisEnum.Query_TreatMedicalRecord, params);
if (!jsonResult.success()) {
throw new ServiceException(jsonResult.getMessage());
}
return jsonResult.getDataMapList(HisMedicalRecord.class, "Items", "Item");
}
}

@ -8,6 +8,7 @@ import com.ynxbd.common.helper.his.HisHelper;
import com.ynxbd.common.result.JsonResult;
import com.ynxbd.common.result.ResultEnum;
import com.ynxbd.common.result.ServiceException;
import com.ynxbd.wx.config.WeChatConfig;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
@ -96,7 +97,7 @@ public class HisPatientDao {
*
* @return 患者
*/
public JsonResult hisUnBind(String idCardNo, String cardType) throws ServiceException {
public JsonResult unBindHis(String idCardNo, String cardType) throws ServiceException {
if (ObjectUtils.isEmpty(idCardNo)) {
throw new ServiceException(ResultEnum.PARAM_IS_DEFECT);
}
@ -125,17 +126,31 @@ public class HisPatientDao {
return queryPatientInfo(patientId, "999");
}
/**
* [患者]根据证件号查询信息
*
* @param cardNo 证件号
*/
public JsonResult queryPatientByCardNo(String cardNo) throws ServiceException {
if (StringUtils.isEmpty(cardNo)) {
throw new ServiceException(ResultEnum.PARAM_IS_DEFECT);
}
return queryPatientInfo(cardNo, "0");
}
/**
* 查询患者信息
*
* @param cardNo 卡号
* @param cardType 类型 {0身份证 1健康卡999患者ID(PatientId) 此步骤对于已经获得PatientId 需要查询患者信息的情景}
* @return hisResult
*/
public JsonResult queryPatientInfo(String cardNo, String cardType) throws ServiceException {
if (StringUtils.isEmpty(cardNo) || cardType == null) {
throw new ServiceException(ResultEnum.PARAM_IS_DEFECT);
}
if (WeChatConfig.IS_ENABLE_GMC && "999".equals(cardType)) {
throw new ServiceException("医共体不能使用患者id查询用户信息");
}
Map<String, Object> params = new HashMap<>();
params.put("CardNo", cardNo);
@ -166,7 +181,6 @@ public class HisPatientDao {
params.put("Name", name);
params.put("IDCardNo", cardNo);
// 不传入,则his中的患者信息不会被修改
params.put("Address_Code", county); // 行政区编码
params.put("Address", address); // 地址

@ -3,6 +3,7 @@ package com.ynxbd.common.helper.common;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
@ -74,7 +75,16 @@ public class URLHelper {
public static String encodeURL(String param) {
try {
URLEncoder.encode(param, "utf-8");
return URLEncoder.encode(param, "UTF-8");
} catch (Exception e) {
log.error(e.getMessage());
}
return null;
}
public static String decodeURL(String param) {
try {
return URLDecoder.decode(param, "UTF-8");
} catch (Exception e) {
log.error(e.getMessage());
}

@ -83,6 +83,7 @@ public enum HisEnum {
Query_InHospRecords("[住院]通过患者ID查询住院记录(出院后)", "1011", "UniversalInterface", true),
Query_OutHospTreatFee("[住院]通过住院号查询费用明细(出院后)", "1012", "UniversalInterface", true),
Query_InHospPrepay("[住院]预交金缴费", "4003", "UniversalInterface", true),
Query_InHospByTreatNum("[住院]通过住院号查询患者信息(含预交金)", "1005", "UniversalInterface", true),
Query_InHospByPatientId("[住院]通过患者ID查询在院患者信息(目前只能查询住院中)", "1006", "UniversalInterface", true),
@ -99,6 +100,8 @@ public enum HisEnum {
XK_QUERY_RE_REGISTER("[互联网医院]查询复诊挂号费","13008","UniversalInterface",true),
Query_TreatMedicalRecord("[病历]查询门诊病历", "1014", "UniversalInterface", false),
// 在线签到
AP_Query_SignIn("[在线签到]查询预约待签到记录","7007","AP_Query_SignIn",true),
AP_SignIN("[在线签到]执行预约签到","7008","AP_SignIn",true),

@ -1,7 +1,8 @@
package com.ynxbd.common.service;
import com.ynxbd.common.bean.Patient;
import com.ynxbd.common.helper.common.CodeHelper;
import com.ynxbd.common.bean.enums.HCardTypeEnum;
import com.ynxbd.common.dao.PatientDao;
import com.ynxbd.common.helper.common.JsonHelper;
import com.ynxbd.common.helper.http.OkHttpHelper;
import com.ynxbd.common.result.JsonResult;
@ -16,34 +17,83 @@ import org.apache.commons.lang3.ObjectUtils;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Slf4j
public class GMCService {
public List<Patient> queryGmcPatientList(HttpServletRequest request, String openId, String unionId) {
try {
if (WeChatConfig.IS_ENABLE_GMC && !WeChatConfig.IS_GMC_SERVER) { // 开启医共体服务 & 不为医共体主体
return new ArrayList<>();
}
if (ObjectUtils.isEmpty(openId)) {
return new ArrayList<>();
/**
* 子服务同步患者数据
*
* @param request request
* @param wxOpenId 子服务的openId
* @param gmcOpenId 主服务的openId
* @return list
*/
public List<Patient> syncPatientData(HttpServletRequest request, String wxOpenId, String gmcOpenId, String unionId) throws ServiceException {
log.error("[医共体-数据同步]wxOpenId={}, gmcOpenId={}", wxOpenId, gmcOpenId);
if (ObjectUtils.isEmpty(wxOpenId) || ObjectUtils.isEmpty(gmcOpenId)) {
return new ArrayList<>();
}
if (!WeChatConfig.IS_ENABLE_GMC || WeChatConfig.IS_GMC_SERVER) { // 医共体开关未开启 || 是主服务器
return new ArrayList<>();
}
long begTime = System.currentTimeMillis();
JsonResult jsonResult = postFormGMC(request, "/patient/queryPatientList", params -> {
params.put("openId", AesWxHelper.encode(gmcOpenId));
params.put("hospAppId", AesWxHelper.encode(WeChatConfig.GMC_APP_ID));
}, null);
if (!jsonResult.success()) {
String message = jsonResult.getMessage();
log.error("[医共体-数据同步]请求主服务失败 wxOpenId={}, gmcOpenId={}, message={}", wxOpenId, gmcOpenId, message);
throw new ServiceException("[医共体-数据同步]请求主服务失败:" + (ObjectUtils.isEmpty(message) ? "" : message));
}
List<Patient> gmcPatients = jsonResult.getDataMapList(Patient.class, "data");
List<Integer> removeIds = new ArrayList<>(); // 需删除用户ids
List<Patient> addList = new ArrayList<>(); // 需添加用户
List<Patient> dbPatients = new PatientDao().selectListByToken(wxOpenId, unionId);
for (Patient item : gmcPatients) {
item.setId(null);
item.setOpenid(wxOpenId);
Patient findDBItem = dbPatients.isEmpty() ? null : dbPatients.stream().filter(o -> (!ObjectUtils.isEmpty(o.getPatientId()) && o.getPatientId().equals(item.getPatientId()))).findFirst().orElse(null);
if (findDBItem == null) { // 需新增
addList.add(item);
} else { // 比对数据
item.setId(findDBItem.getId());
if (HCardTypeEnum.NO_CARD.WX_CODE.equals(item.getCardType())) { // 无证绑定->不做处理
removeIds.add(findDBItem.getId());
} else {
if (!findDBItem.equalsPatient(item)) { // 数据不同->需修改本地数据
removeIds.add(findDBItem.getId());
addList.add(item);
}
}
}
JsonResult jsonResult = postFormGMC(request, "/patient/queryPatientList", params -> {
params.put("openId", openId);
params.put("hospAppId", AesWxHelper.encode(WeChatConfig.GMC_APP_ID));
}, null);
if (!jsonResult.success()) {
return new ArrayList<>();
}
for (Patient item : dbPatients) {
Patient findItem = gmcPatients.stream().filter(o -> (!ObjectUtils.isEmpty(o.getPatientId()) && o.getPatientId().equals(item.getPatientId()))).findFirst().orElse(null);
if (findItem == null) { // 本地数据多余->移除
removeIds.add(item.getId());
}
List<Patient> data = jsonResult.getDataMapList(Patient.class, "data");
System.out.println(JsonHelper.toJsonString(data));
return data;
} catch (Exception e) {
log.error(e.getMessage());
}
return new ArrayList<>();
}
int delRows = 0, addRows = 0;
if (!removeIds.isEmpty()) {
delRows = new PatientDao().delByIds(wxOpenId, removeIds);
}
if (!addList.isEmpty()) {
addRows = new PatientDao().insertBatch(addList);
}
long endTime = System.currentTimeMillis();
String takeTime = (endTime - begTime) + "ms"; // 耗时
log.info("[医共体-数据同步][{}]][耗时:{}]-共[{}]条数据, 删除:[{}]条, 同步:[{}]条", wxOpenId, takeTime, gmcPatients.size(), delRows, addRows);
return gmcPatients;
}
/**
* 医共体绑定
@ -51,25 +101,7 @@ public class GMCService {
* @param request request
* @param bindInfo 绑定信息
*/
public Patient bindGmcServer(HttpServletRequest request, Patient bindInfo) throws ServiceException {
if (!WeChatConfig.IS_ENABLE_GMC) { // 未开启医共体开关
return bindInfo;
}
// String openid = bindInfo.getOpenid();
// String hospAppId = AesWxHelper.decode(bindInfo.getEnHospAppId());
// if (ObjectUtils.isEmpty(hospAppId)) {
// throw new ServiceException("医共体子公众号id参数错误");
// }
String gmcUniqueId;
if (WeChatConfig.IS_GMC_SERVER) { // 是医共体主服务器
// if (!WeChatConfig.APP_ID.equals(hospAppId)) { // 不为自身AppId
// bindInfo.setHospAppId(hospAppId); // 需存的数据
// }
bindInfo.setGmcUniqueId(CodeHelper.get32UUID());
return bindInfo;
}
public Map<String, Object> bindGmcServer(HttpServletRequest request, Patient bindInfo) throws ServiceException {
String enGmcOpenId = bindInfo.getEnGmcOpenId(); // 只有子服务器有主服务器的openId
String gmcOpenId = AesWxHelper.decode(enGmcOpenId);
@ -101,16 +133,7 @@ public class GMCService {
throw new ServiceException(jsonResult.getMessage());
}
log.info("[医供体]绑定转发 resp={}", JsonHelper.toJsonString(jsonResult));
// JSONObject dataJson = jsonResult.dataMapGetNodeToJsonObj();
// gmcUniqueId = dataJson.getString("gmcUniqueId");
// if (ObjectUtils.isEmpty(gmcUniqueId)) {
// throw new ServiceException("医共体返回唯一id为空");
// }
// bindInfo.setGmcUniqueId(gmcUniqueId);
// if (!enGmcOpenId.equals(dataJson.getString("enOpenId"))) {
// throw new ServiceException("医共体主体openId不匹配");
// }
return bindInfo;
return jsonResult.getDataMap();
}
@ -124,11 +147,6 @@ public class GMCService {
}
public List<Patient> updatePatientList(String openId){
return new ArrayList<>();
}
// public Patient queryGmcPatientList(HttpServletRequest request, Patient bindInfo) throws ServiceException {
// if (!WeChatConfig.IS_ENABLE_GMC) { // 不为医共体主体
// return bindInfo;
@ -202,4 +220,11 @@ public class GMCService {
// return bindInfo;
// }
public void queryPatientList(HttpServletRequest request, String openId, String unionId, boolean isEnPid) throws ServiceException {
if (!WeChatConfig.IS_ENABLE_GMC) {
return;
}
}
}

@ -66,7 +66,8 @@ public class HCodeService {
}
}
private static final boolean IS_ENABLE; // 是否启用电子健康看(true:启用, false:禁用)
private static final boolean IS_ENABLE; // 是否启用电子健康卡(true:启用, false:禁用)
public static final boolean IS_UPLOAD_DATA; // 是否允许上传数据(true:启用, false:禁用)
// 健康码
private static final String H_APP_ID;
@ -92,6 +93,7 @@ public class HCodeService {
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);
// 不用对config设置开关,不开启时也需要用到参数
H_APP_ID = config.getString("h.app_id");
H_APP_SECRET = config.getString("h.app_secret");
@ -653,6 +655,10 @@ public class HCodeService {
* @return JSONObject
*/
public static JSONObject reportHISData(String qrCodeText, String deptName, String scene, String cardType, String cardCostType) {
if (!HCodeService.IS_UPLOAD_DATA) { // 禁止数据上传
return null;
}
if (ObjectUtils.isEmpty(qrCodeText) || scene == null || cardType == null) {
log.info("[电子健康卡]用卡数据监测接口,参数为空");
return null;

@ -22,6 +22,10 @@ public class HealthUploadService {
*/
public void regPayReportHISData(String openid, String patientId, String deptName, String regDate) {
try {
if (!HCodeService.IS_UPLOAD_DATA) { // 禁止数据上传
return;
}
if (!HCodeService.isEnableHCode()) { // 判断是否禁用电子健康卡
return;
}
@ -68,6 +72,9 @@ public class HealthUploadService {
*/
public void rxReportHISData(String openid, String patientId) {
try {
if (!HCodeService.IS_UPLOAD_DATA) { // 禁止数据上传
return;
}
if (!HCodeService.isEnableHCode()) { // 判断是否禁用电子健康卡
return;
}
@ -130,26 +137,27 @@ public class HealthUploadService {
public static void dataUpload() {
String qrCodeText = HCodeService.getQRCodeText(false, "F43F5B90877116A61D3B960EDAECBCDDDDE7F452605C23DD425CC79BF4644F61", "530127199711211059");
HCodeService.reportHISData(qrCodeText, "口腔科", "0101011", HealthCardEnum.CARD_TYPE_HEALTH_CARD.STATUS, null);
HCodeService.reportHISData(qrCodeText, "口腔科", "0101012", HealthCardEnum.CARD_TYPE_HEALTH_CARD.STATUS, null);
HCodeService.reportHISData(qrCodeText, null, "0101013", HealthCardEnum.CARD_TYPE_HEALTH_CARD.STATUS, null);
HCodeService.reportHISData(qrCodeText, null, "0101014", HealthCardEnum.CARD_TYPE_HEALTH_CARD.STATUS, null);
// 门诊缴费
HCodeService.reportHISData(qrCodeText, "口腔科", "0101051", HealthCardEnum.CARD_TYPE_HEALTH_CARD.STATUS, "0100");
// 门诊缴费记录
HCodeService.reportHISData(qrCodeText, null, "0101052", HealthCardEnum.CARD_TYPE_HEALTH_CARD.STATUS, null);
HCodeService.reportHISData(qrCodeText, null, "0101081", HealthCardEnum.CARD_TYPE_HEALTH_CARD.STATUS, null);
HCodeService.reportHISData(qrCodeText, null, "0101082", HealthCardEnum.CARD_TYPE_HEALTH_CARD.STATUS, null);
HCodeService.reportHISData(qrCodeText, null, "0101083", HealthCardEnum.CARD_TYPE_HEALTH_CARD.STATUS, null);
// String qrCodeText = HCodeService.getQRCodeText(false, "F43F5B90877116A61D3B960EDAECBCDDDDE7F452605C23DD425CC79BF4644F61", "530127199711211059");
//
// HCodeService.reportHISData(qrCodeText, "口腔科", "0101011", HealthCardEnum.CARD_TYPE_HEALTH_CARD.STATUS, null);
//
// HCodeService.reportHISData(qrCodeText, "口腔科", "0101012", HealthCardEnum.CARD_TYPE_HEALTH_CARD.STATUS, null);
//
// HCodeService.reportHISData(qrCodeText, null, "0101013", HealthCardEnum.CARD_TYPE_HEALTH_CARD.STATUS, null);
//
// HCodeService.reportHISData(qrCodeText, null, "0101014", HealthCardEnum.CARD_TYPE_HEALTH_CARD.STATUS, null);
// // 门诊缴费
// HCodeService.reportHISData(qrCodeText, "口腔科", "0101051", HealthCardEnum.CARD_TYPE_HEALTH_CARD.STATUS, "0100");
//
// // 门诊缴费记录
// HCodeService.reportHISData(qrCodeText, null, "0101052", HealthCardEnum.CARD_TYPE_HEALTH_CARD.STATUS, null);
//
// HCodeService.reportHISData(qrCodeText, null, "0101081", HealthCardEnum.CARD_TYPE_HEALTH_CARD.STATUS, null);
//
// HCodeService.reportHISData(qrCodeText, null, "0101082", HealthCardEnum.CARD_TYPE_HEALTH_CARD.STATUS, null);
//
// HCodeService.reportHISData(qrCodeText, null, "0101083", HealthCardEnum.CARD_TYPE_HEALTH_CARD.STATUS, null);
//
}
public static void main(String[] args) {

@ -1,7 +1,9 @@
package com.ynxbd.common.service;
import com.ynxbd.common.bean.GMCUser;
import com.ynxbd.common.bean.Patient;
import com.ynxbd.common.bean.User;
import com.ynxbd.common.bean.enums.HCardTypeEnum;
import com.ynxbd.common.dao.PatientDao;
import com.ynxbd.common.dao.his.HisPatientDao;
import com.ynxbd.common.helper.common.*;
@ -70,11 +72,17 @@ public class PatientService {
// return queryPatientList(openid, unionId, true);
// }
public List<Patient> queryPatientList(HttpServletRequest request, String openid, String unionId, boolean isEnPid) {
public List<Patient> queryPatientList(HttpServletRequest request, String openId, String unionId, boolean isEnPid) throws ServiceException {
if (request != null && WeChatConfig.IS_ENABLE_GMC && !WeChatConfig.IS_GMC_SERVER) { // 不是主体服务器=>请求主服务器
return new GMCService().queryGmcPatientList(request, openid, unionId);
GMCUserService gmcUserService = new GMCUserService();
GMCUser gmcUser = gmcUserService.queryInfoByOpenId(openId);
if (gmcUser == null) {
log.warn("[医供体]未找到关联关系 openId={}", openId);
return new ArrayList<>();
}
return new GMCService().syncPatientData(request, openId, gmcUser.getGmcOpenId(), gmcUser.getGmcUnionId());
}
List<Patient> patients = new PatientDao().selectListByToken(openid, unionId);
List<Patient> patients = new PatientDao().selectListByToken(openId, unionId);
if (isEnPid) {
patients = enPatientList(patients);
}
@ -100,16 +108,30 @@ public class PatientService {
if (bindInfo == null) {
return Result.error(ResultEnum.PARAM_IS_DEFECT);
}
String openid = bindInfo.getOpenid();
try {
bindInfo = new GMCService().bindGmcServer(request, bindInfo);
} catch (Exception e) {
ErrorHelper.println(e);
return Result.error(e);
if (WeChatConfig.IS_ENABLE_GMC && !WeChatConfig.IS_GMC_SERVER) { // 开启医共体 && 不是医共体主体
try {
Map<String, Object> dataMap = new GMCService().bindGmcServer(request, bindInfo);
if (dataMap == null) {
return Result.error("[医共体]绑定返回空map");
}
WxCacheHelper.removeUser(openid);
Map<String, Object> map = new HashMap<>();
map.put("gmcUniqueId", dataMap.get("gmcUniqueId"));
map.put("enOpenId", AesWxHelper.encode(openid));
return Result.success(map);
} catch (Exception e) {
ErrorHelper.println(e);
return Result.error(e);
}
}
if (WeChatConfig.IS_ENABLE_GMC) { // 是医共体主服务器
bindInfo.setGmcUniqueId(CodeHelper.get32UUID());
}
log.info("[患者]身份绑定: {}", JsonHelper.toJsonString(bindInfo));
String openid = bindInfo.getOpenid();
String name = bindInfo.getName();
String idCardNo = bindInfo.getIdCardNo();
String healthCardId = bindInfo.getHealthCardId();
@ -329,17 +351,39 @@ public class PatientService {
}
// /**
// * [患者]根据患者id查询信息
// *
// * @param patientId 患者id
// * @return patient
// */
// public Patient queryPatientByPatientId(String patientId) throws ServiceException {
// if (ObjectUtils.isEmpty(patientId)) {
// throw new ServiceException(ResultEnum.PARAM_IS_DEFECT);
// }
// JsonResult jsonResult = new HisPatientDao().queryPatientByPatientId(patientId);
// if (!jsonResult.success()) {
// throw new ServiceException(jsonResult.getMessage());
// }
// Patient patient = jsonResult.dataMapToBean(Patient.class);
// if (patient == null) {
// throw new ServiceException(ResultEnum.DATA_NOT_FOUND);
// }
// return patient;
// }
/**
* [患者]根据患者id查询信息
* [患者]根据cardNo查询信息
*
* @param patientId 患者id
* @param cardNo cardNo
* @return patient
*/
public Patient queryPatientByPatientId(String patientId) throws ServiceException {
if (ObjectUtils.isEmpty(patientId)) {
public Patient queryPatientByCardNo(String cardNo) throws ServiceException {
if (ObjectUtils.isEmpty(cardNo)) {
throw new ServiceException(ResultEnum.PARAM_IS_DEFECT);
}
JsonResult jsonResult = new HisPatientDao().queryPatientByPatientId(patientId);
JsonResult jsonResult = new HisPatientDao().queryPatientByCardNo(cardNo);
if (!jsonResult.success()) {
throw new ServiceException(jsonResult.getMessage());
}
@ -350,15 +394,16 @@ public class PatientService {
return patient;
}
/**
* [患者]HIS中是否已绑定
*
* @param patientId 患者id
* @return patient
* @param cardNo 证件号码
* @return bool
*/
public boolean hasHisBind(String patientId) {
public boolean hasHisBindByCardNo(String cardNo) {
try {
Patient patient = queryPatientByPatientId(patientId);
Patient patient = queryPatientByCardNo(cardNo);
if (patient == null) {
return false;
}
@ -367,4 +412,46 @@ public class PatientService {
}
return false;
}
/**
* [维护]替换患者id为医共体id
*
*/
public void wh_gmc_patient_ids() {
List<Patient> patients = new PatientDao().selectNoneGmcList();
log.warn("[医共体]患者id替换开始......共:[{}]条", patients.size());
PatientDao patientDao = new PatientDao();
int errNum = 0;
for (Patient patient : patients) {
String gmcPatientId = null; // 医共体患者id
Integer id = patient.getId();
String hisPatientId = patient.getPatientId(); // 旧id
Patient hisPatient;
if (!HCardTypeEnum.NO_CARD.WX_CODE.equals(patient.getCardType())) { // 不为无证绑定
try {
hisPatient = new HisPatientDao().bind(false, patient);
if (hisPatient == null || ObjectUtils.isEmpty(hisPatient.getPatientId())) {
log.warn("[医共体]患者id替换-调用HIS绑定接口异常,未返回患者信息 id={}, hisPatientId={}", id, hisPatientId);
continue;
}
gmcPatientId = hisPatient.getPatientId();
} catch (Exception e) {
log.warn(e.getMessage());
continue;
}
}
boolean isUpdate = patientDao.updateGmcInfo(patient.getId(), patient.getIdCardNo(), patient.getCardType(), gmcPatientId, hisPatientId);
if (!isUpdate) {
errNum = errNum + 1;
log.warn("[医共体]患者id替换更新数据失败 id={}, hisPatientId={}", id, hisPatientId);
}
log.warn("[医共体]患者id替换 共:[{}]条, 失败:[{}]条", patients.size(), errNum);
}
}
}

@ -226,7 +226,6 @@ public class RegService {
// 挂号导航推送
MessagePushConfig.regNavigatePush(merchantEnum, reg);
// 电子健康卡上报数据
new HealthUploadService().regPayReportHISData(openid, patientId, reg.getDeptName(), reg.getRegDate());
}

@ -35,7 +35,7 @@ public class SmsService {
sms.setSeq(reg.getQueueNum());
sms.setHosp_tip("提前15分钟到医院门诊各导医服务台签到后排队候诊");
log.info("[挂号]发送预约短信通知 sms={}, appId={}, tel-{}", JsonHelper.toJsonString(sms), WeChatConfig.APP_ID, tel);
isResult = SmsHelper.send(SmsTempEnum.SMS_475980406, tel, sms);
isResult = SmsHelper.send(SmsTempEnum.SMS_501641217, tel, sms);
}
return isResult;
}

@ -36,7 +36,7 @@ public class AesWxHelper extends AesHelper {
}
public static void main(String[] args) {
System.out.println(encode("001"));
// System.out.println(decode("E6835E243069406F53EC8464898B37C0"));
}
}

@ -6,6 +6,7 @@ import com.ynxbd.common.bean.User;
import com.ynxbd.common.helper.common.*;
import com.ynxbd.common.helper.http.OkHttpHelper;
import com.ynxbd.common.result.Result;
import com.ynxbd.common.result.ServiceException;
import com.ynxbd.common.service.GMCUserService;
import com.ynxbd.common.service.PatientService;
import com.ynxbd.wx.config.WeChatConfig;
@ -128,26 +129,26 @@ public class WxAuthHelper {
}
public static Result isAuth(HttpServletRequest request, HttpServletResponse response) throws Exception {
String token = request.getParameter("token"); // 前端缓存
String state = request.getParameter("state");
String isUserInfo = request.getParameter("isUserInfo");
String deState = URLDecoder.decode(Base64Helper.decode(state), "UTF-8");
public static Result isAuth(HttpServletRequest request, HttpServletResponse response) {
try {
String token = request.getParameter("token"); // 前端缓存
String state = request.getParameter("state");
String isUserInfo = request.getParameter("isUserInfo");
String deState = URLHelper.decodeURL(Base64Helper.decode(state));
HttpSession session = request.getSession();
session.setMaxInactiveInterval(SESSION_MAX_INACTIVE_INTERVAL);
HttpSession session = request.getSession();
session.setMaxInactiveInterval(SESSION_MAX_INACTIVE_INTERVAL);
Object sessionOpenIdObj = session.getAttribute(OPENID); // 自身openid
String sessionOpenId = sessionOpenIdObj == null ? null : sessionOpenIdObj.toString();
Object sessionOpenIdObj = session.getAttribute(OPENID); // 自身openid
String sessionOpenId = sessionOpenIdObj == null ? null : sessionOpenIdObj.toString();
AuthTokenData authTokenData = new AuthTokenData();
String cacheTokenOpenId = authTokenData.decodeToken(token, WeChatConfig.APP_ID);
AuthTokenData authTokenData = new AuthTokenData();
String cacheTokenOpenId = authTokenData.decodeToken(token, WeChatConfig.APP_ID);
log.warn("[授权is_auth] has_token={}, state={}, isUserInfo={}, deState={}", !ObjectUtils.isEmpty(token), state, isUserInfo, deState);
log.warn("[授权is_auth] has_token={}, state={}, isUserInfo={}, deState={}", !ObjectUtils.isEmpty(token), state, isUserInfo, deState);
String authSessionId = null;
if (WeChatConfig.IS_ENABLE_GMC) { // 开启医共体开关
try {
String authSessionId = null;
if (WeChatConfig.IS_ENABLE_GMC) { // 开启医共体开关
if (WeChatConfig.IS_GMC_SERVER) { // 是医共体主服务器
authSessionId = AesWxHelper.decode(request.getHeader(AUTH_SESSION_ID_NAME));
@ -159,39 +160,37 @@ public class WxAuthHelper {
log.info("[微信认证]向主服务器请求认证 cacheTokenOpenId={}", cacheTokenOpenId);
return reqGmcServiceAuth(request, session, state, isUserInfo, cacheTokenOpenId, token, authTokenData, sessionOpenId, authSessionId);
}
} catch (Exception e) {
ErrorHelper.println(e);
return Result.error(e);
}
}
if (cacheTokenOpenId != null) {
log.info("[微信token认证] cacheOpenId={}", cacheTokenOpenId);
AuthResultData authResultData = getTokenData(request, cacheTokenOpenId, token, authTokenData);
session.setAttribute(OPENID, cacheTokenOpenId);
return Result.success(authResultData.toResultData());
}
if (cacheTokenOpenId != null) {
log.info("[微信token认证] cacheOpenId={}", cacheTokenOpenId);
AuthResultData authResultData = getTokenData(request, cacheTokenOpenId, token, authTokenData);
session.setAttribute(OPENID, cacheTokenOpenId);
return Result.success(authResultData.toResultData());
}
log.info("[微信认证]获取 openId={}, authSessionId={}", sessionOpenId, authSessionId);
if (!ObjectUtils.isEmpty(authSessionId) && ObjectUtils.isEmpty(sessionOpenId)) {
sessionOpenId = WxCacheHelper.findOpenIdBySessionIdCache(authSessionId);
log.info("[微信AID认证]sessionOpenId={}", sessionOpenId);
}
log.info("[微信认证]获取 openId={}, authSessionId={}", sessionOpenId, authSessionId);
if (!ObjectUtils.isEmpty(authSessionId) && ObjectUtils.isEmpty(sessionOpenId)) {
sessionOpenId = WxCacheHelper.findOpenIdBySessionIdCache(authSessionId);
log.info("[微信AID认证]sessionOpenId={}", sessionOpenId);
}
AuthResultData authResultData = getCacheUserData(request, sessionOpenId, state, isUserInfo, authSessionId);
log.info("[返回认证数据] data={}", JsonHelper.toJsonString(authResultData));
if (authResultData.hasAuthUrl()) {
log.info("[返回认证链接]authResultData.getAuthUrl");
return Result.success(authResultData.getAuthUrl());
AuthResultData authResultData = getCacheUserData(request, sessionOpenId, state, isUserInfo, authSessionId);
if (authResultData.hasAuthUrl()) {
return Result.success(authResultData.getAuthUrl());
}
return Result.success(authResultData.toResultData());
} catch (Exception e) {
ErrorHelper.println(e);
return Result.error(e);
}
return Result.success(authResultData.toResultData());
}
/**
* 主体服务器认证
*/
public static Result reqGmcServiceAuth(HttpServletRequest request, HttpSession session, String state, String isUserInfo,
String cacheTokenOpenId, String token, AuthTokenData tokenData, String sessionOpenId, String authSessionId) {
String cacheTokenOpenId, String token, AuthTokenData tokenData, String sessionOpenId, String authSessionId) throws ServiceException {
// 自身认证
boolean hasTokenCache = !ObjectUtils.isEmpty(cacheTokenOpenId);
String openId = hasTokenCache ? cacheTokenOpenId : sessionOpenId;
@ -288,7 +287,7 @@ public class WxAuthHelper {
* @param tokenData token解析出来的数据
* @return bean
*/
public static AuthResultData getTokenData(HttpServletRequest request, String cacheOpenId, String token, AuthTokenData tokenData) {
public static AuthResultData getTokenData(HttpServletRequest request, String cacheOpenId, String token, AuthTokenData tokenData) throws ServiceException {
if (tokenData == null || cacheOpenId == null) {
return null;
}
@ -306,7 +305,11 @@ public class WxAuthHelper {
addCache.setPatientList(patients);
cache.put(cacheOpenId, addCache);
} else {
patients = user.getPatientList();
if (WeChatConfig.IS_ENABLE_GMC && !WeChatConfig.IS_GMC_SERVER) { // 开启医共体 && 不是主服务器
patients = new PatientService().queryPatientList(request, cacheOpenId, null, true);
} else {
patients = user.getPatientList();
}
}
AuthResultData authResultData = new AuthResultData();
@ -333,7 +336,7 @@ public class WxAuthHelper {
* @param authSessionId
* @return
*/
public static AuthResultData getCacheUserData(HttpServletRequest request, String openId, String state, String isUserInfo, String authSessionId) {
public static AuthResultData getCacheUserData(HttpServletRequest request, String openId, String state, String isUserInfo, String authSessionId) throws ServiceException {
log.info("[微信认证]openid={}", openId);
AuthResultData authResultData = new AuthResultData();
boolean isFindUserInfo = ("true".equals(isUserInfo));
@ -360,6 +363,13 @@ public class WxAuthHelper {
}
}
List<Patient> patients;
if (WeChatConfig.IS_ENABLE_GMC && !WeChatConfig.IS_GMC_SERVER) { // 开启医共体 && 不是主服务器
patients = new PatientService().queryPatientList(request, openId, null, true);
} else {
patients = user.getPatientList();
}
authResultData.setDate(new Date());
authResultData.setOpenid(openId);
authResultData.setToken(new AuthTokenData().createToken(WeChatConfig.APP_ID, openId, user.getUnionId(), user.getAvatar(), user.getNickName()));
@ -367,7 +377,7 @@ public class WxAuthHelper {
authResultData.setEnUnionId(AesWxHelper.encode(user.getUnionId(), true));
authResultData.setNickName(user.getNickName());
authResultData.setAvatar(user.getAvatar());
authResultData.setPatientList(user.getPatientList());
authResultData.setPatientList(patients);
authResultData.setEnParams(AesMicroHelper.encode(openId));
authResultData.setEnGmcUniqueId(AesWxHelper.encode(CodeHelper.get32UUID()));
return authResultData;

@ -1,5 +1,7 @@
# \u662F\u5426\u4F7F\u7528\u5065\u5EB7\u5361
is_enable=true
# \u662F\u5426\u4E0A\u4F20\u6570\u636E(\u7B49\u7EA7\u672A\u5230\u8FBE\u65F6\u914D\u7F6E\u4E3Afalse[36626])
h.is_upload_data=false
#\u5FAE\u4FE1\u5F00\u653E\u5E73\u53F0\u8C03\u7528\u53C2\u6570
h.app_id=e4a05c13301f2f6a8b07b3de872dfe2d
h.app_secret=e5322dfd9bfab939851319812c30f9f1
@ -10,6 +12,9 @@ h.card_app_id=5a4a6eacbe1040d8a91c76608aefb943
h.card_public_key=mfkwewyhkozizj0caqyikozizj0daqcdqgaepc6p0omuruc5lq7cwdu18ca4cgmqbtjpwdyrglo4wbal9/m3dv4oywez7fbgtnkkgj/kfojvze6sc/dka+ddca==
h.card_private_key=4e181412b5874b22ba113ea3a907e244
h.card_url=http://220.164.109.105:19211/internet
# mini-app======================================
# \u5C0F\u7A0B\u5E8F\u533B\u9662id
h.mini_hospital_id=36626

@ -1 +1 @@
# \u5F00\u542F\u5904\u65B9\u9884\u7ED3\u7B97\uFF08\u7B2C2\u5F00\u5173\uFF09\uFF08\u6CE8\u610F\u8BE5\u914D\u7F6E\u9700\u8054\u7CFBhis\u5F00\u53D1\u8005\u786E\u8BA4\u652F\u6301\u624D\u80FD\u5F00\u542F\uFF0C\u5426\u5219\u5B58\u5728\u98CE\u9669\uFF01\uFF09 his.is_recipe_prepay=false # \u672C\u5730 #his.url=127.0.0.1:8888 # HIS\u662F\u5426\u5F00\u542F\u652F\u4ED8\u5B9D\u5206\u5F00\u5BF9\u8D26 his.is_ali_mer=false # \u662F\u5426\u5F3A\u5236\u6253\u5370webservice\u7684xml\u8FD4\u56DE\u6570\u636E his.is_log_resp=true # \u662F\u5426\u4F20\u9012openid\u7ED9his\u63A8\u9001\u6D88\u606F his.is_push_msg=false #------------------------------------------------------------- # \u6D4B\u8BD5\u73AF\u5883 his.dev_url=127.0.0.1:7777 # \u533B\u4FDD====================== # \u65E7\u914D\u7F6E his.md_url=127.0.0.1:7777 # \u5FAE\u4FE1\u533B\u4FDD his.wx_med_url=10.20.10.7:7885 # \u652F\u4ED8\u5B9D\u533B\u4FDD his.ali_med_url=10.20.10.7:7885 # \u77F3\u6797\u6D4B\u8BD5 his.url=200.200.200.105:8888 # \u6D4B\u8BD5============================================================ # \u5FB7\u5B8F\u4E2D\u533B #his.url=200.200.200.60:8888 # \u7EA2\u6CB3\u5DDE\u533B\u9662 #his.url=10.20.10.6:8888 # \u8292\u5E02\u5987\u5E7C #his.url=192.168.11.7:8888 # \u5B81\u8497\u5987\u5E7C #his.url=172.19.3.15:8888 # \u516C\u53F8\u6D4B\u8BD5 #his.url=192.168.12.39:8888 # \u516C\u53F8\u6D4B\u8BD5 #his.url=192.168.12.10:8888 # \u7EA2\u6CB3 #his.url=10.20.10.6:8888 # \u7EA2\u6CB3\u533B\u4FDD #his.url=10.20.10.6:8888 #his.url=192.168.12.10:8888 #his.md_url=192.168.1.128:7885 #his.dev_url=10.20.10.6:9988 # \u6C38\u80DC #his.url=200.200.200.20:8888 # \u5FB7\u5B8F\u4E2D\u533B #his.url=200.200.200.60:8888 # \u534E\u576A #his.url=192.168.1.115:8888 # \u8499\u81EA\u4E2D\u533B #his.url=192.168.0.228:8888 # \u7389\u9F99 #his.url=192.168.0.17:8888 # \u4E91\u9F99 #his.url=200.200.200.69:8888 # #his.url=172.16.10.15:8888 # \u7984\u529D\u949F\u7231 #his.url=200.200.200.5:8888 # \u8499\u81EA\u5E02\u4EBA\u6C11\u533B\u9662 #his.url=200.200.200.174:8080 # \u5143\u8C0B #his.url=200.200.200.29:8888 # \u5143\u8C0B\u533B\u4FDD #his.dev_url=200.200.200.36:9999 # \u8292\u5E02 #his.url=192.168.100.8:8888 # \u7EA2\u6CB3\u5987\u5E7C\u4FDD\u5065\u9662 #his.url=192.168.1.204:8888 # \u8292\u5E02\u5987\u5E7C #his.url=192.168.11.7:8888 # #his.url=10.10.11.23:8888 # \u77F3\u6797 #his.url=192.168.10.10:8888 # \u5BCC\u6C11 #his.url=200.200.201.27:8888 # \u897F\u53CC\u7248\u7EB3 #his.url=10.10.11.23:8888 #wx.password=ynxbd@6910
# \u5F00\u542F\u5904\u65B9\u9884\u7ED3\u7B97\uFF08\u7B2C2\u5F00\u5173\uFF09\uFF08\u6CE8\u610F\u8BE5\u914D\u7F6E\u9700\u8054\u7CFBhis\u5F00\u53D1\u8005\u786E\u8BA4\u652F\u6301\u624D\u80FD\u5F00\u542F\uFF0C\u5426\u5219\u5B58\u5728\u98CE\u9669\uFF01\uFF09 his.is_recipe_prepay=false # \u672C\u5730 #his.url=127.0.0.1:8888 # HIS\u662F\u5426\u5F00\u542F\u652F\u4ED8\u5B9D\u5206\u5F00\u5BF9\u8D26 his.is_ali_mer=false # \u662F\u5426\u5F3A\u5236\u6253\u5370webservice\u7684xml\u8FD4\u56DE\u6570\u636E his.is_log_resp=true # \u662F\u5426\u4F20\u9012openid\u7ED9his\u63A8\u9001\u6D88\u606F his.is_push_msg=false #------------------------------------------------------------- # \u6D4B\u8BD5\u73AF\u5883 his.dev_url=127.0.0.1:7777 # \u533B\u4FDD====================== # \u65E7\u914D\u7F6E his.md_url=127.0.0.1:7777 # \u5FAE\u4FE1\u533B\u4FDD his.wx_med_url=10.20.10.7:7885 # \u652F\u4ED8\u5B9D\u533B\u4FDD his.ali_med_url=10.20.10.7:7885 # \u516C\u53F8\u6D4B\u8BD5 his.url=192.168.12.10:8888 # \u77F3\u6797\u6D4B\u8BD5 #his.url=200.200.200.105:8888 # \u6D4B\u8BD5============================================================ # \u5FB7\u5B8F\u4E2D\u533B #his.url=200.200.200.60:8888 # \u7EA2\u6CB3\u5DDE\u533B\u9662 #his.url=10.20.10.6:8888 # \u8292\u5E02\u5987\u5E7C #his.url=192.168.11.7:8888 # \u5B81\u8497\u5987\u5E7C #his.url=172.19.3.15:8888 # \u516C\u53F8\u6D4B\u8BD5 #his.url=192.168.12.39:8888 # \u516C\u53F8\u6D4B\u8BD5 #his.url=192.168.12.10:8888 # \u7EA2\u6CB3 #his.url=10.20.10.6:8888 # \u7EA2\u6CB3\u533B\u4FDD #his.url=10.20.10.6:8888 #his.url=192.168.12.10:8888 #his.md_url=192.168.1.128:7885 #his.dev_url=10.20.10.6:9988 # \u6C38\u80DC #his.url=200.200.200.20:8888 # \u5FB7\u5B8F\u4E2D\u533B #his.url=200.200.200.60:8888 # \u534E\u576A #his.url=192.168.1.115:8888 # \u8499\u81EA\u4E2D\u533B #his.url=192.168.0.228:8888 # \u7389\u9F99 #his.url=192.168.0.17:8888 # \u4E91\u9F99 #his.url=200.200.200.69:8888 # #his.url=172.16.10.15:8888 # \u7984\u529D\u949F\u7231 #his.url=200.200.200.5:8888 # \u8499\u81EA\u5E02\u4EBA\u6C11\u533B\u9662 #his.url=200.200.200.174:8080 # \u5143\u8C0B #his.url=200.200.200.29:8888 # \u5143\u8C0B\u533B\u4FDD #his.dev_url=200.200.200.36:9999 # \u8292\u5E02 #his.url=192.168.100.8:8888 # \u7EA2\u6CB3\u5987\u5E7C\u4FDD\u5065\u9662 #his.url=192.168.1.204:8888 # \u8292\u5E02\u5987\u5E7C #his.url=192.168.11.7:8888 # #his.url=10.10.11.23:8888 # \u77F3\u6797 #his.url=192.168.10.10:8888 # \u5BCC\u6C11 #his.url=200.200.201.27:8888 # \u897F\u53CC\u7248\u7EB3 #his.url=10.10.11.23:8888 #wx.password=ynxbd@6910
Loading…
Cancel
Save