Index: ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/datasync/common/HIPMessageWebServiceImplV2.java =================================================================== diff -u -r31409 -r31644 --- ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/datasync/common/HIPMessageWebServiceImplV2.java (.../HIPMessageWebServiceImplV2.java) (revision 31409) +++ ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/datasync/common/HIPMessageWebServiceImplV2.java (.../HIPMessageWebServiceImplV2.java) (revision 31644) @@ -19,12 +19,14 @@ import org.dom4j.XPath; import org.springframework.beans.factory.annotation.Autowired; +import com.forgon.databaseadapter.service.DateQueryAdapter; import com.forgon.directory.model.BarcodeDevice; import com.forgon.directory.model.OrgUnit; 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.common.CssdUtils; import com.forgon.disinfectsystem.datasynchronization.dao.FindPatientInfoByHospitalNumDao; import com.forgon.disinfectsystem.datasynchronization.dao.FindPatientInfoByTreatmentNumDao; import com.forgon.disinfectsystem.datasynchronization.model.PatientInfoVO; @@ -79,6 +81,8 @@ private SupplyRoomConfigManager supplyRoomConfigManager; @Autowired private OrgUnitManager orgUnitManager; + @Autowired + private DateQueryAdapter dateQueryAdapter; /** * 器械包使用登记(消毒物料使用登记) @@ -120,6 +124,8 @@ String operationScheduleIdXpath = "/req/message_cont/INPUT/operationScheduleId"; // 手术名称 String operationXpath = "/req/message_cont/INPUT/operation"; + // 手术状态 + String operationStatusXpath = "/req/message_cont/INPUT/operationStatus"; // 手术时间 String operationTimeXpath = "/req/message_cont/INPUT/operationTime"; // 医生姓名 @@ -158,6 +164,7 @@ String hospitalNumber = processDataByXpath(document, null, inpatientnoXpath); String treatmentNum = processDataByXpath(document, null, treatmentNumXpath); String operator = processDataByXpath(document, null, excutorXpath); + String operationStatus = processDataByXpath(document, null, operationStatusXpath); String operationTime = processDataByXpath(document, null, excutimeXpath); Date operTime = DateTools.coverStrToDate(operationTime, "yyyyMMddHHmmss"); String departCoding = processDataByXpath(document, null, excutdeptnoXpath); @@ -366,95 +373,114 @@ // 2、创建使用记录 UseRecord newUseRecord = new UseRecord(); + String enableUseRecordFormExtensionFields = CssdUtils.getSystemSetConfigByName("enableUseRecordFormExtensionFields"); + if(StringUtils.isNotBlank(enableUseRecordFormExtensionFields)){ + enableUseRecordFormExtensionFields = enableUseRecordFormExtensionFields.substring(1, enableUseRecordFormExtensionFields.length() -1); + if(StringUtils.contains(enableUseRecordFormExtensionFields, "手术状态")){ + if(StringUtils.isBlank(operationStatus)){ + throw new RuntimeException("患者消毒物料使用登记失败 :手术状态operationStatus不能为空!" ); + } + // 查找同一场手术的未审核的使用记录 + newUseRecord = getUnReviewUseRecord(hospitalNumber, treatmentNum, operationTimeStr); + } + } // 患者姓名 - 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(!DatabaseUtil.isPoIdValid(newUseRecord.getId())){ + // 该使用记录关联的手术未登记过使用记录 + 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 (patient == null) { - throw new RuntimeException("患者消毒物料使用登记失败 :未找到住院号为" + hospitalNumber + "的患者信息"); + + 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{ - if(findPatientInfoByTreatmentNumDao != null){ - PatientInfoVO[] patientInfoVOs = findPatientInfoByTreatmentNumDao.findPatientInfoByTreatmentNum(treatmentNum); - if(patientInfoVOs != null && patientInfoVOs.length > 0){ - patient = patientInfoVOs[0]; - } + 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"; } - if (patient == null) { - throw new RuntimeException("患者消毒物料使用登记失败 :未找到诊疗号为" + treatmentNum + "的患者信息"); - } + 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(patient.getHospitalNumber())){ - newUseRecord.setHospitalNum(patient.getHospitalNumber()); - }else{ - newUseRecord.setHospitalNum(patient.getPatientNumber()); + if(StringUtils.isNotBlank(operationTimeStr)){ + newUseRecord.setOperationTime(DateTools.coverStrToDate(operationTimeStr, "yyyyMMddHHmmss")); } - 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()); + + newUseRecord.setDepart(depart); + newUseRecord.setDepartCoding(departCoding); + newUseRecord.setEnteringDate(operTime); + // 登记人 + newUseRecord.setOperator(operator); + // 录入时间 + newUseRecord.setEnteringDate(operTime); + // 特殊感染类型 + newUseRecord.setSpecialInfection(specialInfection); + newUseRecord.setRemark(remark); + newUseRecord.setOperationStatus(operationStatus); }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)); + // 修改记录录入时间 + newUseRecord.setEnteringDate(operTime); + newUseRecord.setOperationStatus(operationStatus); } - 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)) { @@ -483,7 +509,11 @@ } objectDao.batchSaveOrUpdate(tiList); String useRecordAuditMode = ConfigUtils.getSystemSetConfigByName("useRecordAuditMode", ""); - if(StringUtils.equals(useRecordAuditMode, "3")){ + // useRecordAuditMode = 3, 或者,手术状态”这个字段的值为“手术结束”时把单据改成已申请的状态,并且自动生成一张通用申请单 + if(StringUtils.equals(useRecordAuditMode, "3") + || StringUtils.equals(newUseRecord.getOperationStatus(), UseRecord.OPERATION_STATUS_END_OPERATION) + || StringUtils.equals(newUseRecord.getOperationStatus(), UseRecord.OPERATION_STATUS_OUT_OPERATIONROOM) + || StringUtils.equals(newUseRecord.getOperationStatus(), UseRecord.OPERATION_STATUS_END_ANESTHESIA)){ String applicationFormType = ConfigUtils.getSystemSetConfigByName("applicationFormType", ""); String appType = InvoicePlan.TYPE_COMBO_FORM; if(StringUtils.equals(applicationFormType, "2")){ @@ -955,5 +985,44 @@ } return null; } + + /** + * 根据住院号、门诊号、手术时间查询使用记录(状态为“未审核”、手术状态不是“手术结束”的记录) + * @param hospitalNumber + * @param treatmentNum + * @param operationTimeStr + * @return + */ + private UseRecord getUnReviewUseRecord(String hospitalNumber, String treatmentNum, String operationTimeStr){ + if((StringUtils.isNotBlank(hospitalNumber) || StringUtils.isNotBlank(treatmentNum)) && StringUtils.isNotBlank(operationTimeStr)){ + String sql = String.format(" from %s po where (po.status = '%s' or po.status is null) " + + "and (po.operationStatus <> '%s')", + UseRecord.class.getSimpleName(), UseRecord.STATUS_UNAUDITED, UseRecord.OPERATION_STATUS_END_OPERATION); + if(StringUtils.isNotBlank(hospitalNumber)){ + sql += " and po.hospitalNum = '" + hospitalNumber + "' "; + } + if(StringUtils.isNotBlank(treatmentNum)){ + sql += " and po.treatmentNum = '" + treatmentNum + "' "; + } + if(StringUtils.isNotBlank(operationTimeStr)){ + Date operationTime = DateTools.coverStrToDate(operationTimeStr, "yyyyMMddHHmmss"); + sql += " and po.operationTime = " + dateQueryAdapter.stringToDate(operationTime); + } + + String hql = "select po " + sql + " order by po.id desc "; + + String countSql = "select count(*) " + sql; + + if(objectDao.countBySql(countSql) > 0){ + @SuppressWarnings("unchecked") + List useRecordList = objectDao.findByHql(hql); + if(CollectionUtils.isNotEmpty(useRecordList)){ + return useRecordList.get(0); + } + } + + } + return null; + } } Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/useRecord/UseRecord.java =================================================================== diff -u -r31406 -r31644 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/useRecord/UseRecord.java (.../UseRecord.java) (revision 31406) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/useRecord/UseRecord.java (.../UseRecord.java) (revision 31644) @@ -99,6 +99,11 @@ private String operation;//手术名称 + /** + * 手术状态,有如下4个值:“准备手术”,“手术开始”,“手术中”,“手术结束” + */ + private String operationStatus; + private String operationRoom;//手术间 /** @@ -281,6 +286,45 @@ public static String CONVERT_RECYCLINGMANAGER_MERGE_REGULAR_OPERATIONROOM = "operationRoom"; public static String CONVERT_RECYCLINGMANAGER_MERGE_REGULAR_DEPART = "depart"; + // 佛山市第二人民医院手术状态:“入手术室”,“麻醉开始”,“麻醉操作完成”,“手术开始”,“手术结束”,“麻醉结束”,“出手术室” (FSSDERMYY-7) + /** + * 入手术室(佛山市第二人民医院手术状态) + */ + public static final String OPERATION_STATUS_IN_OPERATIONROOM = "入手术室"; + /** + * 麻醉开始(佛山市第二人民医院手术状态) + */ + public static final String OPERATION_STATUS_BEGIN_ANESTHESIA = "麻醉开始"; + /** + * 麻醉操作完成(佛山市第二人民医院手术状态) + */ + public static final String OPERATION_STATUS_FINISH_ANESTHESIA = "麻醉操作完成"; + /** + * 麻醉结束(佛山市第二人民医院手术状态) + */ + public static final String OPERATION_STATUS_END_ANESTHESIA = "麻醉结束"; + /** + * “出手术室”(佛山市第二人民医院手术状态) + */ + public static final String OPERATION_STATUS_OUT_OPERATIONROOM = "出手术室"; + + /** + * 手术状态:准备手术 + */ + public static final String OPERATION_STATUS_PRE_OPERATION = "准备手术"; + /** + * 手术状态:手术开始 + */ + public static final String OPERATION_STATUS_BEGIN_OPERATION = "手术开始"; + /** + * 手术状态:手术中 + */ + public static final String OPERATION_STATUS_IN_OPERATION = "手术中"; + /** + * 手术状态:手术结束 + */ + public static final String OPERATION_STATUS_END_OPERATION = "手术结束"; + @Override @Id @GeneratedValue(strategy=GenerationType.AUTO) @@ -673,6 +717,14 @@ this.operation = operation; } + public String getOperationStatus() { + return operationStatus; + } + + public void setOperationStatus(String operationStatus) { + this.operationStatus = operationStatus; + } + public String getPatientSex() { return patientSex; } @@ -869,6 +921,7 @@ jsonObject.put("recyclingStatus", getRecyclingStatus()); jsonObject.put("manualSetRecyclingStatusUser", getManualSetRecyclingStatusUser()); jsonObject.put("manualSetRecyclingStatusTime", getManualSetRecyclingStatusTime()); + jsonObject.put("operationStatus", getOperationStatus()); if(CollectionUtils.isNotEmpty(tousseInstanceList)){ JSONArray array = new JSONArray(); Index: ssts-userecord/src/main/java/com/forgon/disinfectsystem/useRecord/service/UseRecordManagerImpl.java =================================================================== diff -u -r31454 -r31644 --- ssts-userecord/src/main/java/com/forgon/disinfectsystem/useRecord/service/UseRecordManagerImpl.java (.../UseRecordManagerImpl.java) (revision 31454) +++ ssts-userecord/src/main/java/com/forgon/disinfectsystem/useRecord/service/UseRecordManagerImpl.java (.../UseRecordManagerImpl.java) (revision 31644) @@ -2339,6 +2339,30 @@ curUseRecord.setOperation(operation); modifyContent.add("手术名称由"+ originalOperation +"修改为"+ operation); } + + // operationStatus + String originalOperationStatus = original.getOperationStatus(); + String operationStatus = modified.getOperationStatus(); + if (!StringUtils.equals(originalOperationStatus, operationStatus)) { + curUseRecord.setOperationStatus(operationStatus); + modifyContent.add("手术状态由"+ originalOperationStatus +"修改为"+ operationStatus); + } + + // anesthesiaMode + String originalAnesthesiaMode = original.getAnesthesiaMode(); + String anesthesiaMode = modified.getAnesthesiaMode(); + if (!StringUtils.equals(originalAnesthesiaMode, anesthesiaMode)) { + curUseRecord.setAnesthesiaMode(anesthesiaMode); + modifyContent.add("麻醉方式由"+ originalAnesthesiaMode +"修改为"+ anesthesiaMode); + } + + // anesthetist + String originalAnesthetist = original.getAnesthetist(); + String anesthetist = modified.getAnesthetist(); + if (!StringUtils.equals(originalAnesthetist, anesthetist)) { + curUseRecord.setOperationStatus(operationStatus); + modifyContent.add("麻醉医生由"+ originalAnesthetist +"修改为"+ anesthetist); + } // specialInfection String originalSpecialInfection = original.getSpecialInfection();