@ -41,8 +41,9 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
LabReqmainMapper labReqmainMapper ;
@Autowired
LabReqdetailMapper labReqdetailMapper ;
@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 ) {
LabReqmain labReqmainOne = commonUtil . getLabReqmainOne ( sqh ) ;
if ( labReqmainOne = = null ) {
@ -58,15 +59,15 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
lisInterfaceUtil . invokeLisInterface ( LisinterfaceNameConstants . GETREQINTERFACE , getReqInterface ) ;
labReqmainOne = commonUtil . getLabReqmainOne ( sqh ) ;
}
if ( labReqmainOne = = null ) return new Result ( " -1 " , " 没有获取到申请单信息! " ) ;
if ( labReqmainOne = = null ) return new Result ( " -1 " , " 没有获取到申请单信息! " ) ;
String zt = labReqmainOne . getZt ( ) . trim ( ) ;
/ / 2 . 校验信息
/ / 校验状态信息
Result result1 = checkZT ( sqh , yq , zt ) ;
if ( ! result1 . getCode ( ) . equals ( " 0 " ) ) return result1 ;
if ( ! result1 . getCode ( ) . equals ( " 0 " ) ) return result1 ;
/ / 校验条码类别
Result result2 = checkReqClass ( sqh , yq , labReqmainOne . getBgddh ( ) ) ;
if ( ! result2 . getCode ( ) . equals ( " 0 " ) ) return result2 ;
if ( ! result2 . getCode ( ) . equals ( " 0 " ) ) return result2 ;
/ / 3 . 调用his上机接口 ,
SetReqStatus setReqStatus = new SetReqStatus ( ) ;
@ -75,7 +76,7 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
setReqStatus . setUserid ( userId . toString ( ) ) ;
setReqStatus . setStatus ( SampleStatusConstants . SIGNFOR ) ;
Result result = lisInterfaceUtil . invokeLisInterface ( LisinterfaceNameConstants . SETREQSTATUS , setReqStatus ) ;
if ( ! result . getCode ( ) . equals ( " 0 " ) ) return result ;
if ( ! result . getCode ( ) . equals ( " 0 " ) ) return result ;
/ / 4 . 获取病人信息
DayMessage dayMessage = new DayMessage ( ) ;
@ -83,7 +84,7 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
dayMessage . setYljg ( " 1 " ) ;
dayMessage . setUserid ( userId . toString ( ) ) ;
dayMessage . setMsgid ( LisinterfaceNameConstants . DAYMESSAGE_GETPATIENT ) ;
String val = labReqmainOne . getBrdh ( ) + " | " + labReqmainOne . getBrly ( ) + " | " ; / / 这里有个医疗机构的 , 没有传 , 要考虑
String val = labReqmainOne . getBrdh ( ) + " | " + labReqmainOne . getBrly ( ) + " | " ; / / 这里有个医疗机构的 , 没有传 , 要考虑
dayMessage . setMsg ( val ) ;
/ / 5 . 保存数据
@ -93,7 +94,7 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
/ / 6 . 写日志
return new Result ( " 0 " , " " ) ;
return new Result ( " 0 " , " " ) ;
}
@Override
@ -101,58 +102,58 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
return null ;
}
private Result checkZT ( String sqh , String yq , String zt ) {
if ( zt . equals ( " 9 " ) ) return new Result ( " -1 " , " 当前条码已经作废,不允许上机! " ) ;
private Result checkZT ( String sqh , String yq , String zt ) {
if ( zt . equals ( " 9 " ) ) return new Result ( " -1 " , " 当前条码已经作废,不允许上机! " ) ;
String SP_GETTOWREQOK = commonUtil . getComOptValue ( " HISOPT " , " SP_GETTOWREQOK " ) ; / / 申请单禁止重复上机
String SP_GETTOWREQOKYQ = commonUtil . getComOptValue ( " HISOPT " , " SP_GETTOWREQOKYQ " ) ; / / 申请单禁止同仪器重复上机
if ( zt . equals ( " 2 " ) ) {
if ( SP_GETTOWREQOK . equals ( " 1 " ) ) return new Result ( " -1 " , " 当前条码已经上机! " ) ;
if ( SP_GETTOWREQOKYQ . equals ( " 1 " ) ) {
if ( zt . equals ( " 2 " ) ) {
if ( SP_GETTOWREQOK . equals ( " 1 " ) ) return new Result ( " -1 " , " 当前条码已经上机! " ) ;
if ( SP_GETTOWREQOKYQ . equals ( " 1 " ) ) {
List < LabPat > labPatList = commonUtil . getLabPatListBySqh ( sqh ) ;
for ( LabPat labPat : labPatList ) {
String yq1 = labPat . getYq ( ) ;
if ( yq . equals ( yq1 ) ) return new Result ( " -1 " , " 该条码已经在当前仪器上机,不允许重复上机! " ) ;
if ( yq . equals ( yq1 ) ) return new Result ( " -1 " , " 该条码已经在当前仪器上机,不允许重复上机! " ) ;
}
}
}
return new Result ( " 0 " , " 校验成功! " ) ;
return new Result ( " 0 " , " 校验成功! " ) ;
}
private Result checkReqClass ( String sqh , String yq , String bgddh ) {
private Result checkReqClass ( String sqh , String yq , String bgddh ) {
String value = commonUtil . getComOptValue ( yq , " chkreqclass " ) ;
if ( ! value . equals ( " 1 " ) ) return new Result ( " 0 " , " " ) ;
if ( ! value . equals ( " 1 " ) ) return new Result ( " 0 " , " " ) ;
LabInstrvsreqclass labInstrvsreqclass = new LabInstrvsreqclass ( ) ;
labInstrvsreqclass . setYq ( yq ) ;
List < LabInstrvsreqclass > labInstrvsreqclassList = labInstrvsreqclassMapper . getLabInstrvsreqclassList ( labInstrvsreqclass ) ;
if ( labInstrvsreqclassList . size ( ) > 0 ) {
if ( labInstrvsreqclassList . size ( ) > 0 ) {
List < LabInstrvsreqclass > collect = labInstrvsreqclassList . stream ( ) . filter ( labInstrvsreqclass1 - > labInstrvsreqclass1 . getBgddh ( ) . equals ( bgddh ) ) . collect ( Collectors . toList ( ) ) ;
List < LabInstrvsreqclass > collect1 = labInstrvsreqclassList . stream ( ) . filter ( labInstrvsreqclass1 - > labInstrvsreqclass1 . getBgddh ( ) . equals ( " MZ_ " + bgddh ) ) . collect ( Collectors . toList ( ) ) ;
if ( collect . size ( ) > 0 ) return new Result ( " 0 " , " " ) ;
if ( collect1 . size ( ) > 0 ) return new Result ( " 0 " , " " ) ;
if ( collect . size ( ) > 0 ) return new Result ( " 0 " , " " ) ;
if ( collect1 . size ( ) > 0 ) return new Result ( " 0 " , " " ) ;
}
Long count = lisWorkOperMapper . checkReqClass ( sqh , yq ) ;
if ( count > 0 ) {
return new Result ( " 0 " , " " ) ;
} else {
return new Result ( " 1 " , " " ) ;
if ( count > 0 ) {
return new Result ( " 0 " , " " ) ;
} else {
return new Result ( " 1 " , " " ) ;
}
}
@Transactional ( rollbackFor = Exception . class )
public Result saveReqInfo ( String userId , String sqh , LabReqmain labReqmain , String yq , Date jyrq , String ybh ) {
public Result saveReqInfo ( String userId , String sqh , LabReqmain labReqmain , String yq , Date jyrq , String ybh ) {
/ / 修改状态和时间
updateLabReqmainZT ( userId , sqh ) ;
updateLabReqmainZT ( userId , sqh ) ;
/ / 保存lab_pat表信息
LabPat labPat = new LabPat ( ) ;
labPat . setJyrq ( commonUtil . getCurrentTime ( ) ) ;
labPat . setYq ( yq ) ;
labPat . setYbh ( ybh ) ;
labPat . setYblx ( commonUtil . getComDictIdByName ( " BT " , labReqmain . getYblx ( ) ) ) ;
labPat . setKsdh ( commonUtil . getComDictIdByName ( " DP " , labReqmain . getKsdh ( ) ) ) ;
labPat . setYblx ( commonUtil . getComDictIdByName ( " BT " , labReqmain . getYblx ( ) ) ) ;
labPat . setKsdh ( commonUtil . getComDictIdByName ( " DP " , labReqmain . getKsdh ( ) ) ) ;
labPat . setSjys ( userId ) ;
labPat . setBrdh ( labReqmain . getBrdh ( ) ) ;
labPat . setBrxm ( labReqmain . getBrxm ( ) ) ;
@ -169,7 +170,7 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
labPat . setJgbz ( " 0 " ) ;
labPat . setZd ( labReqmain . getZd ( ) ) ;
labPat . setCyrq ( labReqmain . getCysj ( ) ) ;
labPat . setJymd ( LisUtil . substringByGbkWidth ( labReqmain . getJymd ( ) , 0 , 50 ) ) ;
labPat . setJymd ( LisUtil . substringByGbkWidth ( labReqmain . getJymd ( ) , 0 , 50 ) ) ;
labPat . setLastuser ( userId ) ;
labPat . setLastdt ( commonUtil . getCurrentTime ( ) ) ;
labPat . setShcs ( 0 ) ;
@ -179,161 +180,171 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
labPat . setAddr ( labReqmain . getAddr ( ) ) ;
labPat . setLstd ( labReqmain . getLstd ( ) ) ;
commonUtil . insertLabPat ( labPat ) ;
return new Result ( " 0 " , " 保存成功! " ) ;
return new Result ( " 0 " , " 保存成功! " ) ;
}
public void updateLabReqmainZT ( String userId , String sqh ) {
public void updateLabReqmainZT ( String userId , String sqh ) {
Map < String , Object > map = new HashMap < > ( ) ;
map . put ( " userId " , userId ) ;
map . put ( " sqh " , sqh ) ;
map . put ( " userId " , userId ) ;
map . put ( " sqh " , sqh ) ;
labReqmainMapper . updateLabReqmainZT ( map ) ;
}
/ * *
* 审核报告单全流程
*
* @param jyrq
* @param yq
* @param ybh
* @param hdys
* @return
* /
public Result check2 ( Date jyrq , String yq , String ybh , String hdys ) {
public Result check2 ( Date jyrq , String yq , String ybh , String hdys ) {
/ / 1 , 审核权限校验
if ( ! commonUtil . getUserPower ( yq , hdys , 20 ) ) return new Result ( " -1 " , " 当前核对者无权对本仪器报告审核! " ) ;
/ / 2 : 数据合法性校验
Result result = beforecheck2 ( jyrq , yq , ybh , hdys ) ;
if ( " 0 " . equals ( result . getCode ( ) ) ) return result ;
if ( ! commonUtil . getUserPower ( yq , hdys , 20 ) ) return new Result ( " -1 " , " 当前核对者无权对本仪器报告审核! " ) ;
/ / 2 : 数据合法性校验
Result result = beforecheck2 ( jyrq , yq , ybh , hdys ) ;
if ( " 0 " . equals ( result . getCode ( ) ) ) return result ;
/ / 3 : 数据完整性校验
result = saveallresult ( jyrq , yq , ybh ) ;
if ( " 0 " . equals ( result . getCode ( ) ) ) return result ;
result = saveallresult ( jyrq , yq , ybh ) ;
if ( " 0 " . equals ( result . getCode ( ) ) ) return result ;
/ / 4 : CA请求业务的处理
/ / Result result = addCA ( jyrq , yq , ybh , hdys ) ;
/ / if ( " 0 " . equals ( result . getCode ( ) ) ) return result ;
/ / 5 : 数据状态修改 , 异步上传接口作业创建
/ / Result result = aftercheck2 ( jyrq , yq , ybh , hdys ) ;
/ / if ( " 0 " . equals ( result . getCode ( ) ) ) return result ;
return new Result ( " 0 " , " 保存成功! " ) ;
return new Result ( " 0 " , " 保存成功! " ) ;
}
public Result beforecheck2 ( Date jyrq , String yq , String ybh , String hdys ) {
if ( hdys = = null | | " " . equals ( hdys ) ) new Result ( " -1 " , " 审核者为空,无法审核! " ) ;
LabPat labPat = commonUtil . getLabPatOne ( jyrq , yq , ybh ) ;
if ( labPat = = null ) return new Result ( " -1 " , " 病人信息为空禁止审核! " ) ;
String jgbz = labPat . getJgbz ( ) ;
if ( " 2 " . equals ( jgbz ) ) new Result ( " 0 " , " 保存成功! " ) ;
if ( " 5 " . equals ( jgbz ) ) return new Result ( " -1 " , " 已锁定报告禁止审核! " ) ;
if ( ! " 1 " . equals ( jgbz ) ) {
String f_check1 = commonUtil . getComOptValue ( yq , " f_check1 " ) ;
if ( " 1 " . equals ( f_check1 ) ) return new Result ( " -1 " , " 审核前必须先初审! " ) ;
public Result beforecheck2 ( Date jyrq , String yq , String ybh , String hdys ) {
if ( hdys = = null | | " " . equals ( hdys ) ) new Result ( " -1 " , " 审核者为空,无法审核! " ) ;
LabPat labPat = commonUtil . getLabPatOne ( jyrq , yq , ybh ) ;
if ( labPat = = null ) return new Result ( " -1 " , " 病人信息为空禁止审核! " ) ;
String jgbz = labPat . getJgbz ( ) ;
if ( " 2 " . equals ( jgbz ) ) new Result ( " 0 " , " 保存成功! " ) ;
if ( " 5 " . equals ( jgbz ) ) return new Result ( " -1 " , " 已锁定报告禁止审核! " ) ;
if ( ! " 1 " . equals ( jgbz ) ) {
String f_check1 = commonUtil . getComOptValue ( yq , " f_check1 " ) ;
if ( " 1 " . equals ( f_check1 ) ) return new Result ( " -1 " , " 审核前必须先初审! " ) ;
}
String brxm = labPat . getBrxm ( ) ;
if ( brxm = = null | | " " . equals ( brxm ) ) new Result ( " -1 " , " 姓名为空禁止审核! " ) ;
List < LabResult > labResultList = commonUtil . getLabResultList ( jyrq , yq , ybh ) ;
if ( labResultList = = null ) return new Result ( " -1 " , " 结果为空禁止审核! " ) ;
String brxm = labPat . getBrxm ( ) ;
if ( brxm = = null | | " " . equals ( brxm ) ) new Result ( " -1 " , " 姓名为空禁止审核! " ) ;
List < LabResult > labResultList = commonUtil . getLabResultList ( jyrq , yq , ybh ) ;
if ( labResultList = = null ) return new Result ( " -1 " , " 结果为空禁止审核! " ) ;
for ( LabResult labResult : labResultList ) {
String csjg = labResult . getCsjg ( ) ;
String csjg = labResult . getCsjg ( ) ;
if ( " 未做 " . equals ( csjg ) ) {
return new Result ( " -1 " , " 还有结果为“未做”的项目,不可审核! " ) ;
return new Result ( " -1 " , " 还有结果为“未做”的项目,不可审核! " ) ;
}
if ( csjg ! = null ) {
if ( csjg . contains ( " ERR " ) ) return new Result ( " -1 " , " 有结果错误,不可审核! " ) ;
if ( csjg . contains ( " 需稀释 " ) ) return new Result ( " -1 " , " 有结果需稀释,不可审核! " ) ;
if ( csjg . contains ( " 需复做 " ) ) return new Result ( " -1 " , " 有结果需复做,不可审核! " ) ;
if ( csjg ! = null ) {
if ( csjg . contains ( " ERR " ) ) return new Result ( " -1 " , " 有结果错误,不可审核! " ) ;
if ( csjg . contains ( " 需稀释 " ) ) return new Result ( " -1 " , " 有结果需稀释,不可审核! " ) ;
if ( csjg . contains ( " 需复做 " ) ) return new Result ( " -1 " , " 有结果需复做,不可审核! " ) ;
}
}
return new Result ( " 0 " , " 保存成功! " ) ;
return new Result ( " 0 " , " 保存成功! " ) ;
}
/ * *
* 保存所有结果的修正值 , 涉及 : 空结果清除 , 计算项目添加 , 添加单位 , 添加申请项目编码 , 参考值重新计算更新 , 结果标志重新计算更新 , 危急值标志计算更新
*
* @param jyrq
* @return
* /
public Result saveallresult ( Date jyrq , String yq , String ybh ) {
public Result saveallresult ( Date jyrq , String yq , String ybh ) {
/ / 清除空白结果
String keepnodataitem = commonUtil . getComOptValue ( yq , " keepnodataitem " ) ;
if ( ! " 1 " . equals ( keepnodataitem ) ) {
String keepnodataitem = commonUtil . getComOptValue ( yq , " keepnodataitem " ) ;
if ( ! " 1 " . equals ( keepnodataitem ) ) {
commonUtil . delNullLabResult ( jyrq , yq , ybh ) ;
}
/ / 查询病人信息
LabPat labPat = commonUtil . getLabPatOne ( jyrq , yq , ybh ) ;
LabPat labPat = commonUtil . getLabPatOne ( jyrq , yq , ybh ) ;
/ / 计算项目更新
calcsample ( labPat ) ;
/ / 保存最新参考值结果标志
saverefs ( labPat ) ;
/ / 补写结果表申请单项目编号
setItemSqxmdh ( jyrq , yq , ybh , labPat . getSqh ( ) ) ;
return new Result ( " 0 " , " 保存成功! " ) ;
setItemSqxmdh ( jyrq , yq , ybh , labPat . getSqh ( ) ) ;
return new Result ( " 0 " , " 保存成功! " ) ;
}
/ * *
* 结果表补充申请单项目代码
*
* @param jyrq
* @param yq
* @param ybh
* /
public void setItemSqxmdh ( Date jyrq , String yq , String ybh ) {
String sqh = commonUtil . getSqhByKey ( jyrq , yq , ybh ) ;
if ( sqh = = null | | " " . equals ( sqh ) ) { } else {
setItemSqxmdh ( jyrq , yq , ybh , sqh ) ;
public void setItemSqxmdh ( Date jyrq , String yq , String ybh ) {
String sqh = commonUtil . getSqhByKey ( jyrq , yq , ybh ) ;
if ( sqh = = null | | " " . equals ( sqh ) ) {
} else {
setItemSqxmdh ( jyrq , yq , ybh , sqh ) ;
}
}
/ / 内部使用
private void setItemSqxmdh ( Date jyrq , String yq , String ybh , String sqh ) {
if ( sqh = = null | | " " . equals ( sqh ) ) { } else {
int sl = labReqdetailMapper . getCountByKey ( sqh ) ;
if ( sl = = 1 ) {
String sqxmdh = lisWorkOperMapper . selectSqxmdh ( sqh ) ;
lisWorkOperMapper . updatelabresultsqxmdhall ( jyrq , yq , ybh , sqxmdh ) ;
} else {
lisWorkOperMapper . updatelabresultsqxmdh ( jyrq , yq , ybh , sqh ) ;
private void setItemSqxmdh ( Date jyrq , String yq , String ybh , String sqh ) {
if ( sqh = = null | | " " . equals ( sqh ) ) {
} else {
int sl = labReqdetailMapper . getCountByKey ( sqh ) ;
if ( sl = = 1 ) {
String sqxmdh = lisWorkOperMapper . selectSqxmdh ( sqh ) ;
lisWorkOperMapper . updatelabresultsqxmdhall ( jyrq , yq , ybh , sqxmdh ) ;
} else {
lisWorkOperMapper . updatelabresultsqxmdh ( jyrq , yq , ybh , sqh ) ;
}
}
}
/ * *
* 计算项目增加及重新计算
*
* @param jyrq
* @param yq
* @param ybh
* /
public Result calcsample ( Date jyrq , String yq , String ybh ) {
LabPat labPat = commonUtil . getLabPatOne ( jyrq , yq , ybh ) ;
public Result calcsample ( Date jyrq , String yq , String ybh ) {
LabPat labPat = commonUtil . getLabPatOne ( jyrq , yq , ybh ) ;
calcsample ( labPat ) ;
return new Result ( " 0 " , " 保存成功! " ) ;
return new Result ( " 0 " , " 保存成功! " ) ;
}
/ / 内部使用
private void calcsample ( LabPat labPat ) {
Date jyrq = labPat . getJyrq ( ) ;
String yq = labPat . getYq ( ) ;
String ybh = labPat . getYbh ( ) ;
List < ResultCalcDTO > resultCalcDTO = lisWorkOperMapper . getResultCalc ( jyrq , yq , ybh ) ;
String xmdhold = " " ;
private void calcsample ( LabPat labPat ) {
Date jyrq = labPat . getJyrq ( ) ;
String yq = labPat . getYq ( ) ;
String ybh = labPat . getYbh ( ) ;
List < ResultCalcDTO > resultCalcDTO = lisWorkOperMapper . getResultCalc ( jyrq , yq , ybh ) ;
String xmdhold = " " ;
for ( ResultCalcDTO resultCalc : resultCalcDTO ) {
String jsgs = resultCalc . getJsgs ( ) ;
String xmdh = resultCalc . getJsxm ( ) ;
if ( ! xmdhold . equals ( xmdh ) ) {
String jsgs = resultCalc . getJsgs ( ) ;
String xmdh = resultCalc . getJsxm ( ) ;
if ( ! xmdhold . equals ( xmdh ) ) {
xmdhold = xmdh ;
String sex = labPat . getBrxb ( ) . trim ( ) ;
if ( " 1 " . equals ( sex ) ) sex = " 男 " ;
if ( " 2 " . equals ( sex ) ) sex = " 女 " ;
String sex = labPat . getBrxb ( ) . trim ( ) ;
if ( " 1 " . equals ( sex ) ) sex = " 男 " ;
if ( " 2 " . equals ( sex ) ) sex = " 女 " ;
double age = AgeUtils . getDecimalAge ( AgeUtils . getBirthDateByAge ( labPat . getNl ( ) , labPat . getNldw ( ) ) ) ;
Map < String , String > variables = new HashMap < > ( ) ;
variables . put ( " SEX " , sex ) ; / / 示例值
variables . put ( " AGE " , String . valueOf ( age ) ) ;
String result = CalcUtils . getValueFromCalc ( jsgs , variables ) ;
String result = CalcUtils . getValueFromCalc ( jsgs , variables ) ;
if ( result ! = null & & ! result . trim ( ) . isEmpty ( ) ) {
/ / 插入结果值
LabResult labResult = commonUtil . getLabResult ( jyrq , yq , ybh , xmdh ) ;
if ( labResult = = null ) {
labResult = new LabResult ( ) ;
LabResult labResult = commonUtil . getLabResult ( jyrq , yq , ybh , xmdh ) ;
if ( labResult = = null ) {
labResult = new LabResult ( ) ;
labResult . setJyrq ( jyrq ) ;
labResult . setYq ( yq ) ;
labResult . setYbh ( ybh ) ;
labResult . setXmdh ( xmdh ) ;
labResult . setCsjg ( result ) ;
commonUtil . insertLabResult ( labResult ) ;
} else {
} else {
labResult . setCsjg ( result ) ;
commonUtil . updateLabResult ( labResult ) ;
}
@ -341,30 +352,33 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
}
}
}
/ * *
* 计算项目参考值结果异常标志
*
* @param jyrq
* @param yq
* @param ybh
* /
public Result saverefs ( Date jyrq , String yq , String ybh ) {
LabPat labPat = commonUtil . getLabPatOne ( jyrq , yq , ybh ) ;
public Result saverefs ( Date jyrq , String yq , String ybh ) {
LabPat labPat = commonUtil . getLabPatOne ( jyrq , yq , ybh ) ;
saverefs ( labPat ) ;
return new Result ( " 0 " , " 保存成功! " ) ;
return new Result ( " 0 " , " 保存成功! " ) ;
}
/ * *
* 计算项目参考值结果异常标志 ( 内部使用 )
*
* @param labPat
* @return 返回值0正常 , 1有危急值明细存在
* @return 返回值0正常 , 1有危急值明细存在
* /
private int saverefs ( LabPat labPat ) {
Date jyrq = labPat . getJyrq ( ) ;
String yq = labPat . getYq ( ) ;
String ybh = labPat . getYbh ( ) ;
String yqdl = lisWorkOperMapper . selectYqdl ( yq ) ;
boolean lb_setbj = true , lb_wjz = false ;
if ( ! " 细菌仪 " . equals ( yqdl ) ) {
private int saverefs ( LabPat labPat ) {
Date jyrq = labPat . getJyrq ( ) ;
String yq = labPat . getYq ( ) ;
String ybh = labPat . getYbh ( ) ;
String yqdl = lisWorkOperMapper . selectYqdl ( yq ) ;
boolean lb_setbj = true , lb_wjz = false ;
if ( ! " 细菌仪 " . equals ( yqdl ) ) {
Map < String , Object > map = new HashMap < > ( ) ;
map . put ( " jyrq " , jyrq ) ;
map . put ( " yq " , yq ) ;
@ -376,84 +390,86 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
String retCode = String . valueOf ( map . get ( " retcode " ) ) ;
String retMsg = String . valueOf ( map . get ( " retmsg " ) ) ;
log . info ( " 调用存储过程{}返回值:{},{} " , " sp_setrefs " , retCode , retMsg ) ;
if ( retCode = = null | | " " . equals ( retCode ) | | " -1 " . equals ( retCode ) ) lb_setbj = false ;
List < LabResult > labResultList = commonUtil . getLabResultList ( jyrq , yq , ybh ) ;
if ( retCode = = null | | " " . equals ( retCode ) | | " -1 " . equals ( retCode ) ) lb_setbj = false ;
List < LabResult > labResultList = commonUtil . getLabResultList ( jyrq , yq , ybh ) ;
for ( LabResult labResult : labResultList ) {
String csjg = labResult . getCsjg ( ) ;
boolean lb_nummode = LisUtil . isTureNumber ( csjg ) ;
String csjg = labResult . getCsjg ( ) ;
boolean lb_nummode = LisUtil . isTureNumber ( csjg ) ;
String ygzq = labResult . getYgzq ( ) ;
String ygzd = labResult . getYgzd ( ) ;
/ / 当结果为数值并且与周期诊断无关 , 计算存储过程保存成功后 , 只进行危急值判断
if ( lb_nummode & & lb_setbj & & ! " Y " . equals ( ygzd ) & & ! " Y " . equals ( ygzq ) ) {
int wjz = alarmcondition ( labPat , labResult ) ;
if ( wjz ! = - 1 ) { / / 危急值标识特殊判断存在时优先使用特殊结果
String resultalarmflag = labResult . getAlarmFlag ( ) ;
if ( ( " " . equals ( resultalarmflag ) & & lb_wjz ) ) {
String jgbz = labResult . getJgbz ( ) ;
if ( jgbz = = null | | ! " L " . equals ( jgbz ) ) jgbz = " H " ;
if ( lb_nummode & & lb_setbj & & ! " Y " . equals ( ygzd ) & & ! " Y " . equals ( ygzq ) ) {
int wjz = alarmcondition ( labPat , labResult ) ;
if ( wjz ! = - 1 ) { / / 危急值标识特殊判断存在时优先使用特殊结果
String resultalarmflag = labResult . getAlarmFlag ( ) ;
if ( ( " " . equals ( resultalarmflag ) & & lb_wjz ) ) {
String jgbz = labResult . getJgbz ( ) ;
if ( jgbz = = null | | ! " L " . equals ( jgbz ) ) jgbz = " H " ;
labResult . setAlarmFlag ( jgbz ) ;
commonUtil . updateLabResult ( labResult ) ;
} else if ( ! " " . equals ( resultalarmflag ) & & ! lb_wjz ) {
} else if ( ! " " . equals ( resultalarmflag ) & & ! lb_wjz ) {
labResult . setAlarmFlag ( " " ) ;
commonUtil . updateLabResult ( labResult ) ;
}
}
String resultalarmflag1 = labResult . getAlarmFlag ( ) ;
if ( ! " " . equals ( resultalarmflag1 ) & & resultalarmflag1 ! = null ) lb_wjz = true ;
} else {
int wjz = setrefs ( labPat , labResult ) ;
String resultalarmflag1 = labResult . getAlarmFlag ( ) ;
if ( ! " " . equals ( resultalarmflag1 ) & & resultalarmflag1 ! = null ) lb_wjz = true ;
} else {
int wjz = setrefs ( labPat , labResult ) ;
if ( wjz = = 1 ) lb_wjz = true ;
}
}
/ / 危急值标识去除原则
String brxm = labPat . getBrxm ( ) ;
if ( brxm . contains ( " 质控 " ) | | brxm . contains ( " 复查 " ) | | brxm . contains ( " QC " ) | | brxm . contains ( " qc " ) | | brxm . contains ( " 软化水 " ) | | brxm . contains ( " 锅炉水 " ) ) {
lb_wjz = false ;
} ;
String brly = labPat . getBrly ( ) ;
brly = commonUtil . getComDictNameById ( " PT " , brly ) ;
if ( brly . contains ( " 质控 " ) ) lb_wjz = false ;
String ksdh = labPat . getKsdh ( ) ;
ksdh = commonUtil . getComDictNameById ( " DP " , ksdh ) ;
if ( ksdh . contains ( " 检验科 " ) ) lb_wjz = false ;
String brxm = labPat . getBrxm ( ) ;
if ( brxm . contains ( " 质控 " ) | | brxm . contains ( " 复查 " ) | | brxm . contains ( " QC " ) | | brxm . contains ( " qc " ) | | brxm . contains ( " 软化水 " ) | | brxm . contains ( " 锅炉水 " ) ) {
lb_wjz = false ;
}
;
String brly = labPat . getBrly ( ) ;
brly = commonUtil . getComDictNameById ( " PT " , brly ) ;
if ( brly . contains ( " 质控 " ) ) lb_wjz = false ;
String ksdh = labPat . getKsdh ( ) ;
ksdh = commonUtil . getComDictNameById ( " DP " , ksdh ) ;
if ( ksdh . contains ( " 检验科 " ) ) lb_wjz = false ;
/ / 同步主表危急值标识
String alarmflag = labPat . getAlarmflag ( ) ;
if ( ( " 1 " . equals ( alarmflag ) & & ! lb_wjz ) ) {
String alarmflag = labPat . getAlarmflag ( ) ;
if ( ( " 1 " . equals ( alarmflag ) & & ! lb_wjz ) ) {
labPat . setAlarmflag ( " 1 " ) ;
commonUtil . updateLabPat ( labPat ) ;
} else if ( ( " " . equals ( alarmflag ) | | alarmflag = = null ) & & lb_wjz ) {
} else if ( ( " " . equals ( alarmflag ) | | alarmflag = = null ) & & lb_wjz ) {
labPat . setAlarmflag ( " " ) ;
commonUtil . updateLabPat ( labPat ) ;
}
}
return 0 ;
return 0 ;
}
/ * *
* 明细结果计算参考值异常标志危急值标志并更新
*
* @param labPat
* @param labResult
* @return
* /
private int setrefs ( LabPat labPat , LabResult labResult ) {
String yq = labPat . getYq ( ) ;
String resultflag = " M " , wjzflag = " " ;
int wjz = 0 ;
String xmdh = labResult . getXmdh ( ) ;
String csjg = labResult . getCsjg ( ) ;
private int setrefs ( LabPat labPat , LabResult labResult ) {
String yq = labPat . getYq ( ) ;
String resultflag = " M " , wjzflag = " " ;
int wjz = 0 ;
String xmdh = labResult . getXmdh ( ) ;
String csjg = labResult . getCsjg ( ) ;
if ( csjg = = null | | csjg . trim ( ) . isEmpty ( ) ) return 0 ;
String csjgnew = LisUtil . getOverNumber ( csjg . trim ( ) ) ;
boolean lb_nummode = LisUtil . isNumber ( csjgnew ) ;
String csjgnew = LisUtil . getOverNumber ( csjg . trim ( ) ) ;
boolean lb_nummode = LisUtil . isNumber ( csjgnew ) ;
/ / 当结果为数值时计算上下限
if ( lb_nummode ) {
if ( lb_nummode ) {
XmInfo xmInfo = commonUtil . getXmInfo ( yq , xmdh ) ;
String dw = xmInfo . getDw ( ) ;
String refs = xmInfo . getDyckz ( ) ;
Double ckxx = xmInfo . getCkxx ( ) ;
Double cksx = xmInfo . getCksx ( ) ;
Double llimit = xmInfo . getLlimit ( ) ;
Double hlimit = xmInfo . getHlimit ( ) ;
Double llimit = xmInfo . getLlimit ( ) ;
Double hlimit = xmInfo . getHlimit ( ) ;
String ygxb = xmInfo . getYgxb ( ) ;
String ygnl = xmInfo . getYgnl ( ) ;
String ygbb = xmInfo . getYgbb ( ) ;
@ -498,42 +514,43 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
map . put ( " slzq " , slzq ) ;
xmRef = commonUtil . getXmRefValue ( map ) ;
}
if ( xmRef ! = null ) {
ckxx = xmRef . getCkxx ( ) ;
cksx = xmRef . getCksx ( ) ;
refs = xmRef . getDyck ( ) ;
Double alterxx = xmRef . getAlterxx ( ) ;
Double altersx = xmRef . getAltersx ( ) ;
if ( alterxx ! = null ) llimit = alterxx ;
if ( altersx ! = null ) hlimit = altersx ;
if ( xmRef ! = null ) {
ckxx = xmRef . getCkxx ( ) ;
cksx = xmRef . getCksx ( ) ;
refs = xmRef . getDyck ( ) ;
Double alterxx = xmRef . getAlterxx ( ) ;
Double altersx = xmRef . getAltersx ( ) ;
if ( alterxx ! = null ) llimit = alterxx ;
if ( altersx ! = null ) hlimit = altersx ;
}
if ( lb_nummode ) {
if ( lb_nummode ) {
/ / 数值型结果判断
Double csjgnum = Double . valueOf ( csjgnew ) ;
if ( ckxx ! = null ) if ( csjgnum < ckxx ) resultflag = " L " ;
if ( cksx ! = null ) if ( csjgnum > cksx ) resultflag = " H " ;
int wjzf = alarmcondition ( labPat , labResult ) ;
if ( wjzf = = - 1 ) {
if ( llimit ! = null ) if ( csjgnum < llimit ) wjzflag = " L " ;
if ( hlimit ! = null ) if ( csjgnum > hlimit ) wjzflag = " H " ;
} else if ( wjzf = = 1 ) {
wjzflag = resultflag ;
if ( ckxx ! = null ) if ( csjgnum < ckxx ) resultflag = " L " ;
if ( cksx ! = null ) if ( csjgnum > cksx ) resultflag = " H " ;
int wjzf = alarmcondition ( labPat , labResult ) ;
if ( wjzf = = - 1 ) {
if ( llimit ! = null ) if ( csjgnum < llimit ) wjzflag = " L " ;
if ( hlimit ! = null ) if ( csjgnum > hlimit ) wjzflag = " H " ;
} else if ( wjzf = = 1 ) {
wjzflag = resultflag ;
}
if ( ! " " . equals ( wjzflag ) ) wjz = 1 ;
} else {
if ( ! " " . equals ( wjzflag ) ) wjz = 1 ;
} else {
/ / 文字型结果判断
String jgbzold = labResult . getJgbz ( ) ;
String lmtflag = getitemlmtflag ( yq , xmdh , csjg ) ;
if ( " P " . equals ( jgbzold ) & & ( csjg . indexOf ( " 阳 " ) > = 0 | | csjg . indexOf ( " + " ) > = 0 | | csjg . indexOf ( " : " ) > = 0 ) & & ( lmtflag = = null | | lmtflag . trim ( ) . isEmpty ( ) ) ) lmtflag = " P " ;
resultflag = lmtflag ;
if ( " J " . equals ( lmtflag ) ) wjzflag = " H " ;
String jgbzold = labResult . getJgbz ( ) ;
String lmtflag = getitemlmtflag ( yq , xmdh , csjg ) ;
if ( " P " . equals ( jgbzold ) & & ( csjg . indexOf ( " 阳 " ) > = 0 | | csjg . indexOf ( " + " ) > = 0 | | csjg . indexOf ( " : " ) > = 0 ) & & ( lmtflag = = null | | lmtflag . trim ( ) . isEmpty ( ) ) )
lmtflag = " P " ;
resultflag = lmtflag ;
if ( " J " . equals ( lmtflag ) ) wjzflag = " H " ;
}
int wjzf = alarmcondition ( labPat , labResult ) ;
if ( wjzf = = 1 ) wjzflag = " H " ; / / 满足特定危机值条件
if ( wjzf = = 0 ) wjzflag = " " ; / / 存在特定危机值条件 , 但不满足不提示
int wjzf = alarmcondition ( labPat , labResult ) ;
if ( wjzf = = 1 ) wjzflag = " H " ; / / 满足特定危机值条件
if ( wjzf = = 0 ) wjzflag = " " ; / / 存在特定危机值条件 , 但不满足不提示
/ / 小数保留位数计算
Integer xsws = xmInfo . getXsws ( ) ;
if ( xsws > = 0 ) csjg = LisUtil . round ( csjg , xsws ) ;
Integer xsws = xmInfo . getXsws ( ) ;
if ( xsws > = 0 ) csjg = LisUtil . round ( csjg , xsws ) ;
labResult . setCsjg ( csjg ) ;
labResult . setDw ( dw ) ;
labResult . setRefs ( refs ) ;
@ -543,99 +560,102 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
commonUtil . updateLabResult ( labResult ) ;
}
if ( ! " " . equals ( wjzflag ) ) wjz = 1 ;
if ( ! " " . equals ( wjzflag ) ) wjz = 1 ;
return wjz ;
}
/ * *
* 特定条件危急值判断
* 特定条件危急值判断
*
* @param labPat
* @param labResult
* @return
* /
private int alarmcondition ( LabPat labPat , LabResult labResult ) {
boolean lb_fcb = false , lb_hasval = false ;
String csjg = labResult . getCsjg ( ) ;
private int alarmcondition ( LabPat labPat , LabResult labResult ) {
boolean lb_fcb = false , lb_hasval = false ;
String csjg = labResult . getCsjg ( ) ;
if ( csjg = = null | | csjg . trim ( ) . isEmpty ( ) ) return - 1 ;
String yq = labPat . getYq ( ) ;
String xmdh = labResult . getXmdh ( ) ;
List < XmAlarmdetail > getXmAlarmdetail = commonUtil . getXmAlarmdetail ( yq , xmdh ) ;
if ( getXmAlarmdetail = = null ) return - 1 ;
String brxm = " " ;
String brdh = " " ;
String ksdh = labPat . getKsdh ( ) ;
String ksdh1 = commonUtil . getComDictIdByName ( " BT " , ksdh ) ;
if ( ksdh1 ! = null & & ! ksdh1 . trim ( ) . isEmpty ( ) ) ksdh = ksdh1 ;
String ybzt = labPat . getYbzt ( ) ;
String ybzt1 = commonUtil . getComDictIdByName ( " ST " , ybzt ) ;
if ( ybzt1 ! = null & & ! ybzt1 . trim ( ) . isEmpty ( ) ) ybzt = ybzt1 ;
String zd = labPat . getZd ( ) ;
for ( XmAlarmdetail xmAlarmdetail : getXmAlarmdetail ) {
String samplecondition = xmAlarmdetail . getSamplecondition ( ) ;
lb_fcb = false ;
String yq = labPat . getYq ( ) ;
String xmdh = labResult . getXmdh ( ) ;
List < XmAlarmdetail > getXmAlarmdetail = commonUtil . getXmAlarmdetail ( yq , xmdh ) ;
if ( getXmAlarmdetail = = null ) return - 1 ;
String brxm = " " ;
String brdh = " " ;
String ksdh = labPat . getKsdh ( ) ;
String ksdh1 = commonUtil . getComDictIdByName ( " BT " , ksdh ) ;
if ( ksdh1 ! = null & & ! ksdh1 . trim ( ) . isEmpty ( ) ) ksdh = ksdh1 ;
String ybzt = labPat . getYbzt ( ) ;
String ybzt1 = commonUtil . getComDictIdByName ( " ST " , ybzt ) ;
if ( ybzt1 ! = null & & ! ybzt1 . trim ( ) . isEmpty ( ) ) ybzt = ybzt1 ;
String zd = labPat . getZd ( ) ;
for ( XmAlarmdetail xmAlarmdetail : getXmAlarmdetail ) {
String samplecondition = xmAlarmdetail . getSamplecondition ( ) ;
lb_fcb = false ;
if ( samplecondition . toLowerCase ( ) . contains ( " [初报] " ) ) {
Map < String , Object > map = new HashMap < > ( ) ;
Map < String , Object > map = new HashMap < > ( ) ;
map . put ( " xmdh " , xmdh ) ;
map . put ( " jyrq " , labPat . getJyrq ( ) ) ;
if ( samplecondition . toLowerCase ( ) . contains ( " brxm " ) ) brxm = labPat . getBrxm ( ) ;
if ( samplecondition . toLowerCase ( ) . contains ( " brdh " ) ) brdh = labPat . getBrdh ( ) ;
if ( samplecondition . toLowerCase ( ) . contains ( " brxm " ) ) brxm = labPat . getBrxm ( ) ;
if ( samplecondition . toLowerCase ( ) . contains ( " brdh " ) ) brdh = labPat . getBrdh ( ) ;
map . put ( " brxm " , brxm ) ;
map . put ( " brdh " , brdh ) ;
int limitcount = lisWorkOperMapper . getLimitCount ( map ) ;
if ( limitcount > 0 ) lb_fcb = true ;
int limitcount = lisWorkOperMapper . getLimitCount ( map ) ;
if ( limitcount > 0 ) lb_fcb = true ;
samplecondition = samplecondition . replace ( " 'brxm' " , " 1 " ) ;
samplecondition = samplecondition . replace ( " 'brdh' " , " 1 " ) ;
samplecondition = samplecondition . replace ( " [初报] " , " [CB] " ) ;
}
labPat . setYblx ( commonUtil . getComDictIdByName ( " BT " , labPat . getYblx ( ) ) ) ;
labPat . setKsdh ( commonUtil . getComDictIdByName ( " DP " , labPat . getKsdh ( ) ) ) ;
samplecondition = samplecondition . replace ( " [科室] " , " [DEPT] " ) ;
samplecondition = samplecondition . replace ( " [诊断] " , " [DIAG] " ) ;
samplecondition = samplecondition . replace ( " [样本状态] " , " [YBZT] " ) ;
labPat . setYblx ( commonUtil . getComDictIdByName ( " BT " , labPat . getYblx ( ) ) ) ;
labPat . setKsdh ( commonUtil . getComDictIdByName ( " DP " , labPat . getKsdh ( ) ) ) ;
samplecondition = samplecondition . replace ( " [科室] " , " [DEPT] " ) ;
samplecondition = samplecondition . replace ( " [诊断] " , " [DIAG] " ) ;
samplecondition = samplecondition . replace ( " [样本状态] " , " [YBZT] " ) ;
Map < String , String > variables = new HashMap < > ( ) ;
variables . put ( " ZB " , " 1 " ) ;
variables . put ( " DEPT " , ksdh ) ;
variables . put ( " DIAG " , zd ) ;
variables . put ( " YBZT " , ybzt ) ;
samplecondition = " if(( " + samplecondition + " ) ,1,0) " ;
String result = CalcUtils . getValueFromCalc ( samplecondition , variables ) ;
if ( " 1 " . equals ( result ) ) {
if ( lb_fcb ) return 0 ;
lb_hasval = true ;
samplecondition = " if(( " + samplecondition + " ) ,1,0) " ;
String result = CalcUtils . getValueFromCalc ( samplecondition , variables ) ;
if ( " 1 " . equals ( result ) ) {
if ( lb_fcb ) return 0 ;
lb_hasval = true ;
String resultcondition = xmAlarmdetail . getResultcondition ( ) ;
resultcondition = resultcondition . replace ( " [结果] " , " [RESULT] " ) ;
resultcondition = resultcondition . replace ( " [结果] " , " [RESULT] " ) ;
Map < String , String > variables1 = new HashMap < > ( ) ;
variables1 . put ( " RESULT " , csjg ) ;
resultcondition = " if(( " + resultcondition + " ) ,1,0) " ;
String result1 = CalcUtils . getValueFromCalc ( resultcondition , variables1 ) ;
if ( " 1 " . equals ( result1 ) ) return 1 ;
resultcondition = " if(( " + resultcondition + " ) ,1,0) " ;
String result1 = CalcUtils . getValueFromCalc ( resultcondition , variables1 ) ;
if ( " 1 " . equals ( result1 ) ) return 1 ;
}
}
if ( lb_hasval ) return 0 ;
if ( lb_hasval ) return 0 ;
else return - 1 ;
}
/ * *
* 获取常用取值结果标志
*
* @param yq
* @param xmdh
* @param csjg
* @return
* /
public String getitemlmtflag ( String yq , String xmdh , String csjg ) {
String jgbz = " " ;
public String getitemlmtflag ( String yq , String xmdh , String csjg ) {
String jgbz = " " ;
if ( csjg = = null | | csjg . isEmpty ( ) ) {
return " " ;
}
String csjg1 = " " , csjg2 = " " ;
String csjg1 = " " , csjg2 = " " ;
java . util . regex . Pattern pattern = java . util . regex . Pattern . compile ( " \\ ((.*?) \\ ) " ) ;
java . util . regex . Matcher matcher = pattern . matcher ( csjg ) ;
if ( matcher . find ( ) ) {
csjg1 = matcher . group ( 1 ) ;
csjg1 = matcher . group ( 1 ) ;
}
int index = csjg . indexOf ( " , " ) ;
if ( index = = - 1 ) csjg2 = StringUtils . substring ( csjg , index + 1 ) ;
jgbz = commonUtil . getXmRefJgbz ( yq , xmdh , csjg , csjg1 , csjg2 ) ;
if ( index = = - 1 ) csjg2 = StringUtils . substring ( csjg , index + 1 ) ;
jgbz = commonUtil . getXmRefJgbz ( yq , xmdh , csjg , csjg1 , csjg2 ) ;
if ( jgbz = = null ) {
return " " ;
}