| | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.RandomUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.core.util.XmlUtil; |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.json.JSONArray; |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ltkj.common.core.domain.AjaxResult; |
| | | import com.ltkj.common.core.domain.entity.SysDept; |
| | | import com.ltkj.common.utils.AgeResult; |
| | | import com.ltkj.common.utils.DateUtils; |
| | | import com.ltkj.hosp.domain.*; |
| | | import com.ltkj.hosp.hisDto.OutpintestapplyDetailsDto; |
| | | import com.ltkj.hosp.pacsDto.SavePacsApply; |
| | | import com.ltkj.hosp.service.*; |
| | | import com.ltkj.hosp.sqlDomain.LtkjExamJcsqd; |
| | | import com.ltkj.system.service.ISysConfigService; |
| | | import com.ltkj.system.service.ISysDeptService; |
| | | import com.ltkj.web.controller.his.HisApiGetMethodService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import javax.xml.soap.*; |
| | | |
| | | /** |
| | | * @Company: 西安路泰科技有限公司 |
| | |
| | | private LtkjEjjfxmzdService ltkjEjjfxmzdService; |
| | | @Autowired |
| | | private LtkjJianchajianyanTreeService ltkjJianchajianyanTreeService; |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | @Autowired |
| | | private ITbTransitionService transitionService; |
| | | @Autowired |
| | | private ITjOrderService tjOrderService; |
| | | @Autowired |
| | | private LtkjExamJcsqdService ltkjExamJcsqdService; |
| | | |
| | | |
| | | /** |
| | |
| | | public int saveProjects(TjOrder tjOrder, TjCustomer tjCustomer, List<TjProject> projects, JSONArray array, ArrayList<SavePacsApply> successPacsList, ArrayList<SavePacsApply> errorPacsList) { |
| | | int allTotal = 0; |
| | | if (projects != null && !projects.isEmpty()) { |
| | | String dept = configService.selectConfigByKey("request_default_dept"); |
| | | String ysbm = configService.selectConfigByKey("request_default_ysbm"); |
| | | String ysmc = configService.selectConfigByKey("request_default_ysmc"); |
| | | for (TjProject project : projects) { |
| | | if (0 == project.getProParentId() && project.getProPrice().compareTo(BigDecimal.ZERO) != 0) { |
| | | if (null != project.getHisXmbm()) { |
| | |
| | | savePacsApply.setCheckPosition("-"); |
| | | savePacsApply.setAmount(project.getProPrice()); |
| | | savePacsApply.setApplyDate(DateFormatUtils.format(date, "yyyy-MM-dd HH:mm:ss")); |
| | | savePacsApply.setApplyDepment("0101"); |
| | | savePacsApply.setApplyDepment(dept); |
| | | savePacsApply.setApplyDepmentName("体检中心"); |
| | | savePacsApply.setApplyDoctor("00029"); |
| | | savePacsApply.setApplyDoctorName("王健萍"); |
| | | savePacsApply.setExecDepment("0101"); |
| | | savePacsApply.setApplyDoctor(ysbm); |
| | | savePacsApply.setApplyDoctorName(ysmc); |
| | | savePacsApply.setExecDepment(dept); |
| | | savePacsApply.setExecDepmentName("体检中心"); |
| | | savePacsApply.setCreateTime(savePacsApply.getApplyDate()); |
| | | // TODO 检查设备 |
| | |
| | | // exec usp_tjjk_pacsjg ‘体检号’ |
| | | // 调用更新状态: |
| | | // exec usp_tjjk_pacszt ‘体检号’ |
| | | |
| | | |
| | | /** |
| | | * 调用pacs申请单推送 |
| | | * xml传递 |
| | | */ |
| | | public boolean OrderAdd(TjCustomer customer,TjOrder tjOrder){ |
| | | String hospbm = configService.selectConfigByKey("common_api_service_hospbm"); |
| | | |
| | | List<TbTransition> detailList = transitionService.getTbTransitionListByCusId(customer.getCusIdcard(), tjOrder.getCardId()); |
| | | LambdaQueryWrapper<TjProject> wq = new LambdaQueryWrapper<>(); |
| | | wq.in(TjProject::getProId, detailList.stream().map(TbTransition::getParentProId).collect(Collectors.toList())); |
| | | wq.in(TjProject::getDeptId, deptService.getJcDeptIds()); |
| | | List<TjProject> projects = projectService.list(wq); |
| | | HashMap<String, Object> root = new HashMap<>(); |
| | | HashMap<String, Object> hashMap = new HashMap<>(); |
| | | |
| | | String xmlRequest = ""; |
| | | |
| | | MessageFactory messageFactory = null; |
| | | try { |
| | | // 创建SOAP消息 |
| | | messageFactory = MessageFactory.newInstance(); |
| | | SOAPMessage soapMessage = messageFactory.createMessage(); |
| | | // 创建SOAP Envelope |
| | | SOAPPart soapPart = soapMessage.getSOAPPart(); |
| | | SOAPEnvelope envelope = soapPart.getEnvelope(); |
| | | envelope.addNamespaceDeclaration("xmlns", "http://tempuri.org/"); |
| | | |
| | | // 创建SOAP Body |
| | | SOAPBody soapBody = envelope.getBody(); |
| | | SOAPElement rootElement = soapBody.addChildElement("OrderAdd", "xmlns"); |
| | | rootElement.addChildElement("dataSourceName").addTextNode("hisDataSource"); |
| | | |
| | | // PatientInfor 部分 |
| | | SOAPElement patientInfor = rootElement.addChildElement("PatientInfor"); |
| | | if (customer.getCusSex() == 0) patientInfor.addChildElement("PatientSex").addTextNode("M"); |
| | | else if (customer.getCusSex() == 1) patientInfor.addChildElement("PatientSex").addTextNode("F"); |
| | | else patientInfor.addChildElement("PatientSex").addTextNode("O"); |
| | | patientInfor.addChildElement("PatBirthday").addTextNode(new SimpleDateFormat("yyyy-MM-dd").format(customer.getCusBrithday())); |
| | | patientInfor.addChildElement("VisitNo").addTextNode(tjOrder.getTjNumber()); |
| | | patientInfor.addChildElement("PatientId").addTextNode(String.valueOf(customer.getCusId())); |
| | | patientInfor.addChildElement("HospitalID").addTextNode("shanxiqinxamjyy"); |
| | | patientInfor.addChildElement("IdCard").addTextNode(customer.getCusIdcard()); |
| | | patientInfor.addChildElement("PatientName").addTextNode(customer.getCusName()); |
| | | patientInfor.addChildElement("PatType").addTextNode("P"); |
| | | |
| | | // ExamItemList 部分 |
| | | SOAPElement examItemList = rootElement.addChildElement("ExamItemList"); |
| | | |
| | | String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); |
| | | for (TjProject project : projects) { |
| | | SOAPElement examItem = examItemList.addChildElement("ExamItem"); |
| | | examItem.addChildElement("HisID").addTextNode(tjOrder.getTjNumber() + String.valueOf(project.getProId()).substring(String.valueOf(project.getProId()).length() - 4)); |
| | | examItem.addChildElement("EmergencyFlag").addTextNode("0"); |
| | | examItem.addChildElement("ExamItemID").addTextNode(project.getHisXmbm()); |
| | | examItem.addChildElement("ExamItemName").addTextNode(project.getHisXmmc()); |
| | | examItem.addChildElement("OrderDT").addTextNode(date); |
| | | SysDept dept = deptService.getById(project.getDeptId()); |
| | | examItem.addChildElement("Modality").addTextNode(dept.getModality()); |
| | | examItem.addChildElement("ChargeFlag").addTextNode("1"); |
| | | } |
| | | |
| | | // 保存SOAP消息 |
| | | soapMessage.saveChanges(); |
| | | |
| | | // 打印生成的SOAP请求 |
| | | System.out.println("生成的SOAP请求内容:"); |
| | | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
| | | soapMessage.writeTo(byteArrayOutputStream); |
| | | xmlRequest = byteArrayOutputStream.toString("UTF-8"); |
| | | } catch (SOAPException | IOException e) { |
| | | log.error("SOAP异常 ->{}",String.valueOf(e)); |
| | | } |
| | | |
| | | |
| | | // HashMap<String, Object> patientInfo = new HashMap<>(); |
| | | // patientInfo.put("PatientId",customer.getCusId()); |
| | | // patientInfo.put("VisitNo",tjOrder.getTjNumber()); |
| | | // patientInfo.put("PatType","P"); |
| | | // patientInfo.put("PatientName",customer.getCusName()); |
| | | // if (customer.getCusSex() == 0) patientInfo.put("PatientSex","M"); |
| | | // else if (customer.getCusSex() == 1) patientInfo.put("PatientSex","F"); |
| | | // else patientInfo.put("PatientSex","O"); |
| | | // patientInfo.put("PatBirthday",new SimpleDateFormat("yyyy-MM-dd").format(customer.getCusBrithday())); |
| | | // patientInfo.put("IdCard",customer.getCusIdcard()); |
| | | // patientInfo.put("hospitalid","chkwyy"); |
| | | // patientInfo.put("HospitalID",hospbm); |
| | | // |
| | | // HashMap<String, Object> examItemList = new HashMap<>(); |
| | | // List<Map<String, Object>> examItemsList = new ArrayList<>(); |
| | | String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); |
| | | // |
| | | // for (TjProject project : projects) { |
| | | // HashMap<String, Object> examItem = new HashMap<>(); |
| | | // // 申请单号规则:体检号_project.getProId()后四位 |
| | | // examItem.put("HisID", tjOrder.getTjNumber() + String.valueOf(project.getProId()).substring(String.valueOf(project.getProId()).length() - 4)); |
| | | // examItem.put("EmergencyFlag", "0"); |
| | | // examItem.put("ExamItemID", project.getHisXmbm()); |
| | | // examItem.put("ExamItemName", project.getHisXmmc()); |
| | | // examItem.put("OrderDT", date); |
| | | // |
| | | // SysDept dept = deptService.getById(project.getDeptId()); |
| | | // examItem.put("Modality", dept.getModality()); |
| | | // // 收费标识:1 是收费,0 未收费 |
| | | // examItem.put("ChargeFlag", "1"); |
| | | // |
| | | // examItemsList.add(examItem); // 将每个ExamItem添加到集合 |
| | | // } |
| | | // |
| | | // // 构造最终的ExamItemList |
| | | // examItemList.put("ExamItem", examItemsList); |
| | | // hashMap.put("ExamItemList", examItemList); |
| | | // |
| | | // hashMap.put("PatientInfor", patientInfo); |
| | | // |
| | | // // 将数据封装到根节点 |
| | | // root.put("Root", hashMap); |
| | | // |
| | | // // 使用Hutool将Map转换为XML字符串 |
| | | // String xmlRequest = XmlUtil.mapToXmlStr(root); |
| | | |
| | | String result = "1"; |
| | | log.info("调用pacs传递参数的值为: "+xmlRequest); |
| | | Map<String, Object> map = XmlUtil.xmlToMap(result); |
| | | if (map.get("Code").toString().equals("1")){ |
| | | for (TjProject project : projects) { |
| | | LtkjJianchajianyanTree tree = new LtkjJianchajianyanTree(); |
| | | tree.setCardId(tjOrder.getTjNumber()); |
| | | tree.setPationid(String.valueOf(customer.getCusId())); |
| | | tree.setSqdh(tjOrder.getTjNumber() + String.valueOf(project.getProId()).substring(String.valueOf(project.getProId()).length() - 4)); |
| | | tree.setFyhj(String.valueOf(project.getProPrice())); |
| | | tree.setHisXmdm(project.getHisXmbm()); |
| | | tree.setType("检查"); |
| | | tree.setService("pacs"); |
| | | tree.setTjPrice(String.valueOf(project.getProPrice())); |
| | | LambdaQueryWrapper<LtkjJfzhglmxjfxmzd> wrapper1 = new LambdaQueryWrapper<>(); |
| | | if (project.getSfzhfy().equals("Y")) |
| | | wrapper1.eq(LtkjJfzhglmxjfxmzd::getZhxmdm, project.getHisXmbm()); |
| | | else wrapper1.eq(LtkjJfzhglmxjfxmzd::getXmdm, project.getHisXmbm()); |
| | | List<LtkjJfzhglmxjfxmzd> ltkjJfzhglmxjfxmzds = ltkjJfzhglmxjfxmzdService.list(wrapper1); |
| | | if (ltkjJfzhglmxjfxmzds != null && !ltkjJfzhglmxjfxmzds.isEmpty()) { |
| | | String xmdm = ltkjJfzhglmxjfxmzds.get(0).getXmdm(); |
| | | LambdaQueryWrapper<LtkjMxjfxmzd> wrapper2 = new LambdaQueryWrapper<>(); |
| | | wrapper2.eq(LtkjMxjfxmzd::getXmdm, xmdm); |
| | | LtkjMxjfxmzd mxjfxmzd = ltkjMxjfxmzdService.getOne(wrapper2); |
| | | LambdaQueryWrapper<LtkjEjjfxmzd> wrapper3 = new LambdaQueryWrapper<>(); |
| | | wrapper3.eq(LtkjEjjfxmzd::getEjkmdm, mxjfxmzd.getEjkmdm()); |
| | | LtkjEjjfxmzd ejjfxmzd = ltkjEjjfxmzdService.getOne(wrapper3); |
| | | tree.setXmfl(ejjfxmzd.getYjkmdm()); |
| | | } |
| | | tree.setCreateTime(DateUtil.date()); |
| | | ltkjJianchajianyanTreeService.save(tree); |
| | | |
| | | |
| | | LtkjExamJcsqd jcsqd = new LtkjExamJcsqd(); |
| | | jcsqd.setTjh(tjOrder.getTjNumber()); |
| | | jcsqd.setTmh(tree.getSqdh()); |
| | | jcsqd.setJcxmid(tree.getHisXmdm()); |
| | | jcsqd.setJcxmmc(project.getHisXmmc()); |
| | | jcsqd.setSqsj(date); |
| | | ltkjExamJcsqdService.save(jcsqd); |
| | | } |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 调用pacs申请单作废 |
| | | * @param sqdh 申请单号 |
| | | * @param czrid 操作人编码 |
| | | * @return |
| | | */ |
| | | public boolean OrderDelete(String sqdh,String czrid){ |
| | | HashMap<String, Object> root = new HashMap<>(); |
| | | HashMap<String, Object> hashMap = new HashMap<>(); |
| | | LtkjJianchajianyanTree tree = ltkjJianchajianyanTreeService.getOne(new LambdaQueryWrapper<LtkjJianchajianyanTree>().eq(LtkjJianchajianyanTree::getSqdh, sqdh)); |
| | | String pationid = tree.getPationid(); |
| | | hashMap.put("PatientId",pationid); |
| | | hashMap.put("PatType","P"); |
| | | hashMap.put("Operator",czrid); |
| | | hashMap.put("HisID",sqdh); |
| | | root.put("Root",hashMap); |
| | | String result = HttpRequest.post("").body(XmlUtil.mapToXmlStr(root)).contentType("application/xml;charset:utf-8;").execute().body(); |
| | | Map<String, Object> map = XmlUtil.xmlToMap(result); |
| | | if (map.get("Code").toString().equals("1")){ |
| | | ltkjJianchajianyanTreeService.removeById(tree); |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | } |