| 
					
				 | 
			
			
				@ -0,0 +1,786 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				package com.yihu.jw.hospital.prescription.service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				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.BaseDoctorRoleDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.BasePatientDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.wx.BasePatientWechatDo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.wx.WxWechatDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.mapping.PatientMappingDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.order.BusinessOrderDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.consult.dao.HospitalWaitingRoomDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.dict.WlyyChargeDictDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.doctor.dao.PatientRegisterTimeDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.drugstore.dao.BaseDrugStoreDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.mapping.dao.PatientMappingDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.mapping.service.PatientMappingService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.prescription.dao.OutpatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.prescription.dao.PrescriptionDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.prescription.dao.PrescriptionExpressageDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.prescription.service.entrance.TnyyEntranceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				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.patient.dao.BasePatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.BasePatientMedicareCardDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.hospital.prescription.WlyyOutpatientVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.wechat.dao.BasePatientWechatDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.wechat.dao.WechatDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.mysql.query.BaseJpaService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.utils.network.HttpResponse; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.utils.network.HttpUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.collections.map.HashedMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Value; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * Created by Trick on 2019/5/17. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				public class TnPrescriptionService extends BaseJpaService<WlyyPrescriptionDO, PrescriptionDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private static final Logger logger = LoggerFactory.getLogger(TnPrescriptionService.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BasePatientDao basePatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PrescriptionExpressageDao prescriptionExpressageDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private HospitalWaitingRoomDao hospitalWaitingRoomDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PatientMappingService patientMappingService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private OutpatientDao outpatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private ObjectMapper objectMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PatientRegisterTimeDao patientRegisterTimeDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private TnyyEntranceService tnyyEntranceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BusinessOrderDao businessOrderDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private WechatDao wechatDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BasePatientWechatDao patientWechatDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BusinessOrderService businessOrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseDrugStoreDao baseDrugStoreDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BasePatientMedicareCardDao basePatientMedicareCardDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PatientMappingDao patientMappingDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DictHospitalDeptDao dictHospitalDeptDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseDoctorHospitalDao doctorHospitalDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseDoctorRoleDao doctorRoleDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DoctorMappingDao doctorMappingDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private WlyyChargeDictDao wlyyChargeDictDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private WlyyHospitalSysDictDao hospitalSysDictDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseDoctorDao doctorDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Value("${demo.flag}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private boolean demoFlag; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Value("${wechat.flag}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private boolean flag; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Value("${pay.flag}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private boolean payFlag; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Value("${wechat.id}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private String wechatId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private YkyyService ykyyService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取居民就诊记录接口 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patient 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param startTime 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param endTime 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param demoFlag 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public  List<WlyyOutpatientVO> findOutpatientList(String patient, String cardNo, String startTime, String endTime, boolean demoFlag, String ksdm)throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        logger.info("findOutpatientList patient:"+patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String patNo =""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(cardNo)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BasePatientDO patientDO = basePatientDao.findByIdAndDel(patient,"1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            /*JSONArray res = ykyyEntranceService.findPatientCodeByCardNo(cardNo,false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(res !=null&&res.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject object = (JSONObject) res.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (object.get("brid")!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patNo = object.get("brid").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONArray res = tnyyEntranceService.selectPatientMappingCode(patientDO.getIdcard()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (res!=null&&res.size()!=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject object = res.getJSONObject(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patNo = object.getString("BRID"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(!StringUtils.isBlank(patNo)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (patientMappingDO!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientMappingDO.setMappingCode(patNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientMappingDO = new PatientMappingDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientMappingDO.setMappingCode(patNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientMappingDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientMappingDO.setSource("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientMappingDO.setPatient(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientMappingDO.setIdcard(patientDO.getIdcard()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientMappingDO.setPatientName(patientDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patientMappingDao.save(patientMappingDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (patientMappingDO!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patNo = patientMappingDO.getMappingCode(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isBlank(patNo)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        logger.info("findOutpatientList patNo "+patNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return tnyyEntranceService.BS30025(patNo,null,startTime,endTime,demoFlag,ksdm); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<WlyyPrescriptionVO> findOriginPrescriptionList(String registerSn, String patient, String realOrder, String admNo, boolean demoFlag)throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String patNo =patientMappingService.findHisPatNoByPatient(patient,null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isBlank(patNo)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //BS16017(String REGISTER_SN,String realOrder,String PAT_NO,String ADM_NO,boolean demoFlag) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        logger.info("findOriginPrescriptionList: registerSn:"+registerSn+" patient"+patient+" patNo:"+patNo+" realOrder:"+realOrder+" admNo:"+admNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return tnyyEntranceService.findMS_CF01And02(admNo,demoFlag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取居民就诊记录接口 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patient 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public  WlyyOutpatientVO findOutpatientInfo(String patient,String conNo, boolean demoFlag,String ksdm)throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        logger.info("findOutpatientList patient:"+patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String patNo =patientMappingService.findYkyyPatNoByPatient(patient,demoFlag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isBlank(patNo)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        logger.info("findOutpatientList patNo "+patNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<WlyyOutpatientVO> wlyyOutpatientVOS = tnyyEntranceService.BS30025(patNo,conNo,null,null,demoFlag,ksdm); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (wlyyOutpatientVOS!=null&&wlyyOutpatientVOS.size()!=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            WlyyOutpatientVO outpatientVO = wlyyOutpatientVOS.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BasePatientDO patientDO = basePatientDao.findById(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            outpatientVO.setSex(patientDO.getSex()+""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            outpatientVO.setBirthday(patientDO.getBirthday()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            outpatientVO.setIdcard(patientDO.getIdcard()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return outpatientVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 发起图文和视频复诊 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param outpatientJson 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param expressageJson 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     *//* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public WlyyOutpatientDO appointmentRevisit(String outpatientJson, String expressageJson, String registerJson, String chargeType) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //1.保存就诊实体 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        WlyyOutpatientDO outpatientDO = objectMapper.readValue(outpatientJson, WlyyOutpatientDO.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO patientDO = basePatientDao.findById(outpatientDO.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseDoctorDO doctorDO = doctorDao.findById(outpatientDO.getDoctor()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        outpatientDO.setMjz("mz"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        outpatientDO.setStatus("0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        outpatientDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        outpatientDO.setIdcard(patientDO.getIdcard()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        outpatientDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (!payFlag){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            outpatientDO.setPayStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            outpatientDO.setPayStatus(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (outpatientDO.getRegisterDate() == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            outpatientDO.setRegisterDate(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        WlyyOutpatientDO outpatient = outpatientDao.save(outpatientDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BusinessOrderDO businessOrderDO = new BusinessOrderDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if("3".equalsIgnoreCase(outpatient.getOutpatientType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            businessOrderDO.setRelationCode(outpatient.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            businessOrderDO.setRelationName("专家咨询费"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            businessOrderDO.setDescription("专家咨询费"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            businessOrderDO.setRematk(outpatient.getDescription()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            businessOrderDO.setPatient(outpatient.getConsumer()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            businessOrderDO.setPatientName(outpatient.getConsumerName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            businessOrderDO.setDoctor(outpatient.getDoctor()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (outpatientDO.getType().equalsIgnoreCase("1")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                businessOrderDO.setOrderType(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                businessOrderDO.setOrderCategory("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else if (outpatientDO.getType().equalsIgnoreCase("2")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                businessOrderDO.setOrderType(17); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                businessOrderDO.setOrderCategory("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            businessOrderDO.setRelationCode(outpatient.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            businessOrderDO.setRelationName("复诊-诊查费"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            businessOrderDO.setDescription("复诊-诊查费"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            businessOrderDO.setRematk(outpatient.getDescription()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            businessOrderDO.setPatient(outpatient.getConsumer()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            businessOrderDO.setPatientName(outpatient.getConsumerName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            businessOrderDO.setDoctor(outpatient.getDoctor()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (outpatientDO.getType().equalsIgnoreCase("1")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                businessOrderDO.setOrderType(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                businessOrderDO.setOrderCategory("2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else if (outpatientDO.getType().equalsIgnoreCase("2")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                businessOrderDO.setOrderType(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                businessOrderDO.setOrderCategory("3"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("WX_MONEY"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Double price = 0.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String chargeType1 = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (doctorDO!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (outpatient.getOutpatientType().equalsIgnoreCase("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(outpatientDO.getType().equalsIgnoreCase("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    chargeType1 = doctorDO.getTwfzChargeType(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else if(outpatientDO.getType().equalsIgnoreCase("2")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    chargeType1 = doctorDO.getSpfzChargeType(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else if (outpatient.getOutpatientType().equalsIgnoreCase("3")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(outpatientDO.getType().equalsIgnoreCase("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    chargeType1 = doctorDO.getTwzxChargeType(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else if(outpatientDO.getType().equalsIgnoreCase("2")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    chargeType1 = doctorDO.getSpzxChargeType(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else if (outpatient.getOutpatientType().equalsIgnoreCase("2")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                chargeType1 = doctorDO.getXtfzChargeType(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(doctorDO!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (StringUtils.isNoneBlank(chargeType1)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    WlyyChargeDictDO chargeDictDO = wlyyChargeDictDao.findByChargeType(chargeType1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (chargeDictDO!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        price = chargeDictDO.getReqFee(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        price = Double.parseDouble(hospitalSysDictDO.getDictValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                price = Double.parseDouble(hospitalSysDictDO.getDictValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNoneBlank(chargeType)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                WlyyChargeDictDO chargeDictDO = wlyyChargeDictDao.findByChargeType(chargeType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (chargeDictDO!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    price = chargeDictDO.getReqFee(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    price = Double.parseDouble(hospitalSysDictDO.getDictValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        *//*if (doctorDO != null && StringUtils.isNoneBlank(doctorDO.getFee())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            price = Double.parseDouble(doctorDO.getFee()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            price = Double.parseDouble(hospitalSysDictDO.getDictValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }*//* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (price == 0.0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            outpatientDO.setPayStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            outpatientDO.setPayStatus(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        businessOrderDO.setPayPrice(price*100); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (!flag){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            businessOrderDO = businessOrderService.saveOrder(businessOrderDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        WlyyPatientRegisterTimeDO registerTimeDO = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //如果是视频预约咨询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotBlank(registerJson)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                registerTimeDO = objectMapper.readValue(registerJson, WlyyPatientRegisterTimeDO.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                registerTimeDO.setOutpatientId(outpatient.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                registerTimeDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patientRegisterTimeDao.save(registerTimeDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new RuntimeException("号源已经被预约,请选择其他号源"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ("3".equalsIgnoreCase(outpatient.getOutpatientType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //2.物流信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            WlyyPrescriptionExpressageDO expressageDO = objectMapper.readValue(expressageJson, WlyyPrescriptionExpressageDO.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            expressageDO.setDel(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            expressageDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            expressageDO.setOutpatientId(outpatient.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionExpressageDao.save(expressageDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (0==expressageDO.getOneselfPickupFlg()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String drugCode= expressageDO.getHospitalCode()==null?"5550":expressageDO.getHospitalCode(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    expressageDO.setHospitalCode(drugCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                System.out.println("进入物流信息"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                expressageDO.setDel(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                expressageDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                expressageDO.setOutpatientId(outpatient.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                prescriptionExpressageDao.save(expressageDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                System.out.println("写入自取信息"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String drugStoreCode = expressageDO.getHospitalCode(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                BaseDrugStoreDO baseDrugStoreDO = baseDrugStoreDao.findDrugByid(drugStoreCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (null!=baseDrugStoreDO){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    expressageDO.setCityCode(baseDrugStoreDO.getCityCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    expressageDO.setCityName(baseDrugStoreDO.getCityName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    expressageDO.setProvinceCode(baseDrugStoreDO.getProvinceCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    expressageDO.setProvinceName(baseDrugStoreDO.getProvinceName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    expressageDO.setTownCode(baseDrugStoreDO.getTownCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    expressageDO.setTownName(baseDrugStoreDO.getTownName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    expressageDO.setHospitalCode(baseDrugStoreDO.getDrugStoreCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    expressageDO.setHospitalName(baseDrugStoreDO.getHospitalName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    expressageDO.setHospitalAddress(baseDrugStoreDO.getAddress()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                expressageDO.setDel(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                expressageDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                expressageDO.setOutpatientId(outpatient.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                prescriptionExpressageDao.save(expressageDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //3.创建候诊室 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        createRoom(outpatient, chargeType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return outpatient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    *//** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 创建候诊室 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param outpatientDO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     *//* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Boolean createRoom(WlyyOutpatientDO outpatientDO, String chargeType) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        WlyyHospitalWaitingRoomDO waitingRoom = new WlyyHospitalWaitingRoomDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        waitingRoom.setDept(outpatientDO.getDept()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        waitingRoom.setDeptName(outpatientDO.getDeptName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        waitingRoom.setHospital(outpatientDO.getHospital()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        waitingRoom.setHospitalName(outpatientDO.getHospitalName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //是否是有协同门诊医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(outpatientDO.getGeneralDoctor())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            waitingRoom.setGeneralDoctor(outpatientDO.getGeneralDoctor()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            waitingRoom.setGeneralDoctorName(outpatientDO.getGeneralDoctorName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        waitingRoom.setPatientId(outpatientDO.getConsumer()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        waitingRoom.setPatientName(outpatientDO.getConsumerName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        waitingRoom.setReservationTime(outpatientDO.getRegisterDate()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        waitingRoom.setVisitStatus(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //设置复诊类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        waitingRoom.setReservationType(StringUtils.isNotBlank(outpatientDO.getOutpatientType()) ? Integer.parseInt(outpatientDO.getOutpatientType()) : 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        waitingRoom.setSort(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        waitingRoom.setConsultType(Integer.parseInt(outpatientDO.getType())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(outpatientDO.getDoctor())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            waitingRoom.setDoctor(outpatientDO.getDoctor()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            waitingRoom.setDoctorName(outpatientDO.getDoctorName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        waitingRoom.setOutpatientId(outpatientDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        waitingRoom.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(chargeType)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            waitingRoom.setChargeType(chargeType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        hospitalWaitingRoomDao.save(waitingRoom); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取药品 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `prescription_id` varchar(50) DEFAULT NULL COMMENT '处方code 关联表wlyy_prescription code', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `drug_no` varchar(50) DEFAULT NULL COMMENT '药品编号', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `drug_name` varchar(50) DEFAULT NULL COMMENT '药品名称', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `disp_deposite` varchar(50) DEFAULT NULL COMMENT '库房号', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `dosage` varchar(50) DEFAULT NULL COMMENT '药量', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `quantity` varchar(50) DEFAULT NULL COMMENT '数量', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `unit` varchar(50) DEFAULT NULL COMMENT '用量单位', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `unit_name` varchar(50) DEFAULT NULL COMMENT '用量单位中文', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `pack_unit` varchar(50) DEFAULT NULL COMMENT '包装单位', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `pack_unit_name` varchar(50) DEFAULT NULL COMMENT '包装单位名称', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `usage_code` varchar(50) DEFAULT NULL COMMENT '频率code', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `usage_name` varchar(50) DEFAULT NULL COMMENT '频次名称', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `supply_code` varchar(50) DEFAULT NULL COMMENT '用法', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `supply_name` varchar(50) DEFAULT NULL COMMENT '用法名称', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `days` varchar(50) DEFAULT NULL COMMENT '天数', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `frequency` varchar(50) DEFAULT NULL COMMENT '组号', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `serial` varchar(50) DEFAULT NULL COMMENT '药品序列号', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `group_no` varchar(50) DEFAULT NULL COMMENT '库房号', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `specification` varchar(50) DEFAULT NULL COMMENT '规格(10mgx10片/盒)', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `pack_retprice` double(10,4) DEFAULT NULL COMMENT '包装价格', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `herbal_count` varchar(10) DEFAULT NULL COMMENT '草药数量', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `post_count` varchar(10) DEFAULT NULL COMMENT '贴数', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `comm` varchar(50) DEFAULT NULL COMMENT '中药用法', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `del` int(2) DEFAULT '1' COMMENT '1可用 0删除', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `drug_place` varchar(100) DEFAULT NULL COMMENT '药品产地', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     `pack_quantity` int(11) DEFAULT NULL COMMENT '包装数量', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     PRIMARY KEY (`id`), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONArray getDrugDictionary(String chargeCode, String pyKey, String winNo, String groupNo,String oupatientId) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String hisCode = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotEmpty(oupatientId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<WlyyPrescriptionExpressageDO> wlyyPrescriptionExpressageDOS = prescriptionExpressageDao.findByOutpatientIdAndOneSelfPick(oupatientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (wlyyPrescriptionExpressageDOS.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                hisCode = wlyyPrescriptionExpressageDOS.get(0).getHospitalCode(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray mapList = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        mapList = tnyyEntranceService.findTnYpxx(chargeCode, null, null, pyKey,hisCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray array = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (int i=0;i<mapList.size();i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject map = mapList.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject object = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("charge_code",map.get("YPXH")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("drugname",map.get("YPMC")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("specification",map.get("YPGG")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("pack_unit_name",map.get("JLDW")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("yfdw",map.get("YFDW")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("pack_size",map.get("YFBZ")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         /*   object.put("yfsx",map.get("yfsx"));//药房属性*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("ypjl",map.get("YPJL"));//药剂量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("jldw",map.get("JLDW"));//剂量单位 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("py_code",map.get("PYDM"));//拼音代码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("fyfs",map.get("FYFS"));//发药方式 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("supply_code",map.get("GYFF"));//给药方式 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("yfzf",map.get("YFZF"));//药房作废 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("supply_name",map.get("GYFF"));//给药方式名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/*            object.put("ybfl",map.get("ybfl"));//医保分类*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("retprice",map.get("LSJG"));//零售价格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("kcsl",map.get("KCSL"));//库存 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("ypcd",map.get("YPCD"));//产地 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("zfpb",map.get("ZFPB"));//作废判别 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("jbywbz",map.get("jbywbz"));//基本药物标志 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (map.get("XTSB")!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (map.getString("XTSB").equalsIgnoreCase("1")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    object.put("group_no",81); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    object.put("group_no",82); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           /* object.put("ydyp",map.get("ydyp"));//药店药品 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("ypmc2",map.get("ypmc2"));//药品名称2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("t",map.get("pzwh"));//药品批文*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            array.add(object); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return array; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取药品用法 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONArray getDrugUse(String pyKey,boolean demoFlag) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray mapList = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        mapList = tnyyEntranceService.findYpyf(pyKey); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray array = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (int i=0;i<mapList.size();i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject map = mapList.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject object = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("supply_code",map.get("YPYF")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("supply_name",map.get("XMMC")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("ypyf",map.get("YPYF")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            array.add(object); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return array; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 医院频次 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONArray getDrugFrequency(boolean demoFlag) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray mapList = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        mapList= tnyyEntranceService.findSypc(null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray array = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (int i=0;i<mapList.size();i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject map = mapList.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject object = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("FREQ_CODE",map.get("PCBM")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("FREQ_NAME",map.get("PCMC")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("MRSC",map.get("MRCS")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            array.add(object); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return array; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   /* *//** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取检查检验 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     *  "action": "select", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     "name": "丙型肝炎RNA测定(全自动荧光定量分析)", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     "charge_unit": "项", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     "charge_amount": "150", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     "py_code": "BXGYRNAC", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     "d_code": "GGEORNAI", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     "code": "393333", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     "exec_unit": "2160000", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     "win_no": "0", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     "exec_unit_name": "检验科" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     *//* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONArray getInspectionDictionary(String pyKey, String codes, String winNo) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray mapList = ykyyEntranceService.findYkJcxm(pyKey); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray array = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (int i=0;i<mapList.size();i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject map = mapList.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject object = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("name",map.get("xmmc")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("code",map.get("zlxmid")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("py_code",map.get("pydm")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("wbdm",map.get("wbdm")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("jxdm",map.get("jxdm")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("qtdm",map.get("qtdm")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("ydyzlb",map.get("ydyzlb")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("mlbh",map.get("mlbh")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("zxpc",map.get("zxpc")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("jfpc",map.get("jfpc")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("jsfs",map.get("jsfs")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("jszq",map.get("jszq")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("charge_unit",map.get("jsdw")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("syxb",map.get("syxb")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("mxsy",map.get("mxsy")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("zysy",map.get("zysy"));//住院使用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("tjsy",map.get("tjsy")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("zxlb",map.get("zxlb"));//执行类别 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("exec_unit",map.get("zxks"));//执行科室 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("zxgzid",map.get("zxgzid"));//执行规则 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("ywzx",map.get("ywzx")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("zxap",map.get("zxap")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("cpzx",map.get("cpzx")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("szzx",map.get("szzx")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("jjlx",map.get("jjlx")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("ycxzsl",map.get("ycxzsl")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("yblx",map.get("yblx")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("zxbz",map.get("zxbz")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("txid",map.get("txid")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("bgbh",map.get("bgbh")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("czsy",map.get("czsy")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("lzsy",map.get("lzsy")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("lccs",map.get("lccs")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("bwbz",map.get("bwbz")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            object.put("yblb",map.get("yblb")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            array.add(object); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return array; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取卡记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     *  "PAT_NO": "P5616242-0  ", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     "CARD_NO": "D40136791", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     "CARD_STAT": "旧卡停用", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     "OP_DATE": "2011-09-27 15:35:57", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     "CARD_TYPE": "2", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     "CARD_TYPE_NAME": "社保卡", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     "social_no": "350211198411053024" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     *//* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONArray findPatientCard(String patient)throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO patientDO = basePatientDao.findById(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (patientDO!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //JSONArray res = ykyyEntranceService.findHisCard(patientDO.getIdcard(),demoFlag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONArray rs = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            *//*if(res !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (int i =0;i<res.size();i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject object = (JSONObject) res.get(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject jsonObject = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("PAT_NO",object.get("pat_no")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("CARD_NO",object.get("card_no")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("OP_DATE",object.get("op_date")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("CARD_STAT",object.get("card_stat")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("CARD_TYPE",object.get("card_type")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("CARD_TYPE_NAME",object.get("card_type_name")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    rs.add(jsonObject); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }*//* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<PatientMedicareCardDO> list  = basePatientMedicareCardDao.findByPatientCode(patientDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patientDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (list!=null&&list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (PatientMedicareCardDO patientMedicareCardDO :list){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject jsonObject = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (null!=patientMappingDO){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        jsonObject.put("PAT_NO",patientMappingDO.getMappingCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        JSONArray res = ykyyEntranceService.findPatientCodeByCardNo(patientMedicareCardDO.getCode(),false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        patientMappingDO = new PatientMappingDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if(res !=null&&res.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            JSONObject object = (JSONObject) res.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            if (object.get("pat_no")!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                jsonObject.put("PAT_NO",object.get("pat_no").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            if (object.get("brid")!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                jsonObject.put("BRID",object.get("brid").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                patientMappingDO.setMappingCode(object.get("brid").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                patientMappingDO.setPatient(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                patientMappingDO.setPatientName(patientDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                patientMappingDO.setIdcard(patientDO.getIdcard()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                patientMappingDO.setSource("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                patientMappingDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                patientMappingDao.save(patientMappingDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("CARD_NO",patientMedicareCardDO.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("OP_DATE",""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("CARD_STAT","正常"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("CARD_TYPE","2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonObject.put("CARD_TYPE_NAME","社保卡"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    rs.add(jsonObject); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return rs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONArray synYkICD10() throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray jsonArray = tnyyEntranceService.synYkICD10(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return jsonArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 处方下单 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Map<String,Object> savePrescriptionOrder(String code,Double price,String tradeType,String wechatId,String appletCode) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        WxWechatDO wxWechatDO = wechatDao.findById(wechatId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> map = new HashedMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(wxWechatDO==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("can't find wechat:the wxId is "+wechatId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (businessOrderDO!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wechatId,businessOrderDO.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String openId = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotBlank(appletCode)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                logger.info("appletCode不为空"+appletCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> objectMap = checkApplets(appletCode,wxWechatDO.getApplets(),wxWechatDO.getAppletsSecret()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (objectMap!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    openId = objectMap.get("openid").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    logger.info("appletCode"+appletCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    logger.info("openid"+openId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                logger.info("appletCode为空"+appletCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<BasePatientWechatDo> patientWechatDo = patientWechatDao.findByWechatIdAndPatientId(wechatId,businessOrderDO.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (patientWechatDo!=null&&patientWechatDo.size()!=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    openId = patientWechatDo.get(0).getOpenid(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String url = wxWechatDO.getBaseUrl(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String notifyUrl =url; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String totalFee =businessOrderDO.getPayPrice().intValue()+""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map = businessOrderService.unifiedorder(wechatId,businessOrderDO.getDescription(),totalFee, tradeType,openId,businessOrderDO.getOrderNo(),notifyUrl,businessOrderDO.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Map<String, Object> checkApplets(String code,String appid,String appSecret) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        HttpUtils httpUtils = new HttpUtils(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, Object> param = new HashedMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        param.put("appid", appid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        param.put("secret", appSecret); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        param.put("js_code", code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        param.put("grant_type", "authorization_code"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        HttpResponse response = httpUtils.doGet("https://api.weixin.qq.com/sns/jscode2session", param); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        org.json.JSONObject rs = new org.json.JSONObject(response.getContent()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, Object> res = new HashedMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        logger.info("checkApplets:"+response.getContent()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (rs.has("openid")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            res.put("openid", rs.getString("openid")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            res.put("sessionKey", rs.getString("session_key")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return res; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取诊断 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param pyKey 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONArray getICD10(String pyKey,boolean demoFlag) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray array = tnyyEntranceService.findIcd10(pyKey,demoFlag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return array; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |