|
@ -3,11 +3,13 @@ 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.device.entity.DevicePatientHealthIndex;
|
|
|
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.health.repository.DevicePatientHealthIndexDao;
|
|
|
import com.yihu.wlyy.repository.followup.FollowUpDao;
|
|
|
import com.yihu.wlyy.repository.followup.FollowupDrugsDao;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
|
|
@ -55,6 +57,8 @@ public class PrescriptionFollowupContentService extends BaseService {
|
|
|
private ImUtill ImUtill;
|
|
|
@Autowired
|
|
|
JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
|
private DevicePatientHealthIndexDao devicePatientHealthIndexDao;
|
|
|
|
|
|
/**
|
|
|
* 根据续方CODE,文件类型获取数据
|
|
@ -266,7 +270,7 @@ public class PrescriptionFollowupContentService extends BaseService {
|
|
|
* @param prescriptioncode
|
|
|
* @param followup_id
|
|
|
*/
|
|
|
public void importPatientBloodSugarToFollowup(String prescriptioncode, String followup_id,boolean sendIM) throws Exception {
|
|
|
public void importPatientBloodSugarToFollowup(String prescriptioncode, String followup_id,boolean sendIM,String healthindexid) throws Exception {
|
|
|
Long followupId = Long.valueOf(followup_id);
|
|
|
|
|
|
Followup followup =followUpDao.findOne(followupId);
|
|
@ -284,7 +288,6 @@ public class PrescriptionFollowupContentService extends BaseService {
|
|
|
|
|
|
List<Object> list = healthIndexService.findIndexByPatient2(patientCode, 1, stardate, enddate, 0, 2);
|
|
|
|
|
|
|
|
|
String followupProjectData = "";
|
|
|
|
|
|
org.json.JSONObject contentDoctor = new org.json.JSONObject();
|
|
@ -302,58 +305,57 @@ public class PrescriptionFollowupContentService extends BaseService {
|
|
|
contentDoctor.put("deviceMsg","您未绑定血糖智能设备,请手动上传体征数据,绑定设备后系统将会自动将您的体征数据上报给医生");
|
|
|
}
|
|
|
|
|
|
if(!list.isEmpty()){
|
|
|
if(StringUtils.isNotBlank(healthindexid) || !list.isEmpty()){
|
|
|
|
|
|
for (Object o: list) {
|
|
|
|
|
|
JSONObject obj = (JSONObject)o;
|
|
|
|
|
|
imBloodSugarDate = obj.getDate("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;
|
|
|
}
|
|
|
JSONObject obj = new JSONObject();
|
|
|
|
|
|
//如果有传体征ID,则查体征数据
|
|
|
if(StringUtils.isNotBlank(healthindexid)){
|
|
|
DevicePatientHealthIndex devicePatientHealthIndex = devicePatientHealthIndexDao.findOne(new Long(healthindexid));
|
|
|
obj = (JSONObject)JSON.toJSON(devicePatientHealthIndex);
|
|
|
}else{
|
|
|
//如果没传体征ID,则获取最近的一条
|
|
|
obj = (JSONObject)list.get(0);
|
|
|
}
|
|
|
|
|
|
imBloodSugarDate = obj.getDate("recordDate");
|
|
|
|
|
|
//餐前
|
|
|
if(StringUtils.isNotBlank(obj.getString("value1"))){
|
|
|
followupProjectData = "{'BS_FPG':'"+obj.getString("value1")+"'}";
|
|
|
imBloodSugarValue = obj.getString("value1");
|
|
|
}
|
|
|
|
|
|
if(StringUtils.isNotBlank(obj.getString("value3"))){
|
|
|
followupProjectData = "{'BS_FPG':'"+obj.getString("value3")+"'}";
|
|
|
imBloodSugarValue = obj.getString("value3");
|
|
|
}
|
|
|
|
|
|
if(StringUtils.isNotBlank(obj.getString("value5"))){
|
|
|
followupProjectData = "{'BS_FPG':'"+obj.getString("value5")+"'}";
|
|
|
imBloodSugarValue = obj.getString("value5");
|
|
|
}
|
|
|
//餐后
|
|
|
if(StringUtils.isNotBlank(obj.getString("value2"))){
|
|
|
followupProjectData = "{'NO_BS_FPG':'"+obj.getString("value2")+"'}";
|
|
|
imBloodSugarValue = obj.getString("value2");
|
|
|
}
|
|
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(obj.getString("value4"))){
|
|
|
followupProjectData = "{'NO_BS_FPG':'"+obj.getString("value4")+"'}";
|
|
|
imBloodSugarValue = obj.getString("value4");
|
|
|
}
|
|
|
|
|
|
if(StringUtils.isNotBlank(obj.getString("value6"))){
|
|
|
followupProjectData = "{'NO_BS_FPG':'"+obj.getString("value6")+"'}";
|
|
|
imBloodSugarValue = obj.getString("value6");
|
|
|
}
|
|
|
|
|
|
//随机血糖
|
|
|
if(StringUtils.isNotBlank(obj.getString("value7"))){
|
|
|
followupProjectData = "{'RANDOM_BLOOD_SUGAR':'"+obj.getString("value7")+"'}";
|
|
|
imBloodSugarValue = obj.getString("value7");
|
|
|
}
|
|
|
|
|
|
followUpService.esSaveFollowupProjectData(followup_id, "3", followupProjectData);
|
|
@ -416,7 +418,7 @@ public class PrescriptionFollowupContentService extends BaseService {
|
|
|
* @param followup_id
|
|
|
* @param sendIM 是否发送IM消息
|
|
|
*/
|
|
|
public void importPatientBloodPressureToFollowup(String prescriptioncode, String followup_id,boolean sendIM) throws Exception {
|
|
|
public void importPatientBloodPressureToFollowup(String prescriptioncode, String followup_id,boolean sendIM,String healthindexid) throws Exception {
|
|
|
|
|
|
Long followupId = Long.valueOf(followup_id);
|
|
|
|
|
@ -432,7 +434,41 @@ public class PrescriptionFollowupContentService extends BaseService {
|
|
|
|
|
|
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);
|
|
|
org.json.JSONArray jsonArray = new org.json.JSONArray();
|
|
|
|
|
|
if(StringUtils.isBlank(healthindexid)){
|
|
|
|
|
|
jsonArray = healthIndexService.findIndexByPatient(patientCode, 2, stardate, enddate, 0, 2);
|
|
|
}else{
|
|
|
DevicePatientHealthIndex devicePatientHealthIndex = devicePatientHealthIndexDao.findOne(new Long(healthindexid));
|
|
|
|
|
|
if(devicePatientHealthIndex != null){
|
|
|
org.json.JSONObject json = new org.json.JSONObject();
|
|
|
json.put("id", devicePatientHealthIndex.getId());
|
|
|
json.put("patient",devicePatientHealthIndex.getUser());
|
|
|
json.put("value1", devicePatientHealthIndex.getValue1());
|
|
|
json.put("value2", devicePatientHealthIndex.getValue2());
|
|
|
json.put("value3", devicePatientHealthIndex.getValue3());
|
|
|
json.put("value4", devicePatientHealthIndex.getValue4());
|
|
|
json.put("value5", devicePatientHealthIndex.getValue5());
|
|
|
json.put("value6", devicePatientHealthIndex.getValue6());
|
|
|
json.put("value7", devicePatientHealthIndex.getValue7());
|
|
|
json.put("deviceSn",devicePatientHealthIndex.getDeviceSn());
|
|
|
json.put("type", devicePatientHealthIndex.getType());
|
|
|
|
|
|
Date date = devicePatientHealthIndex.getRecordDate();
|
|
|
if (devicePatientHealthIndex.getType() == 2) {
|
|
|
json.put("date", DateUtil.dateToStr(date, DateUtil.YYYY_MM_DD_HH_MM_SS));
|
|
|
} else {
|
|
|
json.put("date", DateUtil.dateToStr(date, DateUtil.YYYY_MM_DD));
|
|
|
}
|
|
|
json.put("sortDate",devicePatientHealthIndex.getSortDate());
|
|
|
json.put("czrq", devicePatientHealthIndex.getCzrq());
|
|
|
|
|
|
jsonArray.put(json);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
String followupProjectData = "";
|
|
|
|