|
@ -11,9 +11,13 @@ import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.service.app.survey.SurveyScreenResultService;
|
|
|
import com.yihu.wlyy.service.common.account.DoctorService;
|
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
|
import com.yihu.wlyy.util.http.HttpResponse;
|
|
|
import com.yihu.wlyy.util.http.HttpUtils;
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONException;
|
|
@ -21,6 +25,7 @@ import org.json.JSONObject;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Sort;
|
|
@ -39,6 +44,9 @@ import java.util.*;
|
|
|
@Transactional
|
|
|
public class ManagerQuestionnaireService extends BaseService {
|
|
|
|
|
|
@Value("${customerService.url}")
|
|
|
private String customerUrl;
|
|
|
|
|
|
@Autowired
|
|
|
private SurveyDao surveyDao;
|
|
|
@Autowired
|
|
@ -89,6 +97,8 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
private WechatTemplateConfigDao templateConfigDao;
|
|
|
@Autowired
|
|
|
private SurveyScreenResultService surveyScreenResultService;
|
|
|
@Autowired
|
|
|
private DoctorService doctorService;
|
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
|
|
@ -1809,4 +1819,108 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
//更改调查对象表答题状态为已答
|
|
|
//surveyUserDao.modifyStatus(surveyCode, patient);
|
|
|
}
|
|
|
|
|
|
//查询出推送居民
|
|
|
public List<Map<String, Object>> initPatient(String labelUnitType, String labelSexType, String labelServerType, String labelDiseaseType, String labelHealthType, String currentUserRole, String currentUserRoleLevel) {
|
|
|
String tableSql = " select p.code as service_patient_code ,w.`name` as service_patient_name,w.ssc,w.idcard,w.mobile,w.hospital,w.hospital_name,h.town,h.town_name from wlyy_sign_family w ,wlyy_admin_team t, dm_hospital h ";
|
|
|
String whereSql = " where w.status>0 and w.expenses_status=1 and w.admin_team_code=t.id and t.org_code=h.code ";
|
|
|
|
|
|
//通过登录的角色区域权限 限制所属患者条件
|
|
|
if (StringUtils.isNotBlank(labelUnitType)) {
|
|
|
switch (currentUserRoleLevel) {
|
|
|
case "1": {
|
|
|
whereSql += " and h.city in (" + labelUnitType + ")";
|
|
|
break;
|
|
|
}
|
|
|
case "2": {
|
|
|
whereSql += " and h.town in (" + labelUnitType + ")";
|
|
|
break;
|
|
|
}
|
|
|
case "3": {
|
|
|
whereSql += " and h.code in (" + labelUnitType + ")";
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
switch (currentUserRoleLevel) {
|
|
|
case "1": {
|
|
|
whereSql += " and h.province = '" + currentUserRole + "'";
|
|
|
break;
|
|
|
}
|
|
|
case "2": {
|
|
|
whereSql += " and h.city = '" + currentUserRole + "'";
|
|
|
break;
|
|
|
}
|
|
|
case "3": {
|
|
|
whereSql += " and h.town = '" + currentUserRole + "'";
|
|
|
break;
|
|
|
}
|
|
|
case "4": {
|
|
|
whereSql += " and h.code = '" + currentUserRole + "'";
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(labelServerType)) {
|
|
|
tableSql += " , wlyy_sign_family_server s ";
|
|
|
whereSql += " and s.server_type in (" + labelServerType + " ) and w.code= s.sign_code";
|
|
|
}
|
|
|
|
|
|
tableSql += " , wlyy_patient p ";
|
|
|
whereSql += " and p.code=w.patient AND p.openid IS NOT NULL and p.openid <>'' ";
|
|
|
if (StringUtils.isNotBlank(labelSexType)) {
|
|
|
whereSql += " and p.sex in (" + labelSexType + ") ";
|
|
|
}
|
|
|
List<Map<String, Object>> groupPatient = null;
|
|
|
if (StringUtils.isNotBlank(labelHealthType) || StringUtils.isNotBlank(labelDiseaseType)) {
|
|
|
String sql = "SELECT DISTINCT s.patient as service_patient_code, f.`name` as service_patient_name, f.ssc,f.idcard,f.mobile,f.hospital,f.hospital_name,h.town,h.town_name FROM ( SELECT t.patient," +
|
|
|
" GROUP_CONCAT(',',t.label_type,t.label,',') label FROM " +
|
|
|
" wlyy_sign_patient_label_info t WHERE t.patient IN (" +
|
|
|
tableSql + whereSql + ") AND t. STATUS = 1 GROUP BY t.patient ) s LEFT JOIN wlyy_sign_family f on s.patient=f.patient LEFT JOIN dm_hospital h on f.hospital=h.`code` where 1=1 ";
|
|
|
if (StringUtils.isNotBlank(labelHealthType)) {
|
|
|
String[] aa = labelHealthType.split(",");
|
|
|
String bb = "";
|
|
|
for (String a : aa) {
|
|
|
bb += " OR s.label LIKE '%,2" + a + ",%'";
|
|
|
}
|
|
|
sql += " AND ( " + bb.substring(3) + " )";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(labelDiseaseType)) {
|
|
|
String[] aa = labelDiseaseType.split(",");
|
|
|
String bb = "";
|
|
|
for (String a : aa) {
|
|
|
bb += " OR s.label LIKE '%,3" + a + ",%'";
|
|
|
}
|
|
|
sql += " AND ( " + bb.substring(3) + " )";
|
|
|
}
|
|
|
sql += "and f.status>0 and f.expenses_status=1";
|
|
|
groupPatient = jdbcTemplate.queryForList(sql);
|
|
|
} else {
|
|
|
groupPatient = jdbcTemplate.queryForList(tableSql + whereSql);
|
|
|
}
|
|
|
return groupPatient;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 调用集美客服派发问卷协同服务接口
|
|
|
* @param jsonData
|
|
|
* @param patientInfo
|
|
|
* @param doctor
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public String createWorkOrder(String jsonData, List<Map<String, Object>> patientInfo, String doctor) throws Exception{
|
|
|
JSONObject object = new JSONObject(jsonData);
|
|
|
Doctor d = doctorService.findDoctorByCode(doctor);
|
|
|
object.put("createUser", d.getCode());
|
|
|
object.put("createUserName", d.getName());
|
|
|
object.put("createUserType", 1);
|
|
|
Map<String, Object> param = new HashedMap();
|
|
|
param.put("patientInfo", patientInfo.toString());
|
|
|
param.put("jsonData", object.toString());
|
|
|
HttpResponse response = null;
|
|
|
response = HttpUtils.doPost(customerUrl + "wlyy-manage/createWorkOrder", param);
|
|
|
JSONObject rs = new JSONObject(response.getContent());
|
|
|
return rs.getString("message");
|
|
|
}
|
|
|
}
|