|  | @ -75,14 +75,17 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
 | 
												
													
														
															|  |     private PatientBedApplyDao patientBedApplyDao;
 |  |     private PatientBedApplyDao patientBedApplyDao;
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private BaseDoctorHospitalDao baseDoctorHospitalDao;
 |  |     private BaseDoctorHospitalDao baseDoctorHospitalDao;
 | 
												
													
														
															|  | 
 |  |     @Autowired
 | 
												
													
														
															|  | 
 |  |     private CapacityDoctorDao capacityDoctorDao;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     /**
 |  |     /**
 | 
												
													
														
															|  |      * 按id查找评估明细
 |  |      * 按id查找评估明细
 | 
												
													
														
															|  |      * @param patient
 |  |      * @param patient
 | 
												
													
														
															|  |      * @return
 |  |      * @return
 | 
												
													
														
															|  |      */
 |  |      */
 | 
												
													
														
															|  |     public CapacityAssessmentRecordDO findAssessmentByPatientId(String patient)  {
 |  | 
 | 
												
													
														
															|  |         CapacityAssessmentRecordDO recordDO = capacityAssessmentRecordDao.findByPatient(patient);
 |  | 
 | 
												
													
														
															|  | 
 |  |     public CapacityAssessmentRecordDO findAssessmentByPatientId(String patient) throws Exception {
 | 
												
													
														
															|  | 
 |  |         Date assessmentTime =  DateUtil.dateTimeParse(DateUtil.getNowYear() + "-01-01 00:00:00");
 | 
												
													
														
															|  | 
 |  |         CapacityAssessmentRecordDO recordDO = capacityAssessmentRecordDao.findByPatient(patient,assessmentTime);
 | 
												
													
														
															|  |         recordDO.setLevelConclusionName(dictService.fingByNameAndCode(ConstantUtil.DICT_LEVEL_CONCLUSION,String.valueOf(recordDO.getLevelConclusion())));
 |  |         recordDO.setLevelConclusionName(dictService.fingByNameAndCode(ConstantUtil.DICT_LEVEL_CONCLUSION,String.valueOf(recordDO.getLevelConclusion())));
 | 
												
													
														
															|  |         return recordDO;
 |  |         return recordDO;
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
											
												
													
														
															|  | @ -152,11 +155,11 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
 | 
												
													
														
															|  |                 "c.`status`,c.level_conclusion levelConclusion,c.org_code orgCode,c.org_name orgName,p.name,p.mobile,p.sex,p.idcard  ";
 |  |                 "c.`status`,c.level_conclusion levelConclusion,c.org_code orgCode,c.org_name orgName,p.name,p.mobile,p.sex,p.idcard  ";
 | 
												
													
														
															|  |         String countSql = "SELECT count(*) ";
 |  |         String countSql = "SELECT count(*) ";
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         String filters = "from base_capacity_assessment_record c,base_patient p " +
 |  | 
 | 
												
													
														
															|  | 
 |  |         String filters = "from base_capacity_assessment_record c left join base_capacity_doctor d on c.id =d.capacity_id ,base_patient p " +
 | 
												
													
														
															|  |                 "WHERE  c.patient = p.id  and c.assessment_time>='" + DateUtil.getNowYear() + "-01-01'";
 |  |                 "WHERE  c.patient = p.id  and c.assessment_time>='" + DateUtil.getNowYear() + "-01-01'";
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         if(StringUtils.isNoneBlank(doctorId)){
 |  |         if(StringUtils.isNoneBlank(doctorId)){
 | 
												
													
														
															|  |             filters += " and c.doctor = '"+doctorId+"' ";
 |  | 
 | 
												
													
														
															|  | 
 |  |             filters += " and (c.doctor = '"+doctorId+"' or d.doctor_id = '"+doctorId+"')";
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         if(status!=null){
 |  |         if(status!=null){
 | 
												
													
														
															|  |             filters += " and c.status = "+status;
 |  |             filters += " and c.status = "+status;
 | 
												
											
												
													
														
															|  | @ -271,6 +274,30 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
 | 
												
													
														
															|  |         return result;
 |  |         return result;
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     /**
 | 
												
													
														
															|  | 
 |  |      * 同步能力评估
 | 
												
													
														
															|  | 
 |  |      * @param patient
 | 
												
													
														
															|  | 
 |  |      * @param doctorId
 | 
												
													
														
															|  | 
 |  |      * @throws Exception
 | 
												
													
														
															|  | 
 |  |      */
 | 
												
													
														
															|  | 
 |  |     public void synCapacityRecord(String patient,String doctorId) throws Exception{
 | 
												
													
														
															|  | 
 |  |         Date assessmentTime =  DateUtil.dateTimeParse(DateUtil.getNowYear() + "-01-01 00:00:00");
 | 
												
													
														
															|  | 
 |  |         CapacityAssessmentRecordDO recordDO = capacityAssessmentRecordDao.findByPatient(patient,assessmentTime);
 | 
												
													
														
															|  | 
 |  |         if(recordDO == null){
 | 
												
													
														
															|  | 
 |  |             throw new Exception("居民不存在有效的能力评估报告");
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if(doctorId.equals(recordDO.getDoctor())){
 | 
												
													
														
															|  | 
 |  |            return;
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         CapacityDoctorDO capacityDoctorDO = capacityDoctorDao.findByCapacityIdAndDoctorId(recordDO.getId(),doctorId);
 | 
												
													
														
															|  | 
 |  |         if(capacityDoctorDO == null){
 | 
												
													
														
															|  | 
 |  |             capacityDoctorDO = new CapacityDoctorDO();
 | 
												
													
														
															|  | 
 |  |             capacityDoctorDO.setCapacityId(recordDO.getId());
 | 
												
													
														
															|  | 
 |  |             capacityDoctorDO.setDoctorId(doctorId);
 | 
												
													
														
															|  | 
 |  |             capacityDoctorDao.save(capacityDoctorDO);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     /**
 |  |     /**
 | 
												
													
														
															|  |      * 通过患者id 生成当年评估报告
 |  |      * 通过患者id 生成当年评估报告
 | 
												
													
														
															|  |      * @param patient
 |  |      * @param patient
 |