修改患者参数设置。
This commit is contained in:
parent
17fdd5c280
commit
88d56b5565
@ -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;
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package com.xinelu.common.utils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.util.Calendar;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@ -134,6 +135,11 @@ public class BaseUtil {
|
||||
return "MALE";
|
||||
}
|
||||
}
|
||||
public static int getAge(LocalDate birthDate) {
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
Period period = Period.between(birthDate, currentDate);
|
||||
return period.getYears();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
|
||||
@ -464,107 +464,5 @@ public class SignPatientManageRouteNodeServiceImpl implements ISignPatientManage
|
||||
}
|
||||
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());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,9 @@ package com.xinelu.manage.service.specialdiseasenode.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.xinelu.common.core.domain.AjaxResult;
|
||||
import com.xinelu.common.enums.PatientSexEnum;
|
||||
import com.xinelu.common.exception.ServiceException;
|
||||
import com.xinelu.common.utils.BaseUtil;
|
||||
import com.xinelu.common.utils.SecurityUtils;
|
||||
import com.xinelu.common.utils.bean.BeanUtils;
|
||||
import com.xinelu.manage.domain.patientinfo.PatientInfo;
|
||||
@ -28,6 +30,7 @@ import java.util.stream.Collectors;
|
||||
import javax.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
@ -209,34 +212,52 @@ public class SpecialDiseaseNodeServiceImpl implements ISpecialDiseaseNodeService
|
||||
paramsQuery.setRouteNodeId(id);
|
||||
List<PatientNodeParamsCurrent> nodeParams = patientNodeParamsCurrentMapper.selectPatientNodeParamsCurrentList(paramsQuery);
|
||||
|
||||
if (CollectionUtils.isEmpty(nodeParams)) {
|
||||
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 nodeParam = new PatientNodeParamsCurrent();
|
||||
String paramKey = span.attr("data-fieldMark");
|
||||
String paramName = span.attr("data-fileSpan");
|
||||
nodeParam.setSn("1");
|
||||
nodeParam.setParamName(paramName);
|
||||
nodeParam.setParamKey(paramKey);
|
||||
nodeParam.setParamValue(paramValues.getOrDefault(paramKey, "").toString());
|
||||
nodeParams.add(nodeParam);
|
||||
}
|
||||
// nodeParams去重
|
||||
nodeParams = nodeParams.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(()-> new TreeSet<>(Comparator.comparing(PatientNodeParamsCurrent::getParamKey))), ArrayList::new));
|
||||
retList.add(nodeParams);
|
||||
// 查询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()) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -253,6 +274,10 @@ public class SpecialDiseaseNodeServiceImpl implements ISpecialDiseaseNodeService
|
||||
// 健康档案
|
||||
case "TPC202405200001":
|
||||
retObj = JSONObject.parseObject(JSONObject.toJSONString(patientInfo));
|
||||
// 性别转换成中文
|
||||
retObj.fluentPut("sex", PatientSexEnum.getInfoByCode(patientInfo.getSex()).getInfo());
|
||||
//年龄
|
||||
retObj.fluentPut("age", BaseUtil.getAge(patientInfo.getBirthDate()));
|
||||
break;
|
||||
default:
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user