|
@ -2,15 +2,28 @@ package com.yihu.wlyy.service.app.followup;
|
|
|
|
|
|
import javax.transaction.Transactional;
|
|
import javax.transaction.Transactional;
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
import com.yihu.wlyy.entity.dict.SystemDict;
|
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
|
import com.yihu.wlyy.entity.followup.Followup;
|
|
|
|
import com.yihu.wlyy.entity.followup.FollowupContent;
|
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
|
import com.yihu.wlyy.repository.dict.SystemDictDao;
|
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
|
|
import com.yihu.wlyy.repository.followup.FollowupContentDao;
|
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
|
import org.springframework.data.domain.Sort;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import com.yihu.wlyy.repository.followup.FollowupDao;
|
|
import com.yihu.wlyy.repository.followup.FollowupDao;
|
|
import com.yihu.wlyy.service.BaseService;
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 随访服务
|
|
* 随访服务
|
|
@ -22,16 +35,35 @@ import java.util.Map;
|
|
public class FollowUpService extends BaseService {
|
|
public class FollowUpService extends BaseService {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private FollowupDao followUpPlanDao;
|
|
|
|
|
|
private DoctorDao doctorDao;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private PatientDao patientDao;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private FollowupDao followupDao;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private FollowupContentDao followupContentDao;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private SystemDictDao systemDictDao;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private ObjectMapper objectMapper;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取医生随访列表
|
|
* 获取医生随访列表
|
|
*/
|
|
*/
|
|
public List<Map<String,String>> getListByDoctor(String doctorCode,String startTime,String endTime,String page,String pageSize) throws Exception
|
|
|
|
|
|
public List<Followup> getListByDoctor(String doctorCode,String startTime,String endTime,String page,String pageSize) throws Exception
|
|
{
|
|
{
|
|
List<Map<String,String>> re = new ArrayList<>();
|
|
|
|
|
|
|
|
return re;
|
|
|
|
|
|
// 排序
|
|
|
|
Sort sort = new Sort(Sort.Direction.ASC, "followupDate");
|
|
|
|
// 分页信息
|
|
|
|
int pageInt = Integer.valueOf(page)-1;
|
|
|
|
int pageSizeInt = Integer.valueOf(pageSize);
|
|
|
|
Pageable pageRequest = new PageRequest(pageInt, pageSizeInt, sort);
|
|
|
|
return followupDao.findByDoctor(doctorCode,DateUtil.strToDate(startTime),DateUtil.strToDate(endTime),pageRequest);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@ -39,13 +71,54 @@ public class FollowUpService extends BaseService {
|
|
*/
|
|
*/
|
|
public void addFollowupPlan(String doctorCode,String patientCode,String date) throws Exception {
|
|
public void addFollowupPlan(String doctorCode,String patientCode,String date) throws Exception {
|
|
|
|
|
|
|
|
//获取医生信息
|
|
|
|
Doctor doctor = doctorDao.findByCode(doctorCode);
|
|
|
|
if(doctor==null)
|
|
|
|
{
|
|
|
|
throw new Exception("not exit doctor:"+doctorCode+".\r\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取患者信息
|
|
|
|
Patient patient = patientDao.findByCode(patientCode);
|
|
|
|
if(patient==null)
|
|
|
|
{
|
|
|
|
throw new Exception("not exit patient:"+patientCode+".\r\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
Followup followup = new Followup();
|
|
|
|
followup.setFollowupDate(DateUtil.strToDate(date));
|
|
|
|
followup.setDoctorCode(doctorCode);
|
|
|
|
followup.setDoctorName(doctor.getName());
|
|
|
|
followup.setOrgCode(doctor.getHospital());
|
|
|
|
followup.setOrgName(doctor.getHospitalName());
|
|
|
|
followup.setPatientCode(patientCode);
|
|
|
|
followup.setPatientName(patient.getName());
|
|
|
|
followup.setIdcard(patient.getIdcard());
|
|
|
|
followup.setDataFrom("2");//数据来源 1基卫 2APP
|
|
|
|
followup.setStatus("2"); //状态 0取消 1已完成 2未开始 3进行中
|
|
|
|
followup.setCreateTime(new Date());
|
|
|
|
|
|
|
|
followupDao.save(followup);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
*开始随访记录
|
|
*开始随访记录
|
|
*/
|
|
*/
|
|
public void startFollowup(String id,String date,String followupType,String followupClass,String followupManagerStatus) throws Exception {
|
|
public void startFollowup(String id,String date,String followupType,String followupClass,String followupManagerStatus) throws Exception {
|
|
|
|
|
|
|
|
Followup followup = followupDao.findOne(Long.valueOf(id));
|
|
|
|
if(followup!=null)
|
|
|
|
{
|
|
|
|
followup.setFollowupDate(DateUtil.strToDate(date));
|
|
|
|
followup.setFollowupType(followupType);
|
|
|
|
followup.setFollowupClass(followupClass);
|
|
|
|
followup.setFollowupManagerStatus(followupManagerStatus);
|
|
|
|
followup.setStatus("3"); //状态 0取消 1已完成 2未开始 3进行中
|
|
|
|
|
|
|
|
followupDao.save(followup);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
throw new Exception("not exit follow:"+id+".\r\n");
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@ -53,6 +126,39 @@ public class FollowUpService extends BaseService {
|
|
*/
|
|
*/
|
|
public String addFollowup(String doctorCode,String patientCode,String date,String followupType,String followupClass,String followupManagerStatus) throws Exception {
|
|
public String addFollowup(String doctorCode,String patientCode,String date,String followupType,String followupClass,String followupManagerStatus) throws Exception {
|
|
String re ="";
|
|
String re ="";
|
|
|
|
|
|
|
|
//获取医生信息
|
|
|
|
Doctor doctor = doctorDao.findByCode(doctorCode);
|
|
|
|
if(doctor==null)
|
|
|
|
{
|
|
|
|
throw new Exception("not exit doctor:"+doctorCode+".\r\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取患者信息
|
|
|
|
Patient patient = patientDao.findByCode(patientCode);
|
|
|
|
if(patient==null)
|
|
|
|
{
|
|
|
|
throw new Exception("not exit patient:"+patientCode+".\r\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
Followup followup = new Followup();
|
|
|
|
followup.setFollowupDate(DateUtil.strToDate(date));
|
|
|
|
followup.setDoctorCode(doctorCode);
|
|
|
|
followup.setDoctorName(doctor.getName());
|
|
|
|
followup.setOrgCode(doctor.getHospital());
|
|
|
|
followup.setOrgName(doctor.getHospitalName());
|
|
|
|
followup.setPatientCode(patientCode);
|
|
|
|
followup.setPatientName(patient.getName());
|
|
|
|
followup.setIdcard(patient.getIdcard());
|
|
|
|
followup.setFollowupType(followupType);
|
|
|
|
followup.setFollowupClass(followupClass);
|
|
|
|
followup.setFollowupManagerStatus(followupManagerStatus);
|
|
|
|
followup.setDataFrom("2");//数据来源 1基卫 2APP
|
|
|
|
followup.setStatus("3"); //状态 0取消 1已完成 2未开始 3进行中
|
|
|
|
followup.setCreateTime(new Date());
|
|
|
|
|
|
|
|
followupDao.save(followup);
|
|
|
|
re = String.valueOf(followup.getId());
|
|
return re;
|
|
return re;
|
|
}
|
|
}
|
|
|
|
|
|
@ -60,7 +166,15 @@ public class FollowUpService extends BaseService {
|
|
*取消随访计划
|
|
*取消随访计划
|
|
*/
|
|
*/
|
|
public void cancelFollowupPlan(String id) throws Exception {
|
|
public void cancelFollowupPlan(String id) throws Exception {
|
|
|
|
|
|
|
|
Followup followup = followupDao.findOne(Long.valueOf(id));
|
|
|
|
if(followup!=null)
|
|
|
|
{
|
|
|
|
followup.setStatus("0"); //状态 0取消 1已完成 2未开始 3进行中
|
|
|
|
followupDao.save(followup);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
throw new Exception("not exit follow:"+id+".\r\n");
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -71,43 +185,75 @@ public class FollowUpService extends BaseService {
|
|
public List<Map<String,String>> getFollowupProject(String id) throws Exception
|
|
public List<Map<String,String>> getFollowupProject(String id) throws Exception
|
|
{
|
|
{
|
|
List<Map<String,String>> re = new ArrayList<>();
|
|
List<Map<String,String>> re = new ArrayList<>();
|
|
|
|
|
|
|
|
//获取已填写的面访项目
|
|
|
|
List<String> project = followupContentDao.findProjectByFollowupId(Long.valueOf(id));
|
|
|
|
//获取所有面访项目
|
|
|
|
List<SystemDict> dictList = systemDictDao.findByDictName("FOLLOWUP_PROJECT");
|
|
|
|
if (dictList!=null && dictList.size()>0)
|
|
|
|
{
|
|
|
|
for(SystemDict dict:dictList)
|
|
|
|
{
|
|
|
|
Map<String,String> map = new HashMap<>();
|
|
|
|
String code = dict.getCode();
|
|
|
|
map.put("projectCode",code);
|
|
|
|
map.put("projectName",dict.getValue());
|
|
|
|
if(project!=null && project.contains(code))
|
|
|
|
{
|
|
|
|
map.put("status","1"); //已填写
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
map.put("status","0");//未填写
|
|
|
|
}
|
|
|
|
re.add(map);
|
|
|
|
}
|
|
|
|
}
|
|
return re;
|
|
return re;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取面访项目数据
|
|
* 获取面访项目数据
|
|
*/
|
|
*/
|
|
public List<Map<String,String>> getFollowupProjectData(String id,String followupProject) throws Exception
|
|
|
|
|
|
public Map<String,String> getFollowupProjectData(String id,String followupProject) throws Exception
|
|
{
|
|
{
|
|
List<Map<String,String>> re = new ArrayList<>();
|
|
|
|
|
|
|
|
return re;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取面访用药数据
|
|
|
|
*/
|
|
|
|
public List<Map<String,String>> getFollowupDrugs(String id) throws Exception
|
|
|
|
{
|
|
|
|
List<Map<String,String>> re = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
Map<String,String> re = new HashMap<>();
|
|
|
|
List<FollowupContent> dataList = followupContentDao.findByFollowupIdAndFollowupProject(Long.valueOf(id),followupProject);
|
|
|
|
for(FollowupContent item:dataList)
|
|
|
|
{
|
|
|
|
re.put(item.getFollowupKey(),item.getFollowupValue());
|
|
|
|
}
|
|
return re;
|
|
return re;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
*保存面访项目数据
|
|
*保存面访项目数据
|
|
*/
|
|
*/
|
|
|
|
@Transactional
|
|
public void saveFollowupProjectData(String id,String followupProject,String followupProjectData) throws Exception {
|
|
public void saveFollowupProjectData(String id,String followupProject,String followupProjectData) throws Exception {
|
|
|
|
|
|
|
|
List<FollowupContent> dataList = followupContentDao.findByFollowupIdAndFollowupProject(Long.valueOf(id),followupProject);
|
|
|
|
|
|
|
|
//删除原有记录
|
|
|
|
followupContentDao.delete(dataList);
|
|
|
|
|
|
|
|
Map<String,String> data = objectMapper.readValue(followupProjectData,Map.class);
|
|
|
|
|
|
|
|
if(data!=null && data.keySet().size()>0)
|
|
|
|
{
|
|
|
|
List<FollowupContent> newList = new ArrayList<>();
|
|
|
|
for (String key : data.keySet()) {
|
|
|
|
FollowupContent item = new FollowupContent();
|
|
|
|
item.setFollowupId(Long.valueOf(id));
|
|
|
|
item.setFollowupProject(followupProject);
|
|
|
|
item.setFollowupKey(key);
|
|
|
|
item.setFollowupValue(data.get(key));
|
|
|
|
item.setCreateTime(new Date());
|
|
|
|
newList.add(item);
|
|
|
|
}
|
|
|
|
followupContentDao.save(newList);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
*保存面访用药数据
|
|
|
|
*/
|
|
|
|
public void saveFollowupDrugs(String id,String followupProjectData,String drugsData) throws Exception {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************** 电话随访 *****************************************************************/
|
|
/*********************************** 电话随访 *****************************************************************/
|
|
/**
|
|
/**
|
|
@ -115,7 +261,14 @@ public class FollowUpService extends BaseService {
|
|
*/
|
|
*/
|
|
public String getFollowupPhone(String id) throws Exception {
|
|
public String getFollowupPhone(String id) throws Exception {
|
|
String re = "";
|
|
String re = "";
|
|
|
|
|
|
|
|
Followup followup = followupDao.findOne(Long.valueOf(id));
|
|
|
|
if(followup!=null)
|
|
|
|
{
|
|
|
|
re = followup.getFollowupContentPhone();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
throw new Exception("not exit followup:"+id+".\r\n");
|
|
|
|
}
|
|
return re;
|
|
return re;
|
|
}
|
|
}
|
|
|
|
|
|
@ -123,9 +276,16 @@ public class FollowUpService extends BaseService {
|
|
*记录电话随访内容
|
|
*记录电话随访内容
|
|
*/
|
|
*/
|
|
public void saveFollowupPhone(String id,String content) throws Exception {
|
|
public void saveFollowupPhone(String id,String content) throws Exception {
|
|
|
|
|
|
|
|
Followup followup = followupDao.findOne(Long.valueOf(id));
|
|
|
|
if(followup!=null)
|
|
|
|
{
|
|
|
|
followup.setFollowupContentPhone(content);
|
|
|
|
followupDao.save(followup);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
throw new Exception("not exit followup:"+id+".\r\n");
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|