| 
					
				 | 
			
			
				@ -11,14 +11,19 @@ import com.yihu.jw.hospital.family.dao.WlyyPatientFamilyMemberDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.mapping.dao.PatientMappingDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.prescription.service.entrance.EntranceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.ykyy.service.YkyyService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.BasePatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.BasePatientMedicareCardDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.Envelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.MixEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.rm.base.BaseRequestMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.common.IdCardUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.date.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.utils.hibernate.HibenateUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.mysql.query.BaseJpaService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import jdk.management.resource.internal.inst.SocketOutputStreamRMHooks; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import net.sf.json.JSON; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import net.sf.json.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.checkerframework.checker.units.qual.A; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -50,12 +55,14 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private YkyyEntranceService ykyyEntranceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BasePatientMedicareCardDao basePatientMedicareCardDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private YkyyService ykyyService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Value("${wechat.id}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private String wxId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    //添加关联家属 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public MixEnvelop addFamily(String id,String patientId, String familyName, String dictId, String cardType, String idCard, String phoneNum,boolean demo,String medicareType,String medicare) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public MixEnvelop addFamily(String id,String patientId, String familyName, String dictId, String cardType, String idCard, String phoneNum,boolean demo,String medicareType,String medicare,String clinicId) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        MixEnvelop mixEnvelop = new MixEnvelop(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientMemberDictDO basePatientMemberDictDO = basePatientMemberDictDao.findOne(dictId); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -79,11 +86,12 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String familyId=""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String birth = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String yktFamilyId = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int sex=3; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //获取his家属数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray jsonArray = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if("xm_ykyy_wx".equalsIgnoreCase(wxId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jsonArray = ykyyEntranceService.findHisPatientBymMedicare(medicare,false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jsonArray = ykyyEntranceService.findHisPatientBymMedicare(medicare,clinicId,false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(jsonArray!=null&&jsonArray.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                net.sf.json.JSONObject jsonObject= net.sf.json.JSONObject.fromObject(jsonArray.get(0).toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (null!=jsonObject.get("brid")){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -98,6 +106,63 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    long lt = new Long(birth); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    birth = sf.format(lt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String familySex = IdCardUtil.getSexForIdcard(idCard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (familySex.equalsIgnoreCase("男")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        familySex= "1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else if (familySex.equalsIgnoreCase("女")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        familySex = "0"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        familySex = "2"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String familyAge = String.valueOf(IdCardUtil.getAgeForIdcard(idCard)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    BasePatientMemberDictDO basePatientMemberDictDO1 = basePatientMemberDictDao.findOne(dictId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String relationName = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (null!=basePatientMemberDictDO1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        relationName=basePatientMemberDictDO1.getRelationName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    BasePatientDO basePatientDO1  = basePatientDao.findById(patientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String res = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //id不为空则为修改家人关系 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (StringUtils.isNotBlank(id)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (null!=basePatientDO1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            res = ykyyService.updateYktFamily(familyName,idCard, familySex,familyAge,phoneNum,medicare,relationName,clinicId,result.getYktFamilyId(),birth); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (StringUtils.isNotEmpty(res)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            JSONObject jsonObject1 = JSONObject.parseObject(res); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            if ("200".equalsIgnoreCase(jsonObject1.getString("code"))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                /*JSONObject jsonObject2 = JSONObject.parseObject(jsonObject1.getString("data")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                yktFamilyId = jsonObject2.getString("ID");*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                mixEnvelop.setStatus(408); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                mixEnvelop.setMessage("更新家人关系至眼科通失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                return mixEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            mixEnvelop.setStatus(408); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            mixEnvelop.setMessage("更新家人关系至眼科通失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            return mixEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (null!=basePatientDO1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            res = ykyyService.addYktFamily(familyName,idCard, familySex,familyAge,phoneNum,medicare,relationName,"1",basePatientDO1.getUserId(),birth); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (StringUtils.isNotEmpty(res)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            JSONObject jsonObject1 = JSONObject.parseObject(res); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            if ("200".equalsIgnoreCase(jsonObject1.getString("code"))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                JSONObject jsonObject2 = JSONObject.parseObject(jsonObject1.getString("data")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                yktFamilyId = jsonObject2.getString("ID"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                mixEnvelop.setStatus(408); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                mixEnvelop.setMessage("添加家人关系至眼科通失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                return mixEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            mixEnvelop.setStatus(408); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            mixEnvelop.setMessage("添加家人关系至眼科通失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            return mixEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    System.out.println("眼科转换后的csny"+birth); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    mixEnvelop.setStatus(408); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -149,6 +214,7 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        basePatientDO.setBirthday(saveBirth1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.setFamilyRelation(dictId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.setFamilyRelationName(dictName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.setYktFamilyId(yktFamilyId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.setIsDel(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.setPatient(patientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.setCardNo(idCard); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -200,7 +266,7 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patientMedicareCardDO.setCode(medicare); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patientMedicareCardDO.setType(medicareType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //patientMedicareCardDO.setType(medicareType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patientMedicareCardDO.setPatientCode(patientNewId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patientMedicareCardDO.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                basePatientMedicareCardDao.save(patientMedicareCardDO); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -215,28 +281,168 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return mixEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    //眼科同步家人信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void saveYktFamily(String patientId) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String userId=""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BasePatientDO basePatientDO = basePatientDao.findById(patientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (null!=basePatientDO){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                userId = basePatientDO.getUserId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String, String>> list=new ArrayList<Map<String, String>>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String res  = ykyyService.findYktFamily(userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotEmpty(res)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject jsonObject = JSONObject.parseObject(res); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if ("200".equalsIgnoreCase(jsonObject.getString("code"))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject data = JSONObject.parseObject(jsonObject.getString("data")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONArray jsonArray = JSONArray.fromObject(data.get("list")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if(jsonArray!=null && jsonArray.size()>0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        for (int i = 0; i < jsonArray.size(); i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            JSONObject jsonObject1 = JSONObject.parseObject(jsonArray.get(i).toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            System.out.println("==="+jsonArray.get(i).toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            if (StringUtils.isNotEmpty(jsonObject1.getString("IDCARD"))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                System.out.println("同步的身份证号:"+jsonObject1.getString("IDCARD")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                BasePatientDO patientDO = basePatientDao.findByIdcardAndDel(jsonObject1.getString("IDCARD"),"1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                if (null==patientDO){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    patientDO = new BasePatientDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                patientDO.setMobile(jsonObject1.getString("TEL")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                if(StringUtils.isNotBlank(jsonObject1.getString("BIRTHDAY"))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    patientDO.setBirthday(DateUtil.strToDate(jsonObject1.getString("BIRTHDAY"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                patientDO.setIdcard(jsonObject1.getString("IDCARD")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                patientDO.setName(jsonObject1.getString("NAME")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                patientDO.setSex(jsonObject1.getInteger("SEX")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                patientDO.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                patientDO.setEnabled(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                patientDO.setLocked(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                patientDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                patientDO = basePatientDao.save(patientDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                //取his中的病人code 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                JSONArray hisArray = ykyyEntranceService.findHisPatientBymMedicare(null,patientDO.getIdcard(),false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                if(hisArray!=null&&hisArray.size()>0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    net.sf.json.JSONObject hisObject = net.sf.json.JSONObject.fromObject(hisArray.get(0).toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    PatientMappingDO patientMappingDO = patientMappingDao.findByIdcard(patientDO.getIdcard()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    if(null==patientMappingDO){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        patientMappingDO= new PatientMappingDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    patientMappingDO.setPatientName(jsonObject1.getString("NAME")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    patientMappingDO.setPatient(patientDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    patientMappingDO.setMappingCode(hisObject.getString("brid")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    patientMappingDO.setSource("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    patientMappingDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    patientMappingDO.setIdcard(patientDO.getIdcard()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    patientMappingDao.save(patientMappingDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                WlyyPatientFamilyMemberDO wlyyPatientFamilyMemberDO = wlyyPatientFamilyMemberDao.findbyCardNoAndPatient(patientDO.getIdcard(),patientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                if (null==wlyyPatientFamilyMemberDO){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    wlyyPatientFamilyMemberDO = new WlyyPatientFamilyMemberDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                BasePatientMemberDictDO basePatientMemberDictDO =basePatientMemberDictDao.findByRelationName(jsonObject1.getString("ILLNESS")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                if (null!=basePatientMemberDictDO){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    wlyyPatientFamilyMemberDO.setIsDel(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    wlyyPatientFamilyMemberDO.setPatient(patientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    wlyyPatientFamilyMemberDO.setClinicid(jsonObject1.getString("CLINICID")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    wlyyPatientFamilyMemberDO.setCardType("身份证"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    wlyyPatientFamilyMemberDO.setFamilyMember(patientDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    wlyyPatientFamilyMemberDO.setFamilyRelation(basePatientMemberDictDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    wlyyPatientFamilyMemberDO.setFamilyRelationName(basePatientMemberDictDO.getRelationName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    wlyyPatientFamilyMemberDO.setCardNo(jsonObject1.getString("IDCARD")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    wlyyPatientFamilyMemberDO.setYktFamilyId(jsonObject1.getString("ID")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    wlyyPatientFamilyMemberDao.save(wlyyPatientFamilyMemberDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                if(null!=jsonObject1.get("MEDICALCARD")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    PatientMedicareCardDO patientMedicareCardDO = basePatientMedicareCardDao.findByCode(jsonObject1.getString("MEDICALCARD")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    if (null==patientMedicareCardDO){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        patientMedicareCardDO = new PatientMedicareCardDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    patientMedicareCardDO.setCode(jsonObject1.getString("MEDICALCARD")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    //patientMedicareCardDO.setType(medicareType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    patientMedicareCardDO.setPatientCode(patientDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    patientMedicareCardDO.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    basePatientMedicareCardDao.save(patientMedicareCardDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (ParseException e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            System.out.println("同步家人关系失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    //根据患者id查询关联家属 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Map<String,Object>> findFamilyByPatientId(String patientId) throws ParseException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "select t.id as \"id\",t.card_type as \"cardType\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "t.patient as \"patient\",b.name as \"name\",b.sex as \"sex\","+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "b.birthday as\"birthday\",b.idcard as \"idcard\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "t.family_member as \"familyMember\",c.relation_name as \"relationName\" "+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " from wlyy_patient_family_member t left join base_patient b" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " on t.family_member = b.id left join base_patient_member_dict c on t.family_relation=c.id where 1=1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(patientId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " and t.patient = '"+patientId+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (list!=null&&list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (Map<String,Object> map:list){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (map.get("birthday")!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM-dd"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    int age = getAgeByBirth(sp.parse(map.get("birthday").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    map.put("age",age); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if("xm_ykyy_wx".equalsIgnoreCase(wxId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                saveYktFamily(patientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String sql = "select t.id as \"id\",t.card_type as \"cardType\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "t.patient as \"patient\",b.name as \"name\",b.sex as \"sex\","+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "to_char(b.birthday,'yyyy-MM-dd') as\"birthday\",b.idcard as \"idcard\",t.clinicid as \"clinicid\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "t.family_member as \"familyMember\",c.relation_name as \"relationName\" "+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " from wlyy_patient_family_member t left join base_patient b" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " on t.family_member = b.id left join base_patient_member_dict c on t.family_relation=c.id where 1=1 and t.is_del=1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotBlank(patientId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql += " and t.patient = '"+patientId+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (list!=null&&list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (Map<String,Object> map:list){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (null!=map.get("idcard")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        map.put("age",IdCardUtil.getAgeForIdcard(map.get("idcard").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (null!=map.get("birthday")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        System.out.println("birthday:"+map.get("birthday").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    List<PatientMedicareCardDO> list1 = basePatientMedicareCardDao.findByPatientCode(patientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (null!=list1&&list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        map.put("card",list1.get(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        map.put("card",""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String sql = "select t.id as \"id\",t.card_type as \"cardType\", " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "t.patient as \"patient\",b.name as \"name\",b.sex as \"sex\","+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "b.birthday as\"birthday\",b.idcard as \"idcard\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "t.family_member as \"familyMember\",c.relation_name as \"relationName\" "+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " from wlyy_patient_family_member t left join base_patient b" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " on t.family_member = b.id left join base_patient_member_dict c on t.family_relation=c.id where 1=1 and t.is_del=1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotBlank(patientId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql += " and t.patient = '"+patientId+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (list!=null&&list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (Map<String,Object> map:list){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (map.get("birthday")!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM-dd"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            map.put("birthday",sp.parse(map.get("birthday").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        int age = getAgeByBirth(sp.parse(map.get("birthday").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        map.put("age",age); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    List<PatientMedicareCardDO> list1 = basePatientMedicareCardDao.findByPatientCode(patientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    map.put("cardList",list1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public static void main(String[] args) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String ss ="561657600000"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Date da = new Date(Long.parseLong(ss)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        System.out.println(simpleDateFormat.format(da)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private static int getAgeByBirth(Date birthday) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int age = 0; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -265,7 +471,26 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Envelop envelop = new Envelop(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        WlyyPatientFamilyMemberDO wlyyPatientFamilyMemberDO = wlyyPatientFamilyMemberDao.findOne(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (wlyyPatientFamilyMemberDO!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            wlyyPatientFamilyMemberDao.delete(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            wlyyPatientFamilyMemberDO.setIsDel(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //删除眼科通的家人关系 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String res = ykyyService.deleteYktFamily(wlyyPatientFamilyMemberDO.getYktFamilyId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (StringUtils.isNotEmpty(res)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject jsonObject = JSONObject.parseObject(res); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if ("200".equalsIgnoreCase(jsonObject.getString("code"))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        envelop.setMessage("删除成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        envelop.setMessage("删除失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        envelop.setStatus(-1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        return envelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    envelop.setMessage("删除失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    envelop.setStatus(-1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return envelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            wlyyPatientFamilyMemberDao.save(wlyyPatientFamilyMemberDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            envelop.setMessage("删除成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return envelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -278,11 +503,11 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Map<String,Object>>  findMemberById(String id) throws ParseException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql="select t.id as \"id\",t.card_type as \"cardType\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "t.family_member as \"familyMember\",t.patient as \"patient\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "b.name as \"name\",b.idcard as \"idcard\",b.mobile as \"mobile\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "b.name as \"name\",b.idcard as \"idcard\",b.mobile as \"mobile\",t.clinicid as \"clinicid\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "c.relation_name \"relationName\",b.birthday as\"birthday\",b.sex as\"sex\"" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " from wlyy_patient_family_member t left join base_patient b" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " on t.family_member = b.id left join base_patient_member_dict c on t.family_relation=c.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " where 1=1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " where 1=1 and t.is_del = 1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(id)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" and t.id='"+id+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -294,6 +519,16 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    int age = getAgeByBirth(sp.parse(map.get("birthday").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    map.put("age",age); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if(null!=map.get("familyMember")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        List<PatientMedicareCardDO> list1 = basePatientMedicareCardDao.findByPatientCode(map.get("familyMember").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (null!=list1&&list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            map.put("card",list1.get(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            map.put("card",""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return list; 
			 |