|  | @ -187,8 +187,6 @@ public class SpecialistService{
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public MixEnvelop<PatientLabelVO, PatientLabelVO> getPatientByLabel(String doctor, String labelType, String labelCode, Integer page, Integer size){
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |         String sql="SELECT " +
 | 
	
		
			
				|  |  |                 " p. NAME, " +
 | 
	
		
			
				|  |  |                 " p. CODE, " +
 | 
	
	
		
			
				|  | @ -223,7 +221,11 @@ public class SpecialistService{
 | 
	
		
			
				|  |  |                 " ) lb " +
 | 
	
		
			
				|  |  |                 " JOIN "+basedb+".wlyy_patient p ON p. CODE = lb.patient " +
 | 
	
		
			
				|  |  |                 " JOIN wlyy_specialist_patient_relation s ON s.patient = lb.patient " +
 | 
	
		
			
				|  |  |                 " WHERE ( s.doctor ='"+doctor+"' OR s.health_doctor='"+doctor+"' OR s.health_assistant='"+doctor+ "') AND s.status >=0  AND s.sign_status >0"+
 | 
	
		
			
				|  |  |                 " WHERE s.doctor in " +
 | 
	
		
			
				|  |  |                 " (SELECT m.doctor_code FROM  wlyy.wlyy_admin_team_member m where m.team_id in " +
 | 
	
		
			
				|  |  |                 " (SELECT dt.id FROM  wlyy.wlyy_admin_team dt LEFT JOIN  wlyy.wlyy_admin_team_member watm ON dt.id=watm.team_id " +
 | 
	
		
			
				|  |  |                 " WHERE dt.available='1' AND watm.available='1' AND watm.doctor_code='"+doctor+"') AND  m.available='1') "+
 | 
	
		
			
				|  |  |                 " AND s.status >=0  AND s.sign_status >0"+
 | 
	
		
			
				|  |  |                 " LIMIT "+(page-1)*size+","+size;
 | 
	
		
			
				|  |  |         System.out.print("日志:"+sql);
 | 
	
		
			
				|  |  |         if("7".equals(labelType)){
 | 
	
	
		
			
				|  | @ -242,13 +244,15 @@ public class SpecialistService{
 | 
	
		
			
				|  |  |                     "JOIN "+basedb+".wlyy_patient_disease_server b ON a.id=b.specialist_relation_code AND b.disease=" +labelCode+" and b.del=1 "+
 | 
	
		
			
				|  |  |                     "JOIN "+basedb+".wlyy_patient c ON a.patient=c.CODE " +
 | 
	
		
			
				|  |  |                     "LEFT JOIN "+basedb+".wlyy_sign_patient_label_info d ON a.patient=d.patient AND d.label_type=8 AND d.`status`=1" +
 | 
	
		
			
				|  |  |                     " WHERE a.sign_status> 0 AND a.`status`>=0 AND a.doctor='"+doctor+"' OR a.health_assistant= '"+doctor+
 | 
	
		
			
				|  |  |                     "' LIMIT "+(page-1)*size+","+size;
 | 
	
		
			
				|  |  |                     " WHERE a.sign_status> 0 AND a.`status`>=0 " +
 | 
	
		
			
				|  |  | //                    "AND a.doctor='"+doctor+"' OR a.health_assistant= '"+doctor+
 | 
	
		
			
				|  |  |                     " AND a.doctor in " +
 | 
	
		
			
				|  |  |                     " (SELECT m.doctor_code FROM  wlyy.wlyy_admin_team_member m where m.team_id in " +
 | 
	
		
			
				|  |  |                     " (SELECT dt.id FROM  wlyy.wlyy_admin_team dt LEFT JOIN  wlyy.wlyy_admin_team_member watm ON dt.id=watm.team_id " +
 | 
	
		
			
				|  |  |                     " WHERE dt.available='1' AND watm.available='1' AND watm.doctor_code='"+doctor+"') AND  m.available='1') "+
 | 
	
		
			
				|  |  |                     " LIMIT "+(page-1)*size+","+size;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<PatientLabelVO> PatientLabelVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PatientLabelVO.class));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return MixEnvelop.getSuccess(SpecialistMapping.api_success,PatientLabelVOs);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -616,15 +620,19 @@ public class SpecialistService{
 | 
	
		
			
				|  |  |                 " d.hospital_name AS hospital_name, " +
 | 
	
		
			
				|  |  |                 " d.`level` " +
 | 
	
		
			
				|  |  |                 " FROM " +
 | 
	
		
			
				|  |  |                 " wlyy_specialist_patient_relation r " +
 | 
	
		
			
				|  |  |                 " wlyy_specialist.wlyy_specialist_patient_relation r " +
 | 
	
		
			
				|  |  |                 " JOIN "+basedb+".wlyy_doctor d ON r.doctor = d.`code` " +
 | 
	
		
			
				|  |  |                 " WHERE  " +
 | 
	
		
			
				|  |  |                 " r.patient ='"+patient+"' " +
 | 
	
		
			
				|  |  |                 " AND r.doctor ='"+doctor+"' " +
 | 
	
		
			
				|  |  |                 " AND r.doctor in" +
 | 
	
		
			
				|  |  |                 " (SELECT m.doctor_code FROM  wlyy.wlyy_admin_team_member m where m.team_id in  " +
 | 
	
		
			
				|  |  |                 "  (SELECT dt.id FROM  wlyy.wlyy_admin_team dt LEFT JOIN  wlyy.wlyy_admin_team_member watm ON dt.id=watm.team_id  " +
 | 
	
		
			
				|  |  |                 "  WHERE dt.available='1' AND watm.available='1' AND watm.doctor_code='"+doctor+"') AND  m.available='1')" +
 | 
	
		
			
				|  |  |                 " AND r.`status`>=0 " +
 | 
	
		
			
				|  |  |                 " AND r.sign_status >0 ) r join "+basedb+".wlyy_patient p on r.patient = p.code order by p.czrq DESC ";
 | 
	
		
			
				|  |  |         List<PatientSignInfoVO> patientSignInfoVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PatientSignInfoVO.class));
 | 
	
		
			
				|  |  |         return MixEnvelop.getSuccess(SpecialistMapping.api_success,patientSignInfoVOs.get(0));
 | 
	
		
			
				|  |  |         PatientSignInfoVO patientSignInfoVO = (null != patientSignInfoVOs && patientSignInfoVOs.size() > 0 )? patientSignInfoVOs.get(0):null;
 | 
	
		
			
				|  |  |         return MixEnvelop.getSuccess(SpecialistMapping.api_success, patientSignInfoVO);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |     public MixEnvelop findDoctorAndDoctorHealthBySpecialDoctor(String doctor,String name) {
 | 
	
	
		
			
				|  | @ -839,9 +847,15 @@ public class SpecialistService{
 | 
	
		
			
				|  |  |      * 病人的家签信息、专科开通信息
 | 
	
		
			
				|  |  |      * @param doctorCode 医生code
 | 
	
		
			
				|  |  |      * @param patientCode 病人id
 | 
	
		
			
				|  |  |      * @param signStatus 签约状态,待审核:0;未签约:-1
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONObject doctorForSpecialistInfo(String doctorCode, String patientCode)  throws Exception{
 | 
	
		
			
				|  |  |     public JSONObject doctorForSpecialistInfo(String signStatus,String doctorCode, String patientCode)  throws Exception{
 | 
	
		
			
				|  |  |         JSONObject jsonObject = new JSONObject();
 | 
	
		
			
				|  |  |         SpecialistPatientRelationDO specialistPatientRelationDO = new SpecialistPatientRelationDO();
 | 
	
		
			
				|  |  |         //待审核
 | 
	
		
			
				|  |  |         if ("0".equals(signStatus)) {
 | 
	
		
			
				|  |  |             specialistPatientRelationDO = specialistPatientRelationDao.findByDoctorAndPatient(doctorCode, patientCode);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //1、获取居民基础信息
 | 
	
		
			
				|  |  |         String preSql = "SELECT p.name as name, p.photo as photo,p.idcard as idcard,p.mobile as mobile,p.medicare_number as medicareNumber,p.ssc as ssc," +
 | 
	
		
			
				|  |  |                 " CASE  WHEN wd.name is null THEN '无' ELSE wd.name END as doctorName,CASE  WHEN wd.hospital_name is NULL THEN '无' ELSE wd.hospital_name END as hospitalName,CASE  WHEN wd.mobile is NULL THEN '无' ELSE wd.mobile END as doctorMobole ";
 | 
	
	
		
			
				|  | @ -902,6 +916,118 @@ public class SpecialistService{
 | 
	
		
			
				|  |  |         return jsonObject;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 病人的家签信息、专科开通信息
 | 
	
		
			
				|  |  |      * @param doctorCode 医生code
 | 
	
		
			
				|  |  |      * @param patientCode 病人id
 | 
	
		
			
				|  |  |      * @param signStatus 签约状态,待审核:0;未签约:-1
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONObject doctorForSpecialistInfoNew(String signStatus,String doctorCode, String patientCode)  throws Exception{
 | 
	
		
			
				|  |  |         JSONObject jsonObject = new JSONObject();
 | 
	
		
			
				|  |  |         SpecialistPatientRelationDO specialistPatientRelationDO = new SpecialistPatientRelationDO();
 | 
	
		
			
				|  |  |         //待审核
 | 
	
		
			
				|  |  |         if ("0".equals(signStatus)) {
 | 
	
		
			
				|  |  |             specialistPatientRelationDO = selectByDoctorAndPatient(doctorCode, patientCode);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         jsonObject.put("specialistPatientRelationId", null == specialistPatientRelationDO ? null : specialistPatientRelationDO.getId());
 | 
	
		
			
				|  |  |         //1、获取居民基础信息
 | 
	
		
			
				|  |  |         String preSql = "SELECT p.name as name, p.photo as photo,p.idcard as idcard,p.mobile as mobile,p.medicare_number as medicareNumber,p.ssc as ssc," +
 | 
	
		
			
				|  |  |                 " CASE  WHEN wd.name is null THEN '无' ELSE wd.name END as doctorName,CASE  WHEN wd.hospital_name is NULL THEN '无' ELSE wd.hospital_name END as hospitalName,CASE  WHEN wd.mobile is NULL THEN '无' ELSE wd.mobile END as doctorMobole ";
 | 
	
		
			
				|  |  |         String patientSql = " from " + basedb + ".wlyy_patient p LEFT JOIN " + basedb + ".wlyy_sign_family wsf " +
 | 
	
		
			
				|  |  |                 " ON p.code=wsf.patient AND wsf.type='2' AND wsf.status='1' " +
 | 
	
		
			
				|  |  |                 " LEFT JOIN " + basedb + ".wlyy_doctor wd ON wsf.doctor =wd.code WHERE p.code='" + patientCode + "'";
 | 
	
		
			
				|  |  |         //一个居民 生效的家签信息只会有一条
 | 
	
		
			
				|  |  |         Map<String, Object> map = jdbcTemplate.queryForMap(preSql + patientSql);
 | 
	
		
			
				|  |  |         map.put("age",IdCardUtil.getAgeForIdcard(map.get("idcard")+""));
 | 
	
		
			
				|  |  |         String sexCode=IdCardUtil.getSexForIdcard_new(map.get("idcard")+"");
 | 
	
		
			
				|  |  |         String sexName="";
 | 
	
		
			
				|  |  |         if("1".equals(sexCode)){
 | 
	
		
			
				|  |  |             sexName="男";
 | 
	
		
			
				|  |  |         }else if("2".equals(sexCode)){
 | 
	
		
			
				|  |  |             sexName="女";
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             sexName="未知";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         map.put("sex",sexName);
 | 
	
		
			
				|  |  |         jsonObject.put("patientInfo", map);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //2、获取医生信息(所属医院、科室、姓名)
 | 
	
		
			
				|  |  |         String doctorSql = "SELECT wd.hospital_name as hospitalName,wd.dept_name as deptName,wd.name as name FROM " + basedb + ".wlyy_doctor wd WHERE wd.code='" + doctorCode + "'";;
 | 
	
		
			
				|  |  |         if("0".equals(signStatus)){
 | 
	
		
			
				|  |  |             doctorSql="SELECT wd.hospital_name as hospitalName,wd.dept_name as deptName,wd.name as name FROM " + basedb + ".wlyy_doctor wd WHERE wd.code='" + specialistPatientRelationDO.getDoctor() + "'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         Map<String,Object> result =jdbcTemplate.queryForMap(doctorSql);
 | 
	
		
			
				|  |  |         if(doctorCode.equals(specialistPatientRelationDO.getDoctor())){
 | 
	
		
			
				|  |  |             result.put("buttonShowFlag",true);
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             result.put("buttonShowFlag",false);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         jsonObject.put("doctorInfo", result);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //3、获取该医生所属团队及团队成员信息
 | 
	
		
			
				|  |  |         String teamSql = "SELECT at.name teamName, tm.team_id , tm.doctor_code, wd.NAME as doctorName  FROM " + basedb + ".wlyy_doctor wd LEFT JOIN  " + basedb + ".wlyy_admin_team_member tm ON wd. CODE = tm.doctor_code, " + basedb + ".wlyy_admin_team at " +
 | 
	
		
			
				|  |  |                 "WHERE tm.team_id IN ( SELECT watm.team_id teamId FROM  " + basedb + ".wlyy_admin_team_member watm WHERE watm.doctor_code ='" + doctorCode + "'" + " AND watm.available = '1' ) AND tm.available='1' AND `at`.id=tm.team_id";
 | 
	
		
			
				|  |  |         List<Map<String, Object>> teamList = jdbcTemplate.queryForList(teamSql);
 | 
	
		
			
				|  |  |         Map<Integer, List<Map<String, Object>>> m = teamList.stream().collect(Collectors.groupingBy(tem -> ((Integer) tem.get("team_id")).intValue(), Collectors.toList()));
 | 
	
		
			
				|  |  |         List<Map<String, Object>> mapList = new ArrayList<>();
 | 
	
		
			
				|  |  |         for (Integer i : m.keySet()) {
 | 
	
		
			
				|  |  |             Map<String, Object> objectMap = new HashMap<>();
 | 
	
		
			
				|  |  |             if ("0".equals(signStatus) && i.equals(specialistPatientRelationDO.getTeamCode())) {
 | 
	
		
			
				|  |  |                 objectMap.put("checkFlag", true);
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 objectMap.put("checkFlag", false);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             objectMap.put("teamId", i);
 | 
	
		
			
				|  |  |             objectMap.put("teamName", m.get(i).get(0).get("teamName"));
 | 
	
		
			
				|  |  |             objectMap.put("teamDoctors", m.get(i));
 | 
	
		
			
				|  |  |             //获取专科团队疾病标签
 | 
	
		
			
				|  |  |             String disSql = "SELECT wtdr.disease_code, wtdr.disease_name from  wlyy.wlyy_team_disease_relation wtdr WHERE wtdr.team_code ='" + i + "'" +"  AND wtdr.del='1'";
 | 
	
		
			
				|  |  |             //new BeanPropertyRowMapper(
 | 
	
		
			
				|  |  |             List<Map<String, Object>>  stringList = jdbcTemplate.queryForList(disSql);
 | 
	
		
			
				|  |  |             String areaSql = "SELECT wpds.disease FROM wlyy.wlyy_patient_disease_server wpds WHERE wpds.patient='" + patientCode + "'" + " AND wpds.del='1'";
 | 
	
		
			
				|  |  |             List<String> signDiseaseList = jdbcTemplate.queryForList(areaSql,String.class);
 | 
	
		
			
				|  |  |             Set<String> stringSet =new HashSet<>(signDiseaseList);
 | 
	
		
			
				|  |  |             List<String> speciaSignDiseaseList = new ArrayList<>();
 | 
	
		
			
				|  |  |             if("0".equals(signStatus) ){
 | 
	
		
			
				|  |  |                 String speciaSignSql = "SELECT wpds.disease FROM wlyy.wlyy_patient_disease_server wpds WHERE wpds.patient='" + patientCode + "'" + " AND wpds.del='1' and wpds.specialist_relation_code='" + specialistPatientRelationDO.getId() + "'";
 | 
	
		
			
				|  |  |                 speciaSignDiseaseList = jdbcTemplate.queryForList(speciaSignSql,String.class);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Set<String> speciaSignSet =new HashSet<>(speciaSignDiseaseList);
 | 
	
		
			
				|  |  |             //已签约的疾病状态改成1
 | 
	
		
			
				|  |  |             stringList.stream().forEach(item->{
 | 
	
		
			
				|  |  |                 int status=0;
 | 
	
		
			
				|  |  |                 if(stringSet.contains( item.get("disease_code"))){
 | 
	
		
			
				|  |  |                     //已签约过的疾病
 | 
	
		
			
				|  |  |                     status=1;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 if(null!=speciaSignSet&& speciaSignSet.contains(item.get("disease_code"))){
 | 
	
		
			
				|  |  |                     //本次专病签约的疾病
 | 
	
		
			
				|  |  |                     status=2;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 item.put("status",status) ;
 | 
	
		
			
				|  |  |             });
 | 
	
		
			
				|  |  |             objectMap.put("teamDisease", stringList);
 | 
	
		
			
				|  |  |             mapList.add(objectMap);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         jsonObject.put("teamAndDoctors", mapList);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //康复情况标签
 | 
	
		
			
				|  |  |         String labelSql = "SELECT wspl.label_code,wspl.label_name from  wlyy.wlyy_sign_patient_label wspl WHERE wspl.label_type='8' AND status='1'";
 | 
	
		
			
				|  |  |         List<Map<String, Object>> signPatientLabelList = jdbcTemplate.queryForList(labelSql);
 | 
	
		
			
				|  |  |         //居民的康复情况
 | 
	
		
			
				|  |  |         String patientLabelSql = "SELECT wspl.label from  wlyy.wlyy_sign_patient_label_info wspl WHERE wspl.patient='"+patientCode+"' and  wspl.label_type='8' AND status='1'";
 | 
	
		
			
				|  |  |         List<String> patientLabelList = jdbcTemplate.queryForList(patientLabelSql,String.class);
 | 
	
		
			
				|  |  |         Set<String> patientLabelSet =new HashSet<>(patientLabelList);
 | 
	
		
			
				|  |  |         signPatientLabelList.stream().forEach(item->{
 | 
	
		
			
				|  |  |             item.put("status",patientLabelSet.contains(item.get("label_code").toString())?1:0) ;
 | 
	
		
			
				|  |  |         });
 | 
	
		
			
				|  |  |         jsonObject.put("signPatientLabels", signPatientLabelList);
 | 
	
		
			
				|  |  |         return jsonObject;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 专科医生发起签约
 | 
	
		
			
				|  |  |      * @param specialistPatientRelationDO
 | 
	
	
		
			
				|  | @ -958,21 +1084,33 @@ public class SpecialistService{
 | 
	
		
			
				|  |  |      * 专科-通过手机号码精确搜索注册居民
 | 
	
		
			
				|  |  |      * @param keywords
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public MixEnvelop searchPatientInSpecialistNew(String keywords,Integer page,Integer pageSize) throws Exception{
 | 
	
		
			
				|  |  |     public MixEnvelop searchPatientInSpecialistNew(String doctorCode,String keywords,Integer page,Integer pageSize) throws Exception{
 | 
	
		
			
				|  |  |         String sql1 = " select count(1) as num ";
 | 
	
		
			
				|  |  |         String sql2 = " select p.name as name,p.idcard,p.code,p.photo ,r.sign_status";
 | 
	
		
			
				|  |  |         String sql2 = " select p.name as name,p.idcard,p.code,p.photo";
 | 
	
		
			
				|  |  |         String whereSql ="";
 | 
	
		
			
				|  |  |         if(!StringUtils.isEmpty(keywords)){
 | 
	
		
			
				|  |  |             whereSql+=" and  p.mobile ='"+keywords+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //根据手机号码精确查找居民
 | 
	
		
			
				|  |  |         String centerSql =" from "+basedb+".wlyy_patient p LEFT JOIN wlyy_specialist.wlyy_specialist_patient_relation r ON p.code=r.patient where  p.openid IS NOT NULL "+whereSql;
 | 
	
		
			
				|  |  |         String centerSql =" from "+basedb+".wlyy_patient p /*LEFT JOIN wlyy_specialist.wlyy_specialist_patient_relation r ON p.code=r.patient */where  p.openid IS NOT NULL "+whereSql;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String signSql ="SELECT r.patient,r.sign_status  FROM  wlyy_specialist.wlyy_specialist_patient_relation r WHERE (r.sign_status = '1' or r.sign_status = '0') " +
 | 
	
		
			
				|  |  |                 " AND doctor in (SELECT m.doctor_code FROM  "+basedb+".wlyy_admin_team_member m where m.team_id in " +
 | 
	
		
			
				|  |  |                 " (SELECT dt.id FROM  "+basedb+".wlyy_admin_team dt LEFT JOIN  "+basedb+".wlyy_admin_team_member watm ON dt.id=watm.team_id " +
 | 
	
		
			
				|  |  |                 " WHERE dt.available='1' AND watm.available='1' AND watm.doctor_code='"+doctorCode+"') AND  m.available='1')";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> map1=jdbcTemplate.queryForList(signSql);
 | 
	
		
			
				|  |  |         String sqlCount=sql1+centerSql;
 | 
	
		
			
				|  |  |         String sql=sql2+centerSql+" LIMIT "+(page-1)*pageSize+","+pageSize;
 | 
	
		
			
				|  |  |         List<Map<String,Object>> map = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         List<Map<String,Object>> countMap = jdbcTemplate.queryForList(sqlCount);
 | 
	
		
			
				|  |  |         //根据居民查找专科签约状态
 | 
	
		
			
				|  |  |         //已签约专科,获取签约信息
 | 
	
		
			
				|  |  |         Map<String,String> patientMap = new HashMap<>();
 | 
	
		
			
				|  |  |         if(null!=map1){
 | 
	
		
			
				|  |  |             map1.stream().forEach(temp->{
 | 
	
		
			
				|  |  |                 patientMap.put(temp.get("patient").toString(),temp.get("sign_status").toString()) ;
 | 
	
		
			
				|  |  |             });
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //未签约,获取居民信息,及专科医生信息
 | 
	
		
			
				|  |  |         List<Map<String,Object>> resultList = new ArrayList<>();
 | 
	
		
			
				|  |  |         Map m = null;
 | 
	
	
		
			
				|  | @ -983,13 +1121,14 @@ public class SpecialistService{
 | 
	
		
			
				|  |  |             m = new HashMap();
 | 
	
		
			
				|  |  |             age = IdCardUtil.getAgeForIdcard(one.get("idcard")+"");
 | 
	
		
			
				|  |  |             sex = IdCardUtil.getSexForIdcard_new(one.get("idcard")+"");
 | 
	
		
			
				|  |  |             String patientCode=null==one.get("code")?"":one.get("code").toString();
 | 
	
		
			
				|  |  |             m.put("name",one.get("name"));
 | 
	
		
			
				|  |  |             m.put("age",age);
 | 
	
		
			
				|  |  |             m.put("sex",sex);
 | 
	
		
			
				|  |  |             //1已签约,0待审核,-1未签约或已取消或已拒绝
 | 
	
		
			
				|  |  |             if(null != one.get("sign_status")&& one.get("sign_status").toString()=="1"){
 | 
	
		
			
				|  |  |             if(patientMap.containsKey(patientCode)&&"1".equals(patientMap.get(patientCode))){
 | 
	
		
			
				|  |  |                 m.put("sign_status", 1);
 | 
	
		
			
				|  |  |             }else if(null != one.get("sign_status")&& one.get("sign_status").toString()=="0"){
 | 
	
		
			
				|  |  |             }else if(patientMap.containsKey(patientCode)&&"0".equals(patientMap.get(patientCode))){
 | 
	
		
			
				|  |  |                 m.put("sign_status", 0);
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 m.put("sign_status", -1);
 | 
	
	
		
			
				|  | @ -1008,4 +1147,21 @@ public class SpecialistService{
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return MixEnvelop.getSuccessListWithPage(SpecialistMapping.api_success,resultList,page,pageSize,countMap.size()>0?Long.valueOf(countMap.get(0).get("num")+""):0);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 根据医生和居民code查询居民与该医生所在团队的待审核专科签约信息
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param patient
 | 
	
		
			
				|  |  |      * @param doctor
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public SpecialistPatientRelationDO selectByDoctorAndPatient(String doctor,String patient){
 | 
	
		
			
				|  |  |         String sql = "select * from wlyy_specialist.wlyy_specialist_patient_relation r where r.doctor in ( " +
 | 
	
		
			
				|  |  |                 " SELECT m.doctor_code  FROM wlyy.wlyy_admin_team_member m " +
 | 
	
		
			
				|  |  |                 " WHERE  m.team_id IN ( SELECT dt.id  FROM  wlyy.wlyy_admin_team dt LEFT JOIN wlyy.wlyy_admin_team_member watm ON dt.id = watm.team_id   WHERE " +
 | 
	
		
			
				|  |  |                 " dt.available = '1' AND watm.available = '1'  AND watm.doctor_code = '"+doctor+"') AND m.available = '1'  ) and r.patient = '"+patient+"' and r.sign_status=0";
 | 
	
		
			
				|  |  |         List<SpecialistPatientRelationDO> relationDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SpecialistPatientRelationDO.class));
 | 
	
		
			
				|  |  |         SpecialistPatientRelationDO specialistPatientRelationDO=null!=relationDOS&&relationDOS.size()>0?relationDOS.get(0):new SpecialistPatientRelationDO();
 | 
	
		
			
				|  |  |         return specialistPatientRelationDO;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |