|  | @ -9,6 +9,7 @@ import com.yihu.jw.message.service.MessageService;
 | 
	
		
			
				|  |  | import com.yihu.jw.patient.service.BasePatientMedicardCardService;
 | 
	
		
			
				|  |  | import com.yihu.jw.patient.service.personal_Info.PatientService;
 | 
	
		
			
				|  |  | import com.yihu.jw.patient.service.servicepackage.PackageService;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.common.IdCardUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.date.DateUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.service.WeChatQrcodeService;
 | 
	
		
			
				|  |  | import org.apache.commons.collections.map.HashedMap;
 | 
	
	
		
			
				|  | @ -68,22 +69,11 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<BasePatientFamilyMemberDO> list = patientFamilyMemberService.getByPatientAndFamilyRelation(patient,null);
 | 
	
		
			
				|  |  |         list.addAll(patientFamilyMemberService.getByFamilyMemberAndRelation(patient,null));
 | 
	
		
			
				|  |  |         for(BasePatientFamilyMemberDO one:list){
 | 
	
		
			
				|  |  |             Integer relation = one.getFamilyRelation();
 | 
	
		
			
				|  |  |             if(one.getFamilyMember().equals(patient)){//需要关系转换
 | 
	
		
			
				|  |  |                 BasePatientDO p = patientService.findByIdAndDel(patient);
 | 
	
		
			
				|  |  |                 relation = familyRelationTrans(one.getFamilyRelation(),p.getSex());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if(relation==10){continue;}
 | 
	
		
			
				|  |  |             Map<String,Object> relationMap = map.get(relation.toString());
 | 
	
		
			
				|  |  |             relationMap.put("isBinding",1);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         List<BasePatientFamilyMemberDO> childrenList = patientFamilyMemberService.getByPatientAndFamilyRelation(patient,10);
 | 
	
		
			
				|  |  |         childrenList.addAll(patientFamilyMemberService.getByFamilyMemberAndRelation(patient,2,3));
 | 
	
		
			
				|  |  |         if(childrenList.size()==2){
 | 
	
		
			
				|  |  |             map.get("10").put("isBinding",1);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         Collection<Map<String,Object>> valueCollection = map.values();
 | 
	
		
			
				|  |  |         List<Map<String,Object>> valueList = new LinkedList<>(valueCollection);
 | 
	
		
			
				|  |  |         return valueList;
 | 
	
	
		
			
				|  | @ -97,22 +87,32 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |     public Map<String,Object> bindingMyFamily( String patient, String familyMobile, Integer platform,Integer familyBindRole) throws Exception{
 | 
	
		
			
				|  |  |     public Map<String,Object> bindingMyFamily( String patient, String familyMobile, Integer platform,Integer familyBindRole,String familyName,String principalNum,String idcard) throws Exception{
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         BasePatientDO patientDO = patientService.findByIdAndDel(patient);
 | 
	
		
			
				|  |  |         //1、检验手机号码是否有存在账号,
 | 
	
		
			
				|  |  |         BasePatientDO familyPatient = patientService.findByMobileAndDel(familyMobile);
 | 
	
		
			
				|  |  |         Long time = 1000*60*60*24*Long.valueOf(qrCodeFailurTime);
 | 
	
		
			
				|  |  |         Long minutes = 60*24*Long.valueOf(qrCodeFailurTime);
 | 
	
		
			
				|  |  |         if(familyPatient==null){
 | 
	
		
			
				|  |  |             //2、没有存在账号的,预注册一个账号,调用预注册接口
 | 
	
		
			
				|  |  |             Map<String,Object> map = patientService.bespeakRegist(familyMobile,time);
 | 
	
		
			
				|  |  |             Map<String,Object> map = patientService.bespeakRegist(familyMobile,familyName,idcard,minutes);
 | 
	
		
			
				|  |  |             if(Integer.valueOf(map.get("code")+"")==1){
 | 
	
		
			
				|  |  |                 familyPatient = (BasePatientDO)map.get("patient");
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 throw new Exception(map.get("message")+"");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //生成社保卡号
 | 
	
		
			
				|  |  |         if(!StringUtils.isEmpty(principalNum)){
 | 
	
		
			
				|  |  |             PatientMedicareCardDO medicareCardDO = new PatientMedicareCardDO();
 | 
	
		
			
				|  |  |             medicareCardDO.setCode(principalNum);
 | 
	
		
			
				|  |  |             medicareCardDO.setParentType(PatientMedicareCardDO.ParentType.CareCard.getType());
 | 
	
		
			
				|  |  |             medicareCardDO.setType(PatientMedicareCardDO.Type.MedicareCard.getType());
 | 
	
		
			
				|  |  |             medicareCardDO.setPatientCode(familyPatient.getId());
 | 
	
		
			
				|  |  |             medicareCardDO.setDel("1");
 | 
	
		
			
				|  |  |             patientMedicareCardService.save(medicareCardDO);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //3、生成申请绑定的记录
 | 
	
		
			
				|  |  |         PatientApplyLog patientApplyLog = patientApplyLogService.findValidOne(patient,familyPatient.getId(),new Date(),familyBindRole);
 | 
	
		
			
				|  |  |         if(patientApplyLog==null){
 | 
	
	
		
			
				|  | @ -181,13 +181,30 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  |      * @param familyBindRole 1"配偶",2"父亲",3"母亲",4"公公",5"婆婆",6"岳父",7"岳母",8"女婿",9"儿媳",10"子女"
 | 
	
		
			
				|  |  |      * @param isAdult 0未成年人 1成年人
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Map<String,Object> signBindFamily( String patient, String familyMobile, Integer platform,Integer familyBindRole,Integer isAdult) throws Exception{
 | 
	
		
			
				|  |  |     public Map<String,Object> signBindFamily( String patient, String familyMobile, Integer platform,Integer familyBindRole,Integer isAdult,
 | 
	
		
			
				|  |  |                                               String familyName,String principalNum,String idcard) throws Exception{
 | 
	
		
			
				|  |  |         //判断身份证号和社保卡号重复问题
 | 
	
		
			
				|  |  |         if(patientService.existsByIdcard(idcard)){
 | 
	
		
			
				|  |  |             throw new Exception("填写身份证已存在!");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(patientMedicareCardService.existsByCodeAndDel(principalNum)){
 | 
	
		
			
				|  |  |             throw new Exception("填写社保卡号已存在!");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(isAdult==1){
 | 
	
		
			
				|  |  |             Map<String,Object> p = bindingMyFamily(patient, familyMobile, platform,familyBindRole);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Map<String,Object> p = bindingMyFamily(patient, familyMobile, platform,familyBindRole,familyName,principalNum,idcard);
 | 
	
		
			
				|  |  |             return p;
 | 
	
		
			
				|  |  |         }else if(isAdult==0){
 | 
	
		
			
				|  |  |             //注册一个没有手机号码的用户信息
 | 
	
		
			
				|  |  |             BasePatientDO familyPatient = null;
 | 
	
		
			
				|  |  |             BasePatientDO familyPatient = new BasePatientDO();
 | 
	
		
			
				|  |  |             familyPatient.setLocked(0);
 | 
	
		
			
				|  |  |             familyPatient.setEnabled(1);
 | 
	
		
			
				|  |  |             familyPatient.setDel("0");
 | 
	
		
			
				|  |  |             familyPatient.setLoginFailureCount(0);
 | 
	
		
			
				|  |  |             familyPatient.setPatientStatus("1");
 | 
	
		
			
				|  |  |             familyPatient.setName(familyName);
 | 
	
		
			
				|  |  |             familyPatient.setIdcard(idcard);
 | 
	
		
			
				|  |  |             familyPatient = patientService.save(familyPatient);
 | 
	
		
			
				|  |  |             //生成绑定信息
 | 
	
		
			
				|  |  |             BasePatientFamilyMemberDO patientFamilyMember = new BasePatientFamilyMemberDO();
 | 
	
		
			
				|  |  |             patientFamilyMember.setPatient(patient);
 | 
	
	
		
			
				|  | @ -196,6 +213,15 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  |             patientFamilyMember.setIsAuthorize(1);//0:未授权,1:已授权
 | 
	
		
			
				|  |  |             patientFamilyMember.setDel(1);
 | 
	
		
			
				|  |  |             patientFamilyMemberService.save(patientFamilyMember);
 | 
	
		
			
				|  |  |             //生成家人绑定信息
 | 
	
		
			
				|  |  |             BasePatientFamilyMemberDO patientFamilyMember2 = new BasePatientFamilyMemberDO();
 | 
	
		
			
				|  |  |             patientFamilyMember2.setPatient(familyPatient.getId());
 | 
	
		
			
				|  |  |             patientFamilyMember2.setFamilyMember(patient);
 | 
	
		
			
				|  |  |             BasePatientDO createUser = patientService.findByIdAndDel(patient);
 | 
	
		
			
				|  |  |             patientFamilyMember2.setFamilyRelation(familyRelationTrans(familyBindRole,createUser.getSex()));
 | 
	
		
			
				|  |  |             patientFamilyMember2.setIsAuthorize(1);
 | 
	
		
			
				|  |  |             patientFamilyMember2.setDel(1);
 | 
	
		
			
				|  |  |             patientFamilyMemberService.save(patientFamilyMember2);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return null;
 | 
	
		
			
				|  |  |     }
 | 
	
	
		
			
				|  | @ -267,7 +293,7 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  |                 patientFamilyMemberService.save(patientFamilyMember);
 | 
	
		
			
				|  |  |                 BasePatientFamilyMemberDO patientFamilyMember2 = new BasePatientFamilyMemberDO();
 | 
	
		
			
				|  |  |                 patientFamilyMember2.setPatient(patientApplyLog.getFamilyMemberCode());
 | 
	
		
			
				|  |  |                 patientFamilyMember2.setFamilyMember(patientApplyLog.getFamilyMemberName());
 | 
	
		
			
				|  |  |                 patientFamilyMember2.setFamilyMember(patientApplyLog.getCreateUser());
 | 
	
		
			
				|  |  |                 BasePatientDO createUser = patientService.findByIdAndDel(patientApplyLog.getCreateUser());
 | 
	
		
			
				|  |  |                 patientFamilyMember2.setFamilyRelation(familyRelationTrans(patientApplyLog.getFamilyBindRole(),createUser.getSex()));
 | 
	
		
			
				|  |  |                 patientFamilyMember2.setIsAuthorize(isAuthorize);
 | 
	
	
		
			
				|  | @ -373,6 +399,9 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  |         map.put("name",basePatientDO.getName());//姓名
 | 
	
		
			
				|  |  |         map.put("cardTypeName","身份证");
 | 
	
		
			
				|  |  |         map.put("idcard",basePatientDO.getIdcard());//身份证
 | 
	
		
			
				|  |  |         map.put("photo",basePatientDO.getPhoto());//头像
 | 
	
		
			
				|  |  |         map.put("role","自己");//角色
 | 
	
		
			
				|  |  |         map.put("isAuthorize",1);//授权
 | 
	
		
			
				|  |  |         PatientMedicareCardDO patientMedicareCardDO = patientMedicareCardService.findByTypeAndPatientCodeAndDel(PatientMedicareCardDO.Type.MedicareCard.getType(),patient,"1");
 | 
	
		
			
				|  |  |         if(patientMedicareCardDO!=null){
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -393,13 +422,13 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  |         //家人
 | 
	
		
			
				|  |  |         for(BasePatientFamilyMemberDO one:list){
 | 
	
		
			
				|  |  |             Map<String,Object> map2 = new HashedMap();
 | 
	
		
			
				|  |  |             basePatientDO = patientService.findByIdAndDel(one.getPatient());
 | 
	
		
			
				|  |  |             basePatientDO = patientService.findByIdAndDel(one.getFamilyMember());
 | 
	
		
			
				|  |  |             map2.put("appellation",basePatientDO.getName());//别称
 | 
	
		
			
				|  |  |             map2.put("patientCode",basePatientDO.getId());//居民code
 | 
	
		
			
				|  |  |             map2.put("name",basePatientDO.getName());//姓名
 | 
	
		
			
				|  |  |             map2.put("cardTypeName","身份证");
 | 
	
		
			
				|  |  |             map2.put("idcard",basePatientDO.getIdcard());//身份证
 | 
	
		
			
				|  |  |             PatientMedicareCardDO patientMedicareCard = patientMedicareCardService.findByTypeAndPatientCodeAndDel(PatientMedicareCardDO.Type.MedicareCard.getType(),patient,"1");
 | 
	
		
			
				|  |  |             PatientMedicareCardDO patientMedicareCard = patientMedicareCardService.findByTypeAndPatientCodeAndDel(PatientMedicareCardDO.Type.MedicareCard.getType(),basePatientDO.getId(),"1");
 | 
	
		
			
				|  |  |             if(patientMedicareCardDO!=null){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 map2.put("principalNum",patientMedicareCard.getCode());//社保卡号
 | 
	
	
		
			
				|  | @ -407,14 +436,19 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  |                 map2.put("principalNum","");//社保卡号
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             map2.put("mobile",basePatientDO.getMobile());//手机号码
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(packageId)){
 | 
	
		
			
				|  |  |                 if(packageService.findPatientSignExist(patient,packageId)){
 | 
	
		
			
				|  |  |             if(!StringUtils.isEmpty(packageId)){
 | 
	
		
			
				|  |  |                 if(packageService.findPatientSignExist(basePatientDO.getId(),packageId)){
 | 
	
		
			
				|  |  |                     map2.put("isPackage",1);
 | 
	
		
			
				|  |  |                 }else{
 | 
	
		
			
				|  |  |                     map2.put("isPackage",0);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             map2.put("photo",basePatientDO.getPhoto());//头像
 | 
	
		
			
				|  |  |             map2.put("role",role.get(one.getFamilyRelation()-1));//角色
 | 
	
		
			
				|  |  |             //判断家人是否授权
 | 
	
		
			
				|  |  |             BasePatientFamilyMemberDO o = patientFamilyMemberService.findByPatientAndFamilyMemberAndDel(one.getFamilyMember(),one.getPatient());
 | 
	
		
			
				|  |  |             map2.put("isAuthorize",o.getIsAuthorize());//授权
 | 
	
		
			
				|  |  |             resultList.add(map2);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return resultList;
 | 
	
	
		
			
				|  | @ -567,6 +601,19 @@ public class MyFamilyService {
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 根据身份判断是否未成年
 | 
	
		
			
				|  |  |      * @param idcard
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Integer nonageByIdcard(String idcard){
 | 
	
		
			
				|  |  |         Integer age = IdCardUtil.getAgeForIdcard(idcard);
 | 
	
		
			
				|  |  |         if(age>18){
 | 
	
		
			
				|  |  |             return 1;
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             return 0;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 家庭关系转换
 |