Merge branch '0418_小程序开发' of http://182.92.166.109:3000/zhuangyuanke/PostDischargePatientManage into 0418_小程序开发

This commit is contained in:
haown 2024-05-30 17:55:13 +08:00
commit 26b455d0b5
3 changed files with 130 additions and 85 deletions

View File

@ -0,0 +1,39 @@
package com.xinelu.common.enums;
import lombok.Getter;
@Getter
public enum TemplateTypeEnum {
/**
* 话术
*/
SCRIPT("SCRIPT"),
/**
* 微信
*/
WECHAT("WECHAT"),
/**
* 短信
*/
TEXT_MESSAGE("TEXT_MESSAGE"),
/**
* 问卷
*/
QUESTIONNAIRE("QUESTIONNAIRE"),
/**
* 宣教
*/
PROPAGANDA("PROPAGANDA"),
;
final private String info;
TemplateTypeEnum(String info) {
this.info = info;
}
}

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.enums.PatientSexEnum;
import com.xinelu.common.enums.ReleaseStatusEnum;
import com.xinelu.common.enums.TemplateTypeEnum;
import com.xinelu.common.exception.ServiceException;
import com.xinelu.common.utils.BaseUtil;
import com.xinelu.common.utils.SecurityUtils;
@ -143,7 +144,11 @@ public class SpecialDiseaseNodeServiceImpl implements ISpecialDiseaseNodeService
if (StringUtils.isNotBlank(diseaseNode.getRouteNodeName()) && Objects.nonNull(diseaseNode.getRouteNodeDay()) && StringUtils.isNotBlank(diseaseNode.getTaskType()) && StringUtils.isNotBlank(diseaseNode.getTaskSubdivision()) && StringUtils.isNotBlank(diseaseNode.getTaskStatus())) {
diseaseNode.setRouteId(specialDiseaseRoute.getId());
diseaseNode.setRouteName(specialDiseaseNode.getRouteName());
diseaseNode.setTemplateType(diseaseNode.getTaskSubdivisiontemplateType());
diseaseNode.setTemplateType(null);
if (StringUtils.isNotBlank(diseaseNode.getTaskSubdivisiontemplateType())
&& (TemplateTypeEnum.QUESTIONNAIRE.getInfo().equals(diseaseNode.getTaskSubdivisiontemplateType()) || TemplateTypeEnum.PROPAGANDA.getInfo().equals(diseaseNode.getTaskSubdivisiontemplateType()))) {
diseaseNode.setTemplateType(diseaseNode.getTaskSubdivisiontemplateType());
}
diseaseNode.setUpdateTime(LocalDateTime.now());
diseaseNode.setUpdateBy(SecurityUtils.getUsername());
specialDiseaseNodeVOS.add(diseaseNode);
@ -206,88 +211,89 @@ public class SpecialDiseaseNodeServiceImpl implements ISpecialDiseaseNodeService
return AjaxResult.success(specialDiseaseNodeMapper.updateSpecialDiseaseNode(specialDiseaseNode));
}
@Override
public List<List<PatientNodeParamsCurrent>> getParams(Long id, Long patientId) {
List<List<PatientNodeParamsCurrent>> retList = new ArrayList<>();
// 根据节点id查询是否有已经维护的参数
PatientNodeParamsCurrent paramsQuery = new PatientNodeParamsCurrent();
paramsQuery.setPatientId(patientId);
paramsQuery.setRouteNodeId(id);
List<PatientNodeParamsCurrent> nodeParams = patientNodeParamsCurrentMapper.selectPatientNodeParamsCurrentList(paramsQuery);
@Override
public List<List<PatientNodeParamsCurrent>> getParams(Long id, Long patientId) {
List<List<PatientNodeParamsCurrent>> retList = new ArrayList<>();
// 根据节点id查询是否有已经维护的参数
PatientNodeParamsCurrent paramsQuery = new PatientNodeParamsCurrent();
paramsQuery.setPatientId(patientId);
paramsQuery.setRouteNodeId(id);
List<PatientNodeParamsCurrent> nodeParams = patientNodeParamsCurrentMapper.selectPatientNodeParamsCurrentList(paramsQuery);
// 查询SpecialDiseaseNode中包含的可编辑标签
List<PatientNodeParamsCurrent> diseaseNodeParams = new ArrayList<>();
SpecialDiseaseNode specialDiseaseNode = specialDiseaseNodeMapper.selectSpecialDiseaseNodeById(id);
if (StringUtils.isNotBlank(specialDiseaseNode.getNodeContent()) && specialDiseaseNode.getNodeContent().contains("data-fieldMark")) {
JSONObject paramValues = getParamsValue(specialDiseaseNode.getTaskSubdivision(), patientId);
Document document = Jsoup.parse(specialDiseaseNode.getNodeContent());
// 需要提取的span
Elements spanlist = document.select("span[data-w-e-type]");
for (Element span : spanlist) {
PatientNodeParamsCurrent nodeParamCurrent = new PatientNodeParamsCurrent();
String paramKey = span.attr("data-fieldMark");
String paramName = span.attr("data-fileSpan");
nodeParamCurrent.setSn("1");
nodeParamCurrent.setParamName(paramName);
nodeParamCurrent.setParamKey(paramKey);
nodeParamCurrent.setParamValue(paramValues.getOrDefault(paramKey, "").toString());
diseaseNodeParams.add(nodeParamCurrent);
}
// nodeParams去重
diseaseNodeParams = diseaseNodeParams.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(()-> new TreeSet<>(Comparator.comparing(PatientNodeParamsCurrent::getParamKey))), ArrayList::new));
}
// 之前未维护过参数专病路径节点中的参数为返回值
if (CollectionUtils.isEmpty(nodeParams)) {
retList.add(diseaseNodeParams);
} else {
// 之前维护过参数则将参数进行对比
Map<String, List<PatientNodeParamsCurrent>> groupBySn = nodeParams.stream().collect(Collectors.groupingBy(PatientNodeParamsCurrent::getSn));
for (String sn : groupBySn.keySet()) {
List<PatientNodeParamsCurrent> oldParams = groupBySn.get(sn);
//List<String> paramKeys = oldParams.stream().map(PatientNodeParamsCurrent::getParamKey).collect(Collectors.toList());
//List<String> newKeys = diseaseNodeParams.stream().map(PatientNodeParamsCurrent::getParamKey).collect(Collectors.toList());
//if (ListUtils.isEqualList(paramKeys, newKeys)) {
// retList.add(oldParams);
//} else {
// for(PatientNodeParamsCurrent nodeParam : diseaseNodeParams) {
// if (!paramKeys.contains(nodeParam.getParamKey())) {
// oldParams.add(nodeParam);
// }
// if (!newKeys.contains(nodeParam.getParamKey())) {
// oldParams.remove(nodeParam);
// }
// }
retList.add(oldParams);
//}
}
}
return retList;
}
// 查询SpecialDiseaseNode中包含的可编辑标签
List<PatientNodeParamsCurrent> diseaseNodeParams = new ArrayList<>();
SpecialDiseaseNode specialDiseaseNode = specialDiseaseNodeMapper.selectSpecialDiseaseNodeById(id);
if (StringUtils.isNotBlank(specialDiseaseNode.getNodeContent()) && specialDiseaseNode.getNodeContent().contains("data-fieldMark")) {
JSONObject paramValues = getParamsValue(specialDiseaseNode.getTaskSubdivision(), patientId);
Document document = Jsoup.parse(specialDiseaseNode.getNodeContent());
// 需要提取的span
Elements spanlist = document.select("span[data-w-e-type]");
for (Element span : spanlist) {
PatientNodeParamsCurrent nodeParamCurrent = new PatientNodeParamsCurrent();
String paramKey = span.attr("data-fieldMark");
String paramName = span.attr("data-fileSpan");
nodeParamCurrent.setSn("1");
nodeParamCurrent.setParamName(paramName);
nodeParamCurrent.setParamKey(paramKey);
nodeParamCurrent.setParamValue(paramValues.getOrDefault(paramKey, "").toString());
diseaseNodeParams.add(nodeParamCurrent);
}
// nodeParams去重
diseaseNodeParams = diseaseNodeParams.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(PatientNodeParamsCurrent::getParamKey))), ArrayList::new));
}
// 之前未维护过参数专病路径节点中的参数为返回值
if (CollectionUtils.isEmpty(nodeParams)) {
retList.add(diseaseNodeParams);
} else {
// 之前维护过参数则将参数进行对比
Map<String, List<PatientNodeParamsCurrent>> groupBySn = nodeParams.stream().collect(Collectors.groupingBy(PatientNodeParamsCurrent::getSn));
for (String sn : groupBySn.keySet()) {
List<PatientNodeParamsCurrent> oldParams = groupBySn.get(sn);
//List<String> paramKeys = oldParams.stream().map(PatientNodeParamsCurrent::getParamKey).collect(Collectors.toList());
//List<String> newKeys = diseaseNodeParams.stream().map(PatientNodeParamsCurrent::getParamKey).collect(Collectors.toList());
//if (ListUtils.isEqualList(paramKeys, newKeys)) {
// retList.add(oldParams);
//} else {
// for(PatientNodeParamsCurrent nodeParam : diseaseNodeParams) {
// if (!paramKeys.contains(nodeParam.getParamKey())) {
// oldParams.add(nodeParam);
// }
// if (!newKeys.contains(nodeParam.getParamKey())) {
// oldParams.remove(nodeParam);
// }
// }
retList.add(oldParams);
//}
}
}
return retList;
}
/**
* 根据任务细分类型获取患者的真实信息
* @param taskSubdivision 任务细分类型code
* @param patientId 患者主键
* @return 实际信息
*/
private JSONObject getParamsValue(String taskSubdivision, Long patientId) {
JSONObject retObj = new JSONObject();
PatientInfo patientInfo = patientInfoMapper.selectPatientInfoById(patientId);
switch (taskSubdivision) {
// 健康档案
case "HEALTH_ARCHIVE":
retObj = JSONObject.parseObject(JSONObject.toJSONString(patientInfo));
// 性别转换成中文计算年龄
retObj.fluentPut("sex", PatientSexEnum.getInfoByCode(patientInfo.getSex()).getInfo())
.fluentPut("age", BaseUtil.getAge(patientInfo.getBirthDate()));
break;
default:
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
retObj.fluentPut("patientName", patientInfo.getPatientName())
.fluentPut("dischargeTime", patientInfo.getDischargeTime() == null ? "" : patientInfo.getDischargeTime().format(df))
.fluentPut("visitDate", patientInfo.getVisitDate().format(df));
break;
}
return retObj;
}
/**
* 根据任务细分类型获取患者的真实信息
*
* @param taskSubdivision 任务细分类型code
* @param patientId 患者主键
* @return 实际信息
*/
private JSONObject getParamsValue(String taskSubdivision, Long patientId) {
JSONObject retObj = new JSONObject();
PatientInfo patientInfo = patientInfoMapper.selectPatientInfoById(patientId);
switch (taskSubdivision) {
// 健康档案
case "HEALTH_ARCHIVE":
retObj = JSONObject.parseObject(JSONObject.toJSONString(patientInfo));
// 性别转换成中文计算年龄
retObj.fluentPut("sex", PatientSexEnum.getInfoByCode(patientInfo.getSex()).getInfo())
.fluentPut("age", BaseUtil.getAge(patientInfo.getBirthDate()));
break;
default:
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
retObj.fluentPut("patientName", patientInfo.getPatientName())
.fluentPut("dischargeTime", patientInfo.getDischargeTime() == null ? "" : patientInfo.getDischargeTime().format(df))
.fluentPut("visitDate", patientInfo.getVisitDate().format(df));
break;
}
return retObj;
}
}

View File

@ -227,8 +227,8 @@ public class SpecialDiseaseRouteServiceImpl implements ISpecialDiseaseRouteServi
if (ReleaseStatusEnum.PUBLISHED.getInfo().equals(specialDiseaseRoute.getReleaseStatus())) {
// 专病路径没有节点不能发布
int count = specialDiseaseRouteMapper.selectRouteCheckStatus(specialDiseaseRoute.getId(), RouteCheckStatusEnum.AGREE.getInfo());
if (count > 0) {
return AjaxResult.error("该路径存在未审核的节点,请全部审核后发布!");
if (count >= 0) {
return AjaxResult.error("该路径无节点或存在未审核的节点,请全部审核后发布!");
}
}
if (ReleaseStatusEnum.UNPUBLISHED.getInfo().equals(specialDiseaseRoute.getReleaseStatus())) {