| 
					
				 | 
			
			
				@ -5,10 +5,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.dict.dao.DictHospitalDeptDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.doctor.dao.BaseDoctorDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.doctor.dao.BaseDoctorPatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.doctor.service.BaseDoctorInfoService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.dict.DictHospitalDeptDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.doctor.BaseDoctorDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.doctor.BaseDoctorPatientDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.doctor.BaseDoctorVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.org.BaseDoctorPatientFollowDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.org.BaseOrgDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.BasePatientDO; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -22,6 +25,7 @@ import com.yihu.jw.entity.hospital.doctor.WlyyDoctorWorkTimeDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.doctor.WlyyPatientRegisterTimeDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.mapping.PatientMappingDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.message.SystemMessageDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.prescription.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.order.BusinessOrderDO; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -35,20 +39,24 @@ import com.yihu.jw.hospital.doctor.dao.DoctorWorkTimeDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.doctor.dao.PatientRegisterTimeDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.doctor.dao.WlyyDoctorOnlineTimeDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.mapping.dao.PatientMappingDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.mapping.service.DoctorMappingService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.mapping.service.PatientMappingService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.message.service.SystemMessageService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.prescription.dao.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.prescription.service.entrance.EntranceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.prescription.service.useragent.BaseUserAgent; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.ykyy.service.YkyyService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.order.BusinessOrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.order.dao.BusinessOrderDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.order.pay.ylz.YlzPayService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.org.dao.BaseOrgDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.BaseDoctorPatientFollowDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.BasePatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.BasePatientMedicareCardDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.base.dict.DictHospitalDeptVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.base.doctor.BaseDoctorVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.base.org.BaseOrgVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.hospital.archive.ArchiveVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.hospital.consult.WlyyHospitalSysDictVO; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -56,9 +64,14 @@ import com.yihu.jw.restmodel.hospital.doctor.WlyyDoctorWorkTimeVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.hospital.prescription.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.Envelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.MixEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.ObjEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.PageEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.rm.iot.IotRequestMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.common.IdCardUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.common.LatitudeUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.date.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.utils.StringUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.utils.WebserviceUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.utils.hibernate.HibenateUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.mysql.query.BaseJpaService; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -70,8 +83,12 @@ import com.ylzinfo.ehc.trans.TransResponse; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import jxl.write.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import net.sf.json.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import net.sf.json.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import net.sf.json.xml.XMLSerializer; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.collections.map.HashedMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.jsoup.Jsoup; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.jsoup.nodes.Document; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.jsoup.select.Elements; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -187,8 +204,19 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PrescriptionEmrDao prescriptionEmrDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private WlyyConsultAdviceDao wlyyConsultAdviceDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseDoctorPatientDao baseDoctorPatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseUserAgent userAgent; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private WlyyHospitalSysDictDao hospitalSysDictDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private YlzPayService ylzPayService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BasePatientMedicareCardDao patientMedicareCardDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PatientMappingDao patientMappingDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Value("${demo.flag}") 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -489,10 +517,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param size 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public MixEnvelop findPrescriptionList(String patient, String status,String startTime, String endTime, Integer page, Integer size){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public MixEnvelop findPrescriptionList(String patient, String status,String startTime, String endTime, Integer page, Integer size,String wxId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String totalSql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " count(1) AS total " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " count(1) AS \"total\" " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_prescription p "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        totalSql += " WHERE 1=1 "; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -503,10 +531,20 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql+=" AND p.status IN ("+status+")"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(startTime)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql += " AND create_time >='"+startTime+" 00:00:00'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if("xm_ykyy_wx".equals(wxId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                totalSql +=" and create_time >= to_date('"+startTime+" 00:00:00','YYYY-MM-DD HH24:MI:SS')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                totalSql += " AND create_time >='"+startTime+" 00:00:00'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(endTime)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql += " AND create_time <='"+endTime+" 23:59:59'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if("xm_ykyy_wx".equals(wxId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                totalSql +=" and create_time <= to_date('"+startTime+" 23:59:59','YYYY-MM-DD HH24:MI:SS')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                totalSql += " AND create_time <='"+endTime+" 23:59:59'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -516,48 +554,48 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.id, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.real_order AS realOrder," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.origin_real_order AS originRealOrder," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.adm_no AS admNo," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.origin_adm_no AS originAdmNo," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.serial_no AS serialNo," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.type AS type, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.patient_code AS patientCode, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.patient_name AS patientName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.ssc AS ssc, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.doctor AS doctor, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.doctor_name AS doctorName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.`status` AS `status`, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.mk_fail_reason AS mkFailReason, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.mk_time AS mk_time, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.prescribe_reason AS prescribeReason, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.prescribe_time AS prescribeTime, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.pay_time AS payTime, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.dosage_time AS dosageTime, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.finish_time AS finishTime, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.create_time AS createTime, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.dept AS dept, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.dept_name AS deptName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.hospital AS hospital, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.hospital_name AS hospitalName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.consult AS consult, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.dispensary_type AS dispensaryType, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.reason AS reason, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.remark AS remark, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.cancel_reason AS cancelReason, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.ca_cert_data AS caCertData, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.ca_message AS caMessage, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.digital_sign_no AS digitalSignNo, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.original_data_abstract AS originalDataAbstract, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.str_original_data AS strOriginalData, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.his_dept_code AS hisDeptCode, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.his_doctor_code AS hisDoctorCode, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.his_gister_type_code AS hisGisterTypeCode, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.his_rate_type_code AS hisRateTypeCode, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.his_hospital AS hisHospital, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.his_register_fee AS hisRegisterFee, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.pay_status AS payStatus " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.id as \"id\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.real_order AS \"realOrder\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.origin_real_order AS \"originRealOrder\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.adm_no AS \"admNo\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.origin_adm_no AS \"originAdmNo\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.serial_no AS \"serialNo\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.type AS \"type\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.patient_code AS \"patientCode\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.patient_name AS \"patientName\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.ssc AS \"ssc\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.doctor AS \"doctor\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.doctor_name AS \"doctorName\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.status AS \"status\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.mk_fail_reason AS \"mkFailReason\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.mk_time AS \"mk_time\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.prescribe_reason AS \"prescribeReason\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.prescribe_time AS \"prescribeTime\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.pay_time AS \"payTime\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.dosage_time AS \"dosageTime\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.finish_time AS \"finishTime\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.create_time AS \"createTime\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.dept AS \"dept\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.dept_name AS \"deptName\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.hospital AS \"hospital\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.hospital_name AS \"hospitalName\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.consult AS \"consult\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.dispensary_type AS \"dispensaryType\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.reason AS \"reason\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.remark AS \"remark\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.cancel_reason AS \"cancelReason\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.ca_cert_data AS \"caCertData\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.ca_message AS \"caMessage\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.digital_sign_no AS \"digitalSignNo\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.original_data_abstract AS \"originalDataAbstract\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.str_original_data AS \"strOriginalData\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.his_dept_code AS \"hisDeptCode\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.his_doctor_code AS \"hisDoctorCode\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.his_gister_type_code AS \"hisGisterTypeCode\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.his_rate_type_code AS \"hisRateTypeCode\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.his_hospital AS \"hisHospital\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.his_register_fee AS \"hisRegisterFee\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.pay_status AS \"payStatus\" " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_prescription p " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE 1=1 "; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -568,10 +606,18 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" AND p.status IN ("+status+")"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(startTime)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND create_time >='"+startTime+" 00:00:00'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if("xm_ykyy_wx".equals(wxId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql +=" and create_time >= to_date('"+startTime+" 00:00:00','YYYY-MM-DD HH24:MI:SS')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql += " AND create_time >='"+startTime+" 00:00:00'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(endTime)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND create_time <='"+endTime+" 23:59:59'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if("xm_ykyy_wx".equals(wxId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql +=" and create_time <= to_date('"+startTime+" 23:59:59','YYYY-MM-DD HH24:MI:SS')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql += " AND create_time <='"+endTime+" 23:59:59'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql += " LIMIT " + (page - 1) * size + "," + size + ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<WlyyPrescriptionVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyyPrescriptionVO.class)); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -647,6 +693,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //1.保存就诊实体 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        WlyyOutpatientDO outpatientDO = objectMapper.readValue(outpatientJson,WlyyOutpatientDO.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO patientDO = basePatientDao.findById(outpatientDO.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseDoctorDO doctorDO = baseDoctorDao.findById(outpatientDO.getDoctor()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        outpatientDO.setMjz("mz"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        outpatientDO.setStatus("0"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -654,15 +701,24 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        outpatientDO.setIdcard(patientDO.getIdcard()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        outpatientDO.setOutpatientType("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        outpatientDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        outpatientDO.setPayStatus(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(outpatientDO.getRegisterDate()==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            outpatientDO.setRegisterDate(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        WlyyOutpatientDO outpatient = outpatientDao.save(outpatientDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Double price = 0.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(doctorDO!=null&&StringUtils.isNoneBlank(doctorDO.getFee())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             price = Double.parseDouble(doctorDO.getFee()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(price==0.0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            outpatientDO.setPayStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            outpatientDO.setPayStatus(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Double price = 0.01; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        businessOrderService.recharge(outpatient.getId(),"复诊-诊查费","2","复诊-诊查费",patientDO.getId(),patientDO.getName(),outpatient.getDoctor(),price); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2006,7 +2062,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                result.put("mes", "诊断完成"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Double price = 0.01; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Double price = prescription.getDrugFee(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                businessOrderService.recharge(prescription.getId(),"处方收费","4","处方收费",prescription.getPatientCode(),prescription.getPatientName(),prescription.getDoctor(),price); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //上传his开方 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //sendHisDiagnosis(jsonData, outpatientDO, prescription) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2961,9 +3017,15 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            //协同门诊量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            Integer coordinationCout = outpatientDao.countByDoctorAndStatusAndOutpatientType(doctor,"2","2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            rs.put("coordinationCout",coordinationCout); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //医生关注 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<BaseDoctorPatientFollowDO> doctorPatientFollowDOS = baseOrgPatientDao.findByDoctor(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (doctorPatientFollowDOS!=null&&doctorPatientFollowDOS.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                rs.put("attention","1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                rs.put("attention","0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //专家咨询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String zjCountsql = "SELECT id AS \"id\" FROM wlyy_consult_team WHERE doctor='"+doctor+"' AND (type=1 OR type=15)"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> zjList = jdbcTemplate.queryForList(zjCountsql); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3130,7 +3192,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param operator 1居民 2医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Map<String,Object> cancelOutPatient(String outPatientId,String cancelType,String cancelValue,String cancelRemark,Integer operator){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Map<String,Object> cancelOutPatient(String outPatientId,String cancelType,String cancelValue,String cancelRemark,Integer operator,String wxId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> rs = new HashedMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //判断医生是否接诊 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3151,16 +3213,19 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //更改门诊状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findOne(outPatientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        wlyyOutpatientDO.setStatus("-1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String description = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (1 == operator){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //居民取消 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            wlyyOutpatientDO.setPatientCancelRemark(cancelRemark); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            wlyyOutpatientDO.setPatientCancelType(cancelType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            wlyyOutpatientDO.setPatientCancelValue(cancelValue); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            description = "居民取消"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //医生拒绝接诊 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            wlyyOutpatientDO.setDoctorCancelRemark(cancelRemark); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            wlyyOutpatientDO.setDoctorCancelType(cancelType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            wlyyOutpatientDO.setDoctorCancelValue(cancelValue); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            description = "医生拒绝接诊"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        outpatientDao.save(wlyyOutpatientDO); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3170,7 +3235,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(list!=null&&list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientRegisterTimeDao.delete(list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (wxId.equalsIgnoreCase("xm_ykyy_wx")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                businessOrderService.orderRefund(wxId,wlyyOutpatientDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),description); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else if (wxId.equalsIgnoreCase("xm_zsyy_wx")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                businessOrderService.ylzOrderRefund(wxId,wlyyOutpatientDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),description); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("code",1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("mes","取消成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return  rs; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3323,14 +3398,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Map<String,Object>> findWaitingRoomPatient(String dept, Integer type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "patient.id AS id," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "patient.name AS name," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "patient.sex AS sex," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "patient.idcard AS idcard," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "patient.photo AS photo," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "waitingroom.reservation_type AS type," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "waitingroom.consult_type AS consult_type," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "waitingroom.reservation_time AS reservation_time " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "patient.id AS \"id\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "patient.name AS \"name\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "patient.sex AS \"sex\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "patient.idcard AS \"idcard\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "patient.photo AS \"photo\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "waitingroom.reservation_type AS \"type\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "waitingroom.consult_type AS \"consult_type\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "waitingroom.reservation_time AS \"reservation_time\" " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "wlyy_hospital_waiting_room waitingroom," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "base_patient patient " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3348,11 +3423,16 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject findWaitingRoomStatusCount(String dept) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject findWaitingRoomStatusCount(String dept,String wxId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String totalSql = "SELECT count(id) AS total FROM wlyy_hospital_waiting_room WHERE visit_status=1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        totalSql += " AND reservation_time >='"+DateUtil.dateToStrShort(new Date())+" 00:00:00'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        totalSql += " AND reservation_time <='"+DateUtil.dateToStrShort(new Date())+" 23:59:59'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String totalSql = "SELECT count(id) AS \"total\" FROM wlyy_hospital_waiting_room WHERE visit_status=1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if("xm_ykyy_wx".equals(wxId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql +=" and reservation_time >= to_date('"+DateUtil.dateToStrShort(new Date())+" 00:00:00','YYYY-MM-DD HH24:MI:SS')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql +=" and reservation_time <= to_date('"+DateUtil.dateToStrShort(new Date())+" 23:59:59','YYYY-MM-DD HH24:MI:SS')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql += " AND reservation_time >='"+DateUtil.dateToStrShort(new Date())+" 00:00:00'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql += " AND reservation_time <='"+DateUtil.dateToStrShort(new Date())+" 23:59:59'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Long count = 0L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (rstotal != null && rstotal.size() > 0) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3369,7 +3449,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<JSONObject> findClinicRoomList(String dept,String date,String consult_status) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<JSONObject> findClinicRoomList(String dept,String date,String consult_status,String wxId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isBlank(date)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            date = DateUtil.getStringDateShort(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3380,7 +3460,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNoneBlank(dept)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            doctorsql = doctorsql + " and dept = '"+dept+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        doctorsql = doctorsql+ " GROUP BY doctor"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        doctorsql = doctorsql+ " GROUP BY doctor,doctor_name,dept,dept_name"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> doctorlist = jdbcTemplate.queryForList(doctorsql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3408,24 +3488,30 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //获取预约了今天的候诊居民 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String waitingSql ="SELECT count(op.id) AS waitCount," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "room.doctor AS doctor, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "room.doctor_name AS doctorName " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String waitingSql ="SELECT count(op.id) AS \"waitCount\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "room.doctor AS \"doctor\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "room.doctor_name AS \"doctorName\" " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM wlyy_outpatient op,wlyy_hospital_waiting_room room " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE op.status=0 AND room.outpatient_id=op.id AND room.consult_type=2 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "AND room.doctor IS NOT NULL "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNoneBlank(dept)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            waitingSql = waitingSql + " and op.dept = '"+dept+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        waitingSql = waitingSql + "AND room.reservation_time>='"+date+" 00:00:00' AND room.reservation_time<='"+date+" 23:59:59' GROUP BY room.doctor; "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if("xm_ykyy_wx".equals(wxId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            waitingSql +=" AND room.reservation_time >= to_date('"+date+" 00:00:00','YYYY-MM-DD HH24:MI:SS')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            waitingSql +=" AND room.reservation_time <= to_date('"+date+" 23:59:59','YYYY-MM-DD HH24:MI:SS') GROUP BY room.doctor,room.doctor_name"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            waitingSql = waitingSql + "AND room.reservation_time>='"+date+" 00:00:00' AND room.reservation_time<='"+date+" 23:59:59' GROUP BY room.doctor,room.doctor_name; "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> waitinglist = jdbcTemplate.queryForList(waitingSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(waitinglist!=null&&waitinglist.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //根据身份证计算年龄 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(Map<String,Object> waitObj :waitinglist){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String doctor = (String) waitObj.get("doctor"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(StringUtils.isNoneBlank(doctor)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Long waitCount = (Long) waitObj.get("waitCount"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Long waitCount = Long.parseLong(waitObj.get("waitCount").toString()) ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if(result.keySet().contains(doctor)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        result.get(doctor).put("waiting_count",waitCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else{ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3448,18 +3534,21 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //获取进行中的居民 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String onlineSql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "room.outpatient_id AS id," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "room.patient_id AS patient_id," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "room.patient_name AS patient_name," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "patient.sex AS sex," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "patient.idcard AS idcard," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "patient.photo AS photo," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "patient.birthday AS birthday," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "room.consult_type AS consult_type," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "date_format(room.reservation_time ,'%Y-%m-%d %H:%i:%S' ) AS time," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "TIMESTAMPDIFF(MINUTE, room.reservation_time,NOW()) AS time_cost," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "room.doctor AS doctor, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "room.doctor_name AS doctorName " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "room.outpatient_id AS \"id\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "room.patient_id AS \"patient_id\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "room.patient_name AS \"patient_name\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "patient.sex AS \"sex\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "patient.idcard AS \"idcard\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "patient.photo AS \"photo\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "patient.birthday AS \"birthday\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "room.consult_type AS \"consult_type\","; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if("xm_ykyy_wx".equals(wxId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            onlineSql = onlineSql + "to_char(room.reservation_time,'YYYY-MM-DD hh24:mi:ss')  AS \"time\",ceil((sysdate-to_date(to_char(room.reservation_time,'YYYY-MM-DD hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss'))* 24 * 60) AS \"time_cost\","; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            onlineSql = onlineSql + "date_format(room.reservation_time,'%Y-%m-%d %H:%i:%S' )  AS \"time\",TIMESTAMPDIFF(MINUTE, room.reservation_time,NOW()) AS \"time_cost\","; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                onlineSql=onlineSql+"room.doctor AS \"doctor\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "room.doctor_name AS \"doctorName\" " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "wlyy_hospital_waiting_room room," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "base_patient patient," + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3474,18 +3563,40 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNoneBlank(dept)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            onlineSql = onlineSql + " and outpatient.dept = '"+dept+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        onlineSql = onlineSql+ "AND room.reservation_time>='"+date+" 00:00:00' AND room.reservation_time<='"+date+" 23:59:59' GROUP BY room.doctor"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if("xm_ykyy_wx".equalsIgnoreCase(wxId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            onlineSql +=" AND room.reservation_time >= to_date('"+date+" 00:00:00','YYYY-MM-DD HH24:MI:SS')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            onlineSql +=" AND room.reservation_time <= to_date('"+date+" 23:59:59','YYYY-MM-DD HH24:MI:SS') "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            onlineSql = onlineSql+ "AND room.reservation_time>='"+date+" 00:00:00' AND room.reservation_time<='"+date+" 23:59:59' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> onlinelist = jdbcTemplate.queryForList(onlineSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(onlinelist!=null&&onlinelist.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //根据身份证计算年龄 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(Map<String,Object> onlineObj :onlinelist){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<String> doctors = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> onlines = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (Map<String,Object> onlineObj :onlinelist){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String doctor = (String) onlineObj.get("doctor"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (doctors!=null&&doctors.size()!=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (!doctors.contains(doctor)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        doctors.add(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        onlines.add(onlineObj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctors.add(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    onlines.add(onlineObj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(Map<String,Object> onlineObj :onlines){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String doctor = (String) onlineObj.get("doctor"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(StringUtils.isNoneBlank(doctor)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if(result.keySet().contains(doctor)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        result.get(doctor).put("visit_status",2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        result.get(doctor).put("patient_name",(String) onlineObj.get("patient_name")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        result.get(doctor).put("time_cost",(Long) onlineObj.get("time_cost")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        result.get(doctor).put("time_cost",Long.parseLong(onlineObj.get("time_cost").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        JSONObject jsonObject = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        jsonObject.put("id",doctor); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3498,7 +3609,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        jsonObject.put("visit_status",2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        jsonObject.put("waiting_count",0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        jsonObject.put("patient_name",(String) onlineObj.get("patient_name")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        jsonObject.put("time_cost",(Long) onlineObj.get("time_cost")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        jsonObject.put("time_cost",Long.parseLong(onlineObj.get("time_cost").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        result.put(doctor,jsonObject); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3592,7 +3703,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Map<String,Object>> findDoctorByHospitalAndDiseaseAndDept(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,Integer page,Integer pagesize) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                                          String keyName, String workingTime, String consultStatus,String chargType,String consutlSort,String isAttention,Integer page,Integer pagesize) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      /*  if(page >=1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            page --; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3616,14 +3727,18 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.outpatient_type AS \"outpatientType\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " a.total AS \"consultTotal\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " h.org_name AS \"orgName\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " follow.patient AS \"followid\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " h.org_code AS \"orgCode\"" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " base_doctor d " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " JOIN base_doctor_hospital h ON h.doctor_code = d.id "+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " Left join base_doctor_patient_follow follow on follow.doctor = d.id and follow.patient='"+patientid+"'"+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " Left join ( select count(id) as total,doctor from wlyy_outpatient where status = 2 GROUP BY doctor ) a on a.doctor = d.id "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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.isNotBlank(diseaseKey)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" left join wlyy_doctor_special_disease sp on d.id = sp.doctor_code "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3965,12 +4080,58 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Map<String,Object> updatePatientInfo(String patient,String name,String idcard,String ssc){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Map<String,Object> updatePatientInfo(String patient,String name,String idcard,String ssc,Integer sex,String townCode,String townName,String committeeCode,String committeeName,String address,String photo,String mobile,String province,String provinceName,String city,String cityName){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> rs = new HashedMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO basePatientDO = basePatientDao.findById(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PatientMedicareCardDO patientMedicareCardDO = basePatientMedicareCardDao.findByTypeAndPatientCodeAndDel("A_01",patient,"1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        basePatientDO.setName(name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        basePatientDO.setIdcard(idcard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(name)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            basePatientDO.setName(name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(idcard)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            basePatientDO.setIdcard(idcard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (sex!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            basePatientDO.setSex(sex); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(province)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            basePatientDO.setProvinceCode(province); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(provinceName)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            basePatientDO.setProvinceName(provinceName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(city)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            basePatientDO.setCityCode(city); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(cityName)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            basePatientDO.setCityName(cityName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(townCode)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            basePatientDO.setTownCode(townCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(townName)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            basePatientDO.setTownName(townName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(committeeCode)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            basePatientDO.setCommitteeCode(committeeCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(committeeName)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            basePatientDO.setCommitteeName(committeeName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(address)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            basePatientDO.setAddress(address); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(photo)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            basePatientDO.setPhoto(photo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(mobile)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            basePatientDO.setMobile(mobile); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        basePatientDO = basePatientDao.save(basePatientDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (patientMedicareCardDO!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientMedicareCardDO.setCode(ssc); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -4285,7 +4446,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Long videoOnlineCount = 0l; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (rstotal != null && rstotal.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            videoOnlineCount = (Long) rstotal.get(0).get("total"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            videoOnlineCount = Long.parseLong(rstotal.get(0).get("total").toString()) ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return videoOnlineCount; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -4396,9 +4557,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param type 1图文 2视频 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Long getWaitVideoCount(String doctor,String type,String outpatient_type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Long getWaitVideoCount(String doctor,String type,String outpatient_type,String wxId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "count(outpatient.id) AS total " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "count(outpatient.id) AS \"total\" " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "wlyy_outpatient outpatient," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "base_patient patient " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -4411,11 +4572,19 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if("1".equals(outpatient_type)){//复诊 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql =  sql + " AND outpatient.type= '"+type+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if("2".equals(type)){//视频复诊才需要判断时间, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql =  sql + " AND outpatient.register_date is not null AND  outpatient.register_date >= '"+DateUtil.dateToStrShort(new Date())+" 00:00:00' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if("xm_ykyy_wx".equals(wxId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    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)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //协同门诊也需要判断时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql =  sql + " AND outpatient.register_date is not null AND  outpatient.register_date >= '"+DateUtil.dateToStrShort(new Date())+" 00:00:00' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if("xm_ykyy_wx".equals(wxId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                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' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -4527,9 +4696,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if("1".equals(outpatient.getType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    systemMessageDO.setTitle("图文复诊"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    systemMessageDO.setType("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    saveInquirySystemMessage(outpatient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    systemMessageDO.setTitle("视频复诊"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    systemMessageDO.setTitle("视频复诊预约成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    systemMessageDO.setType("2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    saveInquirySystemMessage(outpatient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            systemMessageDO.setReceiver(outpatient.getDoctor()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -4544,6 +4715,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("age",IdCardUtil.getAgeForIdcard(outpatient.getIdcard())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("gender",IdCardUtil.getSexForIdcard_new(outpatient.getIdcard())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("question",outpatient.getDescription()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String msg="您的视频复诊已预约成功。\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "预计"+outpatient.getDoctorName()+"医生将于"+outpatient.getRegisterDate()+" 与您进行视频咨询。请留意系统消息或微信公众号消息。咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("msg",msg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            systemMessageDO.setData(data.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            systemMessageService.saveMessage(systemMessageDO); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -4555,6 +4729,43 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return systemMessageDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void saveInquirySystemMessage(WlyyOutpatientDO outpatient){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        SystemMessageDO systemMessageDO = new SystemMessageDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String msg=""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String type=""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if("1".equals(outpatient.getType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            type="9"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            msg=outpatient.getPatientName()+",您好!您有一个图文复诊订单待支付,请及时支付。点击完成支付,如您已支付请忽略本条信息。"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            type="16"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            msg=outpatient.getPatientName()+",您好!您有一个视频复诊订单待支付,请及时支付。点击完成支付,如您已支付请忽略本条信息。"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        systemMessageDO.setTitle("支付提醒"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        systemMessageDO.setType("11"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        systemMessageDO.setSender(outpatient.getDoctor()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        systemMessageDO.setSenderName(outpatient.getDoctorName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        systemMessageDO.setRelationCode(outpatient.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        systemMessageDO.setReceiver(outpatient.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        systemMessageDO.setReceiverName(outpatient.getPatientName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject data = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("name",outpatient.getPatientName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("age",IdCardUtil.getAgeForIdcard(outpatient.getIdcard())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("gender",IdCardUtil.getSexForIdcard_new(outpatient.getIdcard())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("question",outpatient.getDescription()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("msg",msg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("type",type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            systemMessageDO.setData(data.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            systemMessageService.saveMessage(systemMessageDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 指定门诊医生医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param outpatientJson 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -4716,7 +4927,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param status 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Envelop findByGeneralDoctor(String generalDoctor,String startDate,String endDate,String status,String sort,Integer page,Integer size){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Envelop findByGeneralDoctor(String generalDoctor,String startDate,String endDate,String status,String sort,Integer page,Integer size,String wxId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sqlTotal ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " count(1) AS total "+ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -4725,10 +4936,20 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.general_doctor = '"+generalDoctor+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(startDate)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sqlTotal += " AND o.register_date >='"+startDate+" 00:00:00' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if("xm_ykyy_wx".equals(wxId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sqlTotal +=" and o.register_date >= to_date('"+startDate+" 00:00:00','YYYY-MM-DD HH24:MI:SS')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sqlTotal += " AND o.register_date >='"+startDate+" 00:00:00' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(endDate)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sqlTotal += " AND o.register_date <='"+endDate+" 23:59:59' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if("xm_ykyy_wx".equals(wxId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sqlTotal +=" and o.register_date <= to_date('"+endDate+" 23:59:59','YYYY-MM-DD HH24:MI:SS')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sqlTotal += " AND o.register_date <='"+endDate+" 23:59:59' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(status)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sqlTotal += " AND o.status ='"+status+"'"; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -4738,66 +4959,74 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Long total = 0l; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (rstotal != null && rstotal.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            total = (Long) rstotal.get(0).get("total"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            total = Long.parseLong(rstotal.get(0).get("total").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.id AS id, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.adm_no AS admNo, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.origin_adm_no AS originAdmNo, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.register_no AS registerNo, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.origin_register_no AS originRegisterNo, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.origin_con_no AS originConNo, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.con_no AS conNo, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.outpatient_type AS outpatientType, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.type AS type, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.hospital AS hospital, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.hospital_name AS hospitalName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.win_no AS winNo, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.dept AS dept, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.dept_name AS deptName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.patient AS patient, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.patient_name AS patientName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.doctor AS doctor, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.doctor_name AS doctorName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.general_doctor AS generalDoctor, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.general_doctor_name AS generalDoctorName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.idcard AS idcard, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.card_no AS cardNo, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.mjz AS mjz, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.icd10 AS icd10, "+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.icd10_name AS icd10Name, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.advice AS advice, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.adm_date AS admDate, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.description AS description, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.disease_img AS diseaseImg, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.create_time AS createTime, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.con_date AS conDate, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.patient_cancel_type AS patientCancelType, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.patient_cancel_value AS patientCancelValue, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.patient_cancel_remark AS patientCancelRemark, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.register_date AS registerDate, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.`status` AS STATUS, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.evaluate_status AS evaluateStatus " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.id AS \"id\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.adm_no AS \"admNo\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.origin_adm_no AS \"originAdmNo\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.register_no AS \"registerNo\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.origin_register_no AS \"originRegisterNo\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.origin_con_no AS \"originConNo\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.con_no AS \"conNo\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.outpatient_type AS \"outpatientType\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.type AS \"type\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.hospital AS \"hospital\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.hospital_name AS \"hospitalName\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.win_no AS \"winNo\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.dept AS \"dept\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.dept_name AS \"deptName\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.patient AS \"patient\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.patient_name AS \"patientName\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.doctor AS \"doctor\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.doctor_name AS \"doctorName\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.general_doctor AS \"generalDoctor\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.general_doctor_name AS \"generalDoctorName\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.idcard AS \"idcard\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.card_no AS \"cardNo\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.mjz AS \"mjz\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.icd10 AS \"icd10\", "+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.icd10_name AS \"icd10Name\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.advice AS \"advice\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.adm_date AS \"admDate\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.description AS \"description\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.disease_img AS \"diseaseImg\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.create_time AS \"createTime\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.con_date AS \"conDate\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.patient_cancel_type AS \"patientCancelType\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.patient_cancel_value AS \"patientCancelValue\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.patient_cancel_remark AS \"patientCancelRemark\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.register_date AS \"registerDate\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.status AS \"STATUS\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.evaluate_status AS \"evaluateStatus\" " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_outpatient o " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.general_doctor = '"+generalDoctor+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(startDate)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" AND o.register_date >='"+startDate+" 00:00:00'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if("xm_ykyy_wx".equals(wxId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql +=" and o.register_date >= to_date('"+startDate+" 00:00:00','YYYY-MM-DD HH24:MI:SS')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql += " AND o.register_date >='"+startDate+" 00:00:00' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(endDate)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" AND o.register_date <='"+endDate+" 23:59:59'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if("xm_ykyy_wx".equals(wxId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql +=" and o.register_date <= to_date('"+endDate+" 23:59:59','YYYY-MM-DD HH24:MI:SS')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql += " AND o.register_date <='"+endDate+" 23:59:59' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(status)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" AND o.status ='"+status+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(sort)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " ORDER BY o.register_date "+sort+" LIMIT " + (page - 1) * size + "," + size + ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " ORDER BY o.register_date "+sort; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " ORDER BY o.register_date ASC LIMIT " + (page - 1) * size + "," + size + ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " ORDER BY o.register_date ASC "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,page,size); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //List<WlyyOutpatientDO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyyOutpatientDO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return MixEnvelop.getSuccessListWithPage(BaseHospitalRequestMapping.Prescription.api_success, list, page, size, total); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -4835,7 +5064,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //统计科预约医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(1) AS total " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(1) AS \"total\" " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " base_doctor d " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " JOIN base_doctor_role r ON d.id = r.doctor_code " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -4854,7 +5083,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //统计在线医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String onlineSql="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(1) AS total " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(1) AS \"total\" " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " base_doctor d " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " JOIN base_doctor_role r ON d.id = r.doctor_code " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -4867,7 +5096,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Long onlineTotal = 0l; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (oltotal != null && oltotal.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            onlineTotal = (Long) oltotal.get(0).get("total"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            onlineTotal = Long.parseLong(oltotal.get(0).get("total").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("onlineTotal",onlineTotal); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -4888,7 +5117,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //总数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sqlAll = "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(room.outpatient_id) AS total " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(room.outpatient_id) AS \"total\" " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "wlyy_hospital_waiting_room room," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "wlyy_outpatient outpatient " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -4907,7 +5136,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //图文复诊 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String imgAll = "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(room.outpatient_id) AS total " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(room.outpatient_id) AS \"total\" " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "wlyy_hospital_waiting_room room," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "wlyy_outpatient outpatient " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -4926,7 +5155,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //视频复诊 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String spsql = "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(room.outpatient_id) AS total " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(room.outpatient_id) AS \"total\" " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "wlyy_hospital_waiting_room room," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "wlyy_outpatient outpatient " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -4946,7 +5175,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //协同门诊 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String xtsql = "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(room.outpatient_id) AS total " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(room.outpatient_id) AS \"total\" " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "wlyy_hospital_waiting_room room," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "wlyy_outpatient outpatient " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -5469,11 +5698,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (status==2){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            /*prescriptionDao.updateCheckStatus(prescriptionId,2,reason,20);*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.info("开始====="+wlyyPrescriptionDO.getCheckStatus()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            WlyyOutpatientDO outpatientDO = outpatientDao.findById(wlyyPrescriptionDO.getOutpatientId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (wxId.equalsIgnoreCase("xm_zsyy_wx")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    List<WlyyPrescriptionInfoDO> infoDOS = prescriptionInfoDao.findByPrescriptionId(prescriptionId,1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    /*List<WlyyPrescriptionInfoDO> infoDOS = prescriptionInfoDao.findByPrescriptionId(prescriptionId,1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    List<WlyyInspectionDO> inspectionDOS = wlyyInspectionDao.findByPrescriptionId(prescriptionId,1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    WlyyOutpatientDO outpatientDO = outpatientDao.findById(wlyyPrescriptionDO.getOutpatientId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(outpatientDO.getDoctor(), outpatientDO.getHospital()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //his处方拼接开方条件 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -5482,12 +5711,37 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        //设置his药品查询条件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        setInfoJsonParam(jsonData, doctorMappingDO, outpatientDO, wlyyPrescriptionDO, info, outpatientDO.getIcd10()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    for (WlyyInspectionDO ins:inspectionDOS){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        //设置his药品查询条件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        setInspectionParam(jsonData, doctorMappingDO, outpatientDO, wlyyPrescriptionDO, ins, outpatientDO.getIcd10()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sendHisDiagnosis(jsonData, outpatientDO, wlyyPrescriptionDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Map<String,Object> map = sendHisDiagnosis(jsonData, outpatientDO, wlyyPrescriptionDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (map.get("code").toString().equalsIgnoreCase("0")){*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        //  * @param applyDepaName @param applyDoctorName 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(prescriptionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String patientCode = prescriptionDO.getPatientCode(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String realerOrder = prescriptionDO.getRealOrder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String free  = prescriptionDO.getDrugFee()+""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String recipeTime = DateUtil.dateToStr(prescriptionDO.getCreateTime(),"yyyyMMddHHmmss"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String applyDepaName = prescriptionDO.getDeptName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String applyDoctorName = prescriptionDO.getDoctorName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        BasePatientDO patientDO = basePatientDao.findById(patientCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String userName = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String idcard = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (patientDO!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            userName = patientDO.getName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            idcard = patientDO.getIdcard(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patientCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String userNo = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (patientMappingDO!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            userNo = patientMappingDO.getMappingCode(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        PatientMedicareCardDO patientMedicareCardDO = patientMedicareCardDao.findByTypeAndPatientCodeAndDel("A_01",patientCode,"1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        ylzPayService.msgPush("01",patientMedicareCardDO.getCode(),"01",patientDO.getMobile(),"03",userNo,userName,idcard,realerOrder,applyDepaName,applyDoctorName,recipeTime,free,"1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                /*    }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //sendHisDiagnosis(jsonData, outpatientDO, wlyyPrescriptionDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -5496,6 +5750,31 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            wlyyPrescriptionDO.setCheckStatus(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            wlyyPrescriptionDO.setCheckReason(reason); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            wlyyPrescriptionDO.setStatus(20); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //发送系统消息 处方支付提醒 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            SystemMessageDO messageDO = new SystemMessageDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDO.setType("6"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDO.setTitle("处方支付提醒"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDO.setSender(outpatientDO.getDoctor()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDO.setSenderName(outpatientDO.getDoctorName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDO.setRelationCode(outpatientDO.getId()+","+wlyyPrescriptionDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDO.setReceiver(outpatientDO.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDO.setReceiverName(outpatientDO.getPatientName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject data = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.put("name",outpatientDO.getPatientName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.put("age", IdCardUtil.getAgeForIdcard(outpatientDO.getIdcard())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.put("gender",IdCardUtil.getSexForIdcard_new(outpatientDO.getIdcard())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.put("question",""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String msg=outpatientDO.getPatientName()+",您好!医生已为您开具处方,请及时支付。如您已支付请忽略本条信息。"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.put("msg",msg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                messageDO.setData(data.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                systemMessageService.saveMessage(messageDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            wlyyPrescriptionDO.setCheckStatus(status); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            wlyyPrescriptionDO.setCheckReason(reason); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -5505,6 +5784,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (status==2||status==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sendCheckMessage(status,wlyyPrescriptionDO,operate,operateName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return prescriptionCheckDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -5762,7 +6043,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 保存排班规则 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param workRoleJsons 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param advicesJson 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Boolean sendOutPatientSuggest(String advicesJson){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -5804,6 +6085,18 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        logger.info("调用电子病历查询接口请求成功,返回值xmlstr:" + returnValue); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        XMLSerializer xmlSerializer = new XMLSerializer(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        net.sf.json.JSON json = xmlSerializer.read(returnValue); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        logger.info("返回json"+json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Object retInfo=  ((JSONObject) json).get("HtResponse"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        logger.info("retInfo:"+retInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(retInfo!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject jsonObject = (JSONObject)retInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String content =jsonObject.getString("XML_CONT"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Document doc = Jsoup.parse(content); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Elements rows = doc.select("table[class=list]").get(0).select("tr"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return returnValue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -5841,4 +6134,277 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 关注医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param doctorId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    public Envelop attentionDoctor(String doctorId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        BaseDoctorDO doctorDO = baseDoctorDao.findById(doctorId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        if (doctorDO==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            return Envelop.getError("医生不存在"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        BaseDoctorPatientDO doctorPatientDO = new BaseDoctorPatientDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        doctorPatientDO.setDoctorCode(doctorId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        doctorPatientDO.setDoctorName(doctorDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        String uid = userAgent.getUID(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        BasePatientDO patientDO = basePatientDao.findById(uid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        if (patientDO==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            return ObjEnvelop.getError("患者不存在"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        doctorPatientDO.setPatientCode(uid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        doctorPatientDO.setPatientName(patientDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        doctorPatientDO.setStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        baseDoctorPatientDao.save(doctorPatientDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        return ObjEnvelop.getSuccess("关注成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     *查询患者关注的医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param keyWord 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param outPatient 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param jobTitleCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param shift 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param page 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param pagesize 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    public PageEnvelop findAllAttentionDoctor(String keyWord, Integer outPatient, String jobTitleCode, Integer shift, Integer page, Integer pagesize) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        StringBuffer sql = new StringBuffer("SELECT DISTINCT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tc.*, e.org_name,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\te.dept_name,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tIFNULL(k.disease_name,NULL)\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tdisease_name\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tbase_doctor c\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "RIGHT JOIN (\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tSELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\t\tdoctor_code\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tFROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\t\tbase_doctor_paitent\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tWHERE\n" + " patient_code = '"+userAgent.getUID()+"'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                " ) d ON c.id = d.doctor_code\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "LEFT JOIN (\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tSELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\t\t*\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tFROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\t\twlyy_doctor_special_disease\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                ") k ON k.doctor_code = c.id\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "LEFT JOIN (\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tSELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\t\t*\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tFROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\t\tbase_doctor_hospital\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                ") e ON e.doctor_code = c.id"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        StringBuffer countSql = new StringBuffer("SELECT DISTINCT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tc.*, e.org_name,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\te.dept_name,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tk.disease_name\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tbase_doctor c\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "RIGHT JOIN (\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tSELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\t\tdoctor_code\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tFROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\t\tbase_doctor_paitent\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tWHERE\n" + " patient_code = '"+userAgent.getUID()+"'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                " ) d ON c.id = d.doctor_code\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "LEFT JOIN (\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tSELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\t\t*\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tFROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\t\twlyy_doctor_special_disease\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                ") k ON k.doctor_code = c.id\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "LEFT JOIN (\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tSELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\t\t*\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\tFROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "\t\tbase_doctor_hospital\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                ") e ON e.doctor_code = c.id"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        if (shift==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            sql.append(" JOIN (\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\tSELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\t\t*\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\tFROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\t\tbase_doctor_hospital\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\tWHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\t\tdept_name = '发热门诊'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    ") h ON h.doctor_code = c.id "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            countSql.append(" JOIN (\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\tSELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\t\t*\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\tFROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\t\tbase_doctor_hospital\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\tWHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\t\tdept_name = '发热门诊'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    ") h ON h.doctor_code = c.id "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        if (StringUtils.isNotEmpty(jobTitleCode)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            sql.append(" AND c.job_title_code =").append(jobTitleCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            countSql.append(" AND c.job_title_code =").append(jobTitleCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        if (outPatient==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            sql.append(" JOIN (\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\tSELECT DISTINCT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\t\t*\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\tFROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\t\twlyy_doctor_work_time\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\tGROUP BY\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\t\tdoctor\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    ") f ON f.doctor = c.id"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            countSql.append(" JOIN (\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\tSELECT DISTINCT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\t\t*\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\tFROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\t\twlyy_doctor_work_time\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\tGROUP BY\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\t\tdoctor\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    ") f ON f.doctor = c.id"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        if(StringUtils.isNotEmpty(keyWord)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            sql.append(" WHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\t(\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    " c.`name` LIKE  '%"+keyWord+"%'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    " OR e.dept_name LIKE '%"+keyWord+"%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    " OR e.org_name LIKE  '%"+keyWord+"%'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    " OR c.expertise LIKE  '%"+keyWord+"%'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    " OR c.introduce LIKE  '%"+keyWord+"%'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    " OR k.disease_name LIKE  '%"+keyWord+"%'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    ") "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            countSql.append(" WHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    "\t(\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    " c.`name` LIKE  '%"+keyWord+"%'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    " OR e.dept_name LIKE '%"+keyWord+"%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    " OR e.org_name LIKE  '%"+keyWord+"%'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    " OR c.expertise LIKE  '%"+keyWord+"%'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    " OR c.introduce LIKE  '%"+keyWord+"%'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    " OR k.disease_name LIKE  '%"+keyWord+"%'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    ") "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        countSql.append(" GROUP BY c.id"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        List<Map<String, Object>> countList = jdbcTemplate.queryForList(countSql.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        long count=countList.size(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        sql.append(" ORDER BY C.update_time LIMIT ").append((page-1)*pagesize).append(",").append(pagesize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        List<BaseDoctorVO> list = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        mapList.forEach(one->{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            String json = com.alibaba.fastjson.JSONObject.toJSONString(one); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            BaseDoctorDO doctorDO = com.alibaba.fastjson.JSONObject.parseObject(json, BaseDoctorDO.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            BaseDoctorVO doctorVO = convertToModel(doctorDO, BaseDoctorVO.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            if (one.get("org_name")!=null&&StringUtils.isNotEmpty(one.get("org_name").toString())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                doctorVO.setHospital(one.get("org_name").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            if(one.get("dept_name")!=null&&StringUtils.isNotEmpty(one.get("dept_name").toString())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                ArrayList<String> deptList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                deptList.add(one.get("dept_name").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                doctorVO.setDepartment(deptList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            if (one.get("disease_name")!=null&&StringUtils.isNotEmpty(one.get("disease_name").toString())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                ArrayList<String> disList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                disList.add(one.get("disease_name").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                doctorVO.setDisease(disList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            if (list!=null&&list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                list.forEach(tow->{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    if (doctorVO.getId().equalsIgnoreCase(tow.getId())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        if (tow.getDepartment()!=null&&StringUtils.isNotEmpty(tow.getDepartment().get(0))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            doctorVO.getDepartment().add(tow.getDepartment().get(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        if (tow.getDisease()!=null&&StringUtils.isNotEmpty(tow.getDisease().get(0))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            doctorVO.getDisease().add(tow.getDisease().get(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        list.remove(tow); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            list.add(doctorVO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        return PageEnvelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find,list,page,pagesize,count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 查询患者所有处方信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param page 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param size 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PageEnvelop findPatientAllPrescription(String keyName,String status,Integer page, Integer size) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String uid = userAgent.getUID(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        StringBuffer sql = new StringBuffer("select a.* from wlyy_prescription a,wlyy_prescription_info b where a.patient_code ='"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        StringBuffer countSql = new StringBuffer("select COUNT(a.id) count from wlyy_prescription a,wlyy_prescription_info b  where a.patient_code ='"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql.append(uid).append("' and a.status >= 0 AND a.id = b.prescription_id"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        countSql.append(uid).append("' and a.status >= 0 AND a.id = b.prescription_id "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotEmpty(keyName)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql.append(" AND (" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " a.doctor_name LIKE '%"+keyName+"%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " OR a.dept_name LIKE'%"+keyName+"%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " OR a.hospital_name LIKE '%"+keyName+"%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " OR b.drug_name LIKE '%"+keyName+"%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " OR a.real_order LIKE '%"+keyName+"%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    ")"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            countSql.append(" AND (" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " a.doctor_name LIKE '%"+keyName+"%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " OR a.dept_name LIKE'%"+keyName+"%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " OR a.hospital_name LIKE '%"+keyName+"%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " OR b.drug_name LIKE '%"+keyName+"%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " OR a.real_order LIKE '%"+keyName+"%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    ")"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotEmpty(status)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            status= status.substring(1, status.length() - 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql.append(" AND a.status IN(").append(status).append(")"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            countSql.append(" AND a.status IN(").append(status).append(")"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql.append(" order by a.prescribe_time limit ").append((page-1)*size).append(",").append(size); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<WlyyPrescriptionDO> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(WlyyPrescriptionDO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> mapList = jdbcTemplate.queryForList(countSql.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        long count = Long.parseLong(mapList.get(0).get("count").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        logger.info("sql="+sql.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        logger.info("countSql="+countSql.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return PageEnvelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find,list,page,size,count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 查询取药地址 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param outpatientId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param longitude 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param dimension 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public MixEnvelop findDrugAddress(String outpatientId, String longitude, String dimension) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql="SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\ta.*\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tbase_org a\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "LEFT JOIN (\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tSELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\t\tc.*\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tFROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\t\twlyy_prescription_expressage c\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "\tWHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " c.outpatient_id = '"+outpatientId+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ) d ON a.`code` = d.hospital_code"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseOrgDO baseOrgDO = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BaseOrgDO.class)).get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, String> rs = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("hospital",baseOrgDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("address",baseOrgDO.getAddress()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String distance = LatitudeUtils.getDistance(longitude, dimension, baseOrgDO.getLongitude(), baseOrgDO.getLatitude()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("distance",distance); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find,rs); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |