|
@ -0,0 +1,174 @@
|
|
|
|
package com.yihu.wlyy.service.specialist;
|
|
|
|
|
|
|
|
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
|
|
|
|
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
|
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
|
|
import com.yihu.wlyy.repository.doctor.SignPatientLabelDao;
|
|
|
|
import com.yihu.wlyy.repository.doctor.SignPatientLabelInfoDao;
|
|
|
|
import com.yihu.wlyy.repository.patient.SignFamilyDao;
|
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
|
import com.yihu.wlyy.util.http.HttpResponse;
|
|
|
|
import com.yihu.wlyy.util.http.HttpUtils;
|
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
|
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.jdbc.core.JdbcTemplate;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by Trick on 2018/5/31.
|
|
|
|
*/
|
|
|
|
@Service
|
|
|
|
public class SpecialistService extends BaseService {
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private SignPatientLabelDao signPatientLabelDao;
|
|
|
|
@Autowired
|
|
|
|
private SignPatientLabelInfoDao signPatientLabelInfoDao;
|
|
|
|
@Autowired
|
|
|
|
private DoctorDao doctorDao;
|
|
|
|
@Autowired
|
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
@Value("${specialist.url}")
|
|
|
|
private String specialistUrl;
|
|
|
|
|
|
|
|
public String setPatientLabelInfo(List<SignPatientLabelInfo> list){
|
|
|
|
if(list!=null&&list.size()>0){
|
|
|
|
for(SignPatientLabelInfo signPatientLabelInfo : list){
|
|
|
|
signPatientLabelInfo.setCzrq(new Date());
|
|
|
|
signPatientLabelInfo.setStatus(1);
|
|
|
|
}
|
|
|
|
signPatientLabelInfoDao.save(list);
|
|
|
|
}
|
|
|
|
|
|
|
|
return "1";
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<Map<String,Object>> findHealthAssistant(){
|
|
|
|
String sql="SELECT " +
|
|
|
|
" d.`code`, " +
|
|
|
|
" d.`name`, " +
|
|
|
|
" d.photo " +
|
|
|
|
" FROM " +
|
|
|
|
" wlyy_doctor d " +
|
|
|
|
" WHERE " +
|
|
|
|
" d.`level` = '5' " +
|
|
|
|
" AND `status` = 1";
|
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<SignPatientLabel> findLabelbyType(String type,Long teamCode){
|
|
|
|
//自定义标签
|
|
|
|
if("4".equals(type)){
|
|
|
|
List<SignPatientLabel> list = signPatientLabelDao.findByLabelTypeAndStatusAndTeamCode(type,1,teamCode);
|
|
|
|
return list;
|
|
|
|
}else{
|
|
|
|
//非自定义标签
|
|
|
|
List<SignPatientLabel> list = signPatientLabelDao.findByLabelTypeAndStatus(type,1);
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Long findSpecialistPatientRelationCout(String doctor)throws Exception{
|
|
|
|
Map<String,Object> param = new HashedMap();
|
|
|
|
param.put("doctor",doctor);
|
|
|
|
HttpResponse response = HttpUtils.doGet(specialistUrl+"findSpecialistPatientRelationCout",param);
|
|
|
|
JSONObject rs = new JSONObject(response.getContent());
|
|
|
|
if("succes".equals(rs.getString("message"))){
|
|
|
|
return rs.getLong("obj");
|
|
|
|
}
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
|
|
|
public JSONArray findNoLabelPatientRelation(String doctor)throws Exception{
|
|
|
|
Map<String,Object> param = new HashedMap();
|
|
|
|
param.put("doctor",doctor);
|
|
|
|
HttpResponse response = HttpUtils.doGet(specialistUrl+"findNoLabelPatientRelation",param);
|
|
|
|
JSONObject rs = new JSONObject(response.getContent());
|
|
|
|
if("succes".equals(rs.getString("message"))){
|
|
|
|
return rs.getJSONArray("obj");
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public JSONArray findPatientRelatioByAssistant(String assistant,Integer page,Integer size)throws Exception{
|
|
|
|
Map<String,Object> param = new HashedMap();
|
|
|
|
param.put("assistant",assistant);
|
|
|
|
param.put("page",page);
|
|
|
|
param.put("size",size);
|
|
|
|
HttpResponse response = HttpUtils.doGet(specialistUrl+"findPatientRelatioByAssistant",param);
|
|
|
|
JSONObject rs = new JSONObject(response.getContent());
|
|
|
|
if("succes".equals(rs.getString("message"))){
|
|
|
|
return rs.getJSONArray("obj");
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String saveHealthAssistant(String json)throws Exception{
|
|
|
|
Map<String,Object> param = new HashedMap();
|
|
|
|
param.put("json",json);
|
|
|
|
HttpResponse response = HttpUtils.doPost(specialistUrl+"saveHealthAssistant",param);
|
|
|
|
JSONObject rs = new JSONObject(response.getContent());
|
|
|
|
if("succes".equals(rs.getString("message"))){
|
|
|
|
return rs.getString("obj");
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<Map<String,Object>> getPatientByLabel(String labelType,String labelCode,Integer page,Integer size){
|
|
|
|
String sql="SELECT " +
|
|
|
|
" p. NAME, " +
|
|
|
|
" p. CODE, " +
|
|
|
|
" IFNULL( " +
|
|
|
|
" YEAR ( " +
|
|
|
|
" from_days(datediff(now(), p.birthday)) " +
|
|
|
|
" ), " +
|
|
|
|
" '未知' " +
|
|
|
|
" ) age, " +
|
|
|
|
" lb.labelName, " +
|
|
|
|
" lb.labelType, " +
|
|
|
|
" lb.label, " +
|
|
|
|
" p.photo, " +
|
|
|
|
" h.label_name as health, " +
|
|
|
|
" h.label AS healthcode " +
|
|
|
|
" FROM " +
|
|
|
|
" ( " +
|
|
|
|
" SELECT " +
|
|
|
|
" i.label_type AS labelType, " +
|
|
|
|
" i.label, " +
|
|
|
|
" i.label_name AS labelName, " +
|
|
|
|
" i.patient " +
|
|
|
|
" FROM " +
|
|
|
|
" wlyy_sign_patient_label_info i " +
|
|
|
|
" WHERE " +
|
|
|
|
" i.label = '"+labelCode+"' " +
|
|
|
|
" AND i.label_type = '"+labelType+"' " +
|
|
|
|
" AND i.`status` = '1' " +
|
|
|
|
" ) lb " +
|
|
|
|
" JOIN wlyy_patient p ON p. CODE = lb.patient " +
|
|
|
|
" LEFT JOIN ( " +
|
|
|
|
" SELECT " +
|
|
|
|
" t.label, " +
|
|
|
|
" t.label_name, " +
|
|
|
|
" t.patient " +
|
|
|
|
" FROM " +
|
|
|
|
" wlyy_sign_patient_label_info t " +
|
|
|
|
" WHERE " +
|
|
|
|
" t.label_type = '8' " +
|
|
|
|
" AND t.`status` = '1' " +
|
|
|
|
" ) h ON h.patient = lb.patient " +
|
|
|
|
" LIMIT LIMIT "+(page-1)*size+","+size;
|
|
|
|
|
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
}
|