|
@ -1,6 +1,7 @@
|
|
|
package com.yihu.jw.healthCare.service;
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
@ -9,15 +10,18 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
|
|
|
import com.yihu.jw.entity.hospital.family.WlyyPatientFamilyMemberDO;
|
|
|
import com.yihu.jw.entity.hospital.healthCare.*;
|
|
|
import com.yihu.jw.entity.hospital.httplog.YlzHttpLogDO;
|
|
|
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
|
|
|
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
|
|
|
import com.yihu.jw.entity.hospital.prescription.*;
|
|
|
import com.yihu.jw.entity.ylzinfo.OauthYlzConfigDO;
|
|
|
import com.yihu.jw.healthCare.utils.AES;
|
|
|
import com.yihu.jw.healthCare.utils.SafeUtil;
|
|
|
import com.yihu.jw.healthCare.utils.YibaoJiaMi;
|
|
|
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
|
|
|
import com.yihu.jw.hospital.family.dao.WlyyPatientFamilyMemberDao;
|
|
|
import com.yihu.jw.hospital.healthCare.*;
|
|
|
import com.yihu.jw.hospital.httplog.dao.YlzHttpLogDao;
|
|
|
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
|
|
@ -27,9 +31,17 @@ import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
|
|
|
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.util.common.LatitudeUtils;
|
|
|
import com.yihu.jw.util.common.QrcodeUtil;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.http.HttpClientUtil;
|
|
|
import com.yihu.jw.util.idcard.IdCardUtil;
|
|
|
import com.yihu.jw.utils.ByteToInputStream;
|
|
|
import com.yihu.utils.security.MD5;
|
|
|
import com.ylzinfo.ehc.EhcHandler;
|
|
|
import com.ylzinfo.ehc.trans.TransRequest;
|
|
|
import com.ylzinfo.ehc.trans.TransResponse;
|
|
|
import net.sf.json.util.JSONTokener;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@ -38,12 +50,16 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
|
|
|
import javax.transaction.Transactional;
|
|
|
import java.io.InputStream;
|
|
|
import java.io.PrintWriter;
|
|
|
import java.io.StringWriter;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
/**
|
|
|
* 医保对接
|
|
@ -95,6 +111,12 @@ public class HealthCareNewService {
|
|
|
private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
|
|
|
@Autowired
|
|
|
private YlzMedicailRelationRefundDao ylzMedicailRelationRefundDao;
|
|
|
@Autowired
|
|
|
private YlzMedicalUserInfoDao ylzMedicalUserInfoDao;
|
|
|
@Autowired
|
|
|
private BasePatientDao basePatientDao;
|
|
|
@Autowired
|
|
|
private WlyyPatientFamilyMemberDao familyMemberDao;
|
|
|
|
|
|
private String ylzConfigUrl;
|
|
|
private String ylzConfigAppid;
|
|
@ -103,6 +125,7 @@ public class HealthCareNewService {
|
|
|
private String ylzConfigSignKey;
|
|
|
private String ylzConfigOrgCode;
|
|
|
|
|
|
|
|
|
public static String entranceHealthCareUrl = "http://127.0.0.1:10023/healthCare/";
|
|
|
|
|
|
|
|
@ -2281,4 +2304,154 @@ public class HealthCareNewService {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取用户信息(N03.00.05.16)
|
|
|
*
|
|
|
* 返回值
|
|
|
*
|
|
|
* @param code 用户信息临时串
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public String getUserInfo(String code) throws Exception{
|
|
|
String funid = "N03.00.05.16";
|
|
|
JSONObject data = new JSONObject();
|
|
|
data.put("code",code);//用户信息临时串
|
|
|
logger.info("data"+data.toJSONString());
|
|
|
String result = requestYlz(data,funid,"获取用户信息");
|
|
|
if (result==null){
|
|
|
throw new Exception("获取用户信息失败");
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取医保二维码
|
|
|
*
|
|
|
* @return
|
|
|
* @throws UnsupportedEncodingException
|
|
|
*/
|
|
|
public Map<String,Object> getYbImage() throws UnsupportedEncodingException {
|
|
|
String no = UUID.randomUUID().toString().substring(0,30);
|
|
|
YlzMedicalUserInfoDO ylzMedicalUserInfoDO = new YlzMedicalUserInfoDO();
|
|
|
ylzMedicalUserInfoDO.setNo(no);
|
|
|
String redirectUrl = "https://hlwyy.xmhcyy.com/hcyy/ims-wx/#/login?no="+no;
|
|
|
String url = "https://service.ylbz.xm.gov.cn/xmyb/web-ixm/app/#/ecAuth?redirectUrl="+ URLEncoder.encode(redirectUrl, "UTF-8");
|
|
|
ylzMedicalUserInfoDO.setUrl(url);
|
|
|
ylzMedicalUserInfoDO.setCreateTime(new Date());
|
|
|
ylzMedicalUserInfoDao.save(ylzMedicalUserInfoDO);
|
|
|
ByteToInputStream byteToInputStream = new ByteToInputStream();
|
|
|
InputStream qrcode = QrcodeUtil.createQrcode(url,300,"jpg");
|
|
|
String QRCodeImg = byteToInputStream.getBase64FromInputStream(qrcode);
|
|
|
Map<String,Object> map = new HashedMap();
|
|
|
map.put("QRCodeImg","data:image/png;base64,"+ QRCodeImg);
|
|
|
map.put("out_authorize_no",no);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @param no
|
|
|
* @param token
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public YlzMedicalUserInfoDO updateUserInfo(String no,String token) throws Exception {
|
|
|
YlzMedicalUserInfoDO ylzMedicalUserInfoDO = ylzMedicalUserInfoDao.findByNo(no);
|
|
|
String result = getUserInfo(token);
|
|
|
ylzMedicalUserInfoDO.setToken(token);
|
|
|
ylzMedicalUserInfoDO.setJson(result);
|
|
|
ylzMedicalUserInfoDO = ylzMedicalUserInfoDao.save(ylzMedicalUserInfoDO);
|
|
|
JSONObject object = JSONObject.parseObject(result);
|
|
|
logger.info(object.toJSONString());
|
|
|
if (object.getString("flag").equalsIgnoreCase("1")){
|
|
|
JSONObject data = object.getJSONObject("encrypt_data");
|
|
|
String idcard = data.getString("idcard");
|
|
|
String name = data.getString("name");
|
|
|
String cardno = data.getString("cardno");
|
|
|
String sex = data.getString("sex");
|
|
|
ylzMedicalUserInfoDO.setIdcard(idcard);
|
|
|
ylzMedicalUserInfoDO.setName(name);
|
|
|
BasePatientDO patientDO = basePatientDao.findByIdcardAndDel(idcard,"1");
|
|
|
if(StringUtils.isNotBlank(idcard)&&patientDO == null){
|
|
|
BasePatientDO patient = new BasePatientDO();
|
|
|
String salt = UUID.randomUUID().toString().substring(0,5);
|
|
|
String pw = null;
|
|
|
pw = idcard.substring(idcard.length()-6);
|
|
|
patient.setIdcard(idcard);
|
|
|
patient.setName(name);
|
|
|
patient.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
|
|
|
patient.setSalt(salt);
|
|
|
patient.setDel("1");
|
|
|
patient.setEnabled(1);
|
|
|
patient.setLocked(0);
|
|
|
patient.setSex(Integer.parseInt(IdCardUtil.getSexForIdcard_new(idcard)));
|
|
|
patient.setCreateTime(new Date());
|
|
|
patient.setUpdateTime(new Date());
|
|
|
patient.setBirthday(DateUtil.strToDate(IdCardUtil.getBirthdayForIdcardStr(idcard),"yyyyMMdd"));
|
|
|
patientDO = basePatientDao.save(patient);
|
|
|
WlyyPatientFamilyMemberDO basePatientFamilyMemberDO = familyMemberDao.findFamilyMemberByPatientAndRelationCode(patientDO.getId(),"7");
|
|
|
if (basePatientFamilyMemberDO==null){
|
|
|
basePatientFamilyMemberDO = new WlyyPatientFamilyMemberDO();
|
|
|
basePatientFamilyMemberDO.setPatient(patientDO.getId());
|
|
|
basePatientFamilyMemberDO.setFamilyRelation("7");
|
|
|
basePatientFamilyMemberDO.setFamilyRelationName("自己");
|
|
|
basePatientFamilyMemberDO.setCardType("身份证");
|
|
|
basePatientFamilyMemberDO.setCardNo(patientDO.getIdcard());
|
|
|
basePatientFamilyMemberDO.setCreateTime(new Date());
|
|
|
basePatientFamilyMemberDO.setUpdateTime(new Date());
|
|
|
basePatientFamilyMemberDO.setIsAuthorize(1);
|
|
|
basePatientFamilyMemberDO.setIsDel(1);
|
|
|
basePatientFamilyMemberDO.setFamilyMember(patientDO.getId());
|
|
|
familyMemberDao.save(basePatientFamilyMemberDO);
|
|
|
}
|
|
|
}else {
|
|
|
basePatientDao.save(patientDO);
|
|
|
WlyyPatientFamilyMemberDO basePatientFamilyMemberDO = familyMemberDao.findFamilyMemberByPatientAndRelationCode(patientDO.getId(), "7");
|
|
|
if (basePatientFamilyMemberDO == null) {
|
|
|
basePatientFamilyMemberDO = new WlyyPatientFamilyMemberDO();
|
|
|
basePatientFamilyMemberDO.setPatient(patientDO.getId());
|
|
|
basePatientFamilyMemberDO.setFamilyRelation("7");
|
|
|
basePatientFamilyMemberDO.setFamilyRelationName("自己");
|
|
|
basePatientFamilyMemberDO.setCardType("身份证");
|
|
|
basePatientFamilyMemberDO.setCardNo(patientDO.getIdcard());
|
|
|
basePatientFamilyMemberDO.setCreateTime(new Date());
|
|
|
basePatientFamilyMemberDO.setUpdateTime(new Date());
|
|
|
basePatientFamilyMemberDO.setIsAuthorize(1);
|
|
|
basePatientFamilyMemberDO.setIsDel(1);
|
|
|
basePatientFamilyMemberDO.setFamilyMember(patientDO.getId());
|
|
|
familyMemberDao.save(basePatientFamilyMemberDO);
|
|
|
}
|
|
|
}
|
|
|
logger.info("获取用户信息成功");
|
|
|
}
|
|
|
return ylzMedicalUserInfoDO;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 验证医保凭证是否授权
|
|
|
* @param authorizeNo
|
|
|
* @return
|
|
|
*/
|
|
|
public Map<String,Object> checkOauthQRCode(String authorizeNo) {
|
|
|
YlzMedicalUserInfoDO ylzMedicalUserInfoDO = ylzMedicalUserInfoDao.findByNo(authorizeNo);
|
|
|
Map<String, Object> rsMap = new HashedMap();
|
|
|
if (ylzMedicalUserInfoDO != null) {
|
|
|
if (StringUtils.isNoneBlank(ylzMedicalUserInfoDO.getToken())) {
|
|
|
rsMap.put("sCode", "succ");
|
|
|
rsMap.put("sMes", "success");
|
|
|
}else {
|
|
|
rsMap.put("sCode", "ing");
|
|
|
rsMap.put("sMes", "正在授权");
|
|
|
}
|
|
|
} else {
|
|
|
rsMap.put("sCode", "ing");
|
|
|
rsMap.put("sMes", "正在授权");
|
|
|
}
|
|
|
return rsMap;
|
|
|
}
|
|
|
}
|