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

This commit is contained in:
jiangs 2025-09-02 17:49:30 +08:00
commit 69da845254
9 changed files with 427 additions and 46 deletions

View File

@ -0,0 +1,23 @@
package com.czlis.common.core.domain.entity.lis;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LabCheckrules {
private Integer ruleid;
private String rptunitid;
private String checkrules;
private String checktype;
private String logflag;
private String logcontent;
private String ruledisplay;
private String actions;
private String autocheck;
}

View File

@ -0,0 +1,21 @@
package com.czlis.interfaceCommon.mapper;
import com.czlis.common.core.domain.entity.lis.LabCheckrules;
import java.util.List;
public interface LabCheckrulesMapper {
/**
* 高级审核条件
* @param yq
* @return
*/
List<LabCheckrules> getLabCheckrules(String yq);
/**
* 自动审核条件
* @param yq
* @return
*/
List<LabCheckrules> getLabCheckrulesAutocheck(String yq);
}

View File

@ -13,4 +13,5 @@ public interface LabResultMapper {
int delLabResult(LabResult labResult); int delLabResult(LabResult labResult);
int updateLabResult(LabResult labResult); int updateLabResult(LabResult labResult);
int delNullLabResult(@Param("jyrq") Date jyrq, @Param("yq") String yq, @Param("ybh") String ybh); int delNullLabResult(@Param("jyrq") Date jyrq, @Param("yq") String yq, @Param("ybh") String ybh);
List<LabResult> getLabResultWithSql(@Param("jyrq") Date jyrq, @Param("yq") String yq, @Param("ybh") String ybh,@Param("wheresql") String wheresql);
} }

View File

@ -58,24 +58,10 @@ public class CalcUtils {
} }
} }
public static boolean getBooleanFromCalc(String CalcExpression, Map<String, String> variableMap) { public static boolean getBooleanFromCalc(String CalcExpression, Map<String, String> variableMap) {
ExpressionParser parser = new SpelExpressionParser(); String resultcondition = "if((" + CalcExpression + ") ,1,0)";
StandardEvaluationContext context = new StandardEvaluationContext(); String result1 = getValueFromCalc(resultcondition, variableMap);
// 统一变量处理:数字转Double,否则保留String if ("1".equals(result1)) return true;
for (Map.Entry<String, String> entry : variableMap.entrySet()) { return false;
String str = entry.getValue();
if (isNumber(str)) {
context.setVariable(entry.getKey(), Double.parseDouble(str));
} else {
context.setVariable(entry.getKey(), entry.getValue());
}
}
String expression = getCalc(CalcExpression);
Expression exp = parser.parseExpression(expression);
try {
return exp.getValue(context, Boolean.class);
} catch (Exception e) {
throw new RuntimeException("布尔表达式计算失败: " + expression, e); // 增强异常信息
}
} }
/** /**

View File

@ -3,24 +3,24 @@ package com.czlis.interfaceCommon.utils;
import com.czlis.common.core.domain.Result; import com.czlis.common.core.domain.Result;
import com.czlis.common.core.domain.entity.lis.*; import com.czlis.common.core.domain.entity.lis.*;
import com.czlis.interfaceCommon.mapper.CheckResultMapper; import com.czlis.interfaceCommon.mapper.CheckResultMapper;
import com.czlis.interfaceCommon.mapper.LabCheckrulesMapper;
import com.czlis.interfaceCommon.mapper.XmInfoMapper; import com.czlis.interfaceCommon.mapper.XmInfoMapper;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Date; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Component @Component
public class CheckResultUtils { public class CheckResultUtils {
@Autowired
XmInfoMapper xmInfoMapper;
@Autowired @Autowired
CheckResultMapper checkResultMapper; CheckResultMapper checkResultMapper;
@Autowired
LabCheckrulesMapper labCheckrulesMapper;
@Autowired
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,7 +30,7 @@ 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 = xmInfoMapper.getXmInfoList(yq); List<XmInfo> xmInfoList = commonUtil.xmInfoMapper.getXmInfoList(yq);
for (LabResult labResult : labResultList) { for (LabResult labResult : labResultList) {
String xmdh = labResult.getXmdh(); String xmdh = labResult.getXmdh();
List<XmInfo> collect = xmInfoList.stream().filter(xmInfo -> xmInfo.getXmdh().equals(xmdh)).collect(Collectors.toList()); List<XmInfo> collect = xmInfoList.stream().filter(xmInfo -> xmInfo.getXmdh().equals(xmdh)).collect(Collectors.toList());
@ -126,8 +126,286 @@ public class CheckResultUtils {
if(!"".equals(errmsg))errmsg= errmsg +LisUtil.LINE_SEPARATOR+ "请咨询该仪器组长或专业检验师 !"; if(!"".equals(errmsg))errmsg= errmsg +LisUtil.LINE_SEPARATOR+ "请咨询该仪器组长或专业检验师 !";
return errmsg; return errmsg;
} }
public Result chksamplenew(LabPat labPat, List<LabResult> labResultList){
return new Result("0", ""); /**
* 自动审核时,询问默认失败,填备注默认每次都填
* @param labPat
* @param labResultList
* @return
*/
public Map<String, Object> autochksamplenew(LabPat labPat, List<LabResult> labResultList) {
Map<String, Object> params=chksamplenew(labPat, labResultList,0);
String code=(String)params.get("code");
if ("3".equals(code))params.put("code","0");
if ("5".equals(code))params.put("code","-1");
if ("1".equals(code))params.put("code","-1");
return params;
} }
/**
* 高级审核,对于重复询问通过xh递归询问
* @param labPat
* @param labResultList
* @param xh
* @return
*/
public Map<String, Object> chksamplenew(LabPat labPat, List<LabResult> labResultList,int xh){
String yq = labPat.getYq();
Date jyrq = labPat.getJyrq();
String ybh = labPat.getYbh();
String bz= labPat.getBz();
Map<String, Object> params = new HashMap<>();
params.put("code", "0");
params.put("msg","");
params.put("bz",bz);
params.put("setbz",false);
params.put("xh",xh);
List<LabCheckrules> labCheckruleslist=labCheckrulesMapper.getLabCheckrules(yq);
if(labCheckruleslist.size()==0)return params;
if(xh>=labCheckruleslist.size())return params;
for (int i = xh; i < labCheckruleslist.size(); i++){
LabCheckrules labCheckrules=labCheckruleslist.get(i);
String checkrules=labCheckrules.getCheckrules();
String checktype=labCheckrules.getChecktype();
String logcontent=labCheckrules.getLogcontent();
String ruledisplay=labCheckrules.getRuledisplay();
String errmsg=checkcondition(labPat,labResultList,checkrules,ruledisplay);
if(!"".equals(errmsg)) {
if("0".equals(checktype)) {
errmsg="审核未通过,你是否要强行通过?"+ruledisplay+LisUtil.LINE_SEPARATOR+"审核未通过,你是否要强行通过?"+LisUtil.LINE_SEPARATOR+errmsg;
params.put("code", "5");
params.put("msg",errmsg);
int ruleid0=labCheckrules.getRuleid();
params.put("xh",i);
return params;
}else if("3".equals(checktype)) {
errmsg="审核未通过"+LisUtil.LINE_SEPARATOR+"设置的组合审核条件:"+errmsg+LisUtil.LINE_SEPARATOR+"审核未通过,不允许审核!";
params.put("code", "1");
params.put("msg",errmsg);
return params;
}else if("4".equals(checktype)) {
bz=replacebz(labPat,labResultList,logcontent);
labPat.setBz(bz);
params.put("setbz", true);
errmsg="此次审核将产生一个备注信息"+LisUtil.LINE_SEPARATOR+bz;
params.put("code", "3");
params.put("msg",errmsg);
params.put("bz",bz);
}
}
}
return params;
}
/**
* 计算公式注入参数执行,返回为真则证明筛选条件成立,需要禁止审核通过!
* @param labPat
* @param labResultList
* @param checkrules
* @param ruledisplay
* @return
*/
private String checkcondition(LabPat labPat, List<LabResult> labResultList,String checkrules,String ruledisplay){
String errmsg="";
boolean flag=false;
checkrules=checkrules.replace("\"","'");
if(checkrules.contains("ANY_")){
Map<String, String> variables = new HashMap<>();
String[] parameters=CalcUtils.getParameters(checkrules);
for (int i = 0; i < parameters.length; i++) {
String itemcode = parameters[i];
switch (itemcode) {
case "SEX":
String sex = labPat.getBrxb().trim();
if ("1".equals(sex)) sex = "男";
if ("2".equals(sex)) sex = "女";
errmsg.replace("[SEX]", sex);
break;
case "AGE":
double age = AgeUtils.getDecimalAge(AgeUtils.getBirthDateByAge(labPat.getNl(), labPat.getNldw()));
errmsg.replace("[AGE]", String.valueOf(age));
break;
case "BRLY":
String brly=labPat.getBrly();
String brlymc= commonUtil.getComDictNameById("PT",brly);
if(!"".equals(brlymc)||brlymc != null) brly=brlymc;
errmsg.replace("[BRLY]", brly);
break;
case "KSDH":
String ksdh=labPat.getKsdh();
String ksdhmc= commonUtil.getComDictNameById("DP",ksdh);
if(!"".equals(ksdhmc)||ksdhmc != null) ksdh=ksdhmc;
errmsg.replace("[KSDH]", ksdh);
break;
case "YBLX":
String yblx=labPat.getYblx();
String yblxmc= commonUtil.getComDictNameById("BT",yblx);
if(!"".equals(yblxmc)||yblxmc != null) yblx=yblxmc;
errmsg.replace("[YBLX]", yblx);
break;
case "BZ":
errmsg.replace("[BZ]", labPat.getBz());
break;
case "ZD":
errmsg.replace("[ZD]", labPat.getZd());
break;
case "ANY_NUMER":
errmsg.replace("[ANY_NUMER]", "lab_result.csjg");
break;
case "ANY_TEXT":
errmsg.replace("[ANY_TEXT]", "lab_result.csjg");
break;
case "ANY_CRI":
errmsg.replace("[ANY_CRI]", "lab_result.alarm_flag");
break;
case "ANY_REV":
errmsg.replace("[ANY_REV]", "lab_result.redo_flag");
break;
case "ANY_JGBZ":
errmsg.replace("[ANY_CRI]", "lab_result.result_flag");
break;
case "ANY_ID":
errmsg.replace("[ANY_CRI]", "lab_result.xmdh");
break;
default:
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="";
errmsg.replace("["+itemcode+"]", csjg);
}
List<LabResult> labResultList0=commonUtil.labResultMapper.getLabResultWithSql(labPat.getJyrq(),labPat.getYq(),labPat.getYbh(),errmsg);
if(labResultList0.size()>0)flag=true;
}
if(flag=true) errmsg = "审核条件: " + ruledisplay + " 未通过!" ;
}else{
Map<String, String> variables = new HashMap<>();
String[] parameters=CalcUtils.getParameters(checkrules);
for (int i = 0; i < parameters.length; i++) {
String itemcode = parameters[i];
switch (itemcode) {
case "SEX":
String sex = labPat.getBrxb().trim();
if ("1".equals(sex)) sex = "男";
if ("2".equals(sex)) sex = "女";
variables.put(itemcode, sex);
break;
case "AGE":
double age = AgeUtils.getDecimalAge(AgeUtils.getBirthDateByAge(labPat.getNl(), labPat.getNldw()));
variables.put(itemcode, String.valueOf(age));
break;
case "BRLY":
String brly=labPat.getBrly();
String brlymc= commonUtil.getComDictNameById("PT",brly);
if(!"".equals(brlymc)||brlymc != null) brly=brlymc;
variables.put(itemcode, brly);
break;
case "KSDH":
String ksdh=labPat.getKsdh();
String ksdhmc= commonUtil.getComDictNameById("DP",ksdh);
if(!"".equals(ksdhmc)||ksdhmc != null) ksdh=ksdhmc;
variables.put(itemcode, ksdh);
break;
case "YBLX":
String yblx=labPat.getYblx();
String yblxmc= commonUtil.getComDictNameById("BT",yblx);
if(!"".equals(yblxmc)||yblxmc != null) yblx=yblxmc;
variables.put(itemcode, yblx);
break;
case "BZ":
variables.put(itemcode, labPat.getBz());
break;
case "ZD":
variables.put(itemcode, labPat.getZd());
break;
default:
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="";
variables.put(itemcode, csjg);
}
}
flag=CalcUtils.getBooleanFromCalc(checkrules, variables);
if(flag=true) errmsg = "审核条件: " + ruledisplay + " 未通过!" ;
}
return errmsg;
}
/**
* 备注信息公式转换备注内容
* @param labPat
* @param labResultList
* @param logcontent
* @return
*/
private String replacebz(LabPat labPat, List<LabResult> labResultList,String logcontent){
String errmsg=logcontent;
String[] parameters=CalcUtils.getParameters(logcontent);
for (int i = 0; i < parameters.length; i++) {
String itemcode = parameters[i];
switch (itemcode) {
case "SEX":
String sex = labPat.getBrxb().trim();
if ("1".equals(sex)) sex = "男";
if ("2".equals(sex)) sex = "女";
errmsg.replace("[SEX]",sex);
break;
case "AGE":
double age = AgeUtils.getDecimalAge(AgeUtils.getBirthDateByAge(labPat.getNl(), labPat.getNldw()));
errmsg.replace("[AGE]",String.valueOf(age));
break;
case "BRLY":
String brly=labPat.getBrly();
String brlymc= commonUtil.getComDictNameById("PT",brly);
if(!"".equals(brlymc)||brlymc != null) brly=brlymc;
errmsg.replace("[BRLY]", brly);
break;
case "KSDH":
String ksdh=labPat.getKsdh();
String ksdhmc= commonUtil.getComDictNameById("DP",ksdh);
if(!"".equals(ksdhmc)||ksdhmc != null) ksdh=ksdhmc;
errmsg.replace("[KSDH]", ksdh);
break;
case "YBLX":
String yblx=labPat.getYblx();
String yblxmc= commonUtil.getComDictNameById("BT",yblx);
if(!"".equals(yblxmc)||yblxmc != null) yblx=yblxmc;
errmsg.replace("[YBLX]", yblx);
break;
case "BZ":
errmsg.replace("[BZ]", labPat.getBz());
break;
case "ZD":
errmsg.replace("[ZD]", labPat.getZd());
break;
default:
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="";
errmsg.replace("["+itemcode+"]", csjg);
}
}
String bz=labPat.getBz();
if(errmsg!=null && !"".equals(errmsg))
if(bz==null||"".equals(bz)) bz=errmsg;
else {
String bz0=String.valueOf(bz.charAt(bz.length() - 1));
switch (bz0) {
case ",":
case ":":
case ";":
case ".":
case "。":
case ",":
case "、":
case ";":
case ":":
bz=bz+errmsg;
break;
default:
bz=bz+","+errmsg;
}}
return bz;
}
} }

View File

@ -30,7 +30,7 @@ public class CommonUtil {
@Autowired @Autowired
ComDictMapper comDictMapper; ComDictMapper comDictMapper;
@Autowired @Autowired
private LabResultMapper labResultMapper; LabResultMapper labResultMapper;
@Autowired @Autowired
LabReqdetailMapper labReqdetailMapper; LabReqdetailMapper labReqdetailMapper;
@Autowired @Autowired

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.czlis.interfaceCommon.mapper.LabCheckrulesMapper">
<select id="getLabCheckrules">
SELECT ruleid,rptunitid,checkrules,checktype,logflag,logcontent,ruledisplay,actions
FROM lab_checkrules where logflag = '1' and rptunitid = #{yq}
</select>
<select id="getLabCheckrulesAutocheck">
SELECT ruleid,rptunitid,checkrules,checktype,logflag,logcontent,ruledisplay,actions
FROM lab_checkrules where (isnull(autocheck,'') = '1') and rptunitid = #{yq}
</select>
</mapper>

View File

@ -37,6 +37,24 @@
</if> </if>
</where> ORDER BY xm_info.dyxh </where> ORDER BY xm_info.dyxh
</select> </select>
<select id="getLabResultWithSql" resultType="com.czlis.common.core.domain.entity.lis.LabResult">
select
lab_result.jyrq, lab_result.yq, lab_result.ybh, lab_result.xmdh, wyh, csjg, od, cutoff, lab_result.jgbz, bz1, bz2, yhdh, instrid, operdt,
operna, refs, flag, lab_result.dw, result_flag, alarm_flag, redo_flag, sqxmdh, redo_text,xm_info.xmmc,xm_info.ygzq,xm_info.ygzd
,textresult
from lab_result join xm_info on xm_info.yq=lab_result.yq and xm_info.xmdh=lab_result.xmdh
<where>
<if test="jyrq != null ">
and lab_result.jyrq = #{jyrq}
</if>
<if test="yq != null and yq != ''">
and lab_result.yq = #{yq}
</if>
<if test="ybh != null and ybh != ''">
and lab_result.ybh = #{ybh}
</if>
</where> ${wheresql}
</select>
<delete id="delLabResult" parameterType="com.czlis.common.core.domain.entity.lis.LabResult"> <delete id="delLabResult" parameterType="com.czlis.common.core.domain.entity.lis.LabResult">
delete from lab_result delete from lab_result
where jyrq = #{jyrq} where jyrq = #{jyrq}
@ -353,4 +371,5 @@
and ybh = #{ybh,jdbcType=VARCHAR} and ybh = #{ybh,jdbcType=VARCHAR}
and xmdh = #{xmdh,jdbcType=VARCHAR} and xmdh = #{xmdh,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>

View File

@ -231,6 +231,15 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
} else if (("".equals(alarmflag) || alarmflag == null) && wjz == 1) { } else if (("".equals(alarmflag) || alarmflag == null) && wjz == 1) {
labPat.setAlarmflag(""); labPat.setAlarmflag("");
} }
//医学审核条件判断
if(problemId<4)problemId=4;
result=chksample(labPat,problemId);
if ("99".equals(result.getCode())) {
labPat.setBz(result.getMsg());
result.setCode("0");
}
if (!"0".equals(result.getCode())) return result;
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;
@ -351,21 +360,7 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
if (Userid == null || "".equals(Userid)) { if (Userid == null || "".equals(Userid)) {
Userid = SecurityUtils.getLoginUser().getUsername(); Userid = SecurityUtils.getLoginUser().getUsername();
} }
//医学审核条件判断
if(problemId<3) {
String checkvalue = checkResultUtils.chksample(labPat, labResultList);
if (checkvalue != null && !"".equals(checkvalue)) {
return new Result("5", checkvalue, 3);
}
}
//医学审核条件判断(新规则)
if(problemId<4) {
Result chksamplenewvalue = checkResultUtils.chksamplenew(labPat, labResultList);
if (chksamplenewvalue.getCode().equals("5")) {
return new Result("5", chksamplenewvalue.getMsg(), 4);
}
if (!chksamplenewvalue.getCode().equals("0")) return chksamplenewvalue;
}
//调用his报告接口,检查外部接口对审核前的定制需求 //调用his报告接口,检查外部接口对审核前的定制需求
SetReport setReport = new SetReport(); SetReport setReport = new SetReport();
setReport.setIp(IpUtils.getIpAddr()); setReport.setIp(IpUtils.getIpAddr());
@ -409,6 +404,49 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
return new Result("0", "保存成功!"); return new Result("0", "保存成功!");
} }
/**
* 医学审核条件判断
* @param labPat
* @param problemId
* @return
*/
private Result chksample(LabPat labPat,Integer problemId) {
List<LabResult> labResultList = commonUtil.getLabResultList(labPat.getJyrq(),labPat.getYq(),labPat.getYbh());
//医学审核条件判断
if(problemId<3) {
String checkvalue = checkResultUtils.chksample(labPat, labResultList);
if (checkvalue != null && !"".equals(checkvalue)) {
return new Result("5", checkvalue, 3);
}
}
Boolean setbz=false;
String bz=labPat.getBz();
//医学审核条件判断(新规则),预留99个递归ID
if(problemId<99) {
int xh=0;
if(problemId>4)xh=problemId - 4;
Map<String, Object> chksamplenewvalue = checkResultUtils.chksamplenew(labPat, labResultList,xh);
String chkCode=(String)chksamplenewvalue.get("code");
String chkMsg=(String)chksamplenewvalue.get("code");
bz=(String)chksamplenewvalue.get("bz");
labPat.setBz(bz);
xh=(Integer) chksamplenewvalue.get("xh");
setbz=(Boolean) chksamplenewvalue.get("setbz");
problemId=4+xh;
if ("5".equals(chkCode)) {
if (setbz){
commonUtil.updateLabPat(labPat);
}
return new Result("5", chkMsg, problemId);
}
if (!"0".equals(chkCode)) return new Result(chkCode, chkMsg, problemId);
}
if (setbz){
commonUtil.updateLabPat(labPat);
return new Result("99", bz);
}
return new Result("0", "保存成功!");
}
/** /**
* 审核后步骤,在审核过程中,必须完成审核前校验通过,结果计算值填充,参考值结果标志危急值标志填写完成,最后使用此方法修改状态 * 审核后步骤,在审核过程中,必须完成审核前校验通过,结果计算值填充,参考值结果标志危急值标志填写完成,最后使用此方法修改状态
* *
@ -476,8 +514,8 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
setReport.setStatus(LisinterfaceNameConstants.REPORTEND); setReport.setStatus(LisinterfaceNameConstants.REPORTEND);
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 < 4) { if (problemId < 100) {
return new Result(result.getCode(), result.getMsg(), 4); return new Result(result.getCode(), result.getMsg(), 100);
} }
return new Result("0", "保存成功!"); return new Result("0", "保存成功!");
} }