瀏覽代碼

随访开发

hzp 8 年之前
父節點
當前提交
7e01cdd4a9

+ 193 - 33
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java

@ -2,15 +2,28 @@ package com.yihu.wlyy.service.app.followup;
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.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 com.yihu.wlyy.repository.followup.FollowupDao;
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 {
	@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 {
		//获取医生信息
		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 {
		 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 {
		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;
	}
@ -60,7 +166,15 @@ public class FollowUpService extends BaseService {
	 *取消随访计划
	 */
	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
	{
		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;
	}
	/**
	 * 获取面访项目数据
	 */
	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;
	}
	/**
	 *保存面访项目数据
	 */
	@Transactional
	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 {
		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;
	}
@ -123,9 +276,16 @@ public class FollowUpService extends BaseService {
	 *记录电话随访内容
	 */
	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");
		}
	}
}

+ 24 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwArchivesService.java

@ -116,4 +116,28 @@ public class JwArchivesService {
            throw new Exception("返回结果为空!");
        }
    }
    /**
     * 上传随访记录接口
     */
    public void uploadFollowup(String id) throws Exception
    {
        String url = jwUrl + "/third/archives/uploadFollowup";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("id", id));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if(!StringUtils.isEmpty(response))
        {
            JSONObject json = new JSONObject(response);
            if (!"200".equals(json.optString("status"))) {
                throw new Exception(json.optString("msg"));
            }
        }
        else{
            throw new Exception("返回结果为空!");
        }
    }
}

+ 21 - 14
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java

@ -3,10 +3,13 @@ package com.yihu.wlyy.web.doctor.followup;
import java.util.*;
import com.yihu.wlyy.entity.followup.Followup;
import com.yihu.wlyy.service.app.followup.FollowupService;
import com.yihu.wlyy.service.app.followup.FollowUpService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
@ -15,6 +18,10 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
/**
@ -26,10 +33,10 @@ import com.yihu.wlyy.web.BaseController;
@Controller
@RequestMapping(value = "/doctor/followup", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-随访接口")
public class DoctorFollowupController extends BaseController {
public class DoctorFollowUpController extends BaseController {
	@Autowired
	private FollowupService followUpService;
	private FollowUpService followUpService;
	/*************************************** 随访计划 ****************************************************************************/
	@ApiOperation("获取随访列表")
@ -44,11 +51,11 @@ public class DoctorFollowupController extends BaseController {
							  @ApiParam(name="pageSize",value="每页几行",defaultValue = "10")
							  @RequestParam(value="pageSize",required = true) String pageSize) {
		try {
			List<Followup> result = followUpService.getListByDoctor(getUID(),startTime,endTime,page,pageSize);
			List<Followup> result = followUpService.getListByDoctor(getUID(),startTime,endTime,page,pageSize);     //"64de9952-5b15-11e6-8344-fa163e8aee56"
			return write(200, "获取随访列表成功!", "data", result);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取随访列表失败!");
			return invalidUserException(e, -1, "获取随访列表失败!"+e.getMessage());
		}
	}
@ -64,7 +71,7 @@ public class DoctorFollowupController extends BaseController {
			return write(200, "新增随访计划成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "新增随访计划失败!");
			return invalidUserException(e, -1, "新增随访计划失败!"+e.getMessage());
		}
	}
@ -87,7 +94,7 @@ public class DoctorFollowupController extends BaseController {
			return write(200, "开始随访记录成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "开始随访记录失败!");
			return invalidUserException(e, -1, "开始随访记录失败!"+e.getMessage());
		}
	}
@ -109,7 +116,7 @@ public class DoctorFollowupController extends BaseController {
			return write(200, "新增临时随访记录成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "新增临时随访记录失败!");
			return invalidUserException(e, -1, "新增临时随访记录失败!"+e.getMessage());
		}
	}
@ -124,7 +131,7 @@ public class DoctorFollowupController extends BaseController {
			return write(200, "取消随访计划成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "取消随访计划失败!");
			return invalidUserException(e, -1, "取消随访计划失败!"+e.getMessage());
		}
	}
@ -140,7 +147,7 @@ public class DoctorFollowupController extends BaseController {
			return write(200, "获取面访项目列表成功!","data",list);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取面访项目列表失败!");
			return invalidUserException(e, -1, "获取面访项目列表失败!"+e.getMessage());
		}
	}
@ -157,7 +164,7 @@ public class DoctorFollowupController extends BaseController {
			return write(200, "获取面访项目数据成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取面访项目数据失败!");
			return invalidUserException(e, -1, "获取面访项目数据失败!"+e.getMessage());
		}
	}
@ -177,7 +184,7 @@ public class DoctorFollowupController extends BaseController {
			return write(200, "保存面访项目数据成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "保存面访项目数据失败!");
			return invalidUserException(e, -1, "保存面访项目数据失败!"+e.getMessage());
		}
	}
@ -193,7 +200,7 @@ public class DoctorFollowupController extends BaseController {
			return write(200, "获取电话随访内容成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取电话随访内容失败!");
			return invalidUserException(e, -1, "获取电话随访内容失败!"+e.getMessage());
		}
	}
@ -209,7 +216,7 @@ public class DoctorFollowupController extends BaseController {
			return write(200, "记录电话随访内容成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "记录电话随访内容失败!");
			return invalidUserException(e, -1, "记录电话随访内容失败!"+e.getMessage());
		}
	}

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowupDrugsController.java

@ -1,6 +1,9 @@
package com.yihu.wlyy.web.doctor.followup;
import com.yihu.wlyy.entity.dict.DmDrugsGroupItem;
import com.yihu.wlyy.entity.followup.Followup;
import com.yihu.wlyy.entity.followup.FollowupDrugs;
import com.yihu.wlyy.service.app.followup.FollowUpService;
import com.yihu.wlyy.service.app.followup.FollowupDrugsService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;