134 lines
6.2 KiB
Java
134 lines
6.2 KiB
Java
|
|
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", "");
|
|||
|
|
}
|
|||
|
|
}
|