|  | @ -103,6 +103,7 @@ import org.slf4j.LoggerFactory;
 | 
	
		
			
				|  |  | import org.springframework.beans.BeanUtils;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Value;
 | 
	
		
			
				|  |  | import org.springframework.boot.Banner;
 | 
	
		
			
				|  |  | import org.springframework.data.redis.core.StringRedisTemplate;
 | 
	
		
			
				|  |  | import org.springframework.jdbc.core.BeanPropertyRowMapper;
 | 
	
		
			
				|  |  | import org.springframework.jdbc.core.JdbcTemplate;
 | 
	
	
		
			
				|  | @ -444,7 +445,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 " o.disease_img AS \"diseaseImg\"," +
 | 
	
		
			
				|  |  |                 " o.consumer as \"consumer\"," +
 | 
	
		
			
				|  |  |                 " o.consumer_name as \"consumerName\"," +
 | 
	
		
			
				|  |  |                 " o.consumer_mobile as \"consumerMobile\", ";
 | 
	
		
			
				|  |  |                 " o.consumer_mobile as \"consumerMobile\", "+
 | 
	
		
			
				|  |  |                 " o.fee as \"fee\", ";
 | 
	
		
			
				|  |  |         if ("xm_ykyy_wx".equals(wechatId)) {
 | 
	
		
			
				|  |  |             if (flag){
 | 
	
		
			
				|  |  |                 sql = sql + "date_format(o.create_time ,'%Y-%m-%d %H:%i:%S' ) AS createTime,";
 | 
	
	
		
			
				|  | @ -506,6 +508,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         rs.put("patientCancelRemark", outpatientDO.getPatientCancelRemark());
 | 
	
		
			
				|  |  |         rs.put("operator",outpatientDO.getOperator());
 | 
	
		
			
				|  |  |         rs.put("status",outpatientDO.getStatus());
 | 
	
		
			
				|  |  |         rs.put("fee",outpatientDO.getFee());
 | 
	
		
			
				|  |  |         rs.put("createTime",DateUtil.dateToStrLong(outpatientDO.getCreateTime()));
 | 
	
		
			
				|  |  |         //居民详情
 | 
	
		
			
				|  |  |         BasePatientDO basePatientDO = basePatientDao.findById(outpatientDO.getPatient());
 | 
	
	
		
			
				|  | @ -569,6 +572,16 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                         //电子病历
 | 
	
		
			
				|  |  |                         vo.setWlyyPrescriptionEmrDO(wlyyPrescriptionEmrDO);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 } else if (wxId.equalsIgnoreCase("xm_xzzx_wx")) {
 | 
	
		
			
				|  |  |                     WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO1 = prescriptionEmrDao.findEmrByPrescriptionId(vo.getId());
 | 
	
		
			
				|  |  |                     if (wlyyPrescriptionEmrDO1 != null) {
 | 
	
		
			
				|  |  |                         vo.setWlyyPrescriptionEmrDO(wlyyPrescriptionEmrDO1);
 | 
	
		
			
				|  |  |                     } else {
 | 
	
		
			
				|  |  |                         List<WlyyPrescriptionEmrDO> listEmr = xzzxEntranceService.selectHistoryEmr(hisPatient,"");
 | 
	
		
			
				|  |  |                         if (null!=listEmr&&listEmr.size()>0){
 | 
	
		
			
				|  |  |                             vo.setWlyyPrescriptionEmrDO(listEmr.get(0));
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 //支付信息
 | 
	
		
			
				|  |  |                 BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(vo.getId());
 | 
	
	
		
			
				|  | @ -1493,6 +1506,29 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 String id = (String) doctor.get("id");
 | 
	
		
			
				|  |  |                 List<WlyyDoctorWorkTimeVO> times = findDoctorWorkTime(id, orgCode);
 | 
	
		
			
				|  |  |                 doctor.put("workTime", times);
 | 
	
		
			
				|  |  |                 String deptTyepCode = "6";
 | 
	
		
			
				|  |  |                 List<BaseDoctorHospitalDO> depts = baseDoctorHospitalDao.findByDoctorCode(id);
 | 
	
		
			
				|  |  |                 if (null!=depts&&depts.size()>0){
 | 
	
		
			
				|  |  |                     BaseDoctorHospitalDO baseDoctorHospitalDO = depts.get(0);
 | 
	
		
			
				|  |  |                     String deptcode =  baseDoctorHospitalDO.getDeptCode();
 | 
	
		
			
				|  |  |                     String hosptitalCode = baseDoctorHospitalDO.getOrgCode();
 | 
	
		
			
				|  |  |                     List<DictHospitalDeptDO> dictHospitalDeptDO = dictHospitalDeptDao.findByOrgCodeAndCode(hosptitalCode,deptcode);
 | 
	
		
			
				|  |  |                     if(null!=dictHospitalDeptDO&&dictHospitalDeptDO.size()>0){
 | 
	
		
			
				|  |  |                         deptTyepCode = dictHospitalDeptDO.get(0).getDeptTypeCode();
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 String chargeTypeList = doctor.get("chargeType").toString();
 | 
	
		
			
				|  |  |                 if (chargeType.contains(",")){
 | 
	
		
			
				|  |  |                     chargeTypeList = chargeType.replace(",","','");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 String sqlCharge = "select charge_type as \"chargeType\",charge_name as \"chargeName\"," +
 | 
	
		
			
				|  |  |                         "req_fee  as \"reqFee\",dept_type_code as \"deptTypeCode\" " +
 | 
	
		
			
				|  |  |                         " from wlyy_charge_dict where 1=1";
 | 
	
		
			
				|  |  |                 sqlCharge+=" and charge_type in ( '"+chargeTypeList+"')";
 | 
	
		
			
				|  |  |                 sqlCharge+=" and dept_type_code in ( '"+deptTyepCode+"')";
 | 
	
		
			
				|  |  |                 List<Map<String,Object>> chargeDictDOLists =  hibenateUtils.createSQLQuery(sqlCharge);
 | 
	
		
			
				|  |  |                 doctor.put("chargeTypeList",chargeDictDOLists);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (StringUtils.isNotBlank(doctorCode)) {
 | 
	
		
			
				|  |  |                 //排序
 | 
	
	
		
			
				|  | @ -3366,8 +3402,30 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             rs.put("sex",doctorDO.getSex());
 | 
	
		
			
				|  |  |             rs.put("popularity",doctorDO.getPopularity());
 | 
	
		
			
				|  |  |             rs.put("qrcode",doctorDO.getQrcode());
 | 
	
		
			
				|  |  |             //号别
 | 
	
		
			
				|  |  |             String deptTyepCode = "6";
 | 
	
		
			
				|  |  |             List<BaseDoctorHospitalDO> depts = baseDoctorHospitalDao.findByDoctorCode(doctor);
 | 
	
		
			
				|  |  |             if (null!=depts&&depts.size()>0){
 | 
	
		
			
				|  |  |                 BaseDoctorHospitalDO baseDoctorHospitalDO = depts.get(0);
 | 
	
		
			
				|  |  |                 String deptcode =  baseDoctorHospitalDO.getDeptCode();
 | 
	
		
			
				|  |  |                 String hosptitalCode = baseDoctorHospitalDO.getOrgCode();
 | 
	
		
			
				|  |  |                 List<DictHospitalDeptDO> dictHospitalDeptDO = dictHospitalDeptDao.findByOrgCodeAndCode(hosptitalCode,deptcode);
 | 
	
		
			
				|  |  |                 if(null!=dictHospitalDeptDO&&dictHospitalDeptDO.size()>0){
 | 
	
		
			
				|  |  |                     deptTyepCode = dictHospitalDeptDO.get(0).getDeptTypeCode();
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String chargeType = doctorDO.getChargeType();
 | 
	
		
			
				|  |  |             if (chargeType.contains(",")){
 | 
	
		
			
				|  |  |                 chargeType = chargeType.replace(",","','");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String sqlCharge = "select charge_type as \"chargeType\",charge_name as \"chargeName\"," +
 | 
	
		
			
				|  |  |                     "req_fee  as \"reqFee\",dept_type_code as \"deptTypeCode\" " +
 | 
	
		
			
				|  |  |                     " from wlyy_charge_dict where 1=1";
 | 
	
		
			
				|  |  |             sqlCharge+=" and charge_type in ( '"+chargeType+"')";
 | 
	
		
			
				|  |  |             sqlCharge+=" and dept_type_code in ( '"+deptTyepCode+"')";
 | 
	
		
			
				|  |  |             List<Map<String,Object>> chargeDictDOLists =  hibenateUtils.createSQLQuery(sqlCharge);
 | 
	
		
			
				|  |  |             rs.put("chargeTypeList",chargeDictDOLists);
 | 
	
		
			
				|  |  |             //机构科室信息
 | 
	
		
			
				|  |  |             List<BaseDoctorHospitalDO> hospitalDOs = baseDoctorHospitalDao.findByDoctorCode(doctorDO.getId());
 | 
	
		
			
				|  |  |             if (hospitalDOs != null && hospitalDOs.size() > 0) {
 | 
	
	
		
			
				|  | @ -3601,7 +3659,30 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             rs.put("learning",doctorDO.getLearning());
 | 
	
		
			
				|  |  |             rs.put("sex",doctorDO.getSex());
 | 
	
		
			
				|  |  |             rs.put("qrcode",doctorDO.getQrcode());
 | 
	
		
			
				|  |  |             //号别
 | 
	
		
			
				|  |  |             String deptTyepCode = "6";
 | 
	
		
			
				|  |  |             List<BaseDoctorHospitalDO> depts = baseDoctorHospitalDao.findByDoctorCode(doctor);
 | 
	
		
			
				|  |  |             if (null!=depts&&depts.size()>0){
 | 
	
		
			
				|  |  |                 BaseDoctorHospitalDO baseDoctorHospitalDO = depts.get(0);
 | 
	
		
			
				|  |  |                 String deptcode =  baseDoctorHospitalDO.getDeptCode();
 | 
	
		
			
				|  |  |                 String hosptitalCode = baseDoctorHospitalDO.getOrgCode();
 | 
	
		
			
				|  |  |                 List<DictHospitalDeptDO> dictHospitalDeptDO = dictHospitalDeptDao.findByOrgCodeAndCode(hosptitalCode,deptcode);
 | 
	
		
			
				|  |  |                 if(null!=dictHospitalDeptDO&&dictHospitalDeptDO.size()>0){
 | 
	
		
			
				|  |  |                     deptTyepCode = dictHospitalDeptDO.get(0).getDeptTypeCode();
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String chargeType = doctorDO.getChargeType();
 | 
	
		
			
				|  |  |             if (chargeType.contains(",")){
 | 
	
		
			
				|  |  |                 chargeType = chargeType.replace(",","','");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String sqlCharge = "select charge_type as \"chargeType\",charge_name as \"chargeName\"," +
 | 
	
		
			
				|  |  |                     "req_fee  as \"reqFee\",dept_type_code as \"deptTypeCode\" " +
 | 
	
		
			
				|  |  |                     " from wlyy_charge_dict where 1=1";
 | 
	
		
			
				|  |  |             sqlCharge+=" and charge_type in ( '"+chargeType+"')";
 | 
	
		
			
				|  |  |             sqlCharge+=" and dept_type_code in ( '"+deptTyepCode+"')";
 | 
	
		
			
				|  |  |             List<Map<String,Object>> chargeDictDOLists =  hibenateUtils.createSQLQuery(sqlCharge);
 | 
	
		
			
				|  |  |             rs.put("chargeTypeList",chargeDictDOLists);
 | 
	
		
			
				|  |  |             //机构科室信息
 | 
	
		
			
				|  |  |             List<BaseDoctorHospitalDO> hospitalDOs = baseDoctorHospitalDao.findByDoctorCode(doctorDO.getId());
 | 
	
		
			
				|  |  |             List<BaseDoctorHospitalDO> hospitalDOList = new ArrayList<>();
 | 
	
	
		
			
				|  | @ -4865,12 +4946,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |       /*  if(page >=1){
 | 
	
		
			
				|  |  |             page --;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (pagesize <= 0) {
 | 
	
		
			
				|  |  |             pagesize = 10;
 | 
	
		
			
				|  |  |         }*/
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |       wechatId = "12";
 | 
	
		
			
				|  |  |         String sql = "SELECT " +
 | 
	
		
			
				|  |  |                 " d.id AS \"id\", " +
 | 
	
		
			
				|  |  |                 " d.photo AS \"photo\", " +
 | 
	
	
		
			
				|  | @ -5030,6 +5110,30 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         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());*/
 | 
	
		
			
				|  |  |         for (Map<String,Object> map:list){
 | 
	
		
			
				|  |  |             String doctor = map.get("id").toString();
 | 
	
		
			
				|  |  |             //号别
 | 
	
		
			
				|  |  |             String deptTyepCode = "6";
 | 
	
		
			
				|  |  |             List<BaseDoctorHospitalDO> depts = baseDoctorHospitalDao.findByDoctorCode(doctor);
 | 
	
		
			
				|  |  |             if (null!=depts&&depts.size()>0){
 | 
	
		
			
				|  |  |                 BaseDoctorHospitalDO baseDoctorHospitalDO = depts.get(0);
 | 
	
		
			
				|  |  |                 String deptcode =  baseDoctorHospitalDO.getDeptCode();
 | 
	
		
			
				|  |  |                 String hosptitalCode = baseDoctorHospitalDO.getOrgCode();
 | 
	
		
			
				|  |  |                 List<DictHospitalDeptDO> dictHospitalDeptDO = dictHospitalDeptDao.findByOrgCodeAndCode(hosptitalCode,deptcode);
 | 
	
		
			
				|  |  |                 if(null!=dictHospitalDeptDO&&dictHospitalDeptDO.size()>0){
 | 
	
		
			
				|  |  |                     deptTyepCode = dictHospitalDeptDO.get(0).getDeptTypeCode();
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             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\",dept_type_code as \"deptTypeCode\" " +
 | 
	
		
			
				|  |  |                     " from wlyy_charge_dict where 1=1";
 | 
	
		
			
				|  |  |             sqlCharge+=" and charge_type in ( '"+chargeType+"')";
 | 
	
		
			
				|  |  |             sqlCharge+=" and dept_type_code in ( '"+deptTyepCode+"')";
 | 
	
		
			
				|  |  |             List<Map<String,Object>> chargeDictDOLists =  hibenateUtils.createSQLQuery(sqlCharge);
 | 
	
		
			
				|  |  |             map.put("chargeTypeList",chargeDictDOLists);
 | 
	
		
			
				|  |  |             //查询医生各项评价平均分
 | 
	
		
			
				|  |  |             String sqlscore = "SELECT " +
 | 
	
		
			
				|  |  |                     "AVG(a.score) AS \"score\"," +
 | 
	
	
		
			
				|  | @ -5575,7 +5679,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<Map<String, Object>> getVideoPrescriptionByDoctor(String doctor, String general_doctor, String wxId) {
 | 
	
		
			
				|  |  |         String condition = "";
 | 
	
		
			
				|  |  |         if ("xm_ykyy_wx".equals(wxId)) {
 | 
	
		
			
				|  |  |         /*if ("xm_ykyy_wx".equals(wxId)) {
 | 
	
		
			
				|  |  |             if (flag){
 | 
	
		
			
				|  |  |                 condition += "date_format(room.reservation_time,'YYYY-MM-DD hh24:mi:ss')  AS \"time\",";
 | 
	
		
			
				|  |  |             }else {
 | 
	
	
		
			
				|  | @ -5584,7 +5688,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             condition += "date_format(room.reservation_time ,'%Y-%m-%d %H:%i:%S' ) AS \"time\",";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         }*/
 | 
	
		
			
				|  |  |         String sql = "SELECT " +
 | 
	
		
			
				|  |  |                 "room.outpatient_id AS \"id\"," +
 | 
	
		
			
				|  |  |                 "room.patient_id AS \"patient_id\"," +
 | 
	
	
		
			
				|  | @ -5594,7 +5698,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 "patient.photo AS \"photo\"," +
 | 
	
		
			
				|  |  |                 "patient.birthday AS \"birthday\"," +
 | 
	
		
			
				|  |  |                 "patient.mobile AS \"mobile\"," +
 | 
	
		
			
				|  |  |                 "room.consult_type AS \"consult_type\"," + condition +
 | 
	
		
			
				|  |  |                 "room.consult_type AS \"consult_type\"," + "room.reservation_time as \"time\", " +
 | 
	
		
			
				|  |  |                 "room.reservation_type AS \"reservation_type\"," +
 | 
	
		
			
				|  |  |                 "outpatient.disease_img AS \"disease_img\"," +
 | 
	
		
			
				|  |  |                 "outpatient.description AS \"description\"," +
 | 
	
	
		
			
				|  | @ -5628,7 +5732,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 String idcard = (String) outpatient.get("idcard");
 | 
	
		
			
				|  |  |                 String patient_id = (String) outpatient.get("patient_id");
 | 
	
		
			
				|  |  |                 outpatient.put("age", DateUtil.getAgeForIdcard(idcard));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 //转换日期格式
 | 
	
		
			
				|  |  |                 outpatient.put("time",null==outpatient.get("time")?"":DateUtil.dateToStrLong(DateUtil.strToDateLong(outpatient.get("time").toString())));
 | 
	
		
			
				|  |  |                 String outpatient_id = (String) outpatient.get("id");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 String isAlert = redisTemplate.opsForValue().get("patient_alert_" + patient_id);
 | 
	
	
		
			
				|  | @ -5717,7 +5822,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         String condition = "";
 | 
	
		
			
				|  |  |         if ("xm_ykyy_wx".equals(wxId)) {
 | 
	
		
			
				|  |  |             if(flag){
 | 
	
		
			
				|  |  |                 condition += "date_format(room.reservation_time,'YYYY-MM-DD hh24:mi:ss')  AS \"time\",";
 | 
	
		
			
				|  |  |                 condition += "date_format(room.reservation_time ,'%Y-%m-%d %H:%i:%S' )  AS \"time\",";
 | 
	
		
			
				|  |  |                 condition += "date_format(room.reservation_time,'YYYY-MM-DD')  AS \"group_date\",";
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 condition += "to_char(room.reservation_time,'YYYY-MM-DD hh24:mi:ss')  AS \"time\",";
 | 
	
	
		
			
				|  | @ -5725,7 +5830,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             condition += "date_format(room.reservation_time ,'%Y-%m-%d %H:%i:%S' ) AS \"time\",";
 | 
	
		
			
				|  |  |                 condition += "date_format(room.reservation_time ,'%Y-%m-%d %H:%i:%S' ) AS \"time\",";
 | 
	
		
			
				|  |  |             condition += "date_format(room.reservation_time ,'%Y-%m-%d' ) AS \"group_date\",";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String sql = "SELECT " +
 | 
	
	
		
			
				|  | @ -8728,4 +8833,123 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |        return envelop;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     //应声开具处方管理
 | 
	
		
			
				|  |  |     public MixEnvelop prescriptionManage(String keyWord,String doctorId,String startTime,String endTime,String checkStatus,Integer page,Integer pageSize){
 | 
	
		
			
				|  |  |         String sql = " select p.create_time as \"createTime\"," +
 | 
	
		
			
				|  |  |                 " p.patient_name as \"patientName\"," +
 | 
	
		
			
				|  |  |                 " p.idcard as \"idcard\"," +
 | 
	
		
			
				|  |  |                 " o.card_no as \"cardNo\"," +
 | 
	
		
			
				|  |  |                 " p.check_status as \"checkStatus\"," +
 | 
	
		
			
				|  |  |                 " p.id as \"id\"," +
 | 
	
		
			
				|  |  |                 " p.check_reason as \"checkReason\" " +
 | 
	
		
			
				|  |  |                 " from wlyy_prescription p left join wlyy_outpatient o on p.outpatient_id  = o.id" +
 | 
	
		
			
				|  |  |                 " where  1=1";
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(keyWord)){
 | 
	
		
			
				|  |  |             sql+=" and (p.patient_name like '%"+keyWord+"%' or p.idcard = '"+keyWord+"'" +
 | 
	
		
			
				|  |  |                     " or o.card_no = '"+keyWord+"')";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(checkStatus)){
 | 
	
		
			
				|  |  |             sql+=" and p.check_status ="+checkStatus;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(doctorId)){
 | 
	
		
			
				|  |  |             sql+=" and p.doctor = '"+doctorId+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(startTime)){
 | 
	
		
			
				|  |  |             if("xm_ykyy_wx".equals(wechatId)){
 | 
	
		
			
				|  |  |                 if (flag){
 | 
	
		
			
				|  |  |                     sql+=" and p.create_time > '" + startTime + " 00:00:00'";
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     sql+=" and p.create_time > to_date('" + startTime + " 00:00:00', 'yyyy-mm-dd hh24:mi:ss') ";
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 sql+=" and p.create_time > '" + startTime + " 00:00:00' ";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(endTime)){
 | 
	
		
			
				|  |  |             if("xm_ykyy_wx".equals(wechatId)){
 | 
	
		
			
				|  |  |                 if (flag){
 | 
	
		
			
				|  |  |                     sql+="  and p.create_time<'" + endTime + " 23:59:59'";
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     sql+=" and p.create_time< to_date('" + endTime + " 23:59:59','yyyy-mm-dd hh24:mi:ss')";
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 sql+="  and p.create_time<'" + endTime + " 23:59:59'";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         sql+=" order by p.create_time desc";
 | 
	
		
			
				|  |  |         String sqlcount = "SELECT COUNT(1) AS \"total\" FROM ("+sql+") q";
 | 
	
		
			
				|  |  |         Long count = 0L;
 | 
	
		
			
				|  |  |         List<Map<String,Object>> total = hibenateUtils.createSQLQuery(sqlcount);
 | 
	
		
			
				|  |  |         if(total!=null){
 | 
	
		
			
				|  |  |             //mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
 | 
	
		
			
				|  |  |             count = hibenateUtils.objTransformLong(total.get(0).get("total"));
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         List<Map<String,Object>> resultList = hibenateUtils.createSQLQuery(sql,page,pageSize);
 | 
	
		
			
				|  |  |         for (Map<String,Object> map:resultList){
 | 
	
		
			
				|  |  |             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 | 
	
		
			
				|  |  |             map.put("createTime",null==map.get("createTime")?"":DateUtil.dateToStrLong(DateUtil.strToDateLong(map.get("createTime").toString())));
 | 
	
		
			
				|  |  |             String prescriptionId = map.get("id").toString();
 | 
	
		
			
				|  |  |             //获取处方信息
 | 
	
		
			
				|  |  |             List<WlyyPrescriptionDO> prescriptionDOs = null;
 | 
	
		
			
				|  |  |             prescriptionDOs = prescriptionDao.findById(prescriptionId);
 | 
	
		
			
				|  |  |             List<WlyyPrescriptionVO> prescriptionVOs = new ArrayList<>();
 | 
	
		
			
				|  |  |             List<BusinessOrderDO> businessOrders = new ArrayList<>();
 | 
	
		
			
				|  |  |             if (prescriptionDOs != null && prescriptionDOs.size() > 0) {
 | 
	
		
			
				|  |  |                 convertToModels(prescriptionDOs, prescriptionVOs, WlyyPrescriptionVO.class);
 | 
	
		
			
				|  |  |                 for (WlyyPrescriptionVO vo : prescriptionVOs) {
 | 
	
		
			
				|  |  |                     List<WlyyPrescriptionCheckDO> prescriptionCheckDO = prescriptionCheckDao.findByPrescriptionId(vo.getId());
 | 
	
		
			
				|  |  |                     //疾病信息
 | 
	
		
			
				|  |  |                     vo.setDiagnosisVOs(findDiagnosisById(vo.getId()));
 | 
	
		
			
				|  |  |                     if(null!=prescriptionCheckDO&&prescriptionCheckDO.size()>0){
 | 
	
		
			
				|  |  |                         vo.setDispUser(prescriptionCheckDO.get(0).getOperate());
 | 
	
		
			
				|  |  |                         vo.setDispUserName(prescriptionCheckDO.get(0).getOperateName());
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     //药品信息
 | 
	
		
			
				|  |  |                     List<WlyyPrescriptionInfoVO> infoVOs = new ArrayList<>();
 | 
	
		
			
				|  |  |                     System.out.println("=====PrescriptionId======"+vo.getId());
 | 
	
		
			
				|  |  |                     convertToModels(prescriptionInfoDao.findByPrescriptionId(vo.getId(), 1), infoVOs, WlyyPrescriptionInfoVO.class);
 | 
	
		
			
				|  |  |                     vo.setInfoVOs(infoVOs);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     //检查检验信息
 | 
	
		
			
				|  |  |                     List<WlyyInspectionVO> inspectionVOs = new ArrayList<>();
 | 
	
		
			
				|  |  |                     vo.setInspectionVOs(convertToModels(wlyyInspectionDao.findByPrescriptionId(vo.getId(), 1), inspectionVOs, WlyyInspectionVO.class));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     //支付信息
 | 
	
		
			
				|  |  |                     BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(vo.getId());
 | 
	
		
			
				|  |  |                     if (null!=businessOrderDO){
 | 
	
		
			
				|  |  |                         businessOrders.add(businessOrderDO);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             map.put("prescriptions",prescriptionVOs);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         MixEnvelop mixEnvelop = new MixEnvelop();
 | 
	
		
			
				|  |  |         mixEnvelop.setDetailModelList(resultList);
 | 
	
		
			
				|  |  |         mixEnvelop.setPageSize(pageSize);
 | 
	
		
			
				|  |  |         mixEnvelop.setCurrPage(page);
 | 
	
		
			
				|  |  |         mixEnvelop.setTotalCount(count.intValue());
 | 
	
		
			
				|  |  |         return  mixEnvelop;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     //作废处方
 | 
	
		
			
				|  |  |     public String disablePrescription(String prescriptionId) throws  Exception{
 | 
	
		
			
				|  |  |         WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(prescriptionId);
 | 
	
		
			
				|  |  |         if (null!=prescriptionDO){
 | 
	
		
			
				|  |  |             String hisId = prescriptionDO.getHisId();
 | 
	
		
			
				|  |  |             if("xm_xzzx_wx".equalsIgnoreCase(wechatId)){
 | 
	
		
			
				|  |  |                 List<WlyyPrescriptionDiagnosisDO> wlyyPrescriptionDiagnosisDOs = prescriptionDiagnosisDao.findByPrescriptionId(prescriptionId,1);
 | 
	
		
			
				|  |  |                 if (null!=wlyyPrescriptionDiagnosisDOs&&wlyyPrescriptionDiagnosisDOs.size()>0){
 | 
	
		
			
				|  |  |                     xzzxEntranceService.deleteCheckInputInfo(hisId,"0",prescriptionDO.getDoctor(),prescriptionDO.getPatientCode(),wlyyPrescriptionDiagnosisDOs);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             prescriptionDO.setStatus(-1);
 | 
	
		
			
				|  |  |             prescriptionDO.setCheckStatus(5);
 | 
	
		
			
				|  |  |             prescriptionDO.setCheckReason("作废处方");
 | 
	
		
			
				|  |  |             prescriptionDao.save(prescriptionDO);
 | 
	
		
			
				|  |  |             return "作废成功";
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             return "作废失败";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |