|
@ -29,6 +29,7 @@ import com.yihu.wlyy.repository.statistics.WlyySignFamilyCodeDao;
|
|
import com.yihu.wlyy.service.app.disease.PatientDiseaseService;
|
|
import com.yihu.wlyy.service.app.disease.PatientDiseaseService;
|
|
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
|
|
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
|
|
import com.yihu.wlyy.service.app.message.MessageService;
|
|
import com.yihu.wlyy.service.app.message.MessageService;
|
|
|
|
import com.yihu.wlyy.service.app.team.AdminTeamService;
|
|
import com.yihu.wlyy.task.SignUploadTask;
|
|
import com.yihu.wlyy.task.SignUploadTask;
|
|
import com.yihu.wlyy.util.MD5;
|
|
import com.yihu.wlyy.util.MD5;
|
|
import org.apache.commons.beanutils.converters.IntegerConverter;
|
|
import org.apache.commons.beanutils.converters.IntegerConverter;
|
|
@ -106,6 +107,8 @@ public class FamilyContractService extends BaseService {
|
|
private DoctorAdminTeamDao doctorAdminTeamDao;
|
|
private DoctorAdminTeamDao doctorAdminTeamDao;
|
|
@Autowired
|
|
@Autowired
|
|
MessageService messageService;
|
|
MessageService messageService;
|
|
|
|
@Autowired
|
|
|
|
AdminTeamService adminTeamService;
|
|
|
|
|
|
public SignFamily findSignFamilyByCode(String code) {
|
|
public SignFamily findSignFamilyByCode(String code) {
|
|
return signFamilyDao.findByCodeAndType(code, 2);
|
|
return signFamilyDao.findByCodeAndType(code, 2);
|
|
@ -241,7 +244,7 @@ public class FamilyContractService extends BaseService {
|
|
SignFamily sf = null;
|
|
SignFamily sf = null;
|
|
if (d.getLevel() == 2) {
|
|
if (d.getLevel() == 2) {
|
|
sf = signFamilyDao.findByDoctorPatient(doctor, patient);
|
|
sf = signFamilyDao.findByDoctorPatient(doctor, patient);
|
|
}else if(d.getLevel() == 3){
|
|
|
|
|
|
} else if (d.getLevel() == 3) {
|
|
sf = signFamilyDao.findByDoctorHealthPatient(doctor, patient);
|
|
sf = signFamilyDao.findByDoctorHealthPatient(doctor, patient);
|
|
}
|
|
}
|
|
|
|
|
|
@ -579,15 +582,15 @@ public class FamilyContractService extends BaseService {
|
|
public int unsign(String patient, String doctor) throws Exception {
|
|
public int unsign(String patient, String doctor) throws Exception {
|
|
Doctor doc = doctorDao.findByCode(doctor);
|
|
Doctor doc = doctorDao.findByCode(doctor);
|
|
|
|
|
|
if(doc == null){
|
|
|
|
|
|
if (doc == null) {
|
|
throw new Exception("doctor info can not find");
|
|
throw new Exception("doctor info can not find");
|
|
}
|
|
}
|
|
//修改签约标识为无效
|
|
//修改签约标识为无效
|
|
SignFamily sf = null;
|
|
SignFamily sf = null;
|
|
|
|
|
|
if(doc.getLevel() == 2){
|
|
|
|
|
|
if (doc.getLevel() == 2) {
|
|
sf = signFamilyDao.findByDoctorPatient(doctor, patient);
|
|
sf = signFamilyDao.findByDoctorPatient(doctor, patient);
|
|
} else if(doc.getLevel() == 3){
|
|
|
|
|
|
} else if (doc.getLevel() == 3) {
|
|
sf = signFamilyDao.findByDoctorHealthPatient(doctor, patient);
|
|
sf = signFamilyDao.findByDoctorHealthPatient(doctor, patient);
|
|
}
|
|
}
|
|
Message message = messageDao.findByPatient(patient, doctor);
|
|
Message message = messageDao.findByPatient(patient, doctor);
|
|
@ -936,18 +939,18 @@ public class FamilyContractService extends BaseService {
|
|
*/
|
|
*/
|
|
|
|
|
|
public JSONObject handleSign(String signType,
|
|
public JSONObject handleSign(String signType,
|
|
String access_token,
|
|
|
|
String doctor,
|
|
|
|
String doctorName,
|
|
|
|
String healthDoctor,
|
|
|
|
String healthDoctorName,
|
|
|
|
long msgid,
|
|
|
|
String patientCard, int type,
|
|
|
|
String healthLabel, String customLabel, String disease,
|
|
|
|
String expenses, long adminTeamCode) throws Exception {
|
|
|
|
|
|
String access_token,
|
|
|
|
String doctor,
|
|
|
|
String doctorName,
|
|
|
|
String healthDoctor,
|
|
|
|
String healthDoctorName,
|
|
|
|
long msgid,
|
|
|
|
String patientCard, int type,
|
|
|
|
String healthLabel, String customLabel, String disease,
|
|
|
|
String expenses, long adminTeamCode) throws Exception {
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
if (type != 1 && type != 2) {
|
|
if (type != 1 && type != 2) {
|
|
result.put("status",-1);
|
|
|
|
|
|
result.put("status", -1);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
@ -964,7 +967,7 @@ public class FamilyContractService extends BaseService {
|
|
// 判断患者有没有家庭签约
|
|
// 判断患者有没有家庭签约
|
|
SignFamily sf = signFamilyDao.findByPatientStatus(patientCard, 0);
|
|
SignFamily sf = signFamilyDao.findByPatientStatus(patientCard, 0);
|
|
if (sf == null) {
|
|
if (sf == null) {
|
|
result.put("status",0);
|
|
|
|
|
|
result.put("status", 0);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
if (type == 1) {
|
|
if (type == 1) {
|
|
@ -993,20 +996,31 @@ public class FamilyContractService extends BaseService {
|
|
//判断是否有三师签约 并且判断全科医生一致
|
|
//判断是否有三师签约 并且判断全科医生一致
|
|
SignFamily sssignFamily = signFamilyDao.findSSByIdcard(p.getIdcard());
|
|
SignFamily sssignFamily = signFamilyDao.findSSByIdcard(p.getIdcard());
|
|
|
|
|
|
if (sssignFamily != null && StringUtils.isNotEmpty(doctor) && !doctor.equals(sssignFamily.getDoctor())) {
|
|
|
|
result.put("status",-2);
|
|
|
|
result.put("msg","居民已签约三师,故全科医生只可为" + sssignFamily.getDoctorName() + "医生,请重新选择全科医生");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sssignFamily != null && StringUtils.isNotEmpty(healthDoctor) && !sf.getDoctor().equals(sssignFamily.getDoctor())) {
|
|
|
|
result.put("status",-3);
|
|
|
|
result.put("msg","对不起,居民已签约三师,故只可与" + sssignFamily.getDoctorName() + "医生签约,该签约申请已失效");
|
|
|
|
messageService.readHealth(msgid);
|
|
|
|
updateSignStatus(p.getIdcard());
|
|
|
|
return result;
|
|
|
|
|
|
if (sssignFamily != null) {
|
|
|
|
if(StringUtils.isNotEmpty(doctor)) {
|
|
|
|
if (!doctor.equals(sssignFamily.getDoctor())) {
|
|
|
|
result.put("status", -2);
|
|
|
|
result.put("msg", "居民已签约三师,故全科医生只可为" + sssignFamily.getDoctorName() + "医生,请重新选择全科医生");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
List<AdminTeam> teams = adminTeamService.findDoctorsTeams(sf.getDoctorHealth(), sssignFamily.getDoctor());
|
|
|
|
|
|
|
|
if (teams == null || teams.size() < 1) {
|
|
|
|
result.put("status", -4);
|
|
|
|
result.put("msg", "居民已签约三师,三师签约的全科医生" + sssignFamily.getDoctorName() + "与该签约申请的健管师" + sf.getDoctorHealthName() + "不在同一个团队,该签约申请已失效");
|
|
|
|
messageService.readHealth(msgid);
|
|
|
|
updateSignStatus(p.getIdcard());
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (StringUtils.isNotEmpty(healthDoctor) && !sf.getDoctor().equals(sssignFamily.getDoctor())) {
|
|
|
|
result.put("status", -3);
|
|
|
|
result.put("msg", "对不起,居民已签约三师,故只可与" + sssignFamily.getDoctorName() + "医生签约,该签约申请已失效");
|
|
|
|
messageService.readHealth(msgid);
|
|
|
|
updateSignStatus(p.getIdcard());
|
|
|
|
return result;
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
AdminTeam team = doctorAdminTeamDao.findOne(adminTeamCode);
|
|
AdminTeam team = doctorAdminTeamDao.findOne(adminTeamCode);
|
|
Doctor docLeader = doctorDao.findByCode(team.getLeaderCode());
|
|
Doctor docLeader = doctorDao.findByCode(team.getLeaderCode());
|
|
|
|
|
|
@ -1081,7 +1095,7 @@ public class FamilyContractService extends BaseService {
|
|
json.put("remark", "您好,签约家庭医生失败通知");
|
|
json.put("remark", "您好,签约家庭医生失败通知");
|
|
// 添加到发送队列
|
|
// 添加到发送队列
|
|
PushMsgTask.getInstance().putWxMsg(access_token, 2, sf.getOpenid(), sf.getName(), json);
|
|
PushMsgTask.getInstance().putWxMsg(access_token, 2, sf.getOpenid(), sf.getName(), json);
|
|
result.put("status",2);
|
|
|
|
|
|
result.put("status", 2);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
@ -1112,7 +1126,7 @@ public class FamilyContractService extends BaseService {
|
|
PushMsgTask.getInstance().putWxMsg(access_token, 1, sf.getOpenid(), sf.getName(), json);
|
|
PushMsgTask.getInstance().putWxMsg(access_token, 1, sf.getOpenid(), sf.getName(), json);
|
|
new Thread(new SignUploadTask(sf.getCode())).start();
|
|
new Thread(new SignUploadTask(sf.getCode())).start();
|
|
}
|
|
}
|
|
result.put("status",1);
|
|
|
|
|
|
result.put("status", 1);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
@ -1692,68 +1706,67 @@ public class FamilyContractService extends BaseService {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Map<String,Object> findNoHealthSignFamilyHealth(String doctor, Integer page, Integer pagesize,String patientName,String patientAddr) {
|
|
|
|
Map<String,Object> returnMap=new HashMap();
|
|
|
|
|
|
public Map<String, Object> findNoHealthSignFamilyHealth(String doctor, Integer page, Integer pagesize, String patientName, String patientAddr) {
|
|
|
|
Map<String, Object> returnMap = new HashMap();
|
|
if (pagesize == null || pagesize <= 0) {
|
|
if (pagesize == null || pagesize <= 0) {
|
|
pagesize = 10;
|
|
pagesize = 10;
|
|
}
|
|
}
|
|
if (page == null || page <=0) {
|
|
|
|
page =1;
|
|
|
|
|
|
if (page == null || page <= 0) {
|
|
|
|
page = 1;
|
|
}
|
|
}
|
|
int start =(page-1)*pagesize;
|
|
|
|
|
|
int start = (page - 1) * pagesize;
|
|
//先找出该医生下面没有健康管理师的患者 然后在去患者表找出该患者
|
|
//先找出该医生下面没有健康管理师的患者 然后在去患者表找出该患者
|
|
StringBuffer sql=new StringBuffer("" +
|
|
|
|
|
|
StringBuffer sql = new StringBuffer("" +
|
|
" select p.* from wlyy_patient p where p.code in " +
|
|
" select p.* from wlyy_patient p where p.code in " +
|
|
" (select a.patient code from wlyy_sign_family a where a.type = 2 and a.status >= 1 and a.doctor_health is null and a.doctor='"+doctor+"' order by a.czrq desc ) ");
|
|
|
|
|
|
" (select a.patient code from wlyy_sign_family a where a.type = 2 and a.status >= 1 and a.doctor_health is null and a.doctor='" + doctor + "' order by a.czrq desc ) ");
|
|
|
|
|
|
StringBuffer countSql=new StringBuffer("" +
|
|
|
|
|
|
StringBuffer countSql = new StringBuffer("" +
|
|
" select count(*) from wlyy_patient p where p.code in " +
|
|
" select count(*) from wlyy_patient p where p.code in " +
|
|
" (select a.patient code from wlyy_sign_family a where a.type = 2 and a.status >= 1 and a.doctor_health is null and a.doctor='"+doctor+"' order by a.czrq desc ) ");
|
|
|
|
|
|
" (select a.patient code from wlyy_sign_family a where a.type = 2 and a.status >= 1 and a.doctor_health is null and a.doctor='" + doctor + "' order by a.czrq desc ) ");
|
|
|
|
|
|
if(!org.springframework.util.StringUtils.isEmpty(patientName)){
|
|
|
|
sql.append(" and name like '"+patientName+"%'");
|
|
|
|
countSql.append(" and name like '"+patientName+"%'");
|
|
|
|
|
|
if (!org.springframework.util.StringUtils.isEmpty(patientName)) {
|
|
|
|
sql.append(" and name like '" + patientName + "%'");
|
|
|
|
countSql.append(" and name like '" + patientName + "%'");
|
|
}
|
|
}
|
|
if(!org.springframework.util.StringUtils.isEmpty(patientAddr)){
|
|
|
|
sql.append(" and address like '"+patientAddr+"%'");
|
|
|
|
countSql.append(" and address like '"+patientAddr+"%'");
|
|
|
|
|
|
if (!org.springframework.util.StringUtils.isEmpty(patientAddr)) {
|
|
|
|
sql.append(" and address like '" + patientAddr + "%'");
|
|
|
|
countSql.append(" and address like '" + patientAddr + "%'");
|
|
}
|
|
}
|
|
sql.append(" limit "+start+","+pagesize+"");
|
|
|
|
List<Patient> returnList= jdbcTemplate.query(sql.toString(),new BeanPropertyRowMapper(Patient.class));
|
|
|
|
|
|
sql.append(" limit " + start + "," + pagesize + "");
|
|
|
|
List<Patient> returnList = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper(Patient.class));
|
|
//得到疾病标签
|
|
//得到疾病标签
|
|
StringBuffer dieaseSql=new StringBuffer("" +
|
|
|
|
|
|
StringBuffer dieaseSql = new StringBuffer("" +
|
|
" select p.* from wlyy_sign_patient_label_info p where p.label_type='2' and p.status=1 and p.patient in " +
|
|
" select p.* from wlyy_sign_patient_label_info p where p.label_type='2' and p.status=1 and p.patient in " +
|
|
" (select a.patient code from wlyy_sign_family a where a.type = 2 and a.status >= 1 and a.doctor_health is null and a.doctor='"+doctor+"' order by a.czrq desc ) ");
|
|
|
|
|
|
" (select a.patient code from wlyy_sign_family a where a.type = 2 and a.status >= 1 and a.doctor_health is null and a.doctor='" + doctor + "' order by a.czrq desc ) ");
|
|
|
|
|
|
|
|
|
|
List<SignPatientLabelInfo> dieaseList= jdbcTemplate.query(dieaseSql.toString(),new BeanPropertyRowMapper(SignPatientLabelInfo.class));
|
|
|
|
Map<String,List<SignPatientLabelInfo>> diseaseMap=new HashMap<>();
|
|
|
|
if(dieaseList!=null&&dieaseList.size()>0){
|
|
|
|
for(SignPatientLabelInfo signPatientLabelInfo:dieaseList){
|
|
|
|
List<SignPatientLabelInfo> signPatientLabelInfoTemp= diseaseMap.get(signPatientLabelInfo.getPatient());
|
|
|
|
if(signPatientLabelInfoTemp!=null){
|
|
|
|
|
|
List<SignPatientLabelInfo> dieaseList = jdbcTemplate.query(dieaseSql.toString(), new BeanPropertyRowMapper(SignPatientLabelInfo.class));
|
|
|
|
Map<String, List<SignPatientLabelInfo>> diseaseMap = new HashMap<>();
|
|
|
|
if (dieaseList != null && dieaseList.size() > 0) {
|
|
|
|
for (SignPatientLabelInfo signPatientLabelInfo : dieaseList) {
|
|
|
|
List<SignPatientLabelInfo> signPatientLabelInfoTemp = diseaseMap.get(signPatientLabelInfo.getPatient());
|
|
|
|
if (signPatientLabelInfoTemp != null) {
|
|
signPatientLabelInfoTemp.add(signPatientLabelInfo);
|
|
signPatientLabelInfoTemp.add(signPatientLabelInfo);
|
|
}else{
|
|
|
|
signPatientLabelInfoTemp=new ArrayList<>();
|
|
|
|
|
|
} else {
|
|
|
|
signPatientLabelInfoTemp = new ArrayList<>();
|
|
signPatientLabelInfoTemp.add(signPatientLabelInfo);
|
|
signPatientLabelInfoTemp.add(signPatientLabelInfo);
|
|
}
|
|
}
|
|
diseaseMap.put(signPatientLabelInfo.getPatient(),signPatientLabelInfoTemp);
|
|
|
|
|
|
diseaseMap.put(signPatientLabelInfo.getPatient(), signPatientLabelInfoTemp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(returnList!=null&&returnList.size()>0){
|
|
|
|
for(Patient patient:returnList){
|
|
|
|
List<SignPatientLabelInfo> signPatientLabelInfoTemp=diseaseMap.get(patient.getCode());
|
|
|
|
|
|
if (returnList != null && returnList.size() > 0) {
|
|
|
|
for (Patient patient : returnList) {
|
|
|
|
List<SignPatientLabelInfo> signPatientLabelInfoTemp = diseaseMap.get(patient.getCode());
|
|
patient.setLabelInfos(signPatientLabelInfoTemp);
|
|
patient.setLabelInfos(signPatientLabelInfoTemp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Integer allCount= jdbcTemplate.queryForObject(countSql.toString(),Integer.class);
|
|
|
|
if(allCount%pagesize==0){
|
|
|
|
returnMap.put("count",allCount/pagesize);
|
|
|
|
}else{
|
|
|
|
returnMap.put("count",(allCount/pagesize)+1);
|
|
|
|
|
|
Integer allCount = jdbcTemplate.queryForObject(countSql.toString(), Integer.class);
|
|
|
|
if (allCount % pagesize == 0) {
|
|
|
|
returnMap.put("count", allCount / pagesize);
|
|
|
|
} else {
|
|
|
|
returnMap.put("count", (allCount / pagesize) + 1);
|
|
}
|
|
}
|
|
returnMap.put("returnList",returnList);
|
|
|
|
|
|
returnMap.put("returnList", returnList);
|
|
return returnMap;
|
|
return returnMap;
|
|
}
|
|
}
|
|
|
|
|