主业务添加代码

This commit is contained in:
tangw 2025-08-28 18:13:57 +08:00
parent b1fdb0f795
commit a487501c1f
8 changed files with 272 additions and 8 deletions

View File

@ -0,0 +1,16 @@
package com.czlis.common.core.domain.entity.lis;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LabChk {
private String yq;
private Integer xh;
private String hdnr;
private String tsxx;
}

View File

@ -36,7 +36,7 @@ public class LabReqmain extends BaseEntity {
private String zxys; private String zxys;
private Date zxsj; private Date zxsj;
private String bgddh; private String bgddh;
private BigDecimal costs; private Double costs;
private Integer nl; private Integer nl;
private String nldw; private String nldw;
private String zd; private String zd;

View File

@ -0,0 +1,13 @@
package com.czlis.interfaceCommon.mapper;
import com.czlis.common.core.domain.entity.lis.LabChk;
import com.czlis.common.core.domain.entity.lis.LabResult;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
public interface CheckResultMapper {
List<LabResult> getChkvaList(@Param("brdh") String brdh, @Param("startda") Date startda, @Param("endda") Date endda,@Param("yq") String yq,@Param("xmdh") String xmdh);
List<LabChk> getLabChkList(String yq);
}

View File

@ -0,0 +1,133 @@
package com.czlis.interfaceCommon.utils;
import com.czlis.common.core.domain.Result;
import com.czlis.common.core.domain.entity.lis.*;
import com.czlis.interfaceCommon.mapper.CheckResultMapper;
import com.czlis.interfaceCommon.mapper.XmInfoMapper;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Component
public class CheckResultUtils {
@Autowired
XmInfoMapper xmInfoMapper;
@Autowired
CheckResultMapper checkResultMapper;
public String chksample(LabPat labPat, List<LabResult> labResultList) {
String errmsg = "";
String brdh = labPat.getBrdh();
if (brdh == null || "".equals(brdh)) {
return errmsg;
}
String yq = labPat.getYq();
Date jyrq = labPat.getJyrq();
String ybh = labPat.getYbh();
List<XmInfo> xmInfoList = xmInfoMapper.getXmInfoList(yq);
for (LabResult labResult : labResultList) {
String xmdh = labResult.getXmdh();
List<XmInfo> collect = xmInfoList.stream().filter(xmInfo -> xmInfo.getXmdh().equals(xmdh)).collect(Collectors.toList());
if (collect.size() > 0) {
XmInfo xmInfo = collect.get(0);
//字典规定的结果值范围约束
Double xjx = xmInfo.getXjx();
Double sjx = xmInfo.getSjx();
if (xjx != null || sjx != null) {
String csjg = LisUtil.getOverNumber(labResult.getCsjg());
if (LisUtil.isNumber(csjg)) {
Double csjgnum = Double.parseDouble(csjg);
if (xjx != null && csjgnum <= xjx) {
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() + ") 相比超标";
}
}
}
}
}
}
List<LabChk> labChkList=checkResultMapper.getLabChkList(yq);
for(LabChk labChk:labChkList){
String jsgs=labChk.getHdnr();
boolean setjgsg = true;
Map<String, String> variables = new HashMap<>();
String[] parameters = CalcUtils.getParameters(jsgs);
for (int i = 0; i < parameters.length; i++) {
String itemcode = parameters[i];
if ("SEX".equals(itemcode)) {
String sex = labPat.getBrxb().trim();
if ("1".equals(sex)) sex = "男";
if ("2".equals(sex)) sex = "女";
variables.put("SEX", sex);
} else if ("AGE".equals(itemcode)) {
double age = AgeUtils.getDecimalAge(AgeUtils.getBirthDateByAge(labPat.getNl(), labPat.getNldw()));
variables.put("AGE", String.valueOf(age));
} else {
List<LabResult> collect = labResultList.stream().filter(result -> result.getXmdh().equals(itemcode)).collect(Collectors.toList());
if (collect.size() > 0) {
variables.put(itemcode, collect.get(0).getCsjg());
} else {
setjgsg = false;
}
}
}
//项目不全,此公式跳过
if(setjgsg) {
boolean result = CalcUtils.getBooleanFromCalc(jsgs, variables);
if (!result) {
errmsg=errmsg+LisUtil.LINE_SEPARATOR+"审核条件: "+ jsgs + " 未通过!";
}
}
}
if(!"".equals(errmsg))errmsg= errmsg +LisUtil.LINE_SEPARATOR+ "请咨询该仪器组长或专业检验师 !";
return errmsg;
}
public Result chksamplenew(LabPat labPat, List<LabResult> labResultList){
return new Result("0", "");
}
}

View File

@ -1,10 +1,12 @@
package com.czlis.interfaceCommon.utils; package com.czlis.interfaceCommon.utils;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
public class LisUtil { public class LisUtil {
// 换行符常量(跨平台)
public static final String LINE_SEPARATOR = System.lineSeparator();
/** /**
* 生日格式为:yyyy-MM-dd * 生日格式为:yyyy-MM-dd
* 根据出生日期计算年龄 * 根据出生日期计算年龄
@ -203,4 +205,55 @@ public class LisUtil {
return input; return input;
} }
} }
/**
* 根据天数返回日期,正数往后推,负数往前推
* @param day
* @return
*/
public static Date relativeDate(int day) {
// 1. 获取当前时间(基于Calendar)
Calendar calendar = Calendar.getInstance(); // 当前时间
calendar.add(Calendar.DAY_OF_MONTH, day);
// 2重置时间为00:00:00
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
// 3. 返回推算的出生日期
return calendar.getTime();
}
public static Date relativeDate(Date date,int day) {
// 1. 获取当前时间(基于Calendar)
Calendar calendar =Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, day);
// 2重置时间为00:00:00
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
// 3. 返回推算的出生日期
return calendar.getTime();
}
/**
* 根据天数返回日期时间,正数往后推,负数往前推
* @param day
* @return
*/
public static Date relativeDateTime(int day) {
// 1. 获取当前时间(基于Calendar)
Calendar calendar = Calendar.getInstance(); // 当前时间
// 2天:忽略小时,按整天推算
calendar.add(Calendar.DAY_OF_MONTH, day);
// 3. 返回推算的时间
return calendar.getTime();
}
public static Date relativeDateTime(Date date,int day) {
// 1. 获取当前时间(基于Calendar)
Calendar calendar = Calendar.getInstance(); // 当前时间
calendar.setTime(date);
// 2天:忽略小时,按整天推算
calendar.add(Calendar.DAY_OF_MONTH, day);
// 3. 返回推算的时间
return calendar.getTime();
}
} }

View File

@ -21,5 +21,12 @@
and DATEPART(weekday, GETDATE()- 1)>= a.weekday and a.weekday1>=DATEPART(weekday, GETDATE()- 1) and DATEPART(weekday, GETDATE()- 1)>= a.weekday and a.weekday1>=DATEPART(weekday, GETDATE()- 1)
and a.bglqdh = #{bglqdh} and a.bglqdh = #{bglqdh}
</select> </select>
<select id="getbglqsm" resultType="String">
select isnull((SELECT top 1 d.bglqsm FROM lab_rptgetruledetail d WHERE d.bglqdh
in(select isnull(xm_fee.bglqdh,c.bglqdh) from xm_fee,lab_reqdetail where xm_fee.sfxmdh=lab_reqdetail.sqxmdh and lab_reqdetail.sqh=b.sqh)
and CONVERT(varchar(5), GETDATE(), 8) >= d.kssj AND d.jssj >= CONVERT(varchar(5), GETDATE(), 8) AND
DATEPART(weekday, GETDATE()- 1)>= d.weekday and d.weekday1>=DATEPART(weekday, GETDATE()- 1)
order by bgxss desc ),'') as bglqsm
from lab_reqmain b left join lab_feeitemclass c on c.sflbdh=b.bgddh where b.sqh = #{sqh}
</select>
</mapper> </mapper>

View File

@ -0,0 +1,26 @@
<?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.CheckResultMapper">
<select id="getChkvaList" resultType="com.czlis.common.core.domain.entity.lis.LabResult">
SELECT lab_result.jyrq,
lab_result.ybh,
lab_result.csjg
FROM lab_result,
lab_pat
WHERE ( lab_result.jyrq = lab_pat.jyrq ) and
( lab_result.yq = lab_pat.yq ) and
( lab_result.ybh = lab_pat.ybh ) and
( ( lab_pat.brdh = #{brdh} ) AND
( lab_result.jyrq >= #{startda} ) AND
( #{endda} >= lab_result.jyrq ) AND
( lab_result.yq = #{yq} ) AND
( lab_result.xmdh =#{xmdh} ) )
</select>
<select id="getLabChkList" resultType="com.czlis.common.core.domain.entity.lis.LabChk">
SELECT lab_chk.yq ,lab_chk.xh,lab_chk.hdnr,lab_chk.tsxx
FROM lab_chk WHERE lab_chk.yq = #{yq}
</select>
</mapper>

View File

@ -49,7 +49,8 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
LabReqmainMapper labReqmainMapper; LabReqmainMapper labReqmainMapper;
@Autowired @Autowired
LabReqdetailMapper labReqdetailMapper; LabReqdetailMapper labReqdetailMapper;
@Autowired
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) {
@ -331,14 +332,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 = "该申请单已经发过结果了,禁止审核!\r\n日期:" + 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 = "该申请单已经发过结果了,禁止审核!\r\n日期:" + 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);
} }
} }
@ -350,6 +351,21 @@ 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());
@ -383,8 +399,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 < 3) { if (problemId < 5) {
return new Result(result.getCode(), result.getMsg(), 3); return new Result(result.getCode(), result.getMsg(), 5);
} }
return new Result("0", "保存成功!"); return new Result("0", "保存成功!");
} }