|  | @ -1059,6 +1059,77 @@ public class YkyyEntranceService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 根据身份证查找his医生
 | 
	
		
			
				|  |  |      * @param idcard
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONArray findHisDoctor(String idcard) throws Exception{
 | 
	
		
			
				|  |  |         String sql ="select y.code AS \"code\",y.ygbh,y.name AS \"name\",y.expertise AS \"expertise\",y.introduce AS \"introduce\",y.mobile AS \"mobile\",y.idCard AS \"idcard\",y.jobtitlecode AS \"jobTitleCode\",y.jobTitleName AS \"jobTitleName\",y.dept AS \"dept\",y.deptName AS \"deptName\" from v_Hlw_Ysxx y where y.idcard ='"+idcard+"'";
 | 
	
		
			
				|  |  |         JSONArray array = new JSONArray();
 | 
	
		
			
				|  |  |         Map<String,Object> params = new HashedMap();
 | 
	
		
			
				|  |  |         params.put("sql",sql);
 | 
	
		
			
				|  |  |         logger.info("idcard:"+sql);
 | 
	
		
			
				|  |  |         HttpResponse response = HttpUtils.doGet(url,params);
 | 
	
		
			
				|  |  |         String content = response.getContent();
 | 
	
		
			
				|  |  |         logger.info("response:"+content);
 | 
	
		
			
				|  |  |         JSONObject rs = JSON.parseObject(content);
 | 
	
		
			
				|  |  |         Integer status = rs.getInteger("status");
 | 
	
		
			
				|  |  |         if (status==200){
 | 
	
		
			
				|  |  |             array = rs.getJSONArray("detailModelList");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return array;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 根据his Icd10
 | 
	
		
			
				|  |  |      * @param code
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONArray findHisIcd10(String code) throws Exception{
 | 
	
		
			
				|  |  |         String sql ="select v.code,v.name,v.flag from V_HLW_ICD10 v WHERE v.code = '"+code+"'";
 | 
	
		
			
				|  |  |         JSONArray array = new JSONArray();
 | 
	
		
			
				|  |  |         Map<String,Object> params = new HashedMap();
 | 
	
		
			
				|  |  |         params.put("sql",sql);
 | 
	
		
			
				|  |  |         logger.info("sql:"+sql);
 | 
	
		
			
				|  |  |         HttpResponse response = HttpUtils.doGet(url,params);
 | 
	
		
			
				|  |  |         String content = response.getContent();
 | 
	
		
			
				|  |  |         logger.info("response:"+content);
 | 
	
		
			
				|  |  |         JSONObject rs = JSON.parseObject(content);
 | 
	
		
			
				|  |  |         Integer status = rs.getInteger("status");
 | 
	
		
			
				|  |  |         if (status==200){
 | 
	
		
			
				|  |  |             array = rs.getJSONArray("detailModelList");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return array;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 查找挂号明细
 | 
	
		
			
				|  |  |      * @param patient
 | 
	
		
			
				|  |  |      * @param doctor
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONArray fingHlwGhmx(String patient,String doctor) throws Exception{
 | 
	
		
			
				|  |  |         String sql = "select v.SBXH,to_char(v.ghsj,'yyyy-mm-dd hh24:mi:ss') as GHSJ from v_hlw_ghmx v where v.brid = '"+patient+"' and v.ysdm =" +
 | 
	
		
			
				|  |  |                 " '"+doctor+"' and v.ghsj > to_date('"+DateUtil.dateToStrLong(DateUtil.getToday())+"','yyyy-MM-dd HH24:mi:ss')";
 | 
	
		
			
				|  |  |         JSONArray array = new JSONArray();
 | 
	
		
			
				|  |  |         Map<String,Object> params = new HashedMap();
 | 
	
		
			
				|  |  |         params.put("sql",sql);
 | 
	
		
			
				|  |  |         logger.info("sql:"+sql);
 | 
	
		
			
				|  |  |         HttpResponse response = HttpUtils.doGet(url,params);
 | 
	
		
			
				|  |  |         String content = response.getContent();
 | 
	
		
			
				|  |  |         logger.info("response:"+content);
 | 
	
		
			
				|  |  |         JSONObject rs = JSON.parseObject(content);
 | 
	
		
			
				|  |  |         Integer status = rs.getInteger("status");
 | 
	
		
			
				|  |  |         if (status==200){
 | 
	
		
			
				|  |  |             array = rs.getJSONArray("detailModelList");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return array;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 诊断
 | 
	
	
		
			
				|  | @ -1074,7 +1145,6 @@ public class YkyyEntranceService {
 | 
	
		
			
				|  |  |         //挂号明细表HLW_GHMX
 | 
	
		
			
				|  |  |         HlwGhmxDO hlwGhmxDO = new HlwGhmxDO();
 | 
	
		
			
				|  |  |         hlwGhmxDO.setSBXH(0);
 | 
	
		
			
				|  |  |         hlwGhmxDO.setJZXH(1);
 | 
	
		
			
				|  |  |         hlwGhmxDO.setGHCS(1);
 | 
	
		
			
				|  |  |         hlwGhmxDO.setGHJE(0);
 | 
	
		
			
				|  |  |         hlwGhmxDO.setZLJE(0);
 | 
	
	
		
			
				|  | @ -1091,52 +1161,74 @@ public class YkyyEntranceService {
 | 
	
		
			
				|  |  |         hlwGhmxDO.setYSPB(0);
 | 
	
		
			
				|  |  |         hlwGhmxDO.setSFFS(0);
 | 
	
		
			
				|  |  |         hlwGhmxDO.setJZZT(2);
 | 
	
		
			
				|  |  |         hlwGhmxDO.setJZXH(0);
 | 
	
		
			
				|  |  |         hlwGhmxDO.setKSDM(wlyyPrescriptionVO.getDept());
 | 
	
		
			
				|  |  |         hlwGhmxDO.setBRID(Integer.parseInt(patientMappingDO.getMappingCode()));
 | 
	
		
			
				|  |  |         hlwGhmxDO.setGHSJ(DateUtil.strToDate(DateUtil.dateToStr(wlyyPrescriptionVO.getCreateTime(),"yyyy-MM-dd HH:mm:ss")));//挂号时间
 | 
	
		
			
				|  |  |         hlwGhmxDO.setGHLB(1);//挂号类别
 | 
	
		
			
				|  |  |         hlwGhmxDO.setYSDM(doctorMappingDO.getMappingCode());//医生代码
 | 
	
		
			
				|  |  |         hlwGhmxDO.setJZYS(doctorMappingDO.getMappingCode());//接诊医生
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(wlyyPrescriptionVO.getAdmNo())){
 | 
	
		
			
				|  |  |             hlwGhmxDO.setJZXH(Integer.parseInt(wlyyPrescriptionVO.getAdmNo()));
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         hlwGhmxDO.setKSDM(wlyyPrescriptionVO.getDept());
 | 
	
		
			
				|  |  |         hlwGhmxDO.setBRID(Integer.parseInt(patientMappingDO.getMappingCode()));
 | 
	
		
			
				|  |  |         String jsonString = JSONObject.toJSONString(hlwGhmxDO);
 | 
	
		
			
				|  |  |         Map<String,Object> params = new HashedMap();
 | 
	
		
			
				|  |  |         params.put("json",jsonString);
 | 
	
		
			
				|  |  |         params.put("table","HlwGhmxDO");
 | 
	
		
			
				|  |  |         logger.info("HlwGhmxDO:"+jsonString);
 | 
	
		
			
				|  |  |         HttpResponse response = HttpUtils.doGet(saveUrl,params);
 | 
	
		
			
				|  |  |         if (response.getStatus()==200){
 | 
	
		
			
				|  |  |             String content = response.getContent();
 | 
	
		
			
				|  |  |             logger.info("content"+content);
 | 
	
		
			
				|  |  |             JSONObject jsonObject = JSONObject.parseObject(content);
 | 
	
		
			
				|  |  |             JSONObject object = jsonObject.getJSONObject("obj");
 | 
	
		
			
				|  |  |             if (object!=null){
 | 
	
		
			
				|  |  |                 GHXH = object.getInteger("sbxh");
 | 
	
		
			
				|  |  |                 logger.info("GHXH=========="+GHXH);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             logger.info("表hlwGhmxDO同步成功!");
 | 
	
		
			
				|  |  |         //病人性质
 | 
	
		
			
				|  |  |         JSONArray jsonArray = findHisPatient(patientMappingDO.getIdcard());
 | 
	
		
			
				|  |  |         if(jsonArray!=null&&jsonArray.size()>0){
 | 
	
		
			
				|  |  |             //获取居民信息
 | 
	
		
			
				|  |  |             JSONObject json = jsonArray.getJSONObject(0);
 | 
	
		
			
				|  |  |             hlwGhmxDO.setBRXZ(json.getInteger("brxz"));
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //就诊历史表HLWYS_MZ_JZLS
 | 
	
		
			
				|  |  |         HlwYsMzJzLsDO hlwYsMzJzLsDO = new HlwYsMzJzLsDO();
 | 
	
		
			
				|  |  |         hlwYsMzJzLsDO.setJZXH(0);
 | 
	
		
			
				|  |  |         hlwYsMzJzLsDO.setGHXH(GHXH);
 | 
	
		
			
				|  |  |         hlwYsMzJzLsDO.setBRBH(Integer.parseInt(patientMappingDO.getMappingCode()));
 | 
	
		
			
				|  |  |         hlwYsMzJzLsDO.setKSDM(Integer.parseInt(wlyyPrescriptionVO.getDept()));
 | 
	
		
			
				|  |  |         hlwYsMzJzLsDO.setYSDM(doctorMappingDO.getMappingCode());
 | 
	
		
			
				|  |  |         hlwYsMzJzLsDO.setKSSJ(DateUtil.strToDate(DateUtil.dateToStr(wlyyPrescriptionVO.getCreateTime(),"yyyy-MM-dd HH:mm:ss")));
 | 
	
		
			
				|  |  |         hlwYsMzJzLsDO.setJZZT(9);
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(wlyyPrescriptionVO.getAdmNo())){
 | 
	
		
			
				|  |  |             hlwYsMzJzLsDO.setJZXH(Integer.parseInt(wlyyPrescriptionVO.getAdmNo()));
 | 
	
		
			
				|  |  |         //操作工号
 | 
	
		
			
				|  |  |         JSONArray jsonArray1 = findHisDoctor(doctorMappingDO.getIdcard());
 | 
	
		
			
				|  |  |         if(jsonArray1!=null&&jsonArray1.size()>0){
 | 
	
		
			
				|  |  |             //获取居民信息
 | 
	
		
			
				|  |  |             JSONObject json = jsonArray1.getJSONObject(0);
 | 
	
		
			
				|  |  |             hlwGhmxDO.setBRXZ(json.getInteger("YGBH"));
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String jsonString2 = JSONObject.toJSONString(hlwYsMzJzLsDO);
 | 
	
		
			
				|  |  |         Map<String,Object> params2 = new HashedMap();
 | 
	
		
			
				|  |  |         params2.put("json",jsonString2);
 | 
	
		
			
				|  |  |         params2.put("table","HlwYsMzJzLsDO");
 | 
	
		
			
				|  |  |         logger.info("HlwYsMzJzLsDO:"+jsonString2);
 | 
	
		
			
				|  |  |         HttpResponse response2 = HttpUtils.doGet(saveUrl,params2);
 | 
	
		
			
				|  |  |         if (response2.getStatus()==200){
 | 
	
		
			
				|  |  |             logger.info("content"+response2.getContent());
 | 
	
		
			
				|  |  |             logger.info("表hlwYsMzJzLsDO同步成功!");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         // 同一个医生同一个病人,一天一条挂号记录。
 | 
	
		
			
				|  |  |         JSONArray ja = fingHlwGhmx(patientMappingDO.getMappingCode(),doctorMappingDO.getMappingCode());
 | 
	
		
			
				|  |  |         if(ja!=null&&ja.size()>0){
 | 
	
		
			
				|  |  |             //更新
 | 
	
		
			
				|  |  |             JSONObject json = ja.getJSONObject(0);
 | 
	
		
			
				|  |  |             hlwGhmxDO.setSBXH(json.getInteger("SBXH"));
 | 
	
		
			
				|  |  |             hlwGhmxDO.setGHSJ(DateUtil.strToDate(json.getString("GHSJ")));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String jsonString = JSONObject.toJSONString(hlwGhmxDO);
 | 
	
		
			
				|  |  |             Map<String,Object> params = new HashedMap();
 | 
	
		
			
				|  |  |             params.put("json",jsonString);
 | 
	
		
			
				|  |  |             params.put("table","HlwGhmxDO");
 | 
	
		
			
				|  |  |             logger.info("HlwGhmxDO:"+jsonString);
 | 
	
		
			
				|  |  |             HttpResponse response = HttpUtils.doGet(updateEntityUrl,params);
 | 
	
		
			
				|  |  |             if (response.getStatus()==200){
 | 
	
		
			
				|  |  |                 logger.info("content"+response.getContent());
 | 
	
		
			
				|  |  |                 logger.info("表hlwGhmxDo更新成功!");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 logger.info("表hlwGhmxDo更新失败!"+response.getErrorMsg());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             //新增
 | 
	
		
			
				|  |  |             String jsonString = JSONObject.toJSONString(hlwGhmxDO);
 | 
	
		
			
				|  |  |             Map<String,Object> params = new HashedMap();
 | 
	
		
			
				|  |  |             params.put("json",jsonString);
 | 
	
		
			
				|  |  |             params.put("table","HlwGhmxDO");
 | 
	
		
			
				|  |  |             logger.info("HlwGhmxDO:"+jsonString);
 | 
	
		
			
				|  |  |             HttpResponse response = HttpUtils.doGet(saveUrl,params);
 | 
	
		
			
				|  |  |             if (response.getStatus()==200){
 | 
	
		
			
				|  |  |                 String content = response.getContent();
 | 
	
		
			
				|  |  |                 logger.info("content"+content);
 | 
	
		
			
				|  |  |                 JSONObject jsonObject = JSONObject.parseObject(content);
 | 
	
		
			
				|  |  |                 JSONObject object = jsonObject.getJSONObject("obj");
 | 
	
		
			
				|  |  |                 if (object!=null){
 | 
	
		
			
				|  |  |                     GHXH = object.getInteger("sbxh");
 | 
	
		
			
				|  |  |                     logger.info("GHXH=========="+GHXH);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 logger.info("表hlwGhmxDo新增成功!");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Integer icd10Flag = 0;
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionDiagnosisDO> diagnosisDOs = prescriptionDiagnosisDao.findByPrescriptionId(wlyyPrescriptionVO.getId());
 | 
	
		
			
				|  |  |         for (WlyyPrescriptionDiagnosisDO diagnosisDO : diagnosisDOs){
 | 
	
		
			
				|  |  |             //疾病诊断表HLWYS_MZ_JBZD
 | 
	
	
		
			
				|  | @ -1149,6 +1241,23 @@ public class YkyyEntranceService {
 | 
	
		
			
				|  |  |             hlwYsMzJbzdDO.setYSDM(doctorMappingDO.getMappingCode());
 | 
	
		
			
				|  |  |             hlwYsMzJbzdDO.setICD(diagnosisDO.getCode());
 | 
	
		
			
				|  |  |             hlwYsMzJbzdDO.setMSZD(diagnosisDO.getName());
 | 
	
		
			
				|  |  |             JSONArray jsonArray2 = findHisIcd10(diagnosisDO.getCode());
 | 
	
		
			
				|  |  |             if(jsonArray2!=null&&jsonArray2.size()>0){
 | 
	
		
			
				|  |  |                 //获取居民信息
 | 
	
		
			
				|  |  |                 JSONObject json = jsonArray2.getJSONObject(0);
 | 
	
		
			
				|  |  |                 icd10Flag = json.getInteger("FLAG");
 | 
	
		
			
				|  |  |                 hlwYsMzJbzdDO.setJBBH(icd10Flag);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             hlwYsMzJbzdDO.setBRBH(Integer.valueOf(patientMappingDO.getMappingCode()));
 | 
	
		
			
				|  |  |             hlwYsMzJbzdDO.setZDLB(11);//诊断类别
 | 
	
		
			
				|  |  |             hlwYsMzJbzdDO.setZDSJ(DateUtil.strToDate(DateUtil.dateToStr(wlyyPrescriptionVO.getCreateTime(),"yyyy-MM-dd HH:mm:ss")));//诊断时间
 | 
	
		
			
				|  |  |             hlwYsMzJbzdDO.setZFPB(0);//作废标志
 | 
	
		
			
				|  |  |             hlwYsMzJbzdDO.setQZBZ(0);//确诊标志
 | 
	
		
			
				|  |  |             hlwYsMzJbzdDO.setQZSJ(DateUtil.strToDate(DateUtil.dateToStr(wlyyPrescriptionVO.getCreateTime(),"yyyy-MM-dd HH:mm:ss")));//确诊时间
 | 
	
		
			
				|  |  |             hlwYsMzJbzdDO.setJBMC(diagnosisDO.getName());//诊断名称
 | 
	
		
			
				|  |  |             hlwYsMzJbzdDO.setZDLX(1);//诊断类型
 | 
	
		
			
				|  |  |             hlwYsMzJbzdDO.setTJBZ(1);//提交标志
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String jsonString1 = JSONObject.toJSONString(hlwYsMzJbzdDO);
 | 
	
		
			
				|  |  |             Map<String,Object> params1 = new HashedMap();
 | 
	
		
			
				|  |  |             params1.put("json",jsonString1);
 | 
	
	
		
			
				|  | @ -1161,6 +1270,35 @@ public class YkyyEntranceService {
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //就诊历史表HLWYS_MZ_JZLS
 | 
	
		
			
				|  |  |         HlwYsMzJzLsDO hlwYsMzJzLsDO = new HlwYsMzJzLsDO();
 | 
	
		
			
				|  |  |         hlwYsMzJzLsDO.setJZXH(0);
 | 
	
		
			
				|  |  |         hlwYsMzJzLsDO.setGHXH(GHXH);
 | 
	
		
			
				|  |  |         hlwYsMzJzLsDO.setBRBH(Integer.parseInt(patientMappingDO.getMappingCode()));
 | 
	
		
			
				|  |  |         hlwYsMzJzLsDO.setKSDM(Integer.parseInt(wlyyPrescriptionVO.getDept()));
 | 
	
		
			
				|  |  |         hlwYsMzJzLsDO.setYSDM(doctorMappingDO.getMappingCode());
 | 
	
		
			
				|  |  |         hlwYsMzJzLsDO.setKSSJ(DateUtil.strToDate(DateUtil.dateToStr(wlyyPrescriptionVO.getCreateTime(),"yyyy-MM-dd HH:mm:ss")));
 | 
	
		
			
				|  |  |         hlwYsMzJzLsDO.setJSSJ(DateUtil.getNight23());
 | 
	
		
			
				|  |  |         hlwYsMzJzLsDO.setJZZT(9);
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(wlyyPrescriptionVO.getAdmNo())){
 | 
	
		
			
				|  |  |             hlwYsMzJzLsDO.setJZXH(Integer.parseInt(wlyyPrescriptionVO.getAdmNo()));
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //V_HLW_ICD10.FLAG
 | 
	
		
			
				|  |  |         hlwYsMzJzLsDO.setZYZD(icd10Flag);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String jsonString2 = JSONObject.toJSONString(hlwYsMzJzLsDO);
 | 
	
		
			
				|  |  |         Map<String,Object> params2 = new HashedMap();
 | 
	
		
			
				|  |  |         params2.put("json",jsonString2);
 | 
	
		
			
				|  |  |         params2.put("table","HlwYsMzJzLsDO");
 | 
	
		
			
				|  |  |         logger.info("HlwYsMzJzLsDO:"+jsonString2);
 | 
	
		
			
				|  |  |         HttpResponse response2 = HttpUtils.doGet(saveUrl,params2);
 | 
	
		
			
				|  |  |         if (response2.getStatus()==200){
 | 
	
		
			
				|  |  |             logger.info("content"+response2.getContent());
 | 
	
		
			
				|  |  |             logger.info("表hlwYsMzJzLsDO同步成功!");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public WlyyPrescriptionVO synPrecriptionHis(WlyyPrescriptionVO wlyyPrescriptionVO,String code) throws Exception {
 |