package com.jyxt.getdatabyview; import com.jyxt.getdatabyview.view.repository.IBPSRepository; import com.jyxt.getdatabyview.view.repository.LISViewRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import java.util.*; @Component public class HandleData { private static final Logger log = LoggerFactory.getLogger(GetDataByViewApplication.class); @Autowired private LISViewRepository lisViewRepository; @Autowired private IBPSRepository ibpsRepository; private static final String RESULT_DELIMITER = "\\^"; private static final List qualityIndicatorList = Collections.unmodifiableList( Arrays.asList( "总标本不合格率", // 0 "抗凝标本凝集率", // 1 "标本类型错误率", // 2 "标本容器错误率", // 3 "标本溶血率", // 4 "标本采集量错误率", // 5 "急诊常规实验室内TAT中位数", // 6 "急诊生化免疫实验室内TAT中位数", // 7 "急诊凝血实验室内TAT中位数", // 8 "急诊血常规检验前周转时间中位数", // 9 "急诊血常规实验室内周转时间中位数", // 10 "常规检验报告发放TAT时间符合率", // 11 "检验报告不正确率", // 12 "危急值通报率", // 13 "危急值通报及时率", // 14 "标本合格率", // 15 "TAT时间合格率", // 16 "报告准确率", // 17 "危急值通报符合率" // 18 ) ); public void startHandleData(String pingjiaId,String zhiliangzhibia,String bianzhishijian, String yuanshishuju) { if (qualityIndicatorList.contains(zhiliangzhibia)){ // System.out.println(output); log.info("ID: {}, zhiliangzhibia: {}, bianzhishijian: {}", pingjiaId, zhiliangzhibia, bianzhishijian); int QIIndex = qualityIndicatorList.indexOf(zhiliangzhibia); String DataDetail = ""; String dateRange = DateRangeUtil.getDateRange(bianzhishijian); String[] resultParts = lisViewRepository.query(QIIndex,dateRange).split(RESULT_DELIMITER); // String[] resultParts = new String[] {"", "", ""}; // if (pingjiaId.equals("1367710945618427904")) { // resultParts = new String[] {"100", "10000", "10000"}; // } String resultValue = resultParts[0]; if (resultValue.startsWith(".")) { resultValue = "0" + resultValue; } String IsQualified = null; if ((!Objects.equals(resultValue, ""))){ IsQualified = ValueEvaluator.evaluateValue(resultValue,yuanshishuju); } //总数统计 if (resultParts.length==2){ String total = resultParts[1]; if ((!Objects.equals(resultValue, ""))&&(!Objects.equals(resultValue,null))&&(!Objects.equals(resultValue,"-1"))) { // System.out.println("output:"+ResultValue); log.info("Get LIS RetVal:{},zhiliangzhibiao:{},bianzhishijian:{}",resultParts,zhiliangzhibia,bianzhishijian); if (QIIndex==6){ DataDetail = "同期临检(住院)及临检(门诊)的三大常规(血、尿、便)标本共 "+resultParts[1]+" 例"; } else if (QIIndex==7){ DataDetail = "同期临检急诊组的急诊生化、免疫标本共 "+resultParts[1]+" 例"; } else if (QIIndex==8){ DataDetail = "同期临检(住院)及临检(门诊) 的急诊血凝标本共 "+resultParts[1]+" 例"; } else if ((QIIndex==9)||(QIIndex==10)){ DataDetail = "同期临检(住院)及临检(门诊) 的急诊血常规标本共 "+resultParts[1]+" 例"; } // qualityIndicatorRepository.save(pingjiaId, resultValue,total,DataDetail,IsQualified); //分子不需要整数 //ibpsRepository.save(pingjiaId, resultValue,resultValue,DataDetail,IsQualified); } } else if (resultParts.length==3){ String numerator = resultParts[1]; String denominator = resultParts[2]; if ((!Objects.equals(resultValue, ""))&&(!Objects.equals(resultValue,null))&&(!Objects.equals(resultValue,"-1"))){ log.info("Get LIS RetVal:{},zhiliangzhibiao:{},bianzhishijian:{}",resultParts,zhiliangzhibia,bianzhishijian); if (QIIndex==0){ DataDetail = "不合格标本数 "+resultParts[1]+" 例,同期标本总数 "+resultParts[2]+" 例"; } else if (QIIndex==1){ DataDetail = "凝集的标本数 "+resultParts[1]+" 例,同期需抗凝的标本总数 "+resultParts[2]+" 例"; } else if (QIIndex==2){ DataDetail = "类型错误或不适当的标本数 "+resultParts[1]+" 例,同期标本总数 "+resultParts[2]+" 例"; } else if (QIIndex==3){ DataDetail = "采集容器错误的标本数 "+resultParts[1]+" 例,同期标本总数 "+resultParts[2]+" 例"; } else if (QIIndex==4){ DataDetail = "溶血的标本 "+resultParts[1]+" 例,同期标本总数 "+resultParts[2]+" 例"; } else if (QIIndex==5){ DataDetail = "量不足或过多(抗凝标本)的标本数 "+resultParts[1]+" 例,同期标本总数 "+resultParts[2]+" 例"; } else if (QIIndex==12){ DataDetail = "实验室发出的不正确报告数 "+resultParts[1]+" 例,报告总数 "+resultParts[2]+" 例"; } else if (QIIndex==13){ DataDetail = "已通报危急值数 "+resultParts[1]+" 例,同期需要通报危急值总数 "+resultParts[2]+" 例"; } else if (QIIndex==14){ DataDetail = "危急值通报时间(从结果确认到与临床医生交流的时间)满足规定时间的检验项目数 "+resultParts[1]+" 例,同期需要危急值通报的检验项目总数 "+resultParts[2]+" 例"; } else if (QIIndex==15){ DataDetail = "全年合格标本总数 "+resultParts[1]+" 例,全年标本总数 "+resultParts[2]+" 例"; } else if (QIIndex==17){ DataDetail = "实验室发出的正确报告数 "+resultParts[1]+" 例,同期实验室发出报告总数 "+resultParts[2]+" 例"; } else if (QIIndex==18){ DataDetail = "危急值通报时间(从结果确认到与临床医生交流的时间)满足规定时间的检验项目数 "+resultParts[1]+" 例,同期需要危急值通报的检验项目总数 "+resultParts[2]+" 例"; } //ibpsRepository.save(pingjiaId,resultValue,numerator,denominator,DataDetail,IsQualified); } } else { log.info("no result to save:zhiliangzhibiao:{},bianzhishijian:{}",zhiliangzhibia,bianzhishijian); } } } }