|
@ -6,14 +6,14 @@ import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
|
|
|
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
|
|
|
import com.yihu.wlyy.entity.message.Message;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.entity.patient.SignFamily;
|
|
|
import com.yihu.wlyy.entity.patient.SignFamilyRenew;
|
|
|
import com.yihu.wlyy.entity.patient.*;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
|
|
|
import com.yihu.wlyy.repository.message.MessageDao;
|
|
|
import com.yihu.wlyy.repository.patient.SignFamilyDao;
|
|
|
import com.yihu.wlyy.repository.patient.SignFamilyRenewDao;
|
|
|
import com.yihu.wlyy.repository.patient.SignFamilyRenewLogDao;
|
|
|
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
|
|
|
import com.yihu.wlyy.service.app.team.AdminTeamService;
|
|
|
import com.yihu.wlyy.service.common.SMSService;
|
|
|
import com.yihu.wlyy.service.common.account.DoctorService;
|
|
@ -34,7 +34,6 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import com.yihu.wlyy.entity.patient.SignWeb;
|
|
|
import com.yihu.wlyy.repository.patient.SignWebDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
|
|
@ -71,6 +70,11 @@ public class SignWebService extends BaseService {
|
|
|
private DoctorDao doctorDao;
|
|
|
@Autowired
|
|
|
private MessageDao messageDao;
|
|
|
@Autowired
|
|
|
private SignPatientLabelInfoService signPatientLabelInfoService;
|
|
|
@Autowired
|
|
|
private SignFamilyRenewLogDao signFamilyRenewLogDao;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 根据医生代码及签约状态编码 获取该医生签约患者的信息列表
|
|
@ -832,8 +836,9 @@ public class SignWebService extends BaseService {
|
|
|
" ,b.sex" +
|
|
|
" ,b.openid" +
|
|
|
" ,a.czrq" +
|
|
|
" ,a.renew_flag as renewFlag "+
|
|
|
" from " +
|
|
|
" ( select czrq,code,patient,doctor,status,id,apply_date,patient_apply_date,expenses_time,reason,begin from wlyy_sign_family_renew where (doctor = ? or doctor_health = ?) and status = ? and type = 2" +
|
|
|
" ( select czrq,code,patient,doctor,status,id,apply_date,patient_apply_date,expenses_time,reason,begin,renew_flag from wlyy_sign_family_renew where (doctor = ? or doctor_health = ?) and status = ? and type = 2" +
|
|
|
" order by begin desc ) a " +
|
|
|
" ,wlyy_patient b " +
|
|
|
" where a.patient = b.code order by a.begin desc limit " + page * pageSize + "," + pageSize;
|
|
@ -858,8 +863,9 @@ public class SignWebService extends BaseService {
|
|
|
" ,b.sex" +
|
|
|
" ,b.openid" +
|
|
|
" ,a.czrq" +
|
|
|
" ,a.renew_flag as renewFlag "+
|
|
|
" from " +
|
|
|
" ( select czrq,code,patient,doctor,status,id,apply_date,reason,begin,expenses_status,LENGTH(trim(ifnull(expenses_status,''))) len from wlyy_sign_family_renew where (doctor = ? or doctor_health = ?) and status > ? and type = 2 order by begin desc ) a " +
|
|
|
" ( select czrq,renew_flag,code,patient,doctor,status,id,apply_date,reason,begin,expenses_status,LENGTH(trim(ifnull(expenses_status,''))) len from wlyy_sign_family_renew where (doctor = ? or doctor_health = ?) and status > ? and type = 2 order by begin desc ) a " +
|
|
|
" ,wlyy_patient b " +
|
|
|
" where a.patient = b.code and a.expenses_status = '0' order by a.begin desc limit " + page * pageSize + "," + pageSize;
|
|
|
|
|
@ -883,8 +889,9 @@ public class SignWebService extends BaseService {
|
|
|
" ,b.sex" +
|
|
|
" ,b.openid" +
|
|
|
" ,a.czrq" +
|
|
|
" ,a.renew_flag as renewFlag "+
|
|
|
" from " +
|
|
|
" ( select expenses_status,czrq,code,patient,doctor,status,id,apply_date,patient_apply_date,expenses_time,reason,begin from wlyy_sign_family_renew where (doctor = ? or doctor_health = ?) and status = ? and type = 2" +
|
|
|
" ( select expenses_status,czrq,code,patient,doctor,status,id,apply_date,patient_apply_date,expenses_time,reason,begin,renew_flag from wlyy_sign_family_renew where (doctor = ? or doctor_health = ?) and status = ? and type = 2" +
|
|
|
" order by begin desc ) a " +
|
|
|
" ,wlyy_patient b " +
|
|
|
" where a.patient = b.code and a.expenses_status = '1' order by a.begin desc limit " + page * pageSize + "," + pageSize;
|
|
@ -975,7 +982,12 @@ public class SignWebService extends BaseService {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public int agreeRenew(String access_token, String dotorCode, String patientCode, String state, Long mesId, String signYear,String code) throws Exception {
|
|
|
public int agreeRenew(String access_token, String dotorCode, String patientCode, String state, Long mesId, String signYear, String code,
|
|
|
String health,
|
|
|
String disease,
|
|
|
String custom,
|
|
|
String sevId,String healthDoctor,
|
|
|
Long teamCode) throws Exception {
|
|
|
|
|
|
// List<SignFamilyRenew> renews = signFamilyRenewDao.findByDoctorAndPatientStatus0(dotorCode, patientCode, signYear);
|
|
|
//
|
|
@ -995,10 +1007,31 @@ public class SignWebService extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
renew.setApplyDate(new Date());
|
|
|
//1.3.3.2新增需求
|
|
|
//设置居民服务类型
|
|
|
setSevId(renew,sevId);
|
|
|
//1.3.3.2新增需求
|
|
|
//设置居民标签
|
|
|
signPatientLabelInfoService.setRenewPatientLabels(renew.getPatient(), health, disease,custom, renew.getDoctor(),renew.getDoctor());
|
|
|
//1.3.3.2设置可修改健康管理师
|
|
|
if(StringUtils.isNotBlank(healthDoctor)){
|
|
|
setHealthDoctor(renew,healthDoctor);
|
|
|
}
|
|
|
//1.3.3.2设置新团队
|
|
|
if(teamCode!=null&&teamCode!=0){
|
|
|
renew.setAdminTeamId(teamCode);
|
|
|
}
|
|
|
|
|
|
signFamilyRenewDao.save(renew);
|
|
|
|
|
|
setMessState(mesId);
|
|
|
|
|
|
//1.3.3.2 加入统计日志
|
|
|
if ("1".equals(state)) {
|
|
|
setRenewLog(renew);
|
|
|
}
|
|
|
|
|
|
|
|
|
//发送微信模板消息
|
|
|
JSONObject data = new JSONObject();
|
|
|
data.put("doctorName", renew.getDoctorName());
|
|
@ -1045,26 +1078,26 @@ public class SignWebService extends BaseService {
|
|
|
}
|
|
|
|
|
|
//-1患者已取消,-2已拒绝,-3已解约,-4已到期,0待签约,1已签约,2患者申请取消签约,3医生申请取消签约
|
|
|
}else if(status==1){
|
|
|
} else if (status == 1) {
|
|
|
//已经同意
|
|
|
return 2;
|
|
|
}else if(status==-1){
|
|
|
} else if (status == -1) {
|
|
|
//-1患者已取消
|
|
|
return 3;
|
|
|
}else if(status ==-2){
|
|
|
} else if (status == -2) {
|
|
|
//已拒绝
|
|
|
return 4;
|
|
|
}else if(status ==-3){
|
|
|
} else if (status == -3) {
|
|
|
//已解约
|
|
|
return 5;
|
|
|
}else if(status ==-4){
|
|
|
} else if (status == -4) {
|
|
|
//已到期
|
|
|
return 6;
|
|
|
}else{
|
|
|
} else {
|
|
|
//已申请取消
|
|
|
return 7;
|
|
|
}
|
|
|
} else{
|
|
|
} else {
|
|
|
//未找到签约关系
|
|
|
return 0;
|
|
|
}
|
|
@ -1081,7 +1114,11 @@ public class SignWebService extends BaseService {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public int agreeRenewOverDue(String access_token, String dotorCode, String patientCode, String state, Long mesId, String signYear ,String signCode) throws Exception {
|
|
|
public int agreeRenewOverDue(String access_token, String dotorCode, String patientCode, String state, Long mesId, String signYear, String signCode, String health,
|
|
|
String disease,
|
|
|
String custom,
|
|
|
String sevId,String healthDoctor,
|
|
|
Long teamCode) throws Exception {
|
|
|
|
|
|
// List<SignFamily> renews = signFamilyDao.findByDoctorAndPatientOverDue(dotorCode, patientCode, signYear);
|
|
|
//
|
|
@ -1101,10 +1138,30 @@ public class SignWebService extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
renew.setApplyDate(new Date());
|
|
|
//1.3.3.2新增需求
|
|
|
//设置居民服务类型
|
|
|
setSevId(renew,sevId);
|
|
|
//1.3.3.2新增需求
|
|
|
//设置居民标签
|
|
|
signPatientLabelInfoService.setPatientLabels(renew.getPatient(), renew.getIdcard(),"", health, disease, custom, renew.getDoctor(), renew.getDoctor());
|
|
|
//1.3.3.2设置可修改健康管理师
|
|
|
if(StringUtils.isNotBlank(healthDoctor)){
|
|
|
setHealthDoctor(renew,healthDoctor);
|
|
|
}
|
|
|
//1.3.3.2设置新团队
|
|
|
if(teamCode!=null&&teamCode!=0){
|
|
|
renew.setAdminTeamId(teamCode);
|
|
|
}
|
|
|
|
|
|
|
|
|
signFamilyDao.save(renew);
|
|
|
//消息设为已读
|
|
|
setMessState(mesId);
|
|
|
|
|
|
if ("1".equals(state)) {
|
|
|
setRenewLog(renew);
|
|
|
}
|
|
|
|
|
|
//发送微信模板消息
|
|
|
JSONObject data = new JSONObject();
|
|
|
data.put("doctorName", renew.getDoctorName());
|
|
@ -1149,22 +1206,22 @@ public class SignWebService extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}else if(status==1){
|
|
|
} else if (status == 1) {
|
|
|
//已经同意
|
|
|
return 2;
|
|
|
}else if(status==-1){
|
|
|
} else if (status == -1) {
|
|
|
//已拒绝
|
|
|
return 3;
|
|
|
}else if(status ==-2){
|
|
|
} else if (status == -2) {
|
|
|
//已拒绝
|
|
|
return 4;
|
|
|
}else if(status ==-3){
|
|
|
} else if (status == -3) {
|
|
|
//已解约
|
|
|
return 5;
|
|
|
}else if(status ==-4){
|
|
|
} else if (status == -4) {
|
|
|
//已到期
|
|
|
return 6;
|
|
|
}else{
|
|
|
} else {
|
|
|
//已取消
|
|
|
return 7;
|
|
|
}
|
|
@ -1217,7 +1274,7 @@ public class SignWebService extends BaseService {
|
|
|
|
|
|
JSONObject rs = new JSONObject();
|
|
|
|
|
|
List<SignFamily> signFamilys = signFamilyDao.findByPatientsLastYear(patient,(DateUtil.getNowYear()-1)+"");
|
|
|
List<SignFamily> signFamilys = signFamilyDao.findByPatientsLastYear(patient, (DateUtil.getNowYear() - 1) + "");
|
|
|
if (signFamilys == null || signFamilys.size() == 0) {
|
|
|
throw new RuntimeException("找不到签约关系!");
|
|
|
}
|
|
@ -1468,11 +1525,187 @@ public class SignWebService extends BaseService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取团队签约数,服务次数,平均满意度,
|
|
|
* @param type
|
|
|
* @return
|
|
|
* 设置服务表服务类型
|
|
|
* @param renew
|
|
|
* @param sevId
|
|
|
*/
|
|
|
public void setSevId(SignFamilyRenew renew, String sevId) {
|
|
|
if (StringUtils.isNotBlank(sevId)) {
|
|
|
int flag = sevId.indexOf("-");
|
|
|
if (flag != -1) {
|
|
|
String sql = "select d.name from wlyy_sign_dict d where d.code = '" + sevId + "' and d.year ='2017' ";
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
|
|
if (list != null && list.size() > 0) {
|
|
|
Map<String, Object> name = list.get(0);
|
|
|
String populationName = (String) name.get("name");
|
|
|
if (StringUtils.isNotBlank(populationName)) {
|
|
|
renew.setSpecialPopulation(sevId);
|
|
|
renew.setSpecialPopulationName(populationName);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
String[] keys = sevId.split("-");
|
|
|
if (keys != null && keys.length > 0) {
|
|
|
String sql2 = "select d.name from wlyy_sign_dict d where d.code = '" + keys[0] + "' and d.year ='2017' ";
|
|
|
List<Map<String, Object>> list2 = jdbcTemplate.queryForList(sql2);
|
|
|
if (list2 != null && list2.size() > 0) {
|
|
|
Map<String, Object> name = list2.get(0);
|
|
|
String serverTypeName = (String) name.get("name");
|
|
|
if (StringUtils.isNotBlank(serverTypeName)) {
|
|
|
renew.setServerType(keys[0]);
|
|
|
renew.setServerTypeName(serverTypeName);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
String sql2 = "select d.name from wlyy_sign_dict d where d.code = '" + sevId + "' and d.year ='2017' ";
|
|
|
List<Map<String, Object>> list2 = jdbcTemplate.queryForList(sql2);
|
|
|
if (list2 != null && list2.size() > 0) {
|
|
|
Map<String, Object> name = list2.get(0);
|
|
|
String serverTypeName = (String) name.get("name");
|
|
|
if (StringUtils.isNotBlank(serverTypeName)) {
|
|
|
renew.setServerType(sevId);
|
|
|
renew.setServerTypeName(serverTypeName);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置签约表服务类型
|
|
|
* @param renew
|
|
|
* @param sevId
|
|
|
*/
|
|
|
public JSONArray get(String type){
|
|
|
return null;
|
|
|
public void setSevId(SignFamily renew, String sevId) {
|
|
|
if (StringUtils.isNotBlank(sevId)) {
|
|
|
int flag = sevId.indexOf("-");
|
|
|
if (flag != -1) {
|
|
|
String sql = "select d.name from wlyy_sign_dict d where d.code = '" + sevId + "' and d.year ='2017' ";
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
|
|
if (list != null && list.size() > 0) {
|
|
|
Map<String, Object> name = list.get(0);
|
|
|
String populationName = (String) name.get("name");
|
|
|
if (StringUtils.isNotBlank(populationName)) {
|
|
|
renew.setSpecialPopulation(sevId);
|
|
|
renew.setSpecialPopulationName(populationName);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
String[] keys = sevId.split("-");
|
|
|
if (keys != null && keys.length > 0) {
|
|
|
String sql2 = "select d.name from wlyy_sign_dict d where d.code = '" + keys[0] + "' and d.year ='2017' ";
|
|
|
List<Map<String, Object>> list2 = jdbcTemplate.queryForList(sql2);
|
|
|
if (list2 != null && list2.size() > 0) {
|
|
|
Map<String, Object> name = list2.get(0);
|
|
|
String serverTypeName = (String) name.get("name");
|
|
|
if (StringUtils.isNotBlank(serverTypeName)) {
|
|
|
renew.setServerType(keys[0]);
|
|
|
renew.setServerTypeName(serverTypeName);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
String sql2 = "select d.name from wlyy_sign_dict d where d.code = '" + sevId + "' and d.year ='2017' ";
|
|
|
List<Map<String, Object>> list2 = jdbcTemplate.queryForList(sql2);
|
|
|
if (list2 != null && list2.size() > 0) {
|
|
|
Map<String, Object> name = list2.get(0);
|
|
|
String serverTypeName = (String) name.get("name");
|
|
|
if (StringUtils.isNotBlank(serverTypeName)) {
|
|
|
renew.setServerType(sevId);
|
|
|
renew.setServerTypeName(serverTypeName);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void setHealthDoctor(SignFamilyRenew signFamilyRenew,String healthDoctor){
|
|
|
Doctor doctor = doctorDao.findByCode(healthDoctor);
|
|
|
signFamilyRenew.setDoctorHealth(doctor.getCode());
|
|
|
signFamilyRenew.setDoctorHealthName(doctor.getName());
|
|
|
}
|
|
|
|
|
|
public void setHealthDoctor(SignFamily signFamilyRenew,String healthDoctor){
|
|
|
Doctor doctor = doctorDao.findByCode(healthDoctor);
|
|
|
signFamilyRenew.setDoctorHealth(doctor.getCode());
|
|
|
signFamilyRenew.setDoctorHealthName(doctor.getName());
|
|
|
}
|
|
|
|
|
|
public int setRenewLog(SignFamilyRenew renew){
|
|
|
if(renew ==null) {
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
String sql = "SELECT * FROM wlyy_sign_family f WHERE f.patient ='"+renew.getPatient()+"' AND (f.`status` =-4 OR f.`status`>0) AND f.expenses_status ='1' AND f.sign_year >='"+(Integer.parseInt(renew.getSignYear())-1)+"' ";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
Map<String,Object> sign = null;
|
|
|
if(list!=null&&list.size()>0){
|
|
|
sign = list.get(0);
|
|
|
}
|
|
|
SignFamilyRenewLog log = new SignFamilyRenewLog();
|
|
|
//存储新记录
|
|
|
log.setRenewSignCode(renew.getCode());
|
|
|
log.setSignYear(renew.getSignYear());
|
|
|
log.setIdcard(renew.getIdcard());
|
|
|
log.setAdminTeamId(renew.getAdminTeamId());
|
|
|
log.setDoctor(renew.getDoctor());
|
|
|
log.setHospital(renew.getHospital());
|
|
|
|
|
|
//存储旧签约记录
|
|
|
if(sign!=null){
|
|
|
Integer id =(Integer) sign.get("admin_team_code");
|
|
|
log.setOldSignCode((String)sign.get("code"));
|
|
|
log.setOldAdminTeamId(id.longValue());
|
|
|
log.setOldHospital((String)sign.get("hospital"));
|
|
|
log.setOldDoctor((String)sign.get("doctor"));
|
|
|
}
|
|
|
log.setNeedUpload("1");
|
|
|
log.setCreateTime(new Date());
|
|
|
log.setUpdateTime(new Date());
|
|
|
signFamilyRenewLogDao.save(log);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
public int setRenewLog(SignFamily renew){
|
|
|
if(renew ==null) {
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
String sql = "SELECT * FROM wlyy_sign_family f WHERE f.patient ='"+renew.getPatient()+"' AND (f.`status` =-4 OR f.`status`>0) AND f.expenses_status ='1' AND f.sign_year >='"+(Integer.parseInt(renew.getSignYear())-1)+"' ";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
Map<String,Object> sign = null;
|
|
|
if(list!=null&&list.size()>0){
|
|
|
sign = list.get(0);
|
|
|
}
|
|
|
SignFamilyRenewLog log = new SignFamilyRenewLog();
|
|
|
//存储新记录
|
|
|
log.setSignCode(renew.getCode());
|
|
|
log.setSignYear(renew.getSignYear());
|
|
|
log.setIdcard(renew.getIdcard());
|
|
|
log.setAdminTeamId(renew.getAdminTeamId());
|
|
|
log.setDoctor(renew.getDoctor());
|
|
|
log.setHospital(renew.getHospital());
|
|
|
|
|
|
//存储旧签约记录
|
|
|
if(sign!=null){
|
|
|
Integer id =(Integer) sign.get("admin_team_code");
|
|
|
log.setOldSignCode((String)sign.get("code"));
|
|
|
log.setOldAdminTeamId(id.longValue());
|
|
|
log.setOldHospital((String)sign.get("hospital"));
|
|
|
log.setOldDoctor((String)sign.get("doctor"));
|
|
|
}
|
|
|
log.setNeedUpload("1");
|
|
|
log.setCreateTime(new Date());
|
|
|
log.setUpdateTime(new Date());
|
|
|
|
|
|
signFamilyRenewLogDao.save(log);
|
|
|
return 1;
|
|
|
}
|
|
|
}
|