|
@ -0,0 +1,180 @@
|
|
|
package com.yihu.wlyy.service.synergy;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.entity.followup.Followup;
|
|
|
import com.yihu.wlyy.entity.organization.Hospital;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.entity.patient.SignFamily;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
|
import com.yihu.wlyy.repository.followup.FollowUpDao;
|
|
|
import com.yihu.wlyy.repository.organization.HospitalDao;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
import com.yihu.wlyy.repository.patient.SignFamilyDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
|
import com.yihu.wlyy.util.http.HttpResponse;
|
|
|
import com.yihu.wlyy.util.http.HttpUtils;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
|
|
|
/**
|
|
|
* Created by humingfen on 2018/10/9.
|
|
|
*/
|
|
|
@Service
|
|
|
@Transactional
|
|
|
public class SynergyManageService extends BaseService {
|
|
|
@Value("${customerService.url}")
|
|
|
private String customerUrl;
|
|
|
@Autowired
|
|
|
private HttpClientUtil httpClientUtil;
|
|
|
@Autowired
|
|
|
private PatientDao patientDao;
|
|
|
@Autowired
|
|
|
private DoctorDao doctorDao;
|
|
|
@Autowired
|
|
|
private SignFamilyDao signFamilyDao;
|
|
|
@Autowired
|
|
|
private FollowUpDao followUpDao;
|
|
|
@Autowired
|
|
|
private HospitalDao hospitalDao;
|
|
|
|
|
|
public JSONObject getWorkOrderInfo(String workorderCode, String patient, Integer role) throws Exception {
|
|
|
Map<String, Object> param = new HashedMap();
|
|
|
param.put("workorderCode", workorderCode);
|
|
|
param.put("patient", patient);
|
|
|
param.put("role", role);
|
|
|
HttpResponse response = null;
|
|
|
response = HttpUtils.doPost(customerUrl + "synergy/customer/getWorkOrderInfo", param);
|
|
|
JSONObject rs = new JSONObject(response.getContent());
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
|
|
|
public String createWorkorder(String doctor, Set<String> patientSet, Integer type, String objectId, String serviceDate, Integer priority, String remark, String followupClass, String followupType) throws Exception {
|
|
|
String response = null;
|
|
|
JSONArray array = new JSONArray();
|
|
|
String patientCode1 = null;
|
|
|
Doctor doctor1 = doctorDao.findByCode(doctor);
|
|
|
StringBuffer buffer = new StringBuffer();
|
|
|
for (String patientCode:patientSet){
|
|
|
if (patientSet.size() == 1){
|
|
|
patientCode1 = patientCode;
|
|
|
}
|
|
|
Patient patient = patientDao.findByCode(patientCode);
|
|
|
com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
|
|
|
object.put("servicePatientCode",patient.getCode());
|
|
|
object.put("servicePatientName",patient.getName());
|
|
|
buffer.append(patient.getName()+",");
|
|
|
object.put("ssc",patient.getSsc());
|
|
|
object.put("idcard",patient.getIdcard());
|
|
|
object.put("mobile",patient.getMobile());
|
|
|
object.put("hospital",doctor1.getHospital());
|
|
|
object.put("hospitalName",doctor1.getHospitalName());
|
|
|
Hospital hospital = hospitalDao.findByCode(doctor1.getHospital());
|
|
|
object.put("town", hospital.getTown());
|
|
|
object.put("townName",hospital.getTownName());
|
|
|
array.add(object);
|
|
|
}
|
|
|
buffer.deleteCharAt(buffer.length()-1);
|
|
|
com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
|
|
|
object.put("type",type);
|
|
|
object.put("serviceTime",serviceDate);
|
|
|
object.put("priority",priority);
|
|
|
object.put("createUser",doctor1.getCode());
|
|
|
object.put("createUserName",doctor1.getName());
|
|
|
object.put("hospital",doctor1.getHospital());
|
|
|
object.put("hospitalName",doctor1.getHospitalName());
|
|
|
object.put("createUserType",1);
|
|
|
object.put("remark",remark);
|
|
|
object.put("servicerCount",patientSet.size());
|
|
|
object.put("servicerKey",buffer);
|
|
|
if (type == 3){
|
|
|
Followup followup = new Followup();
|
|
|
followup.setDoctorCode(doctor1.getCode());
|
|
|
followup.setDoctorName(doctor1.getName());
|
|
|
if (patientCode1 != null){
|
|
|
Patient patient1 = patientDao.findByCode(patientCode1);
|
|
|
followup.setPatientCode(patient1.getCode());
|
|
|
followup.setPatientName(patient1.getName());
|
|
|
followup.setIdcard(patient1.getIdcard());
|
|
|
SignFamily signFamily = signFamilyDao.findByPatient(patientCode1);
|
|
|
followup.setAdminTeamCode(signFamily.getAdminTeamId());
|
|
|
followup.setSignType(Integer.parseInt(signFamily.getSignType()));
|
|
|
followup.setSignCode(signFamily.getCode());
|
|
|
}
|
|
|
followup.setFollowupDate(DateUtil.strToDate(serviceDate));
|
|
|
followup.setFollowupType(followupType);
|
|
|
followup.setFollowupClass(followupClass);
|
|
|
followup.setOrgCode(doctor1.getHospital());
|
|
|
followup.setOrgName(doctor1.getHospitalName());
|
|
|
followup.setDataFrom("2");
|
|
|
followup.setStatus("2");
|
|
|
followup.setCreater(doctor1.getCode());
|
|
|
followup.setCreateTime(new Date());
|
|
|
followup = followUpDao.save(followup);
|
|
|
object.put("relationCode",followup.getId());
|
|
|
object.put("relationCodeName","随访");
|
|
|
}else if (type == 1){
|
|
|
object.put("relationCode",objectId);
|
|
|
object.put("relationCodeName","健康教育");
|
|
|
}else if (type == 5){
|
|
|
object.put("relationCode",objectId);
|
|
|
object.put("relationCodeName","疾病筛查");
|
|
|
}
|
|
|
String url = customerUrl + "synergy/doctor/createWorkorder";
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
params.put("servicers",array.toJSONString());
|
|
|
params.put("workorder",object.toJSONString());
|
|
|
response = httpClientUtil.httpPost(url,params);
|
|
|
com.alibaba.fastjson.JSONObject object1 = JSON.parseObject(response);
|
|
|
if (object1.getInteger("status")==200){
|
|
|
return response;
|
|
|
}else {
|
|
|
throw new Exception("请求客服系统服务失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public JSONObject workorderList(String userCode,Integer workorderType,Integer status,String serviceStartTime,String serviceEndTime,Integer isAcceptTask,Integer page,Integer pageSize) throws Exception{
|
|
|
Map<String, Object> param = new HashedMap();
|
|
|
param.put("userCode",userCode);
|
|
|
param.put("workorderType",workorderType);
|
|
|
param.put("status",status);
|
|
|
param.put("serviceStartTime",serviceStartTime);
|
|
|
param.put("serviceEndTime",serviceEndTime);
|
|
|
param.put("isAcceptTask",isAcceptTask);
|
|
|
param.put("page",page);
|
|
|
param.put("pageSize",pageSize);
|
|
|
HttpResponse response = HttpUtils.doGet(customerUrl + "/doctor/synergy/workorderList", param);
|
|
|
JSONObject result = new JSONObject(response.getContent());
|
|
|
if(result.getInt("status")==200){
|
|
|
JSONObject json = result.getJSONObject("data");
|
|
|
return json;
|
|
|
}
|
|
|
throw new Exception("请求客服系统服务失败!");
|
|
|
}
|
|
|
|
|
|
public void reminder(String userCode,String workorderCode) throws Exception{
|
|
|
Map<String, Object> param = new HashedMap();
|
|
|
param.put("userCode",userCode);
|
|
|
param.put("workorderCode",workorderCode);
|
|
|
HttpResponse response = HttpUtils.doPost(customerUrl + "/synergy/doctor/reminder", param);
|
|
|
JSONObject result = new JSONObject(response.getContent());
|
|
|
if(result.getInt("status")!=200){
|
|
|
throw new Exception("请求客服系统服务失败!");
|
|
|
}
|
|
|
}
|
|
|
}
|