| 
					
				 | 
			
			
				@ -1,7 +1,324 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				package com.yihu.jw.hospital.prescription.service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.dict.dao.DictHospitalDeptDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.doctor.dao.BaseDoctorDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.dict.DictHospitalDeptDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.doctor.BaseDoctorDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.org.BaseOrgDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.BasePatientDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.PatientMedicareCardDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.consult.WlyyDoctorClinicRoomDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDiagnosisDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.consult.dao.DoctorClinicRoomConsultDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.consult.dao.HospitalWaitingRoomDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.prescription.dao.PrescriptionDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.prescription.dao.PrescriptionDiagnosisDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.prescription.dao.PrescriptionExpressageDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.prescription.dao.PrescriptionInfoDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.org.dao.BaseOrgDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.BasePatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.BasePatientMedicareCardDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionDiagnosisVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionExpressageVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.MixEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.rm.base.BaseRequestMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.common.IdCardUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.date.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.mysql.query.BaseJpaService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.collections.map.HashedMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.BeanUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.BeanPropertyRowMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.JdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.beans.PropertyDescriptor; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.lang.reflect.Method; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * Created by Trick on 2019/5/17. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				public class PrescriptionService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, PrescriptionDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private JdbcTemplate jdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseDoctorDao baseDoctorDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BasePatientDao basePatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BasePatientMedicareCardDao basePatientMedicareCardDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PrescriptionDao prescriptionDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PrescriptionDiagnosisDao prescriptionDiagnosisDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PrescriptionExpressageDao prescriptionExpressageDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PrescriptionInfoDao prescriptionInfoDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DoctorClinicRoomConsultDao doctorClinicRoomConsultDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private HospitalWaitingRoomDao HospitalWaitingRoomDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DictHospitalDeptDao dictHospitalDeptDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseOrgDao baseOrgDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public MixEnvelop findPrescriptionList(String patient, String status,String startTime, String endTime, Integer page, Integer size){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String totalSql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " count(1) AS total " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_prescription p "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        totalSql += " WHERE 1=1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(patient)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql+=" AND p.patient ='"+patient+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(status)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql+=" AND p.status IN ("+status+")"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(startTime)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql += " AND create_time >='"+startTime+" 00:00:00'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(endTime)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql += " AND create_time <='"+endTime+" 23:59:59'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Long count = 0L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (rstotal != null && rstotal.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            count = (Long) rstotal.get(0).get("total"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.id, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.saas_id AS saasId, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.recipe_no AS recipeNo, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.visit_no AS visitNo, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " 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 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(patient)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" AND p.patient ='"+patient+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(status)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" AND p.status IN ("+status+")"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(startTime)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND create_time >='"+startTime+" 00:00:00'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(endTime)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND create_time <='"+endTime+" 23:59:59'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql += " LIMIT " + (page - 1) * size + "," + size + ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<WlyyPrescriptionVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyyPrescriptionVO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //设置病种 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(list!=null&&list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(WlyyPrescriptionVO vo:list){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                vo.setDiagnosisVOs(findDiagnosisById(vo.getId())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return MixEnvelop.getSuccessListWithPage(BaseHospitalRequestMapping.Prescription.api_success, list, page, size, count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<WlyyPrescriptionDiagnosisVO> findDiagnosisById(String id){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<WlyyPrescriptionDiagnosisDO> list = prescriptionDiagnosisDao.findByPrescriptionId(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<WlyyPrescriptionDiagnosisVO> rs = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(list!=null&&list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return convertToModels(list,rs,WlyyPrescriptionDiagnosisVO.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return rs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Map<String,Object> findPrescriptionInfo(String prescriptionId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //续方信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> rs = new HashedMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(prescriptionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("prescription",convertToModel(wlyyPrescriptionDO,WlyyPrescriptionVO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //居民详情 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO basePatientDO = basePatientDao.findById(wlyyPrescriptionDO.getPatientCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("patientName",basePatientDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("patientId",basePatientDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("idCard",basePatientDO.getIdcard()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("sex", basePatientDO.getSex()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PatientMedicareCardDO cardDO = basePatientMedicareCardDao.findByTypeAndPatientCodeAndDel(PatientMedicareCardDO.Type.MedicareCard.getType(),wlyyPrescriptionDO.getPatientCode(),"1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("ssc",cardDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("age",IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //物流信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<WlyyPrescriptionExpressageDO> expressageDOs = prescriptionExpressageDao.findByPrescriptionId(wlyyPrescriptionDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(expressageDOs!=null&&expressageDOs.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            rs.put("expressage",convertToModel(expressageDOs.get(0), WlyyPrescriptionExpressageVO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            rs.put("expressage",null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //诊断信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("diagnosis",findDiagnosisById(wlyyPrescriptionDO.getId())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //药品信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("infos",prescriptionInfoDao.findByPrescriptionId(wlyyPrescriptionDO.getId())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return rs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Boolean checkPrescription(String patient){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<WlyyPrescriptionDO> list = prescriptionDao.findByPatientCode(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(list!=null&&list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 预约 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param json 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Boolean appointmentRevisit(JSONObject json){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //1.创建支付 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //2.支付回调 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        paymentCallback(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param json 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String paymentCallback(JSONObject json){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //创建诊室 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        createRoom(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Boolean createPrescription(JSONObject json){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String patient = json.getString("patient"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String doctor = json.getString("doctor"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String dept = json.getString("dept"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String hospital = json.getString("hospital"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String reservationTime = json.getString("reservationTime"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer consultType = json.getInteger("consultType"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO basePatientDO = basePatientDao.findById(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PatientMedicareCardDO cardDO = basePatientMedicareCardDao.findByTypeAndPatientCodeAndDel(PatientMedicareCardDO.Type.MedicareCard.getType(),patient,"1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseDoctorDO baseDoctorDO = baseDoctorDao.findOne(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        WlyyPrescriptionDO prescription = new WlyyPrescriptionDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescription.setStatus(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescription.setPatientCode(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescription.setPatientName(basePatientDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescription.setSsc(cardDO.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescription.setDoctor(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescription.setDoctorName(baseDoctorDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Boolean createRoom(JSONObject json){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String patient = json.getString("patient"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String doctor = json.getString("doctor"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String dept = json.getString("dept"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String hospital = json.getString("hospital"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String reservationTime = json.getString("reservationTime"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer consultType = json.getInteger("consultType"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO basePatientDO = basePatientDao.findById(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseDoctorDO baseDoctorDO = baseDoctorDao.findOne(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<WlyyDoctorClinicRoomDO> list = doctorClinicRoomConsultDao.findByDoctorAndStatus(doctor,1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(list!=null&&list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //已经有诊室不做操作 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //未有诊室则新增 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            WlyyDoctorClinicRoomDO room = new WlyyDoctorClinicRoomDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            room.setDoctor(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            room.setDoctorName(baseDoctorDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            room.setClinicName(baseDoctorDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            DictHospitalDeptDO deptDO = dictHospitalDeptDao.findByCode(dept); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            room.setDept(dept); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            room.setDept(deptDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BaseOrgDO baseOrgDO = baseOrgDao.findByCode(hospital); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            room.setDept(hospital); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            room.setDept(baseOrgDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            room.setClinicStatus(-1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            room.setDate(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            room.setStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            doctorClinicRoomConsultDao.save(room); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        WlyyHospitalWaitingRoomDO waitingRoom = new WlyyHospitalWaitingRoomDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        waitingRoom.setConsultType(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        waitingRoom.setPatientId(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        waitingRoom.setPatientName(basePatientDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        waitingRoom.setReservationTime(DateUtil.strToDate(reservationTime)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        waitingRoom.setVisitStatus(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        waitingRoom.setReservationType(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        waitingRoom.setSort(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        waitingRoom.setConsultType(consultType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        HospitalWaitingRoomDao.save(waitingRoom); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |