浏览代码

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

yeshijie 7 年之前
父节点
当前提交
79dd5b38ff

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

@ -1,5 +1,7 @@
package com.yihu.wlyy.service.app.prenatalInspector;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
@ -14,6 +16,7 @@ import com.yihu.wlyy.repository.patient.PrenatalInspectorRecordDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.service.third.jw.JwMaternalChildService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
@ -50,6 +53,8 @@ public class PrenatalInspectorPreCardService extends BaseService {
    private SignFamilyDao signFamilyDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private JwMaternalChildService jwMaternalChildService;
    /**
@ -120,7 +125,7 @@ public class PrenatalInspectorPreCardService extends BaseService {
    /**
     * 向医生发出产检系统消息
     */
    public void sendMessagePrenatal() throws Exception {
    public void sendMessagePrenatalBak() throws Exception {
        try {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            List<PrenatalInspectorPlan> planList = prenatalInspectorPlanDao.findByTime();
@ -148,6 +153,46 @@ public class PrenatalInspectorPreCardService extends BaseService {
    }
    /**
     * 向医生发出产检系统消息
     */
    public void sendMessagePrenatal() throws Exception {
        try {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            List<PrenatalInspectorPlan> planList = prenatalInspectorPlanDao.findByTime();
            for (PrenatalInspectorPlan plan : planList) {
                String code = plan.getPatient();
                String pregnancyNo = plan.getInspectionCode();
                Date planTime = plan.getInspectionTime();
                Patient patient = patientDao.findByCode(code);
                Date begin = DateUtil.getPreDays(planTime,-14);
                Date end = DateUtil.getPreDays(planTime,14);
                Long days = DateUtil.getDays(new Date(), planTime);
                String content = "您的签约居民" + patient.getName() + "超期未进行孕检,原计划孕检时间" + format.format(plan.getInspectionTime());
                if (StringUtils.isNotEmpty(pregnancyNo) && (pregnancyNo != null)) {
                    Boolean examStatus = getExamStatus(code, pregnancyNo, begin, end);
                    if (!examStatus) {
                        if (days > 7) {
                            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();
        }
    }
    /**
     * 保存系统消息及发送记录
     *
@ -209,4 +254,63 @@ public class PrenatalInspectorPreCardService extends BaseService {
        }
    }
    /**
     * 查询待产检计划产检时间在该时间段内是否有过真实产检
     * @param patient 居民code
     * @param pregnancyNo 产检号
     * @param begin  起始时间
     * @param end  截止时间
     * @return
     * @throws Exception
     */
    public Boolean getExamStatus(String patient,String pregnancyNo,Date begin,Date end) throws Exception {
        Boolean flag = false;
        try {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            JSONArray natals = reExamRecode(patient,pregnancyNo);
            for (Object natal : natals) {
                com.alibaba.fastjson.JSONObject examRecord = JSON.parseObject(natal.toString());
                String exam_time = examRecord.getString("EXAM_TIME");
                Date examTime = format.parse(exam_time);
                if ((examTime.getTime()<= end.getTime()) && (examTime.getTime() >= begin.getTime())){
                    return true;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return flag;
    }
    /**
     * 复检记录
     *
     * @param patientCode
     * @return
     */
    public JSONArray reExamRecode(String patientCode, String pregnancyNo) {
        JSONArray re = new JSONArray();
        try {
            SignFamily signFamily = signFamilyDao.findByPatient(patientCode);
            String hospital = null;
            if (signFamily != null) {
                hospital = signFamily.getHospital();
            }
            Patient patient = patientDao.findByCode(patientCode);
            String response = jwMaternalChildService.getEhrMaternalReExamRecord(patient.getIdcard(), hospital, pregnancyNo);
            com.alibaba.fastjson.JSONObject json = com.alibaba.fastjson.JSONObject.parseObject(response);
            JSONArray data = null;
            if (json.getInteger("status") == 200) {
                data = json.getJSONObject("data").getJSONArray("DATA");
            }
            if (data != null && data.size() > 0) {
                return data;
            }
            return re;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return re;
    }
}

+ 308 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/third/jw/JwMaternalChildService.java

@ -0,0 +1,308 @@
package com.yihu.wlyy.service.third.jw;
import com.yihu.wlyy.util.HttpClientUtil;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by yeshijie on 2017/9/25.
 */
@Service
public class JwMaternalChildService {
    private static final Logger logger = LoggerFactory.getLogger(JwMaternalChildService.class);
    //基卫服务地址
    @Value("${sign.check_upload}")
    private String jwUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 获取孕妇建卡信息
     * @param idcard 身份证
     * @param hospital 医院code
     * @return
     * @throws Exception
     */
    public String getEhrMaternalFirstExamRecord(String idcard,String hospital) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalFirstExamRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取非第一次产检记录
     * @param idcard 身份证
     * @param hospital 医院code
     * @param pregnancyNo 产检号
     * @return
     * @throws Exception
     */
    public String getEhrMaternalReExamRecord(String idcard,String hospital,String pregnancyNo) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalReExamRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        params.add(new BasicNameValuePair("pregnancyNo", pregnancyNo));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取产床预约信息
     * @param idcard 身份证
     * @param hospital 医院code
     * @return
     * @throws Exception
     */
    public String getEhrMaternalBedPrecontractRecord(String idcard,String hospital) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalBedPrecontractRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取高危产妇信息
     * @param idcard 身份证
     * @param hospital 医院code
     * @return
     * @throws Exception
     */
    public String getEhrMaternalPregnancyHighRecord( String idcard, String hospital) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalPregnancyHighRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取孕妇分娩信息
     * @param idcard 身份证
     * @param hospital 医院code
     * @return
     * @throws Exception
     */
    public String getEhrMaternalDeliveryRecord(String idcard, String hospital) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalDeliveryRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取新生儿基本信息
     * @param idcard 身份证
     * @param hospital 医院code
     * @return
     * @throws Exception
     */
    public String getEhrMaternalDeliveryChildRecord(String idcard,String hospital) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalDeliveryChildRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取儿童健康体检0-6岁记录
     * @param idcard 身份证
     * @param hospital 医院code
     * @return
     * @throws Exception
     */
    public String getEhrMaternalChildMedicalRecord(String idcard,String hospital) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalChildMedicalRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取新生儿访视信息
     * @param idcard 身份证
     * @param hospital 医院code
     * @return
     * @throws Exception
     */
    public String getEhrMaternalHomeVisitRecord(String idcard,String hospital) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalHomeVisitRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取新生儿免疫记录
     * @param idcard 身份证
     * @param hospital 医院code
     * @return
     * @throws Exception
     */
    public String getEhrMaternalChildImmuneRecord(String idcard,String hospital) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalChildImmuneRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取孕妇预建卡信息
     * @param idcard 身份证
     * @param hospital 医院code
     * @return
     * @throws Exception
     */
    public String getEhrMaternalPreFirstExamRecord(String idcard,String hospital) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalPreFirstExamRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 上传孕妇预建卡信息
     * @param code 预建卡code
     * @return
     * @throws Exception
     */
    public String SaveEhrMaternalPreFirstExamRecord(String code) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/SaveEhrMaternalPreFirstExamRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("code", code));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 上传新生儿访视信息
     * @param idcard 身份证
     * @param hospital 医院code
     * @return
     * @throws Exception
     */
    public String SaveEhrMaternalHomeVisitRecord(String idcard,String hospital) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/SaveEhrMaternalHomeVisitRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取待产记录
     * @param idcard 身份证
     * @param hospital 医院code
     * @param searchTime 查询时间
     * @return
     * @throws Exception
     */
    public String getEhrMaternalZSPreDeliveryRecord(String idcard,String hospital,String searchTime) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalZSPreDeliveryRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        params.add(new BasicNameValuePair("searchTime", searchTime));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取阴道分娩记录
     * @param idcard 身份证
     * @param hospital 医院code
     * @param searchTime 查询时间
     * @return
     * @throws Exception
     */
    public String getEhrMaternalZSDeliveryRecord(String idcard, String hospital, String searchTime) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalZSDeliveryRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        params.add(new BasicNameValuePair("searchTime", searchTime));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取剖宫产记录
     * @param idcard 身份证
     * @param hospital 医院code
     * @param searchTime 查询时间
     * @return
     * @throws Exception
     */
    public String getEhrMaternalZSCaesareanBirthRecord(String idcard, String hospital, String searchTime) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalZSCaesareanBirthRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        params.add(new BasicNameValuePair("searchTime", searchTime));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
}

+ 17 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/util/DateUtil.java

@ -368,6 +368,23 @@ public class DateUtil {
		return mydate1;
	}
	/**
	 * 时间前推或后推天数(负数前推正数后推)
	 * date 基准时间
	 */
	public static Date getPreDays(Date date, int days) {
		Date day = null;
		try {
			Calendar c = Calendar.getInstance();
			c.setTime(date);
			c.add(Calendar.DATE, days);
			day = c.getTime();
		} catch (Exception e) {
		}
		return day;
	}
	/**
	 * 得到一个时间延后或前移几分钟的时间,nowdate为时间,delay为前移或后延的分钟数
	 */