|
@ -32,9 +32,11 @@ import com.yihu.wlyy.task.SignUploadTask;
|
|
|
import com.yihu.wlyy.util.*;
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
|
|
|
import org.apache.commons.beanutils.BeanUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.CachedIntrospectionResults;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
@ -155,7 +157,7 @@ public class FamilyContractService extends BaseService {
|
|
|
* @return
|
|
|
*/
|
|
|
public SignFamily findSigningRenewByPatient(String patient) {
|
|
|
return signFamilyRenewDao.findSigningByPatient(patient);
|
|
|
return signFamilyDao.findSigningByPatient(patient);
|
|
|
}
|
|
|
/**
|
|
|
* 查询医院列表
|
|
@ -821,13 +823,23 @@ public class FamilyContractService extends BaseService {
|
|
|
throw new Exception("已签约了家庭医生!");
|
|
|
}
|
|
|
//判断是否有三师签约 并且判断全科医生一致
|
|
|
SignFamily sssignFamily = signFamilyDao.findSSByIdcard(idcard);
|
|
|
if (sssignFamily != null && !doctor.equals(sssignFamily.getDoctor())) {
|
|
|
throw new Exception("全科医生不一致!");
|
|
|
}
|
|
|
//屏蔽三师签约判断
|
|
|
// SignFamily sssignFamily = signFamilyDao.findSSByIdcard(idcard);
|
|
|
// if (sssignFamily != null && !doctor.equals(sssignFamily.getDoctor())) {
|
|
|
// throw new Exception("全科医生不一致!");
|
|
|
// }
|
|
|
|
|
|
List<SystemDict> systemDicts = systemDictDao.findByDictName("SIGN_YEAR");
|
|
|
String signYear = systemDicts.get(0).getCode();
|
|
|
// List<SystemDict> systemDicts = systemDictDao.findByDictName("SIGN_YEAR");
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
int m = cal.get(Calendar.MONTH)+1;
|
|
|
String signYear = "" ;
|
|
|
if(m>=4){
|
|
|
//签约当前年度
|
|
|
signYear = cal.get(Calendar.YEAR)+"";
|
|
|
}else{
|
|
|
//签约过去年度
|
|
|
signYear = (cal.get(Calendar.YEAR)-1)+"";
|
|
|
}
|
|
|
|
|
|
SignFamily sf = new SignFamily();
|
|
|
sf.setSignYear(signYear);//设置签约年度
|
|
@ -1119,8 +1131,17 @@ public class FamilyContractService extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
List<SystemDict> systemDicts = systemDictDao.findByDictName("SIGN_YEAR");
|
|
|
String year = systemDicts.get(0).getCode();
|
|
|
//List<SystemDict> systemDicts = systemDictDao.findByDictName("SIGN_YEAR");
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
int m = cal.get(Calendar.MONTH)+1;
|
|
|
String year = "" ;
|
|
|
if(m>=4){
|
|
|
//签约当前年度
|
|
|
year = cal.get(Calendar.YEAR)+"";
|
|
|
}else{
|
|
|
//签约过去年度
|
|
|
year = (cal.get(Calendar.YEAR)-1)+"";
|
|
|
}
|
|
|
|
|
|
Calendar now = Calendar.getInstance();
|
|
|
int month = now.get(Calendar.MONTH) + 1;
|
|
@ -2902,11 +2923,11 @@ public class FamilyContractService extends BaseService {
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
List<SignFamilyRenew> sc = signFamilyRenewDao.findByIdcard(p.getIdcard());
|
|
|
//判断身份证号是否已签约
|
|
|
if (sc != null&&sc.size()>0) {
|
|
|
return -2;
|
|
|
}
|
|
|
// List<SignFamilyRenew> sc = signFamilyRenewDao.findByIdcard(p.getIdcard());
|
|
|
// //判断身份证号是否已签约
|
|
|
// if (sc != null&&sc.size()>0) {
|
|
|
// return -2;
|
|
|
// }
|
|
|
|
|
|
Doctor d = doctorDao.findByCode(doctor);
|
|
|
Doctor hd = doctorDao.findByCode(healthDoctor);
|
|
@ -2915,8 +2936,14 @@ public class FamilyContractService extends BaseService {
|
|
|
return -3;
|
|
|
}
|
|
|
SignFamilyRenew sf = new SignFamilyRenew();
|
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
int year =cal.get(Calendar.YEAR);
|
|
|
int month = cal.get(Calendar.MONTH)+1;
|
|
|
String sql = "";
|
|
|
//判断是否有生效记录SQL
|
|
|
String sql = "SELECT t.doctor,t.team_code teamCode,t.admin_team_code adminTeamCode FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status>=0 AND t.expenses_status='1'";
|
|
|
sql ="SELECT t.doctor,t.team_code teamCode,t.admin_team_code adminTeamCode FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status>=0 AND t.expenses_status='1' AND t.sign_year ='"+(year-1)+"'";
|
|
|
|
|
|
List<Map<String,Object>> signs = jdbcTemplate.queryForList(sql);
|
|
|
if(signs==null||signs.size()==0){
|
|
|
return -4;
|
|
@ -2926,7 +2953,8 @@ public class FamilyContractService extends BaseService {
|
|
|
if(doctor.equals((String)sign.get("doctor"))){
|
|
|
//如果一致保存团队信息
|
|
|
sf.setTeamCode((String)sign.get("teamCode"));
|
|
|
sf.setAdminTeamId((Long)sign.get("adminTeamId"));
|
|
|
Integer c=(Integer)sign.get("adminTeamCode");
|
|
|
sf.setAdminTeamId(c.longValue());
|
|
|
}else {
|
|
|
//如果不一致 查看医生团队
|
|
|
String tcSql = "SELECT t.id FROM wlyy_admin_team t WHERE t.leader_code ='"+doctor+"'";
|
|
@ -3018,8 +3046,7 @@ public class FamilyContractService extends BaseService {
|
|
|
sf.setSignSource("2");//签约来源【1 社区签约 2 移动签约】
|
|
|
//******************扣费接口**********************/
|
|
|
sf.setExpensesStatus("0"); //扣费状态 【0未扣费 1已扣费 2已退费】
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
int year =cal.get(Calendar.YEAR);
|
|
|
|
|
|
sf.setSignYear(year+"");
|
|
|
sf.setIsValid(0);
|
|
|
sf.setBegin(new Date());
|
|
@ -3044,7 +3071,7 @@ public class FamilyContractService extends BaseService {
|
|
|
message.setSignStatus("8");//续签
|
|
|
message.setSex(p.getSex());
|
|
|
message.setOver("1");//未处理
|
|
|
message.setData(temp.getCode());
|
|
|
message.setData(sf.getCode());
|
|
|
messageDao.save(message);
|
|
|
// 发送消息给医生
|
|
|
JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
|
|
@ -3056,4 +3083,253 @@ public class FamilyContractService extends BaseService {
|
|
|
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 续签申请(7月之后)
|
|
|
*
|
|
|
* @param doctor 签约医生
|
|
|
* @param patient 居民code
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional
|
|
|
public int signRenewOverdue(String doctor,String healthDoctor, String patient) throws Exception {
|
|
|
Patient p = patientDao.findByCode(patient);
|
|
|
if (p == null) {
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
Doctor d = doctorDao.findByCode(doctor);
|
|
|
Doctor hd = doctorDao.findByCode(healthDoctor);
|
|
|
|
|
|
if (d == null) {
|
|
|
return -3;
|
|
|
}
|
|
|
SignFamily sf = new SignFamily();
|
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
int year =cal.get(Calendar.YEAR);
|
|
|
int month = cal.get(Calendar.MONTH)+1;
|
|
|
String sql ="SELECT t.doctor,t.team_code teamCode,t.admin_team_code adminTeamCode FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status=-4 AND t.expenses_status='1' AND t.sign_year ='"+(year-1)+"'";
|
|
|
|
|
|
|
|
|
List<Map<String,Object>> signs = jdbcTemplate.queryForList(sql);
|
|
|
if(signs==null||signs.size()==0){
|
|
|
return -4;
|
|
|
}
|
|
|
Map<String,Object> sign = signs.get(0);
|
|
|
//判断续签医生是否一致
|
|
|
if(doctor.equals((String)sign.get("doctor"))){
|
|
|
//如果一致保存团队信息
|
|
|
sf.setTeamCode((String)sign.get("teamCode"));
|
|
|
Integer c=(Integer)sign.get("adminTeamCode");
|
|
|
sf.setAdminTeamId(c.longValue());
|
|
|
}else {
|
|
|
//如果不一致 查看医生团队
|
|
|
String tcSql = "SELECT t.id FROM wlyy_admin_team t WHERE t.leader_code ='"+doctor+"'";
|
|
|
List<Map<String ,Object>> ids = jdbcTemplate.queryForList(tcSql);
|
|
|
if(ids!=null&&ids.size()>0){
|
|
|
Integer id = (Integer)ids.get(0).get("id");
|
|
|
Long lid = id.longValue();
|
|
|
sf.setAdminTeamId(lid);
|
|
|
}else{
|
|
|
//未找到团队信息
|
|
|
return -5;
|
|
|
}
|
|
|
//新建咨询团队组
|
|
|
DoctorTeam team = new DoctorTeam();
|
|
|
String code = getCode();
|
|
|
team.setCode(code);
|
|
|
team.setCzrq(new Date());
|
|
|
team.setDel("1");
|
|
|
team.setSignType("2");
|
|
|
//判断是否有健康管理师
|
|
|
if(hd!=null&&StringUtils.isNotBlank(hd.getName())){
|
|
|
team.setName(d.getName()+","+hd.getName()+","+p.getName());
|
|
|
//新建健康管理师
|
|
|
DoctorTeamMember hdmb = new DoctorTeamMember();
|
|
|
hdmb.setName(hd.getName());
|
|
|
hdmb.setMemberCode(healthDoctor);
|
|
|
hdmb.setCode(getCode());
|
|
|
hdmb.setDel("1");
|
|
|
hdmb.setCzrq(new Date());
|
|
|
hdmb.setTeam(code);
|
|
|
hdmb.setType(hd.getLevel());
|
|
|
hdmb.setSignType("2");
|
|
|
doctorTeamDoctor.save(hdmb);
|
|
|
}else{
|
|
|
team.setName(d.getName()+","+p.getName());
|
|
|
}
|
|
|
//新建医生成员
|
|
|
DoctorTeamMember dmb = new DoctorTeamMember();
|
|
|
dmb.setName(d.getName());
|
|
|
dmb.setMemberCode(doctor);
|
|
|
dmb.setCode(getCode());
|
|
|
dmb.setDel("1");
|
|
|
dmb.setCzrq(new Date());
|
|
|
dmb.setTeam(code);
|
|
|
dmb.setType(d.getLevel());
|
|
|
dmb.setSignType("2");
|
|
|
|
|
|
//新建病人
|
|
|
DoctorTeamMember pmb = new DoctorTeamMember();
|
|
|
pmb.setName(p.getName());
|
|
|
pmb.setMemberCode(patient);
|
|
|
pmb.setCode(getCode());
|
|
|
pmb.setDel("1");
|
|
|
pmb.setCzrq(new Date());
|
|
|
pmb.setTeam(code);
|
|
|
pmb.setType(5);
|
|
|
pmb.setSignType("2");
|
|
|
|
|
|
doctorTeamDoctor.save(dmb);
|
|
|
doctorTeamDoctor.save(pmb);
|
|
|
doctorTeamDao.save(team);
|
|
|
//关联新团队
|
|
|
sf.setTeamCode(code);
|
|
|
}
|
|
|
sf.setCode(getCode());
|
|
|
sf.setCzrq(new Date());
|
|
|
sf.setPatientApplyDate(new Date());
|
|
|
|
|
|
if(d!=null){
|
|
|
sf.setDoctor(doctor);
|
|
|
sf.setDoctorName(d.getName());
|
|
|
}
|
|
|
|
|
|
if(hd!=null){
|
|
|
sf.setDoctorHealth(healthDoctor);
|
|
|
sf.setDoctorHealthName(hd.getName());
|
|
|
}
|
|
|
sf.setMobile(p.getMobile());
|
|
|
sf.setName(p.getName());
|
|
|
sf.setIdcard(p.getIdcard());
|
|
|
sf.setOpenid(p.getOpenid());
|
|
|
sf.setPatient(patient);
|
|
|
sf.setHospital(d.getHospital());
|
|
|
sf.setHospitalName(d.getHospitalName());
|
|
|
sf.setSsc(p.getSsc());
|
|
|
sf.setStatus(0);//0为初始状态
|
|
|
sf.setType(2);// 设置为家庭签约
|
|
|
sf.setSignType("1");//用户申请
|
|
|
sf.setSignSource("2");//签约来源【1 社区签约 2 移动签约】
|
|
|
//******************扣费接口**********************/
|
|
|
sf.setExpensesStatus("0"); //扣费状态 【0未扣费 1已扣费 2已退费】
|
|
|
|
|
|
sf.setSignYear(year+"");
|
|
|
|
|
|
sf.setBegin(new Date());
|
|
|
sf.setEnd(DateUtil.stringToDate(year+1+"-07-01 00:00:00","yyyy-MM-dd HH:mmm:ss"));
|
|
|
|
|
|
SignFamily temp = signFamilyDao.save(sf);
|
|
|
|
|
|
if (temp != null) {
|
|
|
// 添加签约消息
|
|
|
Message message = new Message();
|
|
|
message.setCzrq(new Date());
|
|
|
message.setCreateTime(new Date());
|
|
|
message.setContent("您有一条新的家庭医生续签申请!");
|
|
|
message.setRead(1);//设置未读
|
|
|
message.setReceiver(doctor);//设置接受医生的code
|
|
|
message.setSender(patient);//设置发送的用户
|
|
|
message.setSenderName(p.getName());
|
|
|
message.setCode(getCode());
|
|
|
message.setSenderPhoto(p.getPhoto());
|
|
|
message.setTitle("家庭续签申请");
|
|
|
message.setType(1);//家庭签约信息
|
|
|
message.setReadonly(1);//是否只读消息
|
|
|
message.setSignStatus("8");//续签
|
|
|
message.setSex(p.getSex());
|
|
|
message.setOver("1");//未处理
|
|
|
message.setData(sf.getCode());
|
|
|
messageDao.save(message);
|
|
|
// 发送消息给医生
|
|
|
JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
|
|
|
if (jsonObject.getString("status").equals("1")) {
|
|
|
//如果在工作时间内就推送
|
|
|
PushMsgTask.getInstance().put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.D_SW_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.家庭签约.name(), p.getName()+"申请与您续签家庭医生", patient);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @param code
|
|
|
* @return
|
|
|
*/
|
|
|
public String getTeamName(String code){
|
|
|
try{
|
|
|
String sql = "SELECT t.name FROM wlyy_doctor_team t WHERE t.code ='"+code+"'";
|
|
|
|
|
|
List<Map<String,Object>> map = jdbcTemplate.queryForList(sql);
|
|
|
|
|
|
if(map!=null&&map.size()>0){
|
|
|
return (String)map.get(0).get("name");
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
|
|
|
public JSONArray getSignDoctorMessageOverDue(String patientCode) {
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
//找出患者的三师签约信息
|
|
|
Patient patient = patientDao.findByCode(patientCode);
|
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
int year = cal.get(Calendar.YEAR);
|
|
|
|
|
|
//得到家庭签约
|
|
|
SignFamily jtSignFamily = signFamilyDao.findFamilySignByPatientOverDue(patientCode,(year-1)+"");
|
|
|
|
|
|
if (jtSignFamily != null) {
|
|
|
//家庭签约只找全科医生
|
|
|
Doctor doctor = doctorDao.findByCode(jtSignFamily.getDoctor());
|
|
|
Doctor doctorHealth = doctorDao.findByCode(jtSignFamily.getDoctorHealth());
|
|
|
if (doctor != null) {
|
|
|
JSONObject jo = new JSONObject();
|
|
|
jo.put("code", doctor.getCode());
|
|
|
jo.put("sex", doctor.getSex());
|
|
|
jo.put("name", doctor.getName());
|
|
|
jo.put("photo", doctor.getPhoto());
|
|
|
jo.put("hosptialName", doctor.getHospitalName());
|
|
|
jo.put("level", doctor.getLevel());
|
|
|
jo.put("signType", "2");//三师签约
|
|
|
jo.put("signStatus", jtSignFamily.getStatus());
|
|
|
jo.put("jobName", doctor.getJobName());
|
|
|
jo.put("disease", patient.getDisease());//0健康,1高血压,2糖尿病,3高血压+糖尿病
|
|
|
if (jtSignFamily.getStatus() == 0) {
|
|
|
jo.put("sqDate", DateUtil.dateToStrShort(jtSignFamily.getPatientApplyDate()));//申请时间
|
|
|
} else {
|
|
|
jo.put("qyDate", DateUtil.dateToStrShort(jtSignFamily.getBegin()));//签约时间
|
|
|
jo.put("endDate", DateUtil.dateToStrShort(jtSignFamily.getEnd()));//结束时间
|
|
|
}
|
|
|
jsonArray.put(jo);
|
|
|
}
|
|
|
if (doctorHealth != null) {
|
|
|
JSONObject jo = new JSONObject();
|
|
|
jo.put("code", doctorHealth.getCode());
|
|
|
jo.put("sex", doctorHealth.getSex());
|
|
|
jo.put("name", doctorHealth.getName());
|
|
|
jo.put("photo", doctorHealth.getPhoto());
|
|
|
jo.put("hosptialName", doctorHealth.getHospitalName());
|
|
|
jo.put("level", doctorHealth.getLevel());
|
|
|
jo.put("signType", "2");//三师签约
|
|
|
jo.put("signStatus", jtSignFamily.getStatus());
|
|
|
jo.put("jobName", doctorHealth.getJobName());
|
|
|
jo.put("disease", patient.getDisease());//0健康,1高血压,2糖尿病,3高血压+糖尿病
|
|
|
if (jtSignFamily.getStatus() == 0) {
|
|
|
jo.put("sqDate", DateUtil.dateToStrShort(jtSignFamily.getPatientApplyDate()));//申请时间
|
|
|
} else {
|
|
|
jo.put("qyDate", DateUtil.dateToStrShort(jtSignFamily.getBegin()));//签约时间
|
|
|
jo.put("endDate", DateUtil.dateToStrShort(jtSignFamily.getEnd()));//结束时间
|
|
|
}
|
|
|
jsonArray.put(jo);
|
|
|
}
|
|
|
}
|
|
|
return jsonArray;
|
|
|
}
|
|
|
}
|