|
@ -2,6 +2,7 @@ package com.yihu.jw.care.service.sign;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.jw.care.dao.apply.PatientBedApplyDao;
|
|
|
import com.yihu.jw.care.dao.sign.*;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
@ -11,6 +12,7 @@ import com.yihu.jw.entity.base.servicePackage.ServicePackageDO;
|
|
|
import com.yihu.jw.entity.base.servicePackage.ServicePackageItemDO;
|
|
|
import com.yihu.jw.entity.base.servicePackage.ServicePackageRecordDO;
|
|
|
import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
|
|
|
import com.yihu.jw.entity.care.apply.PatientBedApplyDo;
|
|
|
import com.yihu.jw.entity.care.archive.ArchiveDO;
|
|
|
import com.yihu.jw.entity.care.sign.CapacityAssessmentRecordDO;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
@ -67,6 +69,8 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
|
|
|
private BasePatientMedicardCardService basePatientMedicardCardService;
|
|
|
@Autowired
|
|
|
private StringRedisTemplate redisTemplate;
|
|
|
@Autowired
|
|
|
private PatientBedApplyDao bedApplyDao;
|
|
|
|
|
|
/**
|
|
|
* 查找签约机构
|
|
@ -308,6 +312,7 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public JSONObject servicePackageSign(String jsonData,String doctorId,String patientId) throws Exception{
|
|
|
BasePatientDO patientDO = patientDao.findById(patientId);
|
|
|
JSONObject result = new JSONObject();
|
|
|
ServicePackageSignRecordDO signRecordDO = objectMapper.readValue(jsonData, ServicePackageSignRecordDO.class);
|
|
|
signRecordDO.setPatient(patientId);
|
|
@ -336,6 +341,11 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
|
|
|
archiveDao.save(archiveDO);
|
|
|
}
|
|
|
}else{
|
|
|
ArchiveDO archiveDO = archiveDao.findByPatientAndDoctorCode(patientId,doctorId);
|
|
|
if(archiveDO!=null){
|
|
|
archiveDO.setSignStatus(1);
|
|
|
archiveDao.save(archiveDO);
|
|
|
}
|
|
|
signId = signRecordDOs.get(0).getId();
|
|
|
List<ServicePackageRecordDO> existList = servicePackageRecordDao.findBySignId(signId);
|
|
|
idList = existList.stream().map(ServicePackageRecordDO::getServicePackageId).collect(Collectors.toList());
|
|
@ -367,17 +377,23 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
|
|
|
Map<String,List<Map<String,Object>>> newItem = itemList.stream().collect(Collectors.groupingBy(e->e.get("code").toString()));
|
|
|
if (newItem.containsKey("emergencyAssistance")&&signItem.containsKey("emergencyAssistance")){
|
|
|
String message = "重复签约服务项目:"+newItem.get("emergencyAssistance").get(0).get("name").toString();
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
result.put(ResponseContant.resultMsg,message);
|
|
|
return result;
|
|
|
throw new Exception(message);
|
|
|
}
|
|
|
CapacityAssessmentRecordDO capacityAssessmentRecordDO = capacityAssessmentRecordService.findAssessmentByPatientId(patientId);
|
|
|
capacityAssessmentRecordDO.setServicePackageStatus(1);
|
|
|
capacityAssessmentRecordService.save(capacityAssessmentRecordDO);
|
|
|
servicePackageRecordDao.save(recordDOList);
|
|
|
}
|
|
|
CapacityAssessmentRecordDO capacityAssessmentRecordDO = capacityAssessmentRecordService.findAssessmentByPatientId(patientId);
|
|
|
capacityAssessmentRecordDO.setServicePackageStatus(1);
|
|
|
capacityAssessmentRecordService.save(capacityAssessmentRecordDO);
|
|
|
servicePackageRecordDao.save(recordDOList);
|
|
|
|
|
|
//修改床位生请状态为已完成
|
|
|
PatientBedApplyDo bedApplyDo = bedApplyDao.findByIdcardAndStatus(patientDO.getIdcard(),2);
|
|
|
if (bedApplyDo!=null) {
|
|
|
bedApplyDo.setStatus(0);
|
|
|
bedApplyDao.save(bedApplyDo);
|
|
|
}
|
|
|
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
result.put(ResponseContant.resultMsg,"分配成功");
|
|
|
result.put(ResponseContant.resultMsg,signRecordDO);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@ -427,7 +443,7 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
|
|
|
|
|
|
public List<Map<String,Object>> serviceItemByPackageId(String packageId){
|
|
|
String sql ="select it.code,it.name,count(it.code)count,pack.introduce,pack.type,pack.`name` from base_service_package_item it " +
|
|
|
"INNER JOIN base_service_package pack on it.service_package_id = pack.id where it.service_package_id='"+packageId+"' group by it.code ";
|
|
|
"INNER JOIN base_service_package pack on it.service_package_id = pack.id where it.service_package_id='"+packageId+"' and pack.del=1 group by it.code ";
|
|
|
List<Map<String,Object>> result = jdbcTemplate.queryForList(sql);
|
|
|
return result;
|
|
|
}
|
|
@ -437,14 +453,14 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
|
|
|
String sql="select DISTINCT pack.*,CASE WHEN pack.type=1 THEN '养老服务' WHEN pack.type=2 THEN '医疗服务'\n" +
|
|
|
"WHEN pack.type=3 THEN '安防监护' WHEN pack.type=4 THEN '慢病管理' ELSE pack.type\n" +
|
|
|
"END as 'typeName' from base_service_package_record re, base_service_package_item item,base_service_package pack \n" +
|
|
|
"where re.service_package_id = item.service_package_id and item.service_package_id = pack.id and item.code='"+serverItem+"' and re.sign_id in (\n" +
|
|
|
"where re.service_package_id = item.service_package_id and item.service_package_id = pack.id and pack.del=1 and item.code='"+serverItem+"' and re.sign_id in (\n" +
|
|
|
"select rd.id from base_service_package_sign_record rd where rd.patient='"+patient+"' and rd.status=1) ";
|
|
|
List<Map<String,Object>> resultSql = jdbcTemplate.queryForList(sql);
|
|
|
//查询服务包的服务项目
|
|
|
for (Map<String,Object> map:resultSql){
|
|
|
String packageId = map.get("id").toString();
|
|
|
sql="select DISTINCT it.code serverItem,it.name,pack.introduce,pack.type packageType,pack.`name` packageName from base_service_package_item it \n" +
|
|
|
"INNER JOIN base_service_package pack on it.service_package_id = pack.id where it.service_package_id='"+packageId+"' group by it.code";
|
|
|
"INNER JOIN base_service_package pack on it.service_package_id = pack.id where pack.del=1 and it.service_package_id='"+packageId+"' group by it.code";
|
|
|
List<Map<String,Object>> resultTmp = jdbcTemplate.queryForList(sql);
|
|
|
map.put("serverItems",resultTmp);
|
|
|
}
|
|
@ -459,13 +475,13 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
|
|
|
"CASE WHEN doc.doctor_level=1 THEN '(社区医生)' ELSE '(助老员)' END) as name,doc.photo,doc.mobile\n" +
|
|
|
"from base_service_package_item item ,base_service_package pack,base_team_member mem,base_doctor doc\n" +
|
|
|
"where item.`code`='"+serverItem+"' and item.service_package_id='"+packageId+"' and item.service_package_id = pack.id " +
|
|
|
"and item.team_code = mem.team_code and mem.doctor_code = doc.id and mem.del=1 ";
|
|
|
"and item.team_code = mem.team_code and mem.doctor_code = doc.id and mem.del=1 and pack.del=1 ";
|
|
|
List<Map<String,Object>>result = jdbcTemplate.queryForList(sql);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public Map<String,Object> getPackageDetailById(String packageId){
|
|
|
String sql="select * from base_service_package where id='"+packageId+"' ";
|
|
|
String sql="select * from base_service_package where id='"+packageId+"' and del=1 ";
|
|
|
Map<String,Object>result = jdbcTemplate.queryForMap(sql);
|
|
|
sql = "select org_code,org_name,introduce from base_service_package_item where service_package_id='"+packageId+"'\n" +
|
|
|
"GROUP BY org_code ORDER BY create_time desc ";
|