| 
					
				 | 
			
			
				@ -15,6 +15,7 @@ import com.yihu.jw.hospital.module.rehabilitation.vo.TemplateDetailVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.module.specialist.service.SpecialistHospitalServiceItemService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.module.specialist.service.SpecialistService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.mysql.query.BaseJpaService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.rehabilitation.PatientMedicalRecordsDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.qvo.ParamQvo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.specialist.PatientSignInfoVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.Envelop; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -84,6 +85,12 @@ public class RehabilitationPlanService extends BaseJpaService<RehabilitationPlan 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private RehabilitationServiceItemDao serviceItemDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    TemplateJsonDao templateJsonDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private RehabilitationManageService rehabilitationManageService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private RehabilitationPatientInfoDao rehabilitationPatientInfoDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PatientMedicalRecordsDao patientMedicalRecordsDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 没有默认创建服务项 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -235,32 +242,55 @@ public class RehabilitationPlanService extends BaseJpaService<RehabilitationPlan 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return ListEnvelop.getSuccess(SpecialistMapping.api_success, resultList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PatientRehabilitationPlanDO createPatientRehabilitationPlan(PatientRehabilitationPlanDO planDO) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    //创建康复计划 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PatientRehabilitationPlanDO createPatientRehabilitationPlan(PatientRehabilitationPlanDO planDO,List<RehabilitationDetailDO> details) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String patientInfoCode = planDO.getPatientInfoCode(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        planDO.setStatus(3);//待分配 执行医生和科室 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        planDO.setTitle(planDO.getName()+"的康复计划"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        planDO.setHealthStatusCode("2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        planDO.setPlanType(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        planDO.setPayment(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        planDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        planDO.setStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        planDO.setUpdateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //判断是否签约,如果签约 新增家签团队id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String sql = "SELECT a.admin_team_code  from wlyy.wlyy_sign_family a WHERE patient = '" + planDO.getPatient() + "' and `status`>0 and expenses_status =1 order by id desc limit 1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (list != null && list.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                planDO.setAdminTeamCode(Long.valueOf(list.get(0).get("admin_team_code") + "")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return patientRehabilitationPlanDao.save(planDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        planDO = patientRehabilitationPlanDao.save(planDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<RehabilitationDetailDO> detailDOList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (RehabilitationDetailDO detailDO:details){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            RehabilitationTemplateDetailDO templateDetailDO = templateDetailDao.findById(detailDO.getId()).orElse(null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String frequency_code = templateDetailDO.getFrequencyCode();//频次 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            RehabilitationDetailDO detail = new RehabilitationDetailDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            detail.setHospitalServiceItemId(templateDetailDO.getHospitalServiceItemId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            detail.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            detail.setStatus(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            detail.setType(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            detail.setUpdateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            detail.setPlanId(planDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            detail.setFrequencyCode(frequency_code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            detailDOList.add(detail); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rehabilitationDetailDao.saveAll(detailDOList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rehabilitationManageService.addPlanLog(planDO.getId(),planDO.getPlanDoctor(),planDO.getPlanDoctorName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(patientInfoCode)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            RehabilitationPatientInfoDO infoDO = rehabilitationPatientInfoDao.findByCode(patientInfoCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(StringUtils.isBlank(infoDO.getDiagnosis())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                PatientMedicalRecordsDO recordsDO = patientMedicalRecordsDao.findByCode(planDO.getMedicalRecordsCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                infoDO.setDept(recordsDO.getDept()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                infoDO.setDeptName(recordsDO.getDeptName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                infoDO.setDiagnosis(recordsDO.getAdmittingDiagnosis()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                infoDO.setDiagnosisName(recordsDO.getAdmittingDiagnosisName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            infoDO.setStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            infoDO.setDoctor(planDO.getPlanDoctor()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            infoDO.setDoctorName(planDO.getPlanDoctorName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            infoDO.setReceiveTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            rehabilitationPatientInfoDao.save(infoDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        planDO.setDetailDOList(detailDOList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return planDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<RehabilitationDetailDO> createRehabilitationDetail(List<RehabilitationDetailDO> details, String planId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (RehabilitationDetailDO detail : details) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            /*List<String> list = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            list.add(detail.getHospitalServiceItemId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            HospitalServiceItemDO hospitalServiceItemDO = hospitalServiceItemService.selectById(list).getDetailModelList().get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            detail.setHospital(hospitalServiceItemDO.getHospital()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            detail.setHospitalName(hospitalServiceItemDO.getHospitalName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            detail.setExpense(hospitalServiceItemDO.getExpense());*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            detail.setPlanId(planId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            detail.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            detail.setStatus(0); 
			 |