|
@ -26,6 +26,7 @@ import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.restmodel.web.Envelop;
|
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.ObjEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
|
import com.yihu.jw.rm.specialist.SpecialistMapping;
|
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
@ -96,6 +97,17 @@ public class RehabilitationManageService {
|
|
|
@Autowired
|
|
|
private FollowUpDao followupDao;
|
|
|
|
|
|
//近期康复记录
|
|
|
public Envelop recentServiceItemPlanRecords(String patient,Integer page,Integer size){
|
|
|
String sql = "select p.* ";
|
|
|
String countSql = "select count(p.id) ";
|
|
|
String filter = " from base_service_item_plan p where p.patient='"+patient+"' and p.plan_time<='"+DateUtil.getStringDateShort()+" 23:59:59' ";
|
|
|
String ordereBy = " order by p.plan_time desc limit "+(page-1)*size+","+size;
|
|
|
List<ServiceItemPlanDO> planDOList = jdbcTemplate.query(sql+filter+ordereBy,new BeanPropertyRowMapper<>(ServiceItemPlanDO.class));
|
|
|
long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
|
|
|
return PageEnvelop.getSuccessListWithPage("获取成功",planDOList,page,size,count);
|
|
|
}
|
|
|
|
|
|
//添加康复计划日志
|
|
|
public void addPlanLog(String planId,String doctorCode,String doctorName){
|
|
|
if(StringUtils.isBlank(doctorCode)){
|
|
@ -1348,6 +1360,56 @@ public class RehabilitationManageService {
|
|
|
return detailDOList;
|
|
|
}
|
|
|
|
|
|
//确认完成服务,填写服务笔记
|
|
|
public ServiceItemPlanDO completePlan(String id,String content,String appendixs,String doctor){
|
|
|
ServiceItemPlanDO planDO = serviceItemPlanDao.findById(id).orElse(null);
|
|
|
if(!planDO.getDoctor().equals(doctor)){
|
|
|
throw new ServiceException("不是您的任务,无法完成");
|
|
|
}
|
|
|
if("1".equals(planDO.getStatus())){
|
|
|
throw new ServiceException("请勿重复填写");
|
|
|
}
|
|
|
planDO.setAppendixs(appendixs);
|
|
|
planDO.setContent(content);
|
|
|
planDO = completePlan(planDO);
|
|
|
return planDO;
|
|
|
}
|
|
|
|
|
|
public ServiceItemPlanDO completePlan(ServiceItemPlanDO planDO){
|
|
|
planDO.setStatus("1");
|
|
|
planDO.setCompleteTime(DateUtil.getStringDate());
|
|
|
serviceItemPlanDao.save(planDO);
|
|
|
updPlanStatus(planDO.getPlanId(),planDO.getPlanDetailId());
|
|
|
return planDO;
|
|
|
}
|
|
|
|
|
|
//完成随访
|
|
|
public ServiceItemPlanDO completePlanFollowup(Long followupId){
|
|
|
ServiceItemPlanDO serviceItemPlanDO = serviceItemPlanDao.findByRelationCodeAndRelationType(followupId+"","6");
|
|
|
if(serviceItemPlanDO!=null&&"0".equals(serviceItemPlanDO.getStatus())){
|
|
|
serviceItemPlanDO = completePlan(serviceItemPlanDO);
|
|
|
}
|
|
|
return serviceItemPlanDO;
|
|
|
}
|
|
|
|
|
|
|
|
|
//康复计划状态更新
|
|
|
public void updPlanStatus(String planId,String planDetailId){
|
|
|
List<ServiceItemPlanDO> itemPlanDOS = serviceItemPlanDao.findByPlanDetailId(planDetailId,"0");
|
|
|
if(itemPlanDOS.size()>0){
|
|
|
//服务项计划都完成了
|
|
|
jdbcTemplate.update("update wlyy_rehabilitation_plan_detail set status=1 where id='"+planDetailId+"'");
|
|
|
String sql = "SELECT COUNT(*) total,COUNT(if(`status`=1,1,null)) num from wlyy_rehabilitation_plan_detail " +
|
|
|
"WHERE plan_id='"+planId+"'";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
String total = list.get(0).get("total")+"";
|
|
|
String num = list.get(0).get("num")+"";
|
|
|
if(total.equals(num)){
|
|
|
jdbcTemplate.update("update wlyy_patient_rehabilitation_plan set status=2 where id='"+planId+"'");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//执行计划详情
|
|
|
public ServiceItemPlanDO findServiceItemPlanDetail(String id){
|
|
|
ServiceItemPlanDO planDO = serviceItemPlanDao.findById(id).orElse(null);
|
|
@ -1388,7 +1450,16 @@ public class RehabilitationManageService {
|
|
|
@Transactional
|
|
|
public Envelop saveGuidanceMessage(String messageId, String doctor, Integer doctorType, String content,String imgs,
|
|
|
String planDetailId, Integer contentType) {
|
|
|
GuidanceMessageLogDO guidanceMessageLogDO = new GuidanceMessageLogDO();
|
|
|
GuidanceMessageLogDO guidanceMessageLogDO = null;
|
|
|
List<GuidanceMessageLogDO> logDOS = guidanceMessageLogDao.findByPlanDetailId(planDetailId);
|
|
|
if(logDOS.size()>0){
|
|
|
guidanceMessageLogDO = logDOS.get(0);
|
|
|
guidanceMessageLogDO.setUpdateTime(new Date());
|
|
|
}else {
|
|
|
guidanceMessageLogDO = new GuidanceMessageLogDO();
|
|
|
guidanceMessageLogDO.setCreateTime(new Date());
|
|
|
guidanceMessageLogDO.setUpdateTime(new Date());
|
|
|
}
|
|
|
guidanceMessageLogDO.setMessageId(messageId);
|
|
|
guidanceMessageLogDO.setPlanDetailId(planDetailId);
|
|
|
guidanceMessageLogDO.setContent(content);
|
|
@ -1400,8 +1471,6 @@ public class RehabilitationManageService {
|
|
|
// guidanceMessageLogDO.setAdminTeamCode(adminTeamCode);
|
|
|
// guidanceMessageLogDO.setAdminTeamName(adminTeamName);
|
|
|
guidanceMessageLogDO.setDoctorName(doctorDO.getName());
|
|
|
guidanceMessageLogDO.setCreateTime(new Date());
|
|
|
guidanceMessageLogDO.setUpdateTime(new Date());
|
|
|
guidanceMessageLogDO = guidanceMessageLogDao.save(guidanceMessageLogDO);
|
|
|
return ObjEnvelop.getSuccess(SpecialistMapping.api_success,guidanceMessageLogDO);
|
|
|
}
|