|
@ -36,21 +36,21 @@ public class LabelService {
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
public List<WlyyPatientLabelDO> findByPatient(String patient){
|
|
|
public List<WlyyPatientLabelDO> findByPatient(String patient) {
|
|
|
return patientLabelDao.findByPatient(patient);
|
|
|
}
|
|
|
|
|
|
//查询专病的康复管理未执行完成数量
|
|
|
public int existDisease(String patient,String disease){
|
|
|
public int existDisease(String patient, String disease) {
|
|
|
String sql = "SELECT COUNT(id) from wlyy_patient_rehabilitation_plan " +
|
|
|
" WHERE patient='"+patient+"' and disease ='"+disease+"' and `status` in (1,3)";
|
|
|
return jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
" WHERE patient='" + patient + "' and disease ='" + disease + "' and `status` in (1,3)";
|
|
|
return jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
}
|
|
|
|
|
|
//添加专病标签
|
|
|
public void addDiseaseLable(String patient,String disease,String diseaseName){
|
|
|
public void addDiseaseLable(String patient, String disease, String diseaseName) {
|
|
|
try {
|
|
|
if(patientLabelDao.findByPatient(patient,disease,"3").size()==0){
|
|
|
if (patientLabelDao.findByPatient(patient, disease, "3").size() == 0) {
|
|
|
WlyyPatientLabelDO label = new WlyyPatientLabelDO();
|
|
|
label.setCzrq(new Date());
|
|
|
label.setIsSystem(0);
|
|
@ -60,52 +60,52 @@ public class LabelService {
|
|
|
label.setLabelType("3");
|
|
|
patientLabelDao.save(label);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//查询标签新增日志
|
|
|
public PageEnvelop patientLabelLogPage(String patient, String doctor, String labelType, int page, int size){
|
|
|
public PageEnvelop patientLabelLogPage(String patient, String doctor, String labelType, int page, int size) {
|
|
|
String sql = "select * ";
|
|
|
String countSql = "select count(*) ";
|
|
|
String filter = " from wlyy_patient_label_log where 1=1 ";
|
|
|
String orderBy = " order by create_time desc limit "+(page-1)*size+","+size;
|
|
|
if(StringUtils.isNotBlank(patient)){
|
|
|
filter += " and patient = '"+patient+"' ";
|
|
|
String orderBy = " order by create_time desc limit " + (page - 1) * size + "," + size;
|
|
|
if (StringUtils.isNotBlank(patient)) {
|
|
|
filter += " and patient = '" + patient + "' ";
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(doctor)){
|
|
|
filter += " and doctor = '"+doctor+"' ";
|
|
|
if (StringUtils.isNotBlank(doctor)) {
|
|
|
filter += " and doctor = '" + doctor + "' ";
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(labelType)){
|
|
|
filter += " and label_type = '"+labelType+"' ";
|
|
|
if (StringUtils.isNotBlank(labelType)) {
|
|
|
filter += " and label_type = '" + labelType + "' ";
|
|
|
}
|
|
|
List<WlyyPatientLabelLogDO> logDOS = jdbcTemplate.query(sql+filter+orderBy,new BeanPropertyRowMapper<>(WlyyPatientLabelLogDO.class));
|
|
|
Long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
|
|
|
return PageEnvelop.getSuccessListWithPage("查询成功",logDOS,page,size,count);
|
|
|
List<WlyyPatientLabelLogDO> logDOS = jdbcTemplate.query(sql + filter + orderBy, new BeanPropertyRowMapper<>(WlyyPatientLabelLogDO.class));
|
|
|
Long count = jdbcTemplate.queryForObject(countSql + filter, Long.class);
|
|
|
return PageEnvelop.getSuccessListWithPage("查询成功", logDOS, page, size, count);
|
|
|
}
|
|
|
|
|
|
//保存居民标签
|
|
|
@Transactional
|
|
|
public void savePatientLabel(List<WlyyPatientLabelDO> labelDOS, String patient,String doctor) throws Exception{
|
|
|
public void savePatientLabel(List<WlyyPatientLabelDO> labelDOS, String patient, String doctor) throws Exception {
|
|
|
List<WlyyPatientLabelDO> patientLabelDOS = patientLabelDao.findByPatient(patient);
|
|
|
Map<String,String> map = new HashMap<>();
|
|
|
for (WlyyPatientLabelDO label:patientLabelDOS){
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
for (WlyyPatientLabelDO label : patientLabelDOS) {
|
|
|
String labelCode = label.getLabelCode();
|
|
|
String labelType = label.getLabelType();
|
|
|
map.put(labelType+"_"+labelCode,label.getLabelName());
|
|
|
map.put(labelType + "_" + labelCode, label.getLabelName());
|
|
|
}
|
|
|
patientLabelDao.deleteByPatient(patient);
|
|
|
List<WlyyPatientLabelLogDO> labelLogDOS = new ArrayList<>();
|
|
|
Date now = new Date();
|
|
|
BaseDoctorDO doctorDO = doctorDao.findByIdAndDel(doctor);
|
|
|
if(labelDOS!=null&&labelDOS.size()>0){
|
|
|
for (WlyyPatientLabelDO label:labelDOS){
|
|
|
if (labelDOS != null && labelDOS.size() > 0) {
|
|
|
for (WlyyPatientLabelDO label : labelDOS) {
|
|
|
label.setPatient(patient);
|
|
|
label.setCzrq(new Date());
|
|
|
label.setIsSystem(0);
|
|
|
String key = label.getLabelType()+"_"+label.getLabelCode();
|
|
|
if(!map.containsKey(key)){
|
|
|
String key = label.getLabelType() + "_" + label.getLabelCode();
|
|
|
if (!map.containsKey(key)) {
|
|
|
WlyyPatientLabelLogDO logDO = new WlyyPatientLabelLogDO();
|
|
|
logDO.setCreateTime(now);
|
|
|
logDO.setPatient(patient);
|
|
@ -119,20 +119,20 @@ public class LabelService {
|
|
|
}
|
|
|
}
|
|
|
patientLabelDao.saveAll(labelDOS);
|
|
|
if(labelLogDOS.size()>0){
|
|
|
if (labelLogDOS.size() > 0) {
|
|
|
logDao.saveAll(labelLogDOS);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//添加自定义标签字典
|
|
|
public WlyyHospitalSysDictDO addLabelDict(String labelName) throws Exception{
|
|
|
if(StringUtils.isBlank(labelName)){
|
|
|
public WlyyHospitalSysDictDO addLabelDict(String labelName) throws Exception {
|
|
|
if (StringUtils.isBlank(labelName)) {
|
|
|
throw new ServiceException("请填写分组名称");
|
|
|
}
|
|
|
labelName = labelName.trim();
|
|
|
List<WlyyHospitalSysDictDO> dictDOList = wlyyHospitalSysDictDao.findByDictNameAndDictCode("patient_lable_custom",labelName);
|
|
|
if(dictDOList.size()>0){
|
|
|
List<WlyyHospitalSysDictDO> dictDOList = wlyyHospitalSysDictDao.findByDictNameAndDictCode("patient_lable_custom", labelName);
|
|
|
if (dictDOList.size() > 0) {
|
|
|
throw new ServiceException("该分组已存在");
|
|
|
}
|
|
|
WlyyHospitalSysDictDO dictDO = new WlyyHospitalSysDictDO();
|
|
@ -142,4 +142,47 @@ public class LabelService {
|
|
|
dictDO = wlyyHospitalSysDictDao.save(dictDO);
|
|
|
return dictDO;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* //三院 labelType 1健康情况 2疾病类型 3专病类型 4自定义标签
|
|
|
*/
|
|
|
public List<Map<String, Object>> findLabelPatientGroupCount(String name, String labelType) {
|
|
|
String sql = "SELECT\n" +
|
|
|
" a.label_code,a.label_name,count(1) 'labelCount'\n" +
|
|
|
"FROM\n" +
|
|
|
" wlyy_patient_label a\n" +
|
|
|
" INNER JOIN base_patient b ON a.patient=b.id\n" +
|
|
|
"WHERE\n" +
|
|
|
" 1 = 1 \n" +
|
|
|
" AND a.label_type='" + labelType + "'";
|
|
|
|
|
|
if (StringUtils.isNotBlank(name)) {
|
|
|
sql += " AND b.`name` LIKE '%" + name + "%'\n";
|
|
|
}
|
|
|
|
|
|
sql += "GROUP BY a.label_code";
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
|
|
|
public List findLabelPatientList(String name, String labelType, String labelCode) {
|
|
|
String sql = "SELECT\n" +
|
|
|
" a.label_code 'labelCode',a.label_name 'labelName',b.* \n" +
|
|
|
"FROM\n" +
|
|
|
" wlyy_patient_label a\n" +
|
|
|
" INNER JOIN base_patient b ON a.patient=b.id\n" +
|
|
|
"WHERE\n" +
|
|
|
" 1 = 1 \n" +
|
|
|
" AND a.label_type='" + labelType + "'";
|
|
|
|
|
|
if (StringUtils.isNotBlank(name)) {
|
|
|
sql += " AND b.`name` LIKE '%" + name + "%'\n";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(labelCode)) {
|
|
|
sql += " AND a.label_code='" + labelCode + "'";
|
|
|
}
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
return list;
|
|
|
}
|
|
|
}
|