Преглед на файлове

Merge branch 'dev' of wujunjie/patient-co-management into dev

yeshijie преди 7 години
родител
ревизия
12136abf2e

+ 4 - 30
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/PrenatalInspectorPreCardService.java

@ -22,6 +22,8 @@ import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -58,6 +60,8 @@ public class PrenatalInspectorPreCardService extends BaseService {
    @Autowired
    private JwMaternalChildService jwMaternalChildService;
    Logger logger = LoggerFactory.getLogger(PrenatalInspectorPreCardService.class);
    /**
     * 产检提醒(1预约提醒,2就诊提醒)
@ -124,36 +128,6 @@ public class PrenatalInspectorPreCardService extends BaseService {
    }
    /**
     * 向医生发出产检系统消息
     */
    public void sendMessagePrenatalBak() throws Exception {
        try {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            List<PrenatalInspectorPlan> planList = prenatalInspectorPlanDao.findByTime();
            for (PrenatalInspectorPlan plan : planList) {
                String code = plan.getPatient();
                Patient patient = patientDao.findByCode(code);
                String content = "您的签约居民" + patient.getName() + "超期未进行孕检,原计划孕检时间" + format.format(plan.getInspectionTime());
                List<PrenatalInspectorPlan> plans = prenatalInspectorPlanDao.getScopeById(plan.getId());
                if (plans == null || plans.size() == 0) {
                    SignFamily signFamily = signFamilyDao.findByPatient(code);
                    String doctor = signFamily.getDoctor();
                    String doctorHealth = signFamily.getDoctorHealth();
                    if (StringUtils.isNotEmpty(doctor)) {
                        saveMessageRecord(plan.getId().toString(), doctor,code, content);
                    }
                    if (StringUtils.isNotEmpty(doctorHealth)) {
                        saveMessageRecord(plan.getId().toString(), doctorHealth,code, content);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 向医生发出产检系统消息

+ 4 - 3
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/util/DateUtil.java

@ -603,11 +603,12 @@ public class DateUtil {
	 */
	public static int getDutyDays(Date startDate, Date endDate) {
		int result = 0;
		while (startDate.compareTo(endDate) <= 0) {
			if (startDate.getDay() != 6 && startDate.getDay() != 0) {
        Date  startTime = new Date(startDate.getTime());
		while (startTime.compareTo(endDate) <= 0) {
			if (startTime.getDay() != 6 && startTime.getDay() != 0) {
				result++;
			}
			startDate.setDate(startDate.getDate() + 1);
            startTime.setDate(startTime.getDate() + 1);
		}
		return result;
	}

+ 7 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PrenatalInspectorPlanDao.java

@ -22,11 +22,17 @@ public interface PrenatalInspectorPlanDao extends PagingAndSortingRepository<Pre
    List<PrenatalInspectorPlan> findByPatient(String patient);
    //查询当前时间14天前之后所有产检计划中距当前时间最近的记录
    @Query(value = "SELECT a.id,a.inspection_time FROM wlyy_prenatal_inspector_plan a WHERE a.patient = ?1 " +
    @Query(value = "SELECT a.* FROM wlyy_prenatal_inspector_plan a WHERE a.patient = ?1 " +
            " AND a. STATUS = '0' AND a.del = '1' AND a.inspection_time >= DATE_ADD(CURDATE(),INTERVAL -14 DAY) " +
            " ORDER BY ABS(DATEDIFF(NOW(),inspection_time)) ASC LIMIT 0,1 ",nativeQuery = true)
    PrenatalInspectorPlan findByPatientlateliest(String patient);
    //查询当前时间14天前之前所有产检计划中距当前时间最近的记录
    @Query(value = "SELECT a.* FROM wlyy_prenatal_inspector_plan a WHERE a.patient = ?1 " +
            " AND a. STATUS = '0' AND a.del = '1' AND a.inspection_time < DATE_ADD(CURDATE(), INTERVAL - 14 DAY) " +
            " ORDER BY ABS( DATEDIFF(NOW(), inspection_time) ) ASC LIMIT 0,1 ",nativeQuery = true)
    PrenatalInspectorPlan findByPatientBeforeList(String patient);
    //应产检时间前14天后14天待产检计划(不包括应产检当天)
    @Query(value = "SELECT a.* FROM wlyy_prenatal_inspector_plan a, (SELECT t.* from wlyy_prenatal_inspector_plan t where t.id = ?1 )b  " +
            " WHERE a.inspection_time >= DATE_ADD(b.inspection_time,INTERVAL -14 DAY) and a.inspection_time <= DATE_ADD(b.inspection_time,INTERVAL 14 DAY) " +

+ 22 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/PrenatalInspectorPreCardService.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.service.app.prenatalInspector;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.device.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
@ -831,7 +832,7 @@ public class PrenatalInspectorPreCardService extends BaseService {
    /**
     * 根据待产检ID查询最近一条待产检计划状态
     *
     * 及列表范围之外最近一条待产检计划状态
     * @param prenatalId
     */
    public JSONObject getPrenatalStatus(Long prenatalId) throws Exception {
@ -850,6 +851,7 @@ public class PrenatalInspectorPreCardService extends BaseService {
            if (StringUtils.isNotEmpty(pregnancyNo) && (pregnancyNo != null)){
                Map<String,String> exams = getExamStatus(patient,pregnancyNo,begin,end);
                String examStatus = exams.get("status");
                Object beforePlan = exams.containsKey("plan")?exams.get("plan"):null;
                if ("1".equals(examStatus)){
                    String examTime = exams.get("examTime");
                    json.put("renatalStatus", "4");
@ -858,10 +860,14 @@ public class PrenatalInspectorPreCardService extends BaseService {
                    if (days > 7) {
                        json.put("renatalStatus", "3");
                        json.put("sendStatus", flag == true ? "1" : "0");
                        json.put("plan", plan);
                    }else{
                        PrenatalInspectorRecord record = recordDao.findByRelationAndType(prenatalId.toString(), 0);
                        if (record == null) {
                            json.put("renatalStatus", "1");
                            if (beforePlan !=null){
                                json.put("plan", beforePlan);
                            }
                            if (days < -7) {
                                json.put("reason", "未到提醒时间(" + format.format(DateUtil.getPreDays(plan.getInspectionTime(), -7)) + " 08:00)");
                            }else {
@ -871,6 +877,9 @@ public class PrenatalInspectorPreCardService extends BaseService {
                            PrenatalInspectorRecord docRecord = recordDao.findByRelationAndType(prenatalId.toString(), 1);
                            json.put("renatalStatus", "2");
                            json.put("sendStatus", flag == true ? "1" : "0");
                            if (beforePlan !=null){
                                json.put("plan", beforePlan);
                            }
                            if (docRecord == null) {
                                json.put("sendTime", format.format(record.getSendTime()));
                            } else {
@ -1029,10 +1038,11 @@ public class PrenatalInspectorPreCardService extends BaseService {
     * @throws Exception
     */
    public Map getExamStatus(String patient,String pregnancyNo,Date begin,Date end) throws Exception {
        Map<String,String> respose = new HashMap();
        Map<String,Object> respose = new HashMap();
        respose.put("status","0");
        try {
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                PrenatalInspectorPlan plan = prenatalInspectorPlanDao.findByPatientBeforeList(patient);
                JSONArray natals = reExamRecode(patient,pregnancyNo);
                for (Object natal : natals) {
                    JSONObject examRecord = JSON.parseObject(natal.toString());
@ -1041,8 +1051,17 @@ public class PrenatalInspectorPreCardService extends BaseService {
                    if ((examTime.getTime()<= end.getTime()) && (examTime.getTime() >= begin.getTime())){
                        respose.put("status","1");
                        respose.put("examTime",exam_time);
                        return respose;
                    }
                    if ((plan != null) && (StringUtils.isNotEmpty(plan.getInspectionCode()))){
                        Date planTime = plan.getInspectionTime();
                        Date beginTime = DateUtil.getPreDays(planTime,-14);
                        Date endTime = DateUtil.getPreDays(planTime,14);
                        respose.put("plan",plan);
                        if ((examTime.getTime()<= beginTime.getTime()) && (examTime.getTime() >= endTime.getTime())){
                            respose.remove("plan");
                        }
                    }
                }
        } catch (Exception e) {
            e.printStackTrace();