|
@ -3,24 +3,26 @@ package com.yihu.jw.hospital.module.health.service.scheme;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.device.dao.DevicePatientHealthIndexDao;
|
|
|
import com.yihu.jw.device.dao.PatientAimBloodPressureDao;
|
|
|
import com.yihu.jw.device.dao.PatientAimBloodSuggerDao;
|
|
|
import com.yihu.jw.device.dao.PatientAimSportsDao;
|
|
|
import com.yihu.jw.device.dao.*;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
|
import com.yihu.jw.entity.base.device.PatientAimBloodPressure;
|
|
|
import com.yihu.jw.entity.base.device.PatientAimBloodSugger;
|
|
|
import com.yihu.jw.entity.base.device.PatientAimSports;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.care.device.DevicePatientDevice;
|
|
|
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
|
|
|
import com.yihu.jw.entity.door.WlyySign;
|
|
|
import com.yihu.jw.entity.scheme.*;
|
|
|
import com.yihu.jw.entity.scheme.vo.DoctorSchemeBloodPressureVO;
|
|
|
import com.yihu.jw.entity.scheme.vo.DoctorSchemeBloodSuggerVO;
|
|
|
import com.yihu.jw.hospital.module.health.dao.*;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.restmodel.patient.PatientVO;
|
|
|
import com.yihu.jw.sign.dao.WlyySignDao;
|
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.wlyy.wlyyhttp.WlyyHttpService;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
@ -78,19 +80,147 @@ public class DoctorSchemeService {
|
|
|
|
|
|
@Autowired
|
|
|
private PatientAimBloodPressureDao patientAimBloodPressureDao;
|
|
|
|
|
|
@Autowired
|
|
|
private WlyyHttpService wlyyHttpService;
|
|
|
@Autowired
|
|
|
private DoctorSwitchDao doctorSwitchDao;
|
|
|
|
|
|
@Autowired
|
|
|
private WlyySignDao wlyySignDao;
|
|
|
@Autowired
|
|
|
private TrackPatientDao trackPatientDao;
|
|
|
|
|
|
@Autowired
|
|
|
private PatientDeviceDao patientDeviceDao;
|
|
|
@Autowired
|
|
|
private PatientAimSportsDao patientAimSportsDao;
|
|
|
|
|
|
@Value("${im.data_base_name}")
|
|
|
private String im_dataBase_name;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 健康画像统计-线上服务
|
|
|
* 1、健康咨询次数 = 该居民发起并完成的图文咨询+视频咨询次数总和;
|
|
|
* 2、在线复诊次数 = 该居民发起并完成的图文复诊+视频复诊次数总和;
|
|
|
* 3、在线处方次数 = 该居民通过图文复诊、视频复诊收到并完成支付的处方数量;
|
|
|
* 4、上转(基层)次数 = 该居民的家庭医生通过i健康为该居民代预约等级医院的次数总和;
|
|
|
* 5、下转(基层)次数 = 三院医生为该居民康复下转至社区的次数总和;
|
|
|
* 6、远程协诊发起次数 = 该居民通过社区发起专科协统的次数总和。
|
|
|
*/
|
|
|
public JSONObject healthDataStatic(String patient){
|
|
|
JSONObject json = new JSONObject();
|
|
|
String sql = "SELECT count(if(outpatient_type='3',1,null)) zxNum,count(if(outpatient_type='1',1,null)) fzNum" +
|
|
|
" from wlyy_outpatient where patient='"+patient+"'";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
String sql2 = "select count(1) from wlyy_prescription where patient_code='"+patient+"' and status>=30 ";
|
|
|
int preNum = jdbcTemplate.queryForObject(sql2,Integer.class);
|
|
|
|
|
|
json.put("zxNum",list.get(0).get("zxNum"));//健康咨询次数
|
|
|
json.put("fzNum",list.get(0).get("fzNum"));//在线复诊次数
|
|
|
json.put("preNum",preNum);//在线处方次数
|
|
|
int turnUpNum=0;//上转(基层)次数
|
|
|
int turnDownNum=0;//下转(基层)次数
|
|
|
int coNum=0;//下转(基层)次数
|
|
|
//请求i健康
|
|
|
try{
|
|
|
BasePatientDO patientDO = patientDao.findByIdAndDel(patient,"1");
|
|
|
String configId = "commonGet";
|
|
|
String param = "?idcard="+patientDO.getIdcard();
|
|
|
JSONObject re = wlyyHttpService.sendWlyyMesGet(configId, "healthDataStatic" + param);
|
|
|
if(re!=null&&re.getInteger("status")==200){
|
|
|
JSONObject data = re.getJSONObject("data");
|
|
|
turnUpNum = data.getInteger("turnUpNum");
|
|
|
turnDownNum = data.getInteger("turnDownNum");
|
|
|
coNum = data.getInteger("coNum");
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
json.put("turnUpNum",turnUpNum);//上转(基层)次数
|
|
|
json.put("turnDownNum",turnDownNum);//下转(基层)次数
|
|
|
json.put("coNum",coNum);//下转(基层)次数
|
|
|
return json;
|
|
|
}
|
|
|
|
|
|
//健康画像
|
|
|
public JSONObject healthData(String patient){
|
|
|
JSONObject json = new JSONObject();
|
|
|
BasePatientDO patientDO = patientDao.findByIdAndDel(patient,"1");
|
|
|
json.put("id",patientDO.getId());//居民id
|
|
|
json.put("name",patientDO.getName());//姓名
|
|
|
json.put("idcard",patientDO.getIdcard());//身份证
|
|
|
json.put("mobile",patientDO.getMobile());//手机号
|
|
|
json.put("photo",patientDO.getPhoto());//头像
|
|
|
json.put("sex",patientDO.getSex());//性别
|
|
|
json.put("birthday",DateUtil.dateToStrShort(patientDO.getBirthday()));//出生日期
|
|
|
json.put("age", IdCardUtil.getAgeByIdcardOrBirthday(patientDO.getIdcard(),patientDO.getBirthday()));//年龄
|
|
|
|
|
|
String isDrug = "0";
|
|
|
String sql2 = "select count(1) from wlyy_prescription where patient_code='"+patient+"' ";
|
|
|
int preNum = jdbcTemplate.queryForObject(sql2,Integer.class);
|
|
|
if(preNum>0){
|
|
|
isDrug = "1";
|
|
|
}
|
|
|
String sql3 = "select count(1) from wlyy_patient_rehabilitation_plan where patient='"+patient+"' ";
|
|
|
String isZb = "0";
|
|
|
int zbNum = jdbcTemplate.queryForObject(sql3,Integer.class);
|
|
|
if(zbNum>0){
|
|
|
isZb = "1";
|
|
|
}
|
|
|
json.put("isZb",isZb);//是否专病 1是0否
|
|
|
json.put("isDrug",isDrug);//是否用药 1是0否
|
|
|
|
|
|
String xtDevice = "0";//
|
|
|
String xyDevice = "1";//
|
|
|
List<DevicePatientDevice> deviceList = patientDeviceDao.findByPatient(patient);
|
|
|
for (DevicePatientDevice device:deviceList){
|
|
|
if("1".equals(device.getCategoryCode())){
|
|
|
xtDevice = "1";
|
|
|
}
|
|
|
if("2".equals(device.getCategoryCode())){
|
|
|
xyDevice = "1";
|
|
|
}
|
|
|
}
|
|
|
String isSign = "0";//
|
|
|
String doctorName = "";//
|
|
|
String hospitalName = "";//
|
|
|
WlyySign sign = wlyySignDao.findByPatient(patient);
|
|
|
if(sign!=null&&"1".equals(sign.getStatus())){
|
|
|
isSign = "1";
|
|
|
doctorName = sign.getDoctorName();
|
|
|
hospitalName = sign.getHospitalName();
|
|
|
}
|
|
|
json.put("xtDevice",xtDevice);//是否绑定血糖仪 1是0否
|
|
|
json.put("xyDevice",xyDevice);//是否绑定血压计 1是0否
|
|
|
json.put("isSign",isSign);//是否签约家庭医生 1是0否
|
|
|
json.put("doctorName",doctorName);//家庭医生
|
|
|
json.put("hospitalName",hospitalName);//签约社区
|
|
|
String sql1 = "SELECT DISTINCT dept_name from wlyy_outpatient where patient='"+patient+"' order by create_time desc LIMIT 4";
|
|
|
List<Map<String,Object>> deptList = jdbcTemplate.queryForList(sql1);
|
|
|
json.put("deptList",deptList);//门诊科室
|
|
|
|
|
|
DevicePatientHealthIndex healthIndex1 = findLatelyIndex(patient,"1");
|
|
|
DevicePatientHealthIndex healthIndex2 = findLatelyIndex(patient,"2");
|
|
|
DevicePatientHealthIndex healthIndex3 = findLatelyIndex(patient,"3");
|
|
|
json.put("healthIndex1",healthIndex1);//最近一次血糖数据
|
|
|
json.put("healthIndex2",healthIndex2);//最近一次血压数据
|
|
|
json.put("healthIndex3",healthIndex3);//最近一次身高体征数据
|
|
|
|
|
|
|
|
|
String labelSql = "SELECT label_name disease from wlyy_patient_label WHERE patient = '"+patient+"' and label_type='2' ";
|
|
|
List<Map<String,Object>> diseaseList = jdbcTemplate.queryForList(labelSql);
|
|
|
json.put("diseaseList",diseaseList);//慢病类型
|
|
|
|
|
|
String zbSql = "SELECT distinct disease_name zbName from wlyy_patient_rehabilitation_plan WHERE patient = '"+patient+"' and status='1' ";
|
|
|
List<Map<String,Object>> zbList = jdbcTemplate.queryForList(labelSql);
|
|
|
json.put("zbList",zbList);//专病类型
|
|
|
|
|
|
String sql5 = "SELECT DISTINCT doctor_name from wlyy_outpatient where patient='"+patient+"' order by create_time desc LIMIT 6";
|
|
|
List<Map<String,Object>> doctorList = jdbcTemplate.queryForList(sql5);
|
|
|
json.put("doctorList",doctorList);//专科医生
|
|
|
|
|
|
return json;
|
|
|
}
|
|
|
|
|
|
//取消重点关注
|
|
|
public void delTrack(String patient,String doctor){
|
|
|
synchronized (patient.intern()){
|