|
@ -5,8 +5,6 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.jw.care.aop.RedisLockAOP;
|
|
|
import com.yihu.jw.care.dao.family.PatientFamilyMemberDao;
|
|
|
import com.yihu.jw.care.dao.label.BaseCapacityLabelDao;
|
|
|
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
|
|
|
import com.yihu.jw.care.service.common.DictService;
|
|
@ -15,21 +13,16 @@ import com.yihu.jw.care.service.family.PatientFamilyMemberService;
|
|
|
import com.yihu.jw.care.service.sign.CapacityAssessmentRecordService;
|
|
|
import com.yihu.jw.care.service.sign.ServicePackageService;
|
|
|
import com.yihu.jw.care.util.ConstantUtil;
|
|
|
import com.yihu.jw.care.vo.JczdPersonVo;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
|
|
|
import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
|
|
|
import com.yihu.jw.entity.care.label.BaseCapacityLabelDO;
|
|
|
import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
|
|
|
import com.yihu.jw.entity.care.sign.CapacityAssessmentRecordDO;
|
|
|
import com.yihu.jw.entity.hospital.family.WlyyPatientFamilyMemberDO;
|
|
|
import com.yihu.jw.hospital.family.dao.WlyyPatientFamilyMemberDao;
|
|
|
import com.yihu.jw.im.util.ImUtil;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
|
|
|
import com.yihu.jw.patient.service.BasePatientMedicardCardService;
|
|
|
import com.yihu.jw.patient.service.BasePatientService;
|
|
|
import com.yihu.jw.restmodel.ResponseContant;
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
@ -100,6 +93,149 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
|
|
|
@Autowired
|
|
|
private BasePatientService basePatientService;
|
|
|
|
|
|
/**
|
|
|
* 初始化签约老人2
|
|
|
*/
|
|
|
public void initOldTmp2(){
|
|
|
Map<String,String> lableCodeNameMap = new HashMap<>();
|
|
|
lableCodeNameMap.put("3","独居");//独居
|
|
|
lableCodeNameMap.put("4","孤寡");//孤寡
|
|
|
String sql = "select * from old_tmp";
|
|
|
List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> map:mapList){
|
|
|
String name = (map.get("name")+"").trim();
|
|
|
String idcard = (map.get("idcard")+"").trim();
|
|
|
String area = (map.get("area")+"").trim();
|
|
|
String address = (map.get("address")+"").trim();
|
|
|
String mobile = (map.get("mobile")+"").trim();
|
|
|
String type = (map.get("type")+"").trim();
|
|
|
BasePatientDO patientDO = patientDao.findByIdcard(idcard);
|
|
|
if(patientDO==null){
|
|
|
patientDO = new BasePatientDO();
|
|
|
}else{
|
|
|
continue;
|
|
|
}
|
|
|
patientDO.setRegister("1");
|
|
|
patientDO.setSaasId(area);
|
|
|
String salt = UUID.randomUUID().toString().substring(0,5);
|
|
|
patientDO.setPassword(MD5.md5Hex(idcard + "{" + salt + "}"));
|
|
|
patientDO.setSalt(salt);
|
|
|
patientDO.setOpenid(null);
|
|
|
patientDO.setIdcard(idcard);
|
|
|
patientDO.setSsc(null);
|
|
|
patientDO.setMobile(mobile);
|
|
|
patientDO.setSex(Integer.valueOf(IdCardUtil.getSexForIdcard_new(idcard)));
|
|
|
patientDO.setName(name);
|
|
|
patientDO.setArchiveType(1);
|
|
|
patientDO.setArchiveStatus(1);
|
|
|
if(patientDO.getSex()==2){
|
|
|
patientDO.setPhoto("group1/M00/00/7C/rBoAbmIu8g6ANMrpAAAiSDNDGrM907.png");
|
|
|
}else{
|
|
|
patientDO.setPhoto("group1/M00/00/5A/rBoAb2Iu8gOAQ9WYAAAgcmCLvjQ782.png");
|
|
|
}
|
|
|
patientDO.setDel("1");
|
|
|
patientDO.setLocked(0);
|
|
|
patientDO.setEnabled(1);
|
|
|
patientDO.setSignStatus(0);
|
|
|
patientDO.setCreateTime(new Date());
|
|
|
patientDO.setAddress(address);
|
|
|
Map<String,String> tmp = LatitudeUtils.getGeocoderLatitude(address);
|
|
|
if(tmp!=null){
|
|
|
String latlon = tmp.get("lat")+","+tmp.get("lng");
|
|
|
patientDO.setLatLon(latlon);
|
|
|
}
|
|
|
patientDao.save(patientDO);
|
|
|
String label = lableCodeNameMap.get(type);
|
|
|
if(StringUtils.isNotBlank(label)){
|
|
|
WlyyPatientLabelDO patientLabelDO = new WlyyPatientLabelDO();
|
|
|
patientLabelDO.setCzrq(new Date());
|
|
|
patientLabelDO.setLabelType("3");
|
|
|
patientLabelDO.setPatient(patientDO.getId());
|
|
|
patientLabelDO.setLabelCode(label);
|
|
|
patientLabelDO.setLabelName(lableCodeNameMap.get(label));
|
|
|
patientLabelDao.save(patientLabelDO);
|
|
|
}
|
|
|
logger.info("idcard="+idcard);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 初始化签约老人
|
|
|
*/
|
|
|
public void initOldTmp(){
|
|
|
Map<String,String> lableCodeNameMap = new HashMap<>();
|
|
|
lableCodeNameMap.put("3","独居");//独居
|
|
|
lableCodeNameMap.put("4","孤寡");//孤寡
|
|
|
String sql = "select * from old_tmp";
|
|
|
List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> map:mapList){
|
|
|
String name = (map.get("name")+"").trim();
|
|
|
String idcard = (map.get("idcard")+"").trim();
|
|
|
String area = (map.get("area")+"").trim();
|
|
|
String address = (map.get("address")+"").trim();
|
|
|
String mobile = (map.get("mobile")+"").trim();
|
|
|
String type = (map.get("type")+"").trim();
|
|
|
BasePatientDO patientDO = patientDao.findByIdcard(idcard);
|
|
|
if(patientDO!=null){
|
|
|
if(patientDO.getSignStatus()!=null&&patientDO.getSignStatus()==1){
|
|
|
logger.info("已签约居民idcard="+idcard);
|
|
|
continue;
|
|
|
}
|
|
|
}else{
|
|
|
patientDO = new BasePatientDO();
|
|
|
}
|
|
|
patientDO.setRegister("1");
|
|
|
patientDO.setSaasId(area);
|
|
|
boolean flag = false;
|
|
|
if(StringUtils.isBlank(patientDO.getIdcard())){
|
|
|
String salt = UUID.randomUUID().toString().substring(0,5);
|
|
|
patientDO.setPassword(MD5.md5Hex(idcard + "{" + salt + "}"));
|
|
|
patientDO.setSalt(salt);
|
|
|
patientDO.setOpenid(null);
|
|
|
patientDO.setIdcard(idcard);
|
|
|
patientDO.setSsc(null);
|
|
|
patientDO.setMobile(mobile);
|
|
|
patientDO.setSex(Integer.valueOf(IdCardUtil.getSexForIdcard_new(idcard)));
|
|
|
patientDO.setName(name);
|
|
|
patientDO.setArchiveType(1);
|
|
|
patientDO.setArchiveStatus(1);
|
|
|
if(patientDO.getSex()==2){
|
|
|
patientDO.setPhoto("group1/M00/00/7C/rBoAbmIu8g6ANMrpAAAiSDNDGrM907.png");
|
|
|
}else{
|
|
|
patientDO.setPhoto("group1/M00/00/5A/rBoAb2Iu8gOAQ9WYAAAgcmCLvjQ782.png");
|
|
|
}
|
|
|
patientDO.setDel("1");
|
|
|
patientDO.setLocked(0);
|
|
|
patientDO.setEnabled(1);
|
|
|
patientDO.setSignStatus(0);
|
|
|
patientDO.setCreateTime(new Date());
|
|
|
flag = true;
|
|
|
}
|
|
|
patientDO.setAddress(address);
|
|
|
Map<String,String> tmp = LatitudeUtils.getGeocoderLatitude(address);
|
|
|
if(tmp!=null){
|
|
|
String latlon = tmp.get("lat")+","+tmp.get("lng");
|
|
|
patientDO.setLatLon(latlon);
|
|
|
}
|
|
|
patientDao.save(patientDO);
|
|
|
if(flag){
|
|
|
String label = lableCodeNameMap.get(type);
|
|
|
if(StringUtils.isNotBlank(label)){
|
|
|
WlyyPatientLabelDO patientLabelDO = new WlyyPatientLabelDO();
|
|
|
patientLabelDO.setCzrq(new Date());
|
|
|
patientLabelDO.setLabelType("3");
|
|
|
patientLabelDO.setPatient(patientDO.getId());
|
|
|
patientLabelDO.setLabelCode(label);
|
|
|
patientLabelDO.setLabelName(lableCodeNameMap.get(label));
|
|
|
patientLabelDao.save(patientLabelDO);
|
|
|
}
|
|
|
}
|
|
|
logger.info("idcard="+idcard);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 初始化杭州老人,只保存有身份证且有手机号的数据
|
|
|
*/
|
|
@ -526,8 +662,9 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
|
|
|
JSONObject result = new JSONObject();
|
|
|
BasePatientDO patientDO = patientDao.findById(patient);
|
|
|
if (patientDO==null){
|
|
|
result.put(ResponseContant.resultFlag,ResponseContant.fail);
|
|
|
result.put(ResponseContant.resultMsg,"账号不存在");
|
|
|
result.put(ResponseContant.resultFlag,ResponseContant.success);
|
|
|
result.put(ResponseContant.resultMsg,"操作成功");
|
|
|
return result;
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(patientDO.getIdcard())){
|
|
|
result.put(ResponseContant.resultFlag,ResponseContant.fail);
|
|
@ -747,16 +884,16 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查找签约老人
|
|
|
* 查找签约老人 + 名单800
|
|
|
* @param name
|
|
|
* @param residentialArea
|
|
|
* @param limit
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Map<String,Object>> findOld(String name,String residentialArea,String area,Integer level,String limit,String filter1){
|
|
|
String sql = "SELECT a.id,a.name,a.photo,a.idcard,CAST(IFNULL(a.birthday,'') AS char ) birthday,a.residential_area residentialArea,a.sex " +
|
|
|
String sql = "SELECT DISTINCT a.id,a.name,a.photo,a.idcard,CAST(IFNULL(a.birthday,'') AS char ) birthday,a.residential_area residentialArea,a.sex " +
|
|
|
",a.ykt_id yktId, case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online,IFNULL(sign_status,0) signStatus from base_patient a " +
|
|
|
" WHERE a.archive_type = 1 and a.del = '1' and a.sign_status=1 ";
|
|
|
" WHERE a.archive_type = 1 and a.del = '1' and (a.sign_status=1 or a.register = '1') ";
|
|
|
|
|
|
//case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online
|
|
|
//if(openid is null,0,1) onlineWx,IFNULL(a.on_line,0) onlinePad
|
|
@ -770,7 +907,18 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
|
|
|
sql += " and EXISTS ( select 1 from " +
|
|
|
"base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack " +
|
|
|
" where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " +
|
|
|
" and i.del = 1 and sr.`status`=1 and CONVERT(sr.patient USING utf8) = a.id and r.team_code='"+area+"') ";
|
|
|
" and i.del = 1 and sr.`status`=1 and CONVERT(sr.patient USING utf8) = a.id and r.team_code='"+area+"') ";
|
|
|
|
|
|
sql += " OR (a.saas_id = '"+area+"' ";
|
|
|
|
|
|
if (StringUtils.isNotBlank(name)){
|
|
|
sql+= " and a.name like '%"+name+"%' ";
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(residentialArea)){
|
|
|
sql+= " and a.residential_area = '"+residentialArea+"' ";
|
|
|
}
|
|
|
sql +=" )";
|
|
|
|
|
|
}
|
|
|
sql += filter1;
|
|
|
sql += " GROUP BY a.id,a.name,a.photo,a.idcard,a.birthday,a.residential_area,a.sex,a.ykt_id,online,signStatus ";
|
|
@ -819,7 +967,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
|
|
|
}
|
|
|
|
|
|
public Integer findOldTotal(String name,String residentialArea,String area,Integer level,String filter){
|
|
|
String sql = "SELECT count(a.id) from base_patient a WHERE a.archive_type = 1 and a.del = '1' and a.sign_status=1 ";
|
|
|
String sql = "SELECT count(DISTINCT a.id) from base_patient a WHERE a.archive_type = 1 and a.del = '1' and (a.sign_status=1 or a.register = 1)";
|
|
|
if(!StringUtil.isBlank(name)){
|
|
|
sql+= " and name like '%"+name+"%' ";
|
|
|
}
|
|
@ -830,7 +978,16 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
|
|
|
sql += " and EXISTS ( select 1 from " +
|
|
|
"base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack " +
|
|
|
" where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " +
|
|
|
" and i.del = 1 and sr.`status`=1 and CONVERT(sr.patient USING utf8) = a.id and r.team_code='"+area+"' ) ";
|
|
|
" and i.del = 1 and sr.`status`=1 and CONVERT(sr.patient USING utf8) = a.id and r.team_code='"+area+"' ) ";
|
|
|
|
|
|
sql += "OR (a.saas_id = '"+area+"' ";
|
|
|
if (StringUtils.isNotBlank(name)){
|
|
|
sql+= " and a.name like '%"+name+"%' ";
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(residentialArea)){
|
|
|
sql+= " and a.residential_area = '"+residentialArea+"' ";
|
|
|
}
|
|
|
sql +=" )";
|
|
|
}
|
|
|
sql += filter;
|
|
|
return jdbcTemplate.queryForObject(sql,Integer.class);
|