|  | @ -114,7 +114,8 @@ public class XzzxEntranceService{
 | 
	
		
			
				|  |  |     private BasePatientDao basePatientDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseDoctorHospitalDao baseDoctorHospitalDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PrescriptionEmrDao prescriptionEmrDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private static String key="bvvsf3JA0mUXMU+mVnMaOQ==";
 | 
	
	
		
			
				|  | @ -1498,7 +1499,7 @@ public class XzzxEntranceService{
 | 
	
		
			
				|  |  |                 "\" ID=\""+patientAndDoctor.getString("PATIENT_ID")+
 | 
	
		
			
				|  |  |                 "\" VISIT_ID=\"0\" PATIENT_PRES_ID=\""+patientAndDoctor.getString("PATIENT_PRES_ID")+
 | 
	
		
			
				|  |  |                 "\" BIRTH=\""+patientAndDoctor.getString("BIRTH")+
 | 
	
		
			
				|  |  |                 "\" HEIGHT=\"0\" WEIGHT=\"0\" GENDER=\""+patientAndDoctor.getString("GENDER")+
 | 
	
		
			
				|  |  |                 "\" HEIGHT=\"\" WEIGHT=\"\" GENDER=\""+patientAndDoctor.getString("GENDER")+
 | 
	
		
			
				|  |  |                 "\" PREGNANT=\"\" LACT=\"否\" HEPATICAL=\"\" RENAL=\"\" PANCREAS=\"\" ALERGY_DRUGS=\"\" IDENTITY_TYPE=\"\" FEE_TYPE=\""+patientAndDoctor.getString("FEE_TYPE")+
 | 
	
		
			
				|  |  |                 "\" SCR=\"\" SCR_UNIT=\"\" 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" +
 | 
	
	
		
			
				|  | @ -1516,7 +1517,7 @@ public class XzzxEntranceService{
 | 
	
		
			
				|  |  |                         " DEPT_CODE=\""+patientAndDoctor.getString("DEPT_CODE")+"\" DOCTOR_NAME=\""+patientAndDoctor.getString("DOCTOR_NAME")+
 | 
	
		
			
				|  |  |                         "\" ORDER_NO=\""+i+
 | 
	
		
			
				|  |  |                         "\" ORDER_SUB_NO=\""+1+"\" AUTHORITY_LEVELS=\"\" ALERT_LEVELS=\"\" TITLE=\""+patientAndDoctor.getString("POSITION") +
 | 
	
		
			
				|  |  |                         "\" GROUP_ID=\""+wlyyPrescriptionInfoDO.getFrequency()+"\" USER_ID=\""+patientAndDoctor.getString("doctorId")+
 | 
	
		
			
				|  |  |                         "\" GROUP_ID=\""+i+"\" USER_ID=\""+patientAndDoctor.getString("DOCTOR_ID")+
 | 
	
		
			
				|  |  |                         "\" PRES_ID=\""+patientAndDoctor.getString("PATIENT_PRES_ID")+
 | 
	
		
			
				|  |  |                         "\" PRES_DATE=\""+patientAndDoctor.getString("CREATE_DATE")+
 | 
	
		
			
				|  |  |                         "\" PRES_SEQ_ID=\""+patientAndDoctor.getString("PATIENT_PRES_ID")+
 | 
	
	
		
			
				|  | @ -1652,7 +1653,85 @@ public class XzzxEntranceService{
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return personInfoVOS;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 同步门诊病历
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String returnEmrHtmlByHLW(JSONObject jsonObject,WlyyPrescriptionEmrDO prescriptionEmrDO)throws Exception{
 | 
	
		
			
				|  |  |         String api = "returnEmrHtmlByHLW";
 | 
	
		
			
				|  |  |         String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
 | 
	
		
			
				|  |  |                 "<root> " +
 | 
	
		
			
				|  |  |                 "   <serverName>"+api+"</serverName>  " +
 | 
	
		
			
				|  |  |                 "   <format>xml</format>" +
 | 
	
		
			
				|  |  |                 "   <callOperator></callOperator> " +
 | 
	
		
			
				|  |  |                 "   <certificate>"+key+"</certificate> " +
 | 
	
		
			
				|  |  |                 "</root>";
 | 
	
		
			
				|  |  |         String condition ="";
 | 
	
		
			
				|  |  |         String htmlDeo = "";
 | 
	
		
			
				|  |  |         if (null!=prescriptionEmrDO){
 | 
	
		
			
				|  |  |             WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("EMRHTMLDEMO");
 | 
	
		
			
				|  |  |             if (null!=wlyyHospitalSysDictDO){
 | 
	
		
			
				|  |  |                 htmlDeo = wlyyHospitalSysDictDO.getDictValue();
 | 
	
		
			
				|  |  |                 htmlDeo = htmlDeo.replace("@patientName@",jsonObject.getString("patientName"));
 | 
	
		
			
				|  |  |                 htmlDeo = htmlDeo.replace("@patientAge@",jsonObject.getString("patientAge"));
 | 
	
		
			
				|  |  |                 htmlDeo = htmlDeo.replace("@patientsex@",jsonObject.getString("patientsex"));
 | 
	
		
			
				|  |  |                 htmlDeo = htmlDeo.replace("@deptCode@",jsonObject.getString("deptCode"));
 | 
	
		
			
				|  |  |                 htmlDeo = htmlDeo.replace("@r+outpatientCode@",jsonObject.getString("outpatientCode"));
 | 
	
		
			
				|  |  |                 htmlDeo = htmlDeo.replace("@patientClan@",jsonObject.getString("patientClan"));
 | 
	
		
			
				|  |  |                 htmlDeo = htmlDeo.replace("@Special@",prescriptionEmrDO.getSpecialHistory());
 | 
	
		
			
				|  |  |                 SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd hh:MM");
 | 
	
		
			
				|  |  |                 htmlDeo = htmlDeo.replace("@createTime@",sf.format(prescriptionEmrDO.getCreateTime()));
 | 
	
		
			
				|  |  |                 htmlDeo = htmlDeo.replace("@complaint@",prescriptionEmrDO.getComplaint());
 | 
	
		
			
				|  |  |                 htmlDeo = htmlDeo.replace("@medicalHistory@",prescriptionEmrDO.getMedicalHistory());
 | 
	
		
			
				|  |  |                 htmlDeo = htmlDeo.replace("@popularHistory@",prescriptionEmrDO.getPopularHistory());
 | 
	
		
			
				|  |  |                 htmlDeo = htmlDeo.replace("@pastHistory@",prescriptionEmrDO.getPastHistory());
 | 
	
		
			
				|  |  |                 htmlDeo = htmlDeo.replace("@allergicHistory@",prescriptionEmrDO.getAllergicHistory());
 | 
	
		
			
				|  |  |                 htmlDeo = htmlDeo.replace("@physicalExamination@",prescriptionEmrDO.getPhysicalExamination());
 | 
	
		
			
				|  |  |                 htmlDeo = htmlDeo.replace("@assistExamination@",prescriptionEmrDO.getAssistExamination());
 | 
	
		
			
				|  |  |                 condition+="<content>"+htmlDeo+"</content>";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if ( null!=jsonObject.get("patientid")) {
 | 
	
		
			
				|  |  |             condition+="<patientid>"+jsonObject.getString("patientid")+"</patientid>";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if ( null!=jsonObject.get("eventno")) {
 | 
	
		
			
				|  |  |             condition+="<eventno>"+jsonObject.getString("eventno")+"</eventno>";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if ( null!=jsonObject.get("type")) {
 | 
	
		
			
				|  |  |             condition+="<type>"+jsonObject.getString("type")+"</type>";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if ( null!=jsonObject.get("templateid")) {
 | 
	
		
			
				|  |  |             condition+="<templateid>"+jsonObject.getString("templateid")+"</templateid>";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if ( null!=jsonObject.get("emrtitle")) {
 | 
	
		
			
				|  |  |             condition+="<emrtitle>"+jsonObject.getString("emrtitle")+"</emrtitle>";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (null!=jsonObject.get("catalogid")){
 | 
	
		
			
				|  |  |             condition += "<catalogid>"+jsonObject.getString("catalogid")+"</catalogid>";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (null!=jsonObject.get("operatorname")){
 | 
	
		
			
				|  |  |             condition += "<operatorname>"+jsonObject.getString("operatorname")+"</operatorname>";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (null!=jsonObject.get("operatorid")){
 | 
	
		
			
				|  |  |             condition += "<operatorid>"+jsonObject.getString("operatorid")+"</operatorid>";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (null!=jsonObject.get("emrtype")){
 | 
	
		
			
				|  |  |             condition += "<emrtype>"+jsonObject.getString("emrtype")+"</emrtype>";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (null!=jsonObject.get("id")){
 | 
	
		
			
				|  |  |             condition += "<id>"+jsonObject.getString("id")+"</id>";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
 | 
	
		
			
				|  |  |                 "<root>"+condition+"</root>";
 | 
	
		
			
				|  |  |         Map<String,String> params = new HashedMap();
 | 
	
		
			
				|  |  |         params.put("msgHeader",msgHeader);
 | 
	
		
			
				|  |  |         params.put("msgBody",msgBody);
 | 
	
		
			
				|  |  |         logger.info("returnEmrHtmlByHLW params:"+params.toString());
 | 
	
		
			
				|  |  |         String xml = getXzzxWebServiceInfo("CallInterface",params,getOperateUrl());
 | 
	
		
			
				|  |  |         logger.info("returnEmrHtmlByHLW json:"+xml);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return xml;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | //=====================微信模板消息推送===================================
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public String sendMes(String wxId,String patient,String cardNo,String first,String noticeContent,String remark,String redirectUrl){
 | 
	
	
		
			
				|  | @ -2986,6 +3065,66 @@ public Map checkSyncHis(String IoFlag,String PayCardNo,String NullahNumber,Strin
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return jsonObject;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 保存电子病历
 | 
	
		
			
				|  |  |      * @param prescriptionId 处方id
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONObject saveEmrToEntrance(String prescriptionId) throws Exception {
 | 
	
		
			
				|  |  |         Map<String,String> params = new HashedMap();
 | 
	
		
			
				|  |  |         WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(prescriptionId);
 | 
	
		
			
				|  |  |         JSONObject paramRequest = new JSONObject();
 | 
	
		
			
				|  |  |         if (null!=wlyyPrescriptionDO){
 | 
	
		
			
				|  |  |             paramRequest.put("patientName",wlyyPrescriptionDO.getPatientName());
 | 
	
		
			
				|  |  |             PatientMappingDO patientMappingDO =  patientMappingDao.findByPatient(wlyyPrescriptionDO.getPatientCode());
 | 
	
		
			
				|  |  |             BasePatientDO basePatientDO = basePatientDao.findById(wlyyPrescriptionDO.getPatientCode());
 | 
	
		
			
				|  |  |             DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(wlyyPrescriptionDO.getDoctor());
 | 
	
		
			
				|  |  |             WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(wlyyPrescriptionDO.getOutpatientId());
 | 
	
		
			
				|  |  |             if(null!=patientMappingDO){
 | 
	
		
			
				|  |  |                 paramRequest.put("patientid",patientMappingDO.getMappingCode());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if(null!=doctorMappingDO){
 | 
	
		
			
				|  |  |                 paramRequest.put("operatorid",doctorMappingDO.getMappingCode());
 | 
	
		
			
				|  |  |                 paramRequest.put("operatorname",wlyyPrescriptionDO.getDoctorName());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             paramRequest.put("type","2");
 | 
	
		
			
				|  |  |             WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO =  prescriptionEmrDao.findEmrByPrescriptionId(prescriptionId);
 | 
	
		
			
				|  |  |             if (null!=wlyyPrescriptionEmrDO){
 | 
	
		
			
				|  |  |                 paramRequest.put("id",wlyyPrescriptionEmrDO.getId());
 | 
	
		
			
				|  |  |                 params.put("emrInfo",JSON.toJSONString(wlyyPrescriptionEmrDO));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (null!=basePatientDO){
 | 
	
		
			
				|  |  |                 paramRequest.put("patientAge",IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard()));
 | 
	
		
			
				|  |  |                 paramRequest.put("patientsex",IdCardUtil.getSexForIdcard(basePatientDO.getIdcard()));
 | 
	
		
			
				|  |  |                 paramRequest.put("patientName",basePatientDO.getName());
 | 
	
		
			
				|  |  |                 paramRequest.put("patientClan","0");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (null!=wlyyOutpatientDO){
 | 
	
		
			
				|  |  |                 paramRequest.put("deptCode",wlyyOutpatientDO.getDept());
 | 
	
		
			
				|  |  |                 paramRequest.put("outpatientCode","R"+wlyyOutpatientDO.getRegisterNo());
 | 
	
		
			
				|  |  |                 paramRequest.put("eventno","R"+wlyyOutpatientDO.getRegisterNo());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             paramRequest.put("templateid","662");
 | 
	
		
			
				|  |  |             paramRequest.put("catalogid","50");
 | 
	
		
			
				|  |  |             paramRequest.put("emrtype","0");
 | 
	
		
			
				|  |  |             paramRequest.put("emrtitle","互联网医院");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         params.put("jsonInfo",paramRequest.toJSONString());
 | 
	
		
			
				|  |  |         JSONObject jsonObject = new JSONObject();
 | 
	
		
			
				|  |  |         String response = "";
 | 
	
		
			
				|  |  |         String url = entranceUrl+"returnEmrHtmlByHLW";
 | 
	
		
			
				|  |  |         logger.info("params"+params.toString());
 | 
	
		
			
				|  |  |         response = httpClientUtil.httpPost(url,params);
 | 
	
		
			
				|  |  |         logger.info("保存电子病历"+response);
 | 
	
		
			
				|  |  |         JSONObject object = JSONObject.parseObject(response);
 | 
	
		
			
				|  |  |         if(object.getInteger("status")==200){
 | 
	
		
			
				|  |  |             jsonObject = object.getJSONObject("obj");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return jsonObject;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | //=====================hospital应用调用entrance应用============end=================
 | 
	
		
			
				|  |  | 
 |