|
@ -18,6 +18,7 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
|
|
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
|
|
import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
|
|
import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
|
|
|
|
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
|
|
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
|
|
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
|
|
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
|
|
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
|
|
import com.yihu.jw.entity.hospital.prescription.*;
|
|
import com.yihu.jw.entity.hospital.prescription.*;
|
|
@ -30,7 +31,10 @@ import com.yihu.jw.hospital.prescription.dao.*;
|
|
import com.yihu.jw.hospital.prescription.service.entrance.util.AES;
|
|
import com.yihu.jw.hospital.prescription.service.entrance.util.AES;
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
import com.yihu.jw.restmodel.base.doctor.BaseDoctorVO;
|
|
import com.yihu.jw.restmodel.base.doctor.BaseDoctorVO;
|
|
|
|
import com.yihu.jw.restmodel.hospital.doctor.CheckInfoVO;
|
|
|
|
import com.yihu.jw.restmodel.hospital.doctor.PersonInfoVO;
|
|
import com.yihu.jw.restmodel.hospital.prescription.*;
|
|
import com.yihu.jw.restmodel.hospital.prescription.*;
|
|
|
|
import com.yihu.jw.rm.base.BaseRequestMapping;
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
import com.yihu.jw.util.http.HttpClientUtil;
|
|
import com.yihu.jw.util.http.HttpClientUtil;
|
|
@ -40,8 +44,10 @@ import com.yihu.jw.utils.WebserviceUtil;
|
|
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
|
|
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
|
|
import com.yihu.utils.security.MD5;
|
|
import com.yihu.utils.security.MD5;
|
|
import net.sf.json.xml.XMLSerializer;
|
|
import net.sf.json.xml.XMLSerializer;
|
|
|
|
import nu.xom.*;
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.dom4j.DocumentHelper;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
@ -49,6 +55,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.transaction.Transactional;
|
|
import javax.transaction.Transactional;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.StringReader;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
@ -102,6 +111,10 @@ public class XzzxEntranceService{
|
|
private WlyyInspectionDao wlyyInspectionDao;
|
|
private WlyyInspectionDao wlyyInspectionDao;
|
|
@Autowired
|
|
@Autowired
|
|
private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
|
|
private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
|
|
|
|
@Autowired
|
|
|
|
private BaseDoctorDao baseDoctorDao;
|
|
|
|
@Autowired
|
|
|
|
private BasePatientDao basePatientDao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -114,7 +127,10 @@ public class XzzxEntranceService{
|
|
public static String entranceUrlLocal = "http://localhost:10023/xzzx/";
|
|
public static String entranceUrlLocal = "http://localhost:10023/xzzx/";
|
|
|
|
|
|
public static String hospitalUrl = "http://192.168.118.240:10022/";//172.16.100.63
|
|
public static String hospitalUrl = "http://192.168.118.240:10022/";//172.16.100.63
|
|
|
|
|
|
|
|
//合理用药接口地址
|
|
|
|
public static String checkInfosUrl="http://192.168.102.243:8040/service/api/check.do?tag=1";
|
|
|
|
//保存天际处方接口地址
|
|
|
|
public static String saveTianJiPrescription = "http://192.168.102.243:8040/service/api/checkFromXmlToJson.do?tag=2";
|
|
|
|
|
|
|
|
|
|
public String getSelectUrl(){
|
|
public String getSelectUrl(){
|
|
@ -1323,22 +1339,117 @@ public class XzzxEntranceService{
|
|
return json;
|
|
return json;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
/*
|
|
|
|
*合理用药审核接口入参
|
|
|
|
*/
|
|
|
|
public String checkPrescriptionInfoParam(JSONObject patientAndDoctor,List<WlyyPrescriptionInfoDO> infos){
|
|
|
|
String checkDoctor="<Doctor POSITION=\""+patientAndDoctor.getString("POSITION")+
|
|
|
|
"\" NAME=\""+patientAndDoctor.getString("DOCTOR_NAME")+
|
|
|
|
"\" DEPT_CODE=\""+patientAndDoctor.getString("DEPT_CODE")+
|
|
|
|
"\" DEPT_NAME=\""+patientAndDoctor.getString("DEPT_NAME")+"\" USER_ID=\""+patientAndDoctor.getString("doctorId")+"\" />";
|
|
|
|
String checkPatient="<Patient NAME=\""+patientAndDoctor.getString("patientName")+
|
|
|
|
"\" ID=\""+patientAndDoctor.getString("patientId")+
|
|
|
|
"\" VISIT_ID=\"0\" PATIENT_PRES_ID=\""+patientAndDoctor.getString("PATIENT_PRES_ID")+
|
|
|
|
"\" BIRTH=\""+patientAndDoctor.getString("birth")+
|
|
|
|
"\" HEIGHT=\"0\" WEIGHT=\"0\" GENDER=\""+patientAndDoctor.getString("gender")+
|
|
|
|
"\" PREGNANT=\"\" LACT=\"否\" HEPATICAL=\"是\" RENAL=\"是\" PANCREAS=\"否\" ALERGY_DRUGS=\"青霉素类\" IDENTITY_TYPE=\"\" FEE_TYPE=\""+patientAndDoctor.getString("FEE_TYPE")+
|
|
|
|
"\" SCR=\"\" SCR_UNIT=\"umol/L\" GESTATION_AGE=\"\" PRETERM_BIRTH=\"\" DRUG_HISTORY=\"\" FAMILY_DISEASE_HISTORY=\"\" GENETIC_DISEASE=\"\" MEDICARE_01=\"\" MEDICARE_02=\"\" MEDICARE_03=\"\" MEDICARE_04=\"\" MEDICARE_05=\"\" />";
|
|
|
|
String checkDiagnosises = "<Diagnosises DIAGNOSISES=\""+patientAndDoctor.getString("diagnosises")+"\" >\n" +
|
|
|
|
"</Diagnosises>\n";
|
|
|
|
StringBuffer stringBuffer = new StringBuffer();
|
|
|
|
for (WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO:infos){
|
|
|
|
stringBuffer.append("<Advice REPEAT=\"1\" DRUG_LO_NAME=\""+wlyyPrescriptionInfoDO.getDrugName()+
|
|
|
|
"\" DRUG_LO_ID=\""+wlyyPrescriptionInfoDO.getHisCode()+
|
|
|
|
"\" ADMINISTRATION=\""+wlyyPrescriptionInfoDO.getYpyf()+
|
|
|
|
"\" DOSAGE=\""+wlyyPrescriptionInfoDO.getQuantity()+
|
|
|
|
"\" DOSAGE_UNIT=\""+wlyyPrescriptionInfoDO.getUnit()+
|
|
|
|
"\" FREQ_COUNT=\""+wlyyPrescriptionInfoDO.getUsageCode()+
|
|
|
|
"\" FREQ_INTERVAL=\"1\" FREQ_INTERVAL_UNIT=\""+wlyyPrescriptionInfoDO.getUsageName()+
|
|
|
|
"\" START_DAY=\""+patientAndDoctor.getString("createDate")+"\" END_DAY=\"\" DEPT_CODE=\""+patientAndDoctor.getString("DEPT_CODE")+
|
|
|
|
"\" DOCTOR_NAME=\""+patientAndDoctor.getString("DOCTOR_NAME")+
|
|
|
|
"\" ORDER_NO=\""+wlyyPrescriptionInfoDO.getFrequency()+
|
|
|
|
"\" ORDER_SUB_NO=\""+wlyyPrescriptionInfoDO.getFrequency()+"\" AUTHORITY_LEVELS=\"\" ALERT_LEVELS=\"\" TITLE=\""+patientAndDoctor.getString("POSITION") +
|
|
|
|
"\" GROUP_ID=\""+wlyyPrescriptionInfoDO.getFrequency()+"\" USER_ID=\""+patientAndDoctor.getString("doctorId")+
|
|
|
|
"\" PRES_ID=\""+patientAndDoctor.getString("PATIENT_PRES_ID")+
|
|
|
|
"\" PRES_DATE=\""+patientAndDoctor.getString("createDate")+
|
|
|
|
"\" PRES_SEQ_ID=\""+patientAndDoctor.getString("PATIENT_PRES_ID")+
|
|
|
|
"\" PK_ORDER_NO=\"\" COURSE=\""+wlyyPrescriptionInfoDO.getDays()+
|
|
|
|
"\" PKG_COUNT=\""+wlyyPrescriptionInfoDO.getPackQuantity()+
|
|
|
|
"\" PKG_UNIT=\""+wlyyPrescriptionInfoDO.getPackUnitName()+"\" BAK_01=\"\" BAK_02=\"\" BAK_03=\""+wlyyPrescriptionInfoDO.getUnitName()+
|
|
|
|
"\" BAK_04=\""+wlyyPrescriptionInfoDO.getSpecification()+
|
|
|
|
"\" BAK_05=\""+wlyyPrescriptionInfoDO.getDrugPlace()+"\" />");
|
|
|
|
}
|
|
|
|
String checkInfos = "<Advices>"+stringBuffer.toString()+"</Advices>";
|
|
|
|
String postBody = "<CheckInput TAG=\"2\" INPATIENT=\"否\">"+checkDoctor+checkPatient+checkDiagnosises+checkInfos+"</CheckInput>";
|
|
|
|
return postBody;
|
|
|
|
}
|
|
/*
|
|
/*
|
|
*合理用药审核接口
|
|
*合理用药审核接口
|
|
*/
|
|
*/
|
|
public String checkPrescription(JSONObject patientAndDoctor,List<WlyyPrescriptionInfoDO> infos){
|
|
|
|
String checkDate = "";
|
|
|
|
String postBody = "<CheckInput TAG=\"2\" INPATIENT=\"否\">"+checkDate+"</CheckInput>";
|
|
|
|
return null;
|
|
|
|
|
|
public String checkPrescription(JSONObject patientAndDoctor,List<WlyyPrescriptionInfoDO> infos) throws Exception{
|
|
|
|
String postBody = checkPrescriptionInfoParam(patientAndDoctor,infos);
|
|
|
|
logger.info("发送的报文参数:"+postBody);
|
|
|
|
String res = httpClientUtil.sendPost(checkInfosUrl,postBody);
|
|
|
|
logger.info("返回的报文参数:"+res);
|
|
|
|
WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
|
|
|
|
wlyyHttpLogDO.setDoctor(patientAndDoctor.getString("doctorId"));
|
|
|
|
wlyyHttpLogDO.setCreateTime(new Date());
|
|
|
|
wlyyHttpLogDO.setRequest(postBody);
|
|
|
|
wlyyHttpLogDO.setResponse(res);
|
|
|
|
wlyyHttpLogDO.setName("checkPrescriptionInEntrance");
|
|
|
|
return res;
|
|
}
|
|
}
|
|
//组装审药参数
|
|
|
|
public void checkInpit(String prescriptionId){
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(prescriptionId);
|
|
|
|
if(null!=prescriptionDO){
|
|
|
|
|
|
/*public List<Map<String,Object>> transXmlCommen(String xml){
|
|
|
|
Document doc = null;
|
|
|
|
try {
|
|
|
|
doc = (new Builder()).build(new StringReader(xml));
|
|
|
|
Element root = doc.getRootElement();
|
|
|
|
Elements elements = root.getChildElements();
|
|
|
|
for (int i=0;i<elements.size();i++){
|
|
|
|
Element childElement = elements.get(i);
|
|
|
|
for (int j=0;j<childElement.getAttributeCount();j++){
|
|
|
|
Attribute attribute = childElement.getAttribute(i);
|
|
|
|
attribute.get
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (ParsingException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
}*/
|
|
|
|
public List<PersonInfoVO> transXml(String xml) throws Exception {
|
|
|
|
Document doc = (new Builder()).build(new StringReader(xml));
|
|
|
|
Element root = doc.getRootElement();
|
|
|
|
Elements presInfos = root.getChildElements("PresInfo");
|
|
|
|
List<PersonInfoVO> personInfoVOS = new ArrayList<>();
|
|
|
|
for (int i=0;i<presInfos.size();i++){
|
|
|
|
PersonInfoVO personInfoVO = new PersonInfoVO();
|
|
|
|
List<CheckInfoVO> checkInfoVOS = new ArrayList<>();
|
|
|
|
Element presInfo = presInfos.get(i);
|
|
|
|
personInfoVO.setDrugLoId(presInfo.getAttributeValue("DRUG_LO_ID"));
|
|
|
|
personInfoVO.setDrugLoName(presInfo.getAttributeValue("DRUG_LO_NAME"));
|
|
|
|
personInfoVO.setOrderId(presInfo.getAttributeValue("ORDER_ID"));
|
|
|
|
personInfoVO.setOrderSubId(presInfo.getAttributeValue("ORDER_SUB_ID"));
|
|
|
|
Elements checkinfos = presInfo.getChildElements();
|
|
|
|
if (checkinfos.size()>0){
|
|
|
|
for (int j=0;j<checkinfos.size();j++){
|
|
|
|
CheckInfoVO checkInfoVO = new CheckInfoVO();
|
|
|
|
Element checkinfo = checkinfos.get(j);
|
|
|
|
checkInfoVO.setColor(checkinfo.getAttributeValue("COLOR"));
|
|
|
|
checkInfoVO.setName(checkinfo.getAttributeValue("NAME"));
|
|
|
|
checkInfoVO.setRefResource(checkinfo.getAttributeValue("REF_SOURCE"));
|
|
|
|
checkInfoVO.setWarningInfo(checkinfo.getAttributeValue("WARNING_INFO"));
|
|
|
|
checkInfoVO.setWarningLevel(checkinfo.getAttributeValue("WARNING_LEVEL"));
|
|
|
|
checkInfoVOS.add(checkInfoVO);
|
|
|
|
}
|
|
|
|
personInfoVO.setCheckInfoVOS(checkInfoVOS);
|
|
|
|
}
|
|
|
|
personInfoVOS.add(personInfoVO);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return personInfoVOS;
|
|
}
|
|
}
|
|
|
|
|
|
//=====================微信模板消息推送===================================
|
|
//=====================微信模板消息推送===================================
|
|
@ -2747,7 +2858,87 @@ public Map checkSyncHis(String IoFlag,String PayCardNo,String NullahNumber,Strin
|
|
return map;
|
|
return map;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//组装审药参数
|
|
|
|
public String checkInputInfo(String doctorId,String patientId,List<WlyyPrescriptionInfoDO> infos,List<WlyyPrescriptionDiagnosisDO> wlyyPrescriptionDiagnosisDOS ) throws Exception{
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(doctorId);
|
|
|
|
BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doctorId);
|
|
|
|
jsonObject.put("DOCTOR_NAME", baseDoctorDO.getName());
|
|
|
|
jsonObject.put("DEPT_CODE", baseDoctorDO.getVisitDept());
|
|
|
|
jsonObject.put("DEPT_NAME", baseDoctorDO.getVisitDeptName());
|
|
|
|
if (null != doctorMappingDO && null != baseDoctorDO) {
|
|
|
|
jsonObject.put("doctorId", doctorMappingDO.getMappingCode());
|
|
|
|
jsonObject.put("POSITION", baseDoctorDO.getJobTitleName());
|
|
|
|
}
|
|
|
|
PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patientId);
|
|
|
|
BasePatientDO basePatientDO = patientDao.findById(patientId);
|
|
|
|
jsonObject.put("patientName", basePatientDO.getName());
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
if (null != patientMappingDO && null != basePatientDO) {
|
|
|
|
jsonObject.put("patientId", patientMappingDO.getMappingCode());
|
|
|
|
jsonObject.put("gender", basePatientDO.getSex()==1?"男":"女");
|
|
|
|
jsonObject.put("birth", sdf.format(basePatientDO.getBirthday()));
|
|
|
|
}
|
|
|
|
if (null!=infos&&infos.size()>0) {
|
|
|
|
WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO = infos.get(0);
|
|
|
|
WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(wlyyPrescriptionInfoDO.getPrescriptionId());
|
|
|
|
if (null != prescriptionDO) {
|
|
|
|
jsonObject.put("PATIENT_PRES_ID", prescriptionDO.getId());
|
|
|
|
jsonObject.put("FEE_TYPE", prescriptionDO.getPayType() == 1 ? "医保" : "自费");
|
|
|
|
jsonObject.put("createDate", sdf.format(prescriptionDO.getCreateTime()));
|
|
|
|
}
|
|
|
|
//组装诊断参数
|
|
|
|
if (null != wlyyPrescriptionDiagnosisDOS && wlyyPrescriptionDiagnosisDOS.size() > 0) {
|
|
|
|
List diagnosises = new ArrayList();
|
|
|
|
for (WlyyPrescriptionDiagnosisDO wlyyPrescriptionDiagnosisDO : wlyyPrescriptionDiagnosisDOS) {
|
|
|
|
diagnosises.add(wlyyPrescriptionDiagnosisDO.getName());
|
|
|
|
}
|
|
|
|
jsonObject.put("diagnosises", diagnosises.toArray());
|
|
|
|
}
|
|
|
|
String response = "";
|
|
|
|
String returnJson = "";
|
|
|
|
String url = entranceUrl + "checkPrescription?infos=" + infos + "&patientAndDoctor=" + jsonObject.toString();
|
|
|
|
response = httpClientUtil.get(url, "GBK");
|
|
|
|
logger.info("请求checkPrescription:" + response);
|
|
|
|
JSONObject object = JSONObject.parseObject(response);
|
|
|
|
WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
|
|
|
|
if (object.getInteger("status") == 200) {
|
|
|
|
wlyyHttpLogDO.setCode("200");
|
|
|
|
String obj = object.getString("obj");
|
|
|
|
if (StringUtils.isNotBlank(obj)) {
|
|
|
|
List<PersonInfoVO> returnList = transXml(obj);
|
|
|
|
returnJson = JSONArray.toJSONString(returnList);
|
|
|
|
wlyyHttpLogDO.setDoctor(doctorId);
|
|
|
|
wlyyHttpLogDO.setCreateTime(new Date());
|
|
|
|
wlyyHttpLogDO.setRequest(infos + jsonObject.toString());
|
|
|
|
wlyyHttpLogDO.setResponse(returnJson);
|
|
|
|
wlyyHttpLogDO.setName("checkPrescription");
|
|
|
|
} else {
|
|
|
|
returnJson = "审方返回接口为空请检查参数是否正确";
|
|
|
|
logger.info(returnJson);
|
|
|
|
wlyyHttpLogDO.setCode("error");
|
|
|
|
wlyyHttpLogDO.setDoctor(doctorId);
|
|
|
|
wlyyHttpLogDO.setCreateTime(new Date());
|
|
|
|
wlyyHttpLogDO.setRequest(infos + jsonObject.toString());
|
|
|
|
wlyyHttpLogDO.setResponse(returnJson);
|
|
|
|
wlyyHttpLogDO.setName("checkPrescription");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
returnJson = "entranceUrl接口调用失败";
|
|
|
|
wlyyHttpLogDO.setCode("error");
|
|
|
|
wlyyHttpLogDO.setDoctor(doctorId);
|
|
|
|
wlyyHttpLogDO.setCreateTime(new Date());
|
|
|
|
wlyyHttpLogDO.setRequest(infos + jsonObject.toString());
|
|
|
|
wlyyHttpLogDO.setResponse(returnJson);
|
|
|
|
wlyyHttpLogDO.setName("checkPrescription");
|
|
|
|
}
|
|
|
|
wlyyHttpLogDao.save(wlyyHttpLogDO);
|
|
|
|
|
|
|
|
return returnJson;
|
|
|
|
}else {
|
|
|
|
return "药品信息为空";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|