|  | @ -11,6 +11,7 @@ import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
 | 
												
													
														
															|  | import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
 |  | import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
 | 
												
													
														
															|  | import com.yihu.wlyy.entity.message.Message;
 |  | import com.yihu.wlyy.entity.message.Message;
 | 
												
													
														
															|  | import com.yihu.wlyy.entity.patient.Patient;
 |  | import com.yihu.wlyy.entity.patient.Patient;
 | 
												
													
														
															|  | 
 |  | import com.yihu.wlyy.entity.patient.PatientDisease;
 | 
												
													
														
															|  | import com.yihu.wlyy.entity.patient.SignFamily;
 |  | import com.yihu.wlyy.entity.patient.SignFamily;
 | 
												
													
														
															|  | import com.yihu.wlyy.entity.patient.SignFamilyCode;
 |  | import com.yihu.wlyy.entity.patient.SignFamilyCode;
 | 
												
													
														
															|  | import com.yihu.wlyy.repository.consult.ConsultTeamDao;
 |  | import com.yihu.wlyy.repository.consult.ConsultTeamDao;
 | 
												
											
												
													
														
															|  | @ -24,6 +25,7 @@ import com.yihu.wlyy.repository.patient.SignFamilyDao;
 | 
												
													
														
															|  | import com.yihu.wlyy.repository.patient.SocialSecurityInfoDao;
 |  | import com.yihu.wlyy.repository.patient.SocialSecurityInfoDao;
 | 
												
													
														
															|  | import com.yihu.wlyy.repository.statistics.WlyySignFamilyCodeDao;
 |  | import com.yihu.wlyy.repository.statistics.WlyySignFamilyCodeDao;
 | 
												
													
														
															|  | import com.yihu.wlyy.service.app.disease.PatientDiseaseService;
 |  | import com.yihu.wlyy.service.app.disease.PatientDiseaseService;
 | 
												
													
														
															|  | 
 |  | import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
 | 
												
													
														
															|  | import com.yihu.wlyy.task.SignUploadTask;
 |  | import com.yihu.wlyy.task.SignUploadTask;
 | 
												
													
														
															|  | import org.apache.commons.lang3.StringUtils;
 |  | import org.apache.commons.lang3.StringUtils;
 | 
												
													
														
															|  | import org.json.JSONArray;
 |  | import org.json.JSONArray;
 | 
												
											
												
													
														
															|  | @ -88,17 +90,18 @@ public class FamilyContractService extends BaseService {
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private PatientDiseaseService patientDiseaseService;
 |  |     private PatientDiseaseService patientDiseaseService;
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private StringRedisTemplate redisTemplate;
 |  | 
 | 
												
													
														
															|  |     @Autowired
 |  | 
 | 
												
													
														
															|  |     private PatientDiseaseDao patientDiseaseDao;
 |  |     private PatientDiseaseDao patientDiseaseDao;
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private SocialSecurityInfoDao socialSecurityInfoDao;
 |  |     private SocialSecurityInfoDao socialSecurityInfoDao;
 | 
												
													
														
															|  | 
 |  |     @Autowired
 | 
												
													
														
															|  | 
 |  |     private SignPatientLabelInfoService labelInfoService;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private DoctorAdminTeamDao doctorAdminTeamDao;
 |  |     private DoctorAdminTeamDao doctorAdminTeamDao;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     public SignFamily findSignFamilyByCode(String code){
 |  | 
 | 
												
													
														
															|  |        return signFamilyDao.findByCodeAndType(code,2);
 |  | 
 | 
												
													
														
															|  | 
 |  |     public SignFamily findSignFamilyByCode(String code) {
 | 
												
													
														
															|  | 
 |  |         return signFamilyDao.findByCodeAndType(code, 2);
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     public SignFamily findByPatientByType(String patient, int type) {
 |  |     public SignFamily findByPatientByType(String patient, int type) {
 | 
												
											
												
													
														
															|  | @ -638,7 +641,9 @@ public class FamilyContractService extends BaseService {
 | 
												
													
														
															|  |                                          String majorDoctorName,
 |  |                                          String majorDoctorName,
 | 
												
													
														
															|  |                                          String hospital, String hospitalName,
 |  |                                          String hospital, String hospitalName,
 | 
												
													
														
															|  |                                          String idcard, String ssc, String mobile,
 |  |                                          String idcard, String ssc, String mobile,
 | 
												
													
														
															|  |                                          String emerMobile, String images, String disease, String expenses, String signDoctorCode,
 |  | 
 | 
												
													
														
															|  | 
 |  |                                          String emerMobile, String images,
 | 
												
													
														
															|  | 
 |  |                                          String healthLabel, String customLabel, String disease,
 | 
												
													
														
															|  | 
 |  |                                          String expenses, String signDoctorCode,
 | 
												
													
														
															|  |                                          String signDoctorName, String signDoctorLevel, String customGroup) throws Exception {
 |  |                                          String signDoctorName, String signDoctorLevel, String customGroup) throws Exception {
 | 
												
													
														
															|  |         // 查询是否有家庭签约
 |  |         // 查询是否有家庭签约
 | 
												
													
														
															|  |         SignFamily sc = signFamilyDao.findByIdcard(idcard);
 |  |         SignFamily sc = signFamilyDao.findByIdcard(idcard);
 | 
												
											
												
													
														
															|  | @ -790,123 +795,10 @@ public class FamilyContractService extends BaseService {
 | 
												
													
														
															|  |         wlyyDoctorTeamPatient.setCzrq(new Date());
 |  |         wlyyDoctorTeamPatient.setCzrq(new Date());
 | 
												
													
														
															|  |         doctorTeamDoctor.save(wlyyDoctorTeamPatient);
 |  |         doctorTeamDoctor.save(wlyyDoctorTeamPatient);
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         //病人分组类别
 |  | 
 | 
												
													
														
															|  |         String groupCode = "1";
 |  | 
 | 
												
													
														
															|  |         //判断病人分组
 |  | 
 | 
												
													
														
															|  |         if (!StringUtils.isEmpty(disease)) {
 |  | 
 | 
												
													
														
															|  |             List<String> diseases = Arrays.asList(disease.split(","));
 |  | 
 | 
												
													
														
															|  |             if (diseases.contains("1") || diseases.contains("2")) {
 |  | 
 | 
												
													
														
															|  |                 groupCode = "2";
 |  | 
 | 
												
													
														
															|  |             }
 |  | 
 | 
												
													
														
															|  |         } else {
 |  | 
 | 
												
													
														
															|  |             String birth = patient.getIdcard().substring(6, 14);
 |  | 
 | 
												
													
														
															|  |             int year = Integer.valueOf(birth.substring(0, 4));
 |  | 
 | 
												
													
														
															|  |             int month = Integer.valueOf(birth.substring(4, 6));
 |  | 
 | 
												
													
														
															|  |             int day = Integer.valueOf(birth.substring(6));
 |  | 
 | 
												
													
														
															|  |             Calendar cal = Calendar.getInstance();
 |  | 
 | 
												
													
														
															|  |             int age = cal.get(Calendar.YEAR) - year;
 |  | 
 | 
												
													
														
															|  |             //周岁计算
 |  | 
 | 
												
													
														
															|  |             if (cal.get(Calendar.MONTH) > (month - 1) || (cal.get(Calendar.MONTH) == (month - 1) && cal.get(Calendar.DATE) > day)) {
 |  | 
 | 
												
													
														
															|  |                 age--;
 |  | 
 | 
												
													
														
															|  |             }
 |  | 
 | 
												
													
														
															|  |             if (age >= 65) {
 |  | 
 | 
												
													
														
															|  |                 groupCode = "3";
 |  | 
 | 
												
													
														
															|  |             }
 |  | 
 | 
												
													
														
															|  |         }
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         //把病人添加到健康管理师的健康分组里
 |  | 
 | 
												
													
														
															|  |         DoctorPatientGroupInfo doctorPatientGroupInfo = new DoctorPatientGroupInfo();
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setCzrq(new Date());
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setDoctor(doctorHealth);
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setStatus(1);
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setPatient(patient.getCode());
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setPname(patient.getName());
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setPartAmount(0);
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setGroup(groupCode);//默认健康分组
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setQyrq(new Date());
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setSignType("2");//家庭签约
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfoDao.save(doctorPatientGroupInfo);
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         //把病人添加到全科医生的健康分组里
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo = new DoctorPatientGroupInfo();
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setCzrq(new Date());
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setDoctor(doctor);
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setStatus(1);
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setPatient(patient.getCode());
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setPname(patient.getName());
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setPartAmount(0);
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setGroup(groupCode);//默认健康分组
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setQyrq(new Date());
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setSignType("2");//家庭签约
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfoDao.save(doctorPatientGroupInfo);
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         if (!StringUtils.isEmpty(customGroup) && !customGroup.equals("0")) {
 |  | 
 | 
												
													
														
															|  |             DoctorPatientGroupInfo customDoctorGroup = new DoctorPatientGroupInfo();
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |             customDoctorGroup.setCzrq(new Date());
 |  | 
 | 
												
													
														
															|  |             customDoctorGroup.setDoctor(signDoctorCode);
 |  | 
 | 
												
													
														
															|  |             customDoctorGroup.setStatus(1);
 |  | 
 | 
												
													
														
															|  |             customDoctorGroup.setPatient(patient.getCode());
 |  | 
 | 
												
													
														
															|  |             customDoctorGroup.setPname(patient.getName());
 |  | 
 | 
												
													
														
															|  |             customDoctorGroup.setPartAmount(0);
 |  | 
 | 
												
													
														
															|  |             customDoctorGroup.setGroup(customGroup);
 |  | 
 | 
												
													
														
															|  |             customDoctorGroup.setQyrq(new Date());
 |  | 
 | 
												
													
														
															|  |             customDoctorGroup.setSignType("2");//家庭签约
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |             doctorPatientGroupInfoDao.save(customDoctorGroup);
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |             SignFamily signFamily = signFamilyDao.findSsSignByDoctorPatient(sf.getDoctor(), sf.getPatient());
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |             if (signFamily != null) {
 |  | 
 | 
												
													
														
															|  |                 DoctorPatientGroupInfo ssDoctorGroup = new DoctorPatientGroupInfo();
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |                 ssDoctorGroup.setCzrq(new Date());
 |  | 
 | 
												
													
														
															|  |                 ssDoctorGroup.setDoctor(signDoctorCode);
 |  | 
 | 
												
													
														
															|  |                 ssDoctorGroup.setStatus(1);
 |  | 
 | 
												
													
														
															|  |                 ssDoctorGroup.setPatient(patient.getCode());
 |  | 
 | 
												
													
														
															|  |                 ssDoctorGroup.setPname(patient.getName());
 |  | 
 | 
												
													
														
															|  |                 ssDoctorGroup.setPartAmount(0);
 |  | 
 | 
												
													
														
															|  |                 ssDoctorGroup.setGroup(customGroup);
 |  | 
 | 
												
													
														
															|  |                 ssDoctorGroup.setQyrq(new Date());
 |  | 
 | 
												
													
														
															|  |                 ssDoctorGroup.setSignType("1");//三师签约
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |                 doctorPatientGroupInfoDao.save(ssDoctorGroup);
 |  | 
 | 
												
													
														
															|  |             }
 |  | 
 | 
												
													
														
															|  |         }
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         List<DoctorPatientGroupInfo> groups = doctorPatientGroupInfoDao.findPatientGroups(patient.getCode());
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         if (groups != null && groups.size() > 0) {
 |  | 
 | 
												
													
														
															|  |             for (DoctorPatientGroupInfo group : groups) {
 |  | 
 | 
												
													
														
															|  |                 if (StringUtils.isNotEmpty(group.getSignType()) && group.getSignType().equals("2")) {
 |  | 
 | 
												
													
														
															|  |                     continue;
 |  | 
 | 
												
													
														
															|  |                 }
 |  | 
 | 
												
													
														
															|  |                 if (group.getGroup().equals(customGroup)) {
 |  | 
 | 
												
													
														
															|  |                     continue;
 |  | 
 | 
												
													
														
															|  |                 }
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |                 DoctorPatientGroupInfo patientGroup = new DoctorPatientGroupInfo();
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |                 patientGroup.setCzrq(new Date());
 |  | 
 | 
												
													
														
															|  |                 patientGroup.setDoctor(group.getDoctor());
 |  | 
 | 
												
													
														
															|  |                 patientGroup.setStatus(1);
 |  | 
 | 
												
													
														
															|  |                 patientGroup.setPatient(patient.getCode());
 |  | 
 | 
												
													
														
															|  |                 patientGroup.setPname(patient.getName());
 |  | 
 | 
												
													
														
															|  |                 patientGroup.setPartAmount(0);
 |  | 
 | 
												
													
														
															|  |                 patientGroup.setGroup(group.getGroup());
 |  | 
 | 
												
													
														
															|  |                 patientGroup.setQyrq(new Date());
 |  | 
 | 
												
													
														
															|  |                 patientGroup.setSignType("2");//家庭签约
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |                 doctorPatientGroupInfoDao.save(patientGroup);
 |  | 
 | 
												
													
														
															|  |             }
 |  | 
 | 
												
													
														
															|  |         }
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         if (!StringUtils.isEmpty(disease) && !disease.equals("0")) {
 |  | 
 | 
												
													
														
															|  |             boolean flag = patientDiseaseService.updatePatientDisease(sf.getPatient(), disease);
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |             if (!flag) {
 |  | 
 | 
												
													
														
															|  |                 throw new Exception("疾病更新失败");
 |  | 
 | 
												
													
														
															|  |             }
 |  | 
 | 
												
													
														
															|  | 
 |  |         // 患者标签设置
 | 
												
													
														
															|  | 
 |  |         if(!(labelInfoService.setPatientLabels(patient.getCode(),patient.getIdcard(),
 | 
												
													
														
															|  | 
 |  |                 patient.getName(),healthLabel,disease,customLabel) == 1)){
 | 
												
													
														
															|  | 
 |  |             throw new Exception("patient sign label settting error:" + patient.getIdcard());
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         SignFamily temp = signFamilyDao.save(sf);
 |  |         SignFamily temp = signFamilyDao.save(sf);
 | 
												
											
												
													
														
															|  | @ -947,7 +839,9 @@ public class FamilyContractService extends BaseService {
 | 
												
													
														
															|  |                           String healthDoctor,
 |  |                           String healthDoctor,
 | 
												
													
														
															|  |                           String healthDoctorName,
 |  |                           String healthDoctorName,
 | 
												
													
														
															|  |                           long msgid,
 |  |                           long msgid,
 | 
												
													
														
															|  |                           String patientCard, int type, String disease, String majorDoctor, String majorhDoctorName, String customGroup, String expenses) throws Exception {
 |  | 
 | 
												
													
														
															|  | 
 |  |                           String patientCard, int type,
 | 
												
													
														
															|  | 
 |  |                           String healthLabel, String customLabel, String disease,
 | 
												
													
														
															|  | 
 |  |                           String majorDoctor, String majorhDoctorName, String customGroup, String expenses) throws Exception {
 | 
												
													
														
															|  |         if (type != 1 && type != 2) {
 |  |         if (type != 1 && type != 2) {
 | 
												
													
														
															|  |             return -1;
 |  |             return -1;
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
											
												
													
														
															|  | @ -1072,124 +966,10 @@ public class FamilyContractService extends BaseService {
 | 
												
													
														
															|  |             return 2;
 |  |             return 2;
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         //病人分组类别
 |  | 
 | 
												
													
														
															|  |         String groupCode = "1";
 |  | 
 | 
												
													
														
															|  |         //判断病人分组
 |  | 
 | 
												
													
														
															|  |         if (!StringUtils.isEmpty(disease)) {
 |  | 
 | 
												
													
														
															|  |             List<String> diseases = Arrays.asList(disease.split(","));
 |  | 
 | 
												
													
														
															|  |             if (diseases.contains("1") || diseases.contains("2")) {
 |  | 
 | 
												
													
														
															|  |                 groupCode = "2";
 |  | 
 | 
												
													
														
															|  |             }
 |  | 
 | 
												
													
														
															|  |         } else {
 |  | 
 | 
												
													
														
															|  |             String birth = p.getIdcard().substring(6, 14);
 |  | 
 | 
												
													
														
															|  |             int year = Integer.valueOf(birth.substring(0, 4));
 |  | 
 | 
												
													
														
															|  |             int month = Integer.valueOf(birth.substring(4, 6));
 |  | 
 | 
												
													
														
															|  |             int day = Integer.valueOf(birth.substring(6));
 |  | 
 | 
												
													
														
															|  |             Calendar cal = Calendar.getInstance();
 |  | 
 | 
												
													
														
															|  |             int age = cal.get(Calendar.YEAR) - year;
 |  | 
 | 
												
													
														
															|  |             //周岁计算
 |  | 
 | 
												
													
														
															|  |             if (cal.get(Calendar.MONTH) > (month - 1) || (cal.get(Calendar.MONTH) == (month - 1) && cal.get(Calendar.DATE) > day)) {
 |  | 
 | 
												
													
														
															|  |                 age--;
 |  | 
 | 
												
													
														
															|  |             }
 |  | 
 | 
												
													
														
															|  |             if (age >= 65) {
 |  | 
 | 
												
													
														
															|  |                 groupCode = "3";
 |  | 
 | 
												
													
														
															|  |             }
 |  | 
 | 
												
													
														
															|  |         }
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         //设置签约人到全科管理师和健康管理师的健康人群分组里
 |  | 
 | 
												
													
														
															|  |         //给病人分组
 |  | 
 | 
												
													
														
															|  |         //把病人添加到健康管理师的健康分组里
 |  | 
 | 
												
													
														
															|  |         DoctorPatientGroupInfo doctorPatientGroupInfo = new DoctorPatientGroupInfo();
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setCzrq(new Date());
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setDoctor(healthDoctor);
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setStatus(1);
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setPatient(p.getCode());
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setPname(p.getName());
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setPartAmount(0);
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setGroup(groupCode);//默认健康分组
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setQyrq(new Date());
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setSignType("2");//家庭签约
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfoDao.save(doctorPatientGroupInfo);
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         //把病人添加到全科医生的健康分组里
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo = new DoctorPatientGroupInfo();
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setCzrq(new Date());
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setDoctor(sf.getDoctor());
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setStatus(1);
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setPatient(p.getCode());
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setPname(p.getName());
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setPartAmount(0);
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setGroup(groupCode);//默认健康分组
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setQyrq(new Date());
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfo.setSignType("2");//家庭签约
 |  | 
 | 
												
													
														
															|  |         doctorPatientGroupInfoDao.save(doctorPatientGroupInfo);
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         if (!StringUtils.isEmpty(customGroup) && !customGroup.equals("0")) {
 |  | 
 | 
												
													
														
															|  |             DoctorPatientGroupInfo customDoctorGroup = new DoctorPatientGroupInfo();
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |             customDoctorGroup.setCzrq(new Date());
 |  | 
 | 
												
													
														
															|  |             customDoctorGroup.setDoctor(sf.getDoctor());
 |  | 
 | 
												
													
														
															|  |             customDoctorGroup.setStatus(1);
 |  | 
 | 
												
													
														
															|  |             customDoctorGroup.setPatient(p.getCode());
 |  | 
 | 
												
													
														
															|  |             customDoctorGroup.setPname(p.getName());
 |  | 
 | 
												
													
														
															|  |             customDoctorGroup.setPartAmount(0);
 |  | 
 | 
												
													
														
															|  |             customDoctorGroup.setGroup(customGroup);
 |  | 
 | 
												
													
														
															|  |             customDoctorGroup.setQyrq(new Date());
 |  | 
 | 
												
													
														
															|  |             customDoctorGroup.setSignType("2");//家庭签约
 |  | 
 | 
												
													
														
															|  |             doctorPatientGroupInfoDao.save(customDoctorGroup);
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |             SignFamily signFamily = signFamilyDao.findSsSignByDoctorPatient(sf.getDoctor(), sf.getPatient());
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |             if (signFamily != null) {
 |  | 
 | 
												
													
														
															|  |                 DoctorPatientGroupInfo ssDoctorGroup = new DoctorPatientGroupInfo();
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |                 ssDoctorGroup.setCzrq(new Date());
 |  | 
 | 
												
													
														
															|  |                 ssDoctorGroup.setDoctor(sf.getDoctor());
 |  | 
 | 
												
													
														
															|  |                 ssDoctorGroup.setStatus(1);
 |  | 
 | 
												
													
														
															|  |                 ssDoctorGroup.setPatient(p.getCode());
 |  | 
 | 
												
													
														
															|  |                 ssDoctorGroup.setPname(p.getName());
 |  | 
 | 
												
													
														
															|  |                 ssDoctorGroup.setPartAmount(0);
 |  | 
 | 
												
													
														
															|  |                 ssDoctorGroup.setGroup(customGroup);
 |  | 
 | 
												
													
														
															|  |                 ssDoctorGroup.setQyrq(new Date());
 |  | 
 | 
												
													
														
															|  |                 ssDoctorGroup.setSignType("1");//三师签约
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |                 doctorPatientGroupInfoDao.save(ssDoctorGroup);
 |  | 
 | 
												
													
														
															|  |             }
 |  | 
 | 
												
													
														
															|  |         }
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         List<DoctorPatientGroupInfo> groups = doctorPatientGroupInfoDao.findPatientGroups(p.getCode());
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         if (groups != null && groups.size() > 0) {
 |  | 
 | 
												
													
														
															|  |             for (DoctorPatientGroupInfo group : groups) {
 |  | 
 | 
												
													
														
															|  |                 if (StringUtils.isNotEmpty(group.getSignType()) && group.getSignType().equals("2")) {
 |  | 
 | 
												
													
														
															|  |                     continue;
 |  | 
 | 
												
													
														
															|  |                 }
 |  | 
 | 
												
													
														
															|  |                 if (group.getGroup().equals(customGroup)) {
 |  | 
 | 
												
													
														
															|  |                     continue;
 |  | 
 | 
												
													
														
															|  |                 }
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |                 DoctorPatientGroupInfo patientGroup = new DoctorPatientGroupInfo();
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |                 patientGroup.setCzrq(new Date());
 |  | 
 | 
												
													
														
															|  |                 patientGroup.setDoctor(group.getDoctor());
 |  | 
 | 
												
													
														
															|  |                 patientGroup.setStatus(1);
 |  | 
 | 
												
													
														
															|  |                 patientGroup.setPatient(p.getCode());
 |  | 
 | 
												
													
														
															|  |                 patientGroup.setPname(p.getName());
 |  | 
 | 
												
													
														
															|  |                 patientGroup.setPartAmount(0);
 |  | 
 | 
												
													
														
															|  |                 patientGroup.setGroup(group.getGroup());
 |  | 
 | 
												
													
														
															|  |                 patientGroup.setQyrq(new Date());
 |  | 
 | 
												
													
														
															|  |                 patientGroup.setSignType("2");//家庭签约
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |                 doctorPatientGroupInfoDao.save(patientGroup);
 |  | 
 | 
												
													
														
															|  |             }
 |  | 
 | 
												
													
														
															|  |         }
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         if (!StringUtils.isEmpty(disease) && !disease.equals("0")) {
 |  | 
 | 
												
													
														
															|  |             boolean flag = patientDiseaseService.updatePatientDisease(sf.getPatient(), disease);
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |             if (!flag) {
 |  | 
 | 
												
													
														
															|  |                 throw new Exception("疾病更新失败");
 |  | 
 | 
												
													
														
															|  |             }
 |  | 
 | 
												
													
														
															|  | 
 |  |         // 患者标签设置
 | 
												
													
														
															|  | 
 |  |         if(!(labelInfoService.setPatientLabels(p.getCode(),p.getIdcard(),
 | 
												
													
														
															|  | 
 |  |                 p.getName(),healthLabel,disease,customLabel) == 1)){
 | 
												
													
														
															|  | 
 |  |             throw new Exception("patient sign label settting error:" + p.getIdcard());
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         // 推送消息消息给微信端
 |  |         // 推送消息消息给微信端
 | 
												
											
												
													
														
															|  | @ -1523,16 +1303,13 @@ public class FamilyContractService extends BaseService {
 | 
												
													
														
															|  |             }
 |  |             }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |             // 查询患者疾病
 |  |             // 查询患者疾病
 | 
												
													
														
															|  |             String diseases = redisTemplate.opsForValue().get("disease:" + p.getCode());
 |  | 
 | 
												
													
														
															|  |             if (!StringUtils.isEmpty(diseases)) {
 |  | 
 | 
												
													
														
															|  |                 JSONArray array = new JSONArray(diseases);
 |  | 
 | 
												
													
														
															|  | 
 |  |             List<PatientDisease> diseases = patientDiseaseDao.findByPatientSsDisease(p.getCode());
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |             if (diseases != null && diseases.size() > 0) {
 | 
												
													
														
															|  |                 JSONArray disArray = new JSONArray();
 |  |                 JSONArray disArray = new JSONArray();
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |                 for (int i = 0; i < array.length(); i++) {
 |  | 
 | 
												
													
														
															|  |                     JSONObject json = array.getJSONObject(i);
 |  | 
 | 
												
													
														
															|  |                     if (json != null && json.get("signType").toString().equals("1")) {
 |  | 
 | 
												
													
														
															|  |                         disArray.put(json);
 |  | 
 | 
												
													
														
															|  |                     }
 |  | 
 | 
												
													
														
															|  | 
 |  |                 for (PatientDisease dis : diseases) {
 | 
												
													
														
															|  | 
 |  |                     disArray.put(new JSONObject(dis));
 | 
												
													
														
															|  |                 }
 |  |                 }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |                 result.put("diseases", disArray);
 |  |                 result.put("diseases", disArray);
 | 
												
											
												
													
														
															|  | @ -1652,24 +1429,24 @@ public class FamilyContractService extends BaseService {
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     public String produceSignAdminTeamCode() {
 |  |     public String produceSignAdminTeamCode() {
 | 
												
													
														
															|  |         StringBuffer sf=new StringBuffer();
 |  | 
 | 
												
													
														
															|  |         StringBuffer sf1=new StringBuffer();
 |  | 
 | 
												
													
														
															|  |         Long size=0L;
 |  | 
 | 
												
													
														
															|  | 
 |  |         StringBuffer sf = new StringBuffer();
 | 
												
													
														
															|  | 
 |  |         StringBuffer sf1 = new StringBuffer();
 | 
												
													
														
															|  | 
 |  |         Long size = 0L;
 | 
												
													
														
															|  |         //找出家庭签约中团队code是空的
 |  |         //找出家庭签约中团队code是空的
 | 
												
													
														
															|  |         List<SignFamily> signFamilys= signFamilyDao.findBySignTypeAndTeamCode();
 |  | 
 | 
												
													
														
															|  |         sf.append("家庭签约中团队code是空的数据数:"+signFamilys.size());
 |  | 
 | 
												
													
														
															|  |         for(SignFamily signFamily:signFamilys){
 |  | 
 | 
												
													
														
															|  | 
 |  |         List<SignFamily> signFamilys = signFamilyDao.findBySignTypeAndTeamCode();
 | 
												
													
														
															|  | 
 |  |         sf.append("家庭签约中团队code是空的数据数:" + signFamilys.size());
 | 
												
													
														
															|  | 
 |  |         for (SignFamily signFamily : signFamilys) {
 | 
												
													
														
															|  |             //得到签约中的全科医生的团队
 |  |             //得到签约中的全科医生的团队
 | 
												
													
														
															|  |             String doctorCode=signFamily.getDoctor();
 |  | 
 | 
												
													
														
															|  |             Long id= doctorAdminTeamDao.findIdByLeaderCode(doctorCode);
 |  | 
 | 
												
													
														
															|  |             if(id!=null&&id>0){
 |  | 
 | 
												
													
														
															|  | 
 |  |             String doctorCode = signFamily.getDoctor();
 | 
												
													
														
															|  | 
 |  |             Long id = doctorAdminTeamDao.findIdByLeaderCode(doctorCode);
 | 
												
													
														
															|  | 
 |  |             if (id != null && id > 0) {
 | 
												
													
														
															|  |                 size++;
 |  |                 size++;
 | 
												
													
														
															|  |                 signFamily.setAdminTeamId(id);
 |  |                 signFamily.setAdminTeamId(id);
 | 
												
													
														
															|  |             }else{
 |  | 
 | 
												
													
														
															|  |                 sf1.append(",找不到医生所属的团队,医生code:"+doctorCode);
 |  | 
 | 
												
													
														
															|  | 
 |  |             } else {
 | 
												
													
														
															|  | 
 |  |                 sf1.append(",找不到医生所属的团队,医生code:" + doctorCode);
 | 
												
													
														
															|  |             }
 |  |             }
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         sf.append(",填充团队的签约数据数:"+size);
 |  | 
 | 
												
													
														
															|  | 
 |  |         sf.append(",填充团队的签约数据数:" + size);
 | 
												
													
														
															|  |         sf.append(sf1);
 |  |         sf.append(sf1);
 | 
												
													
														
															|  |         return sf.toString();
 |  |         return sf.toString();
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
											
												
													
														
															|  | @ -1677,25 +1454,25 @@ public class FamilyContractService extends BaseService {
 | 
												
													
														
															|  |     /**
 |  |     /**
 | 
												
													
														
															|  |      * 分配健管师
 |  |      * 分配健管师
 | 
												
													
														
															|  |      *
 |  |      *
 | 
												
													
														
															|  |      * @param patient 患者code
 |  | 
 | 
												
													
														
															|  | 
 |  |      * @param patient      患者code
 | 
												
													
														
															|  |      * @param healthDoctor 健康管理师code
 |  |      * @param healthDoctor 健康管理师code
 | 
												
													
														
															|  |      * @return
 |  |      * @return
 | 
												
													
														
															|  |      */
 |  |      */
 | 
												
													
														
															|  |     public JSONObject updateSignInfo(String patient,String healthDoctor,String expensesType){
 |  | 
 | 
												
													
														
															|  | 
 |  |     public JSONObject updateSignInfo(String patient, String healthDoctor, String expensesType) {
 | 
												
													
														
															|  |         JSONObject result = new JSONObject();
 |  |         JSONObject result = new JSONObject();
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         SignFamily signFamily = signFamilyDao.findByjiatingPatientYes(patient);
 |  |         SignFamily signFamily = signFamilyDao.findByjiatingPatientYes(patient);
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         if(signFamily == null){
 |  | 
 | 
												
													
														
															|  |             result.put("status",-1);
 |  | 
 | 
												
													
														
															|  |             result.put("msg","居民不存在家庭签约");
 |  | 
 | 
												
													
														
															|  | 
 |  |         if (signFamily == null) {
 | 
												
													
														
															|  | 
 |  |             result.put("status", -1);
 | 
												
													
														
															|  | 
 |  |             result.put("msg", "居民不存在家庭签约");
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         if(StringUtils.isNotEmpty(healthDoctor)) {
 |  | 
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotEmpty(healthDoctor)) {
 | 
												
													
														
															|  |             Doctor doctor = doctorDao.findByCode(healthDoctor);
 |  |             Doctor doctor = doctorDao.findByCode(healthDoctor);
 | 
												
													
														
															|  |             if(doctor == null){
 |  | 
 | 
												
													
														
															|  |                 result.put("status",-2);
 |  | 
 | 
												
													
														
															|  |                 result.put("msg","医生不存在");
 |  | 
 | 
												
													
														
															|  | 
 |  |             if (doctor == null) {
 | 
												
													
														
															|  | 
 |  |                 result.put("status", -2);
 | 
												
													
														
															|  | 
 |  |                 result.put("msg", "医生不存在");
 | 
												
													
														
															|  |             }
 |  |             }
 | 
												
													
														
															|  |             if (StringUtils.isNotEmpty(signFamily.getDoctorHealth())) {
 |  |             if (StringUtils.isNotEmpty(signFamily.getDoctorHealth())) {
 | 
												
													
														
															|  |                 // 取消原有健康管理师的家庭签约分组,并新增分组
 |  |                 // 取消原有健康管理师的家庭签约分组,并新增分组
 | 
												
											
												
													
														
															|  | @ -1794,30 +1571,30 @@ public class FamilyContractService extends BaseService {
 | 
												
													
														
															|  |             signFamily.setCzrq(new Date());
 |  |             signFamily.setCzrq(new Date());
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         if(StringUtils.isNotEmpty(expensesType)){
 |  | 
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotEmpty(expensesType)) {
 | 
												
													
														
															|  |             if (StringUtils.isNotEmpty(signFamily.getMedicalInsuranceNum())) {
 |  |             if (StringUtils.isNotEmpty(signFamily.getMedicalInsuranceNum())) {
 | 
												
													
														
															|  |                 result.put("status", -3);
 |  |                 result.put("status", -3);
 | 
												
													
														
															|  |                 result.put("msg","数据已上传社保,不能修改补贴类型");
 |  | 
 | 
												
													
														
															|  |             }else{
 |  | 
 | 
												
													
														
															|  | 
 |  |                 result.put("msg", "数据已上传社保,不能修改补贴类型");
 | 
												
													
														
															|  | 
 |  |             } else {
 | 
												
													
														
															|  |                 signFamily.setExpensesType(expensesType);
 |  |                 signFamily.setExpensesType(expensesType);
 | 
												
													
														
															|  |             }
 |  |             }
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         result.put("status",1);
 |  | 
 | 
												
													
														
															|  |         result.put("msg","更新成功");
 |  | 
 | 
												
													
														
															|  | 
 |  |         result.put("status", 1);
 | 
												
													
														
															|  | 
 |  |         result.put("msg", "更新成功");
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         return result;
 |  |         return result;
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     public List<SignFamily> findNoHealthSignFamilyNum(String doctor) {
 |  |     public List<SignFamily> findNoHealthSignFamilyNum(String doctor) {
 | 
												
													
														
															|  |        return  signFamilyDao.findNoHealthSignFamilyNum(doctor);
 |  | 
 | 
												
													
														
															|  | 
 |  |         return signFamilyDao.findNoHealthSignFamilyNum(doctor);
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     public Page<SignFamily> findNoHealthSignFamilyHealth(String doctor, Integer page, Integer pagesize) {
 |  |     public Page<SignFamily> findNoHealthSignFamilyHealth(String doctor, Integer page, Integer pagesize) {
 | 
												
													
														
															|  |         if (pagesize==null||pagesize <= 0) {
 |  | 
 | 
												
													
														
															|  | 
 |  |         if (pagesize == null || pagesize <= 0) {
 | 
												
													
														
															|  |             pagesize = 10;
 |  |             pagesize = 10;
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         if (page==null||page < 0) {
 |  | 
 | 
												
													
														
															|  | 
 |  |         if (page == null || page < 0) {
 | 
												
													
														
															|  |             page = 0;
 |  |             page = 0;
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         // 分页信息
 |  |         // 分页信息
 |