|  | @ -671,8 +671,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 //取药类型:1 自取 2快递配送
 | 
	
		
			
				|  |  |                 sql = "UPDATE base.wlyy_prescription p SET p.`status`='100',p.pay_status='1' WHERE p.adm_no='" + admNo + "' AND p.real_order='" + realOrder + "' ";
 | 
	
		
			
				|  |  |                 //变更门诊状态
 | 
	
		
			
				|  |  |                 outPatientSql = "UPDATE base.wlyy_outpatient p SET p.`status`='2' WHERE p.adm_no='" + admNo + "'";
 | 
	
		
			
				|  |  |                 jdbcTemplate.execute(outPatientSql);
 | 
	
		
			
				|  |  | //                outPatientSql = "UPDATE base.wlyy_outpatient p SET p.`status`='2' WHERE p.adm_no='" + admNo + "'";
 | 
	
		
			
				|  |  | //                jdbcTemplate.execute(outPatientSql);d
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 //取药类型:1 自取 2快递配送
 | 
	
		
			
				|  |  |                 sql = "UPDATE base.wlyy_prescription p SET p.`status`='32',p.pay_status='1' WHERE p.adm_no='" + admNo + "' AND p.real_order='" + realOrder + "' ";
 | 
	
	
		
			
				|  | @ -1043,7 +1043,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //查找居民当天挂号记录
 | 
	
		
			
				|  |  |         String date = DateUtil.dateToStr(new Date(),"yyyy-MM-dd");
 | 
	
		
			
				|  |  |         List<WlyyPatientRegisterDO>  patientRegisterDOs = patientRegisterDao.findByPatientAndDate(outpatientDO.getPatient(),date);
 | 
	
		
			
				|  |  |         List<WlyyPatientRegisterDO>  patientRegisterDOs = patientRegisterDao.findByPatientAndDateAndDoctor(outpatientDO.getPatient(),date,doctor);
 | 
	
		
			
				|  |  |         if(patientRegisterDOs!=null&&patientRegisterDOs.size()>0){
 | 
	
		
			
				|  |  |             WlyyPatientRegisterDO registerDO = patientRegisterDOs.get(0);
 | 
	
		
			
				|  |  |             //判断是否已经挂号,如果已经挂号
 | 
	
	
		
			
				|  | @ -1081,8 +1081,15 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //存储就诊记录
 | 
	
		
			
				|  |  |             WlyyPatientRegisterDO registerDO = new WlyyPatientRegisterDO();
 | 
	
		
			
				|  |  |             // 存储挂号医生与挂号科室
 | 
	
		
			
				|  |  |             registerDO.setDoctor(outpatientDO.getDoctor());
 | 
	
		
			
				|  |  |             registerDO.setDoctorName(outpatientDO.getDoctorName());
 | 
	
		
			
				|  |  |             registerDO.setDept(outpatientDO.getDept());
 | 
	
		
			
				|  |  |             registerDO.setDeptName(outpatientDO.getDeptName());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             registerDO.setPatient(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |             registerDO.setPatientName(outpatientDO.getPatientName());
 | 
	
		
			
				|  |  |             //挂号流水号与挂号次数
 | 
	
		
			
				|  |  |             registerDO.setRegisterNo(serialNo);
 | 
	
		
			
				|  |  |             registerDO.setConNo(conNo);
 | 
	
		
			
				|  |  |             registerDO.setCreateTime(new Date());
 | 
	
	
		
			
				|  | @ -1100,6 +1107,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //存储就诊记录
 | 
	
		
			
				|  |  |             WlyyPatientRegisterDO registerDO = new WlyyPatientRegisterDO();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             registerDO.setDoctor(outpatientDO.getDoctor());
 | 
	
		
			
				|  |  |             registerDO.setDoctorName(outpatientDO.getDoctorName());
 | 
	
		
			
				|  |  |             registerDO.setDept(outpatientDO.getDept());
 | 
	
		
			
				|  |  |             registerDO.setDeptName(outpatientDO.getDeptName());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             registerDO.setPatient(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |             registerDO.setPatientName(outpatientDO.getPatientName());
 | 
	
		
			
				|  |  |             registerDO.setRegisterNo(serialNo);
 | 
	
	
		
			
				|  | @ -1260,8 +1273,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //获取门诊记录
 | 
	
		
			
				|  |  |         WlyyOutpatientDO outpatientDO = outpatientDao.findOne(outPatientId);
 | 
	
		
			
				|  |  |         //设置医嘱
 | 
	
		
			
				|  |  |         outpatientDO.setAdvice(advice);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //========================处方操作=============================================================
 | 
	
		
			
				|  |  |         //创建处方记录
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionDO> prescriptionDOs = prescriptionDao.findByOutpatientId(outPatientId);
 | 
	
		
			
				|  |  |         WlyyPrescriptionDO prescriptionDO = null;
 | 
	
	
		
			
				|  | @ -1279,10 +1294,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         prescriptionDO.setDoctorName(outpatientDO.getDoctorName());
 | 
	
		
			
				|  |  |         WlyyPrescriptionDO prescription = prescriptionDao.save(prescriptionDO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //========================处方操作结束=============================================================
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //加入处方状态变更流水日志
 | 
	
		
			
				|  |  |         prescriptionLogService.addPrescriptionLog(prescription.getId(),10,2,outpatientDO.getDoctor(),outpatientDO.getDoctorName(),"",new Date());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //下诊断
 | 
	
		
			
				|  |  |         //============================下诊断==============================================================
 | 
	
		
			
				|  |  |         //删除之前诊断
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionDiagnosisDO> ds = prescriptionDiagnosisDao.findByPrescriptionId(prescription.getId());
 | 
	
		
			
				|  |  |         if(ds!=null&&ds.size()>0){
 | 
	
	
		
			
				|  | @ -1304,11 +1321,13 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         prescriptionDiagnosisDao.save(diagnosisDOs);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //存储icd10
 | 
	
		
			
				|  |  |         Icd10 = Icd10.substring(0,Icd10.length()-1);
 | 
	
		
			
				|  |  |         Icd10Name = Icd10Name.substring(0,Icd10Name.length()-1);
 | 
	
		
			
				|  |  |         outpatientDO.setIcd10(Icd10);
 | 
	
		
			
				|  |  |         outpatientDO.setIcd10Name(Icd10Name);
 | 
	
		
			
				|  |  |         outpatientDao.save(outpatientDO);
 | 
	
		
			
				|  |  |         //============================下诊断end==============================================================
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //判断是否有检查检验或药品开方
 | 
	
		
			
				|  |  |         if("1".equals(type)){
 | 
	
	
		
			
				|  | @ -1319,15 +1338,16 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 throw new RuntimeException("未找到医生映射信息");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //删除原有药品信息
 | 
	
		
			
				|  |  |             //his处方拼接开方条件
 | 
	
		
			
				|  |  |             com.alibaba.fastjson.JSONArray jsonData = new com.alibaba.fastjson.JSONArray();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //===================药品操作======================================================
 | 
	
		
			
				|  |  |             // 删除原有药品信息
 | 
	
		
			
				|  |  |             List<WlyyPrescriptionInfoDO> oldInfos = prescriptionInfoDao.findByPrescriptionId(prescription.getId());
 | 
	
		
			
				|  |  |             if(oldInfos!=null&&oldInfos.size()>0){
 | 
	
		
			
				|  |  |                 prescriptionInfoDao.delete(oldInfos);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //his处方拼接开方条件
 | 
	
		
			
				|  |  |             com.alibaba.fastjson.JSONArray jsonData = new com.alibaba.fastjson.JSONArray();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //存储药品,构建his开方入参
 | 
	
		
			
				|  |  |             if(StringUtils.isNotBlank(infoJsons)){
 | 
	
		
			
				|  |  |                 //药品
 | 
	
	
		
			
				|  | @ -1340,16 +1360,20 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                     //设置his药品查询条件
 | 
	
		
			
				|  |  |                     setInfoJsonParam(jsonData,doctorMappingDO,outpatientDO,prescriptionDO,info,Icd10);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 //保存处方
 | 
	
		
			
				|  |  |                 //保存药品信息
 | 
	
		
			
				|  |  |                 prescriptionInfoDao.save(infoDOs);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //=====================药品操作=======================================================================
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //=====================检查检验=======================================================================
 | 
	
		
			
				|  |  |             //存储检查检验,构建his开方入参
 | 
	
		
			
				|  |  |             //删除之前检查检验
 | 
	
		
			
				|  |  |             List<WlyyInspectionDO> inspectionDels = wlyyInspectionDao.findByOutpatientId(outPatientId);
 | 
	
		
			
				|  |  |             if(inspectionDels!=null&&inspectionDels.size()>0){
 | 
	
		
			
				|  |  |                 wlyyInspectionDao.delete(inspectionDels);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //存储检查检验,构建his开方入参
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if(StringUtils.isNotBlank(inspectionJson)){
 | 
	
		
			
				|  |  |                 List<WlyyInspectionDO> inspections = (List<WlyyInspectionDO>) com.alibaba.fastjson.JSONArray.parseArray(inspectionJson, WlyyInspectionDO.class);
 | 
	
		
			
				|  |  |                 for(WlyyInspectionDO ins:inspections){
 | 
	
	
		
			
				|  | @ -1364,11 +1388,13 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 //保存检查检验。
 | 
	
		
			
				|  |  |                 wlyyInspectionDao.save(inspections);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //=====================检查检验=======================================================================
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //上传his开方
 | 
	
		
			
				|  |  |             return sendHisDiagnosis(jsonData,outpatientDO,prescription);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             //
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             outpatientDO.setStatus("2");
 | 
	
		
			
				|  |  |             outpatientDao.save(outpatientDO);
 | 
	
		
			
				|  |  |             result.put("code",1);
 |