瀏覽代碼

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

chenweida 7 年之前
父節點
當前提交
e80be5dd07

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

@ -2630,16 +2630,14 @@ public class ConsultTeamService extends ConsultService {
     * @param prescriptionCode
     * @param type
     */
    public org.json.JSONArray addPrescriptionBloodStatusConsult(String prescriptionCode, String type,String followupid) throws Exception {
        org.json.JSONArray result = new JSONArray();
    public void addPrescriptionBloodStatusConsult(String prescriptionCode, String type,String followupid) throws Exception {
        
        if("1".equals(type)){//血压
            result = prescriptionFollowupContentService.importPatientBloodPressureToFollowup(prescriptionCode,followupid,true);
            prescriptionFollowupContentService.importPatientBloodPressureToFollowup(prescriptionCode,followupid,true);
        }else if("2".equals(type)){//血糖
            result = prescriptionFollowupContentService.importPatientBloodSugarToFollowup(prescriptionCode,followupid,true);
            prescriptionFollowupContentService.importPatientBloodSugarToFollowup(prescriptionCode,followupid,true);
        }
        
        return result;
    }
    
    /**
@ -2647,20 +2645,25 @@ public class ConsultTeamService extends ConsultService {
     * @param prescriptionCode
     * @param type
     */
    public org.json.JSONArray addPrescriptionFollowupContentConsult(String prescriptionCode, String type, String followupid) throws Exception {
    public void addPrescriptionFollowupContentConsult(String prescriptionCode, String type, String followupid) throws Exception {
        Prescription prescription = prescriptionDao.findByCode(prescriptionCode);
        org.json.JSONObject contentDoctor = new org.json.JSONObject();
        org.json.JSONObject contentobj = new org.json.JSONObject();
        //医生发送的消息
        if("1".equals(type)){
            contentDoctor.put("text", "请填写您近期身份异常症状问卷");
            contentobj.put("text","请填写您近期身份异常症状问卷");
        }else{
            contentDoctor.put("text", "请填写您近期体征及生活方式调查问卷");
        }
        contentDoctor.put("msgType",type);
            contentobj.put("text","请填写您近期体征及生活方式调查问卷");
        }
        contentobj.put("doctorremind","已向居民发送问卷填写请求,填写完成后您将收到消息提醒");
        contentobj.put("patientremind","填写完成并提交后,医生将可以查看您的问卷内容");
        contentobj.put("sender_id",prescription.getDoctor());
        contentobj.put("sender_name",prescription.getDoctorName());
        contentobj.put("content_type","17");
        contentobj.put("msgType",type);
        //医生发送Im消息
        ImUtill.sendTopicIM(prescription.getDoctor(), prescription.getDoctorName(), prescription.getConsult(), "17", contentDoctor.toString(), null);
        org.json.JSONArray result = new JSONArray();
        result.put(contentDoctor);
        return result;
        ImUtill.sendTopicIM(prescription.getDoctor(), prescription.getDoctorName(), prescription.getConsult(), "17", contentobj.toString(), null);
    
        //居民发送Im消息
        ImUtill.sendTopicIM(prescription.getPatient(), prescription.getPatientName(), prescription.getConsult(), "17", contentobj.toString(), null);
    }
}

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

@ -266,7 +266,7 @@ public class PrescriptionFollowupContentService extends BaseService {
	 * @param prescriptioncode
	 * @param followup_id
	 */
	public org.json.JSONArray importPatientBloodSugarToFollowup(String prescriptioncode, String followup_id,boolean sendIM) throws Exception {
	public void importPatientBloodSugarToFollowup(String prescriptioncode, String followup_id,boolean sendIM) throws Exception {
		Long followupId = Long.valueOf(followup_id);
		
		Followup followup =followUpDao.findOne(followupId);
@ -277,9 +277,9 @@ public class PrescriptionFollowupContentService extends BaseService {
		
		Prescription prescription = prescriptionDao.findByCode(prescriptioncode);
		
		String patientCode = prescription.getParentCode();
		String patientCode = prescription.getPatient();
		
		String stardate = DateUtil.getNextMonth(new Date(),-30)+" 00:00:00";
		String stardate = DateUtil.getNextMonth(new Date(),-1)+" 00:00:00";
		String enddate = DateUtil.getStringDateShort()+" 23:59:59";
		
		List<Object> list = healthIndexService.findIndexByPatient2(patientCode, 1, stardate, enddate, 0, 2);
@ -289,12 +289,11 @@ public class PrescriptionFollowupContentService extends BaseService {
		
		org.json.JSONObject contentDoctor = new org.json.JSONObject();
		org.json.JSONObject contentPatient = new org.json.JSONObject();
		org.json.JSONArray resultJson = new org.json.JSONArray();
		String imBloodSugarValue = "";
		String imBloodSugarDate = "";
		Date imBloodSugarDate = new Date();
		
		int total = 0;
		String sql = "select sum(category_code) amount deviceType FROM wlyy_patient_device WHERE user='"+prescription.getPatient()+"'";
		String sql = "select sum(category_code) amount 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);
@ -309,22 +308,52 @@ public class PrescriptionFollowupContentService extends BaseService {
				
				JSONObject obj = (JSONObject)o;
				
				imBloodSugarDate = obj.getString("recordDate");
				imBloodSugarDate = obj.getDate("recordDate");
				
				int index = Integer.valueOf(obj.getString("value2"));
				String value1 = obj.getString("value1");
				// 餐后
				if (index % 2 == 0) {
					if(StringUtils.isNotBlank(value1)){
						followupProjectData = "{'BS_FPG':'"+obj.getString("value1")+"'}";
						break;
					}
				} else { //餐前
					followupProjectData = "{'NO_BS_FPG':'"+obj.getString("value1")+"'}";
				//餐前
				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);
@ -333,17 +362,21 @@ public class PrescriptionFollowupContentService extends BaseService {
			if(sendIM){
				//医生发送的消息
				contentDoctor.put("text", "请提供您最近一次的血糖检测数值及检测时间");
				contentDoctor.put("needupload",false);
				contentDoctor.put("needUpload","false");
				contentDoctor.put("type",2);
				contentDoctor.put("sender_id",prescription.getDoctor());
				contentDoctor.put("sender_name",prescription.getDoctorName());
				contentDoctor.put("content_type","16");
				
				//医生发送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("tzMsg", "体征记录:血糖 "+imBloodSugarValue+"mmol/L");
				contentPatient.put("tzTime", "检测时间:"+DateUtil.dateToStr(imBloodSugarDate,"yyyy-MM-dd HH:mm:ss"));
				contentPatient.put("tzAlert","温馨提示:本条体征为居民上传的健康体征数据,您可以");
				contentPatient.put("needUpload","false");
				contentPatient.put("type",2);
				
				//患者发送Im消息
@ -354,8 +387,11 @@ public class PrescriptionFollowupContentService extends BaseService {
			if(sendIM){
				//医生发送的消息
				contentDoctor.put("text", "请提供您最近一次的血糖检测数值及检测时间");
				contentDoctor.put("needupload",true);
				contentDoctor.put("needUpload","true");
				contentDoctor.put("type",2);
				contentDoctor.put("sender_id",prescription.getDoctor());
				contentDoctor.put("sender_name",prescription.getDoctorName());
				contentDoctor.put("content_type","16");
				//医生发送Im消息
				ImUtill.sendTopicIM(prescription.getDoctor(), prescription.getDoctorName(), prescription.getConsult(), "16", contentDoctor.toString(), null);
				
@ -364,6 +400,7 @@ public class PrescriptionFollowupContentService extends BaseService {
				contentPatient.put("tzMsg", "体征记录:无");
				contentPatient.put("tzTime", "检测时间:");
				contentPatient.put("tzAlert","温馨提示:居民近30天未上传血糖体征数据,已通知居民上传数据,请耐心等待");
				contentPatient.put("needUpload","true");
				contentPatient.put("type",2);
				
				//患者发送Im消息
@ -372,10 +409,6 @@ public class PrescriptionFollowupContentService extends BaseService {
				throw new Exception("未找到30天内的血糖记录!");
			}
		}
		
		resultJson.put(contentDoctor);
		
		return resultJson;
	}
	
@ -385,7 +418,7 @@ public class PrescriptionFollowupContentService extends BaseService {
	 * @param followup_id
	 * @param sendIM 是否发送IM消息
	 */
	public org.json.JSONArray importPatientBloodPressureToFollowup(String prescriptioncode, String followup_id,boolean sendIM) throws Exception {
	public void importPatientBloodPressureToFollowup(String prescriptioncode, String followup_id,boolean sendIM) throws Exception {
		
		Long followupId = Long.valueOf(followup_id);
		
@ -397,9 +430,9 @@ public class PrescriptionFollowupContentService extends BaseService {
		
		Prescription prescription = prescriptionDao.findByCode(prescriptioncode);
		
		String patientCode = prescription.getParentCode();
		String patientCode = prescription.getPatient();
		
		String stardate = DateUtil.getNextMonth(new Date(),-30)+" 00:00:00";
		String stardate = DateUtil.getNextMonth(new Date(),-1)+" 00:00:00";
		String enddate = DateUtil.getStringDateShort()+" 23:59:59";
		org.json.JSONArray jsonArray = healthIndexService.findIndexByPatient(patientCode, 2, stardate, enddate, 0, 2);
		
@ -408,10 +441,8 @@ public class PrescriptionFollowupContentService extends BaseService {
		org.json.JSONObject contentDoctor = new org.json.JSONObject();
		org.json.JSONObject contentPatient = new org.json.JSONObject();
		
		org.json.JSONArray resultJson = new org.json.JSONArray();
		
		int total = 0;
		String sql = "select sum(category_code) amount deviceType FROM wlyy_patient_device WHERE user='"+prescription.getPatient()+"'";
		String sql = "select sum(category_code) amount 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);
@ -424,15 +455,18 @@ public class PrescriptionFollowupContentService extends BaseService {
			
			org.json.JSONObject jsonObject = jsonArray.getJSONObject(0);
			
			followupProjectData = "{'BP_D':'"+jsonObject.getString("value1")+"'BP_U':'"+jsonObject.getString("value2")+"'}";
			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);
				contentDoctor.put("needUpload","false");
				contentDoctor.put("type",1);
				contentDoctor.put("sender_id",prescription.getDoctor());
				contentDoctor.put("sender_name",prescription.getDoctorName());
				contentDoctor.put("content_type","16");
				
				//医生发送Im消息
				ImUtill.sendTopicIM(prescription.getDoctor(), prescription.getDoctorName(), prescription.getConsult(), "16", contentDoctor.toString(), null);
@ -442,6 +476,7 @@ public class PrescriptionFollowupContentService extends BaseService {
				contentPatient.put("tzMsg", "体征记录:血压"+jsonObject.getString("value1")+"/"+jsonObject.getString("value2")+" mmHg");
				contentPatient.put("tzTime", "检测时间:"+jsonObject.getString("date"));
				contentPatient.put("tzAlert","温馨提示:本条体征为居民上传的健康体征数据,您可以");
				contentPatient.put("needUpload","false");
				contentPatient.put("type",1);
				
				//患者发送Im消息
@ -453,8 +488,11 @@ public class PrescriptionFollowupContentService extends BaseService {
				
				//医生发送的消息
				contentDoctor.put("text", "请提供您最近一次的血压检测数值及检测时间");
				contentDoctor.put("needUpload",true);
				contentDoctor.put("needUpload","true");
				contentDoctor.put("type",1);
				contentDoctor.put("sender_id",prescription.getDoctor());
				contentDoctor.put("sender_name",prescription.getDoctorName());
				contentDoctor.put("content_type","16");
				//医生发送Im消息
				ImUtill.sendTopicIM(prescription.getDoctor(), prescription.getDoctorName(), prescription.getConsult(), "16", contentDoctor.toString(), null);
				
@ -463,6 +501,7 @@ public class PrescriptionFollowupContentService extends BaseService {
				contentPatient.put("tzMsg", "体征记录:无");
				contentPatient.put("tzTime", "检测时间:");
				contentPatient.put("tzAlert","温馨提示:居民近30天未上传血压体征数据,已通知居民上传数据,请耐心等待");
				contentPatient.put("needUpload","true");
				contentPatient.put("type",1);
				
				//患者发送Im消息
@ -471,11 +510,6 @@ public class PrescriptionFollowupContentService extends BaseService {
				throw new Exception("未找到30天内的血压记录!");
			}
		}
		
		resultJson.put(contentDoctor);
		
		return resultJson;
	
	}
	
@ -525,7 +559,7 @@ public class PrescriptionFollowupContentService extends BaseService {
			}
			//近30天血压
			String stardate = DateUtil.getNextMonth(new Date(),-30)+" 00:00:00";
			String stardate = DateUtil.getNextMonth(new Date(),-1)+" 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){

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

@ -1155,8 +1155,8 @@ public class DoctorConsultController extends WeixinBaseController {
            @ApiParam(name = "followupid", value = "随访记录ID", defaultValue = "")
            @RequestParam(value = "followupid", required = true) String followupid){
        try{
            org.json.JSONArray result  = consultTeamService.addPrescriptionBloodStatusConsult(prescriptionCode,type,followupid);
            return write(200, "添加成功!","data",result);
            consultTeamService.addPrescriptionBloodStatusConsult(prescriptionCode,type,followupid);
            return write(200, "添加成功!");
        }catch (Exception e){
            error(e);
            return error(-1,"添加失败");
@ -1175,8 +1175,8 @@ public class DoctorConsultController extends WeixinBaseController {
            @ApiParam(name = "followupid", value = "随访记录ID", defaultValue = "")
            @RequestParam(value = "followupid", required = true) String followupid){
        try{
            org.json.JSONArray result = consultTeamService.addPrescriptionFollowupContentConsult(prescriptionCode,type,followupid);
            return write(200, "添加成功!","data",result);
            consultTeamService.addPrescriptionFollowupContentConsult(prescriptionCode,type,followupid);
            return write(200, "添加成功!");
        }catch (Exception e){
            error(e);
            return error(-1,"添加失败");