|
@ -853,48 +853,56 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
|
|
*/
|
|
*/
|
|
public JSONObject helperAddPatient(String patient,String doctor){
|
|
public JSONObject helperAddPatient(String patient,String doctor){
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
BasePatientHelperDO patientHelperDO = patientHelperDao.findByPatientAndDoctor(patient,doctor);
|
|
|
|
if (null!=patientHelperDO){
|
|
|
|
result.put(ResponseContant.resultFlag,-1);
|
|
|
|
result.put(ResponseContant.resultMsg,"居民已存在,无需重复添加");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
BasePatientDO patientDO = patientDao.findById(patient);
|
|
|
|
if (null==patientDO){
|
|
|
|
result.put(ResponseContant.resultFlag,-1);
|
|
|
|
result.put(ResponseContant.resultMsg,"添加居民不存在,无法操作");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
BaseDoctorDO doctorDO = doctorDao.findById(doctor);
|
|
|
|
if (null==doctorDO){
|
|
|
|
result.put(ResponseContant.resultFlag,-1);
|
|
|
|
result.put(ResponseContant.resultMsg,"助老员不存在,无法操作");
|
|
|
|
return result;
|
|
|
|
|
|
String[] patients = patient.split(",");
|
|
|
|
List<BasePatientHelperDO> list = new ArrayList<>();
|
|
|
|
for (String tmp:patients){
|
|
|
|
BasePatientHelperDO patientHelperDO = patientHelperDao.findByPatientAndDoctor(tmp,doctor);
|
|
|
|
if (null!=patientHelperDO){
|
|
|
|
result.put(ResponseContant.resultFlag,-1);
|
|
|
|
result.put(ResponseContant.resultMsg,patientHelperDO.getPatientName()+"居民已存在,无需重复添加");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
BasePatientDO patientDO = patientDao.findById(tmp);
|
|
|
|
if (null==patientDO){
|
|
|
|
result.put(ResponseContant.resultFlag,-1);
|
|
|
|
result.put(ResponseContant.resultMsg,"添加居民不存在,无法操作");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
BaseDoctorDO doctorDO = doctorDao.findById(doctor);
|
|
|
|
if (null==doctorDO){
|
|
|
|
result.put(ResponseContant.resultFlag,-1);
|
|
|
|
result.put(ResponseContant.resultMsg,"助老员不存在,无法操作");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
//只有存在签约的居民才可被助老员关联
|
|
|
|
String sql = " SELECT count(DISTINCT p.id) " +
|
|
|
|
"from wlyy_archive a,base_patient p WHERE a.patient = p.id and a.sign_status = 1 and EXISTS( " +
|
|
|
|
"SELECT DISTINCT sr.patient from base_service_package_sign_record sr,base_service_package_record r, " +
|
|
|
|
"base_service_package_item i,base_team_member m " +
|
|
|
|
"WHERE sr.id = r.sign_id and sr.patient = a.patient and sr.status=1 and r.service_package_id = i.service_package_id " +
|
|
|
|
"and i.del = 1 and m.team_code = r.team_code " +
|
|
|
|
"and p.id='"+tmp+"' ) ";
|
|
|
|
Integer signFlag = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
|
if (signFlag==0){
|
|
|
|
result.put(ResponseContant.resultFlag,-1);
|
|
|
|
result.put(ResponseContant.resultMsg,"当前居民未与社工签约,无法添加");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
patientHelperDO = new BasePatientHelperDO();
|
|
|
|
patientHelperDO.setPatient(tmp);
|
|
|
|
patientHelperDO.setPatientName(patientDO.getName());
|
|
|
|
patientHelperDO.setDoctor(doctor);
|
|
|
|
patientHelperDO.setDoctorName(doctorDO.getName());
|
|
|
|
patientHelperDO.setCreateTime(new Date());
|
|
|
|
patientHelperDO.setCreateUser(doctor);
|
|
|
|
patientHelperDO.setDel("1");
|
|
|
|
patientHelperDO.setCreateUserName(doctorDO.getName());
|
|
|
|
list.add(patientHelperDO);
|
|
|
|
|
|
}
|
|
}
|
|
//只有存在签约的居民才可被助老员关联
|
|
|
|
String sql = " SELECT count(DISTINCT p.id) " +
|
|
|
|
"from wlyy_archive a,base_patient p WHERE a.patient = p.id and a.sign_status = 1 and EXISTS( " +
|
|
|
|
"SELECT DISTINCT sr.patient from base_service_package_sign_record sr,base_service_package_record r, " +
|
|
|
|
"base_service_package_item i,base_team_member m " +
|
|
|
|
"WHERE sr.id = r.sign_id and sr.patient = a.patient and sr.status=1 and r.service_package_id = i.service_package_id " +
|
|
|
|
"and i.del = 1 and m.team_code = r.team_code " +
|
|
|
|
"and p.id='"+patient+"' ) ";
|
|
|
|
Integer signFlag = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
|
if (signFlag==0){
|
|
|
|
result.put(ResponseContant.resultFlag,-1);
|
|
|
|
result.put(ResponseContant.resultMsg,"当前居民未与社工签约,无法添加");
|
|
|
|
return result;
|
|
|
|
|
|
if (list.size()>0){
|
|
|
|
patientHelperDao.save(list);
|
|
}
|
|
}
|
|
patientHelperDO = new BasePatientHelperDO();
|
|
|
|
patientHelperDO.setPatient(patient);
|
|
|
|
patientHelperDO.setPatientName(patientDO.getName());
|
|
|
|
patientHelperDO.setDoctor(doctor);
|
|
|
|
patientHelperDO.setDoctorName(doctorDO.getName());
|
|
|
|
patientHelperDO.setCreateTime(new Date());
|
|
|
|
patientHelperDO.setCreateUser(doctor);
|
|
|
|
patientHelperDO.setDel("1");
|
|
|
|
patientHelperDO.setCreateUserName(doctorDO.getName());
|
|
|
|
patientHelperDao.save(patientHelperDO);
|
|
|
|
result.put(ResponseContant.resultFlag,200);
|
|
result.put(ResponseContant.resultFlag,200);
|
|
result.put(ResponseContant.resultMsg,"添加成功");
|
|
result.put(ResponseContant.resultMsg,"添加成功");
|
|
return result;
|
|
return result;
|
|
@ -903,29 +911,37 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
|
|
/**
|
|
/**
|
|
* 助老员删除监护老人
|
|
* 助老员删除监护老人
|
|
*/
|
|
*/
|
|
public JSONObject helperDelPatient(String patient,String doctor){
|
|
|
|
|
|
public JSONObject helperDelPatient(String patient,String doctor) {
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
BasePatientHelperDO patientHelperDO = patientHelperDao.findByPatientAndDoctor(patient,doctor);
|
|
|
|
if (null==patientHelperDO){
|
|
|
|
result.put(ResponseContant.resultFlag,-1);
|
|
|
|
result.put(ResponseContant.resultMsg,"居民已不在你的列表中");
|
|
|
|
return result;
|
|
|
|
|
|
String[] patients = patient.split(",");
|
|
|
|
List<BasePatientHelperDO> list = new ArrayList<>();
|
|
|
|
for (String tmp : patients) {
|
|
|
|
BasePatientHelperDO patientHelperDO = patientHelperDao.findByPatientAndDoctor(tmp, doctor);
|
|
|
|
if (null == patientHelperDO) {
|
|
|
|
result.put(ResponseContant.resultFlag, -1);
|
|
|
|
result.put(ResponseContant.resultMsg, "居民已不在你的列表中");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
BaseDoctorDO doctorDO = doctorDao.findById(doctor);
|
|
|
|
if (null == doctorDO) {
|
|
|
|
result.put(ResponseContant.resultFlag, -1);
|
|
|
|
result.put(ResponseContant.resultMsg, "助老员不存在,无法操作");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
patientHelperDO.setDel("0");
|
|
|
|
patientHelperDO.setUpdateTime(new Date());
|
|
|
|
patientHelperDO.setUpdateUser(doctorDO.getId());
|
|
|
|
patientHelperDO.setUpdateUserName(doctorDO.getName());
|
|
|
|
list.add(patientHelperDO);
|
|
}
|
|
}
|
|
BaseDoctorDO doctorDO = doctorDao.findById(doctor);
|
|
|
|
if (null==doctorDO){
|
|
|
|
result.put(ResponseContant.resultFlag,-1);
|
|
|
|
result.put(ResponseContant.resultMsg,"助老员不存在,无法操作");
|
|
|
|
return result;
|
|
|
|
|
|
if (list.size() > 0) {
|
|
|
|
patientHelperDao.save(list);
|
|
}
|
|
}
|
|
patientHelperDO.setDel("0");
|
|
|
|
patientHelperDO.setUpdateTime(new Date());
|
|
|
|
patientHelperDO.setUpdateUser(doctorDO.getId());
|
|
|
|
patientHelperDO.setUpdateUserName(doctorDO.getName());
|
|
|
|
result.put(ResponseContant.resultFlag,200);
|
|
|
|
result.put(ResponseContant.resultMsg,"删除成功");
|
|
|
|
|
|
result.put(ResponseContant.resultFlag, 200);
|
|
|
|
result.put(ResponseContant.resultMsg, "删除成功");
|
|
return result;
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
/**********************************助老员部分******************************************************/
|
|
/**********************************助老员部分******************************************************/
|
|
/**
|
|
/**
|
|
* 根据居民和服务项查找医生
|
|
* 根据居民和服务项查找医生
|