修改患者参数设置。

This commit is contained in:
haown 2024-05-24 16:12:12 +08:00
parent 17fdd5c280
commit 88d56b5565
4 changed files with 100 additions and 124 deletions

View File

@ -0,0 +1,47 @@
package com.xinelu.common.enums;
import lombok.Getter;
/**
* @Description 患者性别
* @Author haown
* @Date 2024-05-24
*/
@Getter
public enum PatientSexEnum {
/**
*
*/
MALE("MALE", ""),
/**
*
*/
FEMALE("FEMALE", ""),
;
private final String code;
private final String info;
PatientSexEnum(String code, String info) {
this.code = code;
this.info = info;
}
public String getCode() {
return code;
}
public String getInfo() {
return info;
}
public static PatientSexEnum getInfoByCode(String code) {
for (PatientSexEnum sex : PatientSexEnum.values()) {
if (code.equals(sex.getInfo())) {
return sex;
}
}
return PatientSexEnum.MALE;
}
}

View File

@ -1,6 +1,7 @@
package com.xinelu.common.utils; package com.xinelu.common.utils;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.Period;
import java.util.Calendar; import java.util.Calendar;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -134,6 +135,11 @@ public class BaseUtil {
return "MALE"; return "MALE";
} }
} }
public static int getAge(LocalDate birthDate) {
LocalDate currentDate = LocalDate.now();
Period period = Period.between(birthDate, currentDate);
return period.getYears();
}
/** /**
* @return boolean * @return boolean

View File

@ -464,107 +464,5 @@ public class SignPatientManageRouteNodeServiceImpl implements ISignPatientManage
} }
return document.body().html(); return document.body().html();
} }
// nodeContent标签提取替换
public static void main(String[] args) {
// json为数据库中的对象
JSONObject json = new JSONObject();
json.fluentPut("patientName", "张三");
json.fluentPut("sex", "");
json.fluentPut("age", "10");
// html为前端传入后端的数据
String s = "<p><strong>基本信息</strong></p><p>姓名:<span data-w-e-type=\"attachmenttwo\"\n"
+ " data-w-e-is-void\n"
+ " data-w-e-is-inline\n"
+ " data-link=\"\"\n"
+ " data-fieldMark=\"patientName\"\n"
+ " data-fileSpan=\"姓名\"\n"
+ " data-fileName=\"基本信息\">\n"
+ " <span class=\"path-tag-wrap\">\n"
+ " <span>基本信息</span>\n"
+ " <span>姓名</span>\n"
+ " </span>\n"
+ " </span></p><p>性别:<span data-w-e-type=\"attachmenttwo\"\n"
+ " data-w-e-is-void\n"
+ " data-w-e-is-inline\n"
+ " data-link=\"\"\n"
+ " data-fieldMark=\"sex\"\n"
+ " data-fileSpan=\"性别\"\n"
+ " data-fileName=\"基本信息\">\n"
+ " <span class=\"path-tag-wrap\">\n"
+ " <span>基本信息</span>\n"
+ " <span>性别</span>\n"
+ " </span>\n"
+ " </span></p><p>年龄:<span data-w-e-type=\"attachmenttwo\"\n"
+ " data-w-e-is-void\n"
+ " data-w-e-is-inline\n"
+ " data-link=\"\"\n"
+ " data-fieldMark=\"age\"\n"
+ " data-fileSpan=\"年龄\"\n"
+ " data-fileName=\"基本信息\">\n"
+ " <span class=\"path-tag-wrap\">\n"
+ " <span>基本信息</span>\n"
+ " <span>年龄</span>\n"
+ " </span>\n"
+ " </span></p><p>地址:<span data-w-e-type=\"attachmenttwo\"\n"
+ " data-w-e-is-void\n"
+ " data-w-e-is-inline\n"
+ " data-link=\"\"\n"
+ " data-fieldMark=\"address\"\n"
+ " data-fileSpan=\"地址\"\n"
+ " data-fileName=\"基本信息\">\n"
+ " <span class=\"path-tag-wrap\">\n"
+ " <span>基本信息</span>\n"
+ " <span>地址</span>\n"
+ " </span>\n"
+ " </span></p>";
Document document = Jsoup.parse(s);
//Elements spanlist = document.getElementsByClass("attachment");
//for (Element span : spanlist) {
// span.text(json.getString(span.id()))
// .removeAttr("id")
// .removeAttr("class")
// .removeAttr("data-w-e-type")
// .removeAttr("data-link")
// .removeAttr("data-w-e-is-void")
// .removeAttr("data-w-e-is-inline")
// .removeAttr("data-filespan")
// .removeAttr("data-filename");
//}
//Elements element = document.getElementsByTag("p");
//System.out.println("---------------------\n"+element.get(0).html());
//Elements spanlist = document.select("span[data-w-e-type]");
//for (Element span : spanlist) {
// String paramKey = span.attr("data-fieldMark");
// String paramName = span.attr("data-fileSpan");
// System.out.println("属性==========" + paramName + ":"+ paramKey);
//}
Elements spanlist = document.select("span[data-w-e-type]");
for (Element span : spanlist) {
PatientNodeParamsCurrent nodeParam = new PatientNodeParamsCurrent();
String paramKey = span.attr("data-fieldMark");
String text = json.getOrDefault(paramKey, "").toString();
//span.replaceWith(new TextNode("<p>" + text +"</p"));
span.text(text);
// .removeAttr("id")
// .removeAttr("class")
// .removeAttr("data-w-e-type")
// .removeAttr("data-link")
// .removeAttr("data-w-e-is-void")
// .removeAttr("data-w-e-is-inline")
// .removeAttr("data-fieldmark")
// .removeAttr("data-filespan")
// .removeAttr("data-filename");
span.unwrap();
//Element newSpan = new Element(Tag.valueOf("c"), "");
//newSpan.text(text);
//span.replaceWith(newSpan);
}
//Elements element = document.getElementsByTag("p");
//System.out.println("---------------------\n"+element.get(0).html());
//System.out.println(document.body().html());
}
} }

View File

@ -2,7 +2,9 @@ package com.xinelu.manage.service.specialdiseasenode.impl;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.xinelu.common.core.domain.AjaxResult; import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.enums.PatientSexEnum;
import com.xinelu.common.exception.ServiceException; import com.xinelu.common.exception.ServiceException;
import com.xinelu.common.utils.BaseUtil;
import com.xinelu.common.utils.SecurityUtils; import com.xinelu.common.utils.SecurityUtils;
import com.xinelu.common.utils.bean.BeanUtils; import com.xinelu.common.utils.bean.BeanUtils;
import com.xinelu.manage.domain.patientinfo.PatientInfo; import com.xinelu.manage.domain.patientinfo.PatientInfo;
@ -28,6 +30,7 @@ import java.util.stream.Collectors;
import javax.annotation.Resource; import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
@ -209,34 +212,52 @@ public class SpecialDiseaseNodeServiceImpl implements ISpecialDiseaseNodeService
paramsQuery.setRouteNodeId(id); paramsQuery.setRouteNodeId(id);
List<PatientNodeParamsCurrent> nodeParams = patientNodeParamsCurrentMapper.selectPatientNodeParamsCurrentList(paramsQuery); List<PatientNodeParamsCurrent> nodeParams = patientNodeParamsCurrentMapper.selectPatientNodeParamsCurrentList(paramsQuery);
if (CollectionUtils.isEmpty(nodeParams)) { // 查询SpecialDiseaseNode中包含的可编辑标签
SpecialDiseaseNode specialDiseaseNode = specialDiseaseNodeMapper.selectSpecialDiseaseNodeById(id); List<PatientNodeParamsCurrent> diseaseNodeParams = new ArrayList<>();
if (StringUtils.isNotBlank(specialDiseaseNode.getNodeContent()) && specialDiseaseNode.getNodeContent().contains("data-fieldMark")) { SpecialDiseaseNode specialDiseaseNode = specialDiseaseNodeMapper.selectSpecialDiseaseNodeById(id);
JSONObject paramValues = getParamsValue(specialDiseaseNode.getTaskSubdivision(), patientId); if (StringUtils.isNotBlank(specialDiseaseNode.getNodeContent()) && specialDiseaseNode.getNodeContent().contains("data-fieldMark")) {
Document document = Jsoup.parse(specialDiseaseNode.getNodeContent()); JSONObject paramValues = getParamsValue(specialDiseaseNode.getTaskSubdivision(), patientId);
// 需要提取的span Document document = Jsoup.parse(specialDiseaseNode.getNodeContent());
Elements spanlist = document.select("span[data-w-e-type]"); // 需要提取的span
for (Element span : spanlist) { Elements spanlist = document.select("span[data-w-e-type]");
PatientNodeParamsCurrent nodeParam = new PatientNodeParamsCurrent(); for (Element span : spanlist) {
String paramKey = span.attr("data-fieldMark"); PatientNodeParamsCurrent nodeParamCurrent = new PatientNodeParamsCurrent();
String paramName = span.attr("data-fileSpan"); String paramKey = span.attr("data-fieldMark");
nodeParam.setSn("1"); String paramName = span.attr("data-fileSpan");
nodeParam.setParamName(paramName); nodeParamCurrent.setSn("1");
nodeParam.setParamKey(paramKey); nodeParamCurrent.setParamName(paramName);
nodeParam.setParamValue(paramValues.getOrDefault(paramKey, "").toString()); nodeParamCurrent.setParamKey(paramKey);
nodeParams.add(nodeParam); nodeParamCurrent.setParamValue(paramValues.getOrDefault(paramKey, "").toString());
} diseaseNodeParams.add(nodeParamCurrent);
// nodeParams去重
nodeParams = nodeParams.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(()-> new TreeSet<>(Comparator.comparing(PatientNodeParamsCurrent::getParamKey))), ArrayList::new));
retList.add(nodeParams);
} }
// 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 { } else {
// 之前维护过参数则将参数进行对比
Map<String, List<PatientNodeParamsCurrent>> groupBySn = nodeParams.stream().collect(Collectors.groupingBy(PatientNodeParamsCurrent::getSn)); Map<String, List<PatientNodeParamsCurrent>> groupBySn = nodeParams.stream().collect(Collectors.groupingBy(PatientNodeParamsCurrent::getSn));
for (String sn : groupBySn.keySet()) { for (String sn : groupBySn.keySet()) {
retList.add(groupBySn.get(sn)); 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; return retList;
} }
@ -253,6 +274,10 @@ public class SpecialDiseaseNodeServiceImpl implements ISpecialDiseaseNodeService
// 健康档案 // 健康档案
case "TPC202405200001": case "TPC202405200001":
retObj = JSONObject.parseObject(JSONObject.toJSONString(patientInfo)); retObj = JSONObject.parseObject(JSONObject.toJSONString(patientInfo));
// 性别转换成中文
retObj.fluentPut("sex", PatientSexEnum.getInfoByCode(patientInfo.getSex()).getInfo());
//年龄
retObj.fluentPut("age", BaseUtil.getAge(patientInfo.getBirthDate()));
break; break;
default: default:
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");