| | |
| | | Map<String, String> map = new HashMap<>(); |
| | | LoginUser loginUser = getLoginUser(); |
| | | SysUser user = loginUser.getUser(); |
| | | String detpId = user.getDeptId().toString(); |
| | | String deptcodes = user.getDeptCode().toString(); |
| | | String userName = user.getUserName(); |
| | | map.put("deptId", detpId); |
| | | map.put("deptcodes", deptcodes); |
| | | map.put("userName", userName); |
| | | return map; |
| | | } |
| | |
| | | import com.ruoyi.common.constant.HttpStatus; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.smartor.domain.PatArchiveOthreInfo; |
| | | import com.smartor.domain.PatMedReq; |
| | |
| | | @ApiOperation("æ¥è¯¢é¨è¯çç
人次å人æ°") |
| | | public AjaxResult selectPatMedOuthospCount(@RequestBody PatMedReq patMedReq) { |
| | | SysUser user = getLoginUser().getUser(); |
| | | // List<String> deptCode = new ArrayList<>(); |
| | | // for (Map<String, Object> map : user.getBelongDepts()) { |
| | | // if (ObjectUtils.isNotEmpty(map.get("deptCode"))) deptCode.add(map.get("deptCode").toString()); |
| | | // } |
| | | // patMedReq.setDeptcodeList(deptCode); |
| | | patMedReq.setOrgid(user.getOrgid()); |
| | | PatMedRes patMedRes = patMedOuthospService.selectPatMedOuthospCount(patMedReq); |
| | | return success(patMedRes); |
| | |
| | | util.exportExcel(response, list, "æ£è
é¨è¯è®°å½æ°æ®"); |
| | | } |
| | | |
| | | /** |
| | | * è·åæ£è
é¨è¯è®°å½è¯¦ç»ä¿¡æ¯ |
| | | */ |
| | | @ApiOperation("è·åæ£è
é¨è¯è®°å½è¯¦ç»ä¿¡æ¯") |
| | | @ApiImplicitParam(name = "getInfo", value = "主é®ID", dataType = "long", dataTypeClass = Long.class) |
| | | //@PreAuthorize("@ss.hasPermi('smartor:patouthosp:query')") |
| | | @GetMapping(value = "getInfo/{id}") |
| | | public AjaxResult getInfo(@PathVariable("id") Long id) { |
| | | return success(patMedOuthospService.selectPatMedOuthospById(id)); |
| | | } |
| | | // /** |
| | | // * è·åæ£è
é¨è¯è®°å½è¯¦ç»ä¿¡æ¯ |
| | | // */ |
| | | // @ApiOperation("è·åæ£è
é¨è¯è®°å½è¯¦ç»ä¿¡æ¯") |
| | | // @ApiImplicitParam(name = "getInfo", value = "主é®ID", dataType = "long", dataTypeClass = Long.class) |
| | | // //@PreAuthorize("@ss.hasPermi('smartor:patouthosp:query')") |
| | | // @GetMapping(value = "getInfo/{id}") |
| | | // public AjaxResult getInfo(@PathVariable("id") Long id) { |
| | | // return success(patMedOuthospService.selectPatMedOuthospById(id)); |
| | | // } |
| | | |
| | | /** |
| | | * æ°å¢æ£è
é¨è¯è®°å½ |
| | |
| | | */ |
| | | @ApiOperation("å½åç»å½ç¨æ·çé¨è¯ãå¨é¢ãåºé¢ç
人çç»è®¡æ
åµ") |
| | | @GetMapping("/getPatCount") |
| | | public TableDataInfo getPatCount(@RequestParam("deptIds") String detpIds, @RequestParam("dcCodes") String dcCodes) { |
| | | public TableDataInfo getPatCount(@RequestParam("deptcodes") String deptcodes, @RequestParam("dcCodes") String dcCodes) { |
| | | //è·åå½åç»é人 |
| | | Map<String, String> deptAndDocID = DeptUtils.getDeptAndDocID(); |
| | | if (StringUtils.isEmpty(detpIds)) { |
| | | detpIds = deptAndDocID.get("deptId"); |
| | | if (StringUtils.isEmpty(deptcodes)) { |
| | | deptcodes = deptAndDocID.get("deptcodes"); |
| | | } |
| | | if (StringUtils.isEmpty(dcCodes)) { |
| | | dcCodes = deptAndDocID.get("userName"); |
| | | } |
| | | |
| | | List<PerSonWorkbenchDto> patCount = personWorkbenchService.getPatCount(detpIds, dcCodes); |
| | | List<PerSonWorkbenchDto> patCount = personWorkbenchService.getPatCount(deptcodes, dcCodes); |
| | | return getDataTable(patCount); |
| | | } |
| | | |
| | |
| | | @ApiOperation("å½åç»å½ç¨æ·çé¨è¯ãå¨é¢ãåºé¢ç
人çç»è®¡æ
åµ") |
| | | //@PreAuthorize("@ss.hasPermi('system:tag:list')") |
| | | @GetMapping("/getTaskInfo") |
| | | public TableDataInfo getTaskInfo(@RequestParam("deptIds") String detpIds, @RequestParam("dcCodes") String dcCodes) { |
| | | public TableDataInfo getTaskInfo(@RequestParam("deptcode") String deptcode, @RequestParam("dcCodes") String dcCodes) { |
| | | //è·åå½åç»é人 |
| | | Map<String, String> deptAndDocID = DeptUtils.getDeptAndDocID(); |
| | | if (StringUtils.isEmpty(detpIds)) { |
| | | detpIds = deptAndDocID.get("deptId"); |
| | | if (StringUtils.isEmpty(deptcode)) { |
| | | deptcode = deptAndDocID.get("deptcode"); |
| | | } |
| | | if (StringUtils.isEmpty(dcCodes)) { |
| | | dcCodes = deptAndDocID.get("userName"); |
| | | } |
| | | |
| | | List<PerSonWorkbenchDto> patCount = personWorkbenchService.getPatCount(detpIds, dcCodes); |
| | | List<PerSonWorkbenchDto> patCount = personWorkbenchService.getPatCount(deptcode, dcCodes); |
| | | return getDataTable(patCount); |
| | | } |
| | | |
| | |
| | | @ApiOperation("æ¥è¯¢ä»»å¡å表") |
| | | //@PreAuthorize("@ss.hasPermi('smartor:ServiceTask:list')") |
| | | @AddOrgId(field = "orgid", paramIndex = 0, campusField = "campusid") |
| | | @PostMapping("list") |
| | | @PostMapping("/list") |
| | | public TableDataInfo list(@RequestBody ServiceTask serviceTask) { |
| | | PageUtils.startPageByPost(serviceTask.getPageNum(), serviceTask.getPageSize()); |
| | | // List<ServiceTask> list = serviceTaskService.selectServiceTaskList(serviceTask); |
| | |
| | | package com.ruoyi.web.controller.smartor; |
| | | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.DtoConversionUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.service.ISvyTaskSingleService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * åä¸ä»»å¡ï¼é®å·ï¼Controller |
| | |
| | | import com.ruoyi.quartz.service.ICollectHISService; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.mapper.*; |
| | | import com.smartor.service.IPatMedOuthospService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | |
| | | private SysUser2Mapper sysUser2Mapper; |
| | | |
| | | @Autowired |
| | | private SysUserRole2Mapper sysUserRoleMapper; |
| | | private IPatMedOuthospService patMedOuthospService; |
| | | |
| | | @Autowired |
| | | private SysDept2Mapper sysDept2Mapper; |
| | |
| | | patMedOuthosp1.setCampusid(patMedOuthosp1.getOrgid()); |
| | | patMedOuthosp1.setOrgid("1"); |
| | | } |
| | | count += patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp1); |
| | | count += patMedOuthospService.updatePatMedOuthosp(patMedOuthosp1); |
| | | } else { |
| | | patMedOuthosp1.setCreateTime(new Date()); |
| | | //å¸ä¸ é¢åºid对åºorgidï¼æºæid为é»è®¤ç1 |
| | |
| | | patMedOuthosp1.setCampusid(patMedOuthosp1.getOrgid()); |
| | | patMedOuthosp1.setOrgid("1"); |
| | | } |
| | | count += patMedOuthospMapper.insertPatMedOuthosp(patMedOuthosp1); |
| | | count += patMedOuthospService.insertPatMedOuthosp(patMedOuthosp1); |
| | | } |
| | | } catch (Exception ex) { |
| | | log.info("忥åºå
¥é¢:" + ex.getMessage()); |
| | |
| | | patArchiveMapper.insertPatArchiveSingle(patArchives.get(0)); |
| | | patMedOuthosp1.setPatid(patArchives.get(0).getId()); |
| | | } |
| | | i = patMedOuthospMapper.insertPatMedOuthosp(patMedOuthosp1); |
| | | i = patMedOuthospService.insertPatMedOuthosp(patMedOuthosp1); |
| | | } |
| | | |
| | | return i; |
| | |
| | | import com.ruoyi.common.enums.MsgLSEnum; |
| | | import com.ruoyi.common.enums.ServiceFromEnum; |
| | | import com.ruoyi.common.enums.WxGZHEnum; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.*; |
| | | import com.ruoyi.common.utils.http.HttpUtils; |
| | | import com.ruoyi.common.utils.sms.smsUtils; |
| | | import com.ruoyi.quartz.service.ICollectHISService; |
| | | import com.ruoyi.quartz.util.CreateDataTable; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.smartor.common.LSHospTokenUtil; |
| | |
| | | |
| | | @Autowired |
| | | ICollectHISService icollectHis; |
| | | |
| | | @Autowired |
| | | CreateDataTable createDataTable; |
| | | |
| | | |
| | | @Value("${appid}") |
| | |
| | | } |
| | | |
| | | /** |
| | | * é¨è¯åè¡¨å®æ¶ä»»å¡ï¼ä» sys_config 读åå表模å¼ï¼ææ¨¡å¼å»ºè¡¨å¹¶å·æ°è§å¾ v_pat_med_outhosp |
| | | * é
ç½® key: outhosp.split.mode |
| | | * quarter -> æå£åº¦ï¼è¡¨å示ä¾ï¼pat_med_outhosp_20260103 |
| | | * year -> æå¹´ï¼è¡¨å示ä¾ï¼pat_med_outhosp_2026 |
| | | * month -> ææï¼è¡¨å示ä¾ï¼pat_med_outhosp_202601 |
| | | * æ¥è¯¢ä¸å°é
ç½®åä¸å表 |
| | | */ |
| | | public void createOuthospQuarterTable() { |
| | | log.info("ãcreateOuthospQuarterTableãå¼å§æ§è¡é¨è¯å表任å¡"); |
| | | createDataTable.createOuthospQuarterTable(); |
| | | } |
| | | |
| | | /** |
| | | * å¤çæ£è
ä¿¡æ¯ï¼è¿å
¥åä»»å¡è¡¨(微信å°ç¨åº) |
| | | */ |
| | | public void dealOutHospInfoXHC() { |
| | |
| | | |
| | | /** |
| | | * é访-è¡¥å¿å¤ç |
| | | * |
| | | * @param serviceSubtask |
| | | */ |
| | | public void sfHandlle(ServiceSubtask serviceSubtask) { |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.quartz.util; |
| | | |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.smartor.mapper.PatMedOuthospMapper; |
| | | import com.smartor.service.IPatMedOuthospService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.sql.DataSource; |
| | | import java.sql.Connection; |
| | | import java.sql.Statement; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * åå»ºæ°æ®åºè¡¨ |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class CreateDataTable { |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | |
| | | @Autowired |
| | | IPatMedOuthospService iPatMedOuthospService; |
| | | |
| | | @Autowired |
| | | PatMedOuthospMapper patMedOuthospMapper; |
| | | |
| | | @Autowired |
| | | private DataSource dataSource; |
| | | |
| | | |
| | | public void createOuthospQuarterTable() { |
| | | log.info("ãcreateOuthospQuarterTableãå¼å§æ§è¡é¨è¯å表任å¡"); |
| | | try { |
| | | // ä» sys_config æ¥è¯¢å表模å¼ï¼ key = outhosp.split.mode |
| | | String splitMode = configService.selectConfigByKey("outhosp.split.mode"); |
| | | if (org.apache.commons.lang3.StringUtils.isBlank(splitMode)) { |
| | | log.info("ãcreateOuthospQuarterTableãæªé
ç½® outhosp.split.modeï¼ä¸æ§è¡å表"); |
| | | return; |
| | | } |
| | | splitMode = splitMode.trim(); |
| | | if (!"å£åº¦".equals(splitMode) && !"å¹´".equals(splitMode) && !"æ".equals(splitMode)) { |
| | | log.warn("ãcreateOuthospQuarterTableãå表模å¼é
ç½®éæ³ï¼{}ï¼åºä¸º quarter/year/monthï¼ä¸æ§è¡å表", splitMode); |
| | | return; |
| | | } |
| | | String newTable = createPartitionTableAndRefreshView(splitMode); |
| | | if (newTable == null) { |
| | | log.info("ãcreateOuthospQuarterTableãå½åå¨æè¡¨å·²åå¨ï¼æ éæä½"); |
| | | } else { |
| | | log.info("ãcreateOuthospQuarterTableãæ°å»ºå表æåï¼{}ï¼å·²å·æ°è§å¾ v_pat_med_outhosp", newTable); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("ãcreateOuthospQuarterTableã建表å¼å¸¸", e); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * ææå®æ¨¡å¼å»ºé¨è¯åè¡¨å¹¶æ´æ°å¨æè§å¾ |
| | | * splitMode: å£åº¦ / å¹´ / æ / ä¸å表 |
| | | * 表åï¼ |
| | | * quarter -> pat_med_outhosp_20260103 |
| | | * year -> pat_med_outhosp_2026 |
| | | * month -> pat_med_outhosp_202601 |
| | | */ |
| | | public String createPartitionTableAndRefreshView(String splitMode) { |
| | | LocalDate today = LocalDate.now(); |
| | | int year = today.getYear(); |
| | | int month = today.getMonthValue(); |
| | | |
| | | // 1. æ ¹æ®æ¨¡å¼è®¡ç®æ°è¡¨å忍¡æ¿è¡¨å |
| | | String newTableName; |
| | | String templateName; |
| | | |
| | | if ("å¹´".equals(splitMode)) { |
| | | // æå¹´ï¼pat_med_outhosp_2026 |
| | | newTableName = "pat_med_outhosp_" + year; |
| | | // 模æ¿è¡¨ï¼ä¼å
ä¸ä¸å¹´å表 |
| | | String prevYearTable = "pat_med_outhosp_" + (year - 1); |
| | | templateName = patMedOuthospMapper.tableExists(prevYearTable) > 0 ? prevYearTable : "pat_med_outhosp"; |
| | | |
| | | } else if ("æ".equals(splitMode)) { |
| | | // ææï¼pat_med_outhosp_202601 |
| | | newTableName = String.format("pat_med_outhosp_%d%02d", year, month); |
| | | // 模æ¿è¡¨ï¼ä¼å
ä¸ä¸æå表 |
| | | LocalDate prevMonth = today.minusMonths(1); |
| | | String prevMonthTable = String.format("pat_med_outhosp_%d%02d", prevMonth.getYear(), prevMonth.getMonthValue()); |
| | | templateName = patMedOuthospMapper.tableExists(prevMonthTable) > 0 ? prevMonthTable : "pat_med_outhosp"; |
| | | |
| | | } else { |
| | | // é»è®¤æå£åº¦ï¼pat_med_outhosp_20260103 |
| | | String quarterSuffix; |
| | | if (month <= 3) { |
| | | quarterSuffix = "0103"; |
| | | } else if (month <= 6) { |
| | | quarterSuffix = "0406"; |
| | | } else if (month <= 9) { |
| | | quarterSuffix = "0709"; |
| | | } else { |
| | | quarterSuffix = "1012"; |
| | | } |
| | | newTableName = "pat_med_outhosp_" + year + quarterSuffix; |
| | | templateName = resolveQuarterTemplateName(year, quarterSuffix); |
| | | } |
| | | |
| | | // 2. æ£æ¥è¡¨æ¯å¦å·²åå¨ |
| | | if (patMedOuthospMapper.tableExists(newTableName) > 0) { |
| | | log.info("[建表] 表 {} å·²åå¨ï¼æ ééå¤å»ºè¡¨ï¼ä½ä»ç¶å°è¯å·æ°åå¨è¿ç¨ï¼ç¡®ä¿å表已纳å
¥æ¥è¯¢ï¼", newTableName); |
| | | refreshOuthospView(); |
| | | return null; |
| | | } |
| | | |
| | | log.info("[建表] 模å¼={}ï¼ä½¿ç¨æ¨¡æ¿è¡¨ {} å建 {}", splitMode, templateName, newTableName); |
| | | |
| | | // 3. å建æ°è¡¨ï¼LIKE 模æ¿è¡¨ï¼åªå¤å¶ç»æ+ç´¢å¼ï¼ä¸å«æ°æ®ï¼ |
| | | patMedOuthospMapper.createPatMedOuthosp(templateName, newTableName); |
| | | // 4. 设置èªå¢ä¸»é® |
| | | patMedOuthospMapper.createPatMedOuthospAutoAdd(newTableName); |
| | | |
| | | // 5. éå»ºå¨æè§å¾ |
| | | refreshOuthospView(); |
| | | |
| | | log.info("[建表] å»ºè¡¨å¹¶å·æ°è§å¾å®æï¼æ°è¡¨ï¼{}", newTableName); |
| | | return newTableName; |
| | | } |
| | | |
| | | /** |
| | | * å£åº¦å表模æ¿ç¡®å®ï¼ä¼å
ä¸ä¸å£åº¦åè¡¨ï¼æ²¡æåç¨ä¸»è¡¨ |
| | | */ |
| | | private String resolveQuarterTemplateName(int year, String currentQuarterSuffix) { |
| | | String[][] quarters = {{"0103", "1012"}, {"0406", "0103"}, {"0709", "0406"}, {"1012", "0709"}}; |
| | | String prevSuffix = null; |
| | | int prevYear = year; |
| | | for (String[] q : quarters) { |
| | | if (q[0].equals(currentQuarterSuffix)) { |
| | | prevSuffix = q[1]; |
| | | if (currentQuarterSuffix.equals("0103")) { |
| | | prevYear = year - 1; |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | if (prevSuffix != null) { |
| | | String prevTableName = "pat_med_outhosp_" + prevYear + prevSuffix; |
| | | if (patMedOuthospMapper.tableExists(prevTableName) > 0) { |
| | | return prevTableName; |
| | | } |
| | | } |
| | | return "pat_med_outhosp"; |
| | | } |
| | | |
| | | /** |
| | | * å·æ°åå¨è¿ç¨ sp_query_outhosp |
| | | * é»è¾ï¼ |
| | | * 1. ä» information_schema 卿è·å pat_med_outhosp åæ®µå表 |
| | | * 2. æ¥åºææå表ï¼åç¼ä¸º4-8ä½çº¯æ°åï¼æ¼ UNION ALL |
| | | * 3. æ ¹æ®å段æ¯å¦åå¨å¨æå³å®åå¨è¿ç¨åæ°å WHERE æ¡ä»¶ |
| | | * 4. ç¨åç JDBC æ§è¡ï¼CREATE PROCEDURE å
å«åå·ï¼MyBatis æ æ³å¤çï¼ |
| | | */ |
| | | private void refreshOuthospView() { |
| | | // 1. è·åææå表 |
| | | List<String> allTables = patMedOuthospMapper.getAllOuthospTableNames(); |
| | | List<String> partTables = allTables.stream().filter(t -> t.matches("pat_med_outhosp_[0-9]{4,8}")).sorted().collect(java.util.stream.Collectors.toList()); |
| | | |
| | | // 2. 卿è·åä¸»è¡¨åæ®µå表 |
| | | List<String> columns = patMedOuthospMapper.getTableColumns("pat_med_outhosp"); |
| | | Set<String> cs = new HashSet<>(columns); |
| | | String colList = String.join(",", columns); |
| | | |
| | | // 3. æ¼ UNION ALLï¼del_flag å
åµå
¥ SET @sql='...' ä¸ï¼ç¨ ''0'' 转ä¹ï¼ |
| | | StringBuilder union = new StringBuilder(); |
| | | for (String tbl : partTables) { |
| | | union.append("SELECT ").append(colList).append(" FROM ").append(tbl).append(" WHERE del_flag=''0'' UNION ALL "); |
| | | } |
| | | union.append("SELECT ").append(colList).append(" FROM pat_med_outhosp WHERE del_flag=''0''"); |
| | | |
| | | // 4. ä» DB å
æ°æ®å¨ææå»ºåæ°å表 |
| | | // æé¤æ ä¸å¡æä¹ç管çåæ®µ |
| | | Set<String> excludeCols = new HashSet<>(java.util.Arrays.asList("id", "del_flag", "create_by", "create_time", "update_by", "update_time", "remark")); |
| | | // 强å¶ç²¾ç¡®å¹é
çåæ®µï¼å段åä¸ç¬¦å eqPattern è§åä½ä¸å¡ä¸é精确æ¥è¯¢ï¼ |
| | | Set<String> forceEqCols = new HashSet<>(java.util.Arrays.asList("orgid", "guid", "campusid")); |
| | | // 精确å¹é
åæ®µçå
³é®è¯ï¼å« no/code/flag/status/state/num/type/level/grade/sex/gender/phone/tel/id_ï¼ |
| | | java.util.regex.Pattern eqPattern = java.util.regex.Pattern.compile("(no|code|flag|status|state|num|type|level|grade|sex|gender|phone|tel|id_.*|.*_id)$", java.util.regex.Pattern.CASE_INSENSITIVE); |
| | | |
| | | List<Map<String, String>> colMetaList = patMedOuthospMapper.getTableColumnMeta("pat_med_outhosp"); |
| | | // [paramName, colName, kind, sqlType] |
| | | List<Object[]> activeParams = new ArrayList<>(); |
| | | Set<String> addedDateCols = new HashSet<>(); |
| | | for (Map<String, String> meta : colMetaList) { |
| | | String colName = meta.get("column_name"); |
| | | String dataType = meta.get("data_type").toLowerCase(); |
| | | String colType = meta.get("column_type").toUpperCase(); |
| | | if (excludeCols.contains(colName)) continue; |
| | | switch (dataType) { |
| | | case "tinyint": |
| | | case "smallint": |
| | | case "int": |
| | | case "bigint": |
| | | case "integer": |
| | | case "decimal": |
| | | case "float": |
| | | case "double": |
| | | activeParams.add(new Object[]{"p_" + colName, colName, "num", colType}); |
| | | break; |
| | | case "date": |
| | | case "datetime": |
| | | case "timestamp": |
| | | // æ¥æåçæåºé´åæ°ï¼é²æ¢é夿·»å |
| | | if (addedDateCols.add(colName)) { |
| | | if (colName.equals("admitdate")) { |
| | | activeParams.add(new Object[]{"p_begin_" + colName, colName, "date_ge", "DATE"}); |
| | | activeParams.add(new Object[]{"p_end_" + colName, colName, "date_le", "DATE"}); |
| | | } |
| | | } |
| | | break; |
| | | default: |
| | | // varchar / char / text çå符串类å |
| | | if (dataType.contains("char") || dataType.contains("text") || dataType.contains("enum")) { |
| | | if (colName.equals("deptcode")) { |
| | | activeParams.add(new Object[]{"p_" + colName, colName, "in", colType}); |
| | | break; |
| | | } |
| | | if (colName.equals("hospitaldistrictcode")) { |
| | | activeParams.add(new Object[]{"p_" + colName, colName, "in", colType}); |
| | | break; |
| | | } |
| | | String kind = forceEqCols.contains(colName) ? "eq" : (eqPattern.matcher(colName).find() ? "eq" : "like"); |
| | | activeParams.add(new Object[]{"p_" + colName, colName, kind, colType}); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | | // 6. æ¼åæ°å®ä¹ï¼å»é¤éå¤åæ°åï¼å¦ p_begin_xxx/p_end_xxx ååï¼ |
| | | StringBuilder paramDef = new StringBuilder("CREATE PROCEDURE sp_query_outhosp("); |
| | | Set<String> addedParams = new LinkedHashSet<>(); |
| | | for (Object[] m : activeParams) { |
| | | String pName = (String) m[0]; |
| | | String dtype = (String) m[3]; |
| | | if (addedParams.add(pName)) { |
| | | paramDef.append("IN ").append(pName).append(" ").append(dtype).append(","); |
| | | } |
| | | } |
| | | paramDef.append("IN p_page_size INT,IN p_page_num INT)"); |
| | | |
| | | // 7. æ¼åå¨è¿ç¨ä¸»ä½ |
| | | // ä¼åçç¥ï¼ç¨ @cond åéæ¶éææè¿æ»¤æ¡ä»¶ï¼ç¶å注å
¥å°æ¯ä¸ªåæ¥è¯¢ç WHERE ä¸ |
| | | // è¿æ · MySQL å¯ä»¥å¯¹æ¯å¼ åè¡¨ç´æ¥èµ°ç´¢å¼ï¼é¿å
å
¨è¡¨æ«æåå¤å±åè¿æ»¤ |
| | | List<String> body = new ArrayList<>(); |
| | | body.add(paramDef.toString()); |
| | | body.add("BEGIN"); |
| | | body.add(" SET @cond='';"); |
| | | |
| | | // 7a. å¨ææ¼æ¥ @cond æ¡ä»¶ç段 |
| | | for (Object[] m : activeParams) { |
| | | String pName = (String) m[0]; |
| | | String col = (String) m[1]; |
| | | String kind = (String) m[2]; |
| | | String line; |
| | | switch (kind) { |
| | | case "num": |
| | | line = " IF " + pName + " IS NOT NULL THEN SET @cond=CONCAT(@cond,' AND " + col + "='," + pName + "); END IF;"; |
| | | break; |
| | | case "eq": |
| | | line = " IF " + pName + " IS NOT NULL THEN SET @cond=CONCAT(@cond,' AND " + col + "=',QUOTE(" + pName + ")); END IF;"; |
| | | break; |
| | | case "like": |
| | | // MySQL åå¨è¿ç¨å
'' 表示ä¸ä¸ªåå¼å· |
| | | line = " IF " + pName + " IS NOT NULL THEN SET @cond=CONCAT(@cond,' AND " + col + " LIKE CONCAT(''%''," + pName + ",''%'')'); END IF;"; |
| | | break; |
| | | case "date_ge": |
| | | line = " IF " + pName + " IS NOT NULL THEN SET @cond=CONCAT(@cond,' AND " + col + ">=',QUOTE(" + pName + ")); END IF;"; |
| | | break; |
| | | case "date_le": |
| | | line = " IF " + pName + " IS NOT NULL THEN SET @cond=CONCAT(@cond,' AND " + col + "<=',QUOTE(" + pName + ")); END IF;"; |
| | | break; |
| | | case "in": |
| | | // åæ°ä¸ºéå·åéå符串ï¼ç¨ FIND_IN_SET å¹é
åæ®µå¨éåä¸ |
| | | // çæ SQLï¼ FIND_IN_SET(col, 'val1,val2,...') |
| | | line = " IF " + pName + " IS NOT NULL THEN SET @cond=CONCAT(@cond,' AND FIND_IN_SET(" + col + ",',QUOTE(" + pName + "),')'); END IF;"; |
| | | break; |
| | | default: |
| | | line = ""; |
| | | } |
| | | if (!line.isEmpty()) body.add(line); |
| | | } |
| | | |
| | | // 7b. æå»º UNION ALL SQLï¼æ¯ä¸ªåæ¥è¯¢ç WHERE å
ç´æ¥æ³¨å
¥ @cond |
| | | // æç»åå¨è¿ç¨éæ§è¡ç SQL ç±»ä¼¼ï¼ |
| | | // SELECT cols FROM tbl1 WHERE del_flag='0' AND orgid=? AND ... |
| | | // UNION ALL SELECT cols FROM tbl2 WHERE del_flag='0' AND orgid=? AND ... |
| | | // ORDER BY update_time DESC LIMIT ? OFFSET ? |
| | | // |
| | | // å®ç°æ¹å¼ï¼ç¨ CONCAT(åå¼å·å符串, @cond, ...) æ¼æ¥ |
| | | // del_flag=''0'' å¨åå¨è¿ç¨å
åå¼å·å符串ä¸è¡¨ç¤ºä¸ä¸ª '0' |
| | | List<String> allQueryTables = new ArrayList<>(partTables); |
| | | allQueryTables.add("pat_med_outhosp"); |
| | | |
| | | StringBuilder concatArgs = new StringBuilder(); |
| | | for (int i = 0; i < allQueryTables.size(); i++) { |
| | | String tbl = allQueryTables.get(i); |
| | | if (i > 0) { |
| | | concatArgs.append(",' UNION ALL SELECT ").append(colList).append(" FROM ").append(tbl).append(" WHERE del_flag=''0''',@cond"); |
| | | } else { |
| | | concatArgs.append("'SELECT ").append(colList).append(" FROM ").append(tbl).append(" WHERE del_flag=''0''',@cond"); |
| | | } |
| | | } |
| | | |
| | | String orderCol = cs.contains("update_time") ? "update_time" : "id"; |
| | | body.add(" SET @sql=CONCAT(" + concatArgs + ",' ORDER BY " + orderCol + " DESC');"); |
| | | body.add(" IF p_page_size IS NOT NULL AND p_page_num IS NOT NULL THEN"); |
| | | body.add(" SET @sql=CONCAT(@sql,' LIMIT ',p_page_size,' OFFSET ',p_page_num);"); |
| | | body.add(" END IF;"); |
| | | body.add(" PREPARE stmt FROM @sql;"); |
| | | body.add(" EXECUTE stmt;"); |
| | | body.add(" DEALLOCATE PREPARE stmt;"); |
| | | body.add("END"); |
| | | |
| | | String procSql = String.join("\n", body); |
| | | log.debug("[å·æ°åå¨è¿ç¨] DDL=\n{}", procSql); |
| | | |
| | | // 8. éè¿åç JDBC æ§è¡ï¼CREATE PROCEDURE å«åå·ï¼MyBatis 䏿¯æï¼ |
| | | // çç¥ï¼ |
| | | // - åå¨è¿ç¨ä¸åå¨ â å
¨éå建 |
| | | // - åå¨è¿ç¨å·²åå¨ â åªæ DB ä¸è¿æ²¡æçå表以 UNION ALL å½¢å¼è¿½å è¿ SET @sql=CONCAT(...) éï¼ |
| | | // å
¶ä½æææ¡ä»¶é»è¾ï¼äººå·¥æ¹è¿ç模ç³/åºé´çï¼åæ ·ä¿çï¼ç»ä¸è¦ç |
| | | try (Connection conn = dataSource.getConnection(); Statement jdbcStmt = conn.createStatement()) { |
| | | |
| | | // å
æ¥ DB 䏿¯å¦åå¨è¯¥åå¨è¿ç¨åå
¶å®æ´ DDL |
| | | String showCreateDdl = null; |
| | | try (java.sql.ResultSet rs = jdbcStmt.executeQuery("SHOW CREATE PROCEDURE sp_query_outhosp")) { |
| | | if (rs.next()) { |
| | | showCreateDdl = rs.getString("Create Procedure"); |
| | | } |
| | | } catch (Exception ignored) { |
| | | // åå¨è¿ç¨ä¸å卿¶ SHOW CREATE 伿å¼å¸¸ï¼å¿½ç¥ |
| | | } |
| | | |
| | | if (showCreateDdl == null) { |
| | | // åå¨è¿ç¨ä¸åå¨ï¼å
¨éå建 |
| | | jdbcStmt.execute(procSql); |
| | | log.info("[å·æ°åå¨è¿ç¨] sp_query_outhosp 馿¬¡å建ï¼å表æ°éï¼{}", partTables.size()); |
| | | } else { |
| | | // åå¨è¿ç¨å·²åå¨ï¼æ¾åº DB éå·²æåªäºåè¡¨ï¼ææ°å¢ç追å è¿å» |
| | | // æ¾åºå½å DDL éå·²åºç°çææ pat_med_outhosp_xxx 表å |
| | | java.util.regex.Matcher tblMatcher = java.util.regex.Pattern.compile("pat_med_outhosp_([0-9]{4,8})").matcher(showCreateDdl); |
| | | Set<String> existingTables = new java.util.LinkedHashSet<>(); |
| | | while (tblMatcher.find()) { |
| | | existingTables.add(tblMatcher.group(0)); |
| | | } |
| | | |
| | | // æ¾åºæ¬æ¬¡æ°å»ºåè¿æ²¡è¿å
¥åå¨è¿ç¨çå表 |
| | | List<String> newTables = partTables.stream().filter(t -> !existingTables.contains(t)).collect(java.util.stream.Collectors.toList()); |
| | | |
| | | if (newTables.isEmpty()) { |
| | | log.info("[å·æ°åå¨è¿ç¨] æ æ°å¢å表ï¼åå¨è¿ç¨æ éæ´æ°"); |
| | | } else { |
| | | // ç´æ¥ä» DDL éæååæ®µå表ï¼é¿å
ä¸ Java 卿æ¥è¡¨å段ä¸ä¸è´ï¼ |
| | | // DDL éåæ®µå表就å¨ï¼ SELECT åé¢å° FROM åé¢ |
| | | java.util.regex.Matcher colMatcher = java.util.regex.Pattern.compile("SELECT\\s+(.+?)\\s+FROM\\s+pat_med_outhosp", java.util.regex.Pattern.CASE_INSENSITIVE).matcher(showCreateDdl); |
| | | String existingColList = colMatcher.find() ? colMatcher.group(1).trim() : colList; |
| | | |
| | | // 精确éç¹ï¼',@cond,' UNION ALL SELECT cols FROM pat_med_outhosp WHERE |
| | | String mainTableAnchor = "',@cond,' UNION ALL SELECT " + existingColList + " FROM pat_med_outhosp WHERE "; |
| | | int mainAnchorIdx = showCreateDdl.indexOf(mainTableAnchor); |
| | | |
| | | // åæ®µå表å¹é
ä¸å°æ¶ï¼ç®åå®ä½ |
| | | if (mainAnchorIdx < 0) { |
| | | // æ¾ ',@cond,' UNION ALL SELECT ... FROM pat_med_outhosp WHERE |
| | | // å
æ¾ FROM pat_med_outhosp WHEREï¼åå¾åæ¾ ',@cond,' |
| | | int fromIdx = showCreateDdl.indexOf(" FROM pat_med_outhosp WHERE "); |
| | | if (fromIdx >= 0) { |
| | | String before = showCreateDdl.substring(0, fromIdx); |
| | | int condIdx = before.lastIndexOf("',@cond,'"); |
| | | if (condIdx >= 0) mainAnchorIdx = condIdx; |
| | | } |
| | | } |
| | | |
| | | if (mainAnchorIdx < 0) { |
| | | log.warn("[å·æ°åå¨è¿ç¨] æªæ¾å°ä¸»è¡¨éç¹ï¼è·³è¿è¿½å "); |
| | | } else { |
| | | // æ°è¡¨çæ®µï¼æ¯å¼ æ°è¡¨è¿½å 䏿®µ ',@cond,' UNION ALL SELECT cols FROM æ°è¡¨ WHERE del_flag=''0'' |
| | | // æå¨ä¸»è¡¨éç¹åé¢ï¼ä¸»è¡¨éç¹æ¬èº«ï¼',@cond,' UNION ALL ...主表...ï¼ä¿æä¸å¨ |
| | | StringBuilder newTablesFragment = new StringBuilder(); |
| | | for (String nt : newTables) { |
| | | newTablesFragment.append("',@cond,' UNION ALL SELECT ").append(existingColList).append(" FROM ").append(nt).append(" WHERE del_flag=''0''"); |
| | | } |
| | | |
| | | // æå
¥å°ä¸»è¡¨ ',@cond,' çæ®µåé¢ |
| | | String updatedDdl = showCreateDdl.substring(0, mainAnchorIdx) + newTablesFragment + showCreateDdl.substring(mainAnchorIdx); |
| | | |
| | | log.debug("[å·æ°åå¨è¿ç¨] æ´æ°å DDL=\n{}", updatedDdl); |
| | | |
| | | // å®å
¨ä¿æ¤ï¼DROP åå
ä¿åå DDLï¼CREATE 失败åç«å»ç¨å DDL æ¢å¤ |
| | | jdbcStmt.execute("DROP PROCEDURE IF EXISTS sp_query_outhosp"); |
| | | try { |
| | | jdbcStmt.execute(updatedDdl); |
| | | log.info("[å·æ°åå¨è¿ç¨] sp_query_outhosp è¿½å æ°å表 {}ï¼åææ¡ä»¶ä¿æä¸å", newTables); |
| | | } catch (Exception createEx) { |
| | | log.error("[å·æ°åå¨è¿ç¨] æ° DDL æ§è¡å¤±è´¥ï¼æ£å¨ç¨å DDL æ¢å¤, updatedDdl=\n{}", updatedDdl, createEx); |
| | | try { |
| | | jdbcStmt.execute(showCreateDdl); |
| | | log.info("[å·æ°åå¨è¿ç¨] sp_query_outhosp å·²ç¨å DDL æ¢å¤æå"); |
| | | } catch (Exception rollbackEx) { |
| | | log.error("[å·æ°åå¨è¿ç¨] å DDL æ¢å¤ä¹å¤±è´¥ï¼åå¨è¿ç¨ä¸¢å¤±ï¼è¯·æå¨ä¿®å¤, å DDL=\n{}", showCreateDdl, rollbackEx); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("[å·æ°åå¨è¿ç¨] sp_query_outhosp æ´æ°å¤±è´¥, DDL=\n{}", procSql, e); |
| | | } |
| | | |
| | | // 9. 忥巿° count åå¨è¿ç¨ |
| | | refreshOuthospCountProc(partTables, activeParams, colList); |
| | | } |
| | | |
| | | /** |
| | | * å·æ°è®¡æ°åå¨è¿ç¨ sp_count_outhosp |
| | | * ä¸ sp_query_outhosp åæ°å®å
¨ä¸è´ï¼åªè¿åæ»æ¡æ°ï¼ä¸å页 |
| | | */ |
| | | private void refreshOuthospCountProc(List<String> partTables, List<Object[]> activeParams, String colList) { |
| | | // æ¼åæ°å®ä¹ï¼å»æ p_page_size/p_page_numï¼ |
| | | StringBuilder paramDef = new StringBuilder("CREATE PROCEDURE sp_count_outhosp("); |
| | | Set<String> addedParams = new LinkedHashSet<>(); |
| | | for (Object[] m : activeParams) { |
| | | String pName = (String) m[0]; |
| | | String dtype = (String) m[3]; |
| | | if (addedParams.add(pName)) { |
| | | paramDef.append("IN ").append(pName).append(" ").append(dtype).append(","); |
| | | } |
| | | } |
| | | // 廿æåçå¤ä½éå· |
| | | String paramDefStr = paramDef.toString(); |
| | | if (paramDefStr.endsWith(",")) { |
| | | paramDefStr = paramDefStr.substring(0, paramDefStr.length() - 1); |
| | | } |
| | | paramDefStr += ")"; |
| | | |
| | | List<String> body = new ArrayList<>(); |
| | | body.add(paramDefStr); |
| | | body.add("BEGIN"); |
| | | body.add(" SET @cond='';"); |
| | | |
| | | // æ¡ä»¶ç段ï¼ä¸ sp_query_outhosp å®å
¨ä¸è´ï¼ |
| | | for (Object[] m : activeParams) { |
| | | String pName = (String) m[0]; |
| | | String col = (String) m[1]; |
| | | String kind = (String) m[2]; |
| | | String line; |
| | | switch (kind) { |
| | | case "num": |
| | | line = " IF " + pName + " IS NOT NULL THEN SET @cond=CONCAT(@cond,' AND " + col + "='," + pName + "); END IF;"; |
| | | break; |
| | | case "eq": |
| | | line = " IF " + pName + " IS NOT NULL THEN SET @cond=CONCAT(@cond,' AND " + col + "=',QUOTE(" + pName + ")); END IF;"; |
| | | break; |
| | | case "like": |
| | | line = " IF " + pName + " IS NOT NULL THEN SET @cond=CONCAT(@cond,' AND " + col + " LIKE CONCAT(''%''," + pName + ",''%'')'); END IF;"; |
| | | break; |
| | | case "date_ge": |
| | | line = " IF " + pName + " IS NOT NULL THEN SET @cond=CONCAT(@cond,' AND " + col + ">=',QUOTE(" + pName + ")); END IF;"; |
| | | break; |
| | | case "date_le": |
| | | line = " IF " + pName + " IS NOT NULL THEN SET @cond=CONCAT(@cond,' AND " + col + "<=',QUOTE(" + pName + ")); END IF;"; |
| | | break; |
| | | case "in": |
| | | line = " IF " + pName + " IS NOT NULL THEN SET @cond=CONCAT(@cond,' AND FIND_IN_SET(" + col + ",',QUOTE(" + pName + "),')'); END IF;"; |
| | | break; |
| | | default: |
| | | line = ""; |
| | | } |
| | | if (!line.isEmpty()) body.add(line); |
| | | } |
| | | |
| | | // æ¼ COUNT UNION ALL SQLï¼åå表åè®¡ä¸æ¬¡åæ±æ» |
| | | // SELECT SUM(cnt) FROM (SELECT COUNT(1) cnt FROM tbl1 WHERE del_flag=''0'' ... |
| | | // UNION ALL SELECT COUNT(1) cnt FROM tbl2 WHERE del_flag=''0'' ...) t |
| | | List<String> allQueryTables = new ArrayList<>(partTables); |
| | | allQueryTables.add("pat_med_outhosp"); |
| | | |
| | | StringBuilder concatArgs = new StringBuilder(); |
| | | concatArgs.append("'SELECT SUM(cnt) FROM ("); |
| | | for (int i = 0; i < allQueryTables.size(); i++) { |
| | | String tbl = allQueryTables.get(i); |
| | | if (i > 0) { |
| | | concatArgs.append(" UNION ALL SELECT COUNT(1) cnt FROM ").append(tbl).append(" WHERE del_flag=''''0''''").append("',@cond,'"); |
| | | } else { |
| | | concatArgs.append("SELECT COUNT(1) cnt FROM ").append(tbl).append(" WHERE del_flag=''''0''''").append("',@cond,'"); |
| | | } |
| | | } |
| | | concatArgs.append(") t';"); |
| | | |
| | | // éæ°æ¼ï¼æ¯ä¸ªå表 WHERE del_flag=''0'' åæ¼ @cond |
| | | // åå¨è¿ç¨å
'' 表示ä¸ä¸ªåå¼å·ï¼æä»¥ del_flag=''0'' æ£ç¡® |
| | | StringBuilder concatArgs2 = new StringBuilder(); |
| | | for (int i = 0; i < allQueryTables.size(); i++) { |
| | | String tbl = allQueryTables.get(i); |
| | | if (i == 0) { |
| | | concatArgs2.append("'SELECT SUM(cnt) FROM (SELECT COUNT(1) cnt FROM ").append(tbl).append(" WHERE del_flag=''0''',@cond"); |
| | | } else { |
| | | concatArgs2.append(",' UNION ALL SELECT COUNT(1) cnt FROM ").append(tbl).append(" WHERE del_flag=''0''',@cond"); |
| | | } |
| | | } |
| | | concatArgs2.append(",' ) t'"); |
| | | |
| | | body.add(" SET @sql=CONCAT(" + concatArgs2 + ");"); |
| | | body.add(" PREPARE stmt FROM @sql;"); |
| | | body.add(" EXECUTE stmt;"); |
| | | body.add(" DEALLOCATE PREPARE stmt;"); |
| | | body.add("END"); |
| | | |
| | | String procSql = String.join("\n", body); |
| | | log.debug("[å·æ°countåå¨è¿ç¨] DDL=\n{}", procSql); |
| | | |
| | | try (Connection conn = dataSource.getConnection(); Statement jdbcStmt = conn.createStatement()) { |
| | | String showCreateDdl = null; |
| | | try (java.sql.ResultSet rs = jdbcStmt.executeQuery("SHOW CREATE PROCEDURE sp_count_outhosp")) { |
| | | if (rs.next()) showCreateDdl = rs.getString("Create Procedure"); |
| | | } catch (Exception ignored) { |
| | | } |
| | | |
| | | if (showCreateDdl == null) { |
| | | jdbcStmt.execute(procSql); |
| | | log.info("[å·æ°countåå¨è¿ç¨] sp_count_outhosp 馿¬¡å建ï¼å表æ°éï¼{}", partTables.size()); |
| | | } else { |
| | | // åªè¿½å æ°å表ï¼ä¸è¦çå·²ææ¡ä»¶ |
| | | java.util.regex.Matcher tblMatcher = java.util.regex.Pattern.compile("pat_med_outhosp_([0-9]{4,8})").matcher(showCreateDdl); |
| | | Set<String> existingTables = new java.util.LinkedHashSet<>(); |
| | | while (tblMatcher.find()) existingTables.add(tblMatcher.group(0)); |
| | | |
| | | List<String> newTables = partTables.stream().filter(t -> !existingTables.contains(t)).collect(java.util.stream.Collectors.toList()); |
| | | if (newTables.isEmpty()) { |
| | | log.info("[å·æ°countåå¨è¿ç¨] æ æ°å¢åè¡¨ï¼æ éæ´æ°"); |
| | | return; |
| | | } |
| | | |
| | | // ä» DDL éæå COUNT(1) cnt FROM åé¢çåæ®µæ¨¡å¼æ æ¡ï¼COUNTåå¨è¿ç¨æ²¡æå段å表 |
| | | // å®ä½ä¸»è¡¨éç¹ï¼',@cond,' UNION ALL SELECT COUNT(1) cnt FROM pat_med_outhosp WHERE |
| | | String mainAnchor = "',@cond,' UNION ALL SELECT COUNT(1) cnt FROM pat_med_outhosp WHERE "; |
| | | int mainAnchorIdx = showCreateDdl.indexOf(mainAnchor); |
| | | if (mainAnchorIdx < 0) { |
| | | int fromIdx = showCreateDdl.indexOf(" FROM pat_med_outhosp WHERE "); |
| | | if (fromIdx >= 0) { |
| | | String before = showCreateDdl.substring(0, fromIdx); |
| | | int condIdx = before.lastIndexOf("',@cond,'"); |
| | | if (condIdx >= 0) mainAnchorIdx = condIdx; |
| | | } |
| | | } |
| | | |
| | | if (mainAnchorIdx < 0) { |
| | | log.warn("[å·æ°countåå¨è¿ç¨] æªæ¾å°ä¸»è¡¨éç¹ï¼è·³è¿è¿½å "); |
| | | return; |
| | | } |
| | | |
| | | StringBuilder newFrag = new StringBuilder(); |
| | | for (String nt : newTables) { |
| | | newFrag.append("',@cond,' UNION ALL SELECT COUNT(1) cnt FROM ").append(nt).append(" WHERE del_flag=''0''"); |
| | | } |
| | | String updatedDdl = showCreateDdl.substring(0, mainAnchorIdx) + newFrag + showCreateDdl.substring(mainAnchorIdx); |
| | | log.debug("[å·æ°countåå¨è¿ç¨] æ´æ°å DDL=\n{}", updatedDdl); |
| | | |
| | | jdbcStmt.execute("DROP PROCEDURE IF EXISTS sp_count_outhosp"); |
| | | try { |
| | | jdbcStmt.execute(updatedDdl); |
| | | log.info("[å·æ°countåå¨è¿ç¨] sp_count_outhosp è¿½å æ°å表 {}", newTables); |
| | | } catch (Exception createEx) { |
| | | log.error("[å·æ°countåå¨è¿ç¨] æ° DDL å¤±è´¥ï¼æ¢å¤å DDL, updatedDdl=\n{}", updatedDdl, createEx); |
| | | try { |
| | | jdbcStmt.execute(showCreateDdl); |
| | | log.info("[å·æ°countåå¨è¿ç¨] å·²æ¢å¤å DDL"); |
| | | } catch (Exception rollbackEx) { |
| | | log.error("[å·æ°countåå¨è¿ç¨] æ¢å¤ä¹å¤±è´¥ï¼è¯·æå¨ä¿®å¤, å DDL=\n{}", showCreateDdl, rollbackEx); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("[å·æ°countåå¨è¿ç¨] sp_count_outhosp æ´æ°å¤±è´¥", e); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | public List<PatArchiveOthreInfo> selectPatArchiveInfoByInhospQC(PatArchiveReq patArchive); |
| | | |
| | | public List<PatArchiveOthreInfo> selectPatArchiveInfoByOuthospQC(PatArchiveReq patArchive); |
| | | // public List<PatArchiveOthreInfo> selectPatArchiveInfoByOuthospQC(PatArchiveReq patArchive); |
| | | |
| | | public List<PatArchiveOthreInfo> selectPatArchiveInfoByPhysicalQC(PatArchiveReq patArchive); |
| | | |
| | |
| | | */ |
| | | public PatArchiveOut selectPatArchiveOutByPatid(Long patid); |
| | | |
| | | public List<PerSonWorkbenchDto> selectPatArchiveCount(@Param("deptIds") long[] deptIds,@Param("drCodes") String[] drCodes); |
| | | public List<PerSonWorkbenchDto> selectPatArchiveCount(@Param("deptcodes") List<String> deptcodes,@Param("drCodes") String[] drCodes); |
| | | |
| | | /** |
| | | * æ¥è¯¢å¤é¨æ£è
æ¡£æ¡å表 |
| | |
| | | public PatMedRes selectPatMedInhospCount(PatMedReq patMedReq); |
| | | |
| | | |
| | | public List<PatMedRes> getDeptRanking(PatMedReq patMedReq); |
| | | |
| | | /** |
| | | * æ¥è¯¢ä¸ä¸ªç»´åº¦ä»»æä¸ä¸ªæªå¤ççåºé¢æ£è
|
| | | * |
| | | * @return |
| | | */ |
| | | public List<PatMedInhosp> selectNeedProcessList(); |
| | |
| | | package com.smartor.mapper; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.smartor.domain.PatMedOuthosp; |
| | | import com.smartor.domain.PatMedReq; |
| | | import com.smartor.domain.PatMedRes; |
| | | import com.smartor.domain.*; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | |
| | | */ |
| | | @Mapper |
| | | public interface PatMedOuthospMapper { |
| | | /** |
| | | * æ¥è¯¢æ£è
é¨è¯è®°å½ |
| | | * |
| | | * @param id æ£è
é¨è¯è®°å½ä¸»é® |
| | | * @return æ£è
é¨è¯è®°å½ |
| | | */ |
| | | public PatMedOuthosp selectPatMedOuthospById(Long id); |
| | | |
| | | /** |
| | | * æ¥è¯¢æ£è
é¨è¯è®°å½å表 |
| | | * |
| | | * @param patMedOuthosp æ£è
é¨è¯è®°å½ |
| | | * @return æ£è
é¨è¯è®°å½éå |
| | | */ |
| | | public List<PatMedOuthosp> selectPatMedOuthospList(PatMedOuthosp patMedOuthosp); |
| | | |
| | | /** |
| | | * æ°å¢æ£è
é¨è¯è®°å½ |
| | |
| | | * @param patMedOuthosp æ£è
é¨è¯è®°å½ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertPatMedOuthosp(PatMedOuthosp patMedOuthosp); |
| | | |
| | | public int batchPatMedOuthosp(List<PatMedOuthosp> patMedOuthosps); |
| | | // public int insertPatMedOuthosp(PatMedOuthosp patMedOuthosp); |
| | | |
| | | /** |
| | | * æ¹éæå
¥ï¼å¿½ç¥éå¤ï¼INSERT IGNOREï¼ |
| | | * æ°å¢å°æå®å表ï¼ç¨äºè·¯ç±å°ææ°åè¡¨ï¼ |
| | | * |
| | | * @param patMedOuthosps 鍿¥è¯è®°å½å表 |
| | | * @return å®é
æå
¥æ°é |
| | | * @param tableName ç®æ 表å |
| | | * @param record é¨è¯è®°å½ |
| | | * @return æå
¥æ¡æ° |
| | | */ |
| | | public int batchInsertIgnore(List<PatMedOuthosp> patMedOuthosps); |
| | | int insertIntoTable(@Param("tableName") String tableName, @Param("record") PatMedOuthosp record); |
| | | |
| | | |
| | | /** |
| | | * 夿æå®åè¡¨ä¸æ¯å¦åå¨è¯¥ id |
| | | */ |
| | | int existsInTable(@Param("tableName") String tableName, @Param("id") Long id); |
| | | |
| | | /** |
| | | * æ´æ°å°æå®å表ï¼ç¨äºè·¯ç±å°æ£ç¡®åè¡¨ï¼ |
| | | */ |
| | | int updateInTable(@Param("tableName") String tableName, @Param("record") PatMedOuthosp record); |
| | | |
| | | /** |
| | | * è°ç¨åå¨è¿ç¨ sp_query_outhosp æ¥è¯¢é¨è¯è®°å½ |
| | | * |
| | | * @param req å
¥å对象 |
| | | * @return é¨è¯è®°å½å表 |
| | | */ |
| | | List<PatMedOuthosp> callSpQueryOuthosp(PatMedOuthospQueryReq req); |
| | | |
| | | /** |
| | | * è°ç¨åå¨è¿ç¨ sp_query_outhosp æ¥è¯¢é¨è¯è®°å½æ°é |
| | | * |
| | | * @param req å
¥å对象 |
| | | * @return é¨è¯è®°å½å表 |
| | | */ |
| | | Long callSpQueryOuthospCount(PatMedOuthospQueryReq req); |
| | | |
| | | |
| | | /** |
| | | * ä¿®æ¹æ£è
é¨è¯è®°å½ |
| | |
| | | * @param patMedOuthosp æ£è
é¨è¯è®°å½ |
| | | * @return ç»æ |
| | | */ |
| | | public int updatePatMedOuthosp(PatMedOuthosp patMedOuthosp); |
| | | // public int updatePatMedOuthosp(PatMedOuthosp patMedOuthosp); |
| | | |
| | | /** |
| | | * å 餿£è
é¨è¯è®°å½ |
| | | * |
| | | * @param id æ£è
é¨è¯è®°å½ä¸»é® |
| | | * @return ç»æ |
| | | */ |
| | | public int deletePatMedOuthospById(Long id); |
| | | |
| | | /** |
| | | * æ¹éå 餿£è
é¨è¯è®°å½ |
| | | * |
| | | * @param ids éè¦å é¤çæ°æ®ä¸»é®éå |
| | | * @return ç»æ |
| | | */ |
| | | public int deletePatMedOuthospByIds(Long[] ids); |
| | | |
| | | PatMedRes selectPatMedOuthospCount(PatMedReq patMedReq); |
| | | |
| | | public List<PatMedRes> getDeptRanking(PatMedReq patMedReq); |
| | | |
| | | /** |
| | | * è·åè¡¨çæ°é |
| | | * |
| | | * @return |
| | | */ |
| | | int countPatMedOuthosp(); |
| | | |
| | | /** |
| | | * ä¿®æ¹è¡¨å |
| | | * |
| | | * @return |
| | | */ |
| | | void renameTable(@Param("oldName") String oldName, @Param("newName") String newName); |
| | | |
| | | /** |
| | | * å建æ°è¡¨ |
| | | * |
| | | * @param templateName |
| | | * @param newName |
| | | * @param templateName 模æ¿è¡¨å |
| | | * @param newName æ°è¡¨å |
| | | */ |
| | | void createPatMedOuthosp(@Param("templateName") String templateName, @Param("newName") String newName); |
| | | |
| | | void createPatMedOuthospAutoAdd(@Param("newName") String newName); |
| | | |
| | | |
| | | void setAutoIncrement(@Param("tableName") String tableName, @Param("autoInc") long autoInc); |
| | | |
| | | // æ¥è¯¢ææ pat_med_outhosp å¼å¤´ç表å |
| | | List<String> getAllOuthospTableNames(); |
| | | |
| | | // æ¥è¯¢æå®è¡¨çæå¤§id |
| | | Long getMaxIdFromTable(@Param("tableName") String tableName); |
| | | // æ¥è¯¢æå®è¡¨çåæ®µåè¡¨ï¼æ ordinal_position æåºï¼ |
| | | List<String> getTableColumns(@Param("tableName") String tableName); |
| | | |
| | | void createOrReplaceView(@Param("viewSql") String viewSql); |
| | | /** |
| | | * æ¥è¯¢æå®è¡¨çåæ®µå
æ°æ®ï¼column_name, data_type, column_typeï¼ |
| | | * |
| | | * @param tableName 表å |
| | | * @return æ¯è¡å
å« column_name / data_type / column_type |
| | | */ |
| | | List<Map<String, String>> getTableColumnMeta(@Param("tableName") String tableName); |
| | | |
| | | |
| | | /** |
| | | * åå»ºææ´æ°åå¨è¿ç¨ï¼æ¯æ DROP / CREATE PROCEDURE è¯å¥ï¼ |
| | | */ |
| | | void createOrReplaceProcedure(@Param("procSql") String procSql); |
| | | |
| | | /** |
| | | * æ£æ¥è¡¨æ¯å¦å·²åå¨ |
| | | * |
| | | * @param tableName 表å |
| | | * @return åå¨è¿å1ï¼ä¸åå¨è¿å0 |
| | | */ |
| | | int tableExists(@Param("tableName") String tableName); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | /** |
| | | * ç¨äºè¡¥å¿æ¥è¯¢ |
| | | * |
| | | * @param ServiceSubtaskEntity |
| | | * @return |
| | | */ |
| | |
| | | */ |
| | | @MapKey("groupKey") |
| | | public Map<String, Map<String,Object>> selectTimelyRateBatch(ServiceSubtaskEntity ServiceSubtaskvo); |
| | | |
| | | /** |
| | | * éè®¿åæ¶ç详æ
|
| | | * |
| | |
| | | * allVisitCount: å½åç»å½äººéè®¿ä»»å¡æ»é |
| | | */ |
| | | public Map<String, Object> getCurrentUserServiceSubtaskCount(ServiceSubtaskEntity serviceSubtaskVO); |
| | | /** |
| | | * è·åé¨è¯éè®¿äººæ° |
| | | * |
| | | * @param patMedReq |
| | | * @return |
| | | */ |
| | | PatMedRes selectVisitCount(PatMedReq patMedReq); |
| | | |
| | | } |
| | |
| | | /** |
| | | * å½åç»å½ç¨æ·çé¨è¯ãå¨é¢ãåºé¢ç
人çç»è®¡æ
åµ |
| | | */ |
| | | public List<PerSonWorkbenchDto> getPatCount(String detpId, String drCode); |
| | | public List<PerSonWorkbenchDto> getPatCount(String deptIds, String drCode); |
| | | |
| | | } |
| | |
| | | import com.smartor.domain.*; |
| | | import com.smartor.mapper.*; |
| | | import com.smartor.service.IHNGatherPatArchiveService; |
| | | import com.smartor.service.IPatMedOuthospService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private PatArchiveMapper patArchiveMapper; |
| | | |
| | | @Autowired |
| | | private ThreadPoolTaskExecutor taskExecutor; |
| | | private IPatMedOuthospService patMedOuthospService; |
| | | |
| | | @Autowired |
| | | private ShardingMapper shardingMapper; |
| | |
| | | patArchiveMapper.insertPatArchiveSingle(patArchives.get(0)); |
| | | patMedOuthosp1.setPatid(patArchives.get(0).getId()); |
| | | } |
| | | i = patMedOuthospMapper.insertPatMedOuthosp(patMedOuthosp1); |
| | | i = patMedOuthospService.insertPatMedOuthosp(patMedOuthosp1); |
| | | } |
| | | |
| | | return i; |
| | |
| | | private PatArchivecontactMapper patArchivecontactMapper; |
| | | |
| | | @Autowired |
| | | private IPatMedPhysicalService patMedPhysicalService; |
| | | private PatMedOuthospMapper patMedOuthospMapper; |
| | | |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | |
| | | } |
| | | } else if (patArchiveReq.getAllhosp() != null && patArchiveReq.getAllhosp() == 2) { |
| | | // æ¥çä½é¢ 1 æ¥çé¨è¯ 2 æ¥ç使£ 3 |
| | | List<PatArchiveOthreInfo> patArchives2 = patArchiveMapper.selectPatArchiveInfoByOuthosp(patArchiveReq); |
| | | if (CollectionUtils.isNotEmpty(patArchives2)) { |
| | | patArchiveList.addAll(patArchives2); |
| | | // List<PatArchiveOthreInfo> patArchives2 = patArchiveMapper.selectPatArchiveInfoByOuthosp(patArchiveReq); |
| | | List<PatArchiveOthreInfo> patientInfoQC = getPatientInfoUtils(patArchiveReq); |
| | | |
| | | if (CollectionUtils.isNotEmpty(patientInfoQC)) { |
| | | patArchiveList.addAll(patientInfoQC); |
| | | } |
| | | } else if (patArchiveReq.getAllhosp() != null && patArchiveReq.getAllhosp() == 3) { |
| | | // æ¥çä½é¢ 1 æ¥çé¨è¯ 2 æ¥ç使£ 3 |
| | |
| | | patArchiveList.addAll(patArchives1); |
| | | } |
| | | } else if (patArchive.getAllhosp() != null && patArchive.getAllhosp() == 2) { |
| | | List<PatArchiveOthreInfo> patArchives2 = patArchiveMapper.selectPatArchiveInfoByOuthosp(patArchive); |
| | | if (CollectionUtils.isNotEmpty(patArchives2)) { |
| | | patArchiveList.addAll(patArchives2); |
| | | List<PatArchiveOthreInfo> patientInfoUtils = getPatientInfoUtils(patArchive); |
| | | if (CollectionUtils.isNotEmpty(patientInfoUtils)) { |
| | | patArchiveList.addAll(patientInfoUtils); |
| | | } |
| | | } else if (patArchive.getAllhosp() != null && patArchive.getAllhosp() == 3) { |
| | | List<PatArchiveOthreInfo> patArchives3 = patArchiveMapper.selectPatArchiveInfoByPhysical(patArchive); |
| | |
| | | } |
| | | } else if (patArchiveReq.getAllhosp() != null && patArchiveReq.getAllhosp() == 2) { |
| | | // æ¥çä½é¢ 1 æ¥çé¨è¯ 2 æ¥ç使£ 3 æ¥çåºé¢ 4 |
| | | List<PatArchiveOthreInfo> patArchives2 = patArchiveMapper.selectPatArchiveInfoByOuthospQC(patArchiveReq); |
| | | if (CollectionUtils.isNotEmpty(patArchives2)) { |
| | | patArchiveList.addAll(patArchives2); |
| | | List<PatArchiveOthreInfo> patArchives2 = new ArrayList<>(); |
| | | // List<PatArchiveOthreInfo> patArchives2 = patArchiveMapper.selectPatArchiveInfoByOuthospQC(patArchiveReq); |
| | | |
| | | //鍿¥è¯ä¿¡æ¯ï¼éç¨å表æ¥è¯¢ï¼å
æ¥é¨æ¥è¯çåå¨è¿ç¨ï¼åæ¥æ£è
åºæ¬ä¿¡æ¯è¡¨ï¼å
³èæ¡ä»¶ï¼patidï¼ |
| | | List<PatArchiveOthreInfo> patientInfoUtils = getPatientInfoUtils(patArchiveReq); |
| | | if (CollectionUtils.isNotEmpty(patientInfoUtils)) { |
| | | patArchiveList.addAll(patientInfoUtils); |
| | | } |
| | | } else if (patArchiveReq.getAllhosp() != null && patArchiveReq.getAllhosp() == 3) { |
| | | // æ¥çä½é¢ 1 æ¥çé¨è¯ 2 æ¥ç使£ 3 æ¥çåºé¢ 4 |
| | |
| | | count = patArchiveMapper.countPatArchiveInfoByInhospQC(patArchiveReq); |
| | | } else if (patArchiveReq.getAllhosp() != null && patArchiveReq.getAllhosp() == 2) { |
| | | // æ¥çä½é¢ 1 æ¥çé¨è¯ 2 æ¥ç使£ 3 æ¥çåºé¢ 4 |
| | | count = patArchiveMapper.countPatArchiveInfoByOuthospQC(patArchiveReq); |
| | | // count = patArchiveMapper.countPatArchiveInfoByOuthospQC(patArchiveReq); |
| | | PatMedOuthospQueryReq req=new PatMedOuthospQueryReq(); |
| | | String deptcodes = CollectionUtils.isEmpty(patArchiveReq.getLeaveldeptcodes()) ? null : String.join(",", patArchiveReq.getLeaveldeptcodes()); |
| | | String leavehospitaldistrictcodes = CollectionUtils.isEmpty(patArchiveReq.getLeavehospitaldistrictcodes()) ? null : String.join(",", patArchiveReq.getLeavehospitaldistrictcodes()); |
| | | req.setDeptcode(deptcodes); |
| | | req.setHospitaldistrictcode(leavehospitaldistrictcodes); |
| | | req.setOrgid(patArchiveReq.getOrgid()); |
| | | req.setDrname(StringUtils.isNotEmpty(patArchiveReq.getDrname()) ? patArchiveReq.getDrname() : null); |
| | | req.setPatname(StringUtils.isNotEmpty(patArchiveReq.getName()) ? patArchiveReq.getName() : null); |
| | | req.setDiagname(StringUtils.isNotEmpty(patArchiveReq.getLeavediagname()) ? patArchiveReq.getLeavediagname() : null); |
| | | count = patMedOuthospMapper.callSpQueryOuthospCount(req); |
| | | |
| | | |
| | | } else if (patArchiveReq.getAllhosp() != null && patArchiveReq.getAllhosp() == 3) { |
| | | // æ¥çä½é¢ 1 æ¥çé¨è¯ 2 æ¥ç使£ 3 æ¥çåºé¢ 4 |
| | | count = patArchiveMapper.countPatArchiveInfoByPhysicalQC(patArchiveReq); |
| | |
| | | |
| | | return count; |
| | | } |
| | | |
| | | private List<PatArchiveOthreInfo> getPatientInfoUtils(PatArchiveReq patArchiveReq) { |
| | | List<PatArchiveOthreInfo> patArchiveList = new ArrayList<>(); |
| | | |
| | | //鍿¥è¯ä¿¡æ¯ï¼éç¨å表æ¥è¯¢ï¼å
æ¥é¨æ¥è¯çåå¨è¿ç¨ï¼åæ¥æ£è
åºæ¬ä¿¡æ¯è¡¨ï¼å
³èæ¡ä»¶ï¼patidï¼ |
| | | PatMedOuthospQueryReq req=new PatMedOuthospQueryReq(); |
| | | String deptcodes = CollectionUtils.isEmpty(patArchiveReq.getLeaveldeptcodes()) ? null : String.join(",", patArchiveReq.getLeaveldeptcodes()); |
| | | String leavehospitaldistrictcodes = CollectionUtils.isEmpty(patArchiveReq.getLeavehospitaldistrictcodes()) ? null : String.join(",", patArchiveReq.getLeavehospitaldistrictcodes()); |
| | | req.setDeptcode(deptcodes); |
| | | req.setHospitaldistrictcode(leavehospitaldistrictcodes); |
| | | req.setOrgid(patArchiveReq.getOrgid()); |
| | | req.setDrname(StringUtils.isNotEmpty(patArchiveReq.getDrname()) ? patArchiveReq.getDrname() : null); |
| | | req.setPatname(StringUtils.isNotEmpty(patArchiveReq.getName()) ? patArchiveReq.getName() : null); |
| | | req.setDiagname(StringUtils.isNotEmpty(patArchiveReq.getLeavediagname()) ? patArchiveReq.getLeavediagname() : null); |
| | | req.setPageNum(patArchiveReq.getPageNum()==null?null:patArchiveReq.getPageNum()); |
| | | req.setPageSize(patArchiveReq.getPageSize()==null?null:patArchiveReq.getPageSize()); |
| | | List<PatMedOuthosp> patMedOuthosps = patMedOuthospMapper.callSpQueryOuthosp(req); |
| | | for (PatMedOuthosp patMedOuthosp:patMedOuthosps ) { |
| | | PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(patMedOuthosp.getPatid()); |
| | | PatArchiveOthreInfo patArchiveOthreInfo = DtoConversionUtils.sourceToTarget(patArchive, PatArchiveOthreInfo.class); |
| | | patArchiveOthreInfo.setDeptcode(patMedOuthosp.getDeptcode()); |
| | | patArchiveOthreInfo.setDeptname(patMedOuthosp.getDeptname()); |
| | | patArchiveOthreInfo.setDrcode(patMedOuthosp.getDrcode()); |
| | | patArchiveOthreInfo.setDrname(patMedOuthosp.getDrname()); |
| | | patArchiveList.add(patArchiveOthreInfo); |
| | | } |
| | | return patArchiveList; |
| | | } |
| | | } |
| | | |
| | |
| | | package com.smartor.service.impl; |
| | | |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.DtoConversionUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.domain.entity.ServiceSubtaskEntity; |
| | | import com.smartor.mapper.*; |
| | | import com.smartor.service.IPatMedOuthospService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.sql.DataSource; |
| | | import java.sql.Connection; |
| | | import java.sql.Statement; |
| | | import java.time.LocalDate; |
| | | import java.time.Period; |
| | | import java.time.ZoneId; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.*; |
| | | |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.domain.entity.SysUserDept; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.DtoConversionUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.domain.entity.ServiceSubtaskEntity; |
| | | import com.smartor.mapper.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.stereotype.Service; |
| | | import com.smartor.service.IPatMedOuthospService; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | /** |
| | | * æ£è
é¨è¯è®°å½Serviceä¸å¡å±å¤ç |
| | |
| | | private PatMedOuthospMapper patMedOuthospMapper; |
| | | |
| | | @Autowired |
| | | private SysUserDeptMapper sysUserDeptMapper; |
| | | private DataSource dataSource; |
| | | |
| | | @Autowired |
| | | private ServiceSubtaskMapper serviceSubtaskMapper; |
| | |
| | | */ |
| | | @Override |
| | | public PatMedOuthosp selectPatMedOuthospById(Long id) { |
| | | return patMedOuthospMapper.selectPatMedOuthospById(id); |
| | | // return patMedOuthospMapper.selectPatMedOuthospById(id); |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public List<PatMedOuthosp> selectPatMedOuthospList(PatMedOuthosp patMedOuthosp) { |
| | | List<PatMedOuthosp> patMedOuthosps = patMedOuthospMapper.selectPatMedOuthospList(patMedOuthosp); |
| | | PatMedOuthospQueryReq patMedOuthospQueryReq = DtoConversionUtils.sourceToTarget(patMedOuthosp, PatMedOuthospQueryReq.class); |
| | | List<PatMedOuthosp> patMedOuthospQueryResps = patMedOuthospMapper.callSpQueryOuthosp(patMedOuthospQueryReq); |
| | | if (patMedOuthosp.getPageNum() != null) { |
| | | for (PatMedOuthosp patMedOuthosp1 : patMedOuthosps) { |
| | | for (PatMedOuthosp patMedOuthosp1 : patMedOuthospQueryResps) { |
| | | PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(patMedOuthosp1.getPatid()); |
| | | if (patArchive.getBirthdate() != null) { |
| | | Map<String, String> map = calculateAge(patArchive.getBirthdate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), LocalDate.now()); |
| | |
| | | if (!CollectionUtils.isEmpty(serviceSubtaskList)) patMedOuthosp1.setServerState("1"); |
| | | } |
| | | } |
| | | return patMedOuthosps; |
| | | return patMedOuthospQueryResps; |
| | | } |
| | | |
| | | public Map<String, String> calculateAge(LocalDate birthdate, LocalDate today) { |
| | |
| | | |
| | | /** |
| | | * æ°å¢æ£è
é¨è¯è®°å½ |
| | | * æ ¹æ® admitdate è·¯ç±å°å¯¹åºå表ï¼è¥å表ä¸åå¨ååå
¥ä¸»è¡¨ |
| | | * |
| | | * @param patMedOuthosp æ£è
é¨è¯è®°å½ |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public int insertPatMedOuthosp(PatMedOuthosp patMedOuthosp) { |
| | | if (patMedOuthosp.getAdmitdate() != null) { |
| | | log.error("鍿¥å°±è¯æ¶é´ä¸è½ä¸ºç©º"); |
| | | return 0; |
| | | } |
| | | patMedOuthosp.setCreateTime(DateUtils.getNowDate()); |
| | | patMedOuthosp.setUpdateTime(DateUtils.getNowDate()); |
| | | return patMedOuthospMapper.insertPatMedOuthosp(patMedOuthosp); |
| | | patMedOuthosp.setGuid(UUID.randomUUID().toString()); |
| | | //éè¦æå
¥å°åªä¸ªè¡¨ï¼æ ¹æ®å°±è¯æ¶é´çæ¥ææ¥å®ï¼å¦ææ ¹æ®å°±è¯æ¶é´æ¥ç¡®å®ç表ä¸åå¨ï¼ååå¨pat_med_outhospè¡¨ä¸ |
| | | String targetTable = resolveTargetTable(patMedOuthosp.getAdmitdate()); |
| | | if (targetTable != null) { |
| | | log.info("[insert] è·¯ç±å°å表: {}", targetTable); |
| | | return patMedOuthospMapper.insertIntoTable(targetTable, patMedOuthosp); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹æ£è
é¨è¯è®°å½ |
| | | * æ ¹æ® admitdate è·¯ç±å°å¯¹åºå表ï¼è¥å表ä¸åå¨åæ¹ä¸»è¡¨ |
| | | * |
| | | * @param patMedOuthosp æ£è
é¨è¯è®°å½ |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public int updatePatMedOuthosp(PatMedOuthosp patMedOuthosp) { |
| | | if (patMedOuthosp.getSerialnum() == null) { |
| | | log.error("æµæ°´å·ä¸è½ä¸ºç©º"); |
| | | return 0; |
| | | } |
| | | PatMedOuthospQueryReq patMedOuthospQueryReq = new PatMedOuthospQueryReq(); |
| | | patMedOuthospQueryReq.setSerialnum(patMedOuthosp.getSerialnum()); |
| | | patMedOuthospQueryReq.setGuid(patMedOuthosp.getGuid()); |
| | | patMedOuthospQueryReq.setOuthospno(patMedOuthosp.getOuthospno()); |
| | | List<PatMedOuthosp> patMedOuthosps = patMedOuthospMapper.callSpQueryOuthosp(patMedOuthospQueryReq); |
| | | |
| | | if (patMedOuthosps == null || patMedOuthosps.size() == 0) { |
| | | insertPatMedOuthosp(patMedOuthosp); |
| | | } else { |
| | | patMedOuthosp.setUpdateTime(DateUtils.getNowDate()); |
| | | return patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp); |
| | | String targetTable = resolveTargetTable(patMedOuthosp.getAdmitdate()); |
| | | if (targetTable != null) { |
| | | log.info("[update] è·¯ç±å°å表: {}", targetTable); |
| | | return patMedOuthospMapper.updateInTable(targetTable, patMedOuthosp); |
| | | } |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ® create_time æ¨ç®ç®æ å表åï¼ä¸å»ºè¡¨çç¥ä¿æä¸è´ |
| | | * <ul> |
| | | * <li>6ä½åç¼ï¼YYYYMMï¼â ææå表</li> |
| | | * <li>8ä½åç¼ï¼YYYYMMddï¼â æå£åº¦å表ï¼å£åº¦åç¼åºå®ä¸º 0103/0406/0709/1012</li> |
| | | * <li>4ä½åç¼ï¼YYYYï¼ â æå¹´å表</li> |
| | | * </ul> |
| | | * æ¨ç®åºè¡¨ååæ ¡éªè¡¨æ¯å¦åå¨ï¼ä¸åå¨è¿å nullï¼åè½ä¸»è¡¨ï¼ |
| | | * |
| | | * @param createTime å建æ¶é´ï¼ä¸º null æ¶è¿å null |
| | | * @return ç®æ å表åï¼æ null |
| | | */ |
| | | private String resolveTargetTable(java.util.Date createTime) { |
| | | if (createTime == null) return null; |
| | | List<String> allTables = patMedOuthospMapper.getAllOuthospTableNames(); |
| | | if (allTables == null || allTables.isEmpty()) return null; |
| | | |
| | | // 夿å½åå表åç¼é¿åº¦ï¼ä»¥ç¬¬ä¸å¼ 表为åï¼ |
| | | String sample = allTables.get(0); |
| | | String suffix = sample.replaceFirst("pat_med_outhosp_", ""); |
| | | int suffixLen = suffix.length(); |
| | | |
| | | java.util.Calendar cal = java.util.Calendar.getInstance(); |
| | | cal.setTime(createTime); |
| | | int year = cal.get(java.util.Calendar.YEAR); |
| | | int month = cal.get(java.util.Calendar.MONTH) + 1; // 1-based |
| | | |
| | | String targetTable; |
| | | if (suffixLen == 4) { |
| | | // æå¹´ |
| | | targetTable = "pat_med_outhosp_" + year; |
| | | } else if (suffixLen == 6) { |
| | | // ææ |
| | | targetTable = String.format("pat_med_outhosp_%d%02d", year, month); |
| | | } else { |
| | | // æå£åº¦ï¼8ä½åç¼ï¼å¦ 20260103ï¼ |
| | | String quarterSuffix; |
| | | if (month <= 3) quarterSuffix = "0103"; |
| | | else if (month <= 6) quarterSuffix = "0406"; |
| | | else if (month <= 9) quarterSuffix = "0709"; |
| | | else quarterSuffix = "1012"; |
| | | targetTable = "pat_med_outhosp_" + year + quarterSuffix; |
| | | } |
| | | |
| | | boolean exists = allTables.contains(targetTable); |
| | | |
| | | log.info("[è·¯ç±] createTime={} â ç®æ 表={} exists={}", createTime, targetTable, exists); |
| | | return exists ? targetTable : "pat_med_outhosp"; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public int deletePatMedOuthospByIds(Long[] ids) { |
| | | return patMedOuthospMapper.deletePatMedOuthospByIds(ids); |
| | | // return patMedOuthospMapper.deletePatMedOuthospByIds(ids); |
| | | return 0; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public int deletePatMedOuthospById(Long id) { |
| | | return patMedOuthospMapper.deletePatMedOuthospById(id); |
| | | // return patMedOuthospMapper.deletePatMedOuthospById(id); |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public PatMedRes selectPatMedOuthospCount(PatMedReq patMedReq) { |
| | | // // è·åå½åç»é人çé¨é¨æé |
| | | // if (CollectionUtils.isEmpty(patMedReq.getDeptcodeList())) { |
| | | // Long userId = SecurityUtils.getUserId(); |
| | | // List<SysDept> sysDepts = sysUserDeptMapper.selectDeptListByUserId(userId); |
| | | // List<String> deptCode = new ArrayList<>(); |
| | | // for (SysDept sysDept : sysDepts) { |
| | | // deptCode.add(sysDept.getDeptId().toString()); |
| | | // } |
| | | // patMedReq.setDeptcodeList(deptCode); |
| | | // } |
| | | return patMedOuthospMapper.selectPatMedOuthospCount(patMedReq); |
| | | //è·åé¨è¯ç
人信æ¯ï¼å¹¶ç»è®¡äººæ°å人次 |
| | | PatMedOuthospQueryReq req = new PatMedOuthospQueryReq(); |
| | | String deptcodes = CollectionUtils.isEmpty(patMedReq.getDeptcodeList()) ? null : String.join(",", patMedReq.getDeptcodeList()); |
| | | req.setBeginAdmitdate(patMedReq.getStartDate()); |
| | | req.setEndAdmitdate(patMedReq.getEndDate()); |
| | | req.setDeptcode(deptcodes); |
| | | req.setOrgid(patMedReq.getOrgid()); |
| | | // req.setCampusid(patMedReq.getCampusid()); |
| | | Long count = patMedOuthospMapper.callSpQueryOuthospCount(req); |
| | | |
| | | //æ¥è¯¢é访人次åäººæ° |
| | | PatMedRes patMedRes = serviceSubtaskMapper.selectVisitCount(patMedReq); |
| | | patMedRes.setRc(count == null ? 0 : count.intValue()); |
| | | return patMedRes; |
| | | } |
| | | |
| | | @Override |
| | |
| | | if (org.apache.commons.collections4.CollectionUtils.isEmpty(serviceTaskdeptList) || serviceTaskdeptList.size() == 0) { |
| | | patMedOuthosp1.setDeptcheckFlag("2"); |
| | | patMedOuthosp1.setRemark("éè¿é¨é¨,æ²¡ææ¾å°é¨è¯é访任å¡ID"); |
| | | patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp1); |
| | | updatePatMedOuthosp(patMedOuthosp1); |
| | | } else { |
| | | for (ServiceTaskdept serviceTaskdept1 : serviceTaskdeptList) { |
| | | writeInSubTask(serviceTaskdept1.getTaskId(), true, patMedOuthosp1, patArchive, 1); |
| | |
| | | if (org.apache.commons.collections4.CollectionUtils.isEmpty(serviceTaskdiags) || serviceTaskdiags.size() == 0) { |
| | | patMedOuthosp1.setDiagcheckFlag("2"); |
| | | patMedOuthosp1.setRemark("éè¿icd10,æ²¡ææ¾å°é¨è¯é访任å¡ID"); |
| | | patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp1); |
| | | updatePatMedOuthosp(patMedOuthosp1); |
| | | } else { |
| | | for (ServiceTaskdiag serviceTaskdept1 : serviceTaskdiags) { |
| | | writeInSubTask(serviceTaskdept1.getTaskId(), true, patMedOuthosp1, patArchive, 2); |
| | |
| | | if (type == 1) patMedOuthosp.setDiagcheckFlag("2"); |
| | | if (type == 2) patMedOuthosp.setDeptcheckFlag("2"); |
| | | patMedOuthosp.setRemark("该æ£è
é¨è¯éè®¿é¿æä»»å¡ä¸åå¨,ä»»å¡ID为:" + taskid); |
| | | patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp); |
| | | updatePatMedOuthosp(patMedOuthosp); |
| | | return; |
| | | } |
| | | ServiceTask serviceTask = serviceTasks.get(0); |
| | |
| | | patMedOuthosp1.setId(patMedOuthosp.getId()); |
| | | if (type == 1) patMedOuthosp1.setDiagcheckFlag("2"); |
| | | if (type == 2) patMedOuthosp1.setDeptcheckFlag("2"); |
| | | patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp1); |
| | | updatePatMedOuthosp(patMedOuthosp1); |
| | | } else { |
| | | //çæåä»»å¡å¤±è´¥ï¼ |
| | | log.info("çæåä»»å¡å¤±è´¥serviceSubtaskçtaskid为ï¼{},patid为ï¼{}", serviceSubtask.getTaskid(), serviceSubtask.getPatid()); |
| | | PatMedOuthosp pmo = new PatMedOuthosp(); |
| | | pmo.setId(patMedOuthosp.getId()); |
| | | pmo.setGuid(patMedOuthosp.getGuid()); |
| | | pmo.setSerialnum(patMedOuthosp.getSerialnum()); |
| | | if (type == 1) pmo.setDiagcheckFlag("2"); |
| | | if (type == 2) pmo.setDeptcheckFlag("2"); |
| | | pmo.setRemark("çæåä»»å¡å¤±è´¥"); |
| | | patMedOuthospMapper.updatePatMedOuthosp(pmo); |
| | | updatePatMedOuthosp(pmo); |
| | | } |
| | | } |
| | | |
| | |
| | | package com.smartor.service.impl; |
| | | |
| | | import com.smartor.domain.PatMedOuthosp; |
| | | import com.smartor.domain.PatMedOuthospQueryReq; |
| | | import com.smartor.domain.PerSonWorkbenchDto; |
| | | import com.smartor.mapper.PatArchiveOutMapper; |
| | | import com.smartor.mapper.PatMedOuthospMapper; |
| | | import com.smartor.service.PersonWorkbenchService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Autowired |
| | | private PatArchiveOutMapper patArchiveOutMapper; |
| | | |
| | | @Autowired |
| | | private PatMedOuthospMapper patMedOuthospMapper; |
| | | |
| | | @Override |
| | | public List<PerSonWorkbenchDto> getPatCount(String detpId, String drCode) { |
| | | long[] deptIds = Arrays.stream(detpId.split(",")).mapToLong(Long::parseLong).toArray(); |
| | | public List<PerSonWorkbenchDto> getPatCount(String deptcode, String drCode) { |
| | | List<String> deptIds = Arrays.asList(deptcode.split(",")); |
| | | String[] drCodes = drCode.split(","); |
| | | |
| | | List<PerSonWorkbenchDto> perSonWorkbenchDtos = patArchiveOutMapper.selectPatArchiveCount(deptIds, drCodes); |
| | | |
| | | return perSonWorkbenchDtos; |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.DtoConversionUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.domain.entity.ServiceSubtaskEntity; |
| | | import com.smartor.mapper.*; |
| | | import com.smartor.service.IPatMedOuthospService; |
| | | import com.smartor.service.IServiceExternalService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | |
| | | private PatMedInspectionItemMapper patMedInspectionItemMapper; |
| | | @Autowired |
| | | private Icd10Mapper icd10Mapper; |
| | | @Autowired |
| | | private IPatMedOuthospService patMedOuthospService; |
| | | @Autowired |
| | | private PatMedOuthospMapper patMedOuthospMapper; |
| | | @Autowired |
| | |
| | | sysUserDeptTemp.setUserId(sysUser.getUserId()); |
| | | sysUserDeptTemp.setOrgid(externalUserDeptInfo.getZuZhiJGID()); |
| | | List<SysUserDept> sysUserDepts = sysUserDeptMapper.selectSysUserDeptList(sysUserDeptTemp); |
| | | List<String> userDepts = sysUserDepts.stream().map(SysUserDept::getDeptCode). |
| | | distinct().collect(Collectors.toList()); |
| | | List<String> userDepts = sysUserDepts.stream().map(SysUserDept::getDeptCode).distinct().collect(Collectors.toList()); |
| | | //åqueryHospUserInfoListééçæ°æ®æ ¼å¼ä¿æä¸è´ |
| | | List<List<String>> userDeptsList = new ArrayList<>(); |
| | | if(!userDepts.isEmpty()){ |
| | |
| | | * ç¬¬ä¸æ¡ï¼æ¥è¯ç§å®¤çï¼è®°å½ç¼ºå°âåºé¢æ¶é´âï¼å¯¼è´è¯¥è®°å½å¨ç»è®¡ä¸å§ç»æ¾ç¤ºä¸ºâå¨é¢âï¼ |
| | | * èç¬¬äºæ¡ï¼è½¬å
¥ç§å®¤çï¼è®°å½æ¯å®æ´çãæä»¬éè¦éé JZ_ZY_LiQiangæ¥å£çæ°æ®ï¼ |
| | | * éé¢çç¦»æ¢æ¶é´æ¥åå¡«ç¬¬ä¸æ¡è®°å½çâåºé¢æ¶é´âï¼ä»èä¿®æ£ç¬¬ä¸æ¡è®°å½çç¶æã |
| | | * |
| | | * @param dataMap |
| | | * @return |
| | | */ |
| | |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Boolean addFinshJZInfo(Map dataMap) { |
| | | log.info("ServiceExternalServiceImpl---addFinshJZInfoçæ°å¢çå¼ä¸ºï¼{}", dataMap); |
| | | //å
对表è¿è¡ç»´æ¤ |
| | | tableMaintenance(); |
| | | |
| | | Map yeWuXX = (Map) dataMap.get("YeWuXX"); |
| | | Map XiaoXiTou = (Map) dataMap.get("XiaoXiTou"); |
| | |
| | | |
| | | PatArchive patArchive = addPatArchive(externalInHospPatientInfo, null, null); |
| | | |
| | | PatMedOuthosp patMedOuthosp = new PatMedOuthosp(); |
| | | patMedOuthosp.setOuthospno(externalInHospPatientInfo.getBingAnHao()); |
| | | patMedOuthosp.setSerialnum(externalInHospPatientInfo.getJiuZhenYWID()); |
| | | List<PatMedOuthosp> patMedOuthosps = patMedOuthospMapper.selectPatMedOuthospList(patMedOuthosp); |
| | | PatMedOuthospQueryReq patMedOuthospreq = new PatMedOuthospQueryReq(); |
| | | patMedOuthospreq.setOuthospno(externalInHospPatientInfo.getBingAnHao()); |
| | | patMedOuthospreq.setSerialnum(externalInHospPatientInfo.getJiuZhenYWID()); |
| | | List<PatMedOuthosp> patMedOuthosps = patMedOuthospMapper.callSpQueryOuthosp(patMedOuthospreq); |
| | | for (PatMedOuthosp patMedOuthosp1 : patMedOuthosps) { |
| | | PatArchive pa = patArchiveMapper.selectPatArchiveByPatid(patMedOuthosp1.getPatid()); |
| | | if (patArchive.getBirthdate() != null) { |
| | |
| | | } |
| | | } |
| | | |
| | | PatMedOuthosp patMedOuthosp = DtoConversionUtils.sourceToTarget(patMedOuthospreq, PatMedOuthosp.class); |
| | | patMedOuthosp.setPatid(patArchive.getId()); |
| | | patMedOuthosp.setPatno(externalInHospPatientInfo.getBingAnHao()); |
| | | patMedOuthosp.setPatname(externalInHospPatientInfo.getXingMing()); |
| | |
| | | //ä¸éè¦é¿æä»»å¡é访ï¼ç±å»çèªå·±å»é访ï¼ä¸½æ°´ä¸å»é¢é¦æ¬¡æåºï¼ |
| | | patMedOuthosp.setFuflag("1"); |
| | | } |
| | | i = patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp); |
| | | i = patMedOuthospService.updatePatMedOuthosp(patMedOuthosp); |
| | | } else { |
| | | patMedOuthosp.setCreateTime(new Date()); |
| | | patMedOuthosp.setUpdateTime(new Date()); |
| | |
| | | //ä¸éè¦é¿æä»»å¡é访 |
| | | patMedOuthosp.setFuflag("1"); |
| | | } |
| | | i = patMedOuthospMapper.insertPatMedOuthosp(patMedOuthosp); |
| | | } |
| | | i = patMedOuthospService.insertPatMedOuthosp(patMedOuthosp); |
| | | |
| | | // //å
éè¿èº«ä»½è¯åç§å®¤æ¥è¯¢è¯¥æ£è
æ¯å¦æéè¦é访ç(æ¯å®æåºæ¥ç) |
| | | // if (patMedOuthosp.getOrgid().equals("47255004333112711A1001") && StringUtils.isNotEmpty(patMedOuthosp.getIdcardno()) && StringUtils.isNotEmpty(patMedOuthosp.getDeptcode())) { |
| | | // ServiceSubtaskVO serviceSubtaskVO = new ServiceSubtaskVO(); |
| | | // serviceSubtaskVO.setSfzh(patMedOuthosp.getIdcardno()); |
| | | // serviceSubtaskVO.setDeptcode(patMedOuthosp.getDeptcode()); |
| | | // serviceSubtaskVO.setSendstate(2L); |
| | | // List<ServiceSubtask> serviceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskVO); |
| | | // if (CollectionUtils.isNotEmpty(serviceSubtaskList)) { |
| | | // for (ServiceSubtask serviceSubtask : serviceSubtaskList) { |
| | | // serviceSubtask.setSendstate(6L); |
| | | // serviceSubtask.setRemark("æ£è
å·²ç»åæ¥å¤è¯"); |
| | | // serviceSubtask.setUpdateTime(new Date()); |
| | | // serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); |
| | | // } |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | if (i > 0) { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | public void tableMaintenance() { |
| | | // 1. å¤æè¡¨æ°æ®é |
| | | int count = patMedOuthospMapper.countPatMedOuthosp(); |
| | | if (count > 3000000) { |
| | | // 2. å·è表并æ°å»º |
| | | String timeSuffix = new SimpleDateFormat("yyyyMM").format(new Date()); |
| | | String oldName = "pat_med_outhosp"; |
| | | String newName = oldName + "_" + timeSuffix; |
| | | |
| | | // å·è |
| | | patMedOuthospMapper.renameTable(oldName, newName); |
| | | |
| | | // 3. è®¡ç®ææè¡¨çæå¤§id |
| | | List<String> tableNames = patMedOuthospMapper.getAllOuthospTableNames(); |
| | | long maxId = 0; |
| | | for (String tableName : tableNames) { |
| | | Long tableMaxId = patMedOuthospMapper.getMaxIdFromTable(tableName); |
| | | if (tableMaxId != null && tableMaxId > maxId) { |
| | | maxId = tableMaxId; |
| | | } |
| | | } |
| | | |
| | | // 4. æ°å»º(æ¤æ¶åªå©å·è¡¨ï¼PatMedOuthosp没äºï¼éè¦æ°å»ºä¸ä¸ª) |
| | | patMedOuthospMapper.createPatMedOuthosp(newName, oldName); |
| | | |
| | | //5.设置æ°è¡¨èªå¢ä¸»é® |
| | | patMedOuthospMapper.createPatMedOuthospAutoAdd(oldName); |
| | | //6. 设置æ°è¡¨èªå¢èµ·å§å¼ |
| | | patMedOuthospMapper.setAutoIncrement(oldName, maxId + 1); |
| | | |
| | | // 7. æ´æ°/æ°å»ºè§å¾ |
| | | // éæ°è·åææè¡¨åï¼å
å«åæ°å»ºçä¸»è¡¨ï¼ |
| | | List<String> allTables = patMedOuthospMapper.getAllOuthospTableNames(); |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append("CREATE OR REPLACE VIEW v_pat_med_outhosp AS "); |
| | | for (int i = 0; i < allTables.size(); i++) { |
| | | sb.append("SELECT * FROM ").append(allTables.get(i)); |
| | | if (i < allTables.size() - 1) { |
| | | sb.append(" UNION ALL "); |
| | | } |
| | | } |
| | | patMedOuthospMapper.createOrReplaceView(sb.toString()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | import com.smartor.mapper.*; |
| | | import com.smartor.service.IPatArchiveService; |
| | | import com.smartor.service.IPatMedInhospService; |
| | | import com.smartor.service.IPatMedOuthospService; |
| | | import com.smartor.service.IServiceSLTDHealthcareRecordService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | |
| | | private IPatMedInhospService patMedInhospService; |
| | | |
| | | @Autowired |
| | | private PatMedOuthospMapper patMedOuthospMapper; |
| | | private IPatMedOuthospService patMedOuthospService; |
| | | |
| | | @Autowired |
| | | private SysUser2Mapper sysUser2Mapper; |
| | |
| | | try { |
| | | //è¿éç¨èªå¨å¿½ç¥éå¤ä¼æé®é¢ï¼å¦æè¡¨éæ°å»ºï¼serialnumç´¢å¼ä¼ä¸¢å¤±ãå°±æ æ³å»éï¼æä»¥è¿æ¯éè¦å
åéå»é |
| | | batchList = DistinctByProperty.distinctByProperty(batchList, PatMedOuthosp::getSerialnum); |
| | | int insertCount = patMedOuthospMapper.batchInsertIgnore(batchList); |
| | | Integer insertCount = 0; |
| | | for (PatMedOuthosp patMedOuthosp : batchList) { |
| | | insertCount += patMedOuthospService.insertPatMedOuthosp(patMedOuthosp); |
| | | } |
| | | |
| | | log.info("æ¹éæå
¥é¨æ¥è¯è®°å½ï¼æ»æ°ï¼{}, å®é
æå
¥ï¼{}", batchList.size(), insertCount); |
| | | |
| | | } catch (Exception e) { |
| | | log.error("æ¹éæå
¥é¨æ¥è¯è®°å½å¤±è´¥", e); |
| | | // éçº§ä¸ºéæ¡æå
¥ |
| | | for (PatMedOuthosp patMedOuthosp : batchList) { |
| | | try { |
| | | patMedOuthospMapper.insertPatMedOuthosp(patMedOuthosp); |
| | | } catch (Exception ex) { |
| | | log.warn("åæ¡æå
¥å¤±è´¥ï¼serialnum={}", patMedOuthosp.getSerialnum()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return true; |
| | |
| | | if (CollectionUtils.isNotEmpty(patMedInhospList)) patid = patMedInhospList.get(0).getPatid(); |
| | | } else if (serviceSubTaskMYDAnswerReq.getMzzy().equals("2")) { |
| | | //é¨è¯ |
| | | PatMedOuthosp patMedOuthosp = new PatMedOuthosp(); |
| | | PatMedOuthospQueryReq patMedOuthosp = new PatMedOuthospQueryReq(); |
| | | patMedOuthosp.setSerialnum(serviceSubTaskMYDAnswerReq.getSerialnum()); |
| | | patMedOuthosps = patMedOuthospMapper.selectPatMedOuthospList(patMedOuthosp); |
| | | patMedOuthosps = patMedOuthospMapper.callSpQueryOuthosp(patMedOuthosp); |
| | | if (CollectionUtils.isNotEmpty(patMedOuthosps)) patid = patMedOuthosps.get(0).getPatid(); |
| | | } else if (serviceSubTaskMYDAnswerReq.getMzzy().equals("3")) { |
| | | //æå®ä¸ä¸ªé¨é¨ï¼ç¨æ¥å¤çæè¯å»ºè®® |
| | |
| | | private IServiceOutPathService iServiceOutPathService; |
| | | |
| | | @Autowired |
| | | private IPatMedOuthospService iPatMedOuthospService; |
| | | |
| | | @Autowired |
| | | private FtpService ftpService; |
| | | |
| | | @Autowired |
| | | private PatMedInhospMapper patMedInhospMapper; |
| | | |
| | | @Autowired |
| | | private PatMedOuthospMapper patMedOuthospMapper; |
| | | |
| | | @Autowired |
| | | private PatArchiveMapper patArchiveMapper; |
| | |
| | | serviceTaskdept.setDeptCode(deptCode); |
| | | serviceTaskdept.setDeptType("1"); |
| | | serviceTaskdept.setServiceType(serviceTaskVO.getServiceType()); |
| | | //å
éè¿ä»»å¡IDãé¨é¨code,夿ServiceTaskdeptæ¯å¦åå¨ï¼ä¸åå¨åæ°å¢ï¼åå¨åä¿®æ¹ |
| | | serviceTaskdeptService.insertOrUpdateServiceTaskdept(serviceTaskdept); |
| | | serviceTaskdeptService.insertServiceTaskdept(serviceTaskdept); |
| | | } |
| | | } |
| | | if (StringUtils.isNotEmpty(serviceTaskVO.getLeavehospitaldistrictcode())) { |
| | |
| | | serviceTaskdept.setDeptCode(districtcode); |
| | | serviceTaskdept.setDeptType("2"); |
| | | serviceTaskdept.setServiceType(serviceTaskVO.getServiceType()); |
| | | //å
éè¿ä»»å¡IDãé¨é¨code,夿ServiceTaskdeptæ¯å¦åå¨ï¼ä¸åå¨åæ°å¢ï¼åå¨åä¿®æ¹ |
| | | serviceTaskdeptService.insertOrUpdateServiceTaskdept(serviceTaskdept); |
| | | serviceTaskdeptService.insertServiceTaskdept(serviceTaskdept); |
| | | } |
| | | } |
| | | } |
| | |
| | | serviceTaskdept.setDeptCode(deptCode); |
| | | serviceTaskdept.setDeptType("1"); |
| | | serviceTaskdept.setServiceType(serviceTaskVO.getServiceType()); |
| | | //å
éè¿ä»»å¡IDãé¨é¨code,夿ServiceTaskdeptæ¯å¦åå¨ï¼ä¸åå¨åæ°å¢ï¼åå¨åä¿®æ¹ |
| | | serviceTaskdeptService.insertOrUpdateServiceTaskdept(serviceTaskdept); |
| | | ServiceTaskdept st = new ServiceTaskdept(); |
| | | st.setDeptCode(deptCode); |
| | | st.setTaskId(serviceTask.getTaskid()); |
| | | List<ServiceTaskdept> serviceTaskdepts = serviceTaskdeptService.selectServiceTaskdeptList(st); |
| | | if (CollectionUtils.isEmpty(serviceTaskdepts)) { |
| | | serviceTaskdeptService.insertServiceTaskdept(serviceTaskdept); |
| | | } else { |
| | | serviceTaskdeptService.updateServiceTaskdept(serviceTaskdept); |
| | | } |
| | | } |
| | | } |
| | | if (StringUtils.isNotEmpty(serviceTaskVO.getLeavehospitaldistrictcode())) { |
| | |
| | | serviceTaskdept.setDeptType("2"); |
| | | serviceTaskdept.setServiceType(serviceTaskVO.getServiceType()); |
| | | //å
éè¿ä»»å¡IDãé¨é¨code,夿ServiceTaskdeptæ¯å¦åå¨ï¼ä¸åå¨åæ°å¢ï¼åå¨åä¿®æ¹ |
| | | serviceTaskdeptService.insertOrUpdateServiceTaskdept(serviceTaskdept); |
| | | ServiceTaskdept st = new ServiceTaskdept(); |
| | | st.setDeptCode(districtcode); |
| | | st.setTaskId(serviceTask.getTaskid()); |
| | | List<ServiceTaskdept> serviceTaskdepts = serviceTaskdeptService.selectServiceTaskdeptList(st); |
| | | if (CollectionUtils.isEmpty(serviceTaskdepts)) { |
| | | serviceTaskdeptService.insertServiceTaskdept(serviceTaskdept); |
| | | } else { |
| | | serviceTaskdeptService.updateServiceTaskdept(serviceTaskdept); |
| | | } |
| | | } |
| | | } |
| | | } else if (serviceTaskVO.getAppltype().equals("3")) { |
| | |
| | | |
| | | List<ServiceStatisticsResponse> result = serviceSubtaskMapper.getServiceStatistics(request); |
| | | |
| | | //è·å鍿¥è¯æ°æ® |
| | | |
| | | //å¡«å
é¨è¯æ°æ® |
| | | for (ServiceStatisticsResponse serviceStatisticsResponse : result) { |
| | | PatMedOuthospQueryReq req = new PatMedOuthospQueryReq(); |
| | | String deptcodes = CollectionUtils.isEmpty(request.getDeptcodes()) ? null : String.join(",", request.getDeptcodes()); |
| | | if (!request.getTimeType().equals("month")) { |
| | | req.setBeginAdmitdate(DateUtils.parseDate(serviceStatisticsResponse.getTimePeriod())); |
| | | req.setEndAdmitdate(DateUtils.parseDate(serviceStatisticsResponse.getTimePeriod())); |
| | | } else { |
| | | // year ç±»åï¼timePeriod æ ¼å¼ä¸º "yyyy-MM"ï¼åå½æç¬¬ä¸å¤©åæåä¸å¤© |
| | | java.time.YearMonth ym = java.time.YearMonth.parse(serviceStatisticsResponse.getTimePeriod()); |
| | | req.setBeginAdmitdate(DateUtils.toDate(ym.atDay(1))); |
| | | req.setEndAdmitdate(DateUtils.toDate(ym.atEndOfMonth())); |
| | | } |
| | | req.setDeptcode(deptcodes); |
| | | req.setOrgid(request.getOrgid()); |
| | | Long count = patMedOuthospMapper.callSpQueryOuthospCount(req); |
| | | serviceStatisticsResponse.setPmoCount(count); |
| | | } |
| | | |
| | | log.info("getServiceStatisticsè¿åç»ææ°éï¼{}", result.size()); |
| | | return result; |
| | |
| | | patArchive = patArchiveMapper.selectPatArchiveByPatid(patMedInhospList.get(0).getPatid()); |
| | | } |
| | | } else if (StringUtils.isNotEmpty(mzserialnum)) { |
| | | PatMedOuthosp patMedOuthosp = new PatMedOuthosp(); |
| | | PatMedOuthospQueryReq patMedOuthosp = new PatMedOuthospQueryReq(); |
| | | patMedOuthosp.setSerialnum(mzserialnum); |
| | | List<PatMedOuthosp> patMedOuthosps = patMedOuthospMapper.selectPatMedOuthospList(patMedOuthosp); |
| | | List<PatMedOuthosp> patMedOuthosps = patMedOuthospMapper.callSpQueryOuthosp(patMedOuthosp); |
| | | if (CollectionUtils.isNotEmpty(patMedOuthosps)) { |
| | | patArchive = patArchiveMapper.selectPatArchiveByPatid(patMedOuthosps.get(0).getPatid()); |
| | | } |
| | |
| | | <select id="selectHeLibraryAssortList" parameterType="com.smartor.domain.HeLibraryAssort" |
| | | resultMap="HeLibraryAssortResult"> |
| | | <include refid="selectHeLibraryAssortVo"/> |
| | | where 1=1 |
| | | and del_flag != 1 |
| | | where del_flag != 1 |
| | | <if test="assortname != null and assortname != ''">and assortname like concat('%', #{assortname}, '%')</if> |
| | | <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if> |
| | | <if test="isupload != null ">and isupload = #{isupload}</if> |
| | |
| | | <if test="guid != null and guid != ''">and guid = #{guid}</if> |
| | | <if test="seqno != null ">and seqno = #{seqno}</if> |
| | | <if test="hetype != null ">and hetype = #{hetype}</if> |
| | | |
| | | order by seqno asc |
| | | <if test="pageSize != null and pageNum != null">limit ${pageSize} OFFSET ${pageNum}</if> |
| | | </select> |
| | | |
| | | <select id="selectSeqMax" resultType="integer"> |
| | |
| | | ) as tmp |
| | | </select> |
| | | |
| | | <select id="selectPatArchiveInfoByOuthospQC" parameterType="com.smartor.domain.PatArchiveReq" |
| | | resultMap="PatArchiveOthreInfoResult"> |
| | | <!-- <select id="selectPatArchiveInfoByOuthospQC" parameterType="com.smartor.domain.PatArchiveReq"--> |
| | | <!-- resultMap="PatArchiveOthreInfoResult">--> |
| | | |
| | | select |
| | | a.idcardno, |
| | | a.id, |
| | | a.age_unit, |
| | | a.age_unit2, |
| | | a.patid_his, |
| | | a.sd_flag, |
| | | a.campusid, |
| | | a.patientno, |
| | | a.notrequired_flag, |
| | | a.notrequiredreason, |
| | | d.deptname, |
| | | d.deptcode, |
| | | d.drcode, |
| | | d.drname, |
| | | a.name, |
| | | a.sex, |
| | | a.nation, |
| | | a.native_place, |
| | | a.place_of_residence, |
| | | a.birthplace, |
| | | a.birthdate, |
| | | a.age, |
| | | a.age2, |
| | | a.viptype, |
| | | a.sourcefrom, |
| | | a.archivetime, |
| | | a.archiveby, |
| | | a.telcode, |
| | | a.relativetelcode, |
| | | a.idcardtype, |
| | | a.orgid, |
| | | a.openid, |
| | | a.del_flag, |
| | | a.update_by, |
| | | a.update_time, |
| | | a.create_by, |
| | | a.create_time, |
| | | a.isupload, |
| | | a.upload_time, |
| | | a.filter_drname, |
| | | a.filter_drcode, |
| | | a.pattype |
| | | from pat_med_outhosp d JOIN pat_archive a ON a.id = d.patid |
| | | where 1=1 |
| | | and d.del_flag != 1 |
| | | AND a.del_flag != 1 |
| | | and d.orgid = #{orgid} |
| | | <if test="pid != null and pid != ''">and a.id = #{pid}</if> |
| | | <if test="campusid != null and campusid != ''">and a.campusid = #{campusid}</if> |
| | | <if test="name != null and name != ''">and a.name like concat('%', #{name}, '%')</if> |
| | | <if test="idcardno != null and idcardno != ''">and a.idcardno = #{idcardno}</if> |
| | | <if test="telcode != null and telcode != ''">and a.telcode = #{telcode}</if> |
| | | <if test="hospitaldistrictname != null and hospitaldistrictname != ''"> |
| | | AND d.hospitaldistrictname LIKE concat('%',#{hospitaldistrictname}, '%') |
| | | </if> |
| | | <if test="notrequiredFlag != null and notrequiredFlag != ''">and a.notrequired_flag = #{notrequiredFlag} |
| | | </if> |
| | | <if test="leavediagname != null and leavediagname != ''"> |
| | | AND d.diagname LIKE concat('%',#{leavediagname}, '%') |
| | | </if> |
| | | <if test="hospitalname != null and hospitalname != ''"> |
| | | AND d.hospitalname = #{hospitalname} |
| | | </if> |
| | | <if test="visitno != null and visitno != ''"> |
| | | AND d.outhospno = #{visitno} |
| | | </if> |
| | | <if test="deptname != null and deptname != ''"> |
| | | and d.deptname LIKE concat('%', #{deptname}, '%') |
| | | </if> |
| | | <if test="drname != null and drname != ''"> |
| | | AND d.drname LIKE concat('%',#{drname}, '%') |
| | | </if> |
| | | <if test="drcode != null"> |
| | | AND d.drcode = #{drcode} |
| | | </if> |
| | | <if test="pids != null"> |
| | | AND a.id NOT IN |
| | | <foreach collection="pids" item="pid" open="(" separator="," close=")"> |
| | | #{pid} |
| | | </foreach> |
| | | </if> |
| | | <if test="isFilter == true"> |
| | | AND NOT exists ( SELECT 1 FROM pat_filterlist f where d.patid=f.patid) |
| | | </if> |
| | | <if test="pageSize != null and pageNum != null">limit ${pageSize} OFFSET ${pageNum}</if> |
| | | </select> |
| | | <!-- select--> |
| | | <!-- a.idcardno,--> |
| | | <!-- a.id,--> |
| | | <!-- a.age_unit,--> |
| | | <!-- a.age_unit2,--> |
| | | <!-- a.patid_his,--> |
| | | <!-- a.sd_flag,--> |
| | | <!-- a.campusid,--> |
| | | <!-- a.patientno,--> |
| | | <!-- a.notrequired_flag,--> |
| | | <!-- a.notrequiredreason,--> |
| | | <!-- d.deptname,--> |
| | | <!-- d.deptcode,--> |
| | | <!-- d.drcode,--> |
| | | <!-- d.drname,--> |
| | | <!-- a.name,--> |
| | | <!-- a.sex,--> |
| | | <!-- a.nation,--> |
| | | <!-- a.native_place,--> |
| | | <!-- a.place_of_residence,--> |
| | | <!-- a.birthplace,--> |
| | | <!-- a.birthdate,--> |
| | | <!-- a.age,--> |
| | | <!-- a.age2,--> |
| | | <!-- a.viptype,--> |
| | | <!-- a.sourcefrom,--> |
| | | <!-- a.archivetime,--> |
| | | <!-- a.archiveby,--> |
| | | <!-- a.telcode,--> |
| | | <!-- a.relativetelcode,--> |
| | | <!-- a.idcardtype,--> |
| | | <!-- a.orgid,--> |
| | | <!-- a.openid,--> |
| | | <!-- a.del_flag,--> |
| | | <!-- a.update_by,--> |
| | | <!-- a.update_time,--> |
| | | <!-- a.create_by,--> |
| | | <!-- a.create_time,--> |
| | | <!-- a.isupload,--> |
| | | <!-- a.upload_time,--> |
| | | <!-- a.filter_drname,--> |
| | | <!-- a.filter_drcode,--> |
| | | <!-- a.pattype--> |
| | | <!-- from pat_med_outhosp d JOIN pat_archive a ON a.id = d.patid--> |
| | | <!-- where 1=1--> |
| | | <!-- and d.del_flag != 1--> |
| | | <!-- AND a.del_flag != 1--> |
| | | <!-- and d.orgid = #{orgid}--> |
| | | <!-- <if test="pid != null and pid != ''">and a.id = #{pid}</if>--> |
| | | <!-- <if test="campusid != null and campusid != ''">and a.campusid = #{campusid}</if>--> |
| | | <!-- <if test="name != null and name != ''">and a.name like concat('%', #{name}, '%')</if>--> |
| | | <!-- <if test="idcardno != null and idcardno != ''">and a.idcardno = #{idcardno}</if>--> |
| | | <!-- <if test="telcode != null and telcode != ''">and a.telcode = #{telcode}</if>--> |
| | | <!-- <if test="hospitaldistrictname != null and hospitaldistrictname != ''">--> |
| | | <!-- AND d.hospitaldistrictname LIKE concat('%',#{hospitaldistrictname}, '%')--> |
| | | <!-- </if>--> |
| | | <!-- <if test="notrequiredFlag != null and notrequiredFlag != ''">and a.notrequired_flag = #{notrequiredFlag}--> |
| | | <!-- </if>--> |
| | | <!-- <if test="leavediagname != null and leavediagname != ''">--> |
| | | <!-- AND d.diagname LIKE concat('%',#{leavediagname}, '%')--> |
| | | <!-- </if>--> |
| | | <!-- <if test="hospitalname != null and hospitalname != ''">--> |
| | | <!-- AND d.hospitalname = #{hospitalname}--> |
| | | <!-- </if>--> |
| | | <!-- <if test="visitno != null and visitno != ''">--> |
| | | <!-- AND d.outhospno = #{visitno}--> |
| | | <!-- </if>--> |
| | | <!-- <if test="deptname != null and deptname != ''">--> |
| | | <!-- and d.deptname LIKE concat('%', #{deptname}, '%')--> |
| | | <!-- </if>--> |
| | | <!-- <if test="drname != null and drname != ''">--> |
| | | <!-- AND d.drname LIKE concat('%',#{drname}, '%')--> |
| | | <!-- </if>--> |
| | | <!-- <if test="drcode != null">--> |
| | | <!-- AND d.drcode = #{drcode}--> |
| | | <!-- </if>--> |
| | | <!-- <if test="pids != null">--> |
| | | <!-- AND a.id NOT IN--> |
| | | <!-- <foreach collection="pids" item="pid" open="(" separator="," close=")">--> |
| | | <!-- #{pid}--> |
| | | <!-- </foreach>--> |
| | | <!-- </if>--> |
| | | <!-- <if test="isFilter == true">--> |
| | | <!-- AND NOT exists ( SELECT 1 FROM pat_filterlist f where d.patid=f.patid)--> |
| | | <!-- </if>--> |
| | | <!-- <if test="pageSize != null and pageNum != null">limit ${pageSize} OFFSET ${pageNum}</if>--> |
| | | <!-- </select>--> |
| | | |
| | | <select id="selectPatArchiveInfoByPhysicalQC" parameterType="com.smartor.domain.PatArchiveReq" |
| | | resultMap="PatArchiveOthreInfoResult"> |
| | |
| | | </select> |
| | | |
| | | <!-- é¨è¯æ£è
æ»æ°ç»è®¡ï¼å»éï¼ --> |
| | | <select id="countPatArchiveInfoByOuthospQC" parameterType="com.smartor.domain.PatArchiveReq" resultType="long"> |
| | | SELECT COUNT(DISTINCT a.id) |
| | | FROM pat_med_outhosp d |
| | | JOIN pat_archive a ON a.id = d.patid |
| | | WHERE 1=1 |
| | | AND d.del_flag != 1 |
| | | AND a.del_flag != 1 |
| | | AND d.orgid = #{orgid} |
| | | <if test="pid != null and pid != ''">AND a.id = #{pid}</if> |
| | | <if test="campusid != null and campusid != ''">AND a.campusid = #{campusid}</if> |
| | | <if test="name != null and name != ''">AND a.name like concat('%', #{name}, '%')</if> |
| | | <if test="idcardno != null and idcardno != ''">AND a.idcardno = #{idcardno}</if> |
| | | <if test="telcode != null and telcode != ''">AND a.telcode = #{telcode}</if> |
| | | <if test="hospitaldistrictname != null and hospitaldistrictname != ''">AND d.hospitaldistrictname LIKE concat('%',#{hospitaldistrictname}, '%')</if> |
| | | <if test="notrequiredFlag != null and notrequiredFlag != ''">AND a.notrequired_flag = #{notrequiredFlag}</if> |
| | | <if test="leavediagname != null and leavediagname != ''">AND d.diagname LIKE concat('%',#{leavediagname}, '%')</if> |
| | | <if test="hospitalname != null and hospitalname != ''">AND d.hospitalname = #{hospitalname}</if> |
| | | <if test="visitno != null and visitno != ''">AND d.outhospno = #{visitno}</if> |
| | | <if test="deptname != null and deptname != ''">AND d.deptname LIKE concat('%', #{deptname}, '%')</if> |
| | | <if test="drname != null and drname != ''">AND d.drname LIKE concat('%',#{drname}, '%')</if> |
| | | <if test="drcode != null">AND d.drcode = #{drcode}</if> |
| | | <if test="pids != null"> |
| | | AND a.id NOT IN |
| | | <foreach collection="pids" item="pid" open="(" separator="," close=")"> |
| | | #{pid} |
| | | </foreach> |
| | | </if> |
| | | <if test="isFilter == true"> |
| | | AND NOT exists ( SELECT 1 FROM pat_filterlist f where d.patid=f.patid) |
| | | </if> |
| | | </select> |
| | | <!-- <select id="countPatArchiveInfoByOuthospQC" parameterType="com.smartor.domain.PatArchiveReq" resultType="long">--> |
| | | <!-- SELECT COUNT(DISTINCT a.id)--> |
| | | <!-- FROM pat_med_outhosp d--> |
| | | <!-- JOIN pat_archive a ON a.id = d.patid--> |
| | | <!-- WHERE 1=1--> |
| | | <!-- AND d.del_flag != 1--> |
| | | <!-- AND a.del_flag != 1--> |
| | | <!-- AND d.orgid = #{orgid}--> |
| | | <!-- <if test="pid != null and pid != ''">AND a.id = #{pid}</if>--> |
| | | <!-- <if test="campusid != null and campusid != ''">AND a.campusid = #{campusid}</if>--> |
| | | <!-- <if test="name != null and name != ''">AND a.name like concat('%', #{name}, '%')</if>--> |
| | | <!-- <if test="idcardno != null and idcardno != ''">AND a.idcardno = #{idcardno}</if>--> |
| | | <!-- <if test="telcode != null and telcode != ''">AND a.telcode = #{telcode}</if>--> |
| | | <!-- <if test="hospitaldistrictname != null and hospitaldistrictname != ''">AND d.hospitaldistrictname LIKE concat('%',#{hospitaldistrictname}, '%')</if>--> |
| | | <!-- <if test="notrequiredFlag != null and notrequiredFlag != ''">AND a.notrequired_flag = #{notrequiredFlag}</if>--> |
| | | <!-- <if test="leavediagname != null and leavediagname != ''">AND d.diagname LIKE concat('%',#{leavediagname}, '%')</if>--> |
| | | <!-- <if test="hospitalname != null and hospitalname != ''">AND d.hospitalname = #{hospitalname}</if>--> |
| | | <!-- <if test="visitno != null and visitno != ''">AND d.outhospno = #{visitno}</if>--> |
| | | <!-- <if test="deptname != null and deptname != ''">AND d.deptname LIKE concat('%', #{deptname}, '%')</if>--> |
| | | <!-- <if test="drname != null and drname != ''">AND d.drname LIKE concat('%',#{drname}, '%')</if>--> |
| | | <!-- <if test="drcode != null">AND d.drcode = #{drcode}</if>--> |
| | | <!-- <if test="pids != null">--> |
| | | <!-- AND a.id NOT IN--> |
| | | <!-- <foreach collection="pids" item="pid" open="(" separator="," close=")">--> |
| | | <!-- #{pid}--> |
| | | <!-- </foreach>--> |
| | | <!-- </if>--> |
| | | <!-- <if test="isFilter == true">--> |
| | | <!-- AND NOT exists ( SELECT 1 FROM pat_filterlist f where d.patid=f.patid)--> |
| | | <!-- </if>--> |
| | | <!-- </select>--> |
| | | |
| | | <!-- 使£æ£è
æ»æ°ç»è®¡ï¼å»éï¼ --> |
| | | <select id="countPatArchiveInfoByPhysicalQC" parameterType="com.smartor.domain.PatArchiveReq" resultType="long"> |
| | |
| | | <if test="orgid != null and orgid != ''"> |
| | | AND orgid = #{orgid} |
| | | </if> |
| | | <if test="deptIds != null ">and deptId in |
| | | <foreach collection="deptIds" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId} |
| | | <if test="deptcodes != null ">and deptcode in |
| | | <foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")"> |
| | | #{deptcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="drCodes != null ">and drcode in |
| | |
| | | <if test="orgid != null and orgid != ''"> |
| | | AND orgid = #{orgid} |
| | | </if> |
| | | <if test="deptIds != null ">and deptId in |
| | | <foreach collection="deptIds" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId} |
| | | <if test="deptcodes != null ">and leaveldeptcode in |
| | | <foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")"> |
| | | #{deptcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="drCodes != null ">and drcode in |
| | |
| | | #{drCode} |
| | | </foreach> |
| | | </if> |
| | | union |
| | | select "é¨è¯" name1, count(1) as count FROM `pat_med_outhosp` |
| | | where del_flag=0 |
| | | ) aa |
| | | |
| | | </select> |
| | |
| | | </foreach> |
| | | </delete> |
| | | |
| | | <select id="getDeptRanking" parameterType="com.smartor.domain.PatMedReq" resultType="com.smartor.domain.PatMedRes"> |
| | | SELECT deptname, COUNT(1) AS rc |
| | | FROM ( |
| | | <if test="mz != null"> |
| | | SELECT deptname |
| | | FROM pat_med_outhosp |
| | | where 1=1 |
| | | and del_flag=0 |
| | | <if test="deptcodeList != null and deptcodeList.size() > 0"> |
| | | and deptcode in |
| | | <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")"> |
| | | #{deptcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="orgid != null and orgid != ''"> |
| | | and orgid = #{orgid} |
| | | </if> |
| | | </if> |
| | | <if test="mz != null and zy != null"> |
| | | UNION ALL |
| | | </if> |
| | | <if test="zy != null"> |
| | | SELECT deptname |
| | | FROM pat_med_inhosp |
| | | where 1=1 |
| | | and del_flag=0 |
| | | and inhospstate=0 |
| | | <if test="deptcodeList != null and deptcodeList.size() > 0"> |
| | | and deptcode in |
| | | <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")"> |
| | | #{deptcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="orgid != null and orgid != ''"> |
| | | and orgid = #{orgid} |
| | | </if> |
| | | </if> |
| | | <if test="cy != null and zy != null"> |
| | | UNION ALL |
| | | SELECT deptname |
| | | FROM pat_med_inhosp |
| | | where 1=1 |
| | | and del_flag=0 |
| | | and inhospstate=1 |
| | | <if test="deptcodeList != null and deptcodeList.size() > 0"> |
| | | and deptcode in |
| | | <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")"> |
| | | #{deptcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="orgid != null and orgid != ''"> |
| | | and orgid = #{orgid} |
| | | </if> |
| | | </if> |
| | | <if test="mz != null and zy != null and cy==null"> |
| | | UNION ALL |
| | | SELECT deptname |
| | | FROM pat_med_inhosp |
| | | where 1=1 |
| | | and del_flag=0 |
| | | and inhospstate=1 |
| | | <if test="deptcodeList != null and deptcodeList.size() > 0"> |
| | | and deptcode in |
| | | <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")"> |
| | | #{deptcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="orgid != null and orgid != ''"> |
| | | and orgid = #{orgid} |
| | | </if> |
| | | </if> |
| | | ) AS combined |
| | | GROUP BY deptname; |
| | | </select> |
| | | <select id="selectPatMedInhospCount" parameterType="com.smartor.domain.PatMedReq" |
| | | resultType="com.smartor.domain.PatMedRes"> |
| | | SELECT SUM( rs ) AS rs, |
| | |
| | | |
| | | <!-- æ¥è¯¢ä¸ä¸ªç»´åº¦ä»»æä¸ä¸ªæªå¤ççåºé¢æ£è
--> |
| | | <select id="selectNeedProcessList" resultMap="PatMedInhospResult"> |
| | | SELECT * FROM pat_med_inhosp |
| | | SELECT * |
| | | FROM pat_med_inhosp |
| | | WHERE inhospstate = '1' |
| | | AND fuflag = '1' |
| | | AND del_flag = '0' |
| | |
| | | <result property="campusid" column="campusid"/> |
| | | </resultMap> |
| | | |
| | | <sql id="selectPatMedOuthospVo"> |
| | | select id, |
| | | outhospno, |
| | | campusid, |
| | | server_state, |
| | | diagcheck_flag, |
| | | patno, |
| | | remark, |
| | | fudate, |
| | | fuflag, |
| | | serialnum, |
| | | patid, |
| | | hospitalname, |
| | | hospitalcode, |
| | | icd10code, |
| | | diagname, |
| | | deptcode, |
| | | deptname, |
| | | drcode, |
| | | drname, |
| | | admitdate, |
| | | orgid, |
| | | del_flag, |
| | | guid, |
| | | update_by, |
| | | update_time, |
| | | create_by, |
| | | create_time, |
| | | isupload, |
| | | upload_time, |
| | | schemestatus, |
| | | deptid, |
| | | schemetime, |
| | | hpi, |
| | | patname, |
| | | mainsuit |
| | | from pat_med_outhosp |
| | | </sql> |
| | | <!-- <sql id="selectPatMedOuthospVo">--> |
| | | <!-- select id,--> |
| | | <!-- outhospno,--> |
| | | <!-- campusid,--> |
| | | <!-- server_state,--> |
| | | <!-- diagcheck_flag,--> |
| | | <!-- patno,--> |
| | | <!-- remark,--> |
| | | <!-- fudate,--> |
| | | <!-- fuflag,--> |
| | | <!-- serialnum,--> |
| | | <!-- patid,--> |
| | | <!-- hospitalname,--> |
| | | <!-- hospitalcode,--> |
| | | <!-- icd10code,--> |
| | | <!-- diagname,--> |
| | | <!-- deptcode,--> |
| | | <!-- deptname,--> |
| | | <!-- drcode,--> |
| | | <!-- drname,--> |
| | | <!-- admitdate,--> |
| | | <!-- orgid,--> |
| | | <!-- del_flag,--> |
| | | <!-- guid,--> |
| | | <!-- update_by,--> |
| | | <!-- update_time,--> |
| | | <!-- create_by,--> |
| | | <!-- create_time,--> |
| | | <!-- isupload,--> |
| | | <!-- upload_time,--> |
| | | <!-- schemestatus,--> |
| | | <!-- deptid,--> |
| | | <!-- schemetime,--> |
| | | <!-- hpi,--> |
| | | <!-- patname,--> |
| | | <!-- mainsuit--> |
| | | <!-- from pat_med_outhosp--> |
| | | <!-- </sql>--> |
| | | |
| | | <select id="selectPatMedOuthospList" parameterType="com.smartor.domain.PatMedOuthosp" |
| | | resultMap="PatMedOuthospResult"> |
| | | select |
| | | pmo.id, |
| | | pmo.outhospno, |
| | | pmo.patno, |
| | | pmo.serialnum, |
| | | pmo.patid, |
| | | pmo.icd10code, |
| | | pmo.diagname, |
| | | pmo.deptcode, |
| | | pmo.deptname, |
| | | pmo.drcode, |
| | | pmo.drname, |
| | | pmo.admitdate, |
| | | pmo.schemestatus, |
| | | pmo.deptid, |
| | | pmo.schemetime, |
| | | pmo.fuflag, |
| | | pmo.patname, |
| | | pmo.update_time, |
| | | pmo.mainsuit |
| | | from pat_med_outhosp pmo |
| | | <where>pmo.del_flag='0' |
| | | <if test="orgid != null ">and pmo.orgid = #{orgid}</if> |
| | | <if test="serialnum != null ">and pmo.serialnum = #{serialnum}</if> |
| | | <if test="serverState != null ">and pmo.server_state = #{serverState}</if> |
| | | <if test="hospitalname != null and hospitalname != ''">and pmo.hospitalname like concat('%', |
| | | #{hospitalname}, |
| | | '%') |
| | | </if> |
| | | <if test="deptcodes != null and deptcodes.size()>0"> |
| | | AND pmo.deptcode IN |
| | | <foreach collection="deptcodes" item="deptcode" open="(" separator="," |
| | | close=")"> |
| | | #{deptcode} |
| | | </foreach> |
| | | </if> |
| | | <if test="deptname != null and deptname != ''">and pmo.deptname like concat('%', #{deptname}, '%')</if> |
| | | <if test="drname != null and drname != ''">and pmo.drname like concat('%', #{drname}, '%')</if> |
| | | <if test="patname != null and patname != ''">and pmo.patname like concat('%', #{patname}, '%')</if> |
| | | <if test="beginTime != null ">and date_format(pmo.admitdate,'%y%m%d') >= |
| | | date_format(#{beginTime},'%y%m%d') |
| | | </if> |
| | | <if test="endTime != null ">and date_format(pmo.admitdate,'%y%m%d') <= |
| | | date_format(#{endTime},'%y%m%d') |
| | | </if> |
| | | <if test="patid != null ">and pmo.patid = #{patid}</if> |
| | | <if test="campusid != null ">and pmo.campusid = #{campusid}</if> |
| | | <if test="fuflag != null ">and pmo.fuflag = #{fuflag}</if> |
| | | <if test="patno != null ">and pmo.patno = #{patno}</if> |
| | | <if test="outhospno != null and outhospno != ''">and pmo.outhospno = #{outhospno}</if> |
| | | <if test="diagcheckFlag != null and diagcheckFlag != ''">and pmo.diagcheck_flag = #{diagcheckFlag}</if> |
| | | <if test="diagname != null and diagname != ''">and pmo.diagname like concat('%',#{diagname}, '%')</if> |
| | | </where> |
| | | order by pmo.update_time desc |
| | | <if test="pageSize != null and pageNum != null">limit ${pageSize} OFFSET ${pageNum}</if> |
| | | </select> |
| | | <!-- <select id="selectPatMedOuthospList" parameterType="com.smartor.domain.PatMedOuthosp"--> |
| | | <!-- resultMap="PatMedOuthospResult">--> |
| | | <!-- select--> |
| | | <!-- pmo.id,--> |
| | | <!-- pmo.outhospno,--> |
| | | <!-- pmo.patno,--> |
| | | <!-- pmo.serialnum,--> |
| | | <!-- pmo.patid,--> |
| | | <!-- pmo.icd10code,--> |
| | | <!-- pmo.diagname,--> |
| | | <!-- pmo.deptcode,--> |
| | | <!-- pmo.deptname,--> |
| | | <!-- pmo.drcode,--> |
| | | <!-- pmo.drname,--> |
| | | <!-- pmo.admitdate,--> |
| | | <!-- pmo.schemestatus,--> |
| | | <!-- pmo.deptid,--> |
| | | <!-- pmo.schemetime,--> |
| | | <!-- pmo.fuflag,--> |
| | | <!-- pmo.patname,--> |
| | | <!-- pmo.update_time,--> |
| | | <!-- pmo.mainsuit--> |
| | | <!-- from pat_med_outhosp pmo--> |
| | | <!-- <where>pmo.del_flag='0'--> |
| | | <!-- <if test="orgid != null ">and pmo.orgid = #{orgid}</if>--> |
| | | <!-- <if test="serialnum != null ">and pmo.serialnum = #{serialnum}</if>--> |
| | | <!-- <if test="serverState != null ">and pmo.server_state = #{serverState}</if>--> |
| | | <!-- <if test="hospitalname != null and hospitalname != ''">and pmo.hospitalname like concat('%',--> |
| | | <!-- #{hospitalname},--> |
| | | <!-- '%')--> |
| | | <!-- </if>--> |
| | | <!-- <if test="deptcodes != null and deptcodes.size()>0">--> |
| | | <!-- AND pmo.deptcode IN--> |
| | | <!-- <foreach collection="deptcodes" item="deptcode" open="(" separator=","--> |
| | | <!-- close=")">--> |
| | | <!-- #{deptcode}--> |
| | | <!-- </foreach>--> |
| | | <!-- </if>--> |
| | | <!-- <if test="deptname != null and deptname != ''">and pmo.deptname like concat('%', #{deptname}, '%')</if>--> |
| | | <!-- <if test="drname != null and drname != ''">and pmo.drname like concat('%', #{drname}, '%')</if>--> |
| | | <!-- <if test="patname != null and patname != ''">and pmo.patname like concat('%', #{patname}, '%')</if>--> |
| | | <!-- <if test="beginTime != null ">and date_format(pmo.admitdate,'%y%m%d') >=--> |
| | | <!-- date_format(#{beginTime},'%y%m%d')--> |
| | | <!-- </if>--> |
| | | <!-- <if test="endTime != null ">and date_format(pmo.admitdate,'%y%m%d') <=--> |
| | | <!-- date_format(#{endTime},'%y%m%d')--> |
| | | <!-- </if>--> |
| | | <!-- <if test="patid != null ">and pmo.patid = #{patid}</if>--> |
| | | <!-- <if test="campusid != null ">and pmo.campusid = #{campusid}</if>--> |
| | | <!-- <if test="fuflag != null ">and pmo.fuflag = #{fuflag}</if>--> |
| | | <!-- <if test="patno != null ">and pmo.patno = #{patno}</if>--> |
| | | <!-- <if test="outhospno != null and outhospno != ''">and pmo.outhospno = #{outhospno}</if>--> |
| | | <!-- <if test="diagcheckFlag != null and diagcheckFlag != ''">and pmo.diagcheck_flag = #{diagcheckFlag}</if>--> |
| | | <!-- <if test="diagname != null and diagname != ''">and pmo.diagname like concat('%',#{diagname}, '%')</if>--> |
| | | <!-- </where>--> |
| | | <!-- order by pmo.update_time desc--> |
| | | <!-- <if test="pageSize != null and pageNum != null">limit ${pageSize} OFFSET ${pageNum}</if>--> |
| | | <!-- </select>--> |
| | | |
| | | <select id="selectPatMedOuthospById" parameterType="Long" resultMap="PatMedOuthospResult"> |
| | | <include refid="selectPatMedOuthospVo"/> |
| | | where id = #{id} |
| | | </select> |
| | | |
| | | <insert id="insertPatMedOuthosp" parameterType="com.smartor.domain.PatMedOuthosp" useGeneratedKeys="true" |
| | | keyProperty="id"> |
| | | insert into pat_med_outhosp |
| | | <!-- <insert id="insertPatMedOuthosp" parameterType="com.smartor.domain.PatMedOuthosp" useGeneratedKeys="true"--> |
| | | <!-- keyProperty="id">--> |
| | | <!-- insert into pat_med_outhosp--> |
| | | <!-- <trim prefix="(" suffix=")" suffixOverrides=",">--> |
| | | <!-- <if test="serialnum != null">serialnum,</if>--> |
| | | <!-- <if test="patid != null">patid,</if>--> |
| | | <!-- <if test="hospitalname != null">hospitalname,</if>--> |
| | | <!-- <if test="hospitalcode != null">hospitalcode,</if>--> |
| | | <!-- <if test="icd10code != null">icd10code,</if>--> |
| | | <!-- <if test="diagname != null">diagname,</if>--> |
| | | <!-- <if test="deptcode != null">deptcode,</if>--> |
| | | <!-- <if test="deptname != null">deptname,</if>--> |
| | | <!-- <if test="drcode != null">drcode,</if>--> |
| | | <!-- <if test="drname != null">drname,</if>--> |
| | | <!-- <if test="admitdate != null">admitdate,</if>--> |
| | | <!-- <if test="orgid != null">orgid,</if>--> |
| | | <!-- <if test="delFlag != null and delFlag != ''">del_flag,</if>--> |
| | | <!-- <if test="updateBy != null">update_by,</if>--> |
| | | <!-- <if test="updateTime != null">update_time,</if>--> |
| | | <!-- <if test="createBy != null">create_by,</if>--> |
| | | <!-- <if test="createTime != null">create_time,</if>--> |
| | | <!-- <if test="isupload != null">isupload,</if>--> |
| | | <!-- <if test="uploadTime != null">upload_time,</if>--> |
| | | <!-- <if test="schemestatus != null">schemestatus,</if>--> |
| | | <!-- <if test="deptid != null">deptid,</if>--> |
| | | <!-- <if test="schemetime != null">schemetime,</if>--> |
| | | <!-- <if test="hpi != null">hpi,</if>--> |
| | | <!-- <if test="mainsuit != null">mainsuit,</if>--> |
| | | <!-- <if test="outhospno != null">outhospno,</if>--> |
| | | <!-- <if test="patname != null">patname,</if>--> |
| | | <!-- <if test="guid != null">guid,</if>--> |
| | | <!-- <if test="patno != null">patno,</if>--> |
| | | <!-- <if test="diagcheckFlag != null">diagcheck_flag,</if>--> |
| | | <!-- <if test="remark != null">remark,</if>--> |
| | | <!-- <if test="fuflag != null">fuflag,</if>--> |
| | | <!-- <if test="fudate != null">fudate,</if>--> |
| | | <!-- <if test="campusid != null">campusid,</if>--> |
| | | <!-- <if test="serverState != null">server_state,</if>--> |
| | | <!-- </trim>--> |
| | | <!-- <trim prefix="values (" suffix=")" suffixOverrides=",">--> |
| | | <!-- <if test="serialnum != null">#{serialnum},</if>--> |
| | | <!-- <if test="patid != null">#{patid},</if>--> |
| | | <!-- <if test="hospitalname != null">#{hospitalname},</if>--> |
| | | <!-- <if test="hospitalcode != null">#{hospitalcode},</if>--> |
| | | <!-- <if test="icd10code != null">#{icd10code},</if>--> |
| | | <!-- <if test="diagname != null">#{diagname},</if>--> |
| | | <!-- <if test="deptcode != null">#{deptcode},</if>--> |
| | | <!-- <if test="deptname != null">#{deptname},</if>--> |
| | | <!-- <if test="drcode != null">#{drcode},</if>--> |
| | | <!-- <if test="drname != null">#{drname},</if>--> |
| | | <!-- <if test="admitdate != null">#{admitdate},</if>--> |
| | | <!-- <if test="orgid != null">#{orgid},</if>--> |
| | | <!-- <if test="delFlag != null and delFlag != ''">#{delFlag},</if>--> |
| | | <!-- <if test="updateBy != null">#{updateBy},</if>--> |
| | | <!-- <if test="updateTime != null">#{updateTime},</if>--> |
| | | <!-- <if test="createBy != null">#{createBy},</if>--> |
| | | <!-- <if test="createTime != null">#{createTime},</if>--> |
| | | <!-- <if test="isupload != null">#{isupload},</if>--> |
| | | <!-- <if test="uploadTime != null">#{uploadTime},</if>--> |
| | | <!-- <if test="schemestatus != null">#{schemestatus},</if>--> |
| | | <!-- <if test="deptid != null">#{deptid},</if>--> |
| | | <!-- <if test="schemetime != null">#{schemetime},</if>--> |
| | | <!-- <if test="hpi != null">#{hpi},</if>--> |
| | | <!-- <if test="mainsuit != null">#{mainsuit},</if>--> |
| | | <!-- <if test="outhospno != null">#{outhospno},</if>--> |
| | | <!-- <if test="patname != null">#{patname},</if>--> |
| | | <!-- <if test="guid != null">#{guid},</if>--> |
| | | <!-- <if test="patno != null">#{patno},</if>--> |
| | | <!-- <if test="diagcheckFlag != null">#{diagcheckFlag},</if>--> |
| | | <!-- <if test="remark != null">#{remark},</if>--> |
| | | <!-- <if test="fuflag != null">#{fuflag},</if>--> |
| | | <!-- <if test="fudate != null">#{fudate},</if>--> |
| | | <!-- <if test="campusid != null">#{campusid},</if>--> |
| | | <!-- <if test="serverState != null">#{serverState},</if>--> |
| | | <!-- </trim>--> |
| | | <!-- </insert>--> |
| | | |
| | | <!-- æ°å¢å°å¨æè¡¨åï¼ç¨äºè·¯ç±å°ææ°åè¡¨ï¼ --> |
| | | <insert id="insertIntoTable" parameterType="map" useGeneratedKeys="true" keyProperty="record.id"> |
| | | insert into ${tableName} |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="serialnum != null">serialnum,</if> |
| | | <if test="patid != null">patid,</if> |
| | | <if test="hospitalname != null">hospitalname,</if> |
| | | <if test="hospitalcode != null">hospitalcode,</if> |
| | | <if test="icd10code != null">icd10code,</if> |
| | | <if test="diagname != null">diagname,</if> |
| | | <if test="deptcode != null">deptcode,</if> |
| | | <if test="deptname != null">deptname,</if> |
| | | <if test="drcode != null">drcode,</if> |
| | | <if test="drname != null">drname,</if> |
| | | <if test="admitdate != null">admitdate,</if> |
| | | <if test="orgid != null">orgid,</if> |
| | | <if test="delFlag != null and delFlag != ''">del_flag,</if> |
| | | <if test="updateBy != null">update_by,</if> |
| | | <if test="updateTime != null">update_time,</if> |
| | | <if test="createBy != null">create_by,</if> |
| | | <if test="createTime != null">create_time,</if> |
| | | <if test="isupload != null">isupload,</if> |
| | | <if test="uploadTime != null">upload_time,</if> |
| | | <if test="schemestatus != null">schemestatus,</if> |
| | | <if test="deptid != null">deptid,</if> |
| | | <if test="schemetime != null">schemetime,</if> |
| | | <if test="hpi != null">hpi,</if> |
| | | <if test="mainsuit != null">mainsuit,</if> |
| | | <if test="outhospno != null">outhospno,</if> |
| | | <if test="patname != null">patname,</if> |
| | | <if test="guid != null">guid,</if> |
| | | <if test="patno != null">patno,</if> |
| | | <if test="diagcheckFlag != null">diagcheck_flag,</if> |
| | | <if test="remark != null">remark,</if> |
| | | <if test="fuflag != null">fuflag,</if> |
| | | <if test="fudate != null">fudate,</if> |
| | | <if test="campusid != null">campusid,</if> |
| | | <if test="serverState != null">server_state,</if> |
| | | <if test="record.serialnum != null">serialnum,</if> |
| | | <if test="record.patid != null">patid,</if> |
| | | <if test="record.hospitalname != null">hospitalname,</if> |
| | | <if test="record.hospitalcode != null">hospitalcode,</if> |
| | | <if test="record.icd10code != null">icd10code,</if> |
| | | <if test="record.diagname != null">diagname,</if> |
| | | <if test="record.deptcode != null">deptcode,</if> |
| | | <if test="record.deptname != null">deptname,</if> |
| | | <if test="record.drcode != null">drcode,</if> |
| | | <if test="record.drname != null">drname,</if> |
| | | <if test="record.admitdate != null">admitdate,</if> |
| | | <if test="record.orgid != null">orgid,</if> |
| | | <if test="record.delFlag != null and record.delFlag != ''">del_flag,</if> |
| | | <if test="record.updateBy != null">update_by,</if> |
| | | <if test="record.updateTime != null">update_time,</if> |
| | | <if test="record.createBy != null">create_by,</if> |
| | | <if test="record.createTime != null">create_time,</if> |
| | | <if test="record.isupload != null">isupload,</if> |
| | | <if test="record.uploadTime != null">upload_time,</if> |
| | | <if test="record.schemestatus != null">schemestatus,</if> |
| | | <if test="record.deptid != null">deptid,</if> |
| | | <if test="record.schemetime != null">schemetime,</if> |
| | | <if test="record.hpi != null">hpi,</if> |
| | | <if test="record.mainsuit != null">mainsuit,</if> |
| | | <if test="record.outhospno != null">outhospno,</if> |
| | | <if test="record.patname != null">patname,</if> |
| | | <if test="record.guid != null">guid,</if> |
| | | <if test="record.patno != null">patno,</if> |
| | | <if test="record.diagcheckFlag != null">diagcheck_flag,</if> |
| | | <if test="record.remark != null">remark,</if> |
| | | <if test="record.fuflag != null">fuflag,</if> |
| | | <if test="record.fudate != null">fudate,</if> |
| | | <if test="record.campusid != null">campusid,</if> |
| | | <if test="record.serverState != null">server_state,</if> |
| | | </trim> |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test="serialnum != null">#{serialnum},</if> |
| | | <if test="patid != null">#{patid},</if> |
| | | <if test="hospitalname != null">#{hospitalname},</if> |
| | | <if test="hospitalcode != null">#{hospitalcode},</if> |
| | | <if test="icd10code != null">#{icd10code},</if> |
| | | <if test="diagname != null">#{diagname},</if> |
| | | <if test="deptcode != null">#{deptcode},</if> |
| | | <if test="deptname != null">#{deptname},</if> |
| | | <if test="drcode != null">#{drcode},</if> |
| | | <if test="drname != null">#{drname},</if> |
| | | <if test="admitdate != null">#{admitdate},</if> |
| | | <if test="orgid != null">#{orgid},</if> |
| | | <if test="delFlag != null and delFlag != ''">#{delFlag},</if> |
| | | <if test="updateBy != null">#{updateBy},</if> |
| | | <if test="updateTime != null">#{updateTime},</if> |
| | | <if test="createBy != null">#{createBy},</if> |
| | | <if test="createTime != null">#{createTime},</if> |
| | | <if test="isupload != null">#{isupload},</if> |
| | | <if test="uploadTime != null">#{uploadTime},</if> |
| | | <if test="schemestatus != null">#{schemestatus},</if> |
| | | <if test="deptid != null">#{deptid},</if> |
| | | <if test="schemetime != null">#{schemetime},</if> |
| | | <if test="hpi != null">#{hpi},</if> |
| | | <if test="mainsuit != null">#{mainsuit},</if> |
| | | <if test="outhospno != null">#{outhospno},</if> |
| | | <if test="patname != null">#{patname},</if> |
| | | <if test="guid != null">#{guid},</if> |
| | | <if test="patno != null">#{patno},</if> |
| | | <if test="diagcheckFlag != null">#{diagcheckFlag},</if> |
| | | <if test="remark != null">#{remark},</if> |
| | | <if test="fuflag != null">#{fuflag},</if> |
| | | <if test="fudate != null">#{fudate},</if> |
| | | <if test="campusid != null">#{campusid},</if> |
| | | <if test="serverState != null">#{serverState},</if> |
| | | <if test="record.serialnum != null">#{record.serialnum},</if> |
| | | <if test="record.patid != null">#{record.patid},</if> |
| | | <if test="record.hospitalname != null">#{record.hospitalname},</if> |
| | | <if test="record.hospitalcode != null">#{record.hospitalcode},</if> |
| | | <if test="record.icd10code != null">#{record.icd10code},</if> |
| | | <if test="record.diagname != null">#{record.diagname},</if> |
| | | <if test="record.deptcode != null">#{record.deptcode},</if> |
| | | <if test="record.deptname != null">#{record.deptname},</if> |
| | | <if test="record.drcode != null">#{record.drcode},</if> |
| | | <if test="record.drname != null">#{record.drname},</if> |
| | | <if test="record.admitdate != null">#{record.admitdate},</if> |
| | | <if test="record.orgid != null">#{record.orgid},</if> |
| | | <if test="record.delFlag != null and record.delFlag != ''">#{record.delFlag},</if> |
| | | <if test="record.updateBy != null">#{record.updateBy},</if> |
| | | <if test="record.updateTime != null">#{record.updateTime},</if> |
| | | <if test="record.createBy != null">#{record.createBy},</if> |
| | | <if test="record.createTime != null">#{record.createTime},</if> |
| | | <if test="record.isupload != null">#{record.isupload},</if> |
| | | <if test="record.uploadTime != null">#{record.uploadTime},</if> |
| | | <if test="record.schemestatus != null">#{record.schemestatus},</if> |
| | | <if test="record.deptid != null">#{record.deptid},</if> |
| | | <if test="record.schemetime != null">#{record.schemetime},</if> |
| | | <if test="record.hpi != null">#{record.hpi},</if> |
| | | <if test="record.mainsuit != null">#{record.mainsuit},</if> |
| | | <if test="record.outhospno != null">#{record.outhospno},</if> |
| | | <if test="record.patname != null">#{record.patname},</if> |
| | | <if test="record.guid != null">#{record.guid},</if> |
| | | <if test="record.patno != null">#{record.patno},</if> |
| | | <if test="record.diagcheckFlag != null">#{record.diagcheckFlag},</if> |
| | | <if test="record.remark != null">#{record.remark},</if> |
| | | <if test="record.fuflag != null">#{record.fuflag},</if> |
| | | <if test="record.fudate != null">#{record.fudate},</if> |
| | | <if test="record.campusid != null">#{record.campusid},</if> |
| | | <if test="record.serverState != null">#{record.serverState},</if> |
| | | </trim> |
| | | </insert> |
| | | |
| | | <insert id="batchPatMedOuthosp"> |
| | | insert into pat_med_outhosp |
| | | ( |
| | | serialnum, |
| | | patid, |
| | | hospitalname, |
| | | hospitalcode, |
| | | icd10code, |
| | | diagname, |
| | | deptcode, |
| | | deptname, |
| | | drcode, |
| | | drname, |
| | | admitdate, |
| | | orgid, |
| | | del_flag, |
| | | update_by, |
| | | update_time, |
| | | create_by, |
| | | create_time, |
| | | isupload, |
| | | upload_time, |
| | | schemestatus, |
| | | deptid, |
| | | schemetime, |
| | | hpi, |
| | | mainsuit, |
| | | outhospno, |
| | | patname, |
| | | guid, |
| | | patno, |
| | | diagcheck_flag, |
| | | fuflag, |
| | | fudate, |
| | | campusid, |
| | | server_state, |
| | | remark) |
| | | values |
| | | <foreach collection="list" item="item" separator=","> |
| | | ( |
| | | #{item.serialnum}, |
| | | #{item.patid}, |
| | | #{item.hospitalname}, |
| | | #{item.hospitalcode}, |
| | | #{item.icd10code}, |
| | | #{item.diagname}, |
| | | #{item.deptcode}, |
| | | #{item.deptname}, |
| | | #{item.drcode}, |
| | | #{item.drname}, |
| | | #{item.admitdate}, |
| | | #{item.orgid}, |
| | | #{item.delFlag}, |
| | | #{item.updateBy}, |
| | | #{item.updateTime}, |
| | | #{item.createBy}, |
| | | #{item.createTime}, |
| | | #{item.isupload}, |
| | | #{item.uploadTime}, |
| | | #{item.schemestatus}, |
| | | #{item.deptid}, |
| | | #{item.schemetime}, |
| | | #{item.hpi}, |
| | | #{item.mainsuit}, |
| | | #{item.outhospno}, |
| | | #{item.patname}, |
| | | #{item.guid}, |
| | | #{item.patno}, |
| | | #{item.diagcheckFlag}, |
| | | #{item.fuflag}, |
| | | #{item.fudate}, |
| | | #{item.campusid}, |
| | | #{item.serverState}, |
| | | #{item.remark} |
| | | ) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | <insert id="batchInsertIgnore"> |
| | | insert ignore into pat_med_outhosp |
| | | ( |
| | | serialnum, |
| | | patid, |
| | | hospitalname, |
| | | hospitalcode, |
| | | icd10code, |
| | | diagname, |
| | | deptcode, |
| | | deptname, |
| | | drcode, |
| | | drname, |
| | | admitdate, |
| | | orgid, |
| | | del_flag, |
| | | update_by, |
| | | update_time, |
| | | create_by, |
| | | create_time, |
| | | isupload, |
| | | upload_time, |
| | | schemestatus, |
| | | deptid, |
| | | schemetime, |
| | | hpi, |
| | | mainsuit, |
| | | outhospno, |
| | | patname, |
| | | guid, |
| | | patno, |
| | | diagcheck_flag, |
| | | fuflag, |
| | | fudate, |
| | | campusid, |
| | | server_state, |
| | | remark) |
| | | values |
| | | <foreach collection="list" item="item" separator=","> |
| | | ( |
| | | #{item.serialnum}, |
| | | #{item.patid}, |
| | | #{item.hospitalname}, |
| | | #{item.hospitalcode}, |
| | | #{item.icd10code}, |
| | | #{item.diagname}, |
| | | #{item.deptcode}, |
| | | #{item.deptname}, |
| | | #{item.drcode}, |
| | | #{item.drname}, |
| | | #{item.admitdate}, |
| | | #{item.orgid}, |
| | | #{item.delFlag}, |
| | | #{item.updateBy}, |
| | | #{item.updateTime}, |
| | | #{item.createBy}, |
| | | #{item.createTime}, |
| | | #{item.isupload}, |
| | | #{item.uploadTime}, |
| | | #{item.schemestatus}, |
| | | #{item.deptid}, |
| | | #{item.schemetime}, |
| | | #{item.hpi}, |
| | | #{item.mainsuit}, |
| | | #{item.outhospno}, |
| | | #{item.patname}, |
| | | #{item.guid}, |
| | | #{item.patno}, |
| | | #{item.diagcheckFlag}, |
| | | #{item.fuflag}, |
| | | #{item.fudate}, |
| | | #{item.campusid}, |
| | | #{item.serverState}, |
| | | #{item.remark} |
| | | ) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | |
| | | <update id="updatePatMedOuthosp" parameterType="com.smartor.domain.PatMedOuthosp"> |
| | | update pat_med_outhosp |
| | | <trim prefix="SET" suffixOverrides=","> |
| | | <if test="serialnum != null">serialnum = #{serialnum},</if> |
| | | <if test="patid != null">patid = #{patid},</if> |
| | | <if test="hospitalname != null">hospitalname = #{hospitalname},</if> |
| | | <if test="hospitalcode != null">hospitalcode = #{hospitalcode},</if> |
| | | <if test="icd10code != null">icd10code = #{icd10code},</if> |
| | | <if test="diagname != null">diagname = #{diagname},</if> |
| | | <if test="deptcode != null">deptcode = #{deptcode},</if> |
| | | <if test="deptname != null">deptname = #{deptname},</if> |
| | | <if test="drcode != null">drcode = #{drcode},</if> |
| | | <if test="drname != null">drname = #{drname},</if> |
| | | <if test="admitdate != null">admitdate = #{admitdate},</if> |
| | | <if test="orgid != null">orgid = #{orgid},</if> |
| | | <if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if> |
| | | <if test="updateBy != null">update_by = #{updateBy},</if> |
| | | <if test="updateTime != null">update_time = #{updateTime},</if> |
| | | <if test="createBy != null">create_by = #{createBy},</if> |
| | | <if test="createTime != null">create_time = #{createTime},</if> |
| | | <if test="isupload != null">isupload = #{isupload},</if> |
| | | <if test="uploadTime != null">upload_time = #{uploadTime},</if> |
| | | <if test="schemestatus != null">schemestatus = #{schemestatus},</if> |
| | | <if test="deptid != null">deptid = #{deptid},</if> |
| | | <if test="schemetime != null">schemetime = #{schemetime},</if> |
| | | <if test="hpi != null">hpi = #{hpi},</if> |
| | | <if test="mainsuit != null">mainsuit = #{mainsuit},</if> |
| | | <if test="outhospno != null">outhospno = #{outhospno},</if> |
| | | <if test="patname != null">patname = #{patname},</if> |
| | | <if test="guid != null">guid = #{guid},</if> |
| | | <if test="patno != null">patno = #{patno},</if> |
| | | <if test="diagcheckFlag != null">diagcheck_flag = #{diagcheckFlag},</if> |
| | | <if test="remark != null">remark = #{remark},</if> |
| | | <if test="fuflag != null">fuflag = #{fuflag},</if> |
| | | <if test="fudate != null">fudate = #{fudate},</if> |
| | | <if test="campusid != null">campusid = #{campusid},</if> |
| | | <if test="serverState != null">server_state = #{serverState},</if> |
| | | </trim> |
| | | where id = #{id} |
| | | |
| | | <!-- <update id="updatePatMedOuthosp" parameterType="com.smartor.domain.PatMedOuthosp">--> |
| | | <!-- update pat_med_outhosp--> |
| | | <!-- <trim prefix="SET" suffixOverrides=",">--> |
| | | <!-- <if test="serialnum != null">serialnum = #{serialnum},</if>--> |
| | | <!-- <if test="patid != null">patid = #{patid},</if>--> |
| | | <!-- <if test="hospitalname != null">hospitalname = #{hospitalname},</if>--> |
| | | <!-- <if test="hospitalcode != null">hospitalcode = #{hospitalcode},</if>--> |
| | | <!-- <if test="icd10code != null">icd10code = #{icd10code},</if>--> |
| | | <!-- <if test="diagname != null">diagname = #{diagname},</if>--> |
| | | <!-- <if test="deptcode != null">deptcode = #{deptcode},</if>--> |
| | | <!-- <if test="deptname != null">deptname = #{deptname},</if>--> |
| | | <!-- <if test="drcode != null">drcode = #{drcode},</if>--> |
| | | <!-- <if test="drname != null">drname = #{drname},</if>--> |
| | | <!-- <if test="admitdate != null">admitdate = #{admitdate},</if>--> |
| | | <!-- <if test="orgid != null">orgid = #{orgid},</if>--> |
| | | <!-- <if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>--> |
| | | <!-- <if test="updateBy != null">update_by = #{updateBy},</if>--> |
| | | <!-- <if test="updateTime != null">update_time = #{updateTime},</if>--> |
| | | <!-- <if test="createBy != null">create_by = #{createBy},</if>--> |
| | | <!-- <if test="createTime != null">create_time = #{createTime},</if>--> |
| | | <!-- <if test="isupload != null">isupload = #{isupload},</if>--> |
| | | <!-- <if test="uploadTime != null">upload_time = #{uploadTime},</if>--> |
| | | <!-- <if test="schemestatus != null">schemestatus = #{schemestatus},</if>--> |
| | | <!-- <if test="deptid != null">deptid = #{deptid},</if>--> |
| | | <!-- <if test="schemetime != null">schemetime = #{schemetime},</if>--> |
| | | <!-- <if test="hpi != null">hpi = #{hpi},</if>--> |
| | | <!-- <if test="mainsuit != null">mainsuit = #{mainsuit},</if>--> |
| | | <!-- <if test="outhospno != null">outhospno = #{outhospno},</if>--> |
| | | <!-- <if test="patname != null">patname = #{patname},</if>--> |
| | | <!-- <if test="guid != null">guid = #{guid},</if>--> |
| | | <!-- <if test="patno != null">patno = #{patno},</if>--> |
| | | <!-- <if test="diagcheckFlag != null">diagcheck_flag = #{diagcheckFlag},</if>--> |
| | | <!-- <if test="remark != null">remark = #{remark},</if>--> |
| | | <!-- <if test="fuflag != null">fuflag = #{fuflag},</if>--> |
| | | <!-- <if test="fudate != null">fudate = #{fudate},</if>--> |
| | | <!-- <if test="campusid != null">campusid = #{campusid},</if>--> |
| | | <!-- <if test="serverState != null">server_state = #{serverState},</if>--> |
| | | <!-- </trim>--> |
| | | <!-- where id = #{id}--> |
| | | <!-- </update>--> |
| | | |
| | | |
| | | <select id="getTableColumns" resultType="String"> |
| | | SELECT column_name |
| | | FROM information_schema.columns |
| | | WHERE table_schema = DATABASE() |
| | | AND table_name = #{tableName} |
| | | ORDER BY ordinal_position |
| | | </select> |
| | | |
| | | <select id="getTableColumnMeta" resultType="java.util.HashMap"> |
| | | SELECT column_name AS column_name, |
| | | data_type AS data_type, |
| | | column_type AS column_type |
| | | FROM information_schema.columns |
| | | WHERE table_schema = DATABASE() |
| | | AND table_name = #{tableName} |
| | | ORDER BY ordinal_position |
| | | </select> |
| | | |
| | | <update id="createOrReplaceProcedure"> |
| | | ${procSql} |
| | | </update> |
| | | |
| | | <delete id="deletePatMedOuthospById" parameterType="Long"> |
| | | delete |
| | | from pat_med_outhosp |
| | | where id = #{id} |
| | | </delete> |
| | | |
| | | <delete id="deletePatMedOuthospByIds" parameterType="String"> |
| | | delete from pat_med_outhosp where id in |
| | | <foreach item="id" collection="array" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | <select id="selectPatMedOuthospCount" parameterType="com.smartor.domain.PatMedReq" |
| | | resultType="com.smartor.domain.PatMedRes"> |
| | | SELECT SUM( rs ) AS rs, |
| | | SUM( rc ) AS rc |
| | | FROM ( |
| | | SELECT |
| | | COUNT(id) AS rc, |
| | | 0 AS rs |
| | | FROM |
| | | pat_med_outhosp |
| | | where 1=1 |
| | | and del_flag = 0 |
| | | <if test="orgid != null"> |
| | | and orgid = #{orgid} |
| | | </if> |
| | | and date_format(admitdate,'%y%m%d') >= date_format(#{startDate},'%y%m%d') |
| | | and date_format(admitdate,'%y%m%d') <= date_format(#{endDate},'%y%m%d') |
| | | <if test="deptcodeList != null and deptcodeList.size()>0"> |
| | | and deptcode in |
| | | <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")"> |
| | | #{deptcode} |
| | | </foreach> |
| | | </if> |
| | | union all |
| | | select |
| | | 0 AS rc, |
| | | count(1) AS rs |
| | | FROM |
| | | service_subtask |
| | | where 1=1 |
| | | and del_flag = 0 |
| | | and service_type=3 |
| | | <if test="orgid != null"> |
| | | and orgid = #{orgid} |
| | | </if> |
| | | <if test="startDate != null"> |
| | | AND date_format( visit_time, '%y%m%d' ) >= date_format( #{startDate}, '%y%m%d' ) |
| | | </if> |
| | | <if test="endDate != null"> |
| | | AND date_format( visit_time, '%y%m%d' ) <= date_format(#{endDate},'%y%m%d') |
| | | </if> |
| | | <if test="deptcodeList != null and deptcodeList.size()>0"> |
| | | and deptcode in |
| | | <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")"> |
| | | #{deptcode} |
| | | </foreach> |
| | | </if> |
| | | ) AS combined_data |
| | | <!-- è°ç¨åå¨è¿ç¨ sp_query_outhosp æ¥è¯¢é¨è¯è®°å½ --> |
| | | <select id="callSpQueryOuthosp" parameterType="com.smartor.domain.PatMedOuthospQueryReq" |
| | | resultType="com.smartor.domain.PatMedOuthosp" |
| | | statementType="CALLABLE"> |
| | | {CALL sp_query_outhosp( |
| | | #{outhospno, jdbcType=VARCHAR, mode=IN}, |
| | | #{serialnum, jdbcType=VARCHAR, mode=IN}, |
| | | #{patid, jdbcType=BIGINT, mode=IN}, |
| | | #{patname, jdbcType=VARCHAR, mode=IN}, |
| | | #{patno, jdbcType=VARCHAR, mode=IN}, |
| | | #{hospitalname, jdbcType=VARCHAR, mode=IN}, |
| | | #{hospitalcode, jdbcType=VARCHAR, mode=IN}, |
| | | #{icd10code, jdbcType=VARCHAR, mode=IN}, |
| | | #{diagname, jdbcType=VARCHAR, mode=IN}, |
| | | #{deptid, jdbcType=BIGINT, mode=IN}, |
| | | #{deptcode, jdbcType=VARCHAR, mode=IN}, |
| | | #{deptname, jdbcType=VARCHAR, mode=IN}, |
| | | #{drcode, jdbcType=VARCHAR, mode=IN}, |
| | | #{drname, jdbcType=VARCHAR, mode=IN}, |
| | | #{beginAdmitdate,jdbcType=DATE, mode=IN}, |
| | | #{endAdmitdate, jdbcType=DATE, mode=IN}, |
| | | #{orgid, jdbcType=VARCHAR, mode=IN}, |
| | | #{isupload, jdbcType=BIGINT, mode=IN}, |
| | | #{schemestatus, jdbcType=BIGINT, mode=IN}, |
| | | #{hpi, jdbcType=VARCHAR, mode=IN}, |
| | | #{mainsuit, jdbcType=VARCHAR, mode=IN}, |
| | | #{pid, jdbcType=INTEGER, mode=IN}, |
| | | #{guid, jdbcType=VARCHAR, mode=IN}, |
| | | #{pguid, jdbcType=VARCHAR, mode=IN}, |
| | | #{hospitaldistrictcode, jdbcType=VARCHAR, mode=IN}, |
| | | #{hospitaldistrictname, jdbcType=VARCHAR, mode=IN}, |
| | | #{diagcheckFlag, jdbcType=VARCHAR, mode=IN}, |
| | | #{fuflag, jdbcType=VARCHAR, mode=IN}, |
| | | #{campusid, jdbcType=VARCHAR, mode=IN}, |
| | | #{serverState, jdbcType=VARCHAR, mode=IN} |
| | | #{pageSize, jdbcType=INTEGER, mode=IN}, |
| | | #{pageNum, jdbcType=INTEGER, mode=IN} |
| | | )} |
| | | </select> |
| | | |
| | | <select id="getDeptRanking" parameterType="com.smartor.domain.PatMedReq" resultType="com.smartor.domain.PatMedRes"> |
| | | SELECT deptname, COUNT(1) AS rc |
| | | FROM pat_med_outhosp |
| | | where 1=1 |
| | | and del_flag = 0 |
| | | <if test="orgid != null and orgid != ''"> |
| | | and orgid = #{orgid} |
| | | </if> |
| | | <if test="inhospstate != null"> |
| | | and inhospstate= #{inhospstate} |
| | | </if> |
| | | <if test="serverState != null"> |
| | | and server_state= #{inhospstate} |
| | | </if> |
| | | <if test="deptcodeList != null and deptcodeList.size()>0"> |
| | | and deptcode in |
| | | <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")"> |
| | | #{deptcode} |
| | | </foreach> |
| | | </if> |
| | | |
| | | <select id="callSpQueryOuthospCount" parameterType="com.smartor.domain.PatMedOuthospQueryReq" |
| | | resultType="Long" |
| | | statementType="CALLABLE"> |
| | | {CALL sp_count_outhosp( |
| | | #{outhospno, jdbcType=VARCHAR, mode=IN}, |
| | | #{serialnum, jdbcType=VARCHAR, mode=IN}, |
| | | #{patid, jdbcType=BIGINT, mode=IN}, |
| | | #{patname, jdbcType=VARCHAR, mode=IN}, |
| | | #{patno, jdbcType=VARCHAR, mode=IN}, |
| | | #{hospitalname, jdbcType=VARCHAR, mode=IN}, |
| | | #{hospitalcode, jdbcType=VARCHAR, mode=IN}, |
| | | #{icd10code, jdbcType=VARCHAR, mode=IN}, |
| | | #{diagname, jdbcType=VARCHAR, mode=IN}, |
| | | #{deptid, jdbcType=BIGINT, mode=IN}, |
| | | #{deptcode, jdbcType=VARCHAR, mode=IN}, |
| | | #{deptname, jdbcType=VARCHAR, mode=IN}, |
| | | #{drcode, jdbcType=VARCHAR, mode=IN}, |
| | | #{drname, jdbcType=VARCHAR, mode=IN}, |
| | | #{beginAdmitdate,jdbcType=DATE, mode=IN}, |
| | | #{endAdmitdate, jdbcType=DATE, mode=IN}, |
| | | #{orgid, jdbcType=VARCHAR, mode=IN}, |
| | | #{isupload, jdbcType=BIGINT, mode=IN}, |
| | | #{schemestatus, jdbcType=BIGINT, mode=IN}, |
| | | #{hpi, jdbcType=VARCHAR, mode=IN}, |
| | | #{mainsuit, jdbcType=VARCHAR, mode=IN}, |
| | | #{pid, jdbcType=INTEGER, mode=IN}, |
| | | #{guid, jdbcType=VARCHAR, mode=IN}, |
| | | #{pguid, jdbcType=VARCHAR, mode=IN}, |
| | | #{hospitaldistrictcode, jdbcType=VARCHAR, mode=IN}, |
| | | #{hospitaldistrictname, jdbcType=VARCHAR, mode=IN}, |
| | | #{diagcheckFlag, jdbcType=VARCHAR, mode=IN}, |
| | | #{fuflag, jdbcType=VARCHAR, mode=IN}, |
| | | #{campusid, jdbcType=VARCHAR, mode=IN}, |
| | | #{serverState, jdbcType=VARCHAR, mode=IN} |
| | | )} |
| | | </select> |
| | | |
| | | <!-- PatMedOuthospMapper.xml --> |
| | | <select id="countPatMedOuthosp" resultType="int"> |
| | | <select id="existsInTable" resultType="int"> |
| | | SELECT COUNT(*) |
| | | FROM pat_med_outhosp |
| | | FROM ${tableName} |
| | | WHERE id = #{id} |
| | | </select> |
| | | |
| | | <update id="renameTable"> |
| | | RENAME |
| | | TABLE |
| | | ${oldName} |
| | | TO |
| | | ${newName} |
| | | <update id="updateInTable" parameterType="map"> |
| | | update ${tableName} |
| | | <trim prefix="SET" suffixOverrides=","> |
| | | <if test="record.serialnum != null">serialnum = #{record.serialnum},</if> |
| | | <if test="record.patid != null">patid = #{record.patid},</if> |
| | | <if test="record.hospitalname != null">hospitalname = #{record.hospitalname},</if> |
| | | <if test="record.hospitalcode != null">hospitalcode = #{record.hospitalcode},</if> |
| | | <if test="record.icd10code != null">icd10code = #{record.icd10code},</if> |
| | | <if test="record.diagname != null">diagname = #{record.diagname},</if> |
| | | <if test="record.deptcode != null">deptcode = #{record.deptcode},</if> |
| | | <if test="record.deptname != null">deptname = #{record.deptname},</if> |
| | | <if test="record.drcode != null">drcode = #{record.drcode},</if> |
| | | <if test="record.drname != null">drname = #{record.drname},</if> |
| | | <if test="record.admitdate != null">admitdate = #{record.admitdate},</if> |
| | | <if test="record.orgid != null">orgid = #{record.orgid},</if> |
| | | <if test="record.delFlag != null and record.delFlag != ''">del_flag = #{record.delFlag},</if> |
| | | <if test="record.updateBy != null">update_by = #{record.updateBy},</if> |
| | | <if test="record.updateTime != null">update_time = #{record.updateTime},</if> |
| | | <if test="record.createBy != null">create_by = #{record.createBy},</if> |
| | | <if test="record.createTime != null">create_time = #{record.createTime},</if> |
| | | <if test="record.isupload != null">isupload = #{record.isupload},</if> |
| | | <if test="record.uploadTime != null">upload_time = #{record.uploadTime},</if> |
| | | <if test="record.schemestatus != null">schemestatus = #{record.schemestatus},</if> |
| | | <if test="record.deptid != null">deptid = #{record.deptid},</if> |
| | | <if test="record.schemetime != null">schemetime = #{record.schemetime},</if> |
| | | <if test="record.hpi != null">hpi = #{record.hpi},</if> |
| | | <if test="record.mainsuit != null">mainsuit = #{record.mainsuit},</if> |
| | | <if test="record.outhospno != null">outhospno = #{record.outhospno},</if> |
| | | <if test="record.patname != null">patname = #{record.patname},</if> |
| | | <if test="record.guid != null">guid = #{record.guid},</if> |
| | | <if test="record.patno != null">patno = #{record.patno},</if> |
| | | <if test="record.diagcheckFlag != null">diagcheck_flag = #{record.diagcheckFlag},</if> |
| | | <if test="record.remark != null">remark = #{record.remark},</if> |
| | | <if test="record.fuflag != null">fuflag = #{record.fuflag},</if> |
| | | <if test="record.fudate != null">fudate = #{record.fudate},</if> |
| | | <if test="record.campusid != null">campusid = #{record.campusid},</if> |
| | | <if test="record.serverState != null">server_state = #{record.serverState},</if> |
| | | </trim> |
| | | <where>del_flag=0 |
| | | <if test="record.guid != null">and guid = #{record.guid}</if> |
| | | <if test="record.serialnum != null">and serialnum = #{record.serialnum}</if> |
| | | </where> |
| | | </update> |
| | | |
| | | <select id="tableExists" resultType="int"> |
| | | SELECT COUNT(*) |
| | | FROM information_schema.tables |
| | | WHERE table_schema = DATABASE() |
| | | AND table_name = #{tableName} |
| | | </select> |
| | | |
| | | <update id="createPatMedOuthosp"> |
| | | CREATE TABLE ${newName} LIKE ${templateName} |
| | |
| | | WHERE table_schema = DATABASE() |
| | | AND table_name LIKE 'pat_med_outhosp%' |
| | | </select> |
| | | |
| | | <select id="getMaxIdFromTable" resultType="Long"> |
| | | SELECT IFNULL(MAX(id), 0) |
| | | FROM ${tableName} |
| | | </select> |
| | | |
| | | <update id="createOrReplaceView"> |
| | | ${viewSql} |
| | | </update> |
| | | |
| | | </mapper> |
| | |
| | | </foreach> |
| | | </if> |
| | | |
| | | <!-- GROUP BY--> |
| | | <!-- <choose>--> |
| | | <!-- <when test="timeType == 'day'">--> |
| | | <!-- DATE_FORMAT(visit_time, '%Y-%m-%d')--> |
| | | <!-- </when>--> |
| | | <!-- <when test="timeType == 'month'">--> |
| | | <!-- DATE_FORMAT(visit_time, '%Y-%m')--> |
| | | <!-- </when>--> |
| | | <!-- <when test="timeType == 'year'">--> |
| | | <!-- DATE_FORMAT(visit_time, '%Y')--> |
| | | <!-- </when>--> |
| | | <!-- <when test="timeType == 'week'">--> |
| | | <!-- CONCAT(YEAR(visit_time), '-W', LPAD(WEEK(visit_time, 1), 2, '0'))--> |
| | | <!-- </when>--> |
| | | <!-- <otherwise>--> |
| | | <!-- DATE_FORMAT(visit_time, '%Y-%m-%d')--> |
| | | <!-- </otherwise>--> |
| | | <!-- </choose>--> |
| | | |
| | | UNION ALL |
| | | |
| | | -- åºé¢äººæ¬¡æ°æ® |
| | |
| | | </foreach> |
| | | </if> |
| | | |
| | | <!-- GROUP BY--> |
| | | <!-- UNION ALL--> |
| | | |
| | | <!-- -- é¨è¯äººæ¬¡æ°æ®--> |
| | | <!-- SELECT--> |
| | | <!-- <choose>--> |
| | | <!-- <when test="timeType == 'day'">--> |
| | | <!-- DATE_FORMAT(endtime, '%Y-%m-%d')--> |
| | | <!-- DATE_FORMAT(admitdate, '%Y-%m-%d') AS timePeriod,--> |
| | | <!-- </when>--> |
| | | <!-- <when test="timeType == 'month'">--> |
| | | <!-- DATE_FORMAT(endtime, '%Y-%m')--> |
| | | <!-- DATE_FORMAT(admitdate, '%Y-%m') AS timePeriod,--> |
| | | <!-- </when>--> |
| | | <!-- <when test="timeType == 'year'">--> |
| | | <!-- DATE_FORMAT(endtime, '%Y')--> |
| | | <!-- DATE_FORMAT(admitdate, '%Y') AS timePeriod,--> |
| | | <!-- </when>--> |
| | | <!-- <when test="timeType == 'week'">--> |
| | | <!-- CONCAT(YEAR(endtime), '-W', LPAD(WEEK(endtime, 1), 2, '0'))--> |
| | | <!-- CONCAT(YEAR(admitdate), '-W', LPAD(WEEK(admitdate, 1), 2, '0')) AS timePeriod,--> |
| | | <!-- </when>--> |
| | | <!-- <otherwise>--> |
| | | <!-- DATE_FORMAT(endtime, '%Y-%m-%d')--> |
| | | <!-- DATE_FORMAT(admitdate, '%Y-%m-%d') AS timePeriod,--> |
| | | <!-- </otherwise>--> |
| | | <!-- </choose>--> |
| | | <!-- 0 AS dischargeFollowCount,--> |
| | | <!-- 0 AS outpatientFollowCount,--> |
| | | <!-- 0 AS pmiCount,--> |
| | | <!-- 1 AS pmoCount--> |
| | | <!-- FROM pat_med_outhosp--> |
| | | <!-- WHERE del_flag = '0'--> |
| | | <!-- <if test="startDate != null and endDate != null">--> |
| | | <!-- AND admitdate >= #{startDate}--> |
| | | <!-- AND admitdate <= DATE_ADD(#{endDate}, INTERVAL 1 DAY)--> |
| | | <!-- </if>--> |
| | | <!-- <if test="orgid != null">--> |
| | | <!-- AND orgid = #{orgid}--> |
| | | <!-- </if>--> |
| | | |
| | | UNION ALL |
| | | <!-- <if test="deptcodes != null and deptcodes.size() > 0">--> |
| | | <!-- AND deptcode IN--> |
| | | <!-- <foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">--> |
| | | <!-- #{deptcode}--> |
| | | <!-- </foreach>--> |
| | | <!-- </if>--> |
| | | |
| | | -- é¨è¯äººæ¬¡æ°æ® |
| | | SELECT |
| | | <choose> |
| | | <when test="timeType == 'day'"> |
| | | DATE_FORMAT(admitdate, '%Y-%m-%d') AS timePeriod, |
| | | </when> |
| | | <when test="timeType == 'month'"> |
| | | DATE_FORMAT(admitdate, '%Y-%m') AS timePeriod, |
| | | </when> |
| | | <when test="timeType == 'year'"> |
| | | DATE_FORMAT(admitdate, '%Y') AS timePeriod, |
| | | </when> |
| | | <when test="timeType == 'week'"> |
| | | CONCAT(YEAR(admitdate), '-W', LPAD(WEEK(admitdate, 1), 2, '0')) AS timePeriod, |
| | | </when> |
| | | <otherwise> |
| | | DATE_FORMAT(admitdate, '%Y-%m-%d') AS timePeriod, |
| | | </otherwise> |
| | | </choose> |
| | | 0 AS dischargeFollowCount, |
| | | 0 AS outpatientFollowCount, |
| | | 0 AS pmiCount, |
| | | 1 AS pmoCount |
| | | FROM pat_med_outhosp |
| | | WHERE del_flag = '0' |
| | | <if test="startDate != null and endDate != null"> |
| | | AND admitdate >= #{startDate} |
| | | AND admitdate <= DATE_ADD(#{endDate}, INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="orgid != null"> |
| | | AND orgid = #{orgid} |
| | | </if> |
| | | |
| | | <if test="deptcodes != null and deptcodes.size() > 0"> |
| | | AND deptcode IN |
| | | <foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")"> |
| | | #{deptcode} |
| | | </foreach> |
| | | </if> |
| | | |
| | | <!-- GROUP BY--> |
| | | <!-- <choose>--> |
| | | <!-- <when test="timeType == 'day'">--> |
| | | <!-- DATE_FORMAT(admitdate, '%Y-%m-%d')--> |
| | | <!-- </when>--> |
| | | <!-- <when test="timeType == 'month'">--> |
| | | <!-- DATE_FORMAT(admitdate, '%Y-%m')--> |
| | | <!-- </when>--> |
| | | <!-- <when test="timeType == 'year'">--> |
| | | <!-- DATE_FORMAT(admitdate, '%Y')--> |
| | | <!-- </when>--> |
| | | <!-- <when test="timeType == 'week'">--> |
| | | <!-- CONCAT(YEAR(admitdate), '-W', LPAD(WEEK(admitdate, 1), 2, '0'))--> |
| | | <!-- </when>--> |
| | | <!-- <otherwise>--> |
| | | <!-- DATE_FORMAT(admitdate, '%Y-%m-%d')--> |
| | | <!-- </otherwise>--> |
| | | <!-- </choose>--> |
| | | ) AS combined_data |
| | | GROUP BY timePeriod |
| | | ORDER BY timePeriod DESC |
| | |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | <select id="selectVisitCount" parameterType="com.smartor.domain.PatMedReq" |
| | | resultType="com.smartor.domain.PatMedRes"> |
| | | select |
| | | 0 AS rc, |
| | | count(1) AS rs |
| | | FROM |
| | | service_subtask |
| | | where 1=1 |
| | | and del_flag = 0 |
| | | and service_type=3 |
| | | <if test="orgid != null"> |
| | | and orgid = #{orgid} |
| | | </if> |
| | | <if test="startDate != null"> |
| | | AND date_format( visit_time, '%y%m%d' ) >= date_format( #{startDate}, '%y%m%d' ) |
| | | </if> |
| | | <if test="endDate != null"> |
| | | AND date_format( visit_time, '%y%m%d' ) <= date_format(#{endDate},'%y%m%d') |
| | | </if> |
| | | <if test="deptcodeList != null and deptcodeList.size()>0"> |
| | | and deptcode in |
| | | <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")"> |
| | | #{deptcode} |
| | | </foreach> |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="getCurrentUserServiceSubtaskCount" parameterType="com.smartor.domain.entity.ServiceSubtaskEntity" resultType="map"> |
| | | SELECT |
| | | COUNT(CASE WHEN sendstate = 2 AND date_format(visit_time,'%y%m%d') <= date_format(CURDATE(),'%y%m%d') THEN 1 END) AS pendingVisitCount, |