主业务添加代码

This commit is contained in:
tangw 2025-09-02 17:47:53 +08:00
parent 0a59ac9ffe
commit c2b7ead21f
4 changed files with 194 additions and 15 deletions

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

@ -9,20 +9,18 @@ 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 @Autowired
LabCheckrulesMapper labCheckrulesMapper; 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();
@ -32,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());
@ -200,8 +198,18 @@ public class CheckResultUtils {
return params; return params;
} }
/**
* 计算公式注入参数执行,返回为真则证明筛选条件成立,需要禁止审核通过!
* @param labPat
* @param labResultList
* @param checkrules
* @param ruledisplay
* @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;
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);
@ -212,21 +220,124 @@ 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 = "女";
variables.put("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()));
variables.put("AGE", String.valueOf(age)); errmsg.replace("[AGE]", String.valueOf(age));
break; break;
case "": case "BRLY":
String brly=labPat.getBrly();
String brlymc= commonUtil.getComDictNameById("PT",brly);
if(!"".equals(brlymc)||brlymc != null) brly=brlymc;
errmsg.replace("[BRLY]", brly);
break; 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);
} }
} }
boolean flag=CalcUtils.getBooleanFromCalc(checkrules, variables); flag=CalcUtils.getBooleanFromCalc(checkrules, variables);
errmsg = "审核条件: " + ruledisplay + " 未通过!" ; if(flag=true) errmsg = "审核条件: " + ruledisplay + " 未通过!" ;
} }
return errmsg; return errmsg;
} }
/**
* 备注信息公式转换备注内容
* @param labPat
* @param labResultList
* @param logcontent
* @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);
@ -243,10 +354,58 @@ public class CheckResultUtils {
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 "": case "BRLY":
String brly=labPat.getBrly();
String brlymc= commonUtil.getComDictNameById("PT",brly);
if(!"".equals(brlymc)||brlymc != null) brly=brlymc;
errmsg.replace("[BRLY]", brly);
break; 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);
} }
} }
return ""; 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

@ -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>