Browse Source

续方咨询,随访相关接口BUG修改

huangwenjie 7 years ago
parent
commit
d9dd0b4dd5

+ 1 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java

@ -922,6 +922,7 @@ public class DeviceService {
                contentPatient.put("tzTime", "检测时间:"+DateUtil.dateToStrLong(result.getRecordDate()));
                contentPatient.put("tzAlert","温馨提示:本条体征为居民上传的健康体征数据,您可以");
                contentPatient.put("needUpload","false");
                contentPatient.put("healthindexid",result.getId());//体征记录 ID
            
                //患者发送Im消息
                ImUtill.sendTopicIM(patient.getCode(), patient.getName(), consultTeam.getConsult(), "16", contentPatient.toString(), null);

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

@ -624,42 +624,49 @@ public class PatientHealthIndexService extends BaseService {
                        obj.put("value1", data);
                        obj.put("time1", recordDate);
                        obj.put("id1", id);
                        obj.put("healthindexid", id);
                        obj.put("deviceSn1", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("2")) {
                        obj.put("value2", data);
                        obj.put("time2", recordDate);
                        obj.put("id2", id);
                        obj.put("healthindexid", id);
                        obj.put("deviceSn2", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("3")) {
                        obj.put("value3", data);
                        obj.put("time3", recordDate);
                        obj.put("id3", id);
                        obj.put("healthindexid", id);
                        obj.put("deviceSn3", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("4")) {
                        obj.put("value4", data);
                        obj.put("time4", recordDate);
                        obj.put("id4", id);
                        obj.put("healthindexid", id);
                        obj.put("deviceSn4", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("5")) {
                        obj.put("value5", data);
                        obj.put("time5", recordDate);
                        obj.put("id5", id);
                        obj.put("healthindexid", id);
                        obj.put("deviceSn5", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("6")) {
                        obj.put("value6", data);
                        obj.put("time6", recordDate);
                        obj.put("id6", id);
                        obj.put("healthindexid", id);
                        obj.put("deviceSn6", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("7")) {
                        obj.put("value7", data);
                        obj.put("time7", recordDate);
                        obj.put("id7", id);
                        obj.put("healthindexid", id);
                        obj.put("deviceSn7", deviceSn);
                        hadData = true;
                    }
@ -934,6 +941,7 @@ public class PatientHealthIndexService extends BaseService {
                contentPatient.put("tzTime", "检测时间:"+DateUtil.dateToStrLong(result.getRecordDate()));
                contentPatient.put("tzAlert","温馨提示:本条体征为居民上传的健康体征数据,您可以");
                contentPatient.put("needUpload","false");
                contentPatient.put("healthindexid",result.getId());//体征记录 ID
                
                //患者发送Im消息
                ImUtill.sendTopicIM(patient.getCode(), patient.getName(), consultTeam.getConsult(), "16", contentPatient.toString(), null);
@ -1204,6 +1212,7 @@ public class PatientHealthIndexService extends BaseService {
            for (Map<String, Object> map : list) {
                JSONObject json = new JSONObject();
                json.put("id", map.get("id"));
                json.put("healthindexid", map.get("id"));
                json.put("patient", map.get("user"));
                json.put("value1", map.get("value1"));
                json.put("value2", map.get("value2"));

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

@ -300,8 +300,10 @@ public class PrescriptionFollowupContentService extends BaseService {
		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) {
			Double amount = new Double(result.get(0).get("amount").toString());
			total = (result.get(0).get("amount") != null ? amount.intValue() : 0);
			if(result.get(0).get("amount") != null){
				Double amount = new Double(result.get(0).get("amount").toString());
				total = (result.get(0).get("amount") != null ? amount.intValue() : 0);
			}
		}
		if(total != 1 || total != 3){
			contentDoctor.put("deviceMsg","您未绑定血糖智能设备,请手动上传体征数据,绑定设备后系统将会自动将您的体征数据上报给医生");
@ -402,6 +404,8 @@ public class PrescriptionFollowupContentService extends BaseService {
				contentPatient.put("isSendWxTemplate",false);//是否发送咨询回复的微信模板
				contentPatient.put("needUpload","false");
				contentPatient.put("type",2);
				contentPatient.put("healthindexid",obj.getString("healthindexid"));
				
				
				//患者发送Im消息
				ImUtill.sendTopicIM(prescription.getPatient(), prescription.getPatientName(), prescription.getConsult(), "16", contentPatient.toString(), null);
@ -467,7 +471,7 @@ public class PrescriptionFollowupContentService extends BaseService {
			
			if(devicePatientHealthIndex != null){
				org.json.JSONObject json = new org.json.JSONObject();
				json.put("id", devicePatientHealthIndex.getId());
				json.put("healthindexid", devicePatientHealthIndex.getId());
				json.put("patient",devicePatientHealthIndex.getUser());
				json.put("value1", devicePatientHealthIndex.getValue1());
				json.put("value2", devicePatientHealthIndex.getValue2());
@ -502,8 +506,10 @@ public class PrescriptionFollowupContentService extends BaseService {
		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) {
			Double amount = new Double(result.get(0).get("amount").toString());
			total = (result.get(0).get("amount") != null ? amount.intValue() : 0);
			if(result.get(0).get("amount") != null){
				Double amount = new Double(result.get(0).get("amount").toString());
				total = (result.get(0).get("amount") != null ? amount.intValue() : 0);
			}
		}
		if(total != 2 || total != 3){
			contentDoctor.put("deviceMsg","您未绑定血压智能设备,请手动上传体征数据,绑定设备后系统将会自动将您的体征数据上报给医生");
@ -546,6 +552,7 @@ public class PrescriptionFollowupContentService extends BaseService {
				contentPatient.put("needUpload","false");
				contentPatient.put("isSendWxTemplate",false);//是否发送咨询回复的微信模板
				contentPatient.put("type",1);
				contentPatient.put("healthindexid",jsonObject.get("healthindexid"));
				
				//患者发送Im消息
				ImUtill.sendTopicIM(prescription.getPatient(), prescription.getPatientName(), prescription.getConsult(), "16", contentPatient.toString(), null);
@ -617,38 +624,54 @@ public class PrescriptionFollowupContentService extends BaseService {
		}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());
					if(StringUtils.isNotBlank(prescriptionFollowupContent.getFollowupValue())){
						datamap2.put(prescriptionFollowupContent.getFollowupKey(),prescriptionFollowupContent.getFollowupValue());
					}
				}
			}
			//近30天血压
			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){
				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));
			
			//判断随访中是否已经有体征的相关数据
			FollowupContentESDO followupContentESDO = followUpService.esGetFollowupProjectData(followup_id,"2");
			if(followupContentESDO == null){
				//如果没有,则自动获取近30天的血压
				//近30天血压
				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){
					org.json.JSONObject jsonObject = jsonArray.getJSONObject(0);
					datamap2.put("BP_D",jsonObject.getString("value1"));
					datamap2.put("BP_U",jsonObject.getString("value2"));
				}
			}else{
				datamap2.put("BP_D",followupContentESDO.getBP_D());
				datamap2.put("BP_U",followupContentESDO.getBP_U());
			}
			//保存随访体征数据
			if(!datamap2.isEmpty()){
				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: list3) {
					datamap3.put(prescriptionFollowupContent.getFollowupKey(),prescriptionFollowupContent.getFollowupValue());
					if(StringUtils.isNotBlank(prescriptionFollowupContent.getFollowupValue())){
						datamap3.put(prescriptionFollowupContent.getFollowupKey(),prescriptionFollowupContent.getFollowupValue());
					}
				}
			}
			followUpService.esSaveFollowupProjectData(followup_id, "4", JSON.toJSONString(datamap3));
		
			
			//保证生活方式
			if(!datamap3.isEmpty()){
				followUpService.esSaveFollowupProjectData(followup_id, "4", JSON.toJSONString(datamap3));
			}
		}else{}
	}