|
@ -8,16 +8,19 @@ import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
|
|
|
import com.yihu.jw.entity.ylzinfo.OauthYlzConfigDO;
|
|
|
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
|
|
|
import com.yihu.jw.hospital.prescription.dao.OauthYlzConfigDao;
|
|
|
import com.yihu.jw.hospital.ykyy.service.YkyyService;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.wechat.WeiXinMessageReplyUtils;
|
|
|
import com.yihu.jw.utils.StringUtil;
|
|
|
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
|
|
|
import com.yihu.jw.wechat.dao.WechatDao;
|
|
|
import com.ylzinfo.ehc.EhcHandler;
|
|
|
import com.ylzinfo.ehc.common.utils.DateUtils;
|
|
|
import com.ylzinfo.ehc.trans.TransRequest;
|
|
|
import com.ylzinfo.ehc.trans.TransResponse;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
@ -42,18 +45,18 @@ public class MultipleCodeService {
|
|
|
@Autowired
|
|
|
private BasePatientWechatDao basePatientWechatDao;
|
|
|
|
|
|
@Value("${wechat.id}")
|
|
|
private String wxId;
|
|
|
|
|
|
@Autowired
|
|
|
private WechatDao wechatDao;
|
|
|
|
|
|
@Autowired
|
|
|
private WlyyHttpLogDao wlyyHttpLogDao;
|
|
|
|
|
|
@Autowired
|
|
|
private YkyyService ykyyService;
|
|
|
|
|
|
public MixEnvelop mcfRegister(BasePatientDO patientDO, String wechatId) throws Exception {
|
|
|
BasePatientWechatDo patientWechatDo = basePatientWechatDao.findByWechatIdAndPatientId(wechatId, patientDO.getId()).get(0);
|
|
|
WxWechatDO wechatDO = wechatDao.findById(wxId);
|
|
|
WxWechatDO wechatDO = wechatDao.findById(wechatId);
|
|
|
OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findOne("mcf_config");
|
|
|
TransResponse re= new TransResponse();
|
|
|
try {
|
|
@ -97,7 +100,7 @@ public class MultipleCodeService {
|
|
|
}
|
|
|
// 根据openId、 accountId查询三码融合码信息
|
|
|
public MixEnvelop mcfOpenquery(String patientId,String wechatId) throws Exception {
|
|
|
WxWechatDO wechatDO = wechatDao.findByAppId(wxId);
|
|
|
WxWechatDO wechatDO = wechatDao.findByAppId(wechatId);
|
|
|
BasePatientDO patientDO = basePatientDao.findById(patientId);
|
|
|
if (patientDO!=null){
|
|
|
BasePatientWechatDo patientWechatDo = basePatientWechatDao.findByWechatIdAndPatientId(wechatId, patientDO.getId()).get(0);
|
|
@ -118,7 +121,7 @@ public class MultipleCodeService {
|
|
|
EhcHandler ehcHandler = new EhcHandler(oauthYlzConfigDO.getUrl()+"ehcService/gateway.do", oauthYlzConfigDO.getAppId(), oauthYlzConfigDO.getTermId(), oauthYlzConfigDO.getAppKey());
|
|
|
TransResponse re = ehcHandler.execute(request);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
if ((JSONObject.parseObject(re.getRet_code()).toJSONString()).equalsIgnoreCase("0000")){
|
|
|
if (re.getRet_code().equalsIgnoreCase("0000")){
|
|
|
patientDO.setRegister("1");
|
|
|
String idCard = JSONObject.parseObject(re.getBiz_content()).getString("id_no");
|
|
|
if (idCard!=null)
|
|
@ -223,39 +226,42 @@ public class MultipleCodeService {
|
|
|
TransResponse re = ehcHandler.execute(request);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
if (re.getRet_code().equalsIgnoreCase("0000")){
|
|
|
JSONObject object = JSONObject.parseObject(re.getBiz_content());
|
|
|
patientDO.setRegister("1");
|
|
|
String idCard = JSONObject.parseObject(re.getBiz_content()).getString("id_no");
|
|
|
String idCard =object.getString("id_no");
|
|
|
if (idCard!=null)
|
|
|
{
|
|
|
patientDO.setIdcard(idCard);
|
|
|
}
|
|
|
String userName = JSONObject.parseObject(re.getBiz_content()).getString("user_name");
|
|
|
String userName = object.getString("user_name");
|
|
|
if (userName!=null)
|
|
|
{
|
|
|
patientDO.setName(userName);
|
|
|
}
|
|
|
String userSex = JSONObject.parseObject(re.getBiz_content()).getString("user_sex");
|
|
|
String userSex = object.getString("user_sex");
|
|
|
if (userSex!=null){
|
|
|
patientDO.setSex(Integer.valueOf(userName));
|
|
|
patientDO.setSex(Integer.valueOf(userSex));
|
|
|
}
|
|
|
String mobilePhone = JSONObject.parseObject(re.getBiz_content()).getString("mobile_phone");
|
|
|
String mobilePhone = object.getString("mobile_phone");
|
|
|
if (mobilePhone!=null){
|
|
|
patientDO.setMobile(mobilePhone);
|
|
|
}
|
|
|
String birthday = JSONObject.parseObject(re.getBiz_content()).getString("birthday");
|
|
|
String birthday = object.getString("birthday");
|
|
|
if (birthday!=null){
|
|
|
patientDO.setBirthday(DateUtil.strToDate(birthday));
|
|
|
}
|
|
|
String telephone = JSONObject.parseObject(re.getBiz_content()).getString("telephone");
|
|
|
String telephone = object.getString("telephone");
|
|
|
if (telephone!=null){
|
|
|
patientDO.setPhone(telephone);
|
|
|
}
|
|
|
String address = JSONObject.parseObject(re.getBiz_content()).getString("address");
|
|
|
String address = object.getString("address");
|
|
|
if (address!=null){
|
|
|
patientDO.setAddress(address);
|
|
|
}
|
|
|
basePatientDao.save(patientDO);
|
|
|
jsonObject.put("register","1");
|
|
|
jsonObject.put("register",patientDO.getRegister());
|
|
|
String cardType = object.getString("card_type");
|
|
|
String cardNo =object.getString("card_no");
|
|
|
String ehealthCardId = JSONObject.parseObject(re.getBiz_content()).getString("ehealth_card_id");
|
|
|
WlyyHttpLogDO logDO = new WlyyHttpLogDO();
|
|
|
logDO.setCode("ehc.ehealthcard.getCodeUr");
|
|
@ -271,6 +277,24 @@ public class MultipleCodeService {
|
|
|
jsonObject.put("codeUrl",codeUrl);
|
|
|
return codeUrl;
|
|
|
}
|
|
|
if (cardType.equalsIgnoreCase("01")){
|
|
|
if (StringUtils.isNoneBlank(patientDO.getUserId())){
|
|
|
String patientId = patientDO.getId();
|
|
|
String userId = patientDO.getUserId();
|
|
|
ykyyService.addYkCard(patientId,cardNo,userId,"0");
|
|
|
}else {
|
|
|
String mobile = patientDO.getMobile();
|
|
|
String response = ykyyService.getUserId(mobile);
|
|
|
JSONObject jsonObject1 = JSONObject.parseObject(response);
|
|
|
String userId = "";
|
|
|
String patientId = patientDO.getId();
|
|
|
if (jsonObject1.getString("code").equalsIgnoreCase("200")){
|
|
|
JSONObject data = jsonObject1.getJSONObject("data");
|
|
|
userId = data.getString("USER_ID");
|
|
|
}
|
|
|
ykyyService.addYkCard(patientId,cardNo,userId,"0");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|