Merge remote-tracking branch 'lis8.0/master'

This commit is contained in:
jiangs 2025-09-04 16:57:47 +08:00
commit 4764a89ccb
5 changed files with 257 additions and 213 deletions

View File

@ -20,6 +20,7 @@ public class CalcUtils {
public static String getValueFromCalc(String CalcExpression, Map<String, String> variableMap) { public static String getValueFromCalc(String CalcExpression, Map<String, String> variableMap) {
ExpressionParser parser = new SpelExpressionParser(); ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext context = new StandardEvaluationContext(); StandardEvaluationContext context = new StandardEvaluationContext();
variableMap=replaceAllSpecialKeys(variableMap);
for (Map.Entry<String, String> entry : variableMap.entrySet()) { for (Map.Entry<String, String> entry : variableMap.entrySet()) {
String str = entry.getValue(); String str = entry.getValue();
if (isNumber(str)) { if (isNumber(str)) {
@ -57,13 +58,29 @@ public class CalcUtils {
throw new RuntimeException("表达式计算失败: " + expression, e); throw new RuntimeException("表达式计算失败: " + expression, e);
} }
} }
public static boolean getBooleanFromCalc(String CalcExpression, Map<String, String> variableMap) { public static boolean getBooleanFromCalc(String CalcExpression, Map<String, String> variableMap) {
String resultcondition = "if((" + CalcExpression + ") ,1,0)"; String resultcondition = "if((" + CalcExpression + ") ,1,0)";
String result1 = getValueFromCalc(resultcondition, variableMap); String result1 = getValueFromCalc(resultcondition, variableMap);
if ("1".equals(result1)) return true; if ("1".equals(result1)) return true;
return false; return false;
} }
/**
* 批量替换Map中所有包含"/"的键(将"/"改为"_")
* @param variableMap 原始变量Map
* @return 处理后的Map
*/
public static Map<String, String> replaceAllSpecialKeys(Map<String, String> variableMap) {
Map<String, String> newMap = new HashMap<>();
for (Map.Entry<String, String> entry : variableMap.entrySet()) {
// 将键中所有"/"替换为"_"
String newKey = entry.getKey().replace("/", "_");
newMap.put(newKey, entry.getValue());
}
return newMap;
}
/** /**
* 此方法把PB的计算公式转换为SpEL表达式 * 此方法把PB的计算公式转换为SpEL表达式
* @param CalcExpression * @param CalcExpression
@ -74,7 +91,8 @@ public class CalcUtils {
// 1. 替换逻辑运算符:and→&&,or→|| // 1. 替换逻辑运算符:and→&&,or→||
String processed = CalcExpression.replaceAll("\\band|AND\\b", "&&").replaceAll("\\bor|OR\\b", "||"); String processed = CalcExpression.replaceAll("\\band|AND\\b", "&&").replaceAll("\\bor|OR\\b", "||");
// 2. 替换变量格式:[a] → #a // 2. 替换变量格式:[a] → #a
processed = processed.replaceAll("\\[(\\w+)\\]", "#$1"); processed = processed.replaceAll("\\[(\\w+)/(\\w+)\\]", "[$1_$2]");
processed = processed.replaceAll("\\[([^]]+)\\]", "#$1");
// 3. 替换len()函数为length()方法:len(xxx) → xxx.length() // 3. 替换len()函数为length()方法:len(xxx) → xxx.length()
processed = replaceLenFunction(processed); processed = replaceLenFunction(processed);
//4.like '%aa'或者 like 'aa%'或者 like '%aa%' //4.like '%aa'或者 like 'aa%'或者 like '%aa%'
@ -318,10 +336,13 @@ public class CalcUtils {
// 测试 // 测试
public static void main(String[] args) { public static void main(String[] args) {
Map<String, String> variables = new HashMap<>(); Map<String, String> variables = new HashMap<>();
variables.put("RESULT", "4.0"); // 示例值 variables.put("SEX", "1");
variables.put("CREA", "30.3");
variables.put("AGE", "30");
// 示例值
// variables.put("TP", "6.0"); // variables.put("TP", "6.0");
String testCalc = "if(([结果]>7.12) ,1,0)"; String testCalc = "if([AGE]>18,(if([SEX]=1,(( [CREA] / 88.4)^(-1.234)) * ([AGE]^(-0.179))*175 ,(( [CREA] / 88.4)^(-1.234)) * ([AGE]^(-0.179))*175*0.79)),0)";
testCalc=testCalc.replace("[结果]", "[RESULT]"); // testCalc=testCalc.replace("[结果]", "[RESULT]");
//System.out.println(getCalc(testCalc)); //System.out.println(getCalc(testCalc));
System.out.println(getValueFromCalc(testCalc,variables)); System.out.println(getValueFromCalc(testCalc,variables));

View File

@ -21,6 +21,7 @@ public class CheckResultUtils {
LabCheckrulesMapper labCheckrulesMapper; LabCheckrulesMapper labCheckrulesMapper;
@Autowired @Autowired
CommonUtil commonUtil = new CommonUtil(); CommonUtil commonUtil = new CommonUtil();
public String chksample(LabPat labPat, List<LabResult> labResultList) { public String chksample(LabPat labPat, List<LabResult> labResultList) {
String errmsg = ""; String errmsg = "";
String brdh = labPat.getBrdh(); String brdh = labPat.getBrdh();
@ -30,67 +31,70 @@ public class CheckResultUtils {
String yq = labPat.getYq(); String yq = labPat.getYq();
Date jyrq = labPat.getJyrq(); Date jyrq = labPat.getJyrq();
String ybh = labPat.getYbh(); String ybh = labPat.getYbh();
List<XmInfo> xmInfoList = commonUtil.xmInfoMapper.getXmInfoList(yq); List<XmInfo> xmInfoList0 = commonUtil.getXmInfoList(yq);
for (LabResult labResult : labResultList) { List<XmInfo> xmInfoList = xmInfoList0.stream().filter(xmInfo -> xmInfo.getXjx()!=null||xmInfo.getSjx()!=null||xmInfo.getJgjg()!=null||xmInfo.getJgz()!=null||xmInfo.getJgbz()!=null).collect(Collectors.toList());
String xmdh = labResult.getXmdh(); if(xmInfoList.size()>0) {
List<XmInfo> collect = xmInfoList.stream().filter(xmInfo -> xmInfo.getXmdh().equals(xmdh)).collect(Collectors.toList()); for (LabResult labResult : labResultList) {
if (collect.size() > 0) { String xmdh = labResult.getXmdh();
XmInfo xmInfo = collect.get(0); List<XmInfo> collect = xmInfoList.stream().filter(xmInfo -> xmInfo.getXmdh().equals(xmdh)).collect(Collectors.toList());
//字典规定的结果值范围约束 if (collect.size() > 0) {
Double xjx = xmInfo.getXjx(); XmInfo xmInfo = collect.get(0);
Double sjx = xmInfo.getSjx(); //字典规定的结果值范围约束
if (xjx != null || sjx != null) { Double xjx = xmInfo.getXjx();
String csjg = LisUtil.getOverNumber(labResult.getCsjg()); Double sjx = xmInfo.getSjx();
if (LisUtil.isNumber(csjg)) { if (xjx != null || sjx != null) {
Double csjgnum = Double.parseDouble(csjg); String csjg = LisUtil.getOverNumber(labResult.getCsjg());
if (xjx != null && csjgnum <= xjx) { if (LisUtil.isNumber(csjg)) {
errmsg = errmsg + LisUtil.LINE_SEPARATOR + xmdh + " 结果超出审核条件"; Double csjgnum = Double.parseDouble(csjg);
} else if (sjx != null && csjgnum >= sjx) { if (xjx != null && csjgnum <= xjx) {
errmsg = errmsg + LisUtil.LINE_SEPARATOR + xmdh + " 结果超出审核条件"; errmsg = errmsg + LisUtil.LINE_SEPARATOR + xmdh + " 结果超出审核条件";
} } else if (sjx != null && csjgnum >= sjx) {
} errmsg = errmsg + LisUtil.LINE_SEPARATOR + xmdh + " 结果超出审核条件";
}
//字典规定的多少天内结果间隔范围约束
Integer jgjg = xmInfo.getJgjg();
Double jgz = xmInfo.getJgz();
String jgbz = xmInfo.getJgbz();
if (jgjg != null && jgjg > 0 && jgz != null && jgz > 0) {
String csjg = LisUtil.getOverNumber(labResult.getCsjg());
if (LisUtil.isNumber(csjg)) {
Double csjgnum = Double.parseDouble(csjg);
Date ldt_startda = LisUtil.relativeDate(jyrq, -jgjg);
Double lde_up = null;
Double lde_low = null;
if ("2".equals(jgbz)) {
lde_up = csjgnum / (1 - jgz / 100);
lde_low = csjgnum / (1 + jgz / 100);
} else {
lde_up = csjgnum + jgz;
lde_low = csjgnum - jgz;
}
List<LabResult> chkval = checkResultMapper.getChkvaList(brdh, ldt_startda, jyrq, yq, xmdh);
List<LabResult> collect0 = chkval.stream().filter(LabResult0 -> LisUtil.isNumber(LabResult0.getCsjg())).collect(Collectors.toList());
if (collect0.size() > 0) {
Double finalLde_up = lde_up;
Double finalLde_low = lde_low;
List<LabResult> collect1 = collect0.stream().filter(LabResult1 -> Double.parseDouble(LabResult1.getCsjg()) > finalLde_up && Double.parseDouble(LabResult1.getCsjg()) < finalLde_low).collect(Collectors.toList());
if (collect0.size() > 0) {
errmsg = errmsg + LisUtil.LINE_SEPARATOR + xmdh + " 结果 (" + labResult.getCsjg() + ") 和 " +
DateFormatUtils.format(collect1.get(0).getJyrq(), "yyyy-MM-dd") + "日" +
collect1.get(0).getYbh() + " 号标本的结果 (" + collect1.get(0).getCsjg() + ") 相比超标";
} }
} }
} }
//字典规定的多少天内结果间隔范围约束
Integer jgjg = xmInfo.getJgjg();
Double jgz = xmInfo.getJgz();
String jgbz = xmInfo.getJgbz();
if (jgjg != null && jgjg > 0 && jgz != null && jgz > 0) {
String csjg = LisUtil.getOverNumber(labResult.getCsjg());
if (LisUtil.isNumber(csjg)) {
Double csjgnum = Double.parseDouble(csjg);
Date ldt_startda = LisUtil.relativeDate(jyrq, -jgjg);
Double lde_up = null;
Double lde_low = null;
if ("2".equals(jgbz)) {
lde_up = csjgnum / (1 - jgz / 100);
lde_low = csjgnum / (1 + jgz / 100);
} else {
lde_up = csjgnum + jgz;
lde_low = csjgnum - jgz;
}
List<LabResult> chkval = checkResultMapper.getChkvaList(brdh, ldt_startda, jyrq, yq, xmdh);
List<LabResult> collect0 = chkval.stream().filter(LabResult0 -> LisUtil.isNumber(LabResult0.getCsjg())).collect(Collectors.toList());
if (collect0.size() > 0) {
Double finalLde_up = lde_up;
Double finalLde_low = lde_low;
List<LabResult> collect1 = collect0.stream().filter(LabResult1 -> Double.parseDouble(LabResult1.getCsjg()) > finalLde_up && Double.parseDouble(LabResult1.getCsjg()) < finalLde_low).collect(Collectors.toList());
if (collect0.size() > 0) {
errmsg = errmsg + LisUtil.LINE_SEPARATOR + xmdh + " 结果 (" + labResult.getCsjg() + ") 和 " +
DateFormatUtils.format(collect1.get(0).getJyrq(), "yyyy-MM-dd") + "日" +
collect1.get(0).getYbh() + " 号标本的结果 (" + collect1.get(0).getCsjg() + ") 相比超标";
}
}
}
}
} }
} }
} }
List<LabChk> labChkList=checkResultMapper.getLabChkList(yq); List<LabChk> labChkList = checkResultMapper.getLabChkList(yq);
for(LabChk labChk:labChkList){ for (LabChk labChk : labChkList) {
String jsgs=labChk.getHdnr(); String jsgs = labChk.getHdnr();
boolean setjgsg = true; boolean setjgsg = true;
Map<String, String> variables = new HashMap<>(); Map<String, String> variables = new HashMap<>();
String[] parameters = CalcUtils.getParameters(jsgs); String[] parameters = CalcUtils.getParameters(jsgs);
@ -98,8 +102,8 @@ public class CheckResultUtils {
String itemcode = parameters[i]; String itemcode = parameters[i];
if ("SEX".equals(itemcode)) { if ("SEX".equals(itemcode)) {
String sex = labPat.getBrxb().trim(); String sex = labPat.getBrxb().trim();
if ("1".equals(sex)) sex = "男"; // if ("1".equals(sex)) sex = "男";
if ("2".equals(sex)) sex = "女"; // if ("2".equals(sex)) sex = "女";
variables.put("SEX", sex); variables.put("SEX", sex);
} else if ("AGE".equals(itemcode)) { } else if ("AGE".equals(itemcode)) {
double age = AgeUtils.getDecimalAge(AgeUtils.getBirthDateByAge(labPat.getNl(), labPat.getNldw())); double age = AgeUtils.getDecimalAge(AgeUtils.getBirthDateByAge(labPat.getNl(), labPat.getNldw()));
@ -114,84 +118,86 @@ public class CheckResultUtils {
} }
} }
//项目不全,此公式跳过 //项目不全,此公式跳过
if(setjgsg) { if (setjgsg) {
boolean result = CalcUtils.getBooleanFromCalc(jsgs, variables); boolean result = CalcUtils.getBooleanFromCalc(jsgs, variables);
if (!result) { if (result) {
errmsg=errmsg+LisUtil.LINE_SEPARATOR+"审核条件: "+ jsgs + " 未通过!"; errmsg = errmsg + LisUtil.LINE_SEPARATOR + "审核条件: " + jsgs + " 规则触发,未通过审核!";
} }
} }
} }
if(!"".equals(errmsg))errmsg= errmsg +LisUtil.LINE_SEPARATOR+ "请咨询该仪器组长或专业检验师 !"; if (!"".equals(errmsg)) errmsg = errmsg + LisUtil.LINE_SEPARATOR + "请咨询该仪器组长或专业检验师 !";
return errmsg; return errmsg;
} }
/** /**
* 自动审核时,询问默认失败,填备注默认每次都填 * 自动审核时,询问默认失败,填备注默认每次都填
*
* @param labPat * @param labPat
* @param labResultList * @param labResultList
* @return * @return
*/ */
public Map<String, Object> autochksamplenew(LabPat labPat, List<LabResult> labResultList) { public Map<String, Object> autochksamplenew(LabPat labPat, List<LabResult> labResultList) {
Map<String, Object> params=chksamplenew(labPat, labResultList,0); Map<String, Object> params = chksamplenew(labPat, labResultList, 0);
String code=(String)params.get("code"); String code = (String) params.get("code");
if ("3".equals(code))params.put("code","0"); if ("3".equals(code)) params.put("code", "0");
if ("5".equals(code))params.put("code","-1"); if ("5".equals(code)) params.put("code", "-1");
if ("1".equals(code))params.put("code","-1"); if ("1".equals(code)) params.put("code", "-1");
return params; return params;
} }
/** /**
* 高级审核,对于重复询问通过xh递归询问 * 高级审核,对于重复询问通过xh递归询问
*
* @param labPat * @param labPat
* @param labResultList * @param labResultList
* @param xh * @param xh
* @return * @return
*/ */
public Map<String, Object> chksamplenew(LabPat labPat, List<LabResult> labResultList,int xh){ public Map<String, Object> chksamplenew(LabPat labPat, List<LabResult> labResultList, int xh) {
String yq = labPat.getYq(); String yq = labPat.getYq();
Date jyrq = labPat.getJyrq(); String bz = labPat.getBz();
String ybh = labPat.getYbh();
String bz= labPat.getBz();
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("code", "0"); params.put("code", "0");
params.put("msg",""); params.put("msg", "");
params.put("bz",bz); params.put("bz", bz);
params.put("setbz",false); params.put("setbz", false);
params.put("xh",xh); params.put("xh", xh);
List<LabCheckrules> labCheckruleslist=labCheckrulesMapper.getLabCheckrules(yq); List<LabCheckrules> labCheckruleslist = labCheckrulesMapper.getLabCheckrules(yq);
if(labCheckruleslist.size()==0)return params; if (labCheckruleslist.size() == 0) return params;
if(xh>=labCheckruleslist.size())return params; if (xh > labCheckruleslist.size()) return params;
for (int i = xh; i < labCheckruleslist.size(); i++){ for (int i = xh; i < labCheckruleslist.size(); i++) {
LabCheckrules labCheckrules=labCheckruleslist.get(i); LabCheckrules labCheckrules = labCheckruleslist.get(i);
String checkrules=labCheckrules.getCheckrules(); String checkrules = labCheckrules.getCheckrules();
String checktype=labCheckrules.getChecktype(); String checktype = labCheckrules.getChecktype();
String logcontent=labCheckrules.getLogcontent(); String logcontent = labCheckrules.getLogcontent();
String ruledisplay=labCheckrules.getRuledisplay(); String ruledisplay = labCheckrules.getRuledisplay();
String errmsg=checkcondition(labPat,labResultList,checkrules,ruledisplay); String errmsg = checkcondition(labPat, labResultList, checkrules, ruledisplay);
if(!"".equals(errmsg)) { if (!"".equals(errmsg)) {
if("0".equals(checktype)) { if ("0".equals(checktype)) {
errmsg="审核未通过,你是否要强行通过?"+ruledisplay+LisUtil.LINE_SEPARATOR+"审核未通过,你是否要强行通过?"+LisUtil.LINE_SEPARATOR+errmsg; errmsg = "审核规则触发,未通过审核!,你是否要强行通过?" + ruledisplay + LisUtil.LINE_SEPARATOR + "审核规则触发,未通过审核!,你是否要强行通过?" + LisUtil.LINE_SEPARATOR + errmsg;
params.put("code", "5"); params.put("code", "5");
params.put("msg",errmsg); params.put("msg", errmsg);
int ruleid0=labCheckrules.getRuleid(); int ruleid0 = labCheckrules.getRuleid();
params.put("xh",i); params.put("xh", i+1);
return params; return params;
}else if("3".equals(checktype)) { } else if ("3".equals(checktype)) {
errmsg="审核未通过"+LisUtil.LINE_SEPARATOR+"设置的组合审核条件:"+errmsg+LisUtil.LINE_SEPARATOR+"审核未通过,不允许审核!"; errmsg = "审核规则触发,未通过审核!" + LisUtil.LINE_SEPARATOR + "设置的组合审核条件:" + errmsg + LisUtil.LINE_SEPARATOR + "审核规则触发,未通过审核!,不允许审核!";
params.put("code", "1"); params.put("code", "1");
params.put("msg",errmsg); params.put("msg", errmsg);
params.put("xh", i+1);
return params; return params;
}else if("4".equals(checktype)) { } else if ("4".equals(checktype)) {
bz=replacebz(labPat,labResultList,logcontent); bz = replacebz(labPat, labResultList, logcontent);
labPat.setBz(bz); labPat.setBz(bz);
params.put("setbz", true); params.put("setbz", true);
errmsg="此次审核将产生一个备注信息"+LisUtil.LINE_SEPARATOR+bz; errmsg = "此次审核将产生一个备注信息" + LisUtil.LINE_SEPARATOR + bz;
params.put("code", "3"); params.put("code", "3");
params.put("msg",errmsg); params.put("msg", errmsg);
params.put("bz",bz); params.put("bz", bz);
params.put("xh", i+1);
} }
} }
} }
@ -200,26 +206,27 @@ public class CheckResultUtils {
/** /**
* 计算公式注入参数执行,返回为真则证明筛选条件成立,需要禁止审核通过! * 计算公式注入参数执行,返回为真则证明筛选条件成立,需要禁止审核通过!
*
* @param labPat * @param labPat
* @param labResultList * @param labResultList
* @param checkrules * @param checkrules
* @param ruledisplay * @param ruledisplay
* @return * @return
*/ */
private String checkcondition(LabPat labPat, List<LabResult> labResultList,String checkrules,String ruledisplay){ private String checkcondition(LabPat labPat, List<LabResult> labResultList, String checkrules, String ruledisplay) {
String errmsg=""; String errmsg = "";
boolean flag=false; boolean flag = false;
checkrules=checkrules.replace("\"","'"); checkrules = checkrules.replace("\"", "'");
if(checkrules.contains("ANY_")){ if (checkrules.contains("ANY_")) {
Map<String, String> variables = new HashMap<>(); Map<String, String> variables = new HashMap<>();
String[] parameters=CalcUtils.getParameters(checkrules); String[] parameters = CalcUtils.getParameters(checkrules);
for (int i = 0; i < parameters.length; i++) { for (int i = 0; i < parameters.length; i++) {
String itemcode = parameters[i]; String itemcode = parameters[i];
switch (itemcode) { switch (itemcode) {
case "SEX": case "SEX":
String sex = labPat.getBrxb().trim(); String sex = labPat.getBrxb().trim();
if ("1".equals(sex)) sex = "男"; // if ("1".equals(sex)) sex = "男";
if ("2".equals(sex)) sex = "女"; // if ("2".equals(sex)) sex = "女";
errmsg.replace("[SEX]", sex); errmsg.replace("[SEX]", sex);
break; break;
case "AGE": case "AGE":
@ -227,21 +234,21 @@ public class CheckResultUtils {
errmsg.replace("[AGE]", String.valueOf(age)); errmsg.replace("[AGE]", String.valueOf(age));
break; break;
case "BRLY": case "BRLY":
String brly=labPat.getBrly(); String brly = labPat.getBrly();
String brlymc= commonUtil.getComDictNameById("PT",brly); // String brlymc = commonUtil.getComDictNameById("PT", brly);
if(!"".equals(brlymc)||brlymc != null) brly=brlymc; // if (!"".equals(brlymc) || brlymc != null) brly = brlymc;
errmsg.replace("[BRLY]", brly); errmsg.replace("[BRLY]", brly);
break; break;
case "KSDH": case "KSDH":
String ksdh=labPat.getKsdh(); String ksdh = labPat.getKsdh();
String ksdhmc= commonUtil.getComDictNameById("DP",ksdh); // String ksdhmc = commonUtil.getComDictNameById("DP", ksdh);
if(!"".equals(ksdhmc)||ksdhmc != null) ksdh=ksdhmc; // if (!"".equals(ksdhmc) || ksdhmc != null) ksdh = ksdhmc;
errmsg.replace("[KSDH]", ksdh); errmsg.replace("[KSDH]", ksdh);
break; break;
case "YBLX": case "YBLX":
String yblx=labPat.getYblx(); String yblx = labPat.getYblx();
String yblxmc= commonUtil.getComDictNameById("BT",yblx); String yblxmc = commonUtil.getComDictNameById("BT", yblx);
if(!"".equals(yblxmc)||yblxmc != null) yblx=yblxmc; if (!"".equals(yblxmc) || yblxmc != null) yblx = yblxmc;
errmsg.replace("[YBLX]", yblx); errmsg.replace("[YBLX]", yblx);
break; break;
case "BZ": case "BZ":
@ -269,25 +276,25 @@ public class CheckResultUtils {
errmsg.replace("[ANY_CRI]", "lab_result.xmdh"); errmsg.replace("[ANY_CRI]", "lab_result.xmdh");
break; break;
default: default:
String csjg=Optional.ofNullable(labResultList).flatMap(list -> list.stream().filter(result -> result != null && itemcode.equals(result.getXmdh())).map(LabResult::getCsjg).findFirst()).orElse(null); String csjg = Optional.ofNullable(labResultList).flatMap(list -> list.stream().filter(result -> result != null && itemcode.equals(result.getXmdh())).map(LabResult::getCsjg).findFirst()).orElse(null);
if(csjg==null)csjg=""; if (csjg == null) csjg = "";
errmsg.replace("["+itemcode+"]", csjg); errmsg.replace("[" + itemcode + "]", csjg);
} }
List<LabResult> labResultList0=commonUtil.labResultMapper.getLabResultWithSql(labPat.getJyrq(),labPat.getYq(),labPat.getYbh(),errmsg); List<LabResult> labResultList0 = commonUtil.labResultMapper.getLabResultWithSql(labPat.getJyrq(), labPat.getYq(), labPat.getYbh(), errmsg);
if(labResultList0.size()>0)flag=true; if (labResultList0.size() > 0) flag = true;
} }
if(flag=true) errmsg = "审核条件: " + ruledisplay + " 未通过!" ; if (flag = true) errmsg = "审核条件: " + ruledisplay + " 规则触发,未通过审核!";
}else{ } else {
Map<String, String> variables = new HashMap<>(); Map<String, String> variables = new HashMap<>();
String[] parameters=CalcUtils.getParameters(checkrules); String[] parameters = CalcUtils.getParameters(checkrules);
for (int i = 0; i < parameters.length; i++) { for (int i = 0; i < parameters.length; i++) {
String itemcode = parameters[i]; String itemcode = parameters[i];
switch (itemcode) { switch (itemcode) {
case "SEX": case "SEX":
String sex = labPat.getBrxb().trim(); String sex = labPat.getBrxb().trim();
if ("1".equals(sex)) sex = "男"; // if ("1".equals(sex)) sex = "男";
if ("2".equals(sex)) sex = "女"; // if ("2".equals(sex)) sex = "女";
variables.put(itemcode, sex); variables.put(itemcode, sex);
break; break;
case "AGE": case "AGE":
@ -295,21 +302,21 @@ public class CheckResultUtils {
variables.put(itemcode, String.valueOf(age)); variables.put(itemcode, String.valueOf(age));
break; break;
case "BRLY": case "BRLY":
String brly=labPat.getBrly(); String brly = labPat.getBrly();
String brlymc= commonUtil.getComDictNameById("PT",brly); // String brlymc = commonUtil.getComDictNameById("PT", brly);
if(!"".equals(brlymc)||brlymc != null) brly=brlymc; // if (!"".equals(brlymc) || brlymc != null) brly = brlymc;
variables.put(itemcode, brly); variables.put(itemcode, brly);
break; break;
case "KSDH": case "KSDH":
String ksdh=labPat.getKsdh(); String ksdh = labPat.getKsdh();
String ksdhmc= commonUtil.getComDictNameById("DP",ksdh); // String ksdhmc = commonUtil.getComDictNameById("DP", ksdh);
if(!"".equals(ksdhmc)||ksdhmc != null) ksdh=ksdhmc; // if (!"".equals(ksdhmc) || ksdhmc != null) ksdh = ksdhmc;
variables.put(itemcode, ksdh); variables.put(itemcode, ksdh);
break; break;
case "YBLX": case "YBLX":
String yblx=labPat.getYblx(); String yblx = labPat.getYblx();
String yblxmc= commonUtil.getComDictNameById("BT",yblx); String yblxmc = commonUtil.getComDictNameById("BT", yblx);
if(!"".equals(yblxmc)||yblxmc != null) yblx=yblxmc; if (!"".equals(yblxmc) || yblxmc != null) yblx = yblxmc;
variables.put(itemcode, yblx); variables.put(itemcode, yblx);
break; break;
case "BZ": case "BZ":
@ -319,28 +326,29 @@ public class CheckResultUtils {
variables.put(itemcode, labPat.getZd()); variables.put(itemcode, labPat.getZd());
break; break;
default: default:
String csjg=Optional.ofNullable(labResultList).flatMap(list -> list.stream().filter(result -> result != null && itemcode.equals(result.getXmdh())).map(LabResult::getCsjg).findFirst()).orElse(null); String csjg = Optional.ofNullable(labResultList).flatMap(list -> list.stream().filter(result -> result != null && itemcode.equals(result.getXmdh())).map(LabResult::getCsjg).findFirst()).orElse(null);
if(csjg==null)csjg=""; if (csjg == null) csjg = "";
variables.put(itemcode, csjg); variables.put(itemcode, csjg);
} }
} }
flag=CalcUtils.getBooleanFromCalc(checkrules, variables); flag = CalcUtils.getBooleanFromCalc(checkrules, variables);
if(flag=true) errmsg = "审核条件: " + ruledisplay + " 未通过!" ; if (flag = true) errmsg = "审核条件: " + ruledisplay + " 规则触发,未通过审核!";
} }
return errmsg; return errmsg;
} }
/** /**
* 备注信息公式转换备注内容 * 备注信息公式转换备注内容
*
* @param labPat * @param labPat
* @param labResultList * @param labResultList
* @param logcontent * @param logcontent
* @return * @return
*/ */
private String replacebz(LabPat labPat, List<LabResult> labResultList,String logcontent){ private String replacebz(LabPat labPat, List<LabResult> labResultList, String logcontent) {
String errmsg=logcontent; String errmsg = logcontent;
String[] parameters=CalcUtils.getParameters(logcontent); String[] parameters = CalcUtils.getParameters(logcontent);
for (int i = 0; i < parameters.length; i++) { for (int i = 0; i < parameters.length; i++) {
String itemcode = parameters[i]; String itemcode = parameters[i];
switch (itemcode) { switch (itemcode) {
@ -348,28 +356,28 @@ public class CheckResultUtils {
String sex = labPat.getBrxb().trim(); String sex = labPat.getBrxb().trim();
if ("1".equals(sex)) sex = "男"; if ("1".equals(sex)) sex = "男";
if ("2".equals(sex)) sex = "女"; if ("2".equals(sex)) sex = "女";
errmsg.replace("[SEX]",sex); errmsg.replace("[SEX]", sex);
break; break;
case "AGE": case "AGE":
double age = AgeUtils.getDecimalAge(AgeUtils.getBirthDateByAge(labPat.getNl(), labPat.getNldw())); double age = AgeUtils.getDecimalAge(AgeUtils.getBirthDateByAge(labPat.getNl(), labPat.getNldw()));
errmsg.replace("[AGE]",String.valueOf(age)); errmsg.replace("[AGE]", String.valueOf(age));
break; break;
case "BRLY": case "BRLY":
String brly=labPat.getBrly(); String brly = labPat.getBrly();
String brlymc= commonUtil.getComDictNameById("PT",brly); String brlymc = commonUtil.getComDictNameById("PT", brly);
if(!"".equals(brlymc)||brlymc != null) brly=brlymc; if (!"".equals(brlymc) || brlymc != null) brly = brlymc;
errmsg.replace("[BRLY]", brly); errmsg.replace("[BRLY]", brly);
break; break;
case "KSDH": case "KSDH":
String ksdh=labPat.getKsdh(); String ksdh = labPat.getKsdh();
String ksdhmc= commonUtil.getComDictNameById("DP",ksdh); String ksdhmc = commonUtil.getComDictNameById("DP", ksdh);
if(!"".equals(ksdhmc)||ksdhmc != null) ksdh=ksdhmc; if (!"".equals(ksdhmc) || ksdhmc != null) ksdh = ksdhmc;
errmsg.replace("[KSDH]", ksdh); errmsg.replace("[KSDH]", ksdh);
break; break;
case "YBLX": case "YBLX":
String yblx=labPat.getYblx(); String yblx = labPat.getYblx();
String yblxmc= commonUtil.getComDictNameById("BT",yblx); String yblxmc = commonUtil.getComDictNameById("BT", yblx);
if(!"".equals(yblxmc)||yblxmc != null) yblx=yblxmc; if (!"".equals(yblxmc) || yblxmc != null) yblx = yblxmc;
errmsg.replace("[YBLX]", yblx); errmsg.replace("[YBLX]", yblx);
break; break;
case "BZ": case "BZ":
@ -379,31 +387,31 @@ public class CheckResultUtils {
errmsg.replace("[ZD]", labPat.getZd()); errmsg.replace("[ZD]", labPat.getZd());
break; break;
default: default:
String csjg=Optional.ofNullable(labResultList).flatMap(list -> list.stream().filter(result -> result != null && itemcode.equals(result.getXmdh())).map(LabResult::getCsjg).findFirst()).orElse(null); String csjg = Optional.ofNullable(labResultList).flatMap(list -> list.stream().filter(result -> result != null && itemcode.equals(result.getXmdh())).map(LabResult::getCsjg).findFirst()).orElse(null);
if(csjg==null)csjg=""; if (csjg == null) csjg = "";
errmsg.replace("["+itemcode+"]", csjg); errmsg.replace("[" + itemcode + "]", csjg);
} }
} }
String bz=labPat.getBz(); String bz = labPat.getBz();
if(errmsg!=null && !"".equals(errmsg)) if (errmsg == null || "".equals(errmsg)) return bz;
if(bz==null||"".equals(bz)) bz=errmsg; if (bz == null || "".equals(bz)) return errmsg;
else { if (bz.contains(errmsg)) return bz;
String bz0=String.valueOf(bz.charAt(bz.length() - 1)); String bz0 = String.valueOf(bz.charAt(bz.length() - 1));
switch (bz0) { switch (bz0) {
case ",": case ",":
case ":": case ":":
case ";": case ";":
case ".": case ".":
case "。": case "。":
case ",": case ",":
case "、": case "、":
case ";": case ";":
case ":": case ":":
bz=bz+errmsg; bz = bz + errmsg;
break; break;
default: default:
bz=bz+","+errmsg; bz = bz + "," + errmsg;
}} }
return bz; return bz;
} }

View File

@ -20,4 +20,5 @@ public interface LisWorkOperMapper {
Integer checkresultwxh(@Param("jyrq") Date jyrq, @Param("yq") String yq, @Param("ybh") String ybh); Integer checkresultwxh(@Param("jyrq") Date jyrq, @Param("yq") String yq, @Param("ybh") String ybh);
LabPat checkdublereport(@Param("sqh") String sqh, @Param("ybh") String ybh); LabPat checkdublereport(@Param("sqh") String sqh, @Param("ybh") String ybh);
LabPat checkyqdublereport(@Param("sqh") String sqh,@Param("yq") String yq, @Param("ybh") String ybh); LabPat checkyqdublereport(@Param("sqh") String sqh,@Param("yq") String yq, @Param("ybh") String ybh);
Integer getxsws(@Param("yq") String yq, @Param("xmdh") String xmdh);
} }

View File

@ -51,6 +51,7 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
LabReqdetailMapper labReqdetailMapper; LabReqdetailMapper labReqdetailMapper;
@Autowired @Autowired
CheckResultUtils checkResultUtils; CheckResultUtils checkResultUtils;
@Override @Override
public Result newPatInfo(Date jyrq, String ybh, String sqh, String yq, Long userId) { public Result newPatInfo(Date jyrq, String ybh, String sqh, String yq, Long userId) {
@ -220,7 +221,7 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
//2:数据合法性校验 //2:数据合法性校验
LabPat labPat = commonUtil.getLabPatOne(jyrq, yq, ybh); LabPat labPat = commonUtil.getLabPatOne(jyrq, yq, ybh);
labPat.setHdys(hdys); labPat.setHdys(hdys);
Result result = beforeconfirm(labPat, problemId); Result result = beforeconfirm(labPat, 2, problemId);
if (!"0".equals(result.getCode())) return result; if (!"0".equals(result.getCode())) return result;
//3:数据完整保存 //3:数据完整保存
int wjz = saveallresult(labPat); int wjz = saveallresult(labPat);
@ -228,18 +229,20 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
String alarmflag = labPat.getAlarmflag(); String alarmflag = labPat.getAlarmflag();
if (("1".equals(alarmflag) && wjz != 1)) { if (("1".equals(alarmflag) && wjz != 1)) {
labPat.setAlarmflag("1"); labPat.setAlarmflag("1");
commonUtil.updateLabPat(labPat);
} else if (("".equals(alarmflag) || alarmflag == null) && wjz == 1) { } else if (("".equals(alarmflag) || alarmflag == null) && wjz == 1) {
labPat.setAlarmflag(""); labPat.setAlarmflag("");
commonUtil.updateLabPat(labPat);
} }
//医学审核条件判断 //医学审核条件判断
if(problemId<4)problemId=4; if (problemId < 3) problemId = 3;
result=chksample(labPat,problemId); result = chksample(labPat, problemId);
if ("99".equals(result.getCode())) { if ("99".equals(result.getCode())) {
labPat.setBz(result.getMsg()); labPat.setBz(result.getMsg());
result.setCode("0"); result.setCode("0");
} }
if (!"0".equals(result.getCode())) return result; if (!"0".equals(result.getCode())) return result;
if(problemId<99)problemId=99; if (problemId < 99) problemId = 99;
//4:CA请求业务的处理 //4:CA请求业务的处理
//Result result=addCA(jyrq, yq, ybh, hdys); //Result result=addCA(jyrq, yq, ybh, hdys);
//if("0".equals(result.getCode()))return result; //if("0".equals(result.getCode()))return result;
@ -260,11 +263,11 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
public Result beforeconfirm(Date jyrq, String yq, String ybh) { public Result beforeconfirm(Date jyrq, String yq, String ybh) {
int problemId = ServletUtils.getParameterToInt("problemId", 0); int problemId = ServletUtils.getParameterToInt("problemId", 0);
LabPat labPat = commonUtil.getLabPatOne(jyrq, yq, ybh); LabPat labPat = commonUtil.getLabPatOne(jyrq, yq, ybh);
return beforeconfirm(labPat, problemId); return beforeconfirm(labPat, 2, problemId);
} }
//内部使用 //内部使用
private Result beforeconfirm(LabPat labPat, Integer problemId) { private Result beforeconfirm(LabPat labPat, Integer checktype, Integer problemId) {
Date jyrq = labPat.getJyrq(); Date jyrq = labPat.getJyrq();
String yq = labPat.getYq(); String yq = labPat.getYq();
String ybh = labPat.getYbh(); String ybh = labPat.getYbh();
@ -272,11 +275,13 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
String jgbz = labPat.getJgbz(); String jgbz = labPat.getJgbz();
if ("2".equals(jgbz)) return new Result("1", "报告已审核!"); if ("2".equals(jgbz)) return new Result("1", "报告已审核!");
if ("5".equals(jgbz)) return new Result("-1", "已锁定报告禁止审核!"); if ("5".equals(jgbz)) return new Result("-1", "已锁定报告禁止审核!");
if (!"1".equals(jgbz)) { if (!"1".equals(jgbz) && checktype == 2) {
String f_check1 = commonUtil.getComOptValue(yq, "f_check1"); String f_check1 = commonUtil.getComOptValue(yq, "f_check1");
if ("1".equals(f_check1)) return new Result("-1", "审核前必须先初审!"); if ("1".equals(f_check1)) return new Result("-1", "审核前必须先初审!");
} }
if (checkWorkTime(labPat) == 1) return new Result("-1", "核对医生不允许与检验医生相同!"); if (checktype == 2) {
if (checkWorkTime(labPat) == 1) return new Result("-1", "核对医生不允许与检验医生相同!");
}
String limit_brly = commonUtil.getHISOPT("limit_brly"); String limit_brly = commonUtil.getHISOPT("limit_brly");
String brly = labPat.getBrly(); String brly = labPat.getBrly();
if ("1".equals(limit_brly) && (brly == null || "".equals(brly))) if ("1".equals(limit_brly) && (brly == null || "".equals(brly)))
@ -341,14 +346,14 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
LabPat labPat0 = lisWorkOperMapper.checkdublereport(sqh, ybh); LabPat labPat0 = lisWorkOperMapper.checkdublereport(sqh, ybh);
if (labPat0 != null) { if (labPat0 != null) {
String yqmc = commonUtil.getYqmc(yq); String yqmc = commonUtil.getYqmc(yq);
String msg = "该申请单已经发过结果了,禁止审核!"+LisUtil.LINE_SEPARATOR+"日期:" + commonUtil.getDateString(jyrq) + ",仪器:" + yqmc + ",样本号:" + ybh; String msg = "该申请单已经发过结果了,禁止审核!" + LisUtil.LINE_SEPARATOR + "日期:" + commonUtil.getDateString(jyrq) + ",仪器:" + yqmc + ",样本号:" + ybh;
return new Result("-1", msg); return new Result("-1", msg);
} }
} else if ("1".equals(commonUtil.getHISOPT("sp_yqdublereport"))) { } else if ("1".equals(commonUtil.getHISOPT("sp_yqdublereport"))) {
LabPat labPat0 = lisWorkOperMapper.checkyqdublereport(sqh, yq, ybh); LabPat labPat0 = lisWorkOperMapper.checkyqdublereport(sqh, yq, ybh);
if (labPat0 != null) { if (labPat0 != null) {
String yqmc = commonUtil.getYqmc(yq); String yqmc = commonUtil.getYqmc(yq);
String msg = "该申请单已经发过结果了,禁止审核!"+LisUtil.LINE_SEPARATOR+"日期:" + commonUtil.getDateString(jyrq) + ",仪器:" + yqmc + ",样本号:" + ybh; String msg = "该申请单已经发过结果了,禁止审核!" + LisUtil.LINE_SEPARATOR + "日期:" + commonUtil.getDateString(jyrq) + ",仪器:" + yqmc + ",样本号:" + ybh;
return new Result("-1", msg); return new Result("-1", msg);
} }
} }
@ -360,7 +365,8 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
if (Userid == null || "".equals(Userid)) { if (Userid == null || "".equals(Userid)) {
Userid = SecurityUtils.getLoginUser().getUsername(); Userid = SecurityUtils.getLoginUser().getUsername();
} }
//初审不需要调用接口
if (checktype == 1) return new Result("0", "保存成功!");
//调用his报告接口,检查外部接口对审核前的定制需求 //调用his报告接口,检查外部接口对审核前的定制需求
SetReport setReport = new SetReport(); SetReport setReport = new SetReport();
setReport.setIp(IpUtils.getIpAddr()); setReport.setIp(IpUtils.getIpAddr());
@ -394,8 +400,8 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
setReport.setStatus(LisinterfaceNameConstants.REPORTSTART); setReport.setStatus(LisinterfaceNameConstants.REPORTSTART);
Result result = lisInterfaceUtil.invokeLisInterface(LisinterfaceNameConstants.SETREPORT, setReport); Result result = lisInterfaceUtil.invokeLisInterface(LisinterfaceNameConstants.SETREPORT, setReport);
if (result.getCode().equals("5")) { if (result.getCode().equals("5")) {
if (problemId < 5) { if (problemId < 3) {
return new Result(result.getCode(), result.getMsg(), 5); return new Result(result.getCode(), result.getMsg(), 3);
} }
return new Result("0", "保存成功!"); return new Result("0", "保存成功!");
} }
@ -406,47 +412,50 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
/** /**
* 医学审核条件判断 * 医学审核条件判断
*
* @param labPat * @param labPat
* @param problemId * @param problemId
* @return * @return
*/ */
private Result chksample(LabPat labPat,Integer problemId) { private Result chksample(LabPat labPat, Integer problemId) {
List<LabResult> labResultList = commonUtil.getLabResultList(labPat.getJyrq(),labPat.getYq(),labPat.getYbh()); List<LabResult> labResultList = commonUtil.getLabResultList(labPat.getJyrq(), labPat.getYq(), labPat.getYbh());
//医学审核条件判断 //医学审核条件判断
if(problemId<3) { if (problemId < 4) {
String checkvalue = checkResultUtils.chksample(labPat, labResultList); String checkvalue = checkResultUtils.chksample(labPat, labResultList);
if (checkvalue != null && !"".equals(checkvalue)) { if (checkvalue != null && !"".equals(checkvalue)) {
return new Result("5", checkvalue, 3); return new Result("5", checkvalue, 4);
} }
} }
Boolean setbz=false;
String bz=labPat.getBz(); Boolean setbz = false;
String bz = labPat.getBz();
//医学审核条件判断(新规则),预留99个递归ID //医学审核条件判断(新规则),预留99个递归ID
if(problemId<99) { if (problemId < 4) problemId = 4;
int xh=0; if (problemId < 99) {
if(problemId>4)xh=problemId - 4; int xh = problemId - 4;
Map<String, Object> chksamplenewvalue = checkResultUtils.chksamplenew(labPat, labResultList,xh); Map<String, Object> chksamplenewvalue = checkResultUtils.chksamplenew(labPat, labResultList, xh);
String chkCode=(String)chksamplenewvalue.get("code"); String chkCode = (String) chksamplenewvalue.get("code");
String chkMsg=(String)chksamplenewvalue.get("code"); String chkMsg = (String) chksamplenewvalue.get("msg");
bz=(String)chksamplenewvalue.get("bz"); bz = (String) chksamplenewvalue.get("bz");
labPat.setBz(bz); labPat.setBz(bz);
xh=(Integer) chksamplenewvalue.get("xh"); xh = (Integer) chksamplenewvalue.get("xh");
setbz=(Boolean) chksamplenewvalue.get("setbz"); setbz = (Boolean) chksamplenewvalue.get("setbz");
problemId=4+xh; problemId = 4 + xh;
if ("5".equals(chkCode)) { if ("5".equals(chkCode)) {
if (setbz){ if (setbz) {
commonUtil.updateLabPat(labPat); commonUtil.updateLabPat(labPat);
} }
return new Result("5", chkMsg, problemId); return new Result("5", chkMsg, problemId);
} }
if (!"0".equals(chkCode)) return new Result(chkCode, chkMsg, problemId); if (!"0".equals(chkCode)) return new Result(chkCode, chkMsg, problemId);
} }
if (setbz){ if (setbz) {
commonUtil.updateLabPat(labPat); commonUtil.updateLabPat(labPat);
return new Result("99", bz); return new Result("99", bz);
} }
return new Result("0", "保存成功!"); return new Result("0", "保存成功!");
} }
/** /**
* 审核后步骤,在审核过程中,必须完成审核前校验通过,结果计算值填充,参考值结果标志危急值标志填写完成,最后使用此方法修改状态 * 审核后步骤,在审核过程中,必须完成审核前校验通过,结果计算值填充,参考值结果标志危急值标志填写完成,最后使用此方法修改状态
* *
@ -751,8 +760,8 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
String itemcode = parameters[i]; String itemcode = parameters[i];
if ("SEX".equals(itemcode)) { if ("SEX".equals(itemcode)) {
String sex = labPat.getBrxb().trim(); String sex = labPat.getBrxb().trim();
if ("1".equals(sex)) sex = "男"; // if ("1".equals(sex)) sex = "男";
if ("2".equals(sex)) sex = "女"; // if ("2".equals(sex)) sex = "女";
variables.put("SEX", sex); variables.put("SEX", sex);
} else if ("AGE".equals(itemcode)) { } else if ("AGE".equals(itemcode)) {
double age = AgeUtils.getDecimalAge(AgeUtils.getBirthDateByAge(labPat.getNl(), labPat.getNldw())); double age = AgeUtils.getDecimalAge(AgeUtils.getBirthDateByAge(labPat.getNl(), labPat.getNldw()));
@ -769,6 +778,10 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
if (setjgsg) { if (setjgsg) {
String result = CalcUtils.getValueFromCalc(jsgs, variables); String result = CalcUtils.getValueFromCalc(jsgs, variables);
if (result != null && !result.trim().isEmpty()) { if (result != null && !result.trim().isEmpty()) {
if(LisUtil.isNumber(result)) {
Integer xsws =lisWorkOperMapper.getxsws(yq,xmdh);
if (xsws >= 0) result = LisUtil.round(result, xsws);
}
//插入结果值 //插入结果值
LabResult labResult = commonUtil.getLabResult(jyrq, yq, ybh, xmdh); LabResult labResult = commonUtil.getLabResult(jyrq, yq, ybh, xmdh);
if (labResult == null) { if (labResult == null) {

View File

@ -79,6 +79,7 @@
<if test="brxm != null and brxm != ''">and lab_pat.brdh = #{brxm}</if> <if test="brxm != null and brxm != ''">and lab_pat.brdh = #{brxm}</if>
</where> </where>
</select> </select>
<select id="getxsws" resultType="Integer">
select xsws from xm_info where yq=#{yq} and xmdh=#{xmdh}
</select>
</mapper> </mapper>