|
@ -1,10 +1,7 @@
|
|
|
package com.yihu.wlyy.service.app.device;
|
|
|
|
|
|
import com.yihu.device.entity.DeviceDetail;
|
|
|
import com.yihu.wlyy.entity.device.Device;
|
|
|
import com.yihu.wlyy.entity.device.PatientBloodSugger;
|
|
|
import com.yihu.wlyy.entity.device.PatientDevice;
|
|
|
import com.yihu.wlyy.entity.device.PatientHealthTime;
|
|
|
import com.yihu.wlyy.entity.device.*;
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
|
|
|
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
|
|
@ -15,6 +12,7 @@ import com.yihu.wlyy.health.repository.DeviceDetailDao;
|
|
|
import com.yihu.wlyy.repository.deviece.DeviceDao;
|
|
|
import com.yihu.wlyy.repository.deviece.PatientBloodSuggerDao;
|
|
|
import com.yihu.wlyy.repository.deviece.PatientHealthTimeDao;
|
|
|
import com.yihu.wlyy.repository.deviece.WlyyDeviceDetailDao;
|
|
|
import com.yihu.wlyy.repository.dict.Icd10DictDao;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamMemberDao;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
@ -66,6 +64,9 @@ public class PatientDeviceService extends BaseService {
|
|
|
@Autowired
|
|
|
private PatientDeviceDao patientDeviceDao;
|
|
|
|
|
|
@Autowired
|
|
|
private WlyyDeviceDetailDao wlyyWlyyDeviceDetailDao;
|
|
|
|
|
|
@Autowired
|
|
|
private DeviceDao deviceDao;
|
|
|
@Autowired
|
|
@ -1157,7 +1158,7 @@ public class PatientDeviceService extends BaseService {
|
|
|
|
|
|
public Map<String,Object> getDeviceByDeviceSn(String deviceSn)throws Exception {
|
|
|
Map<String,Object> map = new HashedMap();
|
|
|
String sql = "SELECT d.id,d.device_name deviceName,d.device_model deviceMode,d.device_activity_type devityActivityType,e.is_multi_user isMultiUser,e.category_code as deviceType,e.multi_user multiUser FROM device.wlyy_devices d LEFT JOIN wlyy.dm_device e ON d.device_model = e.model WHERE d.device_code='"+deviceSn+"'";
|
|
|
String sql = "SELECT d.id,d.device_name deviceName,d.device_model deviceMode,d.device_activity_type deviceActivityType,e.is_multi_user isMultiUser,e.category_code as deviceType,e.multi_user multiUser FROM wlyy_devices d LEFT JOIN dm_device e ON d.device_model = e.model WHERE d.device_code='"+deviceSn+"'";
|
|
|
List<Map<String,Object>> mapSqlList = jdbcTemplate.queryForList(sql);
|
|
|
if (mapSqlList!=null && mapSqlList.size()>0){
|
|
|
map = mapSqlList.get(0);
|
|
@ -1178,21 +1179,15 @@ public class PatientDeviceService extends BaseService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
public boolean isFirstNewBinding(String deviceSn,String patientId){
|
|
|
public boolean isFirstNewBinding(String deviceSn,String userType){
|
|
|
boolean flag = true;
|
|
|
List<PatientDevice> patientDeviceList = patientDeviceDao.findByPatientAndDeviceSn(patientId,deviceSn);
|
|
|
if (patientDeviceList!=null && patientDeviceList.size()>0){
|
|
|
flag = false;//已经有绑定记录,不是首绑
|
|
|
}else {
|
|
|
String sql = "SELECT device_activity_type as deviceActivityType FROM device.wlyy_devices WHERE device_code= "+deviceSn;
|
|
|
Map<String,Object> map = jdbcTemplate.queryForMap(sql);
|
|
|
if (map==null){
|
|
|
flag = false;//获取不到设备信息
|
|
|
}else {
|
|
|
if (map.get("deviceActivityType")==null){
|
|
|
flag = false;//不是可以加积分的涉笔
|
|
|
}
|
|
|
com.yihu.wlyy.entity.device.DeviceDetail deviceDetail = wlyyWlyyDeviceDetailDao.findByDeviceSn(deviceSn);
|
|
|
if (deviceDetail!=null){
|
|
|
JSONObject jsonObject =new JSONObject(deviceDetail.getBindingCount());
|
|
|
if (jsonObject.getInt(userType)>0){
|
|
|
flag=false;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
return flag;
|
|
|
}
|
|
@ -1219,7 +1214,7 @@ public class PatientDeviceService extends BaseService {
|
|
|
if ("10000".equals(code) || "10001".equals(code)) {
|
|
|
flag = true;
|
|
|
}else {
|
|
|
String sql ="select * from device.wlyy_devices where device_code = '"+deviceSn+"'";
|
|
|
String sql ="select * from wlyy_devices where device_code = '"+deviceSn+"'";
|
|
|
Map<String,Object> map = jdbcTemplate.queryForMap(sql);
|
|
|
if (map!=null && map.size()>0){
|
|
|
if (patientDeviceDao.findByDeviceSn(deviceSn)==null){
|
|
@ -1240,4 +1235,56 @@ public class PatientDeviceService extends BaseService {
|
|
|
map.put("flag",flag);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
public Map<String,Object> getPatientDeviceTaskInfo(String patientCode)throws Exception{
|
|
|
Map<String,Object> resultMap = new HashedMap();
|
|
|
String sql = "SELECT d.binding_count,pd.user_type FROM wlyy_patient_device pd LEFT JOIN wlyy_devices d ON pd.device_sn = d.device_code where pd.del=0 and pd.user='"+patientCode+"'";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
int count = 0;
|
|
|
//查询一共绑定了多少个设备
|
|
|
for (Map<String,Object> map : list){
|
|
|
if (map.get("binding_count")!=null){
|
|
|
JSONObject jsonObject = new JSONObject(String.valueOf(map.get("binding_count")));
|
|
|
Set<String> keyset = jsonObject.keySet();
|
|
|
for (String key : keyset){
|
|
|
if (key.equals(String.valueOf(map.get("user_type"))) && jsonObject.getInt(key)==1){
|
|
|
count++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
resultMap.put("deviceCount",count);
|
|
|
|
|
|
//体征上传表查询是否有今天的数据
|
|
|
int healthBp = 0;
|
|
|
int healthBs = 0;
|
|
|
int resultHealty= 0;
|
|
|
boolean hasUploadHealth = false;
|
|
|
String today = DateUtil.dateToStr(DateUtil.getDateShort(new Date()),"yyyy-MM-dd");
|
|
|
String healthSql ="SELECT type as healtyType,device_sn deviceSn FROM device.wlyy_patient_health_index where czrq >'"+today+" 00:00:00' and czrq<='"+today+" 23:59:59' and status = 0 and del = 1 and user = '"+patientCode+"'";
|
|
|
List<Map<String,Object>> maps =jdbcTemplate.queryForList(healthSql);
|
|
|
for (Map<String,Object> map : maps){
|
|
|
if (map.get("type")!=null && String.valueOf(map.get("Type")).equals("1")){
|
|
|
//血糖
|
|
|
healthBs=1;
|
|
|
}
|
|
|
if (map.get("type")!=null && String.valueOf(map.get("Type")).equals("2")){
|
|
|
//血压
|
|
|
healthBp=1;
|
|
|
}
|
|
|
}
|
|
|
if (healthBp==1 && healthBs ==0){
|
|
|
resultHealty =1;
|
|
|
}
|
|
|
if (healthBs ==1 && healthBp==0){
|
|
|
resultHealty = 2;
|
|
|
}
|
|
|
if (healthBp ==1 && healthBs ==1){
|
|
|
resultHealty = 3;
|
|
|
}
|
|
|
resultMap.put("resultHealty",resultHealty);
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
}
|