Index: ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/datasync/common/HIPMessageWebServiceV3.java
===================================================================
diff -u
--- ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/datasync/common/HIPMessageWebServiceV3.java (revision 0)
+++ ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/datasync/common/HIPMessageWebServiceV3.java (revision 31577)
@@ -0,0 +1,18 @@
+package com.forgon.disinfectsystem.webservice.datasync.common;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+
+/**
+ * 消毒供应系统消毒包字典及使用记录接口
+ * @author zhoupeimian
+ * @since 2021-06-28
+ */
+@WebService(serviceName="/HIPMessageServiceV3")
+public interface HIPMessageWebServiceV3 {
+
+ @WebMethod(operationName="HIPMessageServerV3")
+ public String HIPMessageServerV3(@WebParam(name="action") String action, @WebParam(name="message") String message);
+
+}
Index: ssts-web/src/main/webapp/disinfectsystem/config/gdszyy/interfaces/fieldsMappingTalbe.json
===================================================================
diff -u
--- ssts-web/src/main/webapp/disinfectsystem/config/gdszyy/interfaces/fieldsMappingTalbe.json (revision 0)
+++ ssts-web/src/main/webapp/disinfectsystem/config/gdszyy/interfaces/fieldsMappingTalbe.json (revision 31577)
@@ -0,0 +1,358 @@
+{
+ "fieldsMappingTalbe":[
+ {
+ "fieldChineseName":"申请记录开始节点",
+ "standardFieldName":"APPLY_RECORDS",
+ "3rdPartyFieldName":"APPLY"
+ },
+ {
+ "fieldChineseName":"器械包申请单号",
+ "standardFieldName":"INSTRUMENT_PACK_APPLI_FORM_NO",
+ "3rdPartyFieldName":"INSTRUMENT_PACK_APPLI_FORM_NO"
+ },
+ {
+ "fieldChineseName":"申请科室编码",
+ "standardFieldName":"APPLY_DEPT_CODE",
+ "3rdPartyFieldName":"APPLY_DEPT_CODE"
+ },
+ {
+ "fieldChineseName":"申请科室名称",
+ "standardFieldName":"APPLY_DEPT_NAME",
+ "3rdPartyFieldName":"APPLY_DEPT_NAME"
+ },
+ {
+ "fieldChineseName":"申请人工号",
+ "standardFieldName":"APPLY_OPERATOR_CODE",
+ "3rdPartyFieldName":"APPLY_OPERATOR_CODE"
+ },
+ {
+ "fieldChineseName":"申请人姓名",
+ "standardFieldName":"APPLY_OPERATOR_NAME",
+ "3rdPartyFieldName":"APPLY_OPERATOR_NAME"
+ },
+ {
+ "fieldChineseName":"申请时间",
+ "standardFieldName":"APPLY_DATETIME",
+ "3rdPartyFieldName":"APPLY_DATETIME"
+ },
+ {
+ "fieldChineseName":"申请单类型代码",
+ "standardFieldName":"APPLY_TYPE_CODE",
+ "3rdPartyFieldName":"APPLY_TYPE_CODE"
+ },
+ {
+ "fieldChineseName":"申请单类型名称",
+ "standardFieldName":"APPLY_TYPE_CODE",
+ "3rdPartyFieldName":"APPLY_TYPE_CODE"
+ },{
+ "fieldChineseName":"回收记录开始节点",
+ "standardFieldName":"RECYCLE_RECORDS",
+ "3rdPartyFieldName":"RECOVER"
+ },
+ {
+ "fieldChineseName":"清点人工号",
+ "standardFieldName":"CHECK_OPERATOR_CODE",
+ "3rdPartyFieldName":"CHECK_OPERATOR_CODE"
+ },
+ {
+ "fieldChineseName":"清点人姓名",
+ "standardFieldName":"CHECK_OPERATOR_NAME",
+ "3rdPartyFieldName":"CHECK_OPERATOR_NAME"
+ },
+ {
+ "fieldChineseName":"回收人工号",
+ "standardFieldName":"RECYCLE_OPERATOR_CODE",
+ "3rdPartyFieldName":"RECOVERY_OPERATOR_CODE"
+ },
+ {
+ "fieldChineseName":"回收人姓名",
+ "standardFieldName":"RECYCLE_OPERATOR_NAME",
+ "3rdPartyFieldName":"RECOVERY_OPERATOR_NAME"
+ },
+ {
+ "fieldChineseName":"回收时间",
+ "standardFieldName":"RECYCLE_DATETIME",
+ "3rdPartyFieldName":"RECOVERY_DATETIME"
+ },
+ {
+ "fieldChineseName":"清洗记录开始节点",
+ "standardFieldName":"WASH_RECORDS",
+ "3rdPartyFieldName":"WASH_RECORD"
+ },
+ {
+ "fieldChineseName":"清洗机编号",
+ "standardFieldName":"WASH_MACHINE_CODE",
+ "3rdPartyFieldName":"WASH_MACHINE_CODE"
+ },
+ {
+ "fieldChineseName":"清洗机名称",
+ "standardFieldName":"WASH_MACHINE_NAME",
+ "3rdPartyFieldName":"WASH_MACHINE_NAME"
+ },
+ {
+ "fieldChineseName":"清洗程序名称",
+ "standardFieldName":"WASH_PROCEDURE_NAME",
+ "3rdPartyFieldName":"WASH_PROCEDURE_NAME"
+ },
+ {
+ "fieldChineseName":"清洗操作员工号",
+ "standardFieldName":"WASH_OPERATOR_CODE",
+ "3rdPartyFieldName":"WASH_OPERATOR_CODE"
+ },
+ {
+ "fieldChineseName":"清洗操作员姓名",
+ "standardFieldName":"WASH_OPERATOR_NAME",
+ "3rdPartyFieldName":"WASH_OPERATOR_NAME"
+ },
+ {
+ "fieldChineseName":"清洗开始时间",
+ "standardFieldName":"WASH_BEGIN_DATETIME",
+ "3rdPartyFieldName":"WASH_BEGIN_DATETIME"
+ },
+ {
+ "fieldChineseName":"清洗结束时间",
+ "standardFieldName":"WASH_END_DATETIME",
+ "3rdPartyFieldName":"WASH_END_DATETIME"
+ },
+ {
+ "fieldChineseName":"装配记录节点",
+ "standardFieldName":"ASSEMBLE_RECORDS",
+ "3rdPartyFieldName":"ASSEMBLE"
+ },
+ {
+ "fieldChineseName":"器械包条码",
+ "standardFieldName":"INSTRUMENT_SET_BARCODE",
+ "3rdPartyFieldName":"INSTRUMENT_PACK_BARCODE"
+ },
+ {
+ "fieldChineseName":"器械包名称",
+ "standardFieldName":"INSTRUMENT_SET_NAME",
+ "3rdPartyFieldName":"INSTRUMENT_PACK_NAME"
+ },
+ {
+ "fieldChineseName":"配包人工号",
+ "standardFieldName":"DELIVER_PACK_OPERATOR_CODE",
+ "3rdPartyFieldName":"DELIVER_PACK_OPERATOR_CODE"
+ },
+ {
+ "fieldChineseName":"配包人姓名",
+ "standardFieldName":"DELIVER_PACK_OPERATOR_NAME",
+ "3rdPartyFieldName":"DELIVER_PACK_OPERATOR_NAME"
+ },
+ {
+ "fieldChineseName":"装配审核人工号",
+ "standardFieldName":"ASSEMBLE_PROOF_OPERATOR_CODE",
+ "3rdPartyFieldName":"ASSEMBLE_PROOF_OPERATOR_CODE"
+ },
+ {
+ "fieldChineseName":"装配审核人姓名",
+ "standardFieldName":"ASSEMBLE_PROOF_OPERATOR_NAME",
+ "3rdPartyFieldName":"ASSEMBLE_PROOF_OPERATOR_NAME"
+ },
+ {
+ "fieldChineseName":"装配时间",
+ "standardFieldName":"ASSEMBLE_DATETIME",
+ "3rdPartyFieldName":"ASSEMBLE_DATETIME"
+ },
+ {
+ "fieldChineseName":"审核时间",
+ "standardFieldName":"PROOF_DATETIME",
+ "3rdPartyFieldName":"PROOF_DATETIME"
+ },
+ {
+ "fieldChineseName":"包装类型代码",
+ "standardFieldName":"PACK_TYPE_CODE",
+ "3rdPartyFieldName":"PACK_TYPE_CODE"
+ },
+ {
+ "fieldChineseName":"包装类型名称",
+ "standardFieldName":"PACK_TYPE_NAME",
+ "3rdPartyFieldName":"PACK_TYPE_NAME"
+ },
+ {
+ "fieldChineseName":"灭菌记录节点",
+ "standardFieldName":"STERILIZATION_RECORDS",
+ "3rdPartyFieldName":"STERILIZATION"
+ },
+ {
+ "fieldChineseName":"灭菌员工号",
+ "standardFieldName":"STERILIZATION_OPERATOR_CODE",
+ "3rdPartyFieldName":"STERILIZATION_OPERATOR_CODE"
+ },
+ {
+ "fieldChineseName":"灭菌员姓名",
+ "standardFieldName":"STERILIZATION_OPERATOR_NAME",
+ "3rdPartyFieldName":"STERILIZATION_OPERATOR_NAME"
+ },
+ {
+ "fieldChineseName":"灭菌炉名称",
+ "standardFieldName":"STERILIZATION_FURNACE_NAME",
+ "3rdPartyFieldName":"STERILIZATION_FURNACE_NAME"
+ },
+ {
+ "fieldChineseName":"灭菌程序编码",
+ "standardFieldName":"STERILIZATION_PROGRAM_CODE",
+ "3rdPartyFieldName":"STERILIZATION_PROCEDURE_CODE"
+ },
+ {
+ "fieldChineseName":"灭菌程序名称",
+ "standardFieldName":"STERILIZATION_PROGRAM_NAME",
+ "3rdPartyFieldName":"STERILIZATION_PROCEDURE_NAME"
+ },
+ {
+ "fieldChineseName":"灭菌炉次",
+ "standardFieldName":"STERILIZATION_CYCLE_NUM",
+ "3rdPartyFieldName":"STERILIZATION_FURNACE_NUM"
+ },
+ {
+ "fieldChineseName":"灭菌开始时间",
+ "standardFieldName":"STERILIZATION_BEGIN_DATETIME",
+ "3rdPartyFieldName":"STERILIZATION_BEGIN_DATETIME"
+ },
+ {
+ "fieldChineseName":"灭菌结束时间",
+ "standardFieldName":"STERILIZATION_END_DATETIME",
+ "3rdPartyFieldName":"STERILIZATION_END_DATETIME"
+ },
+ {
+ "fieldChineseName":"化学监测结果",
+ "standardFieldName":"CHEMISTRY_MONITOR_RESULT",
+ "3rdPartyFieldName":"CHEMISTRY_MONITOR_RESULT"
+ },
+ {
+ "fieldChineseName":"生物监测开始时间",
+ "standardFieldName":"BIO_MONITOR_BEGIN_DATETIME",
+ "3rdPartyFieldName":"BIO_MONITOR_BEGIN_DATETIME"
+ },
+ {
+ "fieldChineseName":"生物监测结束时间",
+ "standardFieldName":"BIO_MONITOR_END_DATETIME",
+ "3rdPartyFieldName":"BIO_MONITOR_END_DATETIME"
+ },
+ {
+ "fieldChineseName":"生物监测结果",
+ "standardFieldName":"BIOLOGICAL_MONITOR_RESULT",
+ "3rdPartyFieldName":"BIOLOGICAL_MONITOR_RESULT"
+ },
+ {
+ "fieldChineseName":"器械包失效日期",
+ "standardFieldName":"INSTRUMENT_SET_EXPIRATION_DATETIME",
+ "3rdPartyFieldName":"INSTRUMENT_PACK_EXPIRATION_DATETIME"
+ },
+ {
+ "fieldChineseName":"发货记录节点",
+ "standardFieldName":"DELIVERY_RECORDS",
+ "3rdPartyFieldName":"DELIVERY"
+ },
+ {
+ "fieldChineseName":"发货员工号",
+ "standardFieldName":"DELIVERY_OPERATOR_CODE",
+ "3rdPartyFieldName":"DELIVERY_OPERATOR_CODE"
+ },
+ {
+ "fieldChineseName":"发货员姓名",
+ "standardFieldName":"DELIVERY_OPERATOR_NAME",
+ "3rdPartyFieldName":"DELIVERY_OPERATOR_NAME"
+ },
+ {
+ "fieldChineseName":"发货科室编码",
+ "standardFieldName":"DELIVERY_DEPT_CODE",
+ "3rdPartyFieldName":"DELIVERY_DEPT_CODE"
+ },
+ {
+ "fieldChineseName":"发货科室名称",
+ "standardFieldName":"DELIVERY_DEPT_NAME",
+ "3rdPartyFieldName":"DELIVERY_DEPT_NAME"
+ },
+ {
+ "fieldChineseName":"发货时间",
+ "standardFieldName":"DELIVERY_DATETIME",
+ "3rdPartyFieldName":"DELIVERY_DATETIME"
+ },
+ {
+ "fieldChineseName":"签收记录节点",
+ "standardFieldName":"SIGN_RECORDS",
+ "3rdPartyFieldName":"SIGN"
+ },
+ {
+ "fieldChineseName":"签收时间",
+ "standardFieldName":"SIGN_DATETIME",
+ "3rdPartyFieldName":"SIGN_DATETIME"
+ },
+ {
+ "fieldChineseName":"使用记录节点",
+ "standardFieldName":"USE_RECORDS",
+ "3rdPartyFieldName":"USERECORD"
+ },
+ {
+ "fieldChineseName":"住院号",
+ "standardFieldName":"INHOSP_INDEX_NO",
+ "3rdPartyFieldName":"INHOSP_INDEX_NO"
+ },
+ {
+ "fieldChineseName":"诊疗号",
+ "standardFieldName":"OUTHOSP_INDEX_NO",
+ "3rdPartyFieldName":"INHOSP_NO"
+ },
+ {
+ "fieldChineseName":"手术申请单ID",
+ "standardFieldName":"SURGERY_APPLI_FORM_NO",
+ "3rdPartyFieldName":"SURGERY_APPLI_FORM_NO"
+ },
+ {
+ "fieldChineseName":"器械包录入使用日期",
+ "standardFieldName":"USE_DATETIME",
+ "3rdPartyFieldName":"USE_DATETIME"
+ },
+ {
+ "fieldChineseName":"使用记录操作员工号",
+ "standardFieldName":"REG_OPERATOR_CODE",
+ "3rdPartyFieldName":"RECORD_OPERATOR_CODE"
+ },
+ {
+ "fieldChineseName":"使用记录操作员姓名",
+ "standardFieldName":"REG_OPERATOR_NAME",
+ "3rdPartyFieldName":"RECORD_OPERATOR_NAME"
+ },
+ {
+ "fieldChineseName":"使用记录录入科室编码",
+ "standardFieldName":"USE_DEPT_CODE",
+ "3rdPartyFieldName":"USE_DEPT_CODE"
+ },
+ {
+ "fieldChineseName":"使用记录录入科室名称",
+ "standardFieldName":"USE_DEPT_NAME",
+ "3rdPartyFieldName":"USE_DEPT_NAME"
+ },
+ {
+ "fieldChineseName":"质量监测记录节点",
+ "standardFieldName":"QUALITY_RECORDS",
+ "3rdPartyFieldName":"QUALITY"
+ },
+ {
+ "fieldChineseName":"质量登记人工号",
+ "standardFieldName":"QUALITY_REG_OPERATOR_CODE",
+ "3rdPartyFieldName":"QUALITY_REG_OPERATOR_CODE"
+ },
+ {
+ "fieldChineseName":"质量登记人姓名",
+ "standardFieldName":"QUALITY_REG_OPERATOR_NAME",
+ "3rdPartyFieldName":"QUALITY_REG_OPERATOR_NAME"
+ },
+ {
+ "fieldChineseName":"质量登记时间",
+ "standardFieldName":"QUALITY_REG_DATETIME",
+ "3rdPartyFieldName":"QUALITY_REG_DATETIME"
+ },
+ {
+ "fieldChineseName":"质量监测项编码",
+ "standardFieldName":"QUALITY_MONITOR_ITEM_CODE",
+ "3rdPartyFieldName":"QUALITY_MONITOR_ITEM_CODE"
+ },
+ {
+ "fieldChineseName":"质量监测项名称",
+ "standardFieldName":"QUALITY_MONITOR_ITEM_NAME",
+ "3rdPartyFieldName":"QUALITY_MONITOR_ITEM_NAME"
+ }
+ ]
+}
\ No newline at end of file
Index: ssts-web/src/main/webapp/disinfectsystem/config/gdszyy/spring/webservice-cxf.xml
===================================================================
diff -u -r30231 -r31577
--- ssts-web/src/main/webapp/disinfectsystem/config/gdszyy/spring/webservice-cxf.xml (.../webservice-cxf.xml) (revision 30231)
+++ ssts-web/src/main/webapp/disinfectsystem/config/gdszyy/spring/webservice-cxf.xml (.../webservice-cxf.xml) (revision 31577)
@@ -25,5 +25,20 @@
address="/foreignTousseWebServiceEx"
implementor="#foreignTousseWebServiceEx" />
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/datasync/common/HIPMessageWebServiceImplV3.java
===================================================================
diff -u
--- ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/datasync/common/HIPMessageWebServiceImplV3.java (revision 0)
+++ ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/datasync/common/HIPMessageWebServiceImplV3.java (revision 31577)
@@ -0,0 +1,1445 @@
+package com.forgon.disinfectsystem.webservice.datasync.common;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.Predicate;
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Node;
+import org.dom4j.XPath;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.forgon.directory.model.BarcodeDevice;
+import com.forgon.directory.model.OrgUnit;
+import com.forgon.directory.model.OrgUserRelation;
+import com.forgon.directory.service.OrgUnitManager;
+import com.forgon.disinfectsystem.barcode.service.BarcodeManager;
+import com.forgon.disinfectsystem.basedatamanager.supplyroomconfig.service.SupplyRoomConfigManager;
+import com.forgon.disinfectsystem.basedatamanager.warehouse.service.WareHouseManager;
+import com.forgon.disinfectsystem.datasynchronization.dao.FindPatientInfoByHospitalNumDao;
+import com.forgon.disinfectsystem.datasynchronization.dao.FindPatientInfoByTreatmentNumDao;
+import com.forgon.disinfectsystem.datasynchronization.model.PatientInfoVO;
+import com.forgon.disinfectsystem.datasynchronization.service.DataSynchronizationManager;
+import com.forgon.disinfectsystem.entity.assestmanagement.DiposableGoodsInstance;
+import com.forgon.disinfectsystem.entity.assestmanagement.DisposableGoods;
+import com.forgon.disinfectsystem.entity.basedatamanager.materialdefinition.MaterialDefinition;
+import com.forgon.disinfectsystem.entity.basedatamanager.materialinstance.MaterialInstance;
+import com.forgon.disinfectsystem.entity.basedatamanager.signRecord.SignRecord;
+import com.forgon.disinfectsystem.entity.basedatamanager.sterilisation.Sterilisation;
+import com.forgon.disinfectsystem.entity.basedatamanager.sterilizer.Sterilizer;
+import com.forgon.disinfectsystem.entity.basedatamanager.supplyroomconfig.SupplyRoomConfig;
+import com.forgon.disinfectsystem.entity.basedatamanager.toussedefinition.TousseDefinition;
+import com.forgon.disinfectsystem.entity.basedatamanager.toussedefinition.TousseInstance;
+import com.forgon.disinfectsystem.entity.basedatamanager.warehouse.WareHouse;
+import com.forgon.disinfectsystem.entity.becleanitem.ClassifyBasket;
+import com.forgon.disinfectsystem.entity.customform.formdefinition.FormDefinition;
+import com.forgon.disinfectsystem.entity.invoicemanager.Invoice;
+import com.forgon.disinfectsystem.entity.invoicemanager.InvoicePlan;
+import com.forgon.disinfectsystem.entity.materialerrordamage.MaterialErrorDamageDetail;
+import com.forgon.disinfectsystem.entity.qualitymonitoringmanager.qualitymonitoring.QualityMonitoringInstance;
+import com.forgon.disinfectsystem.entity.recyclingrecord.RecyclingItem;
+import com.forgon.disinfectsystem.entity.recyclingrecord.RecyclingRecord;
+import com.forgon.disinfectsystem.entity.sterilizationmanager.sterilizationrecord.SterilizationRecord;
+import com.forgon.disinfectsystem.entity.urgent.UrgentLevel;
+import com.forgon.disinfectsystem.entity.useRecord.UseRecord;
+import com.forgon.disinfectsystem.entity.washanddisinfectmanager.washanddisinfectrecord.WashAndDisinfectRecord;
+import com.forgon.disinfectsystem.operationreservation.service.OperationReservationManager;
+import com.forgon.disinfectsystem.tousse.toussedefinition.service.TousseInstanceManager;
+import com.forgon.disinfectsystem.useRecord.service.UseRecordManager;
+import com.forgon.security.model.User;
+import com.forgon.tools.date.DateTools;
+import com.forgon.tools.db.DatabaseUtil;
+import com.forgon.tools.hibernate.ObjectDao;
+import com.forgon.tools.util.ConfigUtils;
+import com.forgon.tools.util.ForgonDateUtils;
+import com.forgon.tools.util.SqlUtils;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+
+public class HIPMessageWebServiceImplV3 implements HIPMessageWebServiceV3 {
+
+ private static Logger logger = Logger.getLogger(HIPMessageWebServiceImplV3.class);
+
+ @Autowired
+ private DataSynchronizationManager dataSynchronizationManager;
+ @Autowired
+ private OperationReservationManager operationReservationManager;
+ @Autowired
+ private TousseInstanceManager tousseInstanceManager;
+ @Autowired
+ private BarcodeManager barcodeManager;
+ @Autowired
+ private ObjectDao objectDao;
+ @Autowired
+ private UseRecordManager useRecordManager;
+ @Autowired
+ private WareHouseManager wareHouseManager;
+ @Autowired(required=false)
+ private FindPatientInfoByHospitalNumDao findPatientInfoByHospitalNumDao;
+ @Autowired(required=false)
+ private FindPatientInfoByTreatmentNumDao findPatientInfoByTreatmentNumDao;
+ @Autowired
+ private SupplyRoomConfigManager supplyRoomConfigManager;
+ @Autowired
+ private OrgUnitManager orgUnitManager;
+
+ /**
+ * 同步配置(取自各项目的参数名称配置文件fieldsMappingTalbe.json)
+ */
+ private JsonObject config;
+
+ public JsonObject getConfig() {
+ return config;
+ }
+
+ public void setConfig(JsonObject config) {
+ this.config = config;
+ }
+
+ /**
+ * 器械包使用登记(消毒物料使用登记)
+ * @param action
+ * @param message
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ public String applyRegister(String action, String message) {
+ logger.info("TOUSSE_USERECORD_REGISTRATION ---> action : " + action + "; message : " + message);
+ // typeCode 为处理结果, 0 表示成功 1 表示失败
+ String typeCode = "1";
+ // 处理结果说明
+ String returnStr = "患者消毒物料使用登记失败";
+ try {
+
+ // 登记人姓名
+ String excutorXpath = "/REQUEST/MSG/REG_OPERATOR_NAME";
+ // 录入日期
+ String excutimeXpath = "/REQUEST/MSG/REG_DATETIME";
+ // 登记科室编码
+ String excutdeptnoXpath = "/REQUEST/MSG/REG_DEPT_CODE";
+ // 住院号
+ String inpatientnoXpath = "/REQUEST/MSG/INHOSP_INDEX_NO";
+ // 诊疗号
+ String treatmentNumXpath = "/REQUEST/MSG/OUTHOSP_INDEX_NO";
+ // 病人名称
+ String patientNameXpath = "/REQUEST/MSG/PATIENT_NAME";
+ // 病人年龄
+ String patientAgeXpath = "/REQUEST/MSG/PATIENT_AGE";
+ // 性别
+ String patientSexXpath = "/REQUEST/MSG/PATIENT_SEX";
+ // 身份证
+ String patientIDCardXpath = "/REQUEST/MSG/PATIENT_IDCARD";
+ // 手术单号
+ String operationScheduleIdXpath = "/REQUEST/MSG/SURGERY_APPLI_FORM_NO";
+ // 手术名称
+ String operationXpath = "/REQUEST/MSG/SURGERY_NAME";
+ // 手术时间
+ String operationTimeXpath = "/REQUEST/MSG/SURGERY_DATETIME";
+ // 医生姓名
+ String doctorNameXpath = "/REQUEST/MSG/SURGERY_DOCTOR_NAME";
+ // 洗手护士
+ String washHandNurseXpath = "/REQUEST/MSG/WASH_HAND_NURSE_NAME";
+ // 巡回护士
+ String circuitNurseXpath = "/REQUEST/MSG/CIRCUIT_NURSE_NAME";
+ // 手术间
+ String operationRoomXpath = "/REQUEST/MSG/OPERATION_ROOM";
+ // 病区
+ String patientAreaXpath = "/REQUEST/MSG/PATIENT_AREA";
+ // 病人所属科室名称
+ String ascriptionDepartmentXpath = "/REQUEST/MSG/ASCRIPTION_DEPART_NAME";
+ // 病房
+ String roomNumberXpath = "/REQUEST/MSG/ROOM_NUM";
+ // 床位
+ String bedNumberXpath = "/REQUEST/MSG/BED_NUM";
+ // 住院次数
+ String visitIdXpath = "/REQUEST/MSG/VISIT_NUM";
+ // 特殊感染类型
+ String specialInfectionXpath = "/REQUEST/MSG/SPECIAL_INFECTION";
+ // 备注
+ String remarkXpath = "/REQUEST/MSG/REMARK";
+
+ // 录入器械包条码集合,多个条码用;分割
+ String codeXpath = "/REQUEST/MSG/INSTRUMENT_SET_BARCODE";
+ // 录入器械包条码及加急等级、丢失报损情况节点路径
+ String goodsItemsXpath = "/REQUEST/MSG/GOODS_ITEMS/ITEM";
+
+ Document document = DocumentHelper.parseText(message);
+ // 器械包条码
+ String barcode = processDataByXpath(document, null, codeXpath);
+ // 患者住院号
+ String hospitalNumber = processDataByXpath(document, null, inpatientnoXpath);
+ String treatmentNum = processDataByXpath(document, null, treatmentNumXpath);
+ String operator = processDataByXpath(document, null, excutorXpath);
+ String operationTime = processDataByXpath(document, null, excutimeXpath);
+ Date operTime = DateTools.coverStrToDate(operationTime, "yyyyMMddHHmmss");
+ String departCoding = processDataByXpath(document, null, excutdeptnoXpath);
+ String specialInfection = processDataByXpath(document, null, specialInfectionXpath);
+ String remark = processDataByXpath(document, null, remarkXpath);
+ // 手术时间
+ String operationTimeStr = processDataByXpath(document, null, operationTimeXpath);
+
+ // 住院号和诊疗号不能都为空
+ if(StringUtils.isBlank(hospitalNumber) && StringUtils.isBlank(treatmentNum)){
+ throw new RuntimeException(" 住院号和诊疗号不能都为空!");
+ }
+ // 录入使用记录的科室编码不能都为空
+ if (StringUtils.isBlank(departCoding)) {
+ throw new RuntimeException("录入使用记录的科室编码不能为空!");
+ }
+ // 执行科室(登记使用记录的科室)
+ List orgUnitList = objectDao.findByProperty(OrgUnit.class.getSimpleName(), "orgUnitCoding", departCoding);
+ if(orgUnitList == null || CollectionUtils.isEmpty(orgUnitList)){
+ throw new RuntimeException("执行科室不存在!");
+ }
+ String depart = orgUnitList.get(0).getName();
+ OrgUnit operateDepart = orgUnitList.get(0);
+ // 结算科室
+ SupplyRoomConfig settleSupplyRoomConfig = supplyRoomConfigManager.getApplyDepartDefaultSettleDepart(operateDepart.getOrgUnitCoding());
+ if(settleSupplyRoomConfig == null){
+ settleSupplyRoomConfig = supplyRoomConfigManager.getSupplyRoomConfigByOrgUnitCodingAndType(operateDepart.getOrgUnitCoding(), SupplyRoomConfig.SUPPLYROOM_TYPE_SETTLEACCOUNT);
+ }
+ if(settleSupplyRoomConfig == null){
+ settleSupplyRoomConfig = supplyRoomConfigManager.getSupplyRoomConfigByOrgUnitCodingAndType(operateDepart.getOrgUnitCoding(), SupplyRoomConfig.SUPPLYROOM_TYPE_APPLY);
+ }
+
+
+ // 器械包条码集合
+ List tousseInsBarcodes = new ArrayList();
+
+ // 加急等级集合
+ Map tiBarcodeToUrgentLevelMap = new HashMap();
+ Map tiBarcodeToUrgentLevelIdMap = new HashMap();
+
+ // 丢失报损集合
+ Map> tiBarcodeToErrorDamageMap = new HashMap>();
+ // 丢失备注Map
+ Map errorRemarkMap = new HashMap();
+ // 报损备注Map
+ Map damageRemarkMap = new HashMap();
+
+
+ XPath xpath = document.createXPath(goodsItemsXpath);
+ List nodeList = xpath.selectNodes(document, xpath);
+
+ // 录入的器械包不能为空
+ if(StringUtils.isBlank(barcode) && CollectionUtils.isEmpty(nodeList)){
+ throw new RuntimeException("录入的器械包不能为空!");
+ }
+
+ if(CollectionUtils.isNotEmpty(nodeList)){
+ // 器械包需要加急或者丢失报损情况
+ for(int i=1;i<=nodeList.size();i++){
+ String itemsXpath = "/REQUEST/MSG/GOODS_ITEMS/ITEM[" + i + "]";
+ String barcodeXpath = itemsXpath + "/INSTRUMENT_SET_BARCODE";
+ 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);
+ tousseInsBarcodes.add(tiBarcode);
+ // 加急的
+ String urgentLevelId = processDataByXpath(document, null, urgentLevelIdXpath);
+ if(DatabaseUtil.isPoIdValid(urgentLevelId)){
+ //String urgentLevelName = processDataByXpath(document, null, urgentLevelNameXpath);
+ tiBarcodeToUrgentLevelIdMap.put(tiBarcode, Long.parseLong(urgentLevelId));
+ }
+ // 丢失报损的
+ String errorDamageXpath = itemsXpath + "/ERROR_DAMAGE_LIST/ERROR_DAMAGE";
+ XPath xpath1 = document.createXPath(errorDamageXpath);
+ List nodeList1 = xpath1.selectNodes(document, xpath1);
+ if(CollectionUtils.isNotEmpty(nodeList1)){
+ String errorRemark = processDataByXpath(document, null, errorRemarkXpath);
+ String damageRemark = processDataByXpath(document, null, damageRemarkXpath);
+ // 器械包实例记丢失备注和报损备注
+ errorRemarkMap.put(tiBarcode, errorRemark);
+ damageRemarkMap.put(tiBarcode, damageRemark);
+ List materialErrorDamageList = new ArrayList();
+ for(int j=1;j<=nodeList1.size();j++){
+ String errorDamageItemXpath = itemsXpath + "/ERROR_DAMAGE_LIST/ERROR_DAMAGE[" + j + "]";
+ String errorDamageTypeXpath = errorDamageItemXpath + "/ERROR_DAMAGE_TYPE";
+ String materialDefinitionIdXpath = errorDamageItemXpath + "/MATERIAL_DEFINITION_ID";
+ String materialDefinitionNameXpath = errorDamageItemXpath + "/MATERIAL_DEFINITION_NAME";
+ String materialDefinitionSpecificationXpath = errorDamageItemXpath + "/MATERIAL_DEFINITION_SPEC";
+ String amountXpath = errorDamageItemXpath + "/AMOUNT";
+
+ String type = processDataByXpath(document, null, errorDamageTypeXpath);
+ String errorAmountStr = processDataByXpath(document, null, amountXpath);
+ if(!DatabaseUtil.isPoIdValid(errorAmountStr)){
+ throw new RuntimeException("丢失报损数量无效!" + errorAmountStr);
+ }
+ Integer errorAmount = Integer.parseInt(errorAmountStr);
+ if(errorAmount.intValue() <= 0){
+ throw new RuntimeException("丢失报损数量无效!" + errorAmountStr);
+ }
+ Long materialDefinitionId = null;
+ String materialDefinitionIdStr = processDataByXpath(document, null, materialDefinitionIdXpath);
+ String materialDefinitionName = processDataByXpath(document, null, materialDefinitionNameXpath);
+ String materialDefinitionSpecification = processDataByXpath(document, null, materialDefinitionSpecificationXpath);
+ MaterialDefinition materialDefinition = null;
+ if(DatabaseUtil.isPoIdValid(materialDefinitionIdStr.trim())){
+ materialDefinitionId = Long.parseLong(materialDefinitionIdStr);
+ materialDefinition = (MaterialDefinition) objectDao.getById(MaterialDefinition.class.getSimpleName(), materialDefinitionId);
+ }
+ // 根据id查找不到材料定义
+ if(materialDefinition == null){
+ String mdHql = String.format("select po from %s po where po.name = '%s' and po.specification = '%s'",
+ MaterialDefinition.class.getSimpleName(), materialDefinitionName, materialDefinitionSpecification);
+ if(StringUtils.isBlank(materialDefinitionSpecification)){
+ // 材料规格可能为null或者空字符串
+ mdHql = String.format("select po from %s po where po.name = '%s' and (po.specification = '' or po.specification is null)",
+ MaterialDefinition.class.getSimpleName(), materialDefinitionName);
+ }
+ List mdList = objectDao.findByHql(mdHql);
+ if(CollectionUtils.isEmpty(mdList)){
+ throw new RuntimeException("找不到" + materialDefinitionName + "[" + materialDefinitionSpecification + "]的材料!");
+ }else{
+ materialDefinition = mdList.get(0);
+ }
+ }
+
+ MaterialErrorDamageDetail detail = new MaterialErrorDamageDetail();
+ detail.setMaterialDefinitionId(materialDefinition.getId());
+ if(StringUtils.equals(type, "丢失")){
+ detail.setType(MaterialErrorDamageDetail.TYPE_ERROR);
+ }else if(StringUtils.equals(type, "报损")){
+ detail.setType(MaterialErrorDamageDetail.TYPE_DAMAGE);
+ }else{
+ throw new RuntimeException("丢失报损类型,可选值为丢失或报损!");
+ }
+ detail.setIsUnionToussInstance(true);
+ detail.setLinkType(MaterialErrorDamageDetail.LINKTYPE_USERECORD);
+ if(MaterialErrorDamageDetail.TYPE_ERROR.equals(detail.getType())){
+ detail.setErrorType(MaterialErrorDamageDetail.ERRORTYPE_REDUCE);
+ }
+ detail.setMaterialName(materialDefinition.getName());
+ detail.setIsUnionToussInstance(true);
+ detail.setDepart(operateDepart.getName());
+ detail.setDepartCode(operateDepart.getOrgUnitCoding());
+ detail.setSettleAccountsDepart(settleSupplyRoomConfig.getOrgUnitName());
+ detail.setSettleAccountsDepartCoding(settleSupplyRoomConfig.getOrgUnitCoding());
+ detail.setDepartCodeForId(operateDepart.getOrgUnitCoding());
+ detail.setOperationTime(operTime);
+ detail.setOperator(operator);
+
+ detail.setAmount(errorAmount);
+ materialErrorDamageList.add(detail);
+
+ }
+ tiBarcodeToErrorDamageMap.put(tiBarcode, materialErrorDamageList);
+ }
+
+ }
+ if(MapUtils.isNotEmpty(tiBarcodeToUrgentLevelIdMap)){
+ String hql = String.format("select po from %s po where %s ", UrgentLevel.class.getSimpleName(), SqlUtils.getNonStringFieldInLargeCollectionsPredicate("po.id", tiBarcodeToUrgentLevelIdMap.values()));
+ List urgentLevelList = objectDao.findByHql(hql);
+ if(CollectionUtils.isNotEmpty(urgentLevelList)){
+ Map idToUrgentLevelMap = new HashMap();
+ for (UrgentLevel urgentLevel : urgentLevelList) {
+ idToUrgentLevelMap.put(urgentLevel.getId(), urgentLevel);
+ }
+ for (String tiBarcode : tiBarcodeToUrgentLevelIdMap.keySet()) {
+ Long urgentLevelId = tiBarcodeToUrgentLevelIdMap.get(tiBarcode);
+ tiBarcodeToUrgentLevelMap.put(tiBarcode, idToUrgentLevelMap.get(urgentLevelId));
+ }
+ }
+ }
+ }else{
+ // 器械包不需要加急或者丢失报损情况
+ String[] barcodes = barcode.split(";");
+ tousseInsBarcodes = Arrays.asList(barcodes);
+ }
+
+ List tiList = new ArrayList();
+ // 1、查询器械包实例
+ if(CollectionUtils.isNotEmpty(tousseInsBarcodes)){
+ for (String code : tousseInsBarcodes) {
+ BarcodeDevice bd = barcodeManager.getBarcodeByBarcode(code);
+ if (bd instanceof TousseInstance) {
+ // 1、查询器械包实例
+ TousseInstance tousseInstance = (TousseInstance) bd;
+ if(!StringUtils.equals(TousseInstance.STATUS_SHIPPED, tousseInstance.getStatus())
+ && !StringUtils.equals(TousseInstance.STATUS_SIGNED, tousseInstance.getStatus())){
+ throw new RuntimeException("患者消毒物料使用登记失败 :器械包条码为" + bd.getBarcode() + "的器械包为“" + tousseInstance.getStatus() + "”状态,请录入“已发货”或“已签收”的器械包");
+ }
+ if(StringUtils.isNotBlank(tousseInstance.getLocation2()) && !StringUtils.equals(tousseInstance.getLocation2(), departCoding)){
+ throw new RuntimeException("患者消毒物料使用登记失败 :器械包条码为" + bd.getBarcode() + "的器械包所在科室为" + tousseInstance.getLocationForDisplay2());
+ }else if(!StringUtils.equals(tousseInstance.getLocation(), departCoding)){
+ throw new RuntimeException("患者消毒物料使用登记失败 :器械包条码为" + bd.getBarcode() + "的器械包所在科室为" + tousseInstance.getLocationForDisplay());
+ }
+ tiList.add(tousseInstance);
+ } else {
+ throw new RuntimeException(code + "不是器械包条码");
+ }
+ }
+ }
+
+ // 检查器械包是否包含丢失报损的材料
+ tousseIncludeMaterial(tiList, tiBarcodeToErrorDamageMap);
+
+ // 2、创建使用记录
+ UseRecord newUseRecord = new UseRecord();
+
+ // 患者姓名
+ String patientName = processDataByXpath(document, null, patientNameXpath);
+ if(StringUtils.isBlank(patientName)){
+ // 不传患者姓名则根据住院号查询患者信息
+ PatientInfoVO patient = null;
+ if(StringUtils.isNotBlank(hospitalNumber)){
+ if(findPatientInfoByHospitalNumDao != null){
+ PatientInfoVO[] patientInfoVOs = findPatientInfoByHospitalNumDao.findPatientInfoByHospitalNum(hospitalNumber);
+ if(patientInfoVOs != null && patientInfoVOs.length > 0){
+ patient = patientInfoVOs[0];
+ }
+ }
+ if (patient == null) {
+ throw new RuntimeException("患者消毒物料使用登记失败 :未找到住院号为" + hospitalNumber + "的患者信息");
+ }
+ }else{
+ if(findPatientInfoByTreatmentNumDao != null){
+ PatientInfoVO[] patientInfoVOs = findPatientInfoByTreatmentNumDao.findPatientInfoByTreatmentNum(treatmentNum);
+ if(patientInfoVOs != null && patientInfoVOs.length > 0){
+ patient = patientInfoVOs[0];
+ }
+ }
+ if (patient == null) {
+ throw new RuntimeException("患者消毒物料使用登记失败 :未找到诊疗号为" + treatmentNum + "的患者信息");
+ }
+ }
+
+ if(StringUtils.isNotBlank(patient.getHospitalNumber())){
+ newUseRecord.setHospitalNum(patient.getHospitalNumber());
+ }else{
+ newUseRecord.setHospitalNum(patient.getPatientNumber());
+ }
+ newUseRecord.setTreatmentNum(patient.getClinicNumber());
+ newUseRecord.setPatientName(patient.getPatientName());
+ newUseRecord.setPatientAge(patient.getPatientAge());
+ newUseRecord.setPatientSex(patient.getPatientSex());
+ newUseRecord.setPatientIDCard(patient.getPatientIDCard());
+ newUseRecord.setDoctorName(patient.getDoctorName());
+ newUseRecord.setOperation(patient.getOperation());
+ newUseRecord.setOperationRoom(patient.getOpRoomId());
+ newUseRecord.setPatientArea(patient.getPatientArea());
+ newUseRecord.setRoomNumber(patient.getRoomNumber());
+ newUseRecord.setBedNumber(patient.getBedNumber());
+ newUseRecord.setAscriptionDepartment(patient.getAscriptionDepartment());
+ newUseRecord.setVisitId(patient.getVisitId());
+ newUseRecord.setWashHandNurse(patient.getWashHandNurse());
+ newUseRecord.setCircuitNurse(patient.getCircuitNurse());
+ newUseRecord.setSpecialInfection(patient.getSpecialInfection());
+ //newUseRecord.setOperationScheduleId(patient.getOperationScheduleId());
+ }else{
+ newUseRecord.setHospitalNum(hospitalNumber);
+ newUseRecord.setTreatmentNum(treatmentNum);
+ newUseRecord.setPatientName(patientName);
+ newUseRecord.setPatientAge(processDataByXpath(document, null, patientAgeXpath));
+ newUseRecord.setPatientSex(processDataByXpath(document, null, patientSexXpath));
+ newUseRecord.setPatientIDCard(processDataByXpath(document, null, patientIDCardXpath));
+ newUseRecord.setDoctorName(processDataByXpath(document, null, doctorNameXpath));
+ newUseRecord.setOperation(processDataByXpath(document, null, operationXpath));
+ newUseRecord.setOperationRoom(processDataByXpath(document, null, operationRoomXpath));
+ newUseRecord.setPatientArea(processDataByXpath(document, null, patientAreaXpath));
+ newUseRecord.setRoomNumber(processDataByXpath(document, null, roomNumberXpath));
+ newUseRecord.setBedNumber(processDataByXpath(document, null, bedNumberXpath));
+ newUseRecord.setAscriptionDepartment(processDataByXpath(document, null, ascriptionDepartmentXpath));
+ String visitId = processDataByXpath(document, null, visitIdXpath);
+ if(!DatabaseUtil.isPoIdValid(visitId)){
+ visitId = "0";
+ }
+ newUseRecord.setVisitId(Long.parseLong(visitId));
+ newUseRecord.setWashHandNurse(processDataByXpath(document, null, washHandNurseXpath));
+ newUseRecord.setCircuitNurse(processDataByXpath(document, null, circuitNurseXpath));
+ newUseRecord.setOperationScheduleId(processDataByXpath(document, null, operationScheduleIdXpath));
+ }
+
+ if(StringUtils.isNotBlank(operationTimeStr)){
+ newUseRecord.setOperationTime(DateTools.coverStrToDate(operationTimeStr, "yyyyMMddHHmmss"));
+ }
+
+ newUseRecord.setDepart(depart);
+ newUseRecord.setDepartCoding(departCoding);
+ newUseRecord.setEnteringDate(operTime);
+ // 登记人
+ newUseRecord.setOperator(operator);
+ // 录入时间
+ newUseRecord.setEnteringDate(operTime);
+ // 特殊感染类型
+ newUseRecord.setSpecialInfection(specialInfection);
+ newUseRecord.setRemark(remark);
+
+ objectDao.saveOrUpdate(newUseRecord);
+
+ if (CollectionUtils.isNotEmpty(tiList)) {
+ //科室的默认仓库
+ WareHouse warehouse = wareHouseManager.getDefaultWareHouseByUnitCode(departCoding);
+ for (TousseInstance tousseInstance : tiList) {
+ tousseInstance.setUseRecord_id(newUseRecord.getId());
+ //录入使用记录后,更新位置(此方法一定要放在tousseInstance.setUseRecord_id方法后面调用)
+ tousseInstance.resetLocationInfoAndWarehouseForUseRecord(newUseRecord,null,warehouse);
+ tousseInstance.setStatus(TousseInstance.STATUS_USED);
+ tousseInstance.setPatientName(newUseRecord.getPatientName());
+ tousseInstance.setDoctorName(newUseRecord.getDoctorName());
+ tousseInstance.setUseTime(operTime);
+ if(MapUtils.isNotEmpty(tiBarcodeToUrgentLevelMap)){
+ // 加急级别
+ tousseInstance.setUrgentLevelForUseRecord(tiBarcodeToUrgentLevelMap.get(tousseInstance.getBarcode()));
+ }
+ if(MapUtils.isNotEmpty(errorRemarkMap)){
+ // 丢失备注
+ tousseInstance.setErrorRemark(errorRemarkMap.get(tousseInstance.getBarcode()));
+ }
+ if(MapUtils.isNotEmpty(damageRemarkMap)){
+ // 报损备注
+ tousseInstance.setDamageRemark(damageRemarkMap.get(tousseInstance.getBarcode()));
+ }
+ }
+ objectDao.batchSaveOrUpdate(tiList);
+ String useRecordAuditMode = ConfigUtils.getSystemSetConfigByName("useRecordAuditMode", "");
+ if(StringUtils.equals(useRecordAuditMode, "3")){
+ String applicationFormType = ConfigUtils.getSystemSetConfigByName("applicationFormType", "");
+ String appType = InvoicePlan.TYPE_COMBO_FORM;
+ if(StringUtils.equals(applicationFormType, "2")){
+ appType = InvoicePlan.TYPE_TOUSSE_APPLICATION_FORM;
+ }
+ // 审核人
+ newUseRecord.setReviewer(operator);
+ // 审核时间
+ newUseRecord.setReviewTime(operTime);
+ newUseRecord.setApplicationTime(operTime);
+ // 使用记录转申请单
+ useRecordManager.saveAndReviewAndConvertUseRecordForm_TRANS_REQUIRED(
+ newUseRecord, operator, depart, departCoding,
+ operTime, appType,
+ operator, operator);
+ }else{
+ useRecordManager.saveUseRecord_TRANS_REQUIRED(newUseRecord);
+ }
+
+ // 设置丢失报损
+ for (TousseInstance tousseInstance : tiList) {
+ TousseDefinition tousseDefinition = tousseInstance.getTousseDefinition();
+ if(MapUtils.isNotEmpty(tiBarcodeToErrorDamageMap)){
+ if(!(StringUtils.equals(tousseDefinition.getTousseType(), TousseDefinition.PACKAGE_TYPE_CUSTOM)
+ || StringUtils.equals(tousseDefinition.getTousseType(), TousseDefinition.PACKAGE_TYPE_INSIDE))){
+ throw new RuntimeException(tousseDefinition.getTousseType() + "不需要丢失报损!");
+ }
+ // 丢失报损,自定义器械包和普通器械包科室登记丢失报损
+ List materialErrorDamageList = tiBarcodeToErrorDamageMap.get(tousseInstance.getBarcode());
+ if(CollectionUtils.isNotEmpty(materialErrorDamageList)){
+ setErrorDamageInfo(tousseInstance, tousseDefinition, materialErrorDamageList, newUseRecord);
+ }
+ }
+ }
+ if(newUseRecord != null && DatabaseUtil.isPoIdValid(newUseRecord.getId())){
+ typeCode = "0";
+ returnStr = "患者消毒物料使用登记成功";
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ returnStr = e.getMessage();
+ }
+ StringBuilder returnMsg = new StringBuilder();
+ returnMsg.append("");
+ returnMsg.append("");
+ returnMsg.append("" + typeCode + "");
+ returnMsg.append("" + returnStr + "");
+ returnMsg.append("");
+ returnMsg.append("");
+ logger.info("TOUSSE_USERECORD_REGISTRATION ---> " + returnMsg.toString());
+
+ return returnMsg.toString();
+ }
+
+ /**
+ * 检查器械包是否包含材料
+ * @param tiList
+ * @param tiBarcodeToErrorDamageMap
+ */
+ private void tousseIncludeMaterial(List tiList, Map> tiBarcodeToErrorDamageMap) {
+ if(MapUtils.isEmpty(tiBarcodeToErrorDamageMap) || CollectionUtils.isEmpty(tiList)){
+ return;
+ }
+ if(CollectionUtils.isNotEmpty(tiList)){
+ for (TousseInstance ti : tiList) {
+ List mdIdList = new ArrayList();
+ // 包定义材料id和数量的map
+ Map materialAmountMap = new HashMap();
+ String hql = String.format("select po from %s po where po.tousse.id = %s", MaterialInstance.class.getSimpleName(), ti.getTousseDefinition().getId());
+ @SuppressWarnings("unchecked")
+ List materialInstanceList = objectDao.findByHql(hql);
+ if(CollectionUtils.isNotEmpty(materialInstanceList)){
+ for (MaterialInstance materialInstance : materialInstanceList) {
+ mdIdList.add(materialInstance.getMaterialDefinitionId());
+ materialAmountMap.put(materialInstance.getMaterialDefinitionId(), materialInstance.getCount());
+ }
+ }
+ List list = tiBarcodeToErrorDamageMap.get(ti.getBarcode());
+ // 材料定义id和丢失报损数量的map
+ Map materialErrorDamageAmountMap = new HashMap();
+ Map materialNameMap = new HashMap();
+ for (MaterialErrorDamageDetail materialErrorDamageDetail : list) {
+ if(CollectionUtils.isEmpty(mdIdList) || !mdIdList.contains(materialErrorDamageDetail.getMaterialDefinitionId())){
+ throw new RuntimeException("条码为:" + ti.getBarcode() + "的器械包不包含材料:【" + materialErrorDamageDetail.getMaterialName() + "】");
+ }
+ Long materialDefinitionId = materialErrorDamageDetail.getMaterialDefinitionId();
+ Integer errorDamageAmount = materialErrorDamageAmountMap.get(materialDefinitionId);
+ if(errorDamageAmount == null){
+ errorDamageAmount = 0;
+ }
+ errorDamageAmount += materialErrorDamageDetail.getAmount();
+ materialErrorDamageAmountMap.put(materialDefinitionId, errorDamageAmount);
+ materialNameMap.put(materialDefinitionId, materialErrorDamageDetail.getMaterialName());
+ }
+
+ for (Long materialId : materialErrorDamageAmountMap.keySet()) {
+ Integer errorDamageAmount = materialErrorDamageAmountMap.get(materialId);
+ Integer materialAmount = materialAmountMap.get(materialId);
+ if(errorDamageAmount != null && materialAmount != null && errorDamageAmount.intValue() > materialAmount.intValue()){
+ throw new RuntimeException(materialNameMap.get(materialId) + "的丢失报损数量不能大于材料数量!材料数量为:" + materialAmount);
+ }
+ }
+
+ }
+ }
+ }
+
+ /**
+ * 设置丢失报损信息
+ * @param tousseInstance
+ * @param materialErrorDamageList
+ * @param newUseRecord
+ * @param errorRemark 丢失备注
+ * @param damageRemark 报损备注
+ */
+ private void setErrorDamageInfo(TousseInstance tousseInstance, TousseDefinition tousseDefinition,
+ List materialErrorDamageList, UseRecord newUseRecord) {
+ if(CollectionUtils.isEmpty(materialErrorDamageList) || tousseInstance == null){
+ return;
+ }
+ for (MaterialErrorDamageDetail materialErrorDamageDetail : materialErrorDamageList) {
+ String draftSql = String.format("where po.tousseInstanceId=%s and po.materialDefinitionId=%s and po.type='%s' and po.linkType='%s' and po.status=%s",
+ tousseInstance.getId(), materialErrorDamageDetail.getMaterialDefinitionId(),
+ materialErrorDamageDetail.getType(), MaterialErrorDamageDetail.LINKTYPE_USERECORD,
+ MaterialErrorDamageDetail.STATUS_TWO);
+ MaterialErrorDamageDetail detail = (MaterialErrorDamageDetail)objectDao.getBySql(MaterialErrorDamageDetail.class.getSimpleName(), draftSql);
+ RecyclingItem recyclingItem = null;
+ if(DatabaseUtil.isPoIdValid(tousseInstance.getRecyclingRecordId())){
+ RecyclingRecord recyclingRecord = (RecyclingRecord)objectDao.getById(RecyclingRecord.class.getSimpleName(), tousseInstance.getRecyclingRecordId());
+ String sql = String.format("select po from %s po where po.recyclingRecord.id=%s and po.tousseDefinitionId=%s ",
+ RecyclingItem.class.getSimpleName(),
+ recyclingRecord.getId(),
+ tousseInstance.getTousseDefinition().getId()
+ );
+ @SuppressWarnings("unchecked")
+ List list = objectDao.findByHql(sql);
+ if(CollectionUtils.isNotEmpty(list)){
+ recyclingItem = list.get(0);
+ }
+ }
+ if(detail == null){
+ detail = materialErrorDamageDetail;
+ }else{
+ detail.setAmount(materialErrorDamageDetail.getAmount());
+ }
+ if(recyclingItem != null){
+ String orgUnitCoding = recyclingItem.getRecyclingRecord().getOrgUnitCoding();
+ OrgUnit ou = (OrgUnit) orgUnitManager.getByCode(orgUnitCoding);
+ if(ou != null){
+ detail.setHandleDepartName(ou.getName());
+ }
+ detail.setHandleDepartCode(orgUnitCoding);
+ }
+ if(UseRecord.STATUS_UNAUDITED.equals(newUseRecord.getStatus())){
+ detail.setStatus(MaterialErrorDamageDetail.STATUS_TWO);
+ }
+ detail.setTousseBarcode(tousseInstance.getBarcode());
+ detail.setTousseDefinitionId(tousseInstance.getTousseDefinition().getId());
+ detail.setTousseInstanceId(tousseInstance.getId());
+ detail.setErrorRemark(tousseInstance.getErrorRemark());
+ detail.setDamageRemark(tousseInstance.getDamageRemark());
+ detail.setTousseName(tousseInstance.getTousseDefinitionName());
+ Integer additionalAmount = detail.getAdditionalAmount();
+ Integer errorAmount = detail.getAmount();
+ if(additionalAmount == null || errorAmount - additionalAmount > 0){
+ tousseInstance.setHaveUnSupplementMaterials(true);
+ }
+
+ Long currerntDetailId = detail.getId();
+ objectDao.saveOrUpdate(detail);
+ if(recyclingItem != null){
+ boolean isExist = CollectionUtils.exists(recyclingItem.getErrorDamageDetails(), new Predicate() {
+ @Override
+ public boolean evaluate(MaterialErrorDamageDetail mdetail) {
+ if (StringUtils.equals("" + mdetail.getId(), "" + currerntDetailId)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ });
+ if(!isExist){
+ recyclingItem.getErrorDamageDetails().add(detail);
+ }
+ }
+ }
+ }
+
+ /**
+ * 根据器械包条码查询消毒物料明细查询
+ * @param action
+ * @param message
+ * @return
+ */
+ public String tousseDetailQuery(String action, String message) {
+ logger.info("TOUSSE_BASIC_INFO_QUERY ---> action : " + action + "; message : " + message);
+ // retCode 为处理结果, 0 表示成功 1 表示失败
+ String retCode = "1";
+ // 处理结果说明
+ String returnStr = "";
+ String retDescription = "失败,未找到对应信息";
+ try {
+ if (StringUtils.isBlank(message)) {
+ throw new RuntimeException("参数message为空!");
+ }
+ String barcodeXpath = "/REQUEST/MSG/INSTRUMENT_SET_BARCODE";
+ Document document = DocumentHelper.parseText(message);
+ // 器械包条码
+ String barcode = processDataByXpath(document, null, barcodeXpath);
+ if (StringUtils.isBlank(barcode)) {
+ throw new RuntimeException("器械包条码不能为空!");
+ }
+ BarcodeDevice bd = barcodeManager.getBarcodeByBarcode(barcode);
+ if (bd instanceof TousseInstance) {
+ // 生成器械包信息xml
+ TousseInstance tousseInstance = (TousseInstance) bd;
+ TousseDefinition tousseDefinition = tousseInstance.getTousseDefinition();
+ if (tousseDefinition != null) {
+ List materialInstances = tousseDefinition.getMaterialInstances();
+ List diposableGoodsInstanceList = tousseDefinition.getDiposableGoodsItems();
+ retCode = "0";
+ retDescription = "消毒物料明细查询成功";
+ StringBuilder materialStr = new StringBuilder();
+ materialStr.append("");
+ if (CollectionUtils.isNotEmpty(materialInstances)) {
+ for (MaterialInstance materialInstance : materialInstances) {
+ String detailspec = materialInstance.getSpecification() == null ? "" : materialInstance.getSpecification();
+ materialStr.append("" + materialInstance.getMaterialDefinitionId() + "");
+ materialStr.append("" + materialInstance.getMaterialName() + "");
+ materialStr.append("" + detailspec + "");
+ materialStr.append("" + materialInstance.getCount() + "");
+ }
+ }
+ if (CollectionUtils.isNotEmpty(diposableGoodsInstanceList)) {
+ for (DiposableGoodsInstance disposableGoodsInstance : diposableGoodsInstanceList) {
+ DisposableGoods diposableGoods = disposableGoodsInstance.getDiposableGoods();
+ String detailspec = diposableGoods.getSpecification() == null ? "" : diposableGoods.getSpecification();
+ materialStr.append("" + disposableGoodsInstance.getDiposableGoodsId() + "");
+ materialStr.append("" + diposableGoods.getName() + "");
+ materialStr.append("" + detailspec + "");
+ materialStr.append("" + disposableGoodsInstance.getAmount() + "");
+ }
+ }
+ materialStr.append("");
+ StringBuilder returnStrSB = new StringBuilder();
+ returnStrSB.append("");
+ returnStrSB.append("" + tousseInstance.getBarcode() + "");
+ returnStrSB.append("" + tousseDefinition.getId() + "");
+ returnStrSB.append("" + tousseInstance.getTousseName() + "");
+ returnStrSB.append("" + (tousseInstance.getPrice() == null ? "" : tousseInstance.getPrice()) + "");
+ returnStrSB.append("" + (tousseInstance.getSterileEndTime() == null ? "" : tousseInstance.getSterileEndTime()) + "");
+ returnStrSB.append("" + (tousseInstance.getValidUntilStr() == null ? "" : tousseInstance.getValidUntilStr()) + "");
+ returnStrSB.append(materialStr.toString());
+ returnStrSB.append("");
+ returnStr = returnStrSB.toString();
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ returnStr = e.getMessage();
+ }
+ StringBuilder returnMsgSB = new StringBuilder();
+ returnMsgSB.append("");
+ returnMsgSB.append("" + retCode + "" + retDescription + "");
+ if(StringUtils.isNotBlank(returnStr)){
+ returnMsgSB.append("" + returnStr + "");
+ }
+ logger.info("TOUSSE_BASIC_INFO_QUERY ---> " + returnMsgSB.toString());
+ return returnMsgSB.toString();
+ }
+
+ /**
+ * 医院质控管理需要按患者使用的消毒包条码,进行消毒供应处理步骤的追溯并显示相关信息
+ * @param action
+ * @param message
+ * @return
+ */
+ public String tousseTraceQuery(String action, String message) {
+ logger.info("TOUSSE_TRACE_INFO_QUERY ---> action : " + action + "; message : " + message);
+ // retCoed 为处理结果, 0 表示成功 1 表示失败
+ String retCoed = "1";
+ // 处理结果说明
+ String retDescription = "失败,未找到对应信息";
+ String returnStr = "";
+ try {
+ if (StringUtils.isBlank(message)) {
+ throw new RuntimeException("参数message为空!");
+ }
+ // 器械包条码 INSTRUMENT_PACK_BARCODE
+ String barcodeXpath = "/REQUEST/MSG/INSTRUMENT_SET_BARCODE";
+ Document document = DocumentHelper.parseText(message);
+
+ // 器械包条码
+ String barcode = processDataByXpath(document, null, barcodeXpath);
+ if(StringUtils.isBlank(barcode)){
+ throw new RuntimeException("器械包条码不能为空!");
+ }
+ if(StringUtils.isNotBlank(barcode)){
+ BarcodeDevice bd = barcodeManager.getBarcodeByBarcode(barcode);
+ if (bd instanceof TousseInstance) {
+ // 生成器械包信息xml
+ TousseInstance tousseInstance = (TousseInstance) bd;
+ returnStr = getTousseTraceInfoByBarcode(tousseInstance);
+ }
+ }
+
+ if(StringUtils.isNotBlank(returnStr)){
+ retCoed = "0";
+ retDescription = "成功";
+ returnStr = "" + returnStr + "";
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ retDescription = e.getMessage();
+ }
+ String returnMsg =
+ "" +
+ "" + retCoed + "" + retDescription + "" +
+ returnStr + "";
+ logger.info("TOUSSE_TRACE_INFO_QUERY ---> " + returnMsg);
+ return returnMsg;
+ }
+
+ /**
+ * 根据器械包条码查询器械包的追溯信息
+ * @param barcode
+ * @return ...
+ */
+ private String getTousseTraceInfoByBarcode(TousseInstance tousseInstance) {
+ String returnStr = "";
+
+ // 申请记录信息
+ StringBuilder applyStrSB = new StringBuilder();
+ applyStrSB.append("");
+ Long invoicePlanId = tousseInstance.getInvoicePlanID();
+ if(DatabaseUtil.isPoIdValid(invoicePlanId)){
+ InvoicePlan invoicePlan = (InvoicePlan) objectDao.getById(InvoicePlan.class.getSimpleName(), invoicePlanId);
+ if(invoicePlan != null){
+ applyStrSB.append("");
+ applyStrSB.append("" + invoicePlan.getSerialNumber() + "");
+ applyStrSB.append("" + invoicePlan.getDepartCoding() + "");
+ applyStrSB.append("" + invoicePlan.getDepart() + "");
+ applyStrSB.append("" + invoicePlan.getApplicantCode() + "");
+ applyStrSB.append("" + invoicePlan.getApplicant() + "");
+ applyStrSB.append("" + ForgonDateUtils.safelyFormatDate(invoicePlan.getApplicationTime(), ForgonDateUtils.SIMPLEDATEFORMAT_YYYYMMDDHHMMSS, "") + "");
+ applyStrSB.append("");
+ applyStrSB.append("" + invoicePlan.getType() + "");
+ applyStrSB.append("");
+ }
+ }
+ applyStrSB.append("");
+
+ // 回收记录信息
+ StringBuilder recycleStrSB = new StringBuilder();
+ recycleStrSB.append("");
+ if(DatabaseUtil.isPoIdValid(invoicePlanId)){
+ @SuppressWarnings("unchecked")
+ List recyclingRecordList = objectDao.findBySql(RecyclingRecord.class.getSimpleName(),
+ " where recyclingApplication.id=" + invoicePlanId,
+ " id desc ");
+ if(CollectionUtils.isNotEmpty(recyclingRecordList)){
+ for (RecyclingRecord recyclingRecord : recyclingRecordList) {
+ String recycleDepartCode = recyclingRecord.getDepartCode();
+ String checkOperatorName = recyclingRecord.getOperator();
+ String checkOperatorCode = searchUserCode(checkOperatorName, recycleDepartCode);
+ String recycleOperatorName = recyclingRecord.getRecyclingUser();
+ String recycleOperatorCode = searchUserCode(recycleOperatorName, recycleDepartCode);
+ String recycleDateTimeStr = ForgonDateUtils.safelyFormatDate(recyclingRecord.getRecyclingTime(), ForgonDateUtils.SIMPLEDATEFORMAT_YYYYMMDDHHMMSS, "");
+
+ recycleStrSB.append("");
+ recycleStrSB.append("" + checkOperatorCode + "");
+ recycleStrSB.append("" + (checkOperatorName == null ? "" : checkOperatorName) + "");
+ recycleStrSB.append("" + recycleOperatorCode + "");
+ recycleStrSB.append("" + (recycleOperatorName == null ? "" : recycleOperatorName) + "");
+ recycleStrSB.append("" + recycleDateTimeStr + "");
+ recycleStrSB.append("");
+ }
+ }
+ }
+ recycleStrSB.append("");
+
+ // 清洗记录信息
+ StringBuilder cleanstrSB = new StringBuilder();
+ cleanstrSB.append("");
+ String classifyBasketIds = tousseInstance.getClassifyBasketIds();
+ if(StringUtils.isNotBlank(classifyBasketIds)){
+ String[] classifyBasketIdArr = classifyBasketIds.split(";");
+ List classifyBasketIdList = Arrays.asList(classifyBasketIdArr);
+ String classifyBasketHql = String.format("select po from %s po where %s", ClassifyBasket.class.getSimpleName(),
+ SqlUtils.getNonStringFieldInLargeCollectionsPredicate("po.id", classifyBasketIdList));
+ List classifyBasketList = objectDao.findByHql(classifyBasketHql);
+ if(CollectionUtils.isNotEmpty(classifyBasketList)){
+ List washAndDisinfectRecordList = new ArrayList();
+ for (ClassifyBasket classifyBasket : classifyBasketList) {
+ washAndDisinfectRecordList.addAll(classifyBasket.getWashAndDisinfectRecords());
+ }
+ for (WashAndDisinfectRecord washAndDisinfectRecord : washAndDisinfectRecordList) {
+ cleanstrSB.append("");
+ cleanstrSB.append("" + washAndDisinfectRecord.getRinserId() + "");
+ cleanstrSB.append("" + washAndDisinfectRecord.getDisinfectIdentification() + "");
+ cleanstrSB.append("" + washAndDisinfectRecord.getDisinfectProgram() + "");
+ cleanstrSB.append("" + washAndDisinfectRecord.getOperatorCode() + "");
+ cleanstrSB.append("" + washAndDisinfectRecord.getOperator() + "");
+ cleanstrSB.append("" + washAndDisinfectRecord.getStartDateStr() + "");
+ cleanstrSB.append("" + washAndDisinfectRecord.getEndDateStr() + "");
+ cleanstrSB.append("");
+ }
+ }
+ }
+ cleanstrSB.append("");
+
+ // 装配记录
+ StringBuilder packageStrSB = new StringBuilder();
+ String operationTimeStr = ForgonDateUtils.safelyFormatDate(tousseInstance.getOperationTime(), ForgonDateUtils.SIMPLEDATEFORMAT_YYYYMMDDHHMMSS, "");
+ String reviewTimeStr =ForgonDateUtils.safelyFormatDate(tousseInstance.getReviewTime(), ForgonDateUtils.SIMPLEDATEFORMAT_YYYYMMDDHHMMSS, "");
+ packageStrSB.append("");
+ packageStrSB.append("");
+ packageStrSB.append("" + tousseInstance.getBarcode() + "");
+ packageStrSB.append("" + tousseInstance.getTousseName() + "");
+ packageStrSB.append("" + (tousseInstance.getOperatorCode() == null ? "" : tousseInstance.getOperatorCode()) + "");
+ packageStrSB.append("" + (tousseInstance.getOperator() == null ? "" : tousseInstance.getOperator()) + "");
+ packageStrSB.append("" + (tousseInstance.getReviewerCode() == null ? "" : tousseInstance.getReviewerCode()) + "");
+ packageStrSB.append("" + (tousseInstance.getReviewer() == null ? "" : tousseInstance.getReviewer()) + "");
+ packageStrSB.append("" + operationTimeStr + "");
+ packageStrSB.append("" + reviewTimeStr + "");
+ packageStrSB.append("");
+ packageStrSB.append("" + (tousseInstance.getPackageType() == null ? "" : tousseInstance.getPackageType()) + "");
+ packageStrSB.append("");
+ packageStrSB.append("");
+
+ // 灭菌记录
+ StringBuilder sterilizationstrSB = new StringBuilder();
+ sterilizationstrSB.append("");
+ SterilizationRecord sterilizationRecord = tousseInstance.getSterilizationRecord(objectDao);
+ if(sterilizationRecord != null){
+ String orgUnitCode = sterilizationRecord.getOrgUnitCoding();
+ String sterilizationOperatorName = sterilizationRecord.getSterilizationUser();
+ String sterilizationOperatorCode = searchUserCode(sterilizationOperatorName, orgUnitCode);
+ Sterilizer sterilizer = sterilizationRecord.getSterilizer();
+ String sterilizationProcedure = sterilizationRecord.getSterilizationType();
+ Sterilisation sterilisation = (Sterilisation) objectDao.getByProperty(Sterilisation.class.getSimpleName(),
+ "sterilisation", sterilizationProcedure);
+ String sterilizationBeginTimeStr = ForgonDateUtils.safelyFormatDate(sterilizationRecord.getStartDate(), ForgonDateUtils.SIMPLEDATEFORMAT_YYYYMMDDHHMMSS, "");
+ String sterilizationEndTimeStr = ForgonDateUtils.safelyFormatDate(sterilizationRecord.getEndDate(), ForgonDateUtils.SIMPLEDATEFORMAT_YYYYMMDDHHMMSS, "");
+ String bioMonitorBeginTimeStr = ForgonDateUtils.safelyFormatDate(sterilizationRecord.getBiologicalMonitoringStartDate(), ForgonDateUtils.SIMPLEDATEFORMAT_YYYYMMDDHHMMSS, "");
+ String bioMonitorEndTimeStr = ForgonDateUtils.safelyFormatDate(sterilizationRecord.getBiologicalMonitoringEndDate(), ForgonDateUtils.SIMPLEDATEFORMAT_YYYYMMDDHHMMSS, "");
+ String validUntil = ForgonDateUtils.safelyFormatDate(tousseInstance.getValidUntil(), ForgonDateUtils.SIMPLEDATEFORMAT_YYYYMMDDHHMMSS, "");
+ sterilizationstrSB.append("");
+ sterilizationstrSB.append("" + sterilizationOperatorCode + "");
+ sterilizationstrSB.append("" + sterilizationOperatorName + "");
+ sterilizationstrSB.append("" + sterilizer.getName() + "");
+ sterilizationstrSB.append("" + (sterilisation == null ? "" : sterilisation.getBarcode()) + "");
+ sterilizationstrSB.append("" + (sterilisation == null ? "" : sterilisation.getSterilisation()) + "");
+ sterilizationstrSB.append("" + sterilizationRecord.getFrequency() + "");
+ sterilizationstrSB.append("" + sterilizationBeginTimeStr + "");
+ sterilizationstrSB.append("" + sterilizationEndTimeStr + "");
+ sterilizationstrSB.append("" + (sterilizationRecord.getChemistryResult() == null ? "" : sterilizationRecord.getChemistryResult()) + "");
+ sterilizationstrSB.append("" + bioMonitorBeginTimeStr + "");
+ sterilizationstrSB.append("" + bioMonitorEndTimeStr + "");
+ sterilizationstrSB.append("" + (sterilizationRecord.getBiologyResult() == null ? "" : sterilizationRecord.getBiologyResult()) + "");
+ sterilizationstrSB.append("" + validUntil + "");
+ sterilizationstrSB.append("");
+ }
+ sterilizationstrSB.append("");
+
+ // 发货记录
+ StringBuilder sendstrSB = new StringBuilder();
+ Invoice ip = tousseInstance.getInvoice(objectDao);
+ sendstrSB.append("");
+ if (ip != null) {
+ String senderName = ip.getSender();
+ String senderCode = searchUserCode(senderName, ip.getDepartCoding());
+ String delivertDateTime = ForgonDateUtils.safelyFormatDate(ip.getApplicationTime(), ForgonDateUtils.SIMPLEDATEFORMAT_YYYYMMDDHHMMSS, "");
+ sendstrSB.append("");
+ sendstrSB.append("" + senderCode + "");
+ sendstrSB.append("" + (senderName == null ? "" : senderName) + "");
+ sendstrSB.append("" + (ip.getDepartCoding() == null ? "" : ip.getDepartCoding()) + "");
+ sendstrSB.append("" + (ip.getDepart() == null ? "" : ip.getDepart()) + "");
+ sendstrSB.append("" + delivertDateTime + "");
+ sendstrSB.append("");
+ }
+ sendstrSB.append("");
+
+ // 签收记录
+ StringBuilder signRecordStrSB = new StringBuilder();
+ signRecordStrSB.append("");
+ Long signRecordId = tousseInstance.getSignRecordId();
+ if(DatabaseUtil.isPoIdValid(signRecordId)){
+ SignRecord signRecord = (SignRecord) objectDao.getById(SignRecord.class.getSimpleName(), signRecordId);
+ if(signRecord != null){
+ OrgUnit depart = null;
+ String departCode = signRecord.getDepartCode();
+ @SuppressWarnings("unchecked")
+ List departs = objectDao.findByProperty(OrgUnit.class.getSimpleName(),
+ "orgUnitCoding", departCode);
+ if(CollectionUtils.isNotEmpty(departs)){
+ depart = departs.get(0);
+ }
+ String signDate = ForgonDateUtils.safelyFormatDate(signRecord.getSignDate(), ForgonDateUtils.SIMPLEDATEFORMAT_YYYYMMDDHHMMSS, "");
+ signRecordStrSB.append("");
+ signRecordStrSB.append("" + (signRecord.getSignUserCode() == null ? "" : signRecord.getSignUserCode()) + "");
+ signRecordStrSB.append("" + (signRecord.getSignUserName() == null ? "" : signRecord.getSignUserName()) + "");
+ signRecordStrSB.append("" + (departCode == null ? "" : departCode) + "");
+ signRecordStrSB.append("" + (depart == null ? "" : depart.getName()) + "");
+ signRecordStrSB.append("" + signDate + "");
+ signRecordStrSB.append("");
+ }
+ }
+ signRecordStrSB.append("");
+
+ // 使用记录
+ UseRecord ur = tousseInstance.getUseRecord(objectDao);
+ StringBuilder useStrSB = new StringBuilder();
+ useStrSB.append("");
+ if (ur != null) {
+ String useDate = ForgonDateUtils.safelyFormatDate(ur.getEnteringDate(), ForgonDateUtils.SIMPLEDATEFORMAT_YYYYMMDDHHMMSS, "");
+ String departCode = ur.getDepartCoding();
+ String operatorName = ur.getOperator() == null ? "" : ur.getOperator();
+ String operatorCode = searchUserCode(operatorName, departCode);
+ String washHandNurseName = ur.getWashHandNurse() == null ? "" : ur.getWashHandNurse();
+ String washHandNurseCode = searchUserCode(washHandNurseName, departCode);
+ String circuitNurseName = ur.getCircuitNurse() == null ? "" : ur.getCircuitNurse();
+ String circuitNurseCode = searchUserCode(circuitNurseName, departCode);
+ useStrSB.append("");
+ useStrSB.append("" + (ur.getHospitalNum() == null ? "" : ur.getHospitalNum()) + "");
+ useStrSB.append("" + (ur.getTreatmentNum() == null ? "" : ur.getTreatmentNum()) + "");
+ useStrSB.append("" + (ur.getOperationScheduleId() == null ? "" : ur.getOperationScheduleId()) + "");
+ useStrSB.append("" + useDate + "");
+ useStrSB.append("" + operatorCode + "");
+ useStrSB.append("" + operatorName + "");
+ useStrSB.append("" + washHandNurseCode + "");
+ useStrSB.append("" + washHandNurseName + "");
+ useStrSB.append("" + circuitNurseCode + "");
+ useStrSB.append("" + circuitNurseName + "");
+ useStrSB.append("" + departCode + "");
+ useStrSB.append("" + ur.getDepart() + "");
+ useStrSB.append("");
+ }
+ useStrSB.append("");
+
+ // 废弃
+ StringBuilder discardstrSB = new StringBuilder();
+ String wasteDate = ForgonDateUtils.safelyFormatDate(tousseInstance.getWasteDate(), ForgonDateUtils.SIMPLEDATEFORMAT_YYYYMMDDHHMMSS, "");
+ discardstrSB.append("");
+ discardstrSB.append("");
+ discardstrSB.append("" + wasteDate + "");
+ discardstrSB.append("" + (tousseInstance.getWasteReason() == null ? "" : tousseInstance.getWasteReason()) + "");
+ discardstrSB.append("" + (tousseInstance.getOperateUser() == null ? "" : tousseInstance.getOperateUser()) + "");
+ discardstrSB.append("");
+ discardstrSB.append("");
+
+ // 质量监测记录
+ StringBuilder qualityStrSB = new StringBuilder();
+ qualityStrSB.append("");
+ String qualityHql = String.format("select po from %s po where po.tousseInstance.id = %s", QualityMonitoringInstance.class.getSimpleName(),
+ tousseInstance.getId());
+ @SuppressWarnings("unchecked")
+ List qualityList = objectDao.findByHql(qualityHql);
+ if(CollectionUtils.isNotEmpty(qualityList)){
+ for (QualityMonitoringInstance qualityMonitoringInstance : qualityList) {
+ String departCode = qualityMonitoringInstance.getOrgUnitCoding();
+ String createUserName = qualityMonitoringInstance.getCreateUserName() == null ? "" : qualityMonitoringInstance.getCreateUserName();
+ String createUserCode = searchUserCode(createUserName, departCode);
+ String regDateTime = ForgonDateUtils.safelyFormatDate(qualityMonitoringInstance.getCreateDate(), ForgonDateUtils.SIMPLEDATEFORMAT_YYYYMMDDHHMMSS, "");
+ FormDefinition formDefinition = qualityMonitoringInstance.getFormDefinition();
+ qualityStrSB.append("");
+ qualityStrSB.append("" + createUserCode + "");
+ qualityStrSB.append("" + createUserName + "");
+ qualityStrSB.append("" + departCode + "");
+ qualityStrSB.append("" + qualityMonitoringInstance.getOrgUnit() + "");
+ qualityStrSB.append("" + regDateTime + "");
+ qualityStrSB.append("" + formDefinition.getId() + "");
+ qualityStrSB.append("" + formDefinition.getFormName() + "");
+ qualityStrSB.append("");
+ }
+ }
+ qualityStrSB.append("");
+
+ StringBuilder returnStrSB = new StringBuilder();
+ returnStrSB.append("");
+ returnStrSB.append(applyStrSB.toString());
+ returnStrSB.append(recycleStrSB.toString());
+ returnStrSB.append(cleanstrSB.toString());
+ returnStrSB.append(packageStrSB.toString());
+ returnStrSB.append(sterilizationstrSB.toString());
+ returnStrSB.append(sendstrSB.toString());
+ returnStrSB.append(signRecordStrSB.toString());
+ returnStrSB.append(useStrSB.toString());
+ returnStrSB.append(discardstrSB.toString());
+ returnStrSB.append(qualityStrSB.toString());
+ returnStrSB.append("");
+ returnStr = returnStrSB.toString();
+ return returnStr;
+ }
+
+ /**
+ * 根据用户名和科室编码查找用户编码
+ * @param recycleOperatorName
+ * @param departCode
+ * @return
+ */
+ private String searchUserCode(String recycleOperatorName, String departCode) {
+ String recycleOperatorCode = "";
+ @SuppressWarnings("unchecked")
+ List recycleOperators = objectDao.findByProperty(User.class.getSimpleName(), "fullName", recycleOperatorName);
+ if(CollectionUtils.isNotEmpty(recycleOperators)){
+ for (User user : recycleOperators) {
+ if(StringUtils.isNotBlank(recycleOperatorCode)){
+ break;
+ }
+ Set orgUserRelationSet = user.getOrgUserRelations();
+ for (OrgUserRelation orgUserRelation : orgUserRelationSet) {
+ OrgUnit orgUnit = orgUserRelation.getOrgUnit();
+ if(StringUtils.equals(orgUnit.getOrgUnitCoding(), departCode)){
+ recycleOperatorCode = user.getName();
+ break;
+ }
+ }
+ }
+ }
+ return recycleOperatorCode;
+ }
+
+ @Override
+ public String HIPMessageServerV3(String action, String message) {
+ String result = "";
+ if ("INSTRUMENT_SET_BASIC_INFO_QUERY".equals(action)) {
+ result = this.tousseDetailQuery(action, message);
+ } else if ("INSTRUMENT_SET_USERECORD_REGISTRATION".equals(action)) {
+ result = this.applyRegister(action, message);
+ } else if ("INSTRUMENT_SET_TRACE_INFO_QUERY".equals(action)) {
+ result = this.tousseTraceQuery(action, message);
+ } else if ("INSTRUMENT_SET_USERECORD_INFO_QUERY".equals(action)) {
+ result = this.tousseUseRecordInfoQuery(action, message);
+ } else if(StringUtils.isNotBlank(message) && StringUtils.isBlank(action)){
+ // 广东省中医院的特殊入参处理:action为空,message格式如下
+ /*
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ */
+ result = tousseTraceQueryForGdszyy(message);
+ }else{
+ logger.info("action : " + action + "; message : " + message);
+
+ // retCoed 为处理结果, 0 表示成功 1 表示失败
+ StringBuilder returnMsgSB = new StringBuilder();
+ returnMsgSB.append("");
+ returnMsgSB.append("");
+ returnMsgSB.append("1");
+ returnMsgSB.append("错误的action值!");
+ returnMsgSB.append("");
+ returnMsgSB.append("");
+
+ String returnMsg = returnMsgSB.toString();
+ logger.info("returnMsg : " + returnMsg);
+ return returnMsg;
+ }
+
+ // 根据配置文件fieldsMappingTalbe.json设置参数名称
+ if(config != null){
+ Map fieldsMap = new HashMap();
+ fieldsMap = getFieldsMap(config);
+ result = setFieldNameByConfigMap(result, fieldsMap);
+ }
+ return result;
+ }
+
+ /**
+ * 广东省中医院:根据住院号/诊疗号/手术申请单号/器械包条码获取器械包追溯信息
+ * @param message
+ * @return
+ */
+ private String tousseTraceQueryForGdszyy(String message) {
+ logger.info("TOUSSE_TRACE_INFO_QUERY ---> action : ''; message : " + message);
+ // retCoed 为处理结果, 0 表示成功 1 表示失败
+ String retCode = "1";
+ // 处理结果说明
+ String retDescription = "失败,未找到对应信息";
+ String returnStr = "";
+ try {
+ if (StringUtils.isBlank(message)) {
+ throw new RuntimeException("参数message为空!");
+ }
+ // 门诊号 OUTHOSP_INDEX_NO
+ String treatNumberXpath = "/Request/Msg/OUTHOSP_INDEX_NO";
+ // 住院号 INHOSP_INDEX_NO
+ String hospitalNumberXpath = "/Request/Msg/INHOSP_INDEX_NO";
+ // 器械包条码 INSTRUMENT_PACK_BARCODE
+ String barcodeXpath = "/Request/Msg/INSTRUMENT_PACK_BARCODE";
+ // 手术单号 SURGERY_APPLI_FORM_NO
+ String operationScheIdXpath = "/Request/Msg/SURGERY_APPLI_FORM_NO";
+ Document document = DocumentHelper.parseText(message);
+
+ // 门诊号
+ String treatNumber = processDataByXpath(document, null, treatNumberXpath);
+ // 住院号
+ String hospitalNumber = processDataByXpath(document, null, hospitalNumberXpath);
+ // 器械包条码
+ String barcode = processDataByXpath(document, null, barcodeXpath);
+ // 手术单号
+ String operationScheId = processDataByXpath(document, null, operationScheIdXpath);
+
+ if(StringUtils.isNotBlank(barcode)){
+ if(StringUtils.isNotBlank(barcode)){
+ BarcodeDevice bd = barcodeManager.getBarcodeByBarcode(barcode);
+ if (bd instanceof TousseInstance) {
+ // 生成器械包信息xml
+ TousseInstance tousseInstance = (TousseInstance) bd;
+ // ...
+ returnStr = getTousseTraceInfoByBarcode(tousseInstance);
+ }
+ }
+ }else if(StringUtils.isNotBlank(treatNumber)){
+ // ...
+ returnStr = searchTousseTraceInfoByBarcode("OUTHOSP_INDEX_NO", treatNumber);
+ }else if(StringUtils.isNotBlank(hospitalNumber)){
+ returnStr = searchTousseTraceInfoByBarcode("INHOSP_INDEX_NO", hospitalNumber);
+ }else if(StringUtils.isNotBlank(operationScheId)){
+ returnStr = searchTousseTraceInfoByBarcode("SURGERY_APPLI_FORM_NO", operationScheId);
+ }else{
+ // retCoed 为处理结果, 0 表示成功 1 表示失败
+ StringBuilder returnMsgSB = new StringBuilder();
+ returnMsgSB.append("");
+ returnMsgSB.append("");
+ returnMsgSB.append("1");
+ returnMsgSB.append("查询条件不能为空!");
+ returnMsgSB.append("");
+ returnMsgSB.append("");
+
+ return returnMsgSB.toString();
+ }
+
+ if(StringUtils.isNotBlank(returnStr)){
+ retCode = "0";
+ // 处理结果说明
+ retDescription = "成功";
+ }
+
+ }catch (Exception e) {
+ e.printStackTrace();
+ retCode = "1";
+ retDescription = e.getMessage();
+ }
+ StringBuffer resultStringBuffer = new StringBuffer();
+ resultStringBuffer.append("");
+ resultStringBuffer.append("");
+ resultStringBuffer.append("" + retCode + "");
+ resultStringBuffer.append("" + retDescription + "");
+ resultStringBuffer.append("");
+ resultStringBuffer.append(returnStr);
+ resultStringBuffer.append("");
+ return resultStringBuffer.toString();
+ }
+
+ /**
+ * 根据配置文件修改返回信息的字段名称
+ * @param result
+ * @param fieldsMap
+ * @return
+ */
+ private String setFieldNameByConfigMap(String result, Map fieldsMap) {
+ if(MapUtils.isNotEmpty(fieldsMap)){
+ for (String key : fieldsMap.keySet()) {
+ String value = fieldsMap.get(key);
+ if(StringUtils.isNotBlank(value)){
+ String xmlOrigLTField = "<" + key + ">";
+ String xmlOrigGTField = "" + key + ">";
+ String xmlNewLTField = "<" + value + ">";
+ String xmlNewGTField = "" + value + ">";
+ result = result.replaceAll(xmlOrigLTField, xmlNewLTField);
+ result = result.replaceAll(xmlOrigGTField, xmlNewGTField);
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * 获取参数名称映射关系
+ * @param configObject
+ * @return
+ */
+ private Map getFieldsMap(JsonObject configObject) {
+ Map fieldsMap = new HashMap();
+ JsonArray JsonArray = configObject.getAsJsonArray("fieldsMappingTalbe");
+ if(JsonArray != null){
+ for (JsonElement jsonElement : JsonArray) {
+ JsonObject jsonObj = (JsonObject) jsonElement;
+ String sstsFieldName = jsonObj.get("standardFieldName").getAsString();
+ String trdPartyFieldName = jsonObj.get("3rdPartyFieldName").getAsString();
+ fieldsMap.put(sstsFieldName, trdPartyFieldName);
+ }
+ }
+ return fieldsMap;
+ }
+
+ /**
+ * 根据住院号、诊疗号、手术申请单号获取器械包追溯信息
+ * @param action
+ * @param message
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ private String tousseUseRecordInfoQuery(String action, String message) {
+ logger.info("action : " + action + "; message : " + message);
+ logger.info("TOUSSE_TRACE_INFO_QUERY ---> action : " + action + "; message : " + message);
+ // retCoed 为处理结果, 0 表示成功 1 表示失败
+ String retCode = "1";
+ // 处理结果说明
+ String retDescription = "失败,未找到对应信息";
+ String returnStr = "";
+ try {
+ if (StringUtils.isBlank(message)) {
+ throw new RuntimeException("参数message为空!");
+ }
+ String codeTypeXpath = "/REQUEST/MSG/CODE_TYPE";
+ String codeXpath = "/REQUEST/MSG/CODE";
+ Document document = DocumentHelper.parseText(message);
+ String codeType = processDataByXpath(document, null, codeTypeXpath);
+ String code = processDataByXpath(document, null, codeXpath);
+ if(StringUtils.isBlank(codeType)){
+ throw new RuntimeException("CODE_TYPE不能为空!");
+ }
+ if(StringUtils.isBlank(code)){
+ throw new RuntimeException("CODE不能为空!");
+ }
+ // ...
+ returnStr = searchTousseTraceInfoByBarcode(codeType, code);
+ retCode = "0";
+ retDescription = "成功";
+ } catch (Exception e) {
+ e.printStackTrace();
+ retCode = "1";
+ retDescription = e.getMessage();
+ }
+ StringBuffer resultStringBuffer = new StringBuffer();
+ resultStringBuffer.append("");
+ resultStringBuffer.append("");
+ resultStringBuffer.append("" + retCode + "");
+ resultStringBuffer.append("" + retDescription + "");
+ resultStringBuffer.append("");
+ resultStringBuffer.append(returnStr);
+ resultStringBuffer.append("");
+ return resultStringBuffer.toString();
+ }
+
+ /**
+ * 根据条码查询使用记录登记的器械包的追溯信息
+ * @param codeType
+ * @param code
+ * @return ...
+ */
+ @SuppressWarnings("unchecked")
+ private String searchTousseTraceInfoByBarcode(String codeType, String code) {
+ String returnStr = "";
+ List useRecordList = new ArrayList();
+ List tousseInstanceList = new ArrayList();
+ String useRecordHql = String.format("select po from %s po where 1=0",
+ UseRecord.class.getSimpleName());
+ if(StringUtils.equals(codeType, "INHOSP_INDEX_NO")){
+ useRecordHql = String.format("select po from %s po where po.hospitalNum = '%s'",
+ UseRecord.class.getSimpleName(), code);
+ }else if(StringUtils.equals(codeType, "OUTHOSP_INDEX_NO")){
+ useRecordHql = String.format("select po from %s po where po.treatmentNum = '%s'",
+ UseRecord.class.getSimpleName(), code);
+ }else if(StringUtils.equals(codeType, "SURGERY_APPLI_FORM_NO")){
+ useRecordHql = String.format("select po from %s po where po.operationScheduleId = '%s'",
+ UseRecord.class.getSimpleName(), code);
+ }else{
+ throw new RuntimeException("CODE_TYPE不正确");
+ }
+
+ useRecordList = objectDao.findByHql(useRecordHql);
+ if(CollectionUtils.isNotEmpty(useRecordList)){
+ for (UseRecord useRecord : useRecordList) {
+ List tempList = useRecord.getTousseInstanceList(objectDao);
+ if(CollectionUtils.isNotEmpty(tempList)){
+ tousseInstanceList.addAll(tempList);
+ }
+ }
+ if(CollectionUtils.isNotEmpty(tousseInstanceList)){
+ StringBuffer resultStringBuffer = new StringBuffer();
+ for (TousseInstance tousseInstance : tousseInstanceList) {
+ resultStringBuffer.append(getTousseTraceInfoByBarcode(tousseInstance));
+ }
+ returnStr = resultStringBuffer.toString();
+ returnStr = "" + returnStr + "";
+ }
+ }
+ return returnStr;
+ }
+
+
+ /**
+ * 根据document和Xpath表达式解析数据
+ * @param document
+ * @param nameSpaceURIMap
+ * @param xpathExp
+ * @return
+ */
+ private String processDataByXpath(Document document, Map nameSpaceURIMap, String xpathExp) {
+ if ((StringUtils.isNotBlank(xpathExp)) && (document != null)) {
+ XPath xpath = document.createXPath(xpathExp);
+ if (nameSpaceURIMap != null) {
+ xpath.setNamespaceURIs(nameSpaceURIMap);
+ }
+ Node node = xpath.selectSingleNode(document);
+ if (node != null) {
+ //return node.getStringValue();
+ String value = node.getStringValue();
+ if(value != null){
+ value = value.trim();
+ }
+ return value;
+ }
+ }
+ return null;
+ }
+
+}