Parcourir la source

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

chenweida il y a 7 ans
Parent
commit
0cc1142c61

+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/followup/FollowupDrugs.java

@ -23,7 +23,7 @@ public class FollowupDrugs extends IdEntity {
	private String drugsCode;
	//药品名称
	private String drugsName;
	//药品分组(糖尿病--胰岛特殊处理)
	//药品分组(糖尿病--胰岛特殊处理)胰岛素分类insulin,其他药品为normal
	private String drugsGroup;
	//次剂量
	private String dose;

+ 80 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -32,6 +32,8 @@ import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.prescription.*;
import com.yihu.wlyy.service.app.health.HealthEduArticleService;
import com.yihu.wlyy.service.app.health.PatientHealthGuidanceService;
import com.yihu.wlyy.service.app.health.PatientHealthIndexService;
import com.yihu.wlyy.service.app.prescription.PrescriptionFollowupContentService;
import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
import com.yihu.wlyy.service.app.prescription.PrescriptionLogService;
import com.yihu.wlyy.service.app.talk.TalkGroupService;
@ -142,10 +144,17 @@ public class ConsultTeamService extends ConsultService {
    private PatientService patientService;
    @Autowired
    private FollowUpDao followupDao;
    @Autowired
    private PrescriptionFollowupContentDao prescriptionFollowupContentDao;
    @Autowired
    private PatientHealthIndexService healthIndexService;
    //健康问题 高血压
    private static final String gxy = "HP0093";
    //健康问题 糖尿病
    private static final String tnb ="HP0047";
    
    @Autowired
    private PrescriptionFollowupContentService prescriptionFollowupContentService;
    Map<Integer, String> relations = new HashMap<>();
@ -984,7 +993,7 @@ public class ConsultTeamService extends ConsultService {
            //1、获取基位处方详情(保存续方表、药品续方信息表、续方疾病类型表)
            Prescription prescription = new Prescription();
            savePrescription(prescription,jwCode,doctor,p,ct,reason);
            prescription = savePrescription(prescription,jwCode,doctor,p,ct,reason);
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("title",p.getName()+"申请续方");
@ -999,6 +1008,42 @@ public class ConsultTeamService extends ConsultService {
            }
            //3、获取上次续方时间:与平安的“智慧医保的审方系统”对接,判断居民上次续方时间,点击跳转上次续方记录。(此功能需与第三方系统对接,如果本次版本无法实现,则消息中不显示此条信息)
            jsonObject.put("lastTime","");
    
            //--增加问卷填写情况---huangwenjie--2017.11.01
            List<PrescriptionFollowupContent> prescriptionFollowupContents =prescriptionFollowupContentDao.findByPrescriptionCode(prescription.getCode());
            boolean zzFlag = false;//是否填写症状问卷
            boolean tzssFlag = false;//是否填写体征和生活问卷
            for (PrescriptionFollowupContent prescriptionFollowupContent: prescriptionFollowupContents) {
                if(!zzFlag && "1".equals(prescriptionFollowupContent.getFollowupProject())){
                    zzFlag = true;
                }
    
                if(!tzssFlag &&
                        ("2".equals(prescriptionFollowupContent.getFollowupProject())
                                || "4".equals(prescriptionFollowupContent.getFollowupProject()))
                        ){
                    zzFlag = true;
                }
                
                if(zzFlag && tzssFlag){
                    break;
                }
            }
            if(zzFlag){
                jsonObject.put("zzMsg","居民已填写问卷");
            }else{
                jsonObject.put("zzMsg","居民未填写问卷");
            }
            if(tzssFlag){
                jsonObject.put("tzssMsg","居民已填写问卷");
            }else{
                jsonObject.put("tzssMsg","居民未填写问卷");
            }
            jsonObject.put("zzFlag",zzFlag);
            jsonObject.put("tzssFlag",tzssFlag);
            
            
            
            String content = jsonObject.toString();
            //4、创建咨询
@ -1153,7 +1198,7 @@ public class ConsultTeamService extends ConsultService {
     * @param reason
     * @return
     */
    public void savePrescription(Prescription prescription,String jwCode,Doctor doctor,Patient p,ConsultTeam ct,String reason) throws Exception{
    public Prescription savePrescription(Prescription prescription,String jwCode,Doctor doctor,Patient p,ConsultTeam ct,String reason) throws Exception{
        //获取智业处方详细
        String response = jwPrescriptionService.getRecipe(jwCode,p.getSsc());
        com.alibaba.fastjson.JSONObject jsonObject = presModeAdapter.modelToSinglePrescription(response);
@ -1290,6 +1335,7 @@ public class ConsultTeamService extends ConsultService {
        //添加保存日志
        prescriptionLogService.addLog(prescription, PrescriptionLog.PrescriptionLogType.create.getValue(),1,1);
        return prescription;
    }
    public String getZyCommonDictName(String code){
@ -2571,4 +2617,36 @@ public class ConsultTeamService extends ConsultService {
            }
        }
    }
    
    /**
     * 医生发送血糖血压快捷回复咨询
     * @param prescriptionCode
     * @param type
     */
    public void addPrescriptionBloodStatusConsult(String prescriptionCode, String type,String followupid) throws Exception {
        if("1".equals(type)){//血压
            prescriptionFollowupContentService.importPatientBloodPressureToFollowup(prescriptionCode,followupid,true);
        }else if("2".equals(type)){//血糖
            prescriptionFollowupContentService.importPatientBloodSugarToFollowup(prescriptionCode,followupid,true);
        }
    }
    
    /**
     * 医生发送症状、体征及生活方式回复咨询
     * @param prescriptionCode
     * @param type
     */
    public void addPrescriptionFollowupContentConsult(String prescriptionCode, String type, String followupid) throws Exception {
        Prescription prescription = prescriptionDao.findByCode(prescriptionCode);
        org.json.JSONObject contentDoctor = new org.json.JSONObject();
        //医生发送的消息
        if("1".equals(type)){
            contentDoctor.put("text", "请提供您最近一次的血压检测数值及检测时间");
        }else{
            contentDoctor.put("text", "请提供您最近一次的血压检测数值及检测时间");
        }
        contentDoctor.put("type",type);
        //医生发送Im消息
        ImUtill.sendTopicIM(prescription.getDoctor(), prescription.getDoctorName(), prescription.getConsult(), "17", contentDoctor.toString(), null);
    }
}

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

@ -9,6 +9,7 @@ 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.followup.FollowupDrugs;
import com.yihu.wlyy.entity.followup.FollowupMapping;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
@ -17,6 +18,7 @@ import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.followup.FollowUpDao;
import com.yihu.wlyy.repository.followup.FollowUpMappingDao;
import com.yihu.wlyy.repository.followup.FollowupContentDao;
import com.yihu.wlyy.repository.followup.FollowupDrugsDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
@ -103,6 +105,8 @@ public class FollowUpService extends BaseService {
    private PushMsgTask pushMsgTask;
    @Autowired
    private FollowUpMappingDao followUpMappingDao;
    @Autowired
    private FollowupDrugsDao followupDrugsDao;
    @Value("${doctorAssistant.api}")
    private String doctorAssistant;
    @Value("${doctorAssistant.target_url}")
@ -1047,6 +1051,11 @@ public class FollowUpService extends BaseService {
        return followupContentESDOList;
    }
    
    /**
     * 根据续方CODE获取随访记录信息
     * @param prescriptionCode
     * @return
     */
    public String getFollowupByPrescriptionCode(String prescriptionCode) {
        Followup followup = followupDao.getFollowupByPrescriptionCode(prescriptionCode);
    
@ -1054,5 +1063,41 @@ public class FollowUpService extends BaseService {
        
        return jsonString;
    }
    
    /**
     * 获取随访详情记录分类记录数
     * @param followupid
     * @param type
     * @return
     */
    public int getfollowupcontent(String followupid, String type) throws Exception {
    
        int count = 0;
        String[] typelist = null;
        if(type.contains(",")){
            typelist = type.split(",");
        }else{
            typelist = new String[]{type};
        }
    
        for (String typekey: typelist) {
            if(!"drug".equals(type)){
    
                FollowupContentESDO followupContentESDO = this.esGetFollowupProjectData(followupid,typekey);
                if(followupContentESDO != null){
                    count ++;
                }
            
            }else{
                //获取用药记录
                List<FollowupDrugs> drugsList = followupDrugsDao.findByFollowupId(Long.valueOf(followupid));
                if(!drugsList.isEmpty()){
                    count = count +drugsList.size();
                }
            }
        }
        
        return count;
    }
}

+ 372 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionFollowupContentService.java

@ -3,11 +3,24 @@ package com.yihu.wlyy.service.app.prescription;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.followup.Followup;
import com.yihu.wlyy.entity.followup.FollowupDrugs;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionFollowupContent;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.repository.followup.FollowUpDao;
import com.yihu.wlyy.repository.followup.FollowupDrugsDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.repository.prescription.PrescriptionFollowupContentDao;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.followup.FollowUpService;
import com.yihu.wlyy.service.app.health.PatientHealthIndexService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ImUtill;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -26,6 +39,22 @@ public class PrescriptionFollowupContentService extends BaseService {
	
	@Autowired
	private PrescriptionFollowupContentDao prescriptionFollowupContentDao;
	@Autowired
	private PrescriptionInfoDao prescriptionInfoDao;
	@Autowired
	private FollowupDrugsDao followupDrugsDao;
	@Autowired
	private PrescriptionDao prescriptionDao;
	@Autowired
	private PatientHealthIndexService healthIndexService;
	@Autowired
	private FollowUpService followUpService;
	@Autowired
	private FollowUpDao followUpDao;
	@Autowired
	private ImUtill ImUtill;
	@Autowired
	JdbcTemplate jdbcTemplate;
	
	/**
	 * 根据续方CODE,文件类型获取数据
@ -55,9 +84,10 @@ public class PrescriptionFollowupContentService extends BaseService {
	 * 保存随访调查分类数据
	 * @param prescriptioncode
	 * @param followupProjectData
	 * @param sendIM
	 * @throws Exception
	 */
	public void saveInfo(String prescriptioncode, String followupProjectData,String patientCode) throws Exception{
	public void saveInfo(String prescriptioncode, String followupProjectData,String patientCode,boolean sendIM) throws Exception{
		JSONArray objects = JSON.parseArray(followupProjectData);
		
		if(objects!= null & objects.size() >0){
@ -67,7 +97,7 @@ public class PrescriptionFollowupContentService extends BaseService {
				String followupProject = jsonObject.getString("followupProject");
				String projectValueStr = jsonObject.getString("projectData");
				if(StringUtils.isNotBlank(projectValueStr)){
					HashMap<String,String> projectValueMap = (HashMap)JSON.parse(projectValueStr);
					Map<String,String> projectValueMap = (Map)JSON.parse(projectValueStr);
					if(!projectValueMap.isEmpty()){
						projectValueMap.forEach( (key,value)->{
							PrescriptionFollowupContent prescriptionFollowupContent = new PrescriptionFollowupContent();
@ -84,6 +114,19 @@ public class PrescriptionFollowupContentService extends BaseService {
				if(!savedatas.isEmpty()){
					prescriptionFollowupContentDao.deleteByPrescriptioncodeAndFollowupProject(prescriptioncode,followupProject);
					prescriptionFollowupContentDao.save(savedatas);
					
					if(sendIM){
						org.json.JSONObject content = new org.json.JSONObject();
						content.put("title", "【本消息为系统提醒】:");
						if("1".equals(followupProject)){
							content.put("text", "居民已填写《身份异常症状问卷》");
						}else{
							content.put("text", "居民已填写《体征及生活方式调查问卷》");
						}
						content.put("sysMsg","填写完成并提交后,医生将可以查看您的问卷内容");
						Prescription p = prescriptionDao.findByCode(prescriptioncode);
						ImUtill.sendTopicIM(p.getDoctor(), p.getDoctorName(), p.getConsult(), "17", content.toString(), null);
					}
				}
			}
			
@ -136,7 +179,7 @@ public class PrescriptionFollowupContentService extends BaseService {
			JSONObject jsonObject1 = new JSONObject();
			jsonObject1.put("type","1");
			jsonObject1.put("name","身份异常症状问卷");
			jsonObject1.put("statue","已填写");
			jsonObject1.put("statue","1");//1已填写,2未填写
			jsonObject1.put("createtime",prescriptionFollowupContent1.getCreateTime());
			result.add(jsonObject1);
		}
@ -145,11 +188,336 @@ public class PrescriptionFollowupContentService extends BaseService {
			JSONObject jsonObject2 = new JSONObject();
			jsonObject2.put("type","2");
			jsonObject2.put("name","体征及生活方式调查问卷");
			jsonObject2.put("statue","已填写");
			jsonObject2.put("statue","1");//1已填写,2未填写
			jsonObject2.put("createtime",prescriptionFollowupContent1.getCreateTime());
			result.add(jsonObject2);
		}
		
		return result;
	}
	
	/**
	 * 续方药品导入随访记录
	 * @param prescriptioncode
	 * @param followup_id
	 */
	public void importPrescriptionDrugsToFollowup(String prescriptioncode, String followup_id) throws Exception {
		
		
		
		Long followupId = Long.valueOf(followup_id);
		
		Followup followup =followUpDao.findOne(followupId);
		
		if(followup == null){
			throw new Exception("未找到随访记录!");
		}
		
		//删除原有用药记录
		followupDrugsDao.deleteByFollowupId(Long.valueOf(followupId));
		
		List<PrescriptionInfo> list = prescriptionInfoDao.findByPrescriptionCode(prescriptioncode);
		
		if(list!=null && list.size()>0)
		{
			List<FollowupDrugs> newList = new ArrayList<>();
			for(PrescriptionInfo prescriptionInfo:list)
			{
				FollowupDrugs drug = new FollowupDrugs();
				drug.setFollowupId(followupId);
				
				if(prescriptionInfo.getDrugName().contains("胰岛素") &&prescriptionInfo.getSubjectClass().contains("010")){
					drug.setDrugsGroup("insulin");
				}else{
					drug.setDrugsGroup("normal");
				}
				drug.setDrugsCode(prescriptionInfo.getDrugCode());
				drug.setDrugsName(prescriptionInfo.getDrugName());
				drug.setDose(prescriptionInfo.getPhysicDose());
				drug.setUnit(prescriptionInfo.getDrugNumUnit());
				drug.setFrequency(prescriptionInfo.getDrugRate());
				drug.setCreateTime(new Date());
				newList.add(drug);
			}
			followupDrugsDao.save(newList);
		}
	}
	
	/**
	 * 续方患者的血糖导入随访记录
	 * @param prescriptioncode
	 * @param followup_id
	 */
	public void importPatientBloodSugarToFollowup(String prescriptioncode, String followup_id,boolean sendIM) throws Exception {
		Long followupId = Long.valueOf(followup_id);
		
		Followup followup =followUpDao.findOne(followupId);
		
		if(followup == null){
			throw new Exception("未找到随访记录!");
		}
		
		Prescription prescription = prescriptionDao.findByCode(prescriptioncode);
		
		String patientCode = prescription.getParentCode();
		
		String stardate = DateUtil.getNextMonth(new Date(),-30)+" 00:00:00";
		String enddate = DateUtil.getStringDateShort()+" 23:59:59";
		
		List<Object> list = healthIndexService.findIndexByPatient2(patientCode, 1, stardate, enddate, 0, 2);
		
		
		String followupProjectData = "";
		
		org.json.JSONObject contentDoctor = new org.json.JSONObject();
		org.json.JSONObject contentPatient = new org.json.JSONObject();
		String imBloodSugarValue = "";
		String imBloodSugarDate = "";
		
		if(!list.isEmpty()){
			
			for (Object o: list) {
				
				JSONObject obj = (JSONObject)o;
				
				imBloodSugarDate = obj.getString("recordDate");
				
				//餐前
				if(StringUtils.isNotBlank(obj.getString("value1"))){
					followupProjectData = "{'BS_FPG':'"+obj.getString("value1")+"'}";
					imBloodSugarValue = obj.getString("value1");
					break;
				}
				
				if(StringUtils.isNotBlank(obj.getString("value3"))){
					followupProjectData = "{'BS_FPG':'"+obj.getString("value3")+"'}";
					imBloodSugarValue = obj.getString("value3");
					break;
				}
				
				if(StringUtils.isNotBlank(obj.getString("value5"))){
					followupProjectData = "{'BS_FPG':'"+obj.getString("value5")+"'}";
					imBloodSugarValue = obj.getString("value5");
					break;
				}
				//餐后
				if(StringUtils.isNotBlank(obj.getString("value2"))){
					followupProjectData = "{'NO_BS_FPG':'"+obj.getString("value2")+"'}";
					imBloodSugarValue = obj.getString("value2");
					break;
				}
				
				
				if(StringUtils.isNotBlank(obj.getString("value4"))){
					followupProjectData = "{'NO_BS_FPG':'"+obj.getString("value4")+"'}";
					imBloodSugarValue = obj.getString("value4");
					break;
				}
				
				if(StringUtils.isNotBlank(obj.getString("value6"))){
					followupProjectData = "{'NO_BS_FPG':'"+obj.getString("value6")+"'}";
					imBloodSugarValue = obj.getString("value6");
					break;
				}
				
				//随机血糖
				if(StringUtils.isNotBlank(obj.getString("value7"))){
					followupProjectData = "{'RANDOM_BLOOD_SUGAR':'"+obj.getString("value7")+"'}";
					imBloodSugarValue = obj.getString("value7");
					break;
				}
			}
			
			followUpService.esSaveFollowupProjectData(followup_id, "3", followupProjectData);
			
			//是否需要发送IM消息
			if(sendIM){
				//医生发送的消息
				contentDoctor.put("text", "请提供您最近一次的血糖检测数值及检测时间");
				contentDoctor.put("needupload",false);
				int total = 0;
				String sql = "select sum(category_code) amount deviceType FROM wlyy_patient_device WHERE user="+prescription.getPatient();
				List<Map<String,Object>> result =  jdbcTemplate.queryForList(sql);
				if (result != null && result.size() > 0) {
					total = (result.get(0).get("amount") != null ? Integer.parseInt(result.get(0).get("amount").toString()) : 0);
				}
				if(total != 1 || total != 3){
					contentDoctor.put("deviceMsg","您未绑定血糖智能设备,请手动上传体征数据,绑定设备后系统将会自动将您的体征数据上报给医生");
				}
				
				//医生发送Im消息
				ImUtill.sendTopicIM(prescription.getDoctor(), prescription.getDoctorName(), prescription.getConsult(), "16", contentDoctor.toString(), null);
				
				//患者发送的消息
				contentPatient.put("title", "【本消息为系统提醒】:");
				contentPatient.put("tzMsg", "体征记录:血糖"+imBloodSugarValue);
				contentPatient.put("tzTime", "检测时间:"+imBloodSugarDate);
				contentPatient.put("tzAlert","温馨提示:本条体征为居民上传的健康体征数据,您可以自动填入本次随访记录");
				
				//患者发送Im消息
				ImUtill.sendTopicIM(prescription.getPatient(), prescription.getPatientName(), prescription.getConsult(), "16", contentPatient.toString(), null);
			}
		}else{
			//是否需要发送IM消息
			if(sendIM){
				//医生发送的消息
				contentDoctor.put("text", "居民近30天未上传血糖体征数据,已通知居民上传数据,请耐心等待");
				contentDoctor.put("needupload",true);
			}else{
				throw new Exception("未找到30天内的血糖记录!");
			}
		}
	}
	
	/**
	 * 续方患者的血压导入随访记录
	 * @param prescriptioncode
	 * @param followup_id
	 * @param sendIM 是否发送IM消息
	 */
	public void importPatientBloodPressureToFollowup(String prescriptioncode, String followup_id,boolean sendIM) throws Exception {
		
		Long followupId = Long.valueOf(followup_id);
		
		Followup followup =followUpDao.findOne(followupId);
		
		if(followup == null){
			throw new Exception("未找到随访记录!");
		}
		
		Prescription prescription = prescriptionDao.findByCode(prescriptioncode);
		
		String patientCode = prescription.getParentCode();
		
		String stardate = DateUtil.getNextMonth(new Date(),-30)+" 00:00:00";
		String enddate = DateUtil.getStringDateShort()+" 23:59:59";
		org.json.JSONArray jsonArray = healthIndexService.findIndexByPatient(patientCode, 2, stardate, enddate, 0, 2);
		
		String followupProjectData = "";
		
		org.json.JSONObject contentDoctor = new org.json.JSONObject();
		org.json.JSONObject contentPatient = new org.json.JSONObject();
		
		if(jsonArray.length() > 0){
			
			org.json.JSONObject jsonObject = jsonArray.getJSONObject(0);
			
			followupProjectData = "{'BP_D':'"+jsonObject.getString("value1")+"'BP_U':'"+jsonObject.getString("value2")+"'}";
			followUpService.esSaveFollowupProjectData(followup_id, "2", followupProjectData);
			
			//是否需要发送IM消息
			if(sendIM){
				//医生发送的消息
				contentDoctor.put("text", "请提供您最近一次的血压检测数值及检测时间");
				contentDoctor.put("needUpload",false);
				
				int total = 0;
				String sql = "select sum(category_code) amount deviceType FROM wlyy_patient_device WHERE user="+prescription.getPatient();
				List<Map<String,Object>> result =  jdbcTemplate.queryForList(sql);
				if (result != null && result.size() > 0) {
					total = (result.get(0).get("amount") != null ? Integer.parseInt(result.get(0).get("amount").toString()) : 0);
				}
				if(total != 2 || total != 3){
					contentDoctor.put("deviceMsg","您未绑定血压智能设备,请手动上传体征数据,绑定设备后系统将会自动将您的体征数据上报给医生");
				}
				
				//医生发送Im消息
				ImUtill.sendTopicIM(prescription.getDoctor(), prescription.getDoctorName(), prescription.getConsult(), "16", contentDoctor.toString(), null);
				
				//患者发送的消息
				contentPatient.put("title", "【本消息为系统提醒】:");
				contentPatient.put("tzMsg", "体征记录:血压"+jsonObject.getString("value1")+"/"+jsonObject.getString("value2")+" mmHg");
				contentPatient.put("tzTime", "检测时间:"+jsonObject.getString("date"));
				contentPatient.put("tzAlert","温馨提示:本条体征为居民上传的健康体征数据,您可以自动填入本次随访记录");
				
				//患者发送Im消息
				ImUtill.sendTopicIM(prescription.getPatient(), prescription.getPatientName(), prescription.getConsult(), "16", contentPatient.toString(), null);
			}
		}else{
			//是否需要发送IM消息
			if(sendIM){
				//医生发送的消息
				contentDoctor.put("text", "居民近30天未上传血压体征数据,已通知居民上传数据,请耐心等待");
				contentDoctor.put("needupload",true);
			}else{
				throw new Exception("未找到30天内的血压记录!");
			}
		}
	
	}
	
	/**
	 * 续方问卷导入随访记录
	 * @param prescriptioncode
	 * @param followup_id
	 * @param type
	 */
	public void importfollowupcontent(String prescriptioncode, String followup_id, String type) throws Exception {
		
		Long followupId = Long.valueOf(followup_id);
		
		Followup followup =followUpDao.findOne(followupId);
		
		if(followup == null){
			throw new Exception("未找到随访记录!");
		}
		
		Prescription prescription = prescriptionDao.findByCode(prescriptioncode);
		
		String patientCode = prescription.getParentCode();
		
		
		if("1".equals(type)){
		//1身份异常症状问卷
			List<PrescriptionFollowupContent>  list = prescriptionFollowupContentDao.findByPrescriptionCodeAndFollowupProject(prescriptioncode,type);
			
			Map<String, String> datamap = new HashMap<>();
			
			if(!list.isEmpty()){
				for (PrescriptionFollowupContent prescriptionFollowupContent: list) {
					datamap.put(prescriptionFollowupContent.getFollowupKey(),prescriptionFollowupContent.getFollowupValue());
				}
			}
			
			followUpService.esSaveFollowupProjectData(followup_id, type, JSON.toJSONString(datamap));
		}else if("2".equals(type)){
			//2体征
			Map<String, String> datamap2 = new HashMap<>();
			List<PrescriptionFollowupContent>  list2 = prescriptionFollowupContentDao.findByPrescriptionCodeAndFollowupProject(prescriptioncode,"2");
			
			if(!list2.isEmpty()){
				for (PrescriptionFollowupContent prescriptionFollowupContent: list2) {
					datamap2.put(prescriptionFollowupContent.getFollowupKey(),prescriptionFollowupContent.getFollowupValue());
				}
			}
			//近30天血压
			String stardate = DateUtil.getNextMonth(new Date(),-30)+" 00:00:00";
			String enddate = DateUtil.getStringDateShort()+" 23:59:59";
			org.json.JSONArray jsonArray = healthIndexService.findIndexByPatient(patientCode, 2, stardate, enddate, 0, 2);
			if(jsonArray.length() > 0){
				org.json.JSONObject jsonObject = jsonArray.getJSONObject(0);
				datamap2.put("BP_D",jsonObject.getString("value1"));
				datamap2.put("BP_U",jsonObject.getString("value2"));
			}
			followUpService.esSaveFollowupProjectData(followup_id, "2", JSON.toJSONString(datamap2));
			
			
			Map<String, String> datamap3 = new HashMap<>();
			List<PrescriptionFollowupContent>  list3 = prescriptionFollowupContentDao.findByPrescriptionCodeAndFollowupProject(prescriptioncode,"4");
			
			if(!list3.isEmpty()){
				for (PrescriptionFollowupContent prescriptionFollowupContent: list2) {
					datamap3.put(prescriptionFollowupContent.getFollowupKey(),prescriptionFollowupContent.getFollowupValue());
				}
			}
			followUpService.esSaveFollowupProjectData(followup_id, "4", JSON.toJSONString(datamap3));
		
		}else{}
	}
}

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

@ -424,6 +424,13 @@ public class DateUtil {
		c.add(Calendar.MONTH, months);
		return dateToStrShort(c.getTime());
	}
	
	public static Date getNextMonthReturnDate(Date d, int months) {
		Calendar c = Calendar.getInstance();
		c.setTime(d);
		c.add(Calendar.MONTH, months);
		return c.getTime();
	}
	public static String getNextYear(Date d, int year) {
		Calendar c = Calendar.getInstance();

+ 41 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java

@ -15,7 +15,6 @@ import com.yihu.wlyy.repository.patient.SignFamilyServerDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.app.consult.ConsultTeamService;
import com.yihu.wlyy.service.app.followup.FollowUpService;
import com.yihu.wlyy.service.app.health.PatientHealthGuidanceService;
@ -1143,6 +1142,47 @@ public class DoctorConsultController extends WeixinBaseController {
            return error(-1, "查询失败!");
        }
    }
    
    @RequestMapping(value = "addPrescriptionBloodStatusConsult",method = RequestMethod.POST)
    @ResponseBody
    @ObserverRequired
    @ApiOperation("续方咨询-医生发送血糖血压快捷回复咨询")
    public String addPrescriptionBloodStatusConsult(
            @ApiParam(name = "prescriptionCode", value = "处方code", defaultValue = "")
            @RequestParam(value = "prescriptionCode", required = true) String prescriptionCode,
            @ApiParam(name = "type", value = "类型(1血压,2血糖)", defaultValue = "")
            @RequestParam(value = "type", required = true) String type,
            @ApiParam(name = "followupid", value = "随访记录ID", defaultValue = "")
            @RequestParam(value = "followupid", required = true) String followupid){
        try{
            consultTeamService.addPrescriptionBloodStatusConsult(prescriptionCode,type,followupid);
            return write(200, "添加成功!");
        }catch (Exception e){
            error(e);
            return error(-1,"添加失败");
        }
    }
    
    @RequestMapping(value = "addPrescriptionFollowupContentConsult",method = RequestMethod.POST)
    @ResponseBody
    @ObserverRequired
    @ApiOperation("续方咨询-医生发送问卷快捷回复咨询")
    public String addPrescriptionFollowupContentConsult(
            @ApiParam(name = "prescriptionCode", value = "处方code", defaultValue = "")
            @RequestParam(value = "prescriptionCode", required = true) String prescriptionCode,
            @ApiParam(name = "type", value = "类型(1症状,2体征及生活方式)", defaultValue = "")
            @RequestParam(value = "type", required = true) String type,
            @ApiParam(name = "followupid", value = "随访记录ID", defaultValue = "")
            @RequestParam(value = "followupid", required = true) String followupid){
        try{
            consultTeamService.addPrescriptionFollowupContentConsult(prescriptionCode,type,followupid);
            return write(200, "添加成功!");
        }catch (Exception e){
            error(e);
            return error(-1,"添加失败");
        }
    }
    

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

@ -400,5 +400,24 @@ public class DoctorFollowUpController extends BaseController {
            return invalidUserException(e, -1, "发送随访计划消息失败!" + e.getMessage());
        }
    }
    
    
    @RequestMapping(value = "/checkfollowupcontent", method = RequestMethod.GET)
    @ApiOperation("检查续方关联的随访记录是否对应的详情记录")
    public String getfollowupcontent(
            @ApiParam(name = "followupid", value = "随访ID", defaultValue = "")
            @RequestParam(value = "followupid", required = true) String followupid,
            @ApiParam(name = "type", value = "支持传多个以英文逗号连接,drug为药品,1-9为随访分类", defaultValue = "")
            @RequestParam(value = "type", required = true) String type){
        try {
            int count = followUpService.getfollowupcontent(followupid,type);
            return write(200, "操作成功!","data",count);
        }catch (Exception e){
            //日志文件中记录异常信息
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "操作失败!");
        }
    }
}

+ 79 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/DoctorPrescriptionFollowupContentController.java

@ -35,9 +35,9 @@ public class DoctorPrescriptionFollowupContentController extends BaseController
	@RequestMapping(value = "/getinfo", method = RequestMethod.GET)
	@ApiOperation("根据续方CODE、类型CODE,获取随访调查分类数据")
	public String getinfoByPrescriptionCodeAndFollowupProject(
			@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "续方CODE")
			@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "")
			@RequestParam(value = "prescriptioncode", required = true) String prescriptioncode,
			@ApiParam(name = "followupProject", value = "续方CODE", defaultValue = "问卷类型(症状、体征和问卷)")
			@ApiParam(name = "followupProject", value = "问卷类型(症状、体征和问卷)", defaultValue = "")
			@RequestParam(value = "followupProject", required = true) String followupProject){
		try {
			
@ -64,11 +64,11 @@ public class DoctorPrescriptionFollowupContentController extends BaseController
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	@ApiOperation("根据续方CODE获取随访调查问卷列表")
	public String getList(
			@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "续方CODE")
			@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "")
			@RequestParam(value = "prescriptioncode", required = true) String prescriptioncode){
		try {
			JSONArray result = prescriptionFollowupContentService.getList(prescriptioncode);
			return write(200, "请求成功!");
			return write(200, "请求成功!","data",result);
		}catch (Exception e){
			//日志文件中记录异常信息
			error(e);
@ -76,4 +76,79 @@ public class DoctorPrescriptionFollowupContentController extends BaseController
			return error(-1, "请求失败!"+e.getMessage());
		}
	}
	
	@RequestMapping(value = "/importdrugs", method = RequestMethod.POST)
	@ApiOperation("续方药品导入随访记录")
	public String importPrescriptionDrugsToFollowup(
			@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "")
			@RequestParam(value = "prescriptioncode", required = true) String prescriptioncode,
			@ApiParam(name = "followupid", value = "随访ID", defaultValue = "")
			@RequestParam(value = "followupid", required = true) String followupid){
		try {
			prescriptionFollowupContentService.importPrescriptionDrugsToFollowup(prescriptioncode,followupid);
			return write(200, "操作成功!");
		}catch (Exception e){
			//日志文件中记录异常信息
			error(e);
			//返回接口异常信息处理结果
			return error(-1, "操作失败!");
		}
	}
	
	@RequestMapping(value = "/importbloodsugar", method = RequestMethod.POST)
	@ApiOperation("续方患者的血糖导入随访记录")
	public String importPatientBloodSugarToFollowup(
			@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "")
			@RequestParam(value = "prescriptioncode", required = true) String prescriptioncode,
			@ApiParam(name = "followupid", value = "随访ID", defaultValue = "")
			@RequestParam(value = "followupid", required = true) String followupid){
		try {
			prescriptionFollowupContentService.importPatientBloodSugarToFollowup(prescriptioncode,followupid,false);
			return write(200, "操作成功!");
		}catch (Exception e){
			//日志文件中记录异常信息
			error(e);
			//返回接口异常信息处理结果
			return error(-1, "操作失败!");
		}
	}
	
	@RequestMapping(value = "/importbloodpressure", method = RequestMethod.POST)
	@ApiOperation("续方患者的血压导入随访记录")
	public String importPatientBloodPressureToFollowup(
			@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "")
			@RequestParam(value = "prescriptioncode", required = true) String prescriptioncode,
			@ApiParam(name = "followupid", value = "随访ID", defaultValue = "")
			@RequestParam(value = "followupid", required = true) String followupid){
		try {
			prescriptionFollowupContentService.importPatientBloodPressureToFollowup(prescriptioncode,followupid,false);
			return write(200, "操作成功!");
		}catch (Exception e){
			//日志文件中记录异常信息
			error(e);
			//返回接口异常信息处理结果
			return error(-1, "操作失败!");
		}
	}
	
	@RequestMapping(value = "/importfollowupcontent", method = RequestMethod.POST)
	@ApiOperation("续方患者的血压导入随访记录")
	public String importfollowupcontent(
			@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "")
			@RequestParam(value = "prescriptioncode", required = true) String prescriptioncode,
			@ApiParam(name = "followupid", value = "随访ID", defaultValue = "")
			@RequestParam(value = "followupid", required = true) String followupid,
			@ApiParam(name = "type", value = "问卷类型:1身份异常症状问卷,2体征及生活方式调查问卷", defaultValue = "")
			@RequestParam(value = "type", required = true) String type){
		try {
			prescriptionFollowupContentService.importfollowupcontent(prescriptioncode,followupid,type);
			return write(200, "操作成功!");
		}catch (Exception e){
			//日志文件中记录异常信息
			error(e);
			//返回接口异常信息处理结果
			return error(-1, "操作失败!");
		}
	}
}

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthController.java

@ -471,11 +471,11 @@ public class PatientHealthController extends BaseController {
            JSONArray jsonArray = new JSONArray();
            if (type == 1) {
                List<Object> list = healthIndexService.findIndexByPatient2(getRepUID(), type, start, end, page, pagesize);
//                List<Object> list = healthIndexService.findIndexByPatient2(getUID(), type, start, end, page, pagesize);
//                List<Object> list = healthIndexService.findIndexByPatient2("ec7572875d27446cb4f067b13a85d72a", type, start, end, page, pagesize);
                jsonArray = new JSONArray(list);
            } else {
                jsonArray = healthIndexService.findIndexByPatient(getRepUID(), type, start, end, page, pagesize);
//                List<DevicePatientHealthIndex> list = healthIndexService.findIndexByPatient(getUID(), type, start, end, page, pagesize);
//                List<DevicePatientHealthIndex> list = healthIndexService.findIndexByPatient("ec7572875d27446cb4f067b13a85d72a", type, start, end, page, pagesize);
            }

+ 4 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionFollowupContentController.java

@ -63,9 +63,11 @@ public class PatientPrescriptionFollowupContentController extends BaseController
	public String saveInfo(@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "续方CODE")
	                       @RequestParam(value = "prescriptioncode", required = true) String prescriptioncode,
	                       @ApiParam(name = "followupProjectData", value = "调查分类数据", defaultValue = "[{\"followupProject\":\"1\",\"projectData\":{\"WEIGHT\":\"76\",\"WEIGHT_EXP\":\"60\",\"BMI\":\"11\"}}]")
	                       @RequestParam(value = "followupProjectData", required = true) String followupProjectData){
	                       @RequestParam(value = "followupProjectData", required = true) String followupProjectData,
	                       @ApiParam(name = "sendIM", value = "是否发送IM消息", defaultValue = "false")
	                       @RequestParam(value = "sendIM", required = true) boolean sendIM){
		try {
			prescriptionFollowupContentService.saveInfo(prescriptioncode,followupProjectData,getUID());
			prescriptionFollowupContentService.saveInfo(prescriptioncode,followupProjectData,getUID(),false);
			return write(200, "请求成功!");
		}catch (Exception e){
			//日志文件中记录异常信息