|  | @ -1,22 +1,33 @@
 | 
	
		
			
				|  |  | package com.yihu.jw.healthCare.service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONArray;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.service.BaseDoctorHosService;
 | 
	
		
			
				|  |  | 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.httplog.YlzHttpLogDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.healthCare.utils.AES;
 | 
	
		
			
				|  |  | import com.yihu.jw.healthCare.utils.MD5;
 | 
	
		
			
				|  |  | import com.yihu.jw.healthCare.utils.SafeUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.healthCare.utils.StringUtils;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.httplog.dao.YlzHttpLogDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.patient.dao.BasePatientDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.common.IdCardUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.date.DateUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.http.HttpClientUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.StringUtil;
 | 
	
		
			
				|  |  | import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  | import org.slf4j.Logger;
 | 
	
		
			
				|  |  | import org.slf4j.LoggerFactory;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
	
		
			
				|  | @ -43,6 +54,14 @@ public class HealthCareService {
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseDoctorDao doctorDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BasePatientDao patientDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private OutpatientDao outpatientDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private DoctorMappingDao doctorMappingDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PrescriptionDao prescriptionDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private HttpClientUtil httpClientUtil;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private YlzHttpLogDao ylzHttpLogDao;
 | 
	
	
		
			
				|  | @ -146,7 +165,7 @@ public class HealthCareService {
 | 
	
		
			
				|  |  |         data.put("idcard",doctorDO.getIdcard());//医师证件号
 | 
	
		
			
				|  |  |         data.put("cert_type","");//医师证件类型
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         requestYlz(data.toJSONString(),"N20.17.02.01");
 | 
	
		
			
				|  |  |         requestYlz(data,"N20.17.02.01","医师身份验证");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
	
		
			
				|  | @ -165,7 +184,7 @@ public class HealthCareService {
 | 
	
		
			
				|  |  |         data.put("idcard",doctorDO.getIdcard());//医师证件号
 | 
	
		
			
				|  |  |         data.put("cert_type","");//医师证件类型
 | 
	
		
			
				|  |  |         data.put("redirect_url",hospitalSysDictDO.getDictValue());//回调地址
 | 
	
		
			
				|  |  |         requestYlz(data.toJSONString(),"N20.17.02.02");
 | 
	
		
			
				|  |  |         requestYlz(data,"N20.17.02.02","医师人脸签到表单地址");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
	
		
			
				|  | @ -177,11 +196,121 @@ public class HealthCareService {
 | 
	
		
			
				|  |  |         data.put("name",doctorDO.getName());//医师姓名
 | 
	
		
			
				|  |  |         data.put("idcard",doctorDO.getIdcard());//医师证件号
 | 
	
		
			
				|  |  |         data.put("cert_type","");//医师证件类型
 | 
	
		
			
				|  |  |         requestYlz(data.toJSONString(),"N20.17.02.05");
 | 
	
		
			
				|  |  |         requestYlz(data,"N20.17.02.05","获取医师人脸签到数据");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 2.4.1 事前提醒
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public void advanceWarning(String prescriptionId) throws Exception{
 | 
	
		
			
				|  |  |         WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(prescriptionId);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         WlyyOutpatientDO outpatientDO = outpatientDao.findOne(prescriptionDO.getOutpatientId());
 | 
	
		
			
				|  |  |         BasePatientDO patientDO = patientDao.findById(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |         JSONObject data = new JSONObject();
 | 
	
		
			
				|  |  |         data.put("his_serial",outpatientDO.getRegisterNo());//HIS 门诊挂号号
 | 
	
		
			
				|  |  |         data.put("insurance_serial","insurance_serial");//医保门诊挂号流水号
 | 
	
		
			
				|  |  |         data.put("medical_mode","");//就诊类型 String	Y
 | 
	
		
			
				|  |  |         data.put("region_code","");//参保地区划代码	String	Y
 | 
	
		
			
				|  |  |         data.put("name",patientDO.getName());//姓名
 | 
	
		
			
				|  |  |         data.put("idcard",patientDO.getIdcard());//证件号码
 | 
	
		
			
				|  |  |         data.put("cert_type","");//证件类型
 | 
	
		
			
				|  |  |         data.put("sex","");//性别	String	Y
 | 
	
		
			
				|  |  |         String birth = IdCardUtil.getBirthdayForIdcardStr(patientDO.getIdcard(),patientDO.getBirthday());
 | 
	
		
			
				|  |  |         if(StringUtils.isBlank(birth)){
 | 
	
		
			
				|  |  |             throw new Exception("居民生日信息有误");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         data.put("birth",birth);//出生日期 	String	Y
 | 
	
		
			
				|  |  |         data.put("medical_type","");//医疗类别	String	Y
 | 
	
		
			
				|  |  |         data.put("ticket_no","");//单据流水号	String	Y
 | 
	
		
			
				|  |  |         data.put("disease_code","");//特殊门诊病情编码	String	Y
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String doctorId = outpatientDO.getDoctor();
 | 
	
		
			
				|  |  |         BaseDoctorDO doctorDO = doctorDao.findOne(doctorId);
 | 
	
		
			
				|  |  |         List<BaseDoctorHospitalDO> doctorHospitalDOS = doctorHospitalDao.findByDoctorCode(doctorId);
 | 
	
		
			
				|  |  |         if(doctorHospitalDOS.size()<=0){
 | 
	
		
			
				|  |  |             throw new Exception("未找到医生科室编码");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         BaseDoctorHospitalDO doctorHospitalDO = doctorHospitalDOS.get(0);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(doctorId);
 | 
	
		
			
				|  |  |         if(doctorMappingDO == null){
 | 
	
		
			
				|  |  |             throw new Exception("未找到医生his编码");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         data.put("dept_code",doctorHospitalDO.getDeptCode());//科室代码
 | 
	
		
			
				|  |  |         data.put("dept_name",doctorHospitalDO.getDeptName());//科室名称
 | 
	
		
			
				|  |  |         data.put("doctor_code",doctorMappingDO.getMappingCode());//医师编号
 | 
	
		
			
				|  |  |         data.put("doctor_name",doctorDO.getName());//医生名称
 | 
	
		
			
				|  |  |         data.put("doctor_idcard",doctorDO.getIdcard());//医师身份证号
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         data.put("prescription_date", DateUtil.dateToStr(outpatientDO.getCreateTime(),DateUtil.YYYY_MM_DD));//处方日期
 | 
	
		
			
				|  |  |         data.put("prescription_counts","1");//处方项目数
 | 
	
		
			
				|  |  |         data.put("prescription_source","");//处方来源	String	Y
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //诊断
 | 
	
		
			
				|  |  |         JSONArray zdlist = new JSONArray();
 | 
	
		
			
				|  |  |         String icd10 = outpatientDO.getIcd10();
 | 
	
		
			
				|  |  |         String icd10Name = outpatientDO.getIcd10Name();
 | 
	
		
			
				|  |  |         String icd10sz[] = icd10.split(",");
 | 
	
		
			
				|  |  |         String icd10Namesz[] = icd10Name.split(",");
 | 
	
		
			
				|  |  |         for (int i=0;i<icd10sz.length;i++){
 | 
	
		
			
				|  |  |             JSONObject zd = new JSONObject();
 | 
	
		
			
				|  |  |             zd.put("disease_code_icd10",icd10sz[i].trim());//诊断或症状编码	String	Y	见icd-10或症状表编码
 | 
	
		
			
				|  |  |             zd.put("disease_name_icd10",icd10Namesz[i].trim());//诊断或症状名称	String	Y	见icd-10或症状表名称
 | 
	
		
			
				|  |  |             zd.put("disease_type","");//诊断或症状类型	String	Y	参见编码附件
 | 
	
		
			
				|  |  |             zd.put("disease_order","");//诊断或症状序号	String	Y	参见编码附件
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         data.put("zdlist",zdlist);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //医嘱明细
 | 
	
		
			
				|  |  |         JSONArray mxlist = new JSONArray();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         data.put("mxlist",mxlist);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         requestYlz(data,"N20.17.03.03","事前提醒");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 2.4.2	医师开方上传
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public void doctorPrescriptionUpload(String prescriptionId)throws Exception{
 | 
	
		
			
				|  |  |         WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(prescriptionId);
 | 
	
		
			
				|  |  |         JSONObject data = new JSONObject();
 | 
	
		
			
				|  |  |         data.put("insurance_serial","insurance_serial");//医保门诊挂号流水号
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //医嘱明细
 | 
	
		
			
				|  |  |         JSONArray mxlist = new JSONArray();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         data.put("mxlist",mxlist);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         requestYlz(data,"N20.17.03.01","医师开方上传");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 2.4.3	医师开方上传取消(N20.17.03.06)
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public void doctorPrescriptionUploadCancle(String prescriptionId,String cancelReason)throws Exception{
 | 
	
		
			
				|  |  |         WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(prescriptionId);
 | 
	
		
			
				|  |  |         JSONObject data = new JSONObject();
 | 
	
		
			
				|  |  |         data.put("transaction_no","");//处方上传流水号  	String	Y
 | 
	
		
			
				|  |  |         data.put("insurance_serial","insurance_serial");//医保流水号
 | 
	
		
			
				|  |  |         data.put("cancel_reason",cancelReason);//作废原因
 | 
	
		
			
				|  |  |         data.put("region_code","");//参保地区划代码
 | 
	
		
			
				|  |  |         data.put("idcard",prescriptionDO.getIdcard());//证件号码
 | 
	
		
			
				|  |  |         data.put("name",prescriptionDO.getPatientName());//姓名
 | 
	
		
			
				|  |  |         data.put("cert_type","");//证件类型
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         data.put("data_source","");//数据来源	String	Y	参见编码附件
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         requestYlz(data,"N20.17.03.06","医师开方上传取消");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public String getYlzToken() throws Exception {
 | 
	
		
			
				|  |  |         YlzHttpLogDO ylzHttpLogDO = new YlzHttpLogDO();
 |