Index: ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/datasync/common/CssdUseRecordServiceV4Impl.java =================================================================== diff -u -r40309 -r40324 --- ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/datasync/common/CssdUseRecordServiceV4Impl.java (.../CssdUseRecordServiceV4Impl.java) (revision 40309) +++ ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/datasync/common/CssdUseRecordServiceV4Impl.java (.../CssdUseRecordServiceV4Impl.java) (revision 40324) @@ -212,10 +212,14 @@ String codeXpath = "/REQUEST/MSG/INSTRUMENT_SET_BARCODE"; // 录入器械包条码及加急等级、丢失报损情况节点路径 String goodsItemsXpath = "/REQUEST/MSG/GOODS_ITEMS/ITEM"; + // 内镜循环实例id,多个id用;分割JMSZXYY-111(器械包条码为空时,才会根据内镜循环实例id录入使用记录) + String endoscopeCycleInstanceIdsXpath = "/REQUEST/MSG/ENDOSCOPECYCLEINSTANCEIDS"; Document document = DocumentHelper.parseText(message); // 器械包条码 String barcode = processDataByXpath(document, null, codeXpath); + // 内镜循环实例idJMSZXYY-111 + String endoscopeCycleInstanceIds = processDataByXpath(document, null, endoscopeCycleInstanceIdsXpath); // 患者住院号 String hospitalNumber = processDataByXpath(document, null, inpatientnoXpath); String treatmentNum = processDataByXpath(document, null, treatmentNumXpath); @@ -258,6 +262,8 @@ // 器械包条码集合 List tousseInsBarcodes = new ArrayList(); + // 内镜循环实例id集合JMSZXYY-111 + List endoscopeCycleInstanceIdList = new ArrayList(); // 加急等级集合 Map tiBarcodeToUrgentLevelMap = new HashMap(); @@ -275,7 +281,7 @@ List nodeList = xpath.selectNodes(document, xpath); // 录入的器械包不能为空 - if(StringUtils.isBlank(barcode) && CollectionUtils.isEmpty(nodeList)){ + if(StringUtils.isBlank(barcode) && CollectionUtils.isEmpty(nodeList) && StringUtils.isBlank(endoscopeCycleInstanceIds)){ throw new RuntimeException("录入的器械包不能为空!"); } @@ -284,11 +290,24 @@ for(int i=1;i<=nodeList.size();i++){ String itemsXpath = "/REQUEST/MSG/GOODS_ITEMS/ITEM[" + i + "]"; String barcodeXpath = itemsXpath + "/INSTRUMENT_SET_BARCODE"; + String endoscopeCycleInstanceIdXpath = itemsXpath + "/ENDOSCOPECYCLEINSTANCEID"; String urgentLevelIdXpath = itemsXpath + "/URGENT_LEVEL_ID"; String errorRemarkXpath = itemsXpath + "/ERROR_DAMAGE_LIST/ERROR_DAMAGE/ERROR_REMARK"; String damageRemarkXpath = itemsXpath + "/ERROR_DAMAGE_LIST/ERROR_DAMAGE/DAMAGE_REMARK"; //String urgentLevelNameXpath = itemsXpath + "/urgentLevelName"; String tiBarcode = processDataByXpath(document, null, barcodeXpath); + if(StringUtils.isBlank(tiBarcode)){ + //内镜循环实例id录入使用记录JMSZXYY-111 + String endoscopeCycleInstanceId = processDataByXpath(document, null, endoscopeCycleInstanceIdXpath); + if(StringUtils.isBlank(endoscopeCycleInstanceId)){ + throw new RuntimeException("录入的器械包不能为空!"); + } + TousseInstance tousseInstance = (TousseInstance) objectDao.getByProperty(TousseInstance.class.getSimpleName(), "endoscopeCycleInstanceId", endoscopeCycleInstanceId); + if(tousseInstance == null){ + throw new RuntimeException("内镜循环实例id" + endoscopeCycleInstanceId + "没有关联的器械包实例!"); + } + tiBarcode = tousseInstance.getBarcode(); + } tousseInsBarcodes.add(tiBarcode); // 加急的 String urgentLevelId = processDataByXpath(document, null, urgentLevelIdXpath); @@ -396,10 +415,14 @@ } } } - }else{ + }else if(StringUtils.isNotBlank(barcode)){ // 器械包不需要加急或者丢失报损情况 String[] barcodes = barcode.split(";"); tousseInsBarcodes = Arrays.asList(barcodes); + }else if(StringUtils.isNotBlank(endoscopeCycleInstanceIds)){ + // 条码不为空时,优先根据条码录入使用记录,条码为空时,再根据内镜循环实例id录入使用记录 + String[] endoscopeCycleInstanceIdArr = endoscopeCycleInstanceIds.split(";"); + endoscopeCycleInstanceIdList = Arrays.asList(endoscopeCycleInstanceIdArr); } List tiList = new ArrayList(); @@ -412,51 +435,58 @@ if (bd instanceof TousseInstance) { // 1、查询器械包实例 TousseInstance tousseInstance = (TousseInstance) bd; - - if(StringUtils.isNotBlank(tousseInstance.getEndoscopeCycleInstanceId()) - && (tousseInstance.isSteriled() || tousseInstance.isDisinfected())){ - //内镜的器械包实例,录入使用记录时,已灭菌、已消毒状态也可以录入使用记录JMSZXYY-111 - tiList.add(tousseInstance); - continue; - } - - if(!StringUtils.equals(TousseInstance.STATUS_SHIPPED, tousseInstance.getStatus()) - && !StringUtils.equals(TousseInstance.STATUS_SIGNED, tousseInstance.getStatus())){ - statusErrorTiList.add(tousseInstance); - continue; - } //判断包实例是否可以登记使用记录 - useRecordManager.canRegisterUseRecord(tousseInstance, departCoding); - tiList.add(tousseInstance); + canRegisterUseRecord(departCoding, tousseInstance, tiList, statusErrorTiList); } else { throw new RuntimeException(code + "不是器械包条码"); } } - //状态异常的包的提示信息 - if(CollectionUtils.isNotEmpty(statusErrorTiList)){ - List tousseNameList = new ArrayList(); - String tempGoodsItems = ""; - for (TousseInstance tousseInstance : statusErrorTiList) { - tousseNameList.add(tousseInstance.getTousseName() + "(" + tousseInstance.getBarcode() + ")"); - //使用记录登记接口中,接口返回的异常信息中,增加包名称、条码、包状态字段;DGSETYY-44 - tempGoodsItems += "" + tousseInstance.getBarcode() + "" - + "" + tousseInstance.getTousseName() + "" - + "" + tousseInstance.getStatus() + ""; + } + + //内镜循环实例id + if(CollectionUtils.isNotEmpty(endoscopeCycleInstanceIdList)){ + List tousseInstanceList = objectDao.getCollection(TousseInstance.class.getSimpleName(), "endoscopeCycleInstanceId", endoscopeCycleInstanceIdList); + if(CollectionUtils.isEmpty(tousseInstanceList)){ + throw new RuntimeException("内镜循环实例id" + StringTools.join(endoscopeCycleInstanceIdList, "、") + "没有关联的器械包实例"); + } + Map endoscopeCycleInstanceIdTousseInstanceMap = new HashMap(); + for (TousseInstance tousseInstance : tousseInstanceList) { + endoscopeCycleInstanceIdTousseInstanceMap.put(tousseInstance.getEndoscopeCycleInstanceId(), tousseInstance); + } + for (String endoscopeCycleInstanceId : endoscopeCycleInstanceIdList) { + TousseInstance tousseInstance = endoscopeCycleInstanceIdTousseInstanceMap.get(endoscopeCycleInstanceId); + if(tousseInstance == null){ + throw new RuntimeException("内镜循环实例id" + endoscopeCycleInstanceId + "没有关联的器械包实例"); } - errorStatusTousse = "使用记录接口传入的不能录入使用记录的包:" + StringTools.join(tousseNameList, "、"); - if(StringUtils.isBlank(remark)){ - remark = errorStatusTousse; - }else{ - remark += ";" + errorStatusTousse; - } - //所有条码的包的状态都是异常的,不能录入使用记录 - if(CollectionUtils.isEmpty(tiList)){ - throw new RuntimeException(errorStatusTousse); - } - goodsItems = "" + tempGoodsItems + ""; + //判断包实例是否可以登记使用记录 + canRegisterUseRecord(departCoding, tousseInstance, tiList, statusErrorTiList); } } + //状态异常的包的提示信息 + if(CollectionUtils.isNotEmpty(statusErrorTiList)){ + List tousseNameList = new ArrayList(); + String tempGoodsItems = ""; + for (TousseInstance tousseInstance : statusErrorTiList) { + tousseNameList.add(tousseInstance.getTousseName() + "(" + tousseInstance.getBarcode() + ")"); + //使用记录登记接口中,接口返回的异常信息中,增加包名称、条码、包状态字段;DGSETYY-44 + tempGoodsItems += "" + tousseInstance.getBarcode() + "" + + "" + tousseInstance.getTousseName() + "" + + "" + tousseInstance.getStatus() + ""; + } + errorStatusTousse = "使用记录接口传入的不能录入使用记录的包:" + StringTools.join(tousseNameList, "、"); + if(StringUtils.isBlank(remark)){ + remark = errorStatusTousse; + }else{ + remark += ";" + errorStatusTousse; + } + //所有条码的包的状态都是异常的,不能录入使用记录 + if(CollectionUtils.isEmpty(tiList)){ + throw new RuntimeException(errorStatusTousse); + } + goodsItems = "" + tempGoodsItems + ""; + } + // 检查器械包是否包含丢失报损的材料 tousseIncludeMaterial(tiList, tiBarcodeToErrorDamageMap); @@ -690,6 +720,31 @@ } /** + * 判断是否允许录入使用记录 + * @param departCoding 申请科室编码 + * @param tousseInstance 器械包实例 + * @param tiList 允许录入使用记录的器械包实例集合 + * @param statusErrorTiList 不允许录入使用记录的器械包实例集合 + */ + private void canRegisterUseRecord(String departCoding, TousseInstance tousseInstance, List tiList, List statusErrorTiList) { + if(StringUtils.isNotBlank(tousseInstance.getEndoscopeCycleInstanceId()) + && (tousseInstance.isSteriled() || tousseInstance.isDisinfected())){ + //内镜的器械包实例,录入使用记录时,已灭菌、已消毒状态也可以录入使用记录JMSZXYY-111 + tiList.add(tousseInstance); + return; + } + + if(!StringUtils.equals(TousseInstance.STATUS_SHIPPED, tousseInstance.getStatus()) + && !StringUtils.equals(TousseInstance.STATUS_SIGNED, tousseInstance.getStatus())){ + statusErrorTiList.add(tousseInstance); + return; + } + //判断包实例是否可以登记使用记录 + useRecordManager.canRegisterUseRecord(tousseInstance, departCoding); + tiList.add(tousseInstance); + } + + /** * 查询器械包实例的仓库map * @param tiList 器械包实例的仓库map * @return