|
@ -1,210 +0,0 @@
|
|
|
package com.yihu.wlyy.service.specialist;
|
|
|
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
|
|
|
import com.yihu.wlyy.entity.message.Message;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.service.app.team.AdminTeamService;
|
|
|
import com.yihu.wlyy.util.http.HttpResponse;
|
|
|
import com.yihu.wlyy.util.http.HttpUtils;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.json.JSONArray;
|
|
|
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.Map;
|
|
|
|
|
|
/**
|
|
|
* Created by humingfen on 2018/8/22.
|
|
|
*/
|
|
|
@Service
|
|
|
@Transactional
|
|
|
public class RehabilitationPlanService extends BaseService {
|
|
|
|
|
|
@Value("${specialist.url}")
|
|
|
private String specialistUrl;
|
|
|
@Autowired
|
|
|
private AdminTeamService teamService;
|
|
|
@Autowired
|
|
|
private SpecialistEvaluateSevice specialistEvaluateSevice;
|
|
|
|
|
|
public JSONArray findTemplateInfo(String doctor, String patient) throws Exception {
|
|
|
Map<String, Object> param = new HashedMap();
|
|
|
Long adminTeamId = null;
|
|
|
AdminTeam team = teamService.findByLeaderCode(doctor);
|
|
|
if(StringUtils.isBlank(patient)){
|
|
|
adminTeamId = team.getId();
|
|
|
param.put("adminTeamCode", adminTeamId);
|
|
|
}else {
|
|
|
param.put("doctor", doctor);
|
|
|
param.put("patient", patient);
|
|
|
}
|
|
|
HttpResponse response = null;
|
|
|
try {
|
|
|
response = HttpUtils.doGet(specialistUrl + "svr-specialist/findRehabilitationPlanTemplate", param);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
JSONObject rs = new JSONObject(response.getContent());
|
|
|
if ("success".equals(rs.getString("message"))) {
|
|
|
return rs.getJSONArray("detailModelList");
|
|
|
}
|
|
|
throw new Exception("请求获取模板列表失败!");
|
|
|
}
|
|
|
|
|
|
public JSONArray findTemplateDetailInfo(String templateId) throws Exception {
|
|
|
Map<String, Object> param = new HashedMap();
|
|
|
param.put("templateId", templateId);
|
|
|
HttpResponse response = null;
|
|
|
try {
|
|
|
response = HttpUtils.doGet(specialistUrl + "svr-specialist/findTemplateDetailByTemplateId", param);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
JSONObject rs = new JSONObject(response.getContent());
|
|
|
if ("success".equals(rs.getString("message"))) {
|
|
|
return rs.getJSONArray("detailModelList");
|
|
|
}
|
|
|
throw new Exception("请求获取模板明细列表失败!");
|
|
|
}
|
|
|
|
|
|
public String createTemplate(String title, Doctor doctor, Long teamId) throws Exception {
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("title", title);
|
|
|
json.put("adminTeamCode", teamId);
|
|
|
json.put("hospital", doctor.getHospital());
|
|
|
json.put("hospitalName", doctor.getHospitalName());
|
|
|
json.put("createUser", doctor.getCode());
|
|
|
json.put("createUserName", doctor.getName());
|
|
|
Map<String, Object> param = new HashedMap();
|
|
|
param.put("rehabilitationTemplate", json.toString());
|
|
|
HttpResponse response = null;
|
|
|
try {
|
|
|
response = HttpUtils.doPost(specialistUrl + "svr-specialist/createRehabilitationPlanTemplate", param);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
JSONObject rs = new JSONObject(response.getContent());
|
|
|
if ("success".equals(rs.getString("message"))) {
|
|
|
return rs.getString("obj");
|
|
|
}
|
|
|
return rs.getString("message");
|
|
|
}
|
|
|
|
|
|
public String createTemplateDetail(String json, String type, Doctor doctor) {
|
|
|
JSONObject object = new JSONObject(json);
|
|
|
JSONArray details = new JSONArray();
|
|
|
String templateId = object.get("templateId").toString();
|
|
|
String hospitalServiceItemIds = object.get("hospitalServiceItemId").toString();
|
|
|
if(hospitalServiceItemIds.contains(",")) {
|
|
|
String [] itemIds = hospitalServiceItemIds.split(",");
|
|
|
int len = itemIds.length;
|
|
|
while (len > 0){
|
|
|
len --;
|
|
|
JSONObject j = new JSONObject();
|
|
|
j.put("templateId", templateId);
|
|
|
j.put("hospitalServiceItemId", itemIds[len]);
|
|
|
j.put("createUser", doctor.getCode());
|
|
|
j.put("createUserName", doctor.getName());
|
|
|
details.put(len, j);
|
|
|
}
|
|
|
}else {
|
|
|
object.put("createUser", doctor.getCode());
|
|
|
object.put("createUserName", doctor.getName());
|
|
|
details.put(object);
|
|
|
}
|
|
|
Map<String, Object> param = new HashedMap();
|
|
|
param.put("rehabilitationTemplateDetail", details.toString());
|
|
|
HttpResponse response = null;
|
|
|
try {
|
|
|
if(type.equals("create")) {
|
|
|
response = HttpUtils.doPost(specialistUrl + "svr-specialist/createRehabilitationTemplateDetail", param);
|
|
|
}else if(type.equals("edit")) {
|
|
|
response = HttpUtils.doPost(specialistUrl + "svr-specialist/updateRehabilitationTemplateDetail", param);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
JSONObject rs = new JSONObject(response.getContent());
|
|
|
return rs.getString("message");
|
|
|
}
|
|
|
|
|
|
public JSONArray findServiceItemsByHospital(String doctorHospital, String signHospital) throws Exception {
|
|
|
Map<String, Object> param = new HashedMap();
|
|
|
param.put("doctorHospital", doctorHospital);
|
|
|
param.put("signHospital", signHospital);
|
|
|
HttpResponse response = null;
|
|
|
try {
|
|
|
response = HttpUtils.doGet(specialistUrl + "svr-specialist/findServiceItemsByHospital", param);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
JSONObject rs = new JSONObject(response.getContent());
|
|
|
if ("success".equals(rs.getString("message"))) {
|
|
|
return rs.getJSONArray("detailModelList");
|
|
|
}
|
|
|
throw new Exception("请求获取机构服务项目列表失败!");
|
|
|
}
|
|
|
|
|
|
public String createRehabilitationPlan(String json, Doctor doctor) {
|
|
|
JSONObject object = new JSONObject(json);
|
|
|
String patient = object.getString("patient");
|
|
|
object.put("createUser", doctor.getCode());
|
|
|
object.put("createUserName", doctor.getName());
|
|
|
Map<String, Object> param = new HashedMap();
|
|
|
param.put("rehabilitationPlan", object.toString());
|
|
|
HttpResponse response = null;
|
|
|
try {
|
|
|
response = HttpUtils.doPost(specialistUrl + "svr-specialist/createPatientRehabilitationPlan", param);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
JSONObject rs = new JSONObject(response.getContent());
|
|
|
JSONArray detailModelList = (JSONArray) rs.get("detailModelList");
|
|
|
//康复计划创建完给执行者发送消息
|
|
|
for (Object obj : detailModelList){
|
|
|
JSONObject detail = new JSONObject(obj);
|
|
|
Message message = new Message();
|
|
|
message.setSender(doctor.getCode());
|
|
|
message.setType(19);
|
|
|
message.setRelationCode(detail.getString("planId"));
|
|
|
message.setReceiver(detail.getString("doctor"));
|
|
|
specialistEvaluateSevice.sendMessage(message, detail.getString("hospital"), patient,null);
|
|
|
}
|
|
|
return rs.getString("message");
|
|
|
}
|
|
|
|
|
|
public String deleteTemplate(String templateId) {
|
|
|
Map<String, Object> param = new HashedMap();
|
|
|
param.put("id", templateId);
|
|
|
HttpResponse response = null;
|
|
|
try {
|
|
|
response = HttpUtils.doPost(specialistUrl + "svr-specialist/deleteRehabilitationPlanTemplate", param);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
JSONObject rs = new JSONObject(response.getContent());
|
|
|
return rs.getString("message");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 更新计划的状态
|
|
|
* @param planId
|
|
|
* @param status
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void updatePlanStatusById(String planId, Integer status) throws Exception{
|
|
|
Map<String, Object> param = new HashedMap();
|
|
|
param.put("planId", planId);
|
|
|
param.put("status", status);
|
|
|
HttpResponse response = HttpUtils.doPost(specialistUrl + "svr-specialist/updatePlanStatusById", param);
|
|
|
JSONObject result = new JSONObject(response.getContent());
|
|
|
if(result.getInt("status")!=200){
|
|
|
throw new Exception("请求微服务失败!");
|
|
|
}
|
|
|
}
|
|
|
}
|