| 
					
				 | 
			
			
				@ -4,12 +4,23 @@ 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.area.BaseDrugStoreDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.dict.DictHospitalDeptDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.doctor.BaseDoctorDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.BasePatientDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.PatientMedicareCardDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.wx.BasePatientWechatDo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.wx.WxWechatDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.doctor.WlyyPatientRegisterTimeDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.mapping.PatientMappingDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageDO; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -17,22 +28,26 @@ import com.yihu.jw.entity.order.BusinessOrderDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.consult.dao.HospitalWaitingRoomDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				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.YkyyEntranceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.prescription.service.useragent.BaseUserAgent; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.ykyy.service.YkyyService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.order.BusinessOrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.order.dao.BusinessOrderDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.order.pay.wx.WeChatConfig; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				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.util.common.IdCardUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.wechat.dao.BasePatientWechatDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.wechat.dao.WechatDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.mysql.query.BaseJpaService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.utils.security.MD5; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.collections.map.HashedMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.Logger; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -59,8 +74,6 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BasePatientDao basePatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PrescriptionDao prescriptionDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PrescriptionExpressageDao prescriptionExpressageDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private HospitalWaitingRoomDao hospitalWaitingRoomDao; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -83,9 +96,23 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BusinessOrderService businessOrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseUserAgent userAgent; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseDrugStoreDao baseDrugStoreDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BasePatientMedicareCardDao basePatientMedicareCardDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PatientMappingDao patientMappingDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseDoctorDao doctorDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DictHospitalDeptDao dictHospitalDeptDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseDoctorHospitalDao doctorHospitalDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseDoctorRoleDao doctorRoleDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DoctorMappingDao doctorMappingDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Value("${demo.flag}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private boolean demoFlag; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -109,9 +136,39 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public  List<WlyyOutpatientVO> findOutpatientList(String patient, String startTime, String endTime, boolean demoFlag,String ksdm)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 =patientMappingService.findYkyyPatNoByPatient(patient,demoFlag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -120,6 +177,93 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void synDoctorInfo(String idcard) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray jsonArray = ykyyEntranceService.findHisDoctor(idcard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (jsonArray!=null&&jsonArray.size()!=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (int i=0;i<jsonArray.size();i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject jsonObject = jsonArray.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String idCard= jsonObject.getString("idcard"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String code = jsonObject.getString("code"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String name = jsonObject.getString("name"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String expertise = jsonObject.getString("expertise"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String introduce = jsonObject.getString("introduce"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String mobile = jsonObject.getString("mobile"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String jobTitleCode = jsonObject.getString("jobTitleCode"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String jobTitleName = jsonObject.getString("jobTitleName"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String dept = jsonObject.getString("dept"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String deptName = jsonObject.getString("deptName"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<BaseDoctorDO> doctorDOS =doctorDao.findByIdcard(idcard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (doctorDOS!=null&&doctorDOS.size()!=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    BaseDoctorDO doctorDO = doctorDOS.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO.setIdcard(idcard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO.setName(name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO.setExpertise(expertise); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO.setIntroduce(introduce); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO.setMobile(mobile); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO.setJobTitleCode(jobTitleCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO.setJobTitleName(jobTitleName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    DictHospitalDeptDO dictHospitalDeptDO = dictHospitalDeptDao.findByCode(dept); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    List<BaseDoctorHospitalDO> doctorHospitalDOS = doctorHospitalDao.findByDeptCodeAndDoctorCode(dept,doctorDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    for (BaseDoctorHospitalDO doctorHospitalDO:doctorHospitalDOS){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        doctorHospitalDO.setDeptCode(dept); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        doctorHospitalDO.setDeptName(deptName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        doctorHospitalDao.save(doctorHospitalDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDao.save(doctorDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    BaseDoctorDO doctorDO = new BaseDoctorDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO.setIdcard(idCard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO.setName(name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO.setExpertise(expertise); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO.setIntroduce(introduce); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO.setMobile(mobile); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO.setJobTitleCode(jobTitleCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO.setJobTitleName(jobTitleName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO.setSex(Integer.parseInt(IdCardUtil.getSexForIdcard_new(idcard))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO.setBirthday(IdCardUtil.getBirthdayForIdcard(idcard)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String salt = randomString(5); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String pw = idcard.substring(idcard.length() - 6); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO.setSalt(salt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO.setEnabled(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO.setLocked(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorDO = doctorDao.save(doctorDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //机构信息部门信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    BaseDoctorHospitalDO hospitalDO = new BaseDoctorHospitalDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    hospitalDO.setDoctorCode(doctorDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    hospitalDO.setOrgCode("350211A5004"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    hospitalDO.setOrgName("厦门大学附属厦门眼科中心"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    hospitalDO.setDeptCode(dept); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    hospitalDO.setDeptName(deptName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    hospitalDO.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorHospitalDao.save(hospitalDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    BaseDoctorRoleDO role = new BaseDoctorRoleDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    role.setDoctorCode(doctorDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    role.setRoleCode("specialist"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorRoleDao.save(role); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    DoctorMappingDO mappingDO = new DoctorMappingDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    mappingDO.setIdcard(idcard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    mappingDO.setDoctor(doctorDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    mappingDO.setOrgCode("350211A5004"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    mappingDO.setOrgName("厦门大学附属厦门眼科中心"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    mappingDO.setMappingCode(code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    mappingDO.setMappingName(name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    mappingDO.setDoctorName(name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    mappingDO.setMappingDeptName(deptName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    mappingDO.setMappingDept(dept); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    mappingDO.setMappingJob(jobTitleCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    mappingDO.setMappingJobName(jobTitleName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    mappingDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    doctorMappingDao.save(mappingDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -548,9 +692,9 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONArray findPatientCard(String patient)throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO patientDO = basePatientDao.findById(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (patientDO!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONArray res = ykyyEntranceService.findHisCard(patientDO.getIdcard(),demoFlag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //JSONArray res = ykyyEntranceService.findHisCard(patientDO.getIdcard(),demoFlag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONArray rs = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(res !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            /*if(res !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (int i =0;i<res.size();i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject object = (JSONObject) res.get(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject jsonObject = new JSONObject(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -562,8 +706,43 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    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 rs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 |