浏览代码

Merge branch 'dev' of huangzhanpeng/wlyy_management into dev

lyr 8 年之前
父节点
当前提交
54c9fa2e81

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/health/repository/DevicePatientHealthIndexDao.java

@ -53,6 +53,9 @@ public interface DevicePatientHealthIndexDao
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate >= ?3 and a.recordDate <= ?4 and a.del = '1'")
	Page<DevicePatientHealthIndex> findIndexByPatient(String patient, int type, Date start, Date end, Pageable pageRequest);
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.del = '1'")
	List<DevicePatientHealthIndex> findIndexByPatient(String patient, int type, Pageable pageRequest);
	@Query("SELECT a FROM DevicePatientHealthIndex a where a.user = ?1 order by a.recordDate desc ")
	Iterable<DevicePatientHealthIndex> findRecentByPatient(String patient);

+ 2 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpDao.java

@ -24,6 +24,6 @@ public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>,
    @Query("select a from Followup a where a.creater = ?1 and a.followupDate between ?2 and ?3 and a.status <> '0'")
    List<Followup> findByCreater(String creater, Date begin, Date end, Pageable pageRequest) throws Exception;
    @Query(value = "select a.* from wlyy_followup a where a.doctor_code = ?1 and a.patient_code = ?2 and a.status ='1' order by a.followup_date DESC limit 1",nativeQuery = true)
    Followup findLastFollowup(String doctorCode,String patientCode) throws Exception;
    @Query(value = "select a.* from wlyy_followup a where a.doctor_code in ?1 and a.patient_code = ?2 and a.followup_class=?3 and a.status ='1' order by a.followup_date DESC limit 1",nativeQuery = true)
    Followup findLastFollowup(String[] doctors,String patientCode,String followClass) throws Exception;
}

+ 2 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowupContentDao.java

@ -18,4 +18,6 @@ public interface FollowupContentDao extends PagingAndSortingRepository<FollowupC
    List<String> findProjectByFollowupId(Long followupId) throws Exception;
    List<FollowupContent> findByFollowupIdAndFollowupProject(Long followupId,String followupProject);
    List<FollowupContent> findByFollowupId(Long followupId);
}

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

@ -9,10 +9,13 @@ 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.entity.patient.SignFamily;
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.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.team.DrHealthTeamService;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.task.FollowupUploadTask;
import com.yihu.wlyy.util.DateUtil;
@ -55,6 +58,12 @@ public class FollowUpService extends BaseService {
	@Autowired
	private ObjectMapper objectMapper;
	@Autowired
	private SignFamilyDao signFamilyDao;
	@Autowired
	private DrHealthTeamService drHealthTeamService;
	/**
	 * 转译随访信息
     */
@ -400,26 +409,6 @@ public class FollowUpService extends BaseService {
	}
	/**
	 * 获取上次随访项目数据
	 */
	public Map<String,String> getLastFollowupProjectData(String doctor,String patient,String followupProject) throws Exception
	{
		Map<String,String> re = new HashMap<>();
		Followup lastFollowup = followupDao.findLastFollowup(doctor,patient);
		if(lastFollowup!=null)
		{
			List<FollowupContent> dataList =  followupContentDao.findByFollowupIdAndFollowupProject(lastFollowup.getId(),followupProject);
			for(FollowupContent item:dataList)
			{
				re.put(item.getFollowupKey(),item.getFollowupValue());
			}
		}
		return re;
	}
	/**
	 *保存面访项目数据
	 */
@ -484,4 +473,90 @@ public class FollowUpService extends BaseService {
	}
	/*************************************** 上次随访 ********************************************/
	/**
	 * 获取团队医生
     */
	private List<Doctor>  getTeamDoctors(String doctor,String patient) throws Exception
	{
		List<Doctor> doctors = new ArrayList<>();
		//获取医生团队成员
		SignFamily signFamily = signFamilyDao.findByFamilyDoctorAndPatient(doctor, patient);
		// 查询家庭医生团队
		if (signFamily != null) {
			doctors = drHealthTeamService.findTeamDoctors(signFamily.getTeamCode());
		}
		// 查询三师团队医生
		if (doctors == null || doctors.size() == 0) {
			SignFamily sanshiSign = signFamilyDao.findBySanshiDoctorAndPatient(doctor, patient);
			if (sanshiSign != null) {
				doctors = drHealthTeamService.findTeamDoctors(patient, 1);
			} else {
				doctors = new ArrayList<>();
			}
		}
		return doctors;
	}
	/**
	 * 获取上次随访
	 */
	public Map<String,String> getLastFollowup(String doctor,String patient,String followClass) throws Exception
	{
		Map<String,String> re = new HashMap<>();
		//获取医生团队成员
		String[] doctors = new String[]{doctor};
		List<Doctor> doctorList = getTeamDoctors(doctor,patient);
		if(doctorList!=null&& doctorList.size()>1)
		{
			doctors = new String[doctorList.size()];
			for(int i=0;i<doctorList.size();i++)
			{
				doctors[i] = doctorList.get(i).getCode();
			}
		}
		//获取最新的随访记录
		Followup followup = followupDao.findLastFollowup(doctors,patient,followClass);
		if(followup!=null)
		{
			re.put("id",String.valueOf(followup.getId()));
			re.put("followupDate",DateUtil.dateToStrShort(followup.getFollowupDate()));
		}
		else{
			re = null;
		}
		return re;
	}
	/**
	 * 获取上次随访
	 */
	public void copyFollowup(Long id,Long fromId) throws Exception
	{
		List<FollowupContent> list = followupContentDao.findByFollowupId(fromId);
		if(list!=null && list.size()>0)
		{
			List<FollowupContent> copyList = new ArrayList<>();
			for (FollowupContent item :list)
			{
				FollowupContent copyItem = new FollowupContent();
				copyItem.setFollowupId(id);
				copyItem.setFollowupKey(item.getFollowupKey());
				copyItem.setFollowupValue(item.getFollowupKey());
				copyItem.setFollowupProject(item.getFollowupProject());
				copyItem.setCreateTime(new Date());
				copyList.add(copyItem);
			}
			followupContentDao.save(copyList);
		}
	}
}

+ 65 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java

@ -777,4 +777,69 @@ public class PatientHealthIndexService extends BaseService {
        }
    }
    /**
     * 获取患者健康指标历史记录
     * 1血糖,2血压,3体重,4腰围
     */
    public List<Map<String,String>> getHealthIndexHistory(String patientCode, int type,int page,int pagesize) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        // 排序
        Sort sort = new Sort(Direction.DESC, "recordDate");
        PageRequest pageRequest = new PageRequest(page, pagesize, sort);
        List<DevicePatientHealthIndex> list = patientHealthIndexDao.findIndexByPatient(patientCode, type, pageRequest);
        if (list != null && list.size() > 0) {
            for (DevicePatientHealthIndex item : list) {
                Map<String, String> map = new HashMap<>();
                if (type == 1)    //血糖
                {
                    String gi = item.getValue1();
                    String giType = item.getValue2();
                    map.put("time", DateUtil.dateToStrLong(item.getRecordDate()));
                    map.put("gi", gi); //  血糖值
                    map.put("gi_type", giType); //  血糖值类型
                    String text = gi + " mmol/L";
                    if ("1".equals(giType)) {
                        text += "(早餐前)";
                    } else if ("2".equals(giType)) {
                        text += "(早餐后)";
                    } else if ("3".equals(giType)) {
                        text += "(午餐前)";
                    } else if ("4".equals(giType)) {
                        text += "(午餐后)";
                    } else if ("5".equals(giType)) {
                        text += "(晚饭前)";
                    } else if ("6".equals(giType)) {
                        text += "(晚饭后)";
                    } else if ("7".equals(giType)) {
                        text += "(睡前)";
                    }
                    map.put("text", text); //  展示
                    re.add(map);
                } else if (type == 2) //血压
                {
                    String sys = item.getValue1();   //收缩压
                    String dia = item.getValue2();    //舒张压
                    String pul = item.getValue3();    //脉搏
                    map.put("time", DateUtil.dateToStrLong(item.getRecordDate()));
                    map.put("sys", sys);
                    map.put("dia", dia);
                    map.put("pul", pul);
                    re.add(map);
                } else if (type == 3) //体重
                {
                    String weight = item.getValue1();   //体重
                    map.put("time", DateUtil.dateToStrShort(item.getRecordDate()));
                    map.put("weight", weight);
                    map.put("text", weight + " kg");
                    re.add(map);
                }
            }
        }
        return re;
    }
}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java

@ -953,7 +953,7 @@ public class GuahaoXMService implements IGuahaoService {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
        else if (StringUtils.startsWith(xml, "Error"))  {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }

+ 1 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwSmjkService.java

@ -358,8 +358,7 @@ public class JwSmjkService {
            if (status == 200) {
                String data = jsonObject.getString("data");
                if (!StringUtils.isEmpty(data) && (data.startsWith("error")||data.startsWith("System-Error"))) {
                    return "111111|aaaaaa|zzzz";
                    //throw new Exception(data);
                    throw new Exception(data);
                } else {
                    re = data;
                }

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

@ -234,23 +234,6 @@ public class DoctorFollowUpController extends BaseController {
		}
	}
	@ApiOperation("获取上次随访项目数据")
	@RequestMapping(value = "/getLastFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getLastFollowupProjectData(@ApiParam(name="patient",value="患者代码",defaultValue = "P20161008001")
										 @RequestParam(value="patient",required = true) String patient,
										 @ApiParam(name="followupProject",value="随访项目",defaultValue = "2")
										 @RequestParam(value="followupProject",required = true) String followupProject)
	{
		try {
			Map<String,String> response = followUpService.getLastFollowupProjectData("D20161008003",patient,followupProject);
			return write(200, "获取上次随访项目数据成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取上次随访项目数据失败!"+e.getMessage());
		}
	}
	@ApiOperation("保存随访项目数据")
	@RequestMapping(value = "/saveFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
@ -302,4 +285,38 @@ public class DoctorFollowUpController extends BaseController {
		}
	}
	/*************************************** 上次随访 ********************************************/
	@ApiOperation("获取上次随访")
	@RequestMapping(value = "/getLastFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getLastFollowup(@ApiParam(name="patient",value="患者代码",defaultValue = "P20161008001")
								   @RequestParam(value="patient",required = true) String patient,
								   @ApiParam(name="followClass",value="随访类别",defaultValue = "1")
								   @RequestParam(value="followClass",required = true) String followClass)
	{
		try {
			Map<String,String> response = followUpService.getLastFollowup(getUID(),patient,followClass);
			return write(200, "获取上次随访成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取上次随访失败!"+e.getMessage());
		}
	}
	@ApiOperation("复制上次随访数据")
	@RequestMapping(value = "/copyFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String copyFollowup(@ApiParam(name="id",value="本地随访ID",defaultValue = "")
								  @RequestParam(value="id",required = true) Long id,
								  @ApiParam(name="fromId",value="拷贝随访记录ID",defaultValue = "")
								  @RequestParam(value="fromId",required = true) Long fromId)
	{
		try {
			followUpService.copyFollowup(id,fromId);
			return write(200, "复制上次随访成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "复制上次随访失败!"+e.getMessage());
		}
	}
}

+ 20 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthController.java

@ -256,11 +256,6 @@ public class DoctorHealthController extends BaseController {
	}
	/**
	 * 根据患者标志获取健康指标
	 * @param patient 患者指标
	 * @return 操作结果
	 */
	@RequestMapping(value = "last",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("患者最新健康指标信息")
@ -285,4 +280,24 @@ public class DoctorHealthController extends BaseController {
		}
	}
	@RequestMapping(value = "getHealthIndexHistory",method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation("获取患者健康指标历史记录")
	public String getHealthIndexHistory(@ApiParam(name="patient",value="患者代码",defaultValue = "P20161008001")
										 @RequestParam(value="patient",required = true) String patient,
										 @ApiParam(name="type",value="指标类型1血糖,2血压,3体重,4腰围",defaultValue = "1")
										 @RequestParam(value="type",required = true) int type,
										 @ApiParam(name="page",value="第几页",defaultValue = "0")
										 @RequestParam(value="page",required = true) int page,
										 @ApiParam(name="pagesize",value="每页几行",defaultValue = "10")
										 @RequestParam(value="pagesize",required = true) int pagesize) {
		try {
			List<Map<String,String>> list = healthIndexService.getHealthIndexHistory(patient, type, page, pagesize);
			return write(200, "获取患者健康指标历史记录成功", "data", list);
		} catch (Exception ex) {
			return invalidUserException(ex, -1, ex.getMessage());
		}
	}
}