|
@ -140,12 +140,19 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.crypto.BadPaddingException;
|
|
|
import javax.crypto.IllegalBlockSizeException;
|
|
|
import javax.crypto.NoSuchPaddingException;
|
|
|
import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.lang.Boolean;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.net.URL;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.security.InvalidAlgorithmParameterException;
|
|
|
import java.security.InvalidKeyException;
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
@ -354,6 +361,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
|
private String wechatId;
|
|
|
@Value("${wechat.flag}")
|
|
|
private boolean flag;
|
|
|
@Autowired
|
|
|
private WlyyReservationInfoDao reservationInfoDao;
|
|
|
|
|
|
|
|
|
/**
|
|
@ -16723,10 +16732,157 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
|
}
|
|
|
|
|
|
|
|
|
public void delYlzRelationCode(String outpatientId){
|
|
|
public void delYlzRelationCode(String outpatientId) {
|
|
|
YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
|
|
|
ylzMedicailRelationDao.delete(ylzMedicalRelationDO);
|
|
|
}
|
|
|
|
|
|
private static String reservationApi = "";
|
|
|
private static String reservationKey = "";
|
|
|
|
|
|
private static String reservationUrl = "";
|
|
|
|
|
|
public void initReservation() throws Exception {
|
|
|
List<WlyyHospitalSysDictDO> hospitalSysDictDOList = hospitalSysDictDao.findByDictName("reservation");
|
|
|
for (WlyyHospitalSysDictDO sysDictDO:hospitalSysDictDOList){
|
|
|
if (sysDictDO.getId().equalsIgnoreCase("reservationAppId")){
|
|
|
reservationApi = sysDictDO.getDictValue();
|
|
|
}else if (sysDictDO.getId().equalsIgnoreCase("reservationAppKey")){
|
|
|
reservationKey = sysDictDO.getDictValue();
|
|
|
}else if (sysDictDO.getId().equalsIgnoreCase("reservationUrl")){
|
|
|
reservationUrl = sysDictDO.getDictValue();
|
|
|
}
|
|
|
}
|
|
|
if (hospitalSysDictDOList==null||hospitalSysDictDOList.size()==0){
|
|
|
throw new Exception("未找到配置数据");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 请求医技预约通用接口
|
|
|
*
|
|
|
* @param url
|
|
|
* @param src
|
|
|
* @return
|
|
|
* @throws InvalidAlgorithmParameterException
|
|
|
* @throws NoSuchPaddingException
|
|
|
* @throws IllegalBlockSizeException
|
|
|
* @throws IOException
|
|
|
* @throws NoSuchAlgorithmException
|
|
|
* @throws BadPaddingException
|
|
|
* @throws InvalidKeyException
|
|
|
*/
|
|
|
public String reservationCommonPost(String url, String src) throws Exception {
|
|
|
logger.info("加密前参数"+src);
|
|
|
String encryptData = AESUtils.encrypt(src, reservationKey.substring(0,16));//加密
|
|
|
com.alibaba.fastjson.JSONObject data = new com.alibaba.fastjson.JSONObject();
|
|
|
data.put("hlwyyparam",encryptData);
|
|
|
String res = HttpClientUtil.postBody(url,data);
|
|
|
logger.info("请求返回值:"+res);
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取跳转链接
|
|
|
*
|
|
|
* @param patient
|
|
|
* @param doctor
|
|
|
* @param chiefComplaint
|
|
|
* @param illRecord
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public String getReservationUrl(String patient,String doctor,String chiefComplaint,String illRecord,String relationCode,Integer relationType) throws Exception {
|
|
|
initReservation();
|
|
|
String openHlwyyUrl = "";
|
|
|
String url = reservationUrl+"/yy-prod-api/app-api/third-in/webhook/exam/xdzs-hlwyy/post-exam";
|
|
|
com.alibaba.fastjson.JSONObject data = new com.alibaba.fastjson.JSONObject();
|
|
|
BasePatientDO patientDO = basePatientDao.findById(patient);
|
|
|
PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
|
|
|
PatientMedicareCardDO patientMedicareCardDO = patientMedicareCardDao.findByTypeAndPatientCodeAndDel("A_01",patient,"1");
|
|
|
BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
|
|
|
DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(doctor);
|
|
|
List<BaseDoctorHospitalDO> doctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(doctor);
|
|
|
WlyyReservationInfoDO reservationInfoDO = new WlyyReservationInfoDO();
|
|
|
reservationInfoDO.setCardNo(patientMedicareCardDO.getCode());
|
|
|
reservationInfoDO.setPatient(patient);
|
|
|
reservationInfoDO.setPatientName(patientDO.getName());
|
|
|
reservationInfoDO.setDoctor(doctor);
|
|
|
reservationInfoDO.setDoctorName(doctorDO.getName());
|
|
|
reservationInfoDO.setChiefComplaint(chiefComplaint);
|
|
|
reservationInfoDO.setIllRecord(illRecord);
|
|
|
reservationInfoDO.setRelationCode(relationCode);
|
|
|
reservationInfoDO.setRelationType(relationType);
|
|
|
reservationInfoDO.setIllRecord(illRecord);
|
|
|
reservationInfoDO.setCreateTime(new Date());
|
|
|
reservationInfoDO = reservationInfoDao.save(reservationInfoDO);
|
|
|
data.put("hospitalId","1");
|
|
|
data.put("hisPatientId",patientMappingDO.getMappingCode());
|
|
|
data.put("cardNo",patientMedicareCardDO.getCode());
|
|
|
data.put("idNo",patientDO.getIdcard());
|
|
|
data.put("idType","01");
|
|
|
data.put("tel",patientDO.getMobile());
|
|
|
data.put("patientName",patientDO.getName());
|
|
|
data.put("openDoctorCode",doctorMappingDO.getMappingCode());
|
|
|
data.put("openDoctorName",doctorDO.getName());
|
|
|
data.put("openDoctorIdNo",doctorDO.getIdcard());
|
|
|
data.put("openDoctorPhoneNo",doctorDO.getMobile());
|
|
|
data.put("openDepartmentCode",doctorHospitalDOS.get(0).getDeptCode());
|
|
|
data.put("openDepartmentName",doctorHospitalDOS.get(0).getDeptName());
|
|
|
data.put("chiefComplaint",chiefComplaint);
|
|
|
data.put("illRecord",illRecord);
|
|
|
data.put("timestamp",new Date().getTime()+"");
|
|
|
data.put("appId",reservationApi);
|
|
|
String res = reservationCommonPost(url,data.toJSONString());
|
|
|
if(StringUtils.isNoneBlank(res)){
|
|
|
com.alibaba.fastjson.JSONObject resObj = com.alibaba.fastjson.JSONObject.parseObject(res);
|
|
|
if (resObj.getString("code").equalsIgnoreCase("0")){
|
|
|
String checkCode = resObj.getJSONObject("data").getString("checkKeyNo");
|
|
|
com.alibaba.fastjson.JSONObject checkData = new com.alibaba.fastjson.JSONObject();
|
|
|
checkData.put("checkKeyNo",checkCode);
|
|
|
String hlwyyParam = AESUtils.encrypt(checkData.toJSONString(),reservationKey.substring(0,16));
|
|
|
openHlwyyUrl = reservationUrl+"/doctor-h5/pages/check/open-hlwyy?hlwyyparam="+hlwyyParam;
|
|
|
reservationInfoDO.setUrl(openHlwyyUrl);
|
|
|
reservationInfoDO.setUpdateTime(new Date());
|
|
|
reservationInfoDao.save(reservationInfoDO);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return openHlwyyUrl;
|
|
|
}
|
|
|
|
|
|
|
|
|
public String getReservationList(int flag,String doctor,String patient,String cardNo) throws Exception {
|
|
|
String url = "";
|
|
|
initReservation();
|
|
|
if (flag==1){
|
|
|
//医生
|
|
|
BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
|
|
|
DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(doctor);
|
|
|
BasePatientDO patientDO = basePatientDao.findById(patient);
|
|
|
com.alibaba.fastjson.JSONObject data= new com.alibaba.fastjson.JSONObject();
|
|
|
data.put("openDoctorPhoneNo",doctorDO.getMobile());
|
|
|
data.put("openDoctorIdNo",doctorDO.getIdcard());
|
|
|
data.put("openDoctorName",doctorDO.getName());
|
|
|
data.put("openDoctorCode",doctorMappingDO.getMappingCode());
|
|
|
data.put("userPhoneNo",patientDO.getMobile());
|
|
|
data.put("userIdNo",patientDO.getIdcard());
|
|
|
data.put("userCardNo",cardNo);
|
|
|
String entryData = AESUtils.encrypt(data.toJSONString(),reservationKey.substring(0,16));
|
|
|
url = reservationUrl+"/doctor-h5/pages/patient/apply_list?hlwyyparam="+entryData;
|
|
|
}else if (flag==2){
|
|
|
//患者
|
|
|
BasePatientDO patientDO = basePatientDao.findById(patient);
|
|
|
com.alibaba.fastjson.JSONObject data= new com.alibaba.fastjson.JSONObject();
|
|
|
data.put("userName",patientDO.getName());
|
|
|
data.put("userPhoneNo",patientDO.getMobile());
|
|
|
data.put("userIdNo",patientDO.getIdcard());
|
|
|
data.put("userCardNo",cardNo);
|
|
|
String entryData = AESUtils.encrypt(data.toJSONString(),reservationKey.substring(0,16));
|
|
|
url = reservationUrl+"/user-h5/pages/resv/list?hlwyyparam="+entryData;
|
|
|
}
|
|
|
return url;
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|