| 
					
				 | 
			
			
				@ -32,6 +32,7 @@ import com.yihu.jw.entity.base.patient.BasePatientBusinessDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.BasePatientDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.PatientMedicareCardDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.sms.SmsTemplateDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.words.BaseSensitiveDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.wx.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.yx.YxTokenMappingDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.consult.WlyyDoctorClinicRoomDO; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -148,6 +149,8 @@ import java.text.DecimalFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.text.ParseException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.text.SimpleDateFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.concurrent.TimeUnit; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * Created by Trick on 2019/5/17. 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -308,7 +311,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseJpushTemplateDao baseJpushTemplateDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    HikariDataSource dataSource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseSensitiveDao baseSensitiveDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Value("${demo.flag}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private boolean demoFlag; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3703,7 +3707,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return rs.size(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Transactional(readOnly = true) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Map<String, Object> findDoctorInfo(String doctor, String withWork,String patient) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, Object> rs = new HashedMap(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3934,6 +3938,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<com.alibaba.fastjson.JSONArray> waitinglist = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<BaseSensitiveDO> listSensitive = (List<BaseSensitiveDO>) baseSensitiveDao.findAll(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (scoreList != null && scoreList.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    List<String> stringList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    for (Map<String, Object> scorepatient : scoreList) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3947,7 +3952,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String content = (String)scorepatient.get("content"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (StringUtils.isNotEmpty(content)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            String replace = baseSensitiveFilterWordsService.filterSensitiveWords(content); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            String replace = baseSensitiveFilterWordsService.filterSensitiveWords(content,listSensitive); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            scorepatient.put("content",replace); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -5677,6 +5682,331 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            pagesize = 10; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        testHikar(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        long statr = new Date().getTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.id AS \"id\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.photo AS \"photo\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.name AS \"name\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.expertise AS \"expertise\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.introduce AS \"introduce\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.job_title_code AS \"jobTitleCode\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.job_title_name AS \"jobTitleName\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.charge_type AS \"chargeType\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " h.dept_name AS \"deptName\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " dw.workTotal AS \"workTotal\","+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.consult_status AS \"consultStatus\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.outpatient_type AS \"outpatientType\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " a.total AS \"consultTotal\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.twfz_charge_type AS \"TWFZ_CHARGE_TYPE\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.spfz_charge_type AS \"SPFZ_CHARGE_TYPE\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.spzx_charge_type AS \"SPZX_CHARGE_TYPE\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.xtfz_charge_type AS \"XTFZ_CHARGE_TYPE\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.twzx_charge_type AS \"TWZX_CHARGE_TYPE\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.jyzx_charge_type AS \"JYZX_CHARGE_TYPE\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " h.org_name AS \"orgName\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " h.org_code AS \"orgCode\" " ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNoneBlank(patientid)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" , follow.id AS \"followid\" " ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql+=" FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " base_doctor d " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " JOIN base_doctor_hospital h ON h.doctor_code = d.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " Left join ( select count(id) as total,doctor from wlyy_outpatient where status = 3 GROUP BY doctor ) a on a.doctor = d.id "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, Object> params = new HashedMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Date date = new Date(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql+="LEFT JOIN (SELECT  COUNT(t1.doctor) as workTotal, t1.doctor FROM  wlyy_doctor_work_time t1   WHERE   " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "t1.start_time <=:startTime  AND t1.end_time >=:endTime GROUP BY t1.doctor) dw ON dw.doctor=d.id "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql+="LEFT JOIN (\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tSELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\t\tAVG(a.score) AS score,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\t\tb.doctor AS doctor\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tFROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\t\tbase_evaluate a,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\t\tbase_evaluate_score b\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tWHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\t\ta.relation_code = b.id\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tGROUP BY\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\t\tb.doctor\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ") evaluate ON evaluate.doctor = d.id"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        params.put("startTime", date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        params.put("endTime", date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNoneBlank(patientid)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if ("1".equalsIgnoreCase(isAttention)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql += " join base_doctor_patient_follow follow on follow.doctor = d.id and follow.patient ='" + patientid + "' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if ("0".equalsIgnoreCase(isAttention)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql += " join base_doctor_patient_follow follow on follow.doctor = d.id and follow.patient !='" + patientid + "' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isEmpty(isAttention)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql += " LEFT  JOIN base_doctor_patient_follow follow ON follow.patient='" + patientid + "' AND follow.doctor = d.id "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(diseaseKey)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " left join wlyy_doctor_special_disease sp on d.id = sp.doctor_code "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(workingTime)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " JOIN wlyy_doctor_work_time wk on wk.doctor = d.id "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql += " WHERE  1=1 and h.del = '1' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(chargType)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if ("all".equals(chargType)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //不过滤 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql += " AND d.charge_type = :chargType"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                params.put("chargType", chargType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<WlyyHospitalSysDictDO> wlyyHospitalSysDictDOS  = wlyyHospitalSysDictDao.findByDictCode("isDoctorWork"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        boolean isNeedDoctorWord = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(wlyyHospitalSysDictDOS!=null&&wlyyHospitalSysDictDOS.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(WlyyHospitalSysDictDO wlyyHospitalSysDictDO:wlyyHospitalSysDictDOS){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (!"1".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictValue())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    isNeedDoctorWord = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(iswork) && "1".equals(iswork)&&isNeedDoctorWord) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.info("iswork:" + iswork); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND (" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " EXISTS ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "  1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "  wlyy_doctor_work_time t " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "  t.doctor = d.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.start_time <=:startTime" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND t.end_time >=:endTime" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " ) OR " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " d.consult_status = '1') "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            params.put("startTime", date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            params.put("endTime", date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(orgCode)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND  h.org_code =:orgCode"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            params.put("orgCode", orgCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(diseaseKey)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND sp.disease_name like :diseaseKey"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            params.put("diseaseKey", "%" + diseaseKey + "%"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(doctorNameKey)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND d.name like :doctorNameKey"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            params.put("doctorNameKey", "%" + doctorNameKey + "%"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(dept)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND h.dept_code =:dept "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            params.put("dept", dept); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(jobTitleNameKey)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND d.job_title_name  = :jobTitleNameKey "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            params.put("jobTitleNameKey", jobTitleNameKey); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(outpatientType)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (outpatientType.contains("or")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String[] outpatientTypeArray = outpatientType.split("or"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql += " AND ( "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (int i = 0; i < outpatientTypeArray.length; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sql += " d.outpatient_type like'%" + outpatientTypeArray[i] + "%'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (i != outpatientTypeArray.length - 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        sql += " or "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql += " ) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql += " AND d.outpatient_type like'%" + outpatientType + "%'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND d.outpatient_type is not null "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(keyName)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND (h.dept_name like '%" + keyName + "%' or d.name like '%" + keyName + "%' or d.expertise like '%" + keyName + "%' )"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(workingTime)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND wk.work_date = :workingTime "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            params.put("workingTime", workingTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(consultStatus)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND d.consult_status = :consultStatus "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            params.put("consultStatus", consultStatus); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (flag){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql += " and d.del='1' order by d.consult_status DESC ,evaluate.score desc,a.total " + consutlSort; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql += " and d.del='1' order by d.consult_status desc nulls last ,evaluate.score desc nulls last ,a.total " + consutlSort; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql+=" NULLS LAST,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "\tD.id DESC"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " and d.del='1' order by d.consult_status DESC ,evaluate.score desc,a.total " + consutlSort; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sqlCount = "select count(1) as \"total\" from ( "+sql+" ) t"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, params, page, pagesize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<WlyyHospitalSysDictDO> doctorFrontList = wlyyHospitalSysDictDao.findByDictNameOrderBySort("doctorFrontList",orgCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> frontDoctor = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql= sql.replace("AS \"id\"","AS \"ID\""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sqlCharge = "SELECT t.id as \"id\",\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tm.req_fee as \"twfzFee\",\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ta.req_fee as \"spfzFee\",\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tb.req_fee as \"spzxFee\",\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tv.req_fee as \"twzxFee\",\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tg.req_fee as \"jyzxFee\",\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\td.req_fee as \"xtzxFee\"\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\t  ("+sql+")  t \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "LEFT JOIN wlyy_charge_dict m ON t.twfz_charge_type = m.charge_type\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "LEFT JOIN wlyy_charge_dict a ON t.spfz_charge_type = a.charge_type\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "LEFT JOIN wlyy_charge_dict b ON t.spzx_charge_type = b.charge_type\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "LEFT JOIN wlyy_charge_dict v ON t.twzx_charge_type = v.charge_type\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "LEFT JOIN wlyy_charge_dict d ON t.xtfz_charge_type = d.charge_type\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN wlyy_charge_dict g ON t.jyzx_charge_type = g.charge_type\n"+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " where t.id is not null "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> chargeDictDOLists =  hibenateUtils.createSQLQuery(sqlCharge, params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //查询医生各项评价平均分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sqlscore = "select t.doctor as \"id\" ,sum(t.score)/3 as\"score\" from ("+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "AVG(a.score) AS \"score\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "a.score_type AS \"score_type\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "b.doctor as \"doctor\" " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM ("+sql+") m , base_evaluate a,base_evaluate_score b " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " m.id = b.doctor and " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "a.relation_code=b.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "GROUP BY a.score_type,b.doctor ORDER BY  a.score_type ASC ) t GROUP BY  t.doctor"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> listscore = hibenateUtils.createSQLQuery(sqlscore, params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        /*list.stream().forEach(e->{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (null==e.get("consultStatus")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                e.put("consultStatus",0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (null==e.get("workTotal")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                e.put("workTotal",0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        list.stream().sorted(Comparator.comparing((Map<String, Object> h) -> ((String) h.get("workTotal"))).reversed().thenComparing(Comparator.comparing((Map<String, Object> h) -> ((String) h.get("consultStatus")))).reversed());*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>>  resultList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultList.addAll(list) ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (Map<String,Object> map:list){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String doctor = map.get("id").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            /*List<Map<String,Object>> chargeDictDOLists = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(null!=map.get("chargeType")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String chargeType = map.get("chargeType").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (chargeType.contains(",")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    chargeType = chargeType.replace(",","','"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String sqlCharge = "select charge_type as \"chargeType\",charge_name as \"chargeName\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "req_fee  as \"reqFee\",zj_fee  as \"zjFee\",xt_fee  as \"xtFee\",dept_type_code as \"deptTypeCode\" " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " from wlyy_charge_dict where 1=1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sqlCharge+=" and charge_type in ( '"+chargeType+"')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (StringUtils.isNoneBlank(deptTyepCode)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sqlCharge+=" and dept_type_code in ( '"+deptTyepCode+"')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                chargeDictDOLists =  hibenateUtils.createSQLQuery(sqlCharge); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("chargeTypeList",chargeDictDOLists);*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> doctorChargeDictDOLists = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (Map<String ,Object> chargMap:chargeDictDOLists){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(doctor.equalsIgnoreCase(chargMap.get("id").toString())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorChargeDictDOLists.add(chargMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("chargeTypeList",doctorChargeDictDOLists); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Double doctorScore = new Double("0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (listscore != null && listscore.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (Map<String, Object> _listscore : listscore) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (_listscore.get("id").toString().equalsIgnoreCase(doctor)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        doctorScore = Double.parseDouble(_listscore.get("score").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("doctorScore", doctorScore); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (doctorFrontList!=null&&doctorFrontList.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:doctorFrontList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if(doctor.equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        map.put("doctorFrontSort",wlyyHospitalSysDictDO.getSort()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        logger.info("doctorFrontSort"+wlyyHospitalSysDictDO.getSort()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        logger.info("doctorId"+wlyyHospitalSysDictDO.getDictCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        frontDoctor.add(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        resultList.remove(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> listCount = hibenateUtils.createSQLQuery(sqlCount, params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Long count = 0L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(listCount!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            count = hibenateUtils.objTransformLong(listCount.get(0).get("total")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (frontDoctor!=null&&frontDoctor.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            frontDoctor.sort(Comparator.comparing((Map<String, Object> h) -> ((Integer) h.get("doctorFrontSort")))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.info("size"+frontDoctor.size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (Map<String, Object> map:resultList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                logger.info("id  =="+map.get("id").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                frontDoctor.add(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        logger.info("findDoctorByHospitalAndDiseaseAndDept end:" + DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm:ss:SSS")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        logger.info("sql:" + sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        MixEnvelop envelop =new MixEnvelop(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        envelop.setDetailModelList(frontDoctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        envelop.setTotalCount(count.intValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        envelop.setPageSize(pagesize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        envelop.setCurrPage(page); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        System.out.println("new"+(new Date().getTime()-statr)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return envelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 根据疾病名称,热门部门查询医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param orgCode         机构码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param dept            部门CODE 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param diseaseKey      疾病名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param jobTitleNameKey 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param outpatientType 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param keyName 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param workingTime 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param consutlSort 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Transactional(readOnly = true) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public MixEnvelop findDoctorByHospitalAndDiseaseAndDept2(String iswork, String patientid, String orgCode, String dept, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                            String diseaseKey, String doctorNameKey, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                            String jobTitleNameKey, String outpatientType, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                            String keyName, String workingTime, String consultStatus, String chargType, String consutlSort, String isAttention, Integer page, Integer pagesize) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      /*  if(page >=1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            page --; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (pagesize <= 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            pagesize = 10; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        long statr = new Date().getTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.id AS \"id\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.photo AS \"photo\", " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -5968,6 +6298,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        envelop.setTotalCount(count.intValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        envelop.setPageSize(pagesize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        envelop.setCurrPage(page); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        System.out.println("old"+(new Date().getTime()-statr)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return envelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -6836,6 +7167,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            wlyyHttpLogDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            wlyyHttpLogDao.save(wlyyHttpLogDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ("xm_zsyy_wx".equalsIgnoreCase(wechatId)&&StringUtils.isNoneBlank(wlyyOutpatientDO.getDoctor())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String msgUrl="https://hlwyy.xmzsh.com/ims-wx/index.html#/returnVisit/record?outpatientId="+wlyyOutpatientDO.getId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sendZsMsgFlow("OL_PAY_SUCCESS",wlyyOutpatientDO.getId(),"",msgUrl,"已支付问诊费"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -7119,31 +7454,33 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "AND outpatient.doctor='" + doctor + "' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "AND outpatient.pay_status = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "AND outpatient.outpatient_type= '" + outpatient_type + "'  "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ("1".equals(outpatient_type)||"3".equals(outpatient_type)) {//复诊 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql = sql + " AND outpatient.type= '" + type + "' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if ("2".equals(type)) {//视频复诊才需要判断时间, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (!"xm_ihealth_wx".contains(wxId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if ("1".equals(outpatient_type)||"3".equals(outpatient_type)) {//复诊 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql = sql + " AND outpatient.type= '" + type + "' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if ("2".equals(type)) {//视频复诊才需要判断时间, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if ("xm_ykyy_wx".equals(wxId)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (flag){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            sql += " AND outpatient.register_date is not null and outpatient.register_date >= str_to_date('" + DateUtil.dateToStrShort(new Date()) + " 00:00:00','YYYY-MM-DD HH24:MI:SS')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            sql += " AND outpatient.register_date is not null and outpatient.register_date >= to_date('" + DateUtil.dateToStrShort(new Date()) + " 00:00:00','YYYY-MM-DD HH24:MI:SS')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        sql = sql + " AND outpatient.register_date is not null AND  outpatient.register_date >= '" + DateUtil.dateToStrShort(new Date()) + " 00:00:00' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else if ("2".equals(outpatient_type)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //协同门诊也需要判断时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if ("xm_ykyy_wx".equals(wxId)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (flag){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        sql += " AND outpatient.register_date is not null and outpatient.register_date >= str_to_date('" + DateUtil.dateToStrShort(new Date()) + " 00:00:00','YYYY-MM-DD HH24:MI:SS')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        sql += " AND outpatient.register_date is not null and outpatient.register_date >= to_date('" + DateUtil.dateToStrShort(new Date()) + " 00:00:00','YYYY-MM-DD HH24:MI:SS')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sql = sql + " AND outpatient.register_date is not null AND  outpatient.register_date >= '" + DateUtil.dateToStrShort(new Date()) + " 00:00:00' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else if ("2".equals(outpatient_type)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //协同门诊也需要判断时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if ("xm_ykyy_wx".equals(wxId)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (flag){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sql += " AND outpatient.register_date is not null and outpatient.register_date >= str_to_date('" + DateUtil.dateToStrShort(new Date()) + " 00:00:00','YYYY-MM-DD HH24:MI:SS')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sql += " AND outpatient.register_date is not null and outpatient.register_date >= to_date('" + DateUtil.dateToStrShort(new Date()) + " 00:00:00','YYYY-MM-DD HH24:MI:SS')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql = sql + " AND outpatient.register_date is not null AND  outpatient.register_date >= '" + DateUtil.dateToStrShort(new Date()) + " 00:00:00' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        logger.info("接口名称:doctorReviewConsultCount-->sql="+sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(sql); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -10078,6 +10415,46 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if("xm_zsyy_wx".equalsIgnoreCase(wechatId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                /*prescriptionDao.updateCheckStatus(prescriptionId,2,reason,20);*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                logger.info("作废处方开始" + prescriptionDO.getCheckStatus()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                WlyyOutpatientDO outpatientDO = outpatientDao.findById(prescriptionDO.getOutpatientId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(outpatientDO.getDoctor(), outpatientDO.getHospital()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<WlyyPrescriptionInfoDO> infoDOS = prescriptionInfoDao.findByPrescriptionId(prescriptionId, 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<WlyyInspectionDO> inspectionDOS = wlyyInspectionDao.findByPrescriptionId(prescriptionId, 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<WlyyPrescriptionDiagnosisDO> prescriptionDiagnosisDOS = prescriptionDiagnosisDao.findByPrescriptionId(prescriptionId,1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<WlyyPrescriptionExpressageDO> expressageDOS = prescriptionExpressageDao.findByOutpatientId(outpatientDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                com.alibaba.fastjson.JSONArray jsonData = new com.alibaba.fastjson.JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (WlyyPrescriptionInfoDO info : infoDOS) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //设置his药品查询条件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    setInfoJsonParam(jsonData, doctorMappingDO, outpatientDO, prescriptionDO, info, outpatientDO.getIcd10()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (WlyyInspectionDO ins : inspectionDOS) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //设置his药品查询条件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    setInspectionParam(jsonData, doctorMappingDO, outpatientDO, prescriptionDO, ins, outpatientDO.getIcd10()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (expressageDOS!=null&&expressageDOS.size()!=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    WlyyPrescriptionExpressageDO prescriptionExpressageDO = expressageDOS.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (prescriptionExpressageDO!=null&&prescriptionExpressageDO.getOneselfPickupFlg()==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        for (int i=0;i<jsonData.size();i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            com.alibaba.fastjson.JSONObject object = jsonData.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            object.put("selfDelivered",0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else if (prescriptionExpressageDO!=null&&prescriptionExpressageDO.getOneselfPickupFlg()==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        for (int i=0;i<jsonData.size();i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            com.alibaba.fastjson.JSONObject object = jsonData.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            object.put("selfDelivered",1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    net.sf.json.JSONObject jsonObject = entranceService.BS10112(jsonData.toJSONString(), demoFlag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return "删除失败"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionDO.setStatus(-1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionDO.setCheckStatus(4); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionDO.setCheckReason("已删除"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -11789,17 +12166,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                .build()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        .build()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                .build(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (extras.get("outpatientId")!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            PushResult result = jPushClient.sendPush(payload); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.info("极光推送返回日志==="+result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            WlyyHttpLogDO httpLogDO = new WlyyHttpLogDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            httpLogDO.setCode("JPUSH"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            httpLogDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            /*httpLogDO.setRequest(jsonObject.toJSONString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            httpLogDO.setResponse(result);*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            httpLogDO.setRequest(extras==null?"":extras.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            httpLogDO.setResponse(result==null?"":result.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            wlyyHttpLogDao.save(httpLogDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.info("Got result - " + result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (APIConnectionException e) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -12010,6 +12384,52 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jsonObject.put("type",32); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jsonObject.put("id",prescriptionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jsonObject.put("outpatientId",wlyyOutpatientDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else if("remind_doctor_pickup".equalsIgnoreCase(templateCode)){//接诊下消息提醒 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BaseJpushTemplateDO baseJpushTemplateDO = baseJpushTemplateDao.findByCode(templateCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(baseJpushTemplateDO!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if ("1".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())&&"1".equalsIgnoreCase(wlyyOutpatientDO.getType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    content = baseJpushTemplateDO.getPushContent().replace("{{咨询类型}}","图文复诊").replace("{{患者姓名}}",wlyyOutpatientDO.getPatientName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    title=baseJpushTemplateDO.getPushHeader().replace("{{咨询类型}}","图文复诊接诊提醒"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("type",51); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("patientName",wlyyOutpatientDO.getPatientName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else if ("1".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())&&"2".equalsIgnoreCase(wlyyOutpatientDO.getType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    content = baseJpushTemplateDO.getPushContent().replace("{{咨询类型}}","视频复诊").replace("{{患者姓名}}",wlyyOutpatientDO.getPatientName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    content+= "视频复诊预约时间为:"+wlyyOutpatientDO.getRegisterDate(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    title=baseJpushTemplateDO.getPushHeader().replace("{{咨询类型}}","视频复诊接诊提醒"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("type",52); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("patientName",wlyyOutpatientDO.getPatientName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else if ("3".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())&&"1".equalsIgnoreCase(wlyyOutpatientDO.getType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    content = baseJpushTemplateDO.getPushContent().replace("{{咨询类型}}","图文咨询").replace("{{患者姓名}}",wlyyOutpatientDO.getPatientName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    title=baseJpushTemplateDO.getPushHeader().replace("{{咨询类型}}","图文咨询接诊提醒"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("type",58); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("patientName",wlyyOutpatientDO.getPatientName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else if ("3".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())&&"2".equalsIgnoreCase(wlyyOutpatientDO.getType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    content = baseJpushTemplateDO.getPushContent().replace("{{咨询类型}}","视频咨询").replace("{{患者姓名}}",wlyyOutpatientDO.getPatientName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    title=baseJpushTemplateDO.getPushHeader().replace("{{咨询类型}}","视频咨询接诊提醒"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    content+= "视频咨询预约时间为:"+wlyyOutpatientDO.getRegisterDate(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("type",57); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("patientName",wlyyOutpatientDO.getPatientName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else if ("2".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    content = baseJpushTemplateDO.getPushContent().replace("{{咨询类型}}","协同复诊").replace("{{患者姓名}}",wlyyOutpatientDO.getPatientName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    title=baseJpushTemplateDO.getPushHeader().replace("{{咨询类型}}","协同复诊接诊提醒"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("type",53); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("patientName",wlyyOutpatientDO.getPatientName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else if ("3".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())&&"3".equalsIgnoreCase(wlyyOutpatientDO.getType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    content = baseJpushTemplateDO.getPushContent().replace("{{咨询类型}}","家医咨询").replace("{{患者姓名}}",wlyyOutpatientDO.getPatientName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    title=baseJpushTemplateDO.getPushHeader().replace("{{咨询类型}}","家医咨询接诊提醒"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("type",55); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("patientName",wlyyOutpatientDO.getPatientName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String sex = IdCardUtil.getSexNameForIdcard_new(wlyyOutpatientDO.getIdcard()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Integer age = IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Long createTime = wlyyOutpatientDO.getCreateTime().getTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Long nowTime = new Date().getTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Long minusts = TimeUnit.MILLISECONDS.toMinutes(nowTime - createTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                content = content.replace("{{性别年龄}}",sex+age+"岁").replace("{{等待时间}}",minusts.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            userId = wlyyOutpatientDO.getDoctor(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jsonObject.put("id",wlyyOutpatientDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            isDoctor="1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return jPushMessage(isDoctor,userId,content,title,jsonObject); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -12172,5 +12592,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String findDomainUrlInDict(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("domainUrl"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (wlyyHospitalSysDictDO!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return wlyyHospitalSysDictDO.getDictValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |