Index: ssts-userecord/src/main/java/com/forgon/disinfectsystem/useRecord/action/ButtJointForeignTousseApplicationAction.java =================================================================== diff -u --- ssts-userecord/src/main/java/com/forgon/disinfectsystem/useRecord/action/ButtJointForeignTousseApplicationAction.java (revision 0) +++ ssts-userecord/src/main/java/com/forgon/disinfectsystem/useRecord/action/ButtJointForeignTousseApplicationAction.java (revision 30941) @@ -0,0 +1,426 @@ +package com.forgon.disinfectsystem.useRecord.action; + +import java.util.List; + +import jxl.common.Logger; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.struts2.convention.annotation.Action; +import org.apache.struts2.convention.annotation.Namespace; +import org.apache.struts2.convention.annotation.ParentPackage; + +import com.forgon.Constants; +import com.forgon.directory.acegi.tools.AcegiHelper; +import com.forgon.directory.model.OrgUnit; +import com.forgon.disinfectsystem.basedatamanager.supplier.service.SupplierManager; +import com.forgon.disinfectsystem.basedatamanager.supplyroomconfig.service.SupplyRoomConfigManager; +import com.forgon.disinfectsystem.common.CssdUtils; +import com.forgon.disinfectsystem.datasynchronization.model.PatientInfoVO; +import com.forgon.disinfectsystem.datasynchronization.service.DataSynchronizationManager; +import com.forgon.disinfectsystem.entity.basedatamanager.materialinstance.MaterialInstance; +import com.forgon.disinfectsystem.entity.basedatamanager.supplier.Supplier; +import com.forgon.disinfectsystem.entity.basedatamanager.supplyroomconfig.SupplyRoomConfig; +import com.forgon.disinfectsystem.entity.basedatamanager.toussedefinition.TousseDefinition; +import com.forgon.disinfectsystem.entity.foreigntousseapplication.ForeignTousseApplication; +import com.forgon.disinfectsystem.entity.invoicemanager.InvoicePlan; +import com.forgon.disinfectsystem.foreigntousseapplication.service.ForeignTousseApplicationManager; +import com.forgon.log.model.Log; +import com.forgon.log.service.LogManager; +import com.forgon.tools.GB2Alpha; +import com.forgon.tools.GB2WB; +import com.forgon.tools.StrutsParamUtils; +import com.forgon.tools.StrutsResponseUtils; +import com.forgon.tools.db.DatabaseUtil; +import com.forgon.tools.hibernate.ObjectDao; +import com.forgon.tools.util.ConfigUtils; +import com.forgon.tools.util.ForgonDateUtils; + +@ParentPackage(value = "default") +@Namespace(value = "/buttjoint") +@Action(value = "buttJointForeignTousseApplicationAction") +public class ButtJointForeignTousseApplicationAction { + + private Logger logger = Logger.getLogger(this.getClass()); + + private ObjectDao objectDao; + + private SupplyRoomConfigManager supplyRoomConfigManager; + + private ForeignTousseApplicationManager foreignTousseApplicationManager; + + private DataSynchronizationManager dataSynchronizationManager; + + private SupplierManager supplierManager; + + private LogManager appLogManager; + + public void setObjectDao(ObjectDao objectDao) { + this.objectDao = objectDao; + } + + public void setSupplyRoomConfigManager( + SupplyRoomConfigManager supplyRoomConfigManager) { + this.supplyRoomConfigManager = supplyRoomConfigManager; + } + + public void setForeignTousseApplicationManager( + ForeignTousseApplicationManager foreignTousseApplicationManager) { + this.foreignTousseApplicationManager = foreignTousseApplicationManager; + } + + public void setDataSynchronizationManager( + DataSynchronizationManager dataSynchronizationManager) { + this.dataSynchronizationManager = dataSynchronizationManager; + } + + public void setSupplierManager(SupplierManager supplierManager) { + this.supplierManager = supplierManager; + } + + public void setAppLogManager(LogManager appLogManager) { + this.appLogManager = appLogManager; + } + + //单号前缀 + final static String SERIALNUMBER_PREFIX = "SYNC_"; + + public void submitForeignTousseApplication(){ + String param = StrutsParamUtils.getPraramValue("arg0", ""); + String result = submitForeignTousseApplication(param); + JSONObject jSONObj = JSONObject.fromObject(result); + + StrutsResponseUtils.output(jSONObj); + } + + private String submitForeignTousseApplication(String param) { + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,参数param=" + param); + logger.debug("调用外来器械包接口的submitForeignTousseApplication方法,参数param=" + param); + JSONObject returnJSONObject = new JSONObject(); + returnJSONObject.put("result" , "0"); + returnJSONObject.put("message",""); + JSONObject paramJson = null; + try { + if(StringUtils.isBlank(param)){ + returnJSONObject.put("message","HOSPITAL_NUMBER节点不能为空"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return returnJSONObject.toString(); + } + param = param.replaceAll("\t", ""); + param = param.replaceAll("\n", ""); + param = param.replaceAll("\r", ""); + paramJson = JSONObject.fromObject(param); + } catch (Exception e) { + returnJSONObject.put("message","参数格式不对"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return returnJSONObject.toString(); + } + + try { + SupplyRoomConfig supplyRoomConfig = supplyRoomConfigManager.getSystemParamsObj(); + String serialNumber = SERIALNUMBER_PREFIX + paramJson.optString("SERIALNUMBER"); + + JSONArray jsonArray = new JSONArray(); + Object itemsJson = (Object)paramJson.opt("items"); + if(itemsJson == null){ + returnJSONObject.put("message","未找到items节点"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return returnJSONObject.toString(); + } + if(itemsJson instanceof JSONArray){ + JSONArray itemsJsonArray = (JSONArray)itemsJson; + if(itemsJsonArray.size() == 0){ + returnJSONObject.put("message","未找到items节点下的item节点"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return returnJSONObject.toString(); + } + for (int i = 0; i < itemsJsonArray.size(); i++) { + JSONObject itemsJsonObject = itemsJsonArray.optJSONObject(i); + Long tousseDefinitionId = itemsJsonObject.optLong("TOUSSEDEFINITION_ID"); + if(!DatabaseUtil.isPoIdValid(tousseDefinitionId)){ + returnJSONObject.put("message","TOUSSEDEFINITION_ID不能为空且只能为数字"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return returnJSONObject.toString(); + } + TousseDefinition tousseDefinition = (TousseDefinition)objectDao.getBySql(TousseDefinition.class.getSimpleName(), "where id=" + tousseDefinitionId); + if(tousseDefinition == null){ + returnJSONObject.put("message","未找到TOUSSEDEFINITION_ID为"+ tousseDefinitionId +"的外来器械包定义"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return returnJSONObject.toString(); + } + if(StringUtils.equals(Constants.STR_YES, tousseDefinition.getIsDisable())){ + returnJSONObject.put("message","【"+ tousseDefinition.getName() +"】已停用,TOUSSEDEFINITION_ID为"+ tousseDefinitionId); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return returnJSONObject.toString(); + } + JSONObject foreignTousseInfoJsonObject = new JSONObject(); + foreignTousseInfoJsonObject.put("amount", 1); + foreignTousseInfoJsonObject.put("tousseName", tousseDefinition.getName()); + foreignTousseInfoJsonObject.put("supplierName", itemsJsonObject.optString("SUPPLIER_NAME")); + if(!StringUtils.equals(tousseDefinition.getSupplierName(), itemsJsonObject.optString("SUPPLIER_NAME"))){ + returnJSONObject.put("message","根据TOUSSEDEFINITION_ID查询到的外来器械包的供应商名称为"+ tousseDefinition.getSupplierName() +",与所传参数的供应商名称"+ itemsJsonObject.optString("SUPPLIER_NAME") +"不一致"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return returnJSONObject.toString(); + } + foreignTousseInfoJsonObject.put("price", + tousseDefinition.getPrice() == null || tousseDefinition.getPrice() == 0 ? supplyRoomConfig.getForeignToussePrice() : tousseDefinition.getPrice()); + + JSONArray materialsJsonArray = new JSONArray(); + List materialInstanceList = tousseDefinition.getMaterialInstances(); + if(CollectionUtils.isNotEmpty(materialInstanceList)){ + for (MaterialInstance materialInstance : materialInstanceList) { + JSONObject materialJson = new JSONObject(); + materialJson.put("materialName", CssdUtils.getMaterialName(materialInstance.getMaterialDefinition())); + materialJson.put("amount", materialInstance.getCount()); + materialJson.put("includeImplant", materialInstance.getIsImplant()); + materialsJsonArray.add(materialJson); + } + foreignTousseInfoJsonObject.put("materials", materialsJsonArray); + }else{ + returnJSONObject.put("message","TOUSSEDEFINITION_ID为"+ tousseDefinitionId +"的外来器械包无材料,基础数据有误"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return returnJSONObject.toString(); + } + jsonArray.add(foreignTousseInfoJsonObject); + } + } else if(itemsJson instanceof JSONObject){ + JSONObject itemsJsonObject = (JSONObject)itemsJson; + JSONObject itemJsonObject = itemsJsonObject.optJSONObject("item"); + if(itemJsonObject == null){ + returnJSONObject.put("message","未找到items下的item节点"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return returnJSONObject.toString(); + } + Long tousseDefinitionId = itemJsonObject.optLong("TOUSSEDEFINITION_ID"); + if(!DatabaseUtil.isPoIdValid(tousseDefinitionId)){ + returnJSONObject.put("message","TOUSSEDEFINITION_ID不能为空且只能为数字"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return returnJSONObject.toString(); + } + TousseDefinition tousseDefinition = (TousseDefinition)objectDao.getBySql(TousseDefinition.class.getSimpleName(), "where id=" + tousseDefinitionId); + if(tousseDefinition == null){ + returnJSONObject.put("message","未找到TOUSSEDEFINITION_ID为"+ tousseDefinitionId +"的外来器械包定义"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return returnJSONObject.toString(); + } + JSONObject foreignTousseInfoJsonObject = new JSONObject(); + foreignTousseInfoJsonObject.put("amount", 1); + foreignTousseInfoJsonObject.put("tousseName", tousseDefinition.getName()); + foreignTousseInfoJsonObject.put("supplierName", itemJsonObject.optString("SUPPLIER_NAME")); + if(!StringUtils.equals(tousseDefinition.getSupplierName(), itemJsonObject.optString("SUPPLIER_NAME"))){ + returnJSONObject.put("message","根据TOUSSEDEFINITION_ID查询到的外来器械包的供应商名称为"+ tousseDefinition.getSupplierName() +",与所传参数的供应商名称"+ itemJsonObject.optString("SUPPLIER_NAME") +"不一致"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return returnJSONObject.toString(); + } + foreignTousseInfoJsonObject.put("price", + tousseDefinition.getPrice() == null || tousseDefinition.getPrice() == 0 ? supplyRoomConfig.getForeignToussePrice() : tousseDefinition.getPrice()); + + JSONArray materialsJsonArray = new JSONArray(); + List materialInstanceList = tousseDefinition.getMaterialInstances(); + if(CollectionUtils.isNotEmpty(materialInstanceList)){ + for (MaterialInstance materialInstance : materialInstanceList) { + JSONObject materialJson = new JSONObject(); + materialJson.put("materialName", CssdUtils.getMaterialName(materialInstance.getMaterialDefinition())); + materialJson.put("amount", materialInstance.getCount()); + materialJson.put("includeImplant", materialInstance.getIsImplant()); + materialsJsonArray.add(materialJson); + } + foreignTousseInfoJsonObject.put("materials", materialsJsonArray); + }else{ + returnJSONObject.put("message","TOUSSEDEFINITION_ID为"+ tousseDefinitionId +"的外来器械包无材料,基础数据有误"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return returnJSONObject.toString(); + } + jsonArray.add(foreignTousseInfoJsonObject); + }else{ + returnJSONObject.put("message","所传的items的格式有误"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return returnJSONObject.toString(); + } + //供应商联系人、供应商联系电话 + String supplierContactUser = null, supplierContactPhone = null; + //查询第一个外来器械包的供应商作为外来器械申请单的联系人与联系电话 + if(jsonArray != null && jsonArray.size() > 0){ + JSONObject firstSupplierJsonObject = jsonArray.optJSONObject(0); + String supplierName = firstSupplierJsonObject.optString("supplierName"); + //根据供应商名称及厂商类型查询供应商 + if(StringUtils.isNotBlank(supplierName)){ + Supplier supplier = supplierManager.getFirst(" companyName = '"+ supplierName +"' and rentTousse = '"+ Supplier.SUPPLIER_TYPE_RENTTOUSSE +"'"); + if(supplier != null){ + supplierContactUser = supplier.getContact(); + supplierContactPhone = supplier.getCellPhone(); + } + } + } + String foreignTousseInfo = jsonArray.toString(); + //住院号 + String hospitalNumber = paramJson.optString("HOSPITAL_NUMBER"); + if(StringUtils.isBlank(hospitalNumber)){ + returnJSONObject.put("message","HOSPITAL_NUMBER节点不能为空"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return returnJSONObject.toString(); + } + String applicant = paramJson.optString("APPLICANT"); + if(StringUtils.isBlank(applicant)){ + returnJSONObject.put("message","APPLICANT节点不能为空"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return returnJSONObject.toString(); + } + String departName = ""; + String departCode = ""; + String settlementDepartName = ""; + String settlementDepartCode = ""; + + // 外来器械申请单申请科室编码(HIS系统传送外来器械申请单到追溯系统时,申请单的申请科室和结算科室可通过配置文件配置DGKHYY-27) + String foreignTousseApplicationAppDepartCodeForWSInterface = + ConfigUtils.getSystemSetConfigByName("foreignTousseApplicationAppDepartCodeForWSInterface", ""); + if(StringUtils.isBlank(foreignTousseApplicationAppDepartCodeForWSInterface)){ + departCode = foreignTousseApplicationAppDepartCodeForWSInterface; + @SuppressWarnings("unchecked") + List ouList = objectDao.findByProperty(OrgUnit.class.getSimpleName(), "orgUnitCoding", departCode); + if(CollectionUtils.isEmpty(ouList)){ + returnJSONObject.put("message","默认申请科室不存在,科室编码为:" + departCode); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return returnJSONObject.toString(); + } + departName = ouList.get(0).getName(); + }else{ + departName = paramJson.optString("DEPART_NAME"); + if(StringUtils.isBlank(departName)){ + returnJSONObject.put("message","DEPART_NAME节点不能为空"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return returnJSONObject.toString(); + } + departCode = paramJson.optString("DEPART_CODE"); + if(StringUtils.isBlank(departCode)){ + returnJSONObject.put("message","DEPART_CODE节点不能为空"); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return returnJSONObject.toString(); + } + } + + // 外来器械申请单结算科室编码(HIS系统传送外来器械申请单到追溯系统时,申请单的申请科室和结算科室可通过配置文件配置DGKHYY-27) + String foreignTousseApplicationsettleAccountsDepartCodeForWSInterface = + ConfigUtils.getSystemSetConfigByName("foreignTousseApplicationsettleAccountsDepartCodeForWSInterface", ""); + if(StringUtils.isBlank(foreignTousseApplicationsettleAccountsDepartCodeForWSInterface)){ + settlementDepartCode = foreignTousseApplicationsettleAccountsDepartCodeForWSInterface; + @SuppressWarnings("unchecked") + List ouList = objectDao.findByProperty(OrgUnit.class.getSimpleName(), "orgUnitCoding", settlementDepartCode); + if(CollectionUtils.isEmpty(ouList)){ + returnJSONObject.put("message","默认结算科室不存在,科室编码为:" + settlementDepartCode); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return returnJSONObject.toString(); + } + settlementDepartName = ouList.get(0).getName(); + }else{ + settlementDepartName = paramJson.optString("SETTLEMENT_DEPART_NAME"); + settlementDepartCode = paramJson.optString("SETTLEMENT_DEPART_CODE"); + } + + String applicationTime = paramJson.optString("APPLICATION_TIME"); + ForeignTousseApplication orginalForeignTousseApplication = foreignTousseApplicationManager.getFirst("serialNumber='"+ serialNumber +"'"); + //调用外来器械申请单业务方法 + ForeignTousseApplication foreignTousseApplication = null; + //如果根据单号能找到外来器械申请单,那就进行干预修改的操作 + if(orginalForeignTousseApplication == null){ + foreignTousseApplication = new ForeignTousseApplication(); + foreignTousseApplication.setType(InvoicePlan.TYPE_FOREIGNTOUSSEAPPLIACTION); + foreignTousseApplication.setSerialNumber(serialNumber); + foreignTousseApplication.setApplicant(applicant); + foreignTousseApplication.setDepart(departName); + foreignTousseApplication.setDepartCoding(departCode); + foreignTousseApplication.setSettleAccountsDepart(settlementDepartName); + if(StringUtils.isBlank(foreignTousseApplication.getSettleAccountsDepart())){ + foreignTousseApplication.setSettleAccountsDepart(foreignTousseApplication.getDepart()); + } + foreignTousseApplication.setSettleAccountsDepartCoding(settlementDepartCode); + if(StringUtils.isBlank(foreignTousseApplication.getSettleAccountsDepartCoding())){ + foreignTousseApplication.setSettleAccountsDepartCoding(foreignTousseApplication.getSettleAccountsDepartCoding()); + } + foreignTousseApplication.setApplicationTime(ForgonDateUtils.safelyParseDate(applicationTime)); + foreignTousseApplication.setHospitalNumber(hospitalNumber); + PatientInfoVO[] patientInfoVOs = dataSynchronizationManager.findPatientInfoByHospitalNum(hospitalNumber); + if(patientInfoVOs != null && patientInfoVOs.length > 0){ + foreignTousseApplication.setHospitalNumber(hospitalNumber); + foreignTousseApplication.setPatient(patientInfoVOs[0].getPatientName()); + foreignTousseApplication.setPatientAge(patientInfoVOs[0].getPatientAge()); + foreignTousseApplication.setPatientArea(patientInfoVOs[0].getPatientArea()); + foreignTousseApplication.setPatientSex(patientInfoVOs[0].getPatientSex()); + foreignTousseApplication.setDoctor(patientInfoVOs[0].getDoctorName()); + foreignTousseApplication.setOperationRoom(patientInfoVOs[0].getOpRoomId()); + foreignTousseApplication.setAscriptionDepartment(patientInfoVOs[0].getAscriptionDepartment()); + if(StringUtils.isNotBlank(patientInfoVOs[0].getOperationTime())){ + foreignTousseApplication.setOperationTime(ForgonDateUtils.safelyParseDate(patientInfoVOs[0].getOperationTime())); + } + foreignTousseApplication.setRoomNumber(patientInfoVOs[0].getRoomNumber()); + foreignTousseApplication.setSurgery(patientInfoVOs[0].getOperation()); + } + foreignTousseApplication.setPackageStatus(InvoicePlan.RECYCLINGSTATUS_AWAITRECEIVE); + foreignTousseApplication.setOrderByFiled(InvoicePlan.DELIVER_AWAITDELIVER); + // 设置五笔码和拼音码 + foreignTousseApplication.setSpelling(GB2Alpha.string2Alpha(departName)); + foreignTousseApplication.setWbCode(GB2WB.getWBCode(departName)); + //设置外来器械申请单的供应商联系人与联系电话 + foreignTousseApplication.setSupplierContactName(supplierContactUser); + foreignTousseApplication.setSupplierPhoneNumber(supplierContactPhone); + foreignTousseApplicationManager.saveOrUpdate(foreignTousseApplication, foreignTousseInfo, ForeignTousseApplication.ACTION_TYPE_ADD); + }else{ + if(!StringUtils.equals(orginalForeignTousseApplication.getApplicant(), applicant)){ + orginalForeignTousseApplication.setApplicant(applicant); + } + if(!StringUtils.equals(orginalForeignTousseApplication.getDepart(), departName)){ + orginalForeignTousseApplication.setDepart(departName); + } + if(!StringUtils.equals(orginalForeignTousseApplication.getDepartCoding(), departCode)){ + orginalForeignTousseApplication.setDepartCoding(departCode); + } + if(StringUtils.isBlank(settlementDepartName)){ + orginalForeignTousseApplication.setSettleAccountsDepart(departName); + }else if(!StringUtils.equals(orginalForeignTousseApplication.getSettleAccountsDepart(), settlementDepartName)){ + orginalForeignTousseApplication.setSettleAccountsDepart(settlementDepartName); + } + if(StringUtils.isBlank(settlementDepartCode)){ + orginalForeignTousseApplication.setSettleAccountsDepartCoding(departCode); + }else if(!StringUtils.equals(orginalForeignTousseApplication.getSettleAccountsDepartCoding(), settlementDepartCode)){ + orginalForeignTousseApplication.setSettleAccountsDepartCoding(settlementDepartCode); + } + orginalForeignTousseApplication.setApplicationTime(ForgonDateUtils.safelyParseDate(applicationTime)); + if(!StringUtils.equals(orginalForeignTousseApplication.getHospitalNumber(), hospitalNumber)){ + orginalForeignTousseApplication.setHospitalNumber(hospitalNumber); + PatientInfoVO[] patientInfoVOs = dataSynchronizationManager.findPatientInfoByHospitalNum(hospitalNumber); + if(patientInfoVOs != null && patientInfoVOs.length > 0){ + orginalForeignTousseApplication.setHospitalNumber(hospitalNumber); + orginalForeignTousseApplication.setPatient(patientInfoVOs[0].getPatientName()); + orginalForeignTousseApplication.setPatientAge(patientInfoVOs[0].getPatientAge()); + orginalForeignTousseApplication.setPatientArea(patientInfoVOs[0].getPatientArea()); + orginalForeignTousseApplication.setPatientSex(patientInfoVOs[0].getPatientSex()); + orginalForeignTousseApplication.setDoctor(patientInfoVOs[0].getDoctorName()); + orginalForeignTousseApplication.setOperationRoom(patientInfoVOs[0].getOpRoomId()); + orginalForeignTousseApplication.setAscriptionDepartment(patientInfoVOs[0].getAscriptionDepartment()); + if(StringUtils.isNotBlank(patientInfoVOs[0].getOperationTime())){ + orginalForeignTousseApplication.setOperationTime(ForgonDateUtils.safelyParseDate(patientInfoVOs[0].getOperationTime())); + } + orginalForeignTousseApplication.setRoomNumber(patientInfoVOs[0].getRoomNumber()); + orginalForeignTousseApplication.setSurgery(patientInfoVOs[0].getOperation()); + } + } + //设置外来器械申请单的供应商联系人与联系电话 + orginalForeignTousseApplication.setSupplierContactName(supplierContactUser); + orginalForeignTousseApplication.setSupplierPhoneNumber(supplierContactPhone); + objectDao.saveOrUpdate(orginalForeignTousseApplication); + } + returnJSONObject.put("result" , "1"); + } catch (RuntimeException e) { + e.printStackTrace(); + returnJSONObject.put("message",e.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + returnJSONObject.put("message","生成外来器械申请单失败"); + } + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_QUERY, "调用外来器械包接口的submitForeignTousseApplication方法,返回结果=" + returnJSONObject); + return returnJSONObject.toString(); + } + +}