|
@ -8,13 +8,20 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.jw.care.dao.device.PatientDeviceDao;
|
|
|
import com.yihu.jw.care.dao.security.*;
|
|
|
import com.yihu.jw.care.dao.team.BaseTeamMemberDao;
|
|
|
import com.yihu.jw.care.service.common.DictService;
|
|
|
import com.yihu.jw.care.service.consult.ConsultTeamService;
|
|
|
import com.yihu.jw.care.service.device.PatientDeviceService;
|
|
|
import com.yihu.jw.care.service.family.PatientFamilyMemberService;
|
|
|
import com.yihu.jw.care.service.sign.ServicePackageService;
|
|
|
import com.yihu.jw.care.util.ConstantUtil;
|
|
|
import com.yihu.jw.care.util.CountDistance;
|
|
|
import com.yihu.jw.entity.base.im.ConsultDo;
|
|
|
import com.yihu.jw.entity.care.assistance.EmergencyAssistanceDO;
|
|
|
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
|
|
|
import com.yihu.jw.im.dao.ConsultDao;
|
|
|
import com.yihu.jw.im.util.ImUtil;
|
|
|
import com.yihu.jw.restmodel.emergency.EmergencyOrderVO;
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
|
import com.yihu.jw.util.common.GpsUtil;
|
|
|
import com.yihu.jw.care.util.MessageUtil;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
@ -56,12 +63,10 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
@Autowired
|
|
|
private ServicePackageService servicePackageService;
|
|
|
@Autowired
|
|
|
private SecurityMonitoringOrderCancelLogDao securityMonitoringOrderCancelLogDao;
|
|
|
private EmergencyWarnCancelLogDao emergencyWarnCancelLogDao;
|
|
|
@Autowired
|
|
|
private MessageUtil messageUtil;
|
|
|
@Autowired
|
|
|
private SecurityMonitoringOrderPatientConfirmLogDao securityMonitoringOrderPatientConfirmLogDao;
|
|
|
@Autowired
|
|
|
private SecurityMonitoringDoctorStatusDao doctorStatusDao;
|
|
|
@Autowired
|
|
|
private SystemMessageDao systemMessageDao;
|
|
@ -70,7 +75,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
@Autowired
|
|
|
private BaseDoctorDao baseDoctorDao;
|
|
|
@Autowired
|
|
|
private SecurityMonitoringConclusionDao securityMonitoringConclusionDao;
|
|
|
private EmergencyWarnConclusionDao emergencyWarnConclusionDao;
|
|
|
@Autowired
|
|
|
private BaseDoctorHospitalDao baseDoctorHospitalDao;
|
|
|
@Autowired
|
|
@ -87,6 +92,12 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
private BaseTeamMemberDao baseTeamMemberDao;
|
|
|
@Autowired
|
|
|
private ImUtil imUtil;
|
|
|
@Autowired
|
|
|
private DictService dictService;
|
|
|
@Autowired
|
|
|
private EmergencyWarnDoctorResponseDao emergencyWarnDoctorResponseDao;
|
|
|
@Autowired
|
|
|
private PatientFamilyMemberService familyMemberService;
|
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(SecurityMonitoringOrderService.class);
|
|
|
|
|
@ -154,21 +165,17 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
}
|
|
|
|
|
|
//已取消的订单也可以申请
|
|
|
boolean bool = securityMonitoringOrderDao.existsByPatientAndStatusIn(orderDO.getPatient(),
|
|
|
new Integer[]{SecurityMonitoringOrderDO.Status.waitForSend.getType(),
|
|
|
SecurityMonitoringOrderDO.Status.waitForArrive.getType(),
|
|
|
SecurityMonitoringOrderDO.Status.signed.getType(),
|
|
|
SecurityMonitoringOrderDO.Status.registerSummary.getType(),
|
|
|
SecurityMonitoringOrderDO.Status.waitForAdded.getType(),
|
|
|
});
|
|
|
|
|
|
if(bool){
|
|
|
String failMsg = "当前服务对象存在未完成的服务,请先完成该服务!";
|
|
|
result.put("resultFlag", 0);
|
|
|
result.put("resultMsg", failMsg);
|
|
|
logger.error(failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
// boolean bool = securityMonitoringOrderDao.existsByPatientAndStatusIn(orderDO.getPatient(),
|
|
|
// new Integer[]{SecurityMonitoringOrderDO.Status.apply.getType()
|
|
|
// });
|
|
|
|
|
|
// if(bool){
|
|
|
// String failMsg = "当前服务对象存在未完成的服务,请先完成该服务!";
|
|
|
// result.put("resultFlag", 0);
|
|
|
// result.put("resultMsg", failMsg);
|
|
|
// logger.error(failMsg);
|
|
|
// return result;
|
|
|
// }
|
|
|
Map<String,Object> mapTmp = items.get(0);
|
|
|
List<BaseDoctorDO> doctorDOS = baseTeamMemberDao.findAllMembers(mapTmp.get("team_code").toString());
|
|
|
if (doctorDOS.size()==0){
|
|
@ -180,7 +187,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
|
|
|
orderDO.setCreateTime(new Date());
|
|
|
//判断创建预警服务类型,发起类型(1本人发起 2家人待预约 3医生代预约)
|
|
|
orderDO.setType(3);//发起类型
|
|
|
orderDO.setType(1);//发起类型
|
|
|
orderDO.setServiceStatus("2");
|
|
|
this.save(orderDO);
|
|
|
//创建im会话 安防警报咨询的sessionid 为居民code+(wlyy_consult_team表consult)+20
|
|
@ -209,8 +216,9 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public JSONObject getSecurityOrderDetail(String orderID){
|
|
|
public JSONObject getSecurityOrderDetail(String orderID,String doctor){
|
|
|
JSONObject result = new JSONObject();
|
|
|
EmergencyOrderVO emergencyOrderVO = new EmergencyOrderVO();
|
|
|
SecurityMonitoringOrderDO orderDO = securityMonitoringOrderDao.findOne(orderID);
|
|
|
if (orderDO==null){
|
|
|
String failMsg = "工单不存在!";
|
|
@ -219,49 +227,158 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
logger.error(failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
Integer conclusionStatus = Integer.valueOf(orderDO.getConclusionStatus()==null?"0":(orderDO.getConclusionStatus()+""));
|
|
|
String conclusionStatusName = "";
|
|
|
switch (conclusionStatus){
|
|
|
case 1:conclusionStatusName="待补录";break;
|
|
|
case 2:conclusionStatusName="已登记";break;
|
|
|
emergencyOrderVO.setId(orderDO.getId());
|
|
|
BasePatientDO patientDO = basePatientDao.findById(orderDO.getPatient());
|
|
|
Integer statustemp = Integer.valueOf(orderDO.getStatus()+"");
|
|
|
String statusName = "";
|
|
|
switch (statustemp){
|
|
|
case -2:statusName="误警报";break;
|
|
|
case -1:statusName="已取消";break;
|
|
|
case 0:statusName="已完成";break;
|
|
|
case 1:statusName="申请中";break;
|
|
|
}
|
|
|
emergencyOrderVO.setStatusName(statusName);
|
|
|
emergencyOrderVO.setOrderId(orderID);
|
|
|
emergencyOrderVO.setStatus(orderDO.getStatus());
|
|
|
emergencyOrderVO.setCreateTime(orderDO.getCreateTime());
|
|
|
emergencyOrderVO.setServeLat(orderDO.getServeLat());
|
|
|
emergencyOrderVO.setServeLon(orderDO.getServeLon());
|
|
|
emergencyOrderVO.setServeAddress(orderDO.getServeAddress());
|
|
|
emergencyOrderVO.setPatient(orderDO.getPatient());
|
|
|
emergencyOrderVO.setPatientName(orderDO.getPatientName());
|
|
|
emergencyOrderVO.setSex(patientDO.getSex());
|
|
|
|
|
|
if(StringUtils.isNotBlank(patientDO.getIdcard())){
|
|
|
emergencyOrderVO.setAge((IdCardUtil.getAgeForIdcard(patientDO.getIdcard()))+"");
|
|
|
}
|
|
|
emergencyOrderVO.setLiveAddress(patientDO.getAddress());
|
|
|
emergencyOrderVO.setOrderSource(orderDO.getOrderSource());
|
|
|
if(orderDO.getStatus()==-2){//误报警
|
|
|
emergencyOrderVO.setUpdateUserName(orderDO.getUpdateUserName());
|
|
|
emergencyOrderVO.setUpdateUser(orderDO.getUpdateUser());
|
|
|
emergencyOrderVO.setUpdateTime(orderDO.getUpdateTime());
|
|
|
emergencyOrderVO.setEmergencyCancel(orderDO.getEmergencyCancel());
|
|
|
}
|
|
|
emergencyOrderVO.setUpdateTime(orderDO.getUpdateTime());
|
|
|
if (orderDO.getStatus()==-1){//已取消
|
|
|
emergencyOrderVO.setUpdateTime(orderDO.getCancelTime());
|
|
|
}
|
|
|
//小结
|
|
|
Integer conclusionStatus = Integer.valueOf(orderDO.getConclusionStatus()==null?"0":(orderDO.getConclusionStatus()+""));
|
|
|
if (conclusionStatus==2){
|
|
|
SecurityMonitoringConclusionDO conclusionDO = securityMonitoringConclusionDao.findByOrderId(orderDO.getId());
|
|
|
EmergencyWarnConclusionDO conclusionDO = emergencyWarnConclusionDao.findByOrderId(orderDO.getId());
|
|
|
if (conclusionDO!=null){
|
|
|
orderDO.setMonitoringConclusion(conclusionDO);
|
|
|
conclusionDO.setReasonName(dictService.fingByNameAndCode(ConstantUtil.DICT_EMERGENCY_REASON,String.valueOf(conclusionDO.getEmergencyReason())));
|
|
|
conclusionDO.setTreatmentStatusName(dictService.fingByNameAndCode(ConstantUtil.DICT_EMERGENCY_TREATMENT_STATUS,String.valueOf(conclusionDO.getEmergencyTreatmentStatus())));
|
|
|
emergencyOrderVO.setEmergencyWarnConclusionDO(conclusionDO);
|
|
|
}
|
|
|
}
|
|
|
JSONObject jsonObject = JSON.parseObject(JSON.toJSONStringWithDateFormat(orderDO,"yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue));
|
|
|
|
|
|
jsonObject.put("conclusionStatusName",conclusionStatusName);
|
|
|
Integer statustemp = Integer.valueOf(orderDO.getStatus()+"");
|
|
|
String statusName = "";
|
|
|
switch (statustemp){
|
|
|
case -1:statusName="已取消";break;
|
|
|
case 1:statusName="待处置";break;
|
|
|
case 2:statusName="前往居民定位";break;
|
|
|
case 3:statusName="已签到";break;
|
|
|
case 4:statusName="已登记小结";break;
|
|
|
case 5:statusName="待补录";break;
|
|
|
case 6:statusName="待评价";break;
|
|
|
case 7:statusName="已完成";break;
|
|
|
//附加信息 电子围栏状态
|
|
|
if (orderDO.getOrderSource()==2){
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
map.put("inFenceStatus",false);
|
|
|
map.put("inFenceName","疑似超出安全区域");
|
|
|
emergencyOrderVO.setInformation(map);
|
|
|
}
|
|
|
BasePatientDO patientDO = basePatientDao.findById(orderDO.getPatient());
|
|
|
if (patientDO!=null){
|
|
|
jsonObject.put("patientAddress",patientDO.getAddress());
|
|
|
//通知对象
|
|
|
List<Map<String,Object>> noticePersons = new ArrayList<>();
|
|
|
JSONArray familyArr = familyMemberService.getPatientMembers(orderDO.getPatient(),null,null,null);
|
|
|
for (int i=0;i<familyArr.size();i++){
|
|
|
String patientId = familyArr.getJSONObject(i).getString("id");
|
|
|
BasePatientDO patientDO1 = basePatientDao.findById(patientId);
|
|
|
Map<String,Object> noticeObj = new HashMap<>();
|
|
|
noticeObj.put("type","0");
|
|
|
noticeObj.put("typeName","家属");
|
|
|
noticeObj.put("id",patientDO1.getId());
|
|
|
noticeObj.put("name",patientDO1.getName());
|
|
|
noticeObj.put("photo",patientDO1.getPhoto());
|
|
|
noticeObj.put("mobile",patientDO1.getMobile());
|
|
|
List<Map<String,Object>> arr = new ArrayList<>();
|
|
|
Map<String,Object> tmp = new HashMap<>();
|
|
|
tmp.put("name","系统预警");
|
|
|
tmp.put("status",0);
|
|
|
tmp.put(statusName,"未读");
|
|
|
SystemMessageDO messageDO = systemMessageDao.findByRelationCodeAndReceiver(orderDO.getId(),patientId);
|
|
|
if (messageDO != null){
|
|
|
if (StringUtils.isNotBlank(messageDO.getIsRead())){
|
|
|
tmp.put("status",Integer.parseInt(messageDO.getIsRead()));
|
|
|
if (Integer.parseInt(messageDO.getIsRead())==1){
|
|
|
tmp.put(statusName,"已读");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
arr.add(tmp);
|
|
|
noticeObj.put("response",arr);
|
|
|
noticePersons.add(noticeObj);
|
|
|
}
|
|
|
else {
|
|
|
jsonObject.put("patientAddress",null);
|
|
|
//医生信息
|
|
|
String sql ="SELECT i.code,i.team_code,i.org_code,i.org_name from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i \n" +
|
|
|
"where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and i.del = 1 and sr.`status`=1 \n" +
|
|
|
"and sr.patient = '"+orderDO.getPatient()+"' and i.code='preventLost' ";
|
|
|
List<Map<String,Object>> items = jdbcTemplate.queryForList(sql);
|
|
|
if (items.size()>0){
|
|
|
Map<String,Object> mapTmp = items.get(0);
|
|
|
List<BaseDoctorDO> doctorDOS = baseTeamMemberDao.findAllMembers(mapTmp.get("team_code").toString());
|
|
|
JSONArray otherDoctorDistance = new JSONArray();
|
|
|
JSONObject otherDoctorDistanceObj = new JSONObject();
|
|
|
for(BaseDoctorDO doc:doctorDOS){
|
|
|
Map<String,Object> noticeObj = new HashMap<>();
|
|
|
noticeObj.put("type","1");
|
|
|
noticeObj.put("typeName","助老员");
|
|
|
noticeObj.put("id",doc.getId());
|
|
|
noticeObj.put("name",doc.getName());
|
|
|
noticeObj.put("photo",doc.getPhoto());
|
|
|
noticeObj.put("mobile",doc.getMobile());
|
|
|
List<Map<String,Object>> arr = new ArrayList<>();
|
|
|
Map<String,Object> tmp = new HashMap<>();
|
|
|
tmp.put("name","系统预警");
|
|
|
tmp.put("status",0);
|
|
|
tmp.put("statusName","未响应");
|
|
|
if (emergencyWarnDoctorResponseDao.findByDoctorAndOrderId(doc.getId(),orderDO.getId())!=null){
|
|
|
tmp.put("status",1);
|
|
|
tmp.put("statusName","已响应");
|
|
|
}
|
|
|
arr.add(tmp);
|
|
|
noticeObj.put("response",arr);
|
|
|
noticePersons.add(noticeObj);
|
|
|
|
|
|
if (StringUtils.isBlank(doc.getDoctorLat()) || StringUtils.isBlank(doc.getDoctorLon())) {
|
|
|
continue;
|
|
|
}
|
|
|
double distanceTmp = countDistance.getDistance(Double.parseDouble(orderDO.getServeLat()),Double.parseDouble(orderDO.getServeLon()),Double.parseDouble(doc.getDoctorLat()),Double.parseDouble(doc.getDoctorLon()));
|
|
|
otherDoctorDistanceObj = new JSONObject();
|
|
|
otherDoctorDistanceObj.put("doctor",doc.getId());
|
|
|
otherDoctorDistanceObj.put("doctorName",doc.getName());
|
|
|
otherDoctorDistanceObj.put("doctorAddress",doc.getDoctorLocateAddress());
|
|
|
otherDoctorDistanceObj.put("doctorLon",doc.getDoctorLon());
|
|
|
otherDoctorDistanceObj.put("doctorLat",doc.getDoctorLat());
|
|
|
otherDoctorDistanceObj.put("distance",distanceTmp);//两点距离
|
|
|
otherDoctorDistance.add(otherDoctorDistanceObj);
|
|
|
}
|
|
|
emergencyOrderVO.setOtherDoctorDistance(otherDoctorDistance.toJSONString());
|
|
|
}
|
|
|
jsonObject.put("statusName",statusName);
|
|
|
emergencyOrderVO.setNoticePersons(noticePersons);
|
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(JSON.toJSONStringWithDateFormat(emergencyOrderVO,"yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue));
|
|
|
//获取咨询
|
|
|
ConsultDo consult = consultDao.queryByRelationCode(orderID);
|
|
|
if (null != consult) {
|
|
|
String sessionId = orderDO.getPatient() + "_" + consult.getId() + "_" + consult.getType();
|
|
|
jsonObject.put("sessionId",sessionId);
|
|
|
if (1==orderDO.getStatus()&&StringUtils.isNotBlank(doctor)){//查询未读数量
|
|
|
try {
|
|
|
Integer count = imUtil.UserSessionsUnreadMessageCount(sessionId,doctor);
|
|
|
jsonObject.put("UnRead",count);
|
|
|
}catch (Exception e){
|
|
|
jsonObject.put("sessionId",sessionId);
|
|
|
jsonObject.put("UnRead",0);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
jsonObject.put("sessionId",null);
|
|
|
jsonObject.put("UnRead",0);
|
|
|
}
|
|
|
|
|
|
result.put("resultFlag", 1);
|
|
@ -270,30 +387,57 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
|
|
|
}
|
|
|
|
|
|
public JSONArray getSecurityOrderList(String doctor,String serverDoctor,String patientName, String patient, String status, Integer page, Integer pageSize){
|
|
|
public JSONObject errorWarning(String orderId,Integer emergencyCancel,String doctor){
|
|
|
JSONObject result = new JSONObject();
|
|
|
SecurityMonitoringOrderDO orderDO = securityMonitoringOrderDao.findOne(orderId);
|
|
|
if (orderDO==null){
|
|
|
String failMsg = "工单不存在!";
|
|
|
result.put("resultFlag", 0);
|
|
|
result.put("resultMsg", failMsg);
|
|
|
logger.error(failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
|
|
|
orderDO.setStatus(-2);
|
|
|
orderDO.setCancelTime(new Date());
|
|
|
orderDO.setUpdateTime(new Date());
|
|
|
orderDO.setUpdateUserName(doctorDO.getName());
|
|
|
orderDO.setUpdateUser(doctorDO.getId());
|
|
|
orderDO.setEmergencyCancel(emergencyCancel);
|
|
|
securityMonitoringOrderDao.save(orderDO);
|
|
|
|
|
|
result = getSecurityOrderDetail(orderId,null);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public PageEnvelop getSecurityOrderList(String doctor, String serverDoctor, String patientName, String patient, String status, Integer page, Integer pageSize){
|
|
|
String sqlCount = "select count(ord.id) from base_security_monitoring_order ord INNER JOIN base_patient p on p.id = ord.patient " +
|
|
|
"where 1=1 ";
|
|
|
String fliter = " ";
|
|
|
String sql = " select p.id patientCode,p.name,p.sex,p.photo,p.idcard,ord.id orderId,ord.number,ord.serve_desc,ord.create_time,ord.`status`,ord.doctor," +
|
|
|
"ord.doctor_name,ord.patient_phone,ord.conclusion_status from base_security_monitoring_order ord INNER JOIN base_patient p on p.id = ord.patient " +
|
|
|
"where 1=1 ";
|
|
|
if (StringUtils.isNotBlank(doctor)){
|
|
|
sql+=" and EXISTS ( SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
|
|
|
fliter+=" and EXISTS ( SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
|
|
|
"base_team_member m " +
|
|
|
"where ord.patient = CONVERT(sr.patient USING utf8) and sr.id = r.sign_id and sr.status=1 and " +
|
|
|
" r.service_package_id = i.service_package_id and m.team_code = i.team_code and i.del = 1 and sr.`status`=1 and i.code='preventLost' and m.doctor_code = '"+doctor+"' and m.del = '1') ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(serverDoctor)){
|
|
|
sql +=" and ord.doctor = '"+serverDoctor+"' ";
|
|
|
fliter +=" and ord.doctor = '"+serverDoctor+"' ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(patientName)){
|
|
|
sql+=" and (ord.patient_name like '%"+patientName+"%' or p.idcard='"+patientName+"') ";
|
|
|
fliter+=" and (ord.patient_name like '%"+patientName+"%' or p.idcard='"+patientName+"') ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(patient)){
|
|
|
sql+=" and ord.patient='"+patient+"' ";
|
|
|
fliter+=" and ord.patient='"+patient+"' ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(status)){
|
|
|
sql+=" and ord.status='"+Integer.parseInt(status)+"' ";
|
|
|
fliter+=" and ord.status='"+Integer.parseInt(status)+"' ";
|
|
|
}
|
|
|
sql+=" order by ord.create_time desc limit " + (page*pageSize) + "," + pageSize;
|
|
|
List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
|
|
|
Long count = jdbcTemplate.queryForObject(sqlCount+fliter,Long.class);
|
|
|
fliter+=" order by ord.create_time desc limit " + (page*pageSize) + "," + pageSize;
|
|
|
List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql+fliter);
|
|
|
|
|
|
JSONArray result = new JSONArray();
|
|
|
for (Map<String,Object>one:sqlResult){
|
|
@ -323,14 +467,10 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
Integer statustemp = Integer.valueOf(one.get("status")+"");
|
|
|
String statusName = "";
|
|
|
switch (statustemp){
|
|
|
case -2:statusName="误警报";break;
|
|
|
case -1:statusName="已取消";break;
|
|
|
case 1:statusName="待处置";break;
|
|
|
case 2:statusName="前往居民定位";break;
|
|
|
case 3:statusName="已签到";break;
|
|
|
case 4:statusName="已登记小结";break;
|
|
|
case 5:statusName="待补录";break;
|
|
|
case 6:statusName="待评价";break;
|
|
|
case 7:statusName="已完成";break;
|
|
|
case 0:statusName="已完成";break;
|
|
|
case 1:statusName="申请中";break;
|
|
|
}
|
|
|
tmp.put("statusName",statusName);
|
|
|
result.add(tmp);
|
|
@ -345,13 +485,13 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
tmp.put("deviceFlag","0");
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
return PageEnvelop.getSuccessListWithPage("success",result,page,pageSize,count);
|
|
|
}
|
|
|
public List<Map<String,Object>> getSecurityOrderUnCompleteList(String doctor){
|
|
|
List<Map<String,Object>> result = new ArrayList<>();
|
|
|
String sql = " select p.id patientCode,p.name,p.sex,p.idcard,p.photo,ord.id orderId,ord.number,ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time,ord.`status`,ord.doctor," +
|
|
|
"ord.doctor_name,ord.patient_phone,ord.conclusion_status from base_security_monitoring_order ord INNER JOIN base_patient p on p.id = ord.patient " +
|
|
|
"where ord.status <>-1 and ord.status<> 7 ";
|
|
|
"where ord.status <>-1 and ord.status<>0 ";
|
|
|
sql+= "and EXISTS ( SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
|
|
|
"base_team_member m " +
|
|
|
"where ord.patient = CONVERT(sr.patient USING utf8) and sr.id = r.sign_id and sr.status=1 and " +
|
|
@ -371,8 +511,10 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 系统更新医生上门服务工单状态
|
|
|
* 系统更新医生工单状态
|
|
|
* @param doctor
|
|
|
* @param dispatchOrderStatus
|
|
|
*/
|
|
@ -399,24 +541,9 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
if (null == doorServiceOrder) {
|
|
|
throw new Exception("该工单不存在");
|
|
|
}
|
|
|
doorServiceOrder.setStatus(SecurityMonitoringOrderDO.Status.waitForArrive.getType()); //
|
|
|
this.updateDispatchStatusBySystem(doorServiceOrder.getDoctor(), 3);//待服务
|
|
|
doorServiceOrder.setServiceResponseTime(new Date());
|
|
|
|
|
|
//新增工单医生关联关系
|
|
|
// JSONObject jsonObjectParam = new JSONObject();
|
|
|
// JSONObject doc = new JSONObject();
|
|
|
// doc.put("doctor",doorServiceOrder.getDoctor());
|
|
|
// doc.put("doctorName",doorServiceOrder.getDoctorName());
|
|
|
// doc.put("hospitalLevel",hospitalLevel);
|
|
|
// doc.put("doctorJobCode",jobCode);
|
|
|
// doc.put("doctorJobName",jobCodeName);
|
|
|
// JSONArray docArr = new JSONArray();
|
|
|
// docArr.add(doc);
|
|
|
// jsonObjectParam.put("doctorArr",docArr);
|
|
|
|
|
|
// 无费用
|
|
|
// if (wlyyDoorServiceOrderService.orderWithDoctorAdd(new JSONObject(), jsonObjectParam, doorServiceOrder)) return null;
|
|
|
// doorServiceOrder.setStatus(SecurityMonitoringOrderDO.Status.waitForArrive.getType()); //
|
|
|
// this.updateDispatchStatusBySystem(doorServiceOrder.getDoctor(), 3);//待服务
|
|
|
// doorServiceOrder.setServiceResponseTime(new Date());
|
|
|
|
|
|
securityMonitoringOrderDao.save(doorServiceOrder);
|
|
|
|
|
@ -452,84 +579,65 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public JSONObject acceptOrder(String orderId,String doctor) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
SecurityMonitoringOrderDO doorServiceOrderDO = securityMonitoringOrderDao.findOne(orderId);
|
|
|
if(null == doorServiceOrderDO){
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
String failMsg = "当前工单不存在,id:" + orderId;
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
logger.error(failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
if (doorServiceOrderDO.getStatus()!=1){//待处置工单才可进行接单操作
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
String failMsg = "当前工单已被取消或接收:" + orderId;
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
logger.error(failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
SecurityMonitoringDoctorStatusDo doctorStatusDo = doctorStatusDao.findByDoctor(doctor);
|
|
|
BaseDoctorDO doctorVO = baseDoctorDao.findById(doctor);
|
|
|
if (null == doctorStatusDo) {
|
|
|
doctorStatusDo =new SecurityMonitoringDoctorStatusDo();
|
|
|
doctorStatusDo.setDoctor(doctor);
|
|
|
doctorStatusDo.setStatus(2);
|
|
|
doctorStatusDo.setCreateTime(new Date());
|
|
|
doctorStatusDo.setCreateUser(doctor);
|
|
|
doctorStatusDo.setCreateUserName(null != doctorVO ? doctorVO.getName() : null);
|
|
|
doctorStatusDao.save(doctorStatusDo);
|
|
|
}
|
|
|
|
|
|
SecurityMonitoringDoctorStatusDo doorDoctorStatusDO = doctorStatusDao.queryByDoctorAndStatusIn(doctor,new Integer[]{SecurityMonitoringDoctorStatusDo.Status.waitForSend.getType(),
|
|
|
SecurityMonitoringDoctorStatusDo.Status.waitForAccept.getType(),
|
|
|
SecurityMonitoringDoctorStatusDo.Status.waitForServe.getType(),
|
|
|
SecurityMonitoringDoctorStatusDo.Status.serving.getType(),
|
|
|
});
|
|
|
if(null == doorDoctorStatusDO){
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
String failMsg = "当前接单的医生不存在或禁止接单,doctor:" + doctor;
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
logger.error(failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
BaseDoctorDO doctorDO= baseDoctorDao.findById(doctor);
|
|
|
doorServiceOrderDO.setDoctor(doctor);
|
|
|
doorServiceOrderDO.setDoctorName(doctorDO.getName());
|
|
|
doorServiceOrderDO.setDoctorType("医生");
|
|
|
doorServiceOrderDO.setStatus(SecurityMonitoringOrderDO.Status.waitForArrive.getType());//前往居民定位
|
|
|
doorServiceOrderDO.setUpdateUser(doctor);
|
|
|
doorServiceOrderDO.setUpdateUserName(doctorDO.getName());
|
|
|
securityMonitoringOrderDao.save(doorServiceOrderDO);
|
|
|
// 派单时,把医生拉入会话,作为其中一个成员,医生拒单时,退出会话
|
|
|
//TODO 接单时创建两个人聊天
|
|
|
// ConsultDo consult = consultDao.queryByRelationCode(orderId);
|
|
|
// String sessionId = doorServiceOrderDO.getPatient() + "_" + consult.getId() + "_" + doorServiceOrderDO.getNumber() + "_" + consult.getType();
|
|
|
// imUtill.updateParticipantNew(sessionId,doctor,null);
|
|
|
|
|
|
// 工单状态变更记录
|
|
|
// WlyyDoorProcessLogDO processLogDO = new WlyyDoorProcessLogDO();
|
|
|
// processLogDO.setOrderId(orderId);
|
|
|
// processLogDO.setStatus(WlyyDoorServiceOrderDO.Status.waitForAccept.getType());
|
|
|
// processLogDO.setDispatcher(dispatcher);
|
|
|
// processLogDO.setDispatcherName(dispathcherName);
|
|
|
// processLogDO.setCreateTime(new Date());
|
|
|
// wlyyDoorProcessLogDao.save(processLogDO);
|
|
|
|
|
|
|
|
|
// 发送IM消息通知患者医生已派单
|
|
|
// String noticeContent = "已转派"+doorServiceOrderDO.getDoctorName()+"医生为您服务,请耐心等待医生接单";
|
|
|
// this.qucikSendIM(doorServiceOrderDO.getId(), dispatcher, "智能助手","1", noticeContent);
|
|
|
|
|
|
SecurityMonitoringOrderDO doorServiceOrder = acceptOrder1(orderId, doctor);
|
|
|
if(doorServiceOrder==null){
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
String failMsg = "当前接单的医生不存在或禁止接单,doctor:" + doctor;
|
|
|
result.put(ResponseContant.resultMsg, failMsg);
|
|
|
logger.error(failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
// JSONObject result = new JSONObject();
|
|
|
// SecurityMonitoringOrderDO doorServiceOrderDO = securityMonitoringOrderDao.findOne(orderId);
|
|
|
// if(null == doorServiceOrderDO){
|
|
|
// result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
// String failMsg = "当前工单不存在,id:" + orderId;
|
|
|
// result.put(ResponseContant.resultMsg, failMsg);
|
|
|
// logger.error(failMsg);
|
|
|
// return result;
|
|
|
// }
|
|
|
// if (doorServiceOrderDO.getStatus()!=1){//待处置工单才可进行接单操作
|
|
|
// result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
// String failMsg = "当前工单已被取消或接收:" + orderId;
|
|
|
// result.put(ResponseContant.resultMsg, failMsg);
|
|
|
// logger.error(failMsg);
|
|
|
// return result;
|
|
|
// }
|
|
|
// SecurityMonitoringDoctorStatusDo doctorStatusDo = doctorStatusDao.findByDoctor(doctor);
|
|
|
// BaseDoctorDO doctorVO = baseDoctorDao.findById(doctor);
|
|
|
// if (null == doctorStatusDo) {
|
|
|
// doctorStatusDo =new SecurityMonitoringDoctorStatusDo();
|
|
|
// doctorStatusDo.setDoctor(doctor);
|
|
|
// doctorStatusDo.setStatus(2);
|
|
|
// doctorStatusDo.setCreateTime(new Date());
|
|
|
// doctorStatusDo.setCreateUser(doctor);
|
|
|
// doctorStatusDo.setCreateUserName(null != doctorVO ? doctorVO.getName() : null);
|
|
|
// doctorStatusDao.save(doctorStatusDo);
|
|
|
// }
|
|
|
//
|
|
|
// SecurityMonitoringDoctorStatusDo doorDoctorStatusDO = doctorStatusDao.queryByDoctorAndStatusIn(doctor,new Integer[]{SecurityMonitoringDoctorStatusDo.Status.waitForSend.getType(),
|
|
|
// SecurityMonitoringDoctorStatusDo.Status.waitForAccept.getType(),
|
|
|
// SecurityMonitoringDoctorStatusDo.Status.waitForServe.getType(),
|
|
|
// SecurityMonitoringDoctorStatusDo.Status.serving.getType(),
|
|
|
// });
|
|
|
// if(null == doorDoctorStatusDO){
|
|
|
// result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
// String failMsg = "当前接单的医生不存在或禁止接单,doctor:" + doctor;
|
|
|
// result.put(ResponseContant.resultMsg, failMsg);
|
|
|
// logger.error(failMsg);
|
|
|
// return result;
|
|
|
// }
|
|
|
// BaseDoctorDO doctorDO= baseDoctorDao.findById(doctor);
|
|
|
// doorServiceOrderDO.setDoctor(doctor);
|
|
|
// doorServiceOrderDO.setDoctorName(doctorDO.getName());
|
|
|
// doorServiceOrderDO.setDoctorType("医生");
|
|
|
// doorServiceOrderDO.setStatus(SecurityMonitoringOrderDO.Status.waitForArrive.getType());//前往居民定位
|
|
|
// doorServiceOrderDO.setUpdateUser(doctor);
|
|
|
// doorServiceOrderDO.setUpdateUserName(doctorDO.getName());
|
|
|
// securityMonitoringOrderDao.save(doorServiceOrderDO);
|
|
|
//
|
|
|
//
|
|
|
// SecurityMonitoringOrderDO doorServiceOrder = acceptOrder1(orderId, doctor);
|
|
|
// if(doorServiceOrder==null){
|
|
|
// result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
// String failMsg = "当前接单的医生不存在或禁止接单,doctor:" + doctor;
|
|
|
// result.put(ResponseContant.resultMsg, failMsg);
|
|
|
// logger.error(failMsg);
|
|
|
// return result;
|
|
|
// }
|
|
|
|
|
|
result = getSecurityOrderDetail(orderId);
|
|
|
|
|
|
// 发送微信模板消息通知患者医生已接单
|
|
|
// BasePatientDO patient = basePatientDao.findById(doorServiceOrder.getPatient());//
|
|
@ -551,9 +659,9 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
// logger.error(e.getMessage());
|
|
|
// }
|
|
|
// 待接单消息设为已操作, 434 医生接单-- 王五接受了服务工单12345678
|
|
|
messageUtil.createMessage("医生接单","634",doorServiceOrder.getPatient(),doorServiceOrder.getPatientName(),
|
|
|
doorServiceOrder.getId(), doorServiceOrder.getDoctor(),doorServiceOrder.getDoctorName() ,null, doorServiceOrder.getDoctorName() + "接受了服务工单"+ doorServiceOrder.getNumber());
|
|
|
return result;
|
|
|
// messageUtil.createMessage("医生接单","634",doorServiceOrder.getPatient(),doorServiceOrder.getPatientName(),
|
|
|
// doorServiceOrder.getId(), doorServiceOrder.getDoctor(),doorServiceOrder.getDoctorName() ,null, doorServiceOrder.getDoctorName() + "接受了服务工单"+ doorServiceOrder.getNumber());
|
|
|
return getSecurityOrderDetail(orderId,null);
|
|
|
}
|
|
|
|
|
|
|
|
@ -582,8 +690,8 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
logger.error(failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
if(orderDO.getStatus() > SecurityMonitoringOrderDO.Status.waitForSend.getType()){
|
|
|
String failMsg = "只有医生接单前的工单才可取消";
|
|
|
if(orderDO.getStatus() == SecurityMonitoringOrderDO.Status.complete.getType()){
|
|
|
String failMsg = "当前工单已结束";
|
|
|
result.put("resultFlag", 0);
|
|
|
result.put("resultMsg", failMsg);
|
|
|
logger.error(failMsg);
|
|
@ -609,25 +717,13 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
}
|
|
|
|
|
|
//保存取消记录
|
|
|
SecurityMonitoringOrderCancelLog cancelLogDO = new SecurityMonitoringOrderCancelLog();
|
|
|
EmergencyWarnCancelLogDO cancelLogDO = new EmergencyWarnCancelLogDO();
|
|
|
cancelLogDO.setOrderId(orderId);
|
|
|
cancelLogDO.setPatient(orderDO.getPatient());
|
|
|
cancelLogDO.setCancelType(type);
|
|
|
cancelLogDO.setCancelReason(reason);
|
|
|
cancelLogDO.setTime(orderDO.getCancelTime());
|
|
|
securityMonitoringOrderCancelLogDao.save(cancelLogDO);
|
|
|
|
|
|
//保存居民确认取消记录
|
|
|
JSONObject confirmInfo = new JSONObject();
|
|
|
confirmInfo.put("orderId",orderId);
|
|
|
confirmInfo.put("patient",orderDO.getPatient());
|
|
|
confirmInfo.put("patientName",orderDO.getPatientName());
|
|
|
confirmInfo.put("type",4);
|
|
|
confirmInfo.put("description",reason);
|
|
|
JSONObject confirmInfoJson = new JSONObject();
|
|
|
confirmInfoJson.put("confirmInfo",confirmInfo);
|
|
|
this.orderWithConfirmLogAdd(result,confirmInfo,orderId);
|
|
|
|
|
|
emergencyWarnCancelLogDao.save(cancelLogDO);
|
|
|
|
|
|
// Consult consult = consultDao.queryByRelationCode(orderId);
|
|
|
// // 发送微信模板消息,通知居民工单已取消(smyyyqx-上门预约已取消)
|
|
@ -648,40 +744,10 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
// }
|
|
|
// pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 30, patient.getOpenid(), patient.getName(), json);
|
|
|
|
|
|
result = getSecurityOrderDetail(orderId);
|
|
|
result = getSecurityOrderDetail(orderId,null);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean orderWithConfirmLogAdd(JSONObject result, JSONObject jsonObjectParam, String orderId) {
|
|
|
// 确认信息
|
|
|
JSONObject confirmInfo = jsonObjectParam.getJSONObject("confirmInfo");
|
|
|
if (null != confirmInfo) {
|
|
|
SecurityMonitoringOrderPatientConfirmLog confirmLogDO = null;
|
|
|
try {
|
|
|
confirmLogDO = EntityUtils.jsonToEntity(confirmInfo.toString(), SecurityMonitoringOrderPatientConfirmLog.class);
|
|
|
} catch (Exception e) {
|
|
|
String failMsg = "工单关联【居民确认操作日志记录】时出错";
|
|
|
result.put("resultFlag", 0);
|
|
|
result.put("resultMsg", failMsg);
|
|
|
logger.error(failMsg);
|
|
|
return true;
|
|
|
}
|
|
|
confirmLogDO.setOrderId(orderId);
|
|
|
confirmLogDO.setCreateTime(new Date());
|
|
|
try {
|
|
|
securityMonitoringOrderPatientConfirmLogDao.save(confirmLogDO);
|
|
|
} catch (Exception e) {
|
|
|
String failMsg = "保存工单关联的【居民确认操作日志记录】时出错";
|
|
|
result.put("resultFlag", 0);
|
|
|
result.put("resultMsg", failMsg);
|
|
|
logger.error(failMsg);
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 签到保存
|
|
|
* @param orderId
|
|
@ -693,7 +759,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
*/
|
|
|
public JSONObject signIn(String orderId, String signTime, Integer signWay, String signLocation,
|
|
|
String signImg, String twoDimensionalCode,String doctorId) throws Exception {
|
|
|
SecurityMonitoringOrderDO doorServiceOrder = securityMonitoringOrderDao.findOne(orderId);
|
|
|
/* SecurityMonitoringOrderDO doorServiceOrder = securityMonitoringOrderDao.findOne(orderId);
|
|
|
doorServiceOrder.setDoctorSignTime(DateUtil.strToDate(signTime));
|
|
|
doorServiceOrder.setDoctorSignWay(signWay);
|
|
|
// 签到方式-2扫码时,需要去解析地址
|
|
@ -717,8 +783,10 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
doorServiceOrder = securityMonitoringOrderDao.save(doorServiceOrder);
|
|
|
// 修改医生上门服务工单状态 4服务中
|
|
|
this.updateDispatchStatusBySystem(doorServiceOrder.getDoctor(), 4);
|
|
|
|
|
|
return getSecurityOrderDetail(orderId);
|
|
|
}
|
|
|
}*/
|
|
|
return getSecurityOrderDetail(orderId,null);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -737,7 +805,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject updateDoorConclusion(Integer manageStatus,String orderId,String conclusion,Integer examPapeStatus) throws Exception {
|
|
|
public JSONObject updateDoorConclusion(Integer emergency_reason,Integer treatment_status,String orderId,String conclusion,String conclusion_img) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd"));
|
|
@ -748,17 +816,19 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
result.put("resultMsg", failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
SecurityMonitoringConclusionDO doorConclusion = securityMonitoringConclusionDao.findByOrderId(orderId);
|
|
|
EmergencyWarnConclusionDO doorConclusion = emergencyWarnConclusionDao.findByOrderId(orderId);
|
|
|
if (doorConclusion==null){
|
|
|
doorConclusion = new SecurityMonitoringConclusionDO();
|
|
|
doorConclusion = new EmergencyWarnConclusionDO();
|
|
|
doorConclusion.setOrderId(orderId);
|
|
|
doorConclusion.setPatient(one.getPatient());
|
|
|
doorConclusion.setPatientName(one.getPatientName());
|
|
|
doorConclusion.setDoctor(one.getDoctor());
|
|
|
doorConclusion.setDoctorName(one.getDoctorName());
|
|
|
}
|
|
|
doorConclusion.setStatus(manageStatus);
|
|
|
doorConclusion.setEmergencyReason(emergency_reason);
|
|
|
doorConclusion.setEmergencyTreatmentStatus(treatment_status);
|
|
|
doorConclusion.setConclusion(conclusion);
|
|
|
doorConclusion.setConclusionImg(conclusion_img);
|
|
|
BaseDoctorDO doctorVO = baseDoctorDao.findById(one.getDoctor());
|
|
|
if (doorConclusion != null && org.apache.commons.lang.StringUtils.isNotEmpty(doorConclusion.getId())) {
|
|
|
doorConclusion.setUpdateTime(new Date());
|
|
@ -770,22 +840,22 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
doorConclusion.setCreateUser(one.getDoctor());
|
|
|
doorConclusion.setCreateUserName(null != doctorVO ? doctorVO.getName() : null);
|
|
|
}
|
|
|
securityMonitoringConclusionDao.save(doorConclusion);
|
|
|
// 设置是否需要上传补录报告
|
|
|
if (!(one.getStatus()==SecurityMonitoringOrderDO.Status.complete.getType())){
|
|
|
one.setStatus(SecurityMonitoringOrderDO.Status.registerSummary.getType());//已登记服务小结
|
|
|
if (!consultTeamService.finishConsult(one.getId(),one.getPatient(),one.getPatient(),1)){
|
|
|
String failMsg = "咨询结束失败 无法结束工单";
|
|
|
throw new Exception(failMsg);
|
|
|
}
|
|
|
one.setExamPaperStatus(examPapeStatus);
|
|
|
emergencyWarnConclusionDao.save(doorConclusion);
|
|
|
one.setStatus(SecurityMonitoringOrderDO.Status.complete.getType());//已完成
|
|
|
one.setConclusionStatus(2);
|
|
|
securityMonitoringOrderDao.save(one);
|
|
|
return getSecurityOrderDetail(orderId);
|
|
|
return getSecurityOrderDetail(orderId,null);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 跳过登记服务小结
|
|
|
* @param orderId
|
|
|
*/
|
|
|
public JSONObject cancelConclusion(String orderId) {
|
|
|
public JSONObject cancelConclusion(String orderId) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
SecurityMonitoringOrderDO one = securityMonitoringOrderDao.findOne(orderId);
|
|
|
if (one==null){
|
|
@ -794,13 +864,12 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
result.put("resultMsg", failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
if (one.getStatus()==SecurityMonitoringOrderDO.Status.complete.getType()){//修改工单记录
|
|
|
securityMonitoringOrderDao.updateConclusionStatus2(orderId);
|
|
|
}
|
|
|
else {
|
|
|
securityMonitoringOrderDao.updateConclusionStatus(orderId);
|
|
|
if (!consultTeamService.finishConsult(one.getId(),one.getPatient(),one.getPatient(),1)){
|
|
|
String failMsg = "咨询结束失败 无法结束工单";
|
|
|
throw new Exception(failMsg);
|
|
|
}
|
|
|
return getSecurityOrderDetail(orderId);
|
|
|
securityMonitoringOrderDao.updateConclusionStatus(orderId);
|
|
|
return getSecurityOrderDetail(orderId,null);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -820,68 +889,42 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
* @param orderId
|
|
|
* @return
|
|
|
*/
|
|
|
public SecurityMonitoringConclusionDO getDoorConclusion(String orderId){
|
|
|
SecurityMonitoringConclusionDO doorConclusion = securityMonitoringConclusionDao.findByOrderId(orderId);
|
|
|
public EmergencyWarnConclusionDO getDoorConclusion(String orderId){
|
|
|
EmergencyWarnConclusionDO doorConclusion = emergencyWarnConclusionDao.findByOrderId(orderId);
|
|
|
SecurityMonitoringOrderDO one = securityMonitoringOrderDao.findOne(orderId);
|
|
|
if (doorConclusion==null&&one!=null) {
|
|
|
doorConclusion = new SecurityMonitoringConclusionDO();
|
|
|
doorConclusion = new EmergencyWarnConclusionDO();
|
|
|
doorConclusion.setOrderId(one.getId());
|
|
|
doorConclusion.setPatient(one.getPatient());
|
|
|
doorConclusion.setPatientName(one.getPatientName());
|
|
|
doorConclusion.setDoctor(one.getDoctor());
|
|
|
doorConclusion.setDoctorName(one.getDoctorName());
|
|
|
}else {
|
|
|
doorConclusion.setReasonName(dictService.fingByNameAndCode(ConstantUtil.DICT_EMERGENCY_REASON,String.valueOf(doorConclusion.getEmergencyReason())));
|
|
|
doorConclusion.setTreatmentStatusName(dictService.fingByNameAndCode(ConstantUtil.DICT_EMERGENCY_TREATMENT_STATUS,String.valueOf(doorConclusion.getEmergencyTreatmentStatus())));
|
|
|
}
|
|
|
return doorConclusion;
|
|
|
}
|
|
|
|
|
|
public JSONObject saveOrderFinishBydoctor(String orderId ,String finishImg) throws Exception {
|
|
|
SecurityMonitoringOrderDO one = securityMonitoringOrderDao.findOne(orderId);
|
|
|
one.setDoctorConfirmFinishImg(finishImg);
|
|
|
one.setStatus(SecurityMonitoringOrderDO.Status.complete.getType());
|
|
|
one.setDoctorConfirmFinishTime(new Date());
|
|
|
one.setCompleteTime(one.getDoctorConfirmFinishTime());
|
|
|
// 更新记录
|
|
|
this.setUpdateColumnInfo(one);
|
|
|
if (!consultTeamService.finishConsult(one.getId(),one.getPatient(),one.getPatient(),1)){
|
|
|
String failMsg = "咨询结束失败 无法结束工单";
|
|
|
throw new Exception(failMsg);
|
|
|
}
|
|
|
securityMonitoringOrderDao.save(one);
|
|
|
SecurityMonitoringOrderDO doorServiceOrderDO = this.getDoorServiceOrderById(orderId);
|
|
|
|
|
|
// 发送微信通知 待付款
|
|
|
BasePatientDO patient = basePatientDao.findById(one.getPatient());
|
|
|
|
|
|
// SecurityMonitoringOrderDO one = securityMonitoringOrderDao.findOne(orderId);
|
|
|
// one.setDoctorConfirmFinishImg(finishImg);
|
|
|
// one.setStatus(SecurityMonitoringOrderDO.Status.complete.getType());
|
|
|
// one.setDoctorConfirmFinishTime(new Date());
|
|
|
// one.setCompleteTime(one.getDoctorConfirmFinishTime());
|
|
|
// // 更新记录
|
|
|
// this.setUpdateColumnInfo(one);
|
|
|
// if (!consultTeamService.finishConsult(one.getId(),one.getPatient(),one.getPatient(),1)){
|
|
|
// String failMsg = "咨询结束失败 无法结束工单";
|
|
|
// throw new Exception(failMsg);
|
|
|
// }
|
|
|
// securityMonitoringOrderDao.save(one);
|
|
|
// SecurityMonitoringOrderDO doorServiceOrderDO = this.getDoorServiceOrderById(orderId);
|
|
|
//
|
|
|
// // 发送微信通知 待付款
|
|
|
// BasePatientDO patient = basePatientDao.findById(one.getPatient());
|
|
|
|
|
|
// 获取微信模板 smfwdwk-上门服务待付款
|
|
|
// Consult consult = consultDao.queryByRelationCode(orderId);
|
|
|
try {
|
|
|
// WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_process_feedback","fwyspf");
|
|
|
// String first = templateConfig.getFirst();
|
|
|
// first = first.replace("key1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm"));
|
|
|
// first = first .replace("key2", null != one.getDoctorName() ? one.getDoctorName() : "");
|
|
|
// org.json.JSONObject json = new org.json.JSONObject();
|
|
|
// json.put("first", first);
|
|
|
// json.put("keyword1", DateUtil.dateToStrShort(new Date()));
|
|
|
// json.put("keyword2", "服务医生评分");
|
|
|
// json.put("url", templateConfig.getUrl());
|
|
|
// json.put("remark", templateConfig.getRemark());
|
|
|
// json.put("id",orderId);
|
|
|
// //json.put("consult",consult.getCode());
|
|
|
// WlyyDoorCommentDO wlyyDoorCommentDO = this.DoorCommentDao.selectCommentDoctor(patient.getCode(),orderId);
|
|
|
// String finish="";
|
|
|
// if(wlyyDoorCommentDO!=null){
|
|
|
// finish = "0";
|
|
|
// json.put("finish",finish);
|
|
|
// }else {
|
|
|
// finish = "1";
|
|
|
// json.put("finish",finish);
|
|
|
// }
|
|
|
// pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 31, patient.getOpenid(), patient.getName(), json);
|
|
|
}catch (Exception e){
|
|
|
logger.error(e.getMessage());
|
|
|
}
|
|
|
return getSecurityOrderDetail(orderId);
|
|
|
return getSecurityOrderDetail(orderId,null);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -910,8 +953,8 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
|
|
|
|
|
|
// 设置服务小结
|
|
|
SecurityMonitoringConclusionDO doorConclusion = this.getDoorConclusion(id);
|
|
|
doorServiceOrder.setMonitoringConclusion(doorConclusion);
|
|
|
EmergencyWarnConclusionDO doorConclusion = this.getDoorConclusion(id);
|
|
|
doorServiceOrder.setEmergencyWarnConclusionDO(doorConclusion);
|
|
|
|
|
|
|
|
|
return doorServiceOrder;
|
|
@ -1002,6 +1045,74 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public JSONObject updateDoctorLocation(String doctor,String orderId,String doctorAddress,String doctorLat,String doctorLon){
|
|
|
JSONObject result = new JSONObject();
|
|
|
BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
|
|
|
if (doctorDO==null){
|
|
|
String failMsg = "当前医生不存在";
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
result.put(ResponseContant.resultMsg,failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
else {
|
|
|
doctorDO.setDoctorLocateAddress(doctorAddress);
|
|
|
doctorDO.setDoctorLat(doctorLat);
|
|
|
doctorDO.setDoctorLon(doctorLon);
|
|
|
baseDoctorDao.save(doctorDO);
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public JSONObject updatePatientLocation(String patient,String patientAddress,String patientLat,String patientLon){
|
|
|
JSONObject result = new JSONObject();
|
|
|
BasePatientDO patientDO = basePatientDao.findById(patient);
|
|
|
if (patientDO==null){
|
|
|
String failMsg = "患者不存在";
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
result.put(ResponseContant.resultMsg,failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
List<SecurityMonitoringOrderDO> monitoringOrderDO = securityMonitoringOrderDao.findByPatientAndStatus(patient,1);
|
|
|
|
|
|
if (monitoringOrderDO.size()>0){
|
|
|
for (SecurityMonitoringOrderDO tmp:monitoringOrderDO){
|
|
|
tmp.setServeAddress(patientAddress);
|
|
|
tmp.setServeLat(patientLat);
|
|
|
tmp.setServeLon(patientLon);
|
|
|
securityMonitoringOrderDao.save(monitoringOrderDO);
|
|
|
}
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
}
|
|
|
else {
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
result.put(ResponseContant.resultMsg,null);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public JSONObject responseOrder(String orderId,String doctor){
|
|
|
JSONObject result = new JSONObject();
|
|
|
SecurityMonitoringOrderDO one = securityMonitoringOrderDao.findOne(orderId);
|
|
|
if (one==null){
|
|
|
String failMsg = "工单不存在" ;
|
|
|
result.put("resultFlag", 0);
|
|
|
result.put("resultMsg", failMsg);
|
|
|
return result;
|
|
|
}
|
|
|
if (emergencyWarnDoctorResponseDao.findByDoctorAndOrderId(doctor,orderId)==null){
|
|
|
EmergencyWarnDoctorResponseDO responseDO = new EmergencyWarnDoctorResponseDO();
|
|
|
responseDO.setOrderId(orderId);
|
|
|
responseDO.setDoctor(doctor);
|
|
|
responseDO.setResponseTime(new Date());
|
|
|
emergencyWarnDoctorResponseDao.save(responseDO);
|
|
|
}
|
|
|
result.put("resultFlag", 1);
|
|
|
result.put("resultMsg", "success");
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
private String getRandomIntStr(){
|
|
|
Random rand = new Random();
|
|
|
int i = rand.nextInt(); //int范围类的随机数
|