|  | @ -68,8 +68,6 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private GuidanceMessageLogDao guidanceMessageLogDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private SpecialistPatientRelationDao specialistPatientRelationDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private RehabilitationOperateRecordsDao rehabilitationOperateRecordsDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private RehabilitationDetailAppointmentDao rehabilitationDetailAppointmentDao;
 | 
	
	
		
			
				|  | @ -151,7 +149,7 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public MixEnvelop<Map<String,Object>, Map<String,Object>> findRehabilitationPlan(String doctorCode, String diseaseCode, Integer planType,Integer todaybacklog, String patientCondition,Integer page, Integer pageSize) throws Exception{
 | 
	
		
			
				|  |  |         Integer doctorType =null;
 | 
	
		
			
				|  |  |         BaseDoctorDO doctor = baseDoctorDao.findById(doctorCode);
 | 
	
		
			
				|  |  |         BaseDoctorDO doctor = baseDoctorDao.findById(doctorCode).orElse(null);
 | 
	
		
			
				|  |  |         List<BaseDoctorRoleDO> baseDoctorRoleDO = baseDoctorRoleDao.findByDoctorCode(doctor.getId());
 | 
	
		
			
				|  |  |         for(BaseDoctorRoleDO baseDoctorRoleDO1:baseDoctorRoleDO){
 | 
	
		
			
				|  |  |             if ("specialist".equalsIgnoreCase(baseDoctorRoleDO1.getRoleCode())){
 | 
	
	
		
			
				|  | @ -212,7 +210,7 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  | //                resultMap.put("sex","1".equals(sex)?"男":("2".equals(sex)?"女":"未知"));
 | 
	
		
			
				|  |  |                 resultMap.put("patientName",one.get("patientName"));
 | 
	
		
			
				|  |  |                 resultMap.put("patientCode",one.get("patient"));
 | 
	
		
			
				|  |  |                 patient = basePatientDao.findById(one.get("patient").toString());
 | 
	
		
			
				|  |  |                 patient = basePatientDao.findById(one.get("patient").toString()).orElse(null);
 | 
	
		
			
				|  |  |                 if (patient!=null){
 | 
	
		
			
				|  |  |                     resultMap.put("photo",patient!=null?patient.getPhoto():"");
 | 
	
		
			
				|  |  |                     Integer age = IdCardUtil.getAgeForIdcard(patient.getIdcard());
 | 
	
	
		
			
				|  | @ -398,7 +396,7 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |                 rehabilitationPlanList.add(planMap);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             resultMap.put("rehabilitationPlanList",rehabilitationPlanList);
 | 
	
		
			
				|  |  |             BasePatientDO p = basePatientDao.findById(patientCode);
 | 
	
		
			
				|  |  |             BasePatientDO p = basePatientDao.findById(patientCode).orElse(null);
 | 
	
		
			
				|  |  |             resultMap.put("patientPhoto",p.getPhoto());
 | 
	
		
			
				|  |  |             resultList.add(resultMap);
 | 
	
		
			
				|  |  |         }
 | 
	
	
		
			
				|  | @ -1067,7 +1065,7 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |         List<Map<String,Object>> healthyConditionList = jdbcTemplate.queryForList(healthyConditionSql);
 | 
	
		
			
				|  |  |         String healthyCondition = healthyConditionList.size()>0?healthyConditionList.get(0).get("label_name")+"":"";
 | 
	
		
			
				|  |  |         String healthyConditionType = healthyConditionList.size()>0?healthyConditionList.get(0).get("label")+"":"";
 | 
	
		
			
				|  |  |         BasePatientDO patient = basePatientDao.findById(patientCode);
 | 
	
		
			
				|  |  |         BasePatientDO patient = basePatientDao.findById(patientCode).orElse(null);
 | 
	
		
			
				|  |  |         //个人基础信息(康复机构)
 | 
	
		
			
				|  |  |         String patientInfoSql = " SELECT DISTINCT hospital_name from wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " +
 | 
	
		
			
				|  |  |                 " where p.patient='"+patientCode+"' and p.status=1 ";
 | 
	
	
		
			
				|  | @ -1133,7 +1131,7 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |             serviceDoctorList.add(map);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         for (Map<String,Object> d:serviceDoctorList){
 | 
	
		
			
				|  |  |             BaseDoctorDO baseDoctorDO1 = baseDoctorDao.findById(d.get("doctorCode").toString());
 | 
	
		
			
				|  |  |             BaseDoctorDO baseDoctorDO1 = baseDoctorDao.findById(d.get("doctorCode").toString()).orElse(null);
 | 
	
		
			
				|  |  |             d.put("doctorPhoto",baseDoctorDO1!=null?baseDoctorDO1.getPhoto():"");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         resultMap.put("serviceDoctorList",serviceDoctorList);
 | 
	
	
		
			
				|  | @ -1288,7 +1286,7 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @Transactional
 | 
	
		
			
				|  |  |     public Envelop saveGuidanceMessage(String messageId,String doctor,String content,String planDetailId,Integer contentType) throws Exception{
 | 
	
		
			
				|  |  |         BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
 | 
	
		
			
				|  |  |         BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor).orElse(null);
 | 
	
		
			
				|  |  |         Integer doctorType =null;
 | 
	
		
			
				|  |  |         if (doctorDO!=null){
 | 
	
		
			
				|  |  |             List<BaseDoctorRoleDO> baseDoctorRoleDO = baseDoctorRoleDao.findByDoctorCode(doctor);
 | 
	
	
		
			
				|  | @ -1620,8 +1618,8 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |         if (evaluation == 1){
 | 
	
		
			
				|  |  |             String serviceItemId = resultMap.get("service_item_id").toString();
 | 
	
		
			
				|  |  |             String title = resultMap.get("title").toString();
 | 
	
		
			
				|  |  |             BasePatientDO p = basePatientDao.findById(patient);
 | 
	
		
			
				|  |  |             BaseDoctorDO doctor1 = baseDoctorDao.findById(doctor);
 | 
	
		
			
				|  |  |             BasePatientDO p = basePatientDao.findById(patient).orElse(null);
 | 
	
		
			
				|  |  |             BaseDoctorDO doctor1 = baseDoctorDao.findById(doctor).orElse(null);
 | 
	
		
			
				|  |  |             String patientName = p.getName();
 | 
	
		
			
				|  |  |             String openId = p.getOpenid();
 | 
	
		
			
				|  |  |             /*WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_service","fwxmpj");
 | 
	
	
		
			
				|  | @ -1773,7 +1771,7 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |             PatientMedicalRecordsDO patientMedicalRecordsDO = patientMedicalRecordsDao.findByCode(p.getMedicalRecordsCode());
 | 
	
		
			
				|  |  |             resultMap.put("patientMedicalRecordsDO",patientMedicalRecordsDO);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         BasePatientDO basePatientDO = basePatientDao.findById(patientCode);
 | 
	
		
			
				|  |  |         BasePatientDO basePatientDO = basePatientDao.findById(patientCode).orElse(null);
 | 
	
		
			
				|  |  |         Integer age = IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard());
 | 
	
		
			
				|  |  |         String sex = IdCardUtil.getSexForIdcard_new(basePatientDO.getIdcard());
 | 
	
		
			
				|  |  |         resultMap.put("sex","1".equals(sex)?"男":("2".equals(sex)?"女":"未知"));
 | 
	
	
		
			
				|  | @ -1945,7 +1943,7 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |             reslutMap.put("disease_name", list.get(0).get("disease_name"));
 | 
	
		
			
				|  |  |             reslutMap.put("create_time", list.get(0).get("create_time"));
 | 
	
		
			
				|  |  |             reslutMap.put("patient_img", list.get(0).get("patient_img"));
 | 
	
		
			
				|  |  |             BasePatientDO patient = basePatientDao.findById(patientCode);
 | 
	
		
			
				|  |  |             BasePatientDO patient = basePatientDao.findById(patientCode).orElse(null);
 | 
	
		
			
				|  |  |             if (patient!=null){
 | 
	
		
			
				|  |  |                 reslutMap.put("openid", patient.getOpenid());
 | 
	
		
			
				|  |  |                 reslutMap.put("ssc",patient.getSsc());
 | 
	
	
		
			
				|  | @ -2055,7 +2053,7 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |             sql ="update wlyy_doctor_patient_relation set is_manage=1,manage_user ='"+doctor+"', manage_time ='"+DateUtil.getStringDate()+"' where id='"+tmp.get("id").toString()+"' ";
 | 
	
		
			
				|  |  |             jdbcTemplate.execute(sql);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         BaseDoctorDO doctorObject = baseDoctorDao.findById(doctor);//家庭医生
 | 
	
		
			
				|  |  |         BaseDoctorDO doctorObject = baseDoctorDao.findById(doctor).orElse(null);//家庭医生
 | 
	
		
			
				|  |  |         //接收患者时,给服务医生群组发送消息
 | 
	
		
			
				|  |  |         List<String> patientRelationDoctor = new ArrayList<>();
 | 
	
		
			
				|  |  |         for (Map<String,Object> tmp:planByCreate){
 | 
	
	
		
			
				|  | @ -2107,7 +2105,7 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |             String doctor =map.get("create_user").toString();
 | 
	
		
			
				|  |  |             patient = map.get("patient").toString();
 | 
	
		
			
				|  |  |             JSONObject object = new JSONObject();
 | 
	
		
			
				|  |  |             BaseDoctorDO doctor1 = baseDoctorDao.findById(doctor);
 | 
	
		
			
				|  |  |             BaseDoctorDO doctor1 = baseDoctorDao.findById(doctor).orElse(null);
 | 
	
		
			
				|  |  |             object.put("code",doctor1.getId());
 | 
	
		
			
				|  |  |             object.put("name",doctor1.getName());
 | 
	
		
			
				|  |  |             object.put("level",doctor1.getLevel());
 | 
	
	
		
			
				|  | @ -2469,7 +2467,7 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |         Integer turnDownStateTotal_2=0;//已接受
 | 
	
		
			
				|  |  |         Integer turnDownStateTotal_3=0;//未下转
 | 
	
		
			
				|  |  |         org.json.JSONObject resultObj = new org.json.JSONObject();
 | 
	
		
			
				|  |  |         BaseDoctorDO doctorObj = baseDoctorDao.findById(doctor);
 | 
	
		
			
				|  |  |         BaseDoctorDO doctorObj = baseDoctorDao.findById(doctor).orElse(null);
 | 
	
		
			
				|  |  |         List<Map<String, Object>> result = new ArrayList<>();
 | 
	
		
			
				|  |  |         String sql = "SELECT DISTINCT pr.id,p.`name`,plan.id as planId, p.`id` as code, p.idcard,p.photo, plan.disease,plan.disease_name,YEAR (now()) - YEAR (substring(p.idcard, 7, 8)) as age," +
 | 
	
		
			
				|  |  |                 "p.sex,pr.doctor AS specialist,pr.doctor_name AS specialistName,pr.disease_code,pr.doctor_name ," +
 | 
	
	
		
			
				|  | @ -2508,7 +2506,7 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |         List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         System.out.println("mapList"+sql);
 | 
	
		
			
				|  |  |         for (Map<String,Object> map:mapList){
 | 
	
		
			
				|  |  |             BasePatientDO patientDo = basePatientDao.findById(map.get("code").toString());
 | 
	
		
			
				|  |  |             BasePatientDO patientDo = basePatientDao.findById(map.get("code").toString()).orElse(null);
 | 
	
		
			
				|  |  |             List<BaseDoctorHospitalDO> depts= baseDoctorHospitalDao.findByDoctorCode(doctor);
 | 
	
		
			
				|  |  |             if (depts!=null&&depts.size()>0){
 | 
	
		
			
				|  |  |                 map.put("dept_code",depts.get(0).getDeptCode());
 | 
	
	
		
			
				|  | @ -2582,7 +2580,7 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |                 map.put("dept_code",depts.get(0).getDeptCode());
 | 
	
		
			
				|  |  |                 map.put("dept_name",depts.get(0).getDeptName());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             BasePatientDO patientDo = basePatientDao.findById(map.get("code").toString());
 | 
	
		
			
				|  |  |             BasePatientDO patientDo = basePatientDao.findById(map.get("code").toString()).orElse(null);
 | 
	
		
			
				|  |  |             Integer age = IdCardUtil.getAgeByIdcardOrBirthday(patientDo.getIdcard(),patientDo.getBirthday());
 | 
	
		
			
				|  |  |             map.put("age",age);
 | 
	
		
			
				|  |  |             map.put("disease_name", "暂无");
 | 
	
	
		
			
				|  | @ -2702,7 +2700,7 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |         List<Map<String,Object>> mapList = hibenateUtils.createSQLQuery(sql,page,pageSize);
 | 
	
		
			
				|  |  |         System.out.println("mapList"+sql);
 | 
	
		
			
				|  |  |         for (Map<String,Object> map:mapList){
 | 
	
		
			
				|  |  |             BasePatientDO patientDo = basePatientDao.findById(map.get("code").toString());
 | 
	
		
			
				|  |  |             BasePatientDO patientDo = basePatientDao.findById(map.get("code").toString()).orElse(null);
 | 
	
		
			
				|  |  |             List<BaseDoctorHospitalDO> depts= baseDoctorHospitalDao.findByDoctorCode(doctor);
 | 
	
		
			
				|  |  |             if (depts!=null&&depts.size()>0){
 | 
	
		
			
				|  |  |                 map.put("dept_code",depts.get(0).getDeptCode());
 | 
	
	
		
			
				|  | @ -3113,8 +3111,8 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |         //智业中山同步病历
 | 
	
		
			
				|  |  |         String result = "";
 | 
	
		
			
				|  |  |         List<PatientMedicalRecordsDO> query = new ArrayList<>();
 | 
	
		
			
				|  |  |         BasePatientDO patient1 = basePatientDao.findById(patient);
 | 
	
		
			
				|  |  |         BaseDoctorDO doctor = baseDoctorDao.findById(doctorCode);
 | 
	
		
			
				|  |  |         BasePatientDO patient1 = basePatientDao.findById(patient).orElse(null);
 | 
	
		
			
				|  |  |         BaseDoctorDO doctor = baseDoctorDao.findById(doctorCode).orElse(null);
 | 
	
		
			
				|  |  |         String orgCode="";
 | 
	
		
			
				|  |  |         List<BaseDoctorHospitalDO> baseDoctorHospitalDO = baseDoctorHospitalDao.findByDoctorCode(doctorCode);
 | 
	
		
			
				|  |  |         if(baseDoctorHospitalDO!=null&&baseDoctorHospitalDO.size()>0){
 | 
	
	
		
			
				|  | @ -3233,7 +3231,7 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |             sql +=" and p.status ="+status;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(doctor)){
 | 
	
		
			
				|  |  |             BaseDoctorDO doctor1 = baseDoctorDao.findById(doctor);
 | 
	
		
			
				|  |  |             BaseDoctorDO doctor1 = baseDoctorDao.findById(doctor).orElse(null);
 | 
	
		
			
				|  |  |             if (doctor1!=null&&doctor1.getLevel()==1){
 | 
	
		
			
				|  |  |                 sql +=" and p.create_user ='"+doctor+"'";
 | 
	
		
			
				|  |  |             }
 | 
	
	
		
			
				|  | @ -3303,7 +3301,7 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |         List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         for (Map<String,Object> map:mapList){
 | 
	
		
			
				|  |  |             String doctorCode = map.get("doctor")+"";
 | 
	
		
			
				|  |  |             BaseDoctorDO doctor = baseDoctorDao.findById(doctorCode);
 | 
	
		
			
				|  |  |             BaseDoctorDO doctor = baseDoctorDao.findById(doctorCode).orElse(null);
 | 
	
		
			
				|  |  |             List<BaseDoctorHospitalDO> depts=baseDoctorHospitalDao.findByDoctorCode(doctorCode);
 | 
	
		
			
				|  |  |             if (depts!=null&&depts.size()>0){
 | 
	
		
			
				|  |  |                 map.put("hospital",depts.get(0).getOrgCode());
 |