commit 4a5d8df44c7c5f7416f29e28f47d3b321820336a Author: linjj <850658129@qq.com> Date: Fri Aug 4 15:14:36 2023 +0800 英德人医按需采集初始化 diff --git a/pacs/pacs.iml b/pacs/pacs.iml new file mode 100644 index 0000000..1129e7a --- /dev/null +++ b/pacs/pacs.iml @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pacs/pom.xml b/pacs/pom.xml new file mode 100644 index 0000000..ff75b70 --- /dev/null +++ b/pacs/pom.xml @@ -0,0 +1,233 @@ + + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.3.8.RELEASE + + + + com.xjgs + pacs + 1.0-SNAPSHOT + + + UTF-8 + 1.7 + 1.7 + + + + + + + + io.springfox + springfox-boot-starter + 3.0.0 + + + com.fasterxml.jackson.datatype + jackson-datatype-guava + 2.10.1 + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-test + + + junit + junit + 4.11 + + + com.microsoft.sqlserver + sqljdbc6 + 6.4.0 + + + com.oracle + ojdbc14 + 14.0.0 + + + com.xdb + xdb + 1.0.0 + + + + org.apache.cxf + cxf-rt-transports-http + 3.1.8 + + + org.apache.cxf + cxf-rt-frontend-jaxws + 3.1.8 + + + + org.apache.cxf + cxf-rt-transports-http-jetty + 3.0.1 + + + commons-net + commons-net + 1.4.1 + + + + org.slf4j + slf4j-log4j12 + 1.6.4 + + + commons-io + commons-io + 2.6 + + + dom4j + dom4j + 1.6.1 + + + mysql + mysql-connector-java + 5.1.17 + + + + commons-dbutils + commons-dbutils + 1.6 + + + com.mchange + c3p0 + 0.9.5.2 + + + log4j + log4j + 1.2.17 + + + + com.itextpdf + itextpdf + 5.5.13 + + + com.oracle.ojdbc + xmlparserv2 + 19.3.0.0 + + + + + org.bouncycastle + bcprov-jdk16 + 1.46 + + + + org.apache.commons + commons-lang3 + 3.3.2 + + + commons-codec + commons-codec + 1.13 + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + + + + com.baomidou + mybatis-plus-extension + 3.4.2 + + + + com.baomidou + mybatis-plus-boot-starter + 3.4.2 + + + com.baomidou + mybatis-plus-annotation + 3.4.2 + + + com.baomidou + mybatis-plus-core + 3.4.2 + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.3.8.RELEASE + + com.xjgs.Applicaltion + + + + + + repackage + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 8 + 8 + + + + + + src/main/resources + + **/*.xml + **/*.properties + + + + + + src/main/resources + + **/*.* + + + + + diff --git a/pacs/src/main/java/com/xjgs/Applicaltion.java b/pacs/src/main/java/com/xjgs/Applicaltion.java new file mode 100644 index 0000000..4e5642f --- /dev/null +++ b/pacs/src/main/java/com/xjgs/Applicaltion.java @@ -0,0 +1,32 @@ +package com.xjgs; + +import org.apache.ibatis.annotations.Mapper; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.scheduling.annotation.EnableScheduling; +import springfox.documentation.oas.annotations.EnableOpenApi; + +/** + * @description: + * @author:ChenJ + * @date:2022/05/09 + **/ +@SpringBootApplication +public class Applicaltion extends SpringBootServletInitializer { + + /** + * springboot的启动方式是jar,所以主入口不再是启动tomcat + * spring启动的时候都做了哪些事 + * jar需要main方式启动 + * 在main中告诉springboot中加载类 + * + * @param args 参数 + */ + public static void main(String[] args) { + SpringApplication.run(Applicaltion.class, args); + } +} diff --git a/pacs/src/main/java/com/xjgs/Application3.java b/pacs/src/main/java/com/xjgs/Application3.java new file mode 100644 index 0000000..663b781 --- /dev/null +++ b/pacs/src/main/java/com/xjgs/Application3.java @@ -0,0 +1,34 @@ +//package com.xjgs; +// +//import com.xjgs.service.PacsService; +//import com.xjgs.service.RadiateService; +// +//import java.util.concurrent.ScheduledThreadPoolExecutor; +//import java.util.concurrent.TimeUnit; +// +//public class Application3 { +// static ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = null; +// public static void main(String[] args) { +// final PacsService pacsService = new PacsService (); +// final RadiateService radiateService = new RadiateService (); +// scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(5); +// scheduledThreadPoolExecutor.scheduleWithFixedDelay(new Runnable() { +// @Override +// public void run() { +// pacsService.uploadRadiation (); +// } +// },0,5, TimeUnit.MINUTES); +// scheduledThreadPoolExecutor.scheduleWithFixedDelay(new Runnable() { +// @Override +// public void run() { +// pacsService.fanshe (); +// } +// },2,5, TimeUnit.MINUTES); +// scheduledThreadPoolExecutor.scheduleWithFixedDelay(new Runnable() { +// @Override +// public void run() { +// radiateService.fangsheInfo (); +// } +// },4,5, TimeUnit.MINUTES); +// } +//} diff --git a/pacs/src/main/java/com/xjgs/config/PacsConfig.java b/pacs/src/main/java/com/xjgs/config/PacsConfig.java new file mode 100644 index 0000000..cb12337 --- /dev/null +++ b/pacs/src/main/java/com/xjgs/config/PacsConfig.java @@ -0,0 +1,65 @@ +package com.xjgs.config; + +import org.apache.ibatis.session.SqlSessionFactory; +import org.mybatis.spring.SqlSessionFactoryBean; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.jdbc.DataSourceBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; +import org.springframework.transaction.PlatformTransactionManager; + +import javax.sql.DataSource; + +/** + * @ClassName RecordConfig + * @Description Pacs数据数据源配置 + * @Author linjj + * @Date 2023/8/2 16:48 + * @Version 1.0 + */ +@Configuration +// 指定主数据库扫描对应的Mapper文件,生成代理对象 +@MapperScan(basePackages ="com.xjgs.pacsDao" ,sqlSessionFactoryRef = "pacsSqlSessionFactory") +public class PacsConfig { + + // mapper.xml所在地址 + private static final String MAPPER_LOCATION = "classpath*:mapper2/*.xml"; + + + /** + * 主数据源,Primary注解必须增加,它表示该数据源为默认数据源 + * 项目中还可能存在其他的数据源,如获取时不指定名称,则默认获取这个数据源,如果不添加,则启动时候回报错 + */ + @Bean(name = "pacsDataSource") + // 读取spring.datasource.master前缀的配置文件映射成对应的配置对象 + @ConfigurationProperties(prefix = "spring.datasource.db2") + public DataSource dataSource() { + DataSource build = DataSourceBuilder.create().build(); + return build; + } + + /** + * 事务管理器,Primary注解作用同上 + */ + @Bean(name = "pacsTransactionManager") + public PlatformTransactionManager dataSourceTransactionManager(@Qualifier("pacsDataSource") DataSource dataSource) { + return new DataSourceTransactionManager(dataSource); + } + + /** + * session工厂,Primary注解作用同上 + */ + + @Bean(name = "pacsSqlSessionFactory") + public SqlSessionFactory sqlSessionFactory(@Qualifier("pacsDataSource") DataSource dataSource) throws Exception { + final SqlSessionFactoryBean sessionFactoryBean = new SqlSessionFactoryBean(); + sessionFactoryBean.setDataSource(dataSource); + sessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(PacsConfig.MAPPER_LOCATION)); + return sessionFactoryBean.getObject(); + } +} diff --git a/pacs/src/main/java/com/xjgs/config/RecordConfig.java b/pacs/src/main/java/com/xjgs/config/RecordConfig.java new file mode 100644 index 0000000..a4b71d7 --- /dev/null +++ b/pacs/src/main/java/com/xjgs/config/RecordConfig.java @@ -0,0 +1,70 @@ +package com.xjgs.config; + +import org.apache.ibatis.session.SqlSessionFactory; +import org.mybatis.spring.SqlSessionFactoryBean; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.jdbc.DataSourceBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; +import org.springframework.transaction.PlatformTransactionManager; + +import javax.sql.DataSource; + +/** + * @ClassName RecordConfig + * @Description 归档数据数据源配置 + * @Author linjj + * @Date 2023/8/2 16:48 + * @Version 1.0 + */ +@Configuration +// 指定主数据库扫描对应的Mapper文件,生成代理对象 +@MapperScan(basePackages ="com.xjgs.recordDao" ,sqlSessionFactoryRef = "recordSqlSessionFactory") +public class RecordConfig { + + // mapper.xml所在地址 + private static final String MAPPER_LOCATION = "classpath*:mapper/*.xml"; + + + /** + * 主数据源,Primary注解必须增加,它表示该数据源为默认数据源 + * 项目中还可能存在其他的数据源,如获取时不指定名称,则默认获取这个数据源,如果不添加,则启动时候回报错 + */ + @Primary + @Bean(name = "recordDataSource") + // 读取spring.datasource.master前缀的配置文件映射成对应的配置对象 + @ConfigurationProperties(prefix = "spring.datasource.db1") + public DataSource dataSource() { + DataSource build = DataSourceBuilder.create().build(); + return build; + } + + /** + * 事务管理器,Primary注解作用同上 + */ + @Bean(name = "recordTransactionManager") + @Primary + public PlatformTransactionManager dataSourceTransactionManager(@Qualifier("recordDataSource") DataSource dataSource) { + return new DataSourceTransactionManager(dataSource); + } + + /** + * session工厂,Primary注解作用同上 + */ + + @Bean(name = "recordSqlSessionFactory") + @Primary + public SqlSessionFactory sqlSessionFactory(@Qualifier("recordDataSource") DataSource dataSource) throws Exception { + final SqlSessionFactoryBean sessionFactoryBean = new SqlSessionFactoryBean(); + sessionFactoryBean.setDataSource(dataSource); + sessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(RecordConfig.MAPPER_LOCATION)); + return sessionFactoryBean.getObject(); + } + + +} diff --git a/pacs/src/main/java/com/xjgs/controller/MakeUpPacs.java b/pacs/src/main/java/com/xjgs/controller/MakeUpPacs.java new file mode 100644 index 0000000..d4f940f --- /dev/null +++ b/pacs/src/main/java/com/xjgs/controller/MakeUpPacs.java @@ -0,0 +1,109 @@ +package com.xjgs.controller; + +import com.xjgs.pacsDao.PacsMapper; +import com.xjgs.recordDao.ArchiveDetailMapper; +import com.xjgs.exception.BusinessException; +import com.xjgs.exception.ExceptionCode; +import com.xjgs.service.MakeUpPacsService; +import com.xjgs.service.PacsService; +import com.xjgs.util.JsonResult; +import com.xjgs.util.StringUtil; +import com.xjgs.vo.ArchiveMaster; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import java.util.List; +import java.util.Map; + +/** + * @BelongsProject: pacs + * @BelongsPackage: com.xjgs.controller + * @Author: ChenJ + * @CreateTime: 2022-05-11 17:00 + */ +@Api("补偿采集的相关接口") +@Controller +@ResponseBody +@RequestMapping("/makeUp") +public class MakeUpPacs { + @Autowired + ArchiveDetailMapper archiveDetailMapper; + @Autowired + PacsMapper pacsMapper; + @Autowired + MakeUpPacsService makeUpPacsService; + + /** + * @description: 根据记账号补偿采集 + * @author: ChenJ + * @date: 2022/5/11 17:24 + * @param: + * @param patient 患者记账号 + * @return: java.util.Map + **/ +// @ApiOperation("按需采集") +// @GetMapping("/makeUpByPacs") +// public Map makeUpByNeed(String patient) throws BusinessException { +// +// // 先对参数进行校验,如果为空则抛出异常 +// if (StringUtil.isEmpty(patient)){ +// throw new BusinessException(ExceptionCode.WRONG_PARAMS); +// } +// // 声明Pacs操作类 +// PacsService pacsService = new PacsService(); +// // 调用采集 +// pacsService.fanshe(patient); +// pacsService.uploadRadiation(patient); +// +// +// // 声明返回 +// JsonResult jsonResult = new JsonResult(); +// jsonResult.setCode("200"); +// jsonResult.setMsg("调用成功,请稍等下载文件"); +// return jsonResult.getDataMap(); +// } + + /** + * @description: 根据出院时间按需采集 + * @params: startTime + * @params: endTime + * @author linjj + * @date: 2023/7/25 14:34 + */ + @ApiOperation("按需采集") + @GetMapping("/makeUpByPacsAndTime") + public Map makeUpByNeed(String startTime,String endTime) throws BusinessException { + //返回类 + JsonResult jsonResult = new JsonResult(); + // 先对参数进行校验,如果为空则抛出异常 + if (StringUtil.isEmpty(startTime)){ + throw new BusinessException(ExceptionCode.WRONG_PARAMS); + } + // 先对参数进行校验,如果为空则抛出异常 + if (StringUtil.isEmpty(endTime)){ + throw new BusinessException(ExceptionCode.WRONG_PARAMS); + } + //查询时间段内需要按需采集病历信息 + List archiveMasterList = archiveDetailMapper.getArchiveMasterList(startTime, endTime); + if (archiveMasterList.size()==0){ + jsonResult.setCode("100"); + jsonResult.setMsg("该时间段内无采集病历"); + return jsonResult.getDataMap(); + } + //循环执行 + for (ArchiveMaster list:archiveMasterList){ + makeUpPacsService.getPacsPathList(list); + } + // 声明返回 + jsonResult.setCode("200"); + jsonResult.setMsg("调用成功,请稍等下载文件"); + return jsonResult.getDataMap(); + } + + +} diff --git a/pacs/src/main/java/com/xjgs/dao/JDBCUtils.java b/pacs/src/main/java/com/xjgs/dao/JDBCUtils.java new file mode 100644 index 0000000..55f8076 --- /dev/null +++ b/pacs/src/main/java/com/xjgs/dao/JDBCUtils.java @@ -0,0 +1,69 @@ +package com.xjgs.dao; + +import com.mchange.v2.c3p0.C3P0ProxyConnection; +import com.mchange.v2.c3p0.ComboPooledDataSource; + +import javax.sql.DataSource; +import java.lang.reflect.Method; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +public class JDBCUtils { + //创建数据库连接池对象 + private static ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource("his"); + + //获取连接的方法 + public static Connection getConnection() throws SQLException { + return comboPooledDataSource.getConnection(); + } + + //提供数据库连接池对象的方法 + public static DataSource getDataSource(){ + return comboPooledDataSource; + } + //释放资源的方法 + public static void release(ResultSet rs, Statement stmt, Connection conn) { + + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + rs = null; + } + release(stmt, conn); + } + + public static void release(Statement stmt, Connection conn) { + if (stmt != null) { + try { + stmt.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + stmt = null; + } + if (conn != null) { + try { + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + conn = null; + } + } + public static Connection getRawConnection(Connection conn) { + C3P0ProxyConnection cpCon = (C3P0ProxyConnection) conn; + Connection unwrappedCon = null; + try { + Method rawConnectionMethod = JDBCUtils.class.getMethod("getRawConnection", new Class[]{Connection.class}); + unwrappedCon = (Connection) cpCon.rawConnectionOperation(rawConnectionMethod, null, new Object[]{C3P0ProxyConnection.RAW_CONNECTION}); + } catch (Exception ex) { + //do something } + } + return conn; + } +} diff --git a/pacs/src/main/java/com/xjgs/dao/JDBCUtils3.java b/pacs/src/main/java/com/xjgs/dao/JDBCUtils3.java new file mode 100644 index 0000000..3191bf7 --- /dev/null +++ b/pacs/src/main/java/com/xjgs/dao/JDBCUtils3.java @@ -0,0 +1,56 @@ +package com.xjgs.dao; + +import com.mchange.v2.c3p0.ComboPooledDataSource; + +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +public class JDBCUtils3 { + //创建数据库连接池对象 + private static ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource("sql"); + + //获取连接的方法 + public static Connection getConnection() throws SQLException { + return comboPooledDataSource.getConnection(); + } + + //提供数据库连接池对象的方法 + public static DataSource getDataSource(){ + return comboPooledDataSource; + } + //释放资源的方法 + public static void release(ResultSet rs, Statement stmt, Connection conn) { + + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + rs = null; + } + release(stmt, conn); + } + + public static void release(Statement stmt, Connection conn) { + if (stmt != null) { + try { + stmt.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + stmt = null; + } + if (conn != null) { + try { + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + conn = null; + } + } +} diff --git a/pacs/src/main/java/com/xjgs/dao/JDBCUtils4.java b/pacs/src/main/java/com/xjgs/dao/JDBCUtils4.java new file mode 100644 index 0000000..7ac2c5a --- /dev/null +++ b/pacs/src/main/java/com/xjgs/dao/JDBCUtils4.java @@ -0,0 +1,56 @@ +package com.xjgs.dao; + +import com.mchange.v2.c3p0.ComboPooledDataSource; + +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +public class JDBCUtils4 { + //创建数据库连接池对象 + private static ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource("chaosheng"); + + //获取连接的方法 + public static Connection getConnection() throws SQLException { + return comboPooledDataSource.getConnection(); + } + + //提供数据库连接池对象的方法 + public static DataSource getDataSource(){ + return comboPooledDataSource; + } + //释放资源的方法 + public static void release(ResultSet rs, Statement stmt, Connection conn) { + + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + rs = null; + } + release(stmt, conn); + } + + public static void release(Statement stmt, Connection conn) { + if (stmt != null) { + try { + stmt.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + stmt = null; + } + if (conn != null) { + try { + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + conn = null; + } + } +} diff --git a/pacs/src/main/java/com/xjgs/dao/JDBCUtils5.java b/pacs/src/main/java/com/xjgs/dao/JDBCUtils5.java new file mode 100644 index 0000000..9a2f31c --- /dev/null +++ b/pacs/src/main/java/com/xjgs/dao/JDBCUtils5.java @@ -0,0 +1,56 @@ +package com.xjgs.dao; + +import com.mchange.v2.c3p0.ComboPooledDataSource; + +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +public class JDBCUtils5 { + //创建数据库连接池对象 + private static ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource("mysql"); + + //获取连接的方法 + public static Connection getConnection() throws SQLException { + return comboPooledDataSource.getConnection(); + } + + //提供数据库连接池对象的方法 + public static DataSource getDataSource(){ + return comboPooledDataSource; + } + //释放资源的方法 + public static void release(ResultSet rs, Statement stmt, Connection conn) { + + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + rs = null; + } + release(stmt, conn); + } + + public static void release(Statement stmt, Connection conn) { + if (stmt != null) { + try { + stmt.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + stmt = null; + } + if (conn != null) { + try { + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + conn = null; + } + } +} diff --git a/pacs/src/main/java/com/xjgs/exception/BusinessException.java b/pacs/src/main/java/com/xjgs/exception/BusinessException.java new file mode 100644 index 0000000..67fd37f --- /dev/null +++ b/pacs/src/main/java/com/xjgs/exception/BusinessException.java @@ -0,0 +1,26 @@ +package com.xjgs.exception; + + + +/** + * @description: 自定义的异常类 + * @author: ChenJ + * @date: 2022/5/9 17:29 + * @param: + * @return: + **/ +public class BusinessException extends Exception { + /** + * 枚举类型,内含状态码code和信息msg + */ + private final ExceptionCode exceptionCode; + + public ExceptionCode getExceptionCode() { + return exceptionCode; + } + + public BusinessException(ExceptionCode exceptionCode) { + super(exceptionCode.getMessage()); + this.exceptionCode = exceptionCode; + } +} diff --git a/pacs/src/main/java/com/xjgs/exception/ExceptionCode.java b/pacs/src/main/java/com/xjgs/exception/ExceptionCode.java new file mode 100644 index 0000000..c4aa174 --- /dev/null +++ b/pacs/src/main/java/com/xjgs/exception/ExceptionCode.java @@ -0,0 +1,30 @@ +package com.xjgs.exception; + +/** + * @description: 这是一个列举异常信息的枚举类 + * @author: ChenJ + * @date: 2022/5/9 17:31 + **/ +public enum ExceptionCode { + /** + * 服务器开小差了,请稍后再试 + */ + WRONG_PARAMS("参数不对", 1001); + + + private final String message; + private final Integer code; + + ExceptionCode(String message, int code) { + this.message = message; + this.code = code; + } + + public String getMessage() { + return message; + } + + public Integer getCode() { + return code; + } +} diff --git a/pacs/src/main/java/com/xjgs/pacsDao/PacsMapper.java b/pacs/src/main/java/com/xjgs/pacsDao/PacsMapper.java new file mode 100644 index 0000000..4f04e99 --- /dev/null +++ b/pacs/src/main/java/com/xjgs/pacsDao/PacsMapper.java @@ -0,0 +1,26 @@ +package com.xjgs.pacsDao; + +import com.xjgs.vo.ArchiveMaster; +import com.xjgs.vo.PacsVo; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * @InterfaceName commomtableMapper + * @Description + * @Author linjj + * @Date 2023/8/2 17:49 + * @Version 1.0 + */ +@Mapper +public interface PacsMapper { + /** + * @description: 查询pacs路径集合 + * @params: ArchiveMaster + * @return: PacsVo + * @author linjj + * @date: 2023/8/3 11:08 + */ + List getPacsPathList(ArchiveMaster archiveMaster); +} diff --git a/pacs/src/main/java/com/xjgs/recordDao/ArchiveDetailMapper.java b/pacs/src/main/java/com/xjgs/recordDao/ArchiveDetailMapper.java new file mode 100644 index 0000000..6cdcc1d --- /dev/null +++ b/pacs/src/main/java/com/xjgs/recordDao/ArchiveDetailMapper.java @@ -0,0 +1,20 @@ +package com.xjgs.recordDao; + + + +import com.xjgs.vo.ArchiveMaster; +import com.xjgs.vo.Archive_Detail; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface ArchiveDetailMapper { + + ListgetArchiveMasterList(@Param(value = "startTime") String startTime, @Param(value = "endTime") String endTime); + + ListpacsGetPatId(); + + List getIdAndJzh(@Param(value = "ids")String ids); +} diff --git a/pacs/src/main/java/com/xjgs/service/ItextPdfImpl.java b/pacs/src/main/java/com/xjgs/service/ItextPdfImpl.java new file mode 100644 index 0000000..d72b680 --- /dev/null +++ b/pacs/src/main/java/com/xjgs/service/ItextPdfImpl.java @@ -0,0 +1,371 @@ +package com.xjgs.service; + +import com.itextpdf.text.*; +import com.itextpdf.text.pdf.*; +import com.xjgs.vo.Fangshe; +import org.apache.commons.lang3.StringUtils; +import org.junit.Test; + +import java.io.File; +import java.io.FileOutputStream; + +public class ItextPdfImpl{ + + public String[] convertMath(String str){ + String[] s = str.split(" "); + return s; + } + public boolean writePdf(Fangshe source, String temp, String str, String str1, String prof) { + PdfWriter writer = null; + Document docPDF = null; + try { + docPDF = new Document (PageSize.A4, 25, 1.3F, 40, 0.74F); + //PageSize.A4.rotate () 为横向 + writer = PdfWriter.getInstance (docPDF, new FileOutputStream (temp)); + docPDF.open (); + + BaseFont baseFont = BaseFont.createFont("C:\\Windows\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H,BaseFont.EMBEDDED); + // 标题 + Font font = new Font(baseFont,16,Font.NORMAL); //正常 + Paragraph paragraph = new Paragraph(14);// 边距 + // 1 2 3 中右左 + paragraph.setAlignment(1); // 对齐方式 + paragraph.setFont(font);// 设置段落字体 + Chunk chunk = new Chunk("英德市人民医院影像中心"); + paragraph.add(chunk); + docPDF.add(paragraph); + + + Paragraph paragraph1 = new Paragraph(14); + BaseFont bfComic = BaseFont.createFont("c:\\windows\\fonts\\simkai.ttf", + BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); + // 1 2 3 中右左 + Font font2 = new Font(bfComic,20,Font.NORMAL); //正常 + paragraph1.setLeading(20f);// 行间距 + paragraph1.setAlignment(1); // 对齐方式 + paragraph1.setFont(font2); + Chunk chunk1 = new Chunk(prof); + paragraph1.add(chunk1); + docPDF.add(paragraph1); + + PdfPTable t0 = CreateTable0 (source); + PdfPTable t1 = CreateTable1 (source); + PdfPTable t2 = CreateTable2 (source); + PdfPTable t3 = CreateTable3 (source,str,str1); + docPDF.add (t0); + docPDF.add (t1); + docPDF.add (t2); + docPDF.add (t3); + PdfPTable t4 = CreateTable4 (source); + docPDF.add (t4); + //PdfPTable t5 = AddImage2PDF ("C:\\1102.png"); + //docPDF.add (t5); + + } + catch (Exception e) + { + e.printStackTrace (); + }finally { + if(null!=docPDF){ + docPDF.close (); + } + if(null !=writer){ + writer.close (); + } + } + File file = new File (temp); + return file.exists (); + } + + private final float RowHeight = 20F; + private final String FontName="宋体"; + private PdfPTable CreateTable0(Fangshe obj) throws Exception { + PdfPTable pt = new PdfPTable (8); + float[] widthes = new float[]{3F,4F,3F,2F,3F,2F,4F,4F}; + pt.setWidths(widthes); + pt.setWidthPercentage (95F); + + PdfPCell p11 = CreateCell (RowHeight,FontName, -1, false, -1, -1, "姓 名:"); + PdfPCell p12 = CreateCell (RowHeight,FontName, -1, false,PdfPCell.ALIGN_LEFT , -1, obj.getFIRSTNAME ()); + PdfPCell p13 = CreateCell (RowHeight,FontName, -1, false, -1, -1, "性 别:"); + PdfPCell p14 = CreateCell (RowHeight,FontName, -1, false, -1, -1, obj.getPATIENTSEX ()); + PdfPCell p15 = CreateCell (RowHeight,FontName, -1, false, -1, -1, "年 龄:"); + PdfPCell p16 = CreateCell (RowHeight,FontName, -1, false, -1, -1, obj.getPATIENTAGE ()); + PdfPCell p17 = CreateCell (RowHeight,FontName, -1, false, -1, -1, "检 查 号:"); + PdfPCell p18 = CreateCell (RowHeight,FontName, -1, false, PdfPCell.ALIGN_LEFT, -1, obj.getPATIENT_ID ()); + + + PdfPRow pr1 = new PdfPRow (new PdfPCell[]{ p11, p12, p13, p14,p15,p16, p17,p18 }); + pt.getRows ().add (pr1); + + PdfPCell p21 = CreateCell (RowHeight,FontName, -1, false, -1, -1, "申请科室:"); + PdfPCell p22 = CreateCell (RowHeight,FontName, 10, false, PdfPCell.ALIGN_LEFT, -1, obj.getREQUESTINGDEPARTMENT ()); + PdfPCell p23 = CreateCell (RowHeight,FontName, -1, false, -1, -1, "床 号:"); + PdfPCell p24 = CreateCell (RowHeight,FontName, -1, false, -1, -1, obj.getBEDID ()); + PdfPCell p25 = CreateCell (RowHeight,FontName, -1, false, -1, -1, "门诊号:"); + PdfPCell p26 = CreateCell (RowHeight,FontName, -1, false, -1, -1, obj.getCLINICAL_ID()); + PdfPCell p27 = CreateCell (RowHeight,FontName, -1, false, -1, -1, "住 院 号:"); + PdfPCell p28 = CreateCell (RowHeight,FontName, -1, false, PdfPCell.ALIGN_LEFT, -1, obj.getINPATIENT_ID()); + + PdfPRow pr2 = new PdfPRow (new PdfPCell[]{ p21, p22, p23, p24,p25,p26, p27,p28 }); + pt.getRows ().add (pr2); + AppendLine (8,pt,false, 2F); + + return pt; + } + private PdfPTable AddImage2PDF(String srcImg) throws Exception { + Image img = Image.getInstance(srcImg); + img.setScaleToFitHeight (true); + PdfPTable pt = new PdfPTable (1); + float[] widthes = new float[]{10F}; + pt.setWidths(widthes); + pt.setWidthPercentage (95F); + + PdfPCell p11 = CreateCell (0.1F,FontName, -1, false,Element.ALIGN_RIGHT, -1, " "); + p11.addElement(img); + + + PdfPRow pr1 = new PdfPRow (new PdfPCell[]{ p11 }); + pt.getRows ().add (pr1); + + + return pt; + } + private PdfPTable CreateTable1(Fangshe obj) throws Exception { + PdfPTable pt = new PdfPTable (2); + float[] widthes = new float[]{2F,8F}; + pt.setWidths(widthes); + pt.setWidthPercentage (95F); + + PdfPCell p11 = CreateCell (RowHeight,FontName, -1, false, -1, -1, "检查部位:"); + PdfPCell p12 = CreateCell (RowHeight,FontName, -1, false, -1, -1, obj.getREQUESTEDPROCEDUREDESCRIPTION ()); + + + PdfPRow pr1 = new PdfPRow (new PdfPCell[]{ p11, p12 }); + pt.getRows ().add (pr1); + return pt; + } + private PdfPTable CreateTable2(Fangshe obj) throws Exception { + PdfPTable pt = new PdfPTable (1); + float[] widthes = new float[]{2F}; + pt.setWidths(widthes); + pt.setWidthPercentage (95F); + + PdfPCell p11 = CreateCell (RowHeight,FontName, 14, false, -1, -1, "检查所见:"); + PdfPRow pr1 = new PdfPRow (new PdfPCell[]{ p11}); + pt.getRows ().add (pr1); + //AppendEmptyLine (2,pt,2F); + PdfPCell p12 = CreateCell (RowHeight,FontName, -1, false, -1, -1, " "+obj.getEXAMINEDESCRIPTION ()); + PdfPRow pr2 = new PdfPRow (new PdfPCell[]{ p12}); + pt.getRows ().add (pr2); + //增加空表格 + PdfPCell p122 = CreateCell (RowHeight,FontName, -1, false, -1, -1, ""); + PdfPRow pr122 = new PdfPRow (new PdfPCell[]{ p122}); + p122.setMinimumHeight(150); + pt.getRows ().add (pr122); + + AppendEmptyLine (2,pt,2F); + PdfPCell p13 = CreateCell (RowHeight,FontName, 14, false, -1, -1, "诊断提示:"); + PdfPRow pr3 = new PdfPRow (new PdfPCell[]{ p13}); + pt.getRows ().add (pr3); + String[] strings = convertMath(obj.getDIAGNOSISPROMPT()); + PdfPCell p14 = null; + for(String s:strings){ + p14 = CreateCell (RowHeight,FontName, -1, false, -1, -1, s); + PdfPRow pr4 = new PdfPRow (new PdfPCell[]{ p14}); + pt.getRows ().add (pr4); + } + PdfPCell p144 = CreateCell (RowHeight,FontName, -1, false, -1, -1,""); + PdfPRow pr144 = new PdfPRow (new PdfPCell[]{ p144}); + p144.setMinimumHeight(100); + pt.getRows ().add (pr144); + //AppendLine (1,pt,false,2F); + return pt; + } + private PdfPTable CreateTable3(Fangshe obj,String str,String str1) throws Exception { + PdfPTable pt = new PdfPTable (4); + float[] widthes = new float[]{3F,5F,3F,5F}; + pt.setWidths(widthes); + pt.setWidthPercentage (95F); + PdfPCell p11 = CreateCell (RowHeight,FontName, -1, false, -1, -1, "报告医师:"); + PdfPCell p12 = CreateCell (5F,FontName, -1, false, Element.ALIGN_RIGHT, -1, ""); + PdfPCell p13 = CreateCell (RowHeight,FontName, -1, false, -1, -1, "审核医师:"); + PdfPCell p14 = CreateCell (5F,FontName, -1, false, Element.ALIGN_RIGHT, -1, ""); + if(StringUtils.isNoneBlank (str)){ + Image img = Image.getInstance(str); + img.scalePercent (30); + p12.addElement (img); + } + //跨两行 + p12.setRowspan(2); + if(StringUtils.isNoneBlank (str1)){ + Image img1 = Image.getInstance(str1); + img1.scalePercent (30); + p14.addElement (img1); + } + //跨两行 + p14.setRowspan(2); + PdfPRow pr1 = new PdfPRow (new PdfPCell[]{ p11, p12, p13, p14}); + pt.getRows ().add (pr1); + //AppendLine (6,pt,false,2F); + + PdfPCell p21 = CreateCell (RowHeight,FontName, -1, false, -1, -1,obj.getREPORTDOCTOR()); + PdfPCell p22 = CreateCell (RowHeight,FontName, -1, false, -1, -1, ""); + PdfPCell p23 = CreateCell (RowHeight,FontName, -1, false, -1, -1, obj.getAUDITINGDOCTOR()); + PdfPCell p24 = CreateCell (RowHeight,FontName, -1, false, -1, -1,""); + PdfPRow pr2 = new PdfPRow (new PdfPCell[]{ p21,p22,p23,p24}); + pt.getRows ().add (pr2); + + + PdfPCell p31 = CreateCell (RowHeight,FontName, -1, false, -1, -1, "报告日期:"); + PdfPCell p32 = CreateCell (RowHeight,FontName, -1, false, -1, -1, obj.getREPORTDATE()); + PdfPCell p33 = CreateCell (RowHeight,FontName, -1, false, -1, -1, "审核日期:"); + PdfPCell p34 = CreateCell (RowHeight,FontName, -1, false, -1, -1,obj.getAUDITINGDATE()); + PdfPRow pr3 = new PdfPRow (new PdfPCell[]{ p31,p32,p33,p34}); + pt.getRows ().add (pr3); + + AppendLine (4,pt,false,2F); + return pt; + } + + private PdfPTable CreateTable4(Fangshe obj) throws Exception { + PdfPTable pt = new PdfPTable (1); + float[] widthes = new float[]{4F}; + pt.setWidths(widthes); + pt.setWidthPercentage (95F); + + PdfPCell p11 = CreateCell (5F,FontName, -1, false,-1, -1, "注:此报告仅供参考,不作任何证明。 电话:0763-2226116"); + + //img.scaleToFit (p13.getWidth (), p13.getHeight ()); + + PdfPRow pr1 = new PdfPRow (new PdfPCell[]{ p11}); + pt.getRows ().add (pr1); + + return pt; + } + + private Font CreateFont(String fontName, float fontSize, boolean isBold) throws Exception { + + String fontFile = "c:\\windows\\Fonts\\Simsun.ttc"; + BaseFont bsFont = null; + try { + bsFont = BaseFont.createFont (fontFile+",0", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); + } + catch (Exception e) + { + try { + bsFont = BaseFont.createFont ("宋体", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); + } catch(Exception e2) + { + e2.printStackTrace (); + } + } + if(bsFont==null) + { + throw new Exception ("bsFont==null"); + } + Font font =null; + if(fontSize>0) + { + font= new Font (bsFont, fontSize); + } + else + { + font= new Font (bsFont); + } + if(isBold) + { + font.setStyle (Font.BOLD); + } + return font; + } + + private PdfPCell CreateCell(float H, String fontName, float fontSize, boolean isBold, int align, int colSpan, String text) throws Exception { + String sText = text; + sText = sText.replace ("\r", "").replace ("\n",""); + PdfPCell p1 = new PdfPCell (new Phrase (sText, CreateFont (fontName,fontSize, isBold))); + p1.setMinimumHeight ((H>0?H:20F)); + + + if(align== PdfPCell.ALIGN_LEFT ||align== PdfPCell.ALIGN_CENTER ||align== PdfPCell.ALIGN_RIGHT ) + { + p1.setHorizontalAlignment (align); + } + else + { + p1.setHorizontalAlignment (PdfPCell.ALIGN_LEFT); + } + p1.setVerticalAlignment (PdfPCell.ALIGN_MIDDLE); + + if(colSpan>0) + { + p1.setColspan (colSpan); + } + p1.setBorder (Rectangle.NO_BORDER); + return p1; + } + + private void AppendEmptyLine(int cellCount , PdfPTable pt, float H) + { + PdfPCell[] cells = new PdfPCell[cellCount]; + + for (int i = 0; i < cellCount; i++) + { + cells[i] = new PdfPCell (new Paragraph (" ")); + cells[i].setMinimumHeight (20F); + //cells[i].setFixedHeight (H); + cells[i].setUseVariableBorders (true); + cells[i].setBorderWidthBottom (1F); + cells[i].setBorderWidthTop (1F); + cells[i].setBorderWidthLeft (0F); + cells[i].setBorderWidthRight (0F); + cells[i].setBorderColorBottom (BaseColor.WHITE); + cells[i].setBorderColorTop (BaseColor.WHITE); + cells[i].setBorderColorLeft (BaseColor.WHITE); + cells[i].setBorderColorRight (BaseColor.WHITE); + } + + + PdfPRow prow = new PdfPRow(cells); + pt.getRows ().add (prow); + } + private void AppendLine(int cellCount , PdfPTable pt,boolean isTop, float H) + { + PdfPCell[] cells = new PdfPCell[cellCount]; + + for (int i = 0; i < cellCount; i++) + { + cells[i] = new PdfPCell (new Paragraph (" ")); + cells[i].setFixedHeight (H); + cells[i].setUseVariableBorders (true); + cells[i].setBorderWidthBottom (1F); + cells[i].setBorderWidthTop (1F); + cells[i].setBorderWidthLeft (0F); + cells[i].setBorderWidthRight (0F); + if(isTop) + { + cells[i].setBorderColorBottom (BaseColor.WHITE); + cells[i].setBorderColorTop (BaseColor.BLACK); + cells[i].setBorderColorLeft (BaseColor.WHITE); + cells[i].setBorderColorRight (BaseColor.WHITE); + } + else + { + + cells[i].setBorderColorBottom (BaseColor.BLACK); + cells[i].setBorderColorTop (BaseColor.WHITE); + cells[i].setBorderColorLeft (BaseColor.WHITE); + cells[i].setBorderColorRight (BaseColor.WHITE); + } + } + PdfPRow prow = new PdfPRow(cells); + pt.getRows ().add (prow); + } + public Fangshe source() { + return new Fangshe ("冯秋仪","女","61岁", + "CT162361","普通外科二区","10","187855","", + "上腹(CT)平扫 1 次"," 平扫:腹盆腔内见巨大囊实性混杂信号包块影,大小约37cmX27cmX16cm,多房,边界大致清楚,实性部分形态不规则,信号不均匀,囊性部分局部内见间隔影,局部可见壁结节;子宫受压,内膜、肌层未见异常信号影。膀胱无充盈,未见明显异常。所见腹腔内见少量积液影,未见明确淋巴结肿大。右肾轻度扩张积液。", + " 对比2020-3-21片 1、慢支肺气肿并肺部感染较前吸收。 2、右上肺外胸膜下、左肺下叶胸膜下结节并邻近增厚粘连,大致同前。 3、主动脉、冠状动脉硬化.","2019年9月21日","2019年9月21日","朱玉莉", + "2019年9月21日","武义"); + } +} diff --git a/pacs/src/main/java/com/xjgs/service/MakeUpPacsService.java b/pacs/src/main/java/com/xjgs/service/MakeUpPacsService.java new file mode 100644 index 0000000..ec9f3c8 --- /dev/null +++ b/pacs/src/main/java/com/xjgs/service/MakeUpPacsService.java @@ -0,0 +1,25 @@ +package com.xjgs.service; + +import com.xjgs.vo.ArchiveMaster; +import com.xjgs.vo.PacsVo; + +import java.util.List; + +/** + * @InterfaceName MakeUpPacsService + * @Description 按需采集pacs接口 + * @Author linjj + * @Date 2023/8/3 11:06 + * @Version 1.0 + */ +public interface MakeUpPacsService { + + /** + * @description: 查询pacs路径集合 + * @params: ArchiveMaster + * @return: PacsVo + * @author linjj + * @date: 2023/8/3 11:08 + */ + void getPacsPathList(ArchiveMaster archiveMaster); +} diff --git a/pacs/src/main/java/com/xjgs/service/MakeUpPacsServiceImpl.java b/pacs/src/main/java/com/xjgs/service/MakeUpPacsServiceImpl.java new file mode 100644 index 0000000..1f319af --- /dev/null +++ b/pacs/src/main/java/com/xjgs/service/MakeUpPacsServiceImpl.java @@ -0,0 +1,724 @@ +package com.xjgs.service; + +import com.xjgs.dao.JDBCUtils; +import com.xjgs.dao.JDBCUtils3; +import com.xjgs.dao.JDBCUtils4; +import com.xjgs.dao.JDBCUtils5; +import com.xjgs.pacsDao.PacsMapper; +import com.xjgs.recordDao.ArchiveDetailMapper; +import com.xjgs.util.FileUtil; +import com.xjgs.util.FtpUtil; +import com.xjgs.util.Logger; +import com.xjgs.vo.*; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * @ClassName MakeUpPacsServiceImpl + * @Description pacs按需采集实现类 + * @Author linjj + * @Date 2023/8/3 11:06 + * @Version 1.0 + */ +@Service +public class MakeUpPacsServiceImpl implements MakeUpPacsService { + private static Logger logger = new Logger(); + @Autowired + PacsMapper pacsMapper; + @Autowired + ArchiveDetailMapper archiveDetailMapper; + + @Override + public void getPacsPathList(ArchiveMaster archiveMaster) { + //病案主件id + String ids = archiveMaster.getId(); + //根据入院前六小时出院后六小时住院号查询要下载pdf的路径 + List pacsPathList = pacsMapper.getPacsPathList(archiveMaster); + + //判断文件表中是否存在 + List archiveDetails = archiveDetailMapper.pacsGetPatId(); + //判断是否需要采集 + if (!pacsPathList.isEmpty()) { + for (PacsVo list : pacsPathList) { + boolean flag = true; + for (Archive_Detail archive_detail : archiveDetails) { + if (archive_detail.getSubAssort().equals(list.getSOURCEID() + "_" + list.getACCESSIONNUMBER())) { + flag = false; + } + } + //不存在执行 + if (flag) { + loadDcmToPdf(list, ids); + } + } + } + } + + + public void loadDcmToPdf(PacsVo pacsVo, String ids) { + String temp = System.getProperty("user.dir") + "\\temp"; + File fs = new File(temp); + if (!fs.isDirectory()) { + fs.mkdirs(); + } + UUID uuid = UUID.randomUUID();//UUID唯一识别 + String id = uuid.toString(); + id = id.replace("-", ""); + FtpUtil ftpUtil = new FtpUtil(); + File file = new File(temp + "\\" + id + ".pdf"); + File file3 = new File(temp + "\\" + id + ".dcm"); + System.out.println("temp" + temp); + ftpUtil.downloadFile(pacsVo.getDCMFile(), pacsVo.getDCMName(), temp, id + ".dcm"); + File fd = new File(temp + "\\" + id + ".dcm"); + boolean b = fd.exists(); + try { + if (b) { + //DCM转pdf工具 + DCM2PDF(temp + "\\" + id + ".dcm", temp + "\\" + id + ".pdf"); + if (file.exists()) { + Archive_Detail archiveDetail = new Archive_Detail(); +// ArchiveMaster archiveMaster = pacsGetHisId(pacsVo.getSOURCEID()); +// ArchiveMaster archiveMaster1 = null; +// if (StringUtils.isNoneBlank(archiveMaster.getPatientId())) { +// System.out.println("112"); +// archiveMaster1 = getMasterIdByPa(archiveMaster.getPatientId()); +// if (StringUtils.isNoneBlank(archiveMaster1.getId())) { +// System.out.println("113"); +// archiveMaster.setId(archiveMaster1.getId()); +// } else { +// uploadHomePageByPid(archiveMaster.getPatientId()); +// ArchiveMaster id1 = getMasterIdByPa(archiveMaster.getPatientId()); +// archiveMaster.setId(id1.getId()); +// System.out.println("114"); +// } +// } + List list = archiveDetailMapper.getIdAndJzh(ids); + if (list.size()==0){ + return ; + } + ArchiveMaster archiveMaster = list.get(0); + archiveDetail.setMasterId(ids); + archiveDetail.setUploadDateTime(new Date()); + archiveDetail.setAssortId("EABEEB5D628449A7930F4C0A9953A754"); + archiveDetail.setSource("pacs"); + archiveDetail.setFlag("0"); + archiveDetail.setTitle(pacsVo.getREQUESTEDPROCEDUREDESCRIPTION().replaceAll("\\s*", "")); + archiveDetail.setSubAssort(pacsVo.getSOURCEID() + "_" + pacsVo.getACCESSIONNUMBER()); + archiveDetail.setPdfPath(getXmlPath("path") + "\\pacs\\" + archiveMaster.getPatientId() + "\\" + id + ".pdf"); + File file2 = new File(getXmlPath("path") + "\\pacs\\" + archiveMaster.getPatientId()); + if (!file2.isDirectory()) { + file2.mkdirs(); + } + FileUtils.copyFile(file, new File(archiveDetail.getPdfPath())); + File file1 = new File(archiveDetail.getPdfPath()); + logger.log("4"); + if (file1.exists() && FileUtil.checkFileWritingOn(file1.getAbsolutePath())) { + logger.log("5"); + writeArchiveDetail(archiveDetail); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String format = sdf.format(new Date()); + logger.log("dcm转化成功,同步时间:" + format); + } + } + } else { + fanshe(pacsVo.getPATIENTID()); + } + } catch (Exception e) { + logger.log(e.toString()); + } finally { + file.delete(); + file3.delete(); + } + } + + //增加病例文件信息表记录 + public int writeArchiveDetail(Archive_Detail archiveDetail) { + String sql = "insert into archive_detail(id,PDF_PATH,MasterID,UpLoadDateTime,AssortID,Source,SubAssort,Title,flag)values(replace(newid(), '-', '')," + + "?,?,?,?,?,?,?,?)"; + Connection connection = null; + PreparedStatement statement = null; + Object[] parms = new Object[]{archiveDetail.getPdfPath(), archiveDetail.getMasterId(), archiveDetail.getUploadDateTime(), archiveDetail.getAssortId(), archiveDetail.getSource(), archiveDetail.getSubAssort(), archiveDetail.getTitle(), archiveDetail.getFlag()}; + int j = 0; + try { + connection = JDBCUtils3.getConnection(); + statement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + statement.setObject(i + 1, parms[i]); + } + } + j = statement.executeUpdate(); + } catch (Exception e) { + logger.log(e.toString()); + } finally { + JDBCUtils.release(null, statement, connection); + } + return j; + } + + private void DCM2PDF(String dcmFile, String toPDFFile) throws Exception { + File oFile = null; + byte b1 = 37; + byte b2 = 80; + byte b3 = 68; + byte b4 = 70; + FileInputStream inputStream = null; + String pdfFile = toPDFFile; + File tFile = null; + FileOutputStream outputStream = null; + try { + oFile = new File(dcmFile); + + if (!(oFile.isFile() && oFile.exists())) { + throw new Exception("DCM 文件读取失败=>" + dcmFile); + } + inputStream = new FileInputStream(oFile); + byte[] bs = new byte[(int) oFile.length()]; + inputStream.read(bs, 0, bs.length); + int seekPos = -1; + for (int i = 0; i < bs.length; i++) { + byte B1 = bs[i]; + byte B2 = 0; + byte B3 = 0; + byte B4 = 0; + if (i + 1 < bs.length) { + B2 = (byte) bs[i + 1]; + } + if (i + 2 < bs.length) { + B3 = (byte) bs[i + 2]; + } + if (i + 3 < bs.length) { + B4 = (byte) bs[i + 3]; + } + if (b1 == B1 && b2 == B2 && B3 == b3 && b4 == B4) { + seekPos = i; + break; + } + + } + + if (seekPos == -1) { + System.out.println("未发现2550 4446"); + throw new Exception("DCM 未读取到标志位=>" + dcmFile); + } + + tFile = new File(pdfFile); + if (tFile.isFile() && tFile.exists()) { + throw new Exception("目标文件已经存在=>" + pdfFile); + } + outputStream = new FileOutputStream(tFile, true); + for (int i = seekPos; i < bs.length; i++) { + outputStream.write(bs[i]); + } + + + } catch (Exception ex) { + System.out.println("读写出错" + ex.getMessage()); + throw ex; + } finally { + try { + if (inputStream != null) { + inputStream.close(); + + } + if (outputStream != null) { + outputStream.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + + public ArchiveMaster pacsGetHisId(String sourceId) { + String sql = "select fvisit_id,fappnote_no from mp.smp_pacs_appnote where fappnote_no = ?"; + Object[] parms = new Object[]{sourceId}; + ArchiveMaster archiveMaster = null; + ResultSet resultSet = null; + Connection connection = null; + PreparedStatement preparedStatement = null; + try { + connection = JDBCUtils.getConnection(); + preparedStatement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + preparedStatement.setObject(i + 1, parms[i]); + } + } + resultSet = preparedStatement.executeQuery(); + while (resultSet.next()) { + archiveMaster = new ArchiveMaster(); + archiveMaster.setPatientId(resultSet.getString("fvisit_id")); + } + } catch (SQLException e) { + logger.log(e.toString()); + } catch (Exception e) { + logger.log(e.toString()); + } finally { + JDBCUtils.release(resultSet, preparedStatement, connection); + } + return archiveMaster == null ? new ArchiveMaster() : archiveMaster; + } + + + public ArchiveMaster getMasterIdByPa(String jzh) { + String sql = "select ID,patient_id from archive_master where patient_id = ?"; + Object[] parms = new Object[]{jzh}; + ArchiveMaster archiveMaster = null; + ResultSet resultSet = null; + Connection connection = null; + PreparedStatement statement = null; + try { + connection = JDBCUtils3.getConnection(); + statement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + statement.setObject(i + 1, parms[i]); + } + } + resultSet = statement.executeQuery(); + while (resultSet.next()) { + archiveMaster = new ArchiveMaster(); + archiveMaster.setId(resultSet.getString("ID")); + archiveMaster.setPatientId(resultSet.getString("patient_id")); + } + } catch (Exception e) { + logger.log(e.toString()); + } finally { + JDBCUtils.release(resultSet, statement, connection); + } + return archiveMaster == null ? new ArchiveMaster() : archiveMaster; + } + + + public void uploadHomePageByPid(String patientId) { + String sql = "select t.zyh as 住院号,t.jzh as 记账号,t.zycs as 住院次数,t.xm as 姓名,t.xb as 性别,t.ryrq as 入院日期,t.cyrq as 出院日期,t.sfzh as 身份证号,t.rybq as 入院科室,t.dqbq as 出院科室,t.rycw as 入院床位,hp.fdrname as 主管医生 " + + "from ndns.zl t left join hthis.p_doctor hp on t.dqys = hp.fdrid where t.jzh = ? order by t.jzh desc"; + ArchiveMaster master = null; + ResultSet resultSet = null; + Connection connection = null; + PreparedStatement statement = null; + Object[] parms = new Object[]{patientId}; + try { + connection = JDBCUtils.getConnection(); + statement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + statement.setObject(i + 1, parms[i]); + } + } + resultSet = statement.executeQuery(); + while (resultSet.next()) { + master = new ArchiveMaster(); + master.setInpNo(resultSet.getString("住院号").trim()); + master.setPatientId(resultSet.getString("记账号").trim()); + master.setVisitId(resultSet.getString("住院次数")); + master.setName(resultSet.getString("姓名")); + master.setSex(resultSet.getString("性别")); + master.setAdmissionDateTime(resultSet.getString("入院日期")); + master.setDischargeDateTime(resultSet.getString("出院日期")); + master.setIdNo(resultSet.getString("身份证号")); + master.setDeptAdmissionTo(resultSet.getString("入院科室")); + master.setDeptName(resultSet.getString("出院科室")); + master.setDoctorInCharge(resultSet.getString("主管医生")); + master.setBedId(resultSet.getString("入院床位")); + if (null == master.getDischargeDateTime() || master.getDischargeDateTime().isEmpty()) { + master.setStatus("在院"); + } else { + master.setStatus("归档中"); + } + if ("2".equals(master.getSex())) { + master.setSex("女"); + } else { + master.setSex("男"); + } + writeHomeEntity(master); + } + } catch (Exception e) { + logger.log(e.toString()); + } finally { + JDBCUtils.release(resultSet, statement, connection); + } + } + + //新增首页数据 + int writeHomeEntity(ArchiveMaster archiveMaster) { + String sql = "insert into archive_master(id,patient_id,inp_no,visit_id,name,sex,dept_name,discharge_date_time," + + "archivestate,admission_date_time,dept_admission_to,doctor_in_charge,id_no,bed_id)values(replace(newid(), '-', ''),?,?,?,?,?,?,?,?,?,?,?,?,?)"; + Object[] parms = new Object[]{archiveMaster.getPatientId(), archiveMaster.getInpNo(), archiveMaster.getVisitId(), archiveMaster.getName(), archiveMaster.getSex(), archiveMaster.getDeptName(), archiveMaster.getDischargeDateTime(), archiveMaster.getStatus(), archiveMaster.getAdmissionDateTime(), archiveMaster.getDeptAdmissionTo(), archiveMaster.getDoctorInCharge(), archiveMaster.getIdNo(), archiveMaster.getBedId()}; + Connection connection = null; + PreparedStatement statement = null; + int j = 0; + try { + connection = JDBCUtils3.getConnection(); + statement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + statement.setObject(i + 1, parms[i]); + } + } + j = statement.executeUpdate(); + } catch (Exception e) { + logger.log(e.toString()); + } finally { + JDBCUtils.release(null, statement, connection); + } + return j; + } + + + public String getXmlPath(String elementName) { + Document doc = null; + try { + doc = new SAXReader().read(this.getClass().getResourceAsStream("/localPath.xml")); + } catch (DocumentException e) { + logger.log(e.toString()); + } + Element root = doc.getRootElement(); + Iterator itr = root.elementIterator(); + while (itr.hasNext()) { + Element element = (Element) itr.next(); + if (elementName.equals(element.getName())) { + return element.getTextTrim(); + } + } + return ""; + } + + public void fanshe(String patient_id) { + String temp = System.getProperty("user.dir") + "\\temp"; + File fs = new File(temp); + if (!fs.isDirectory()) { + fs.mkdirs(); + } + String loccalPath = getXmlPath("path"); + ItextPdfImpl itextPdf = new ItextPdfImpl(); + List fangsheList = getFangshe(patient_id); + List archive_details = getAssortIdBySource("pacs"); + Archive_Detail archiveDetail = null; + for (Fangshe fangshe : fangsheList) { + boolean flag = true; + for (Archive_Detail archive_detail : archive_details) { + if (archive_detail.getSubAssort().equals(fangshe.getSource_id() + "_" + fangshe.getACCESSIONNUMBER())) { + flag = false; + } + } + if (flag) { + String picPath = getPicPath(fangshe); + String picPath1 = getPicPath1(fangshe); + UUID uuid = UUID.randomUUID();//UUID唯一识别 + String id = uuid.toString(); + id = id.replace("-", ""); + archiveDetail = new Archive_Detail(); + archiveDetail.setAssortId("EABEEB5D628449A7930F4C0A9953A754"); + archiveDetail.setSubAssort(fangshe.getSource_id() + "_" + fangshe.getACCESSIONNUMBER()); + archiveDetail.setUploadDateTime(new Date()); + archiveDetail.setSource("pacs"); + archiveDetail.setFlag("0"); + archiveDetail.setTitle(fangshe.getREQUESTEDPROCEDUREDESCRIPTION().replaceAll("\\s*", "")); + try { + ArchiveMaster archiveMaster = pacsGetHisId(fangshe.getSource_id()); + if (StringUtils.isNoneBlank(archiveMaster.getPatientId())) { + ArchiveMaster archiveMaster1 = getMasterIdByPa(archiveMaster.getPatientId()); + if (StringUtils.isNoneBlank(archiveMaster1.getId())) { + archiveMaster.setId(archiveMaster1.getId()); + } else { + uploadHomePageByPid(archiveMaster.getPatientId()); + ArchiveMaster id1 = getMasterIdByPa(archiveMaster.getPatientId()); + archiveMaster.setId(id1.getId()); + } + File file = new File(loccalPath + "\\pacs\\" + archiveMaster.getPatientId()); + if (!file.isDirectory()) { + file.mkdirs(); + } + boolean b = itextPdf.writePdf(fangshe, temp + "\\" + id + ".pdf", picPath, picPath1, fangshe.getProf()); + if (b && FileUtil.checkFileWritingOn(temp + "\\" + id + ".pdf")) { + FileUtils.copyFile(new File(temp + "\\" + id + ".pdf"), new File(loccalPath + "\\pacs\\" + archiveMaster.getPatientId() + "\\" + id + ".pdf")); + archiveDetail.setPdfPath(loccalPath + "\\pacs\\" + archiveMaster.getPatientId() + "\\" + id + ".pdf"); + archiveDetail.setMasterId(archiveMaster.getId()); + File file1 = new File(archiveDetail.getPdfPath()); + if (file1.exists() && FileUtil.checkFileWritingOn(file1.getAbsolutePath())) { + writeArchiveDetail(archiveDetail); + logger.log("模板打出报告>>>>>单号:" + patient_id); + } + } + } + } catch (Exception e) { + logger.log(e.toString()); + } finally { + File file2 = new File(temp + "\\" + id + ".pdf"); + if (file2.exists()) { + file2.delete(); + } + } + } + } + } + + + public List getFangshe(String patient_id) { + ResultSet resultSet = null; + Connection connection = null; + PreparedStatement statement = null; + String sql = "select ACCESSIONNUMBER,PROF,source_id,FIRSTNAME AS 姓名,PATIENTSEX AS 性别,PATIENTAGE AS 年龄,PATIENT_ID AS 检查号,\n" + + "REQUESTINGDEPARTMENT AS 申请科室,BEDID AS 床号,INPATIENT_ID AS 住院号,CLINICAL_ID AS 门诊号,\n" + + "REQUESTEDPROCEDUREDESCRIPTION AS 检查部位,EXAMINEDESCRIPTION AS 检查所见,DIAGNOSISPROMPT AS \n" + + "诊断提示,CONVERT(varchar, DATEPART(yy,EXAMINEDATE))+'年'+CONVERT(varchar, DATEPART(mm,EXAMINEDATE))+'月'+\n" + + "CONVERT(varchar, DATEPART(DD,EXAMINEDATE))+'日'AS 检查日期,CONVERT(varchar, DATEPART(yy,REPORTDATE))+'年'+\n" + + "CONVERT(varchar, DATEPART(mm,REPORTDATE))+'月'+CONVERT(varchar, DATEPART(DD,REPORTDATE))+'日' AS 报告日期,\n" + + "REPORTDOCTOR AS 报告医生,CONVERT(varchar, DATEPART(yy,AUDITINGDATE))+'年'+CONVERT(varchar, DATEPART(mm,AUDITINGDATE))+'月'+\n" + + "CONVERT(varchar, DATEPART(DD,AUDITINGDATE))+'日'AS 审核日期,AUDITINGDOCTOR AS 审核医生 from RIS_STUDIES\n" + + "where REPORTDATE is not null and PATIENT_ID=?"; + Fangshe fangshe = null; + List fangsheList = new ArrayList<>(); + Object[] parms = new Object[]{patient_id}; + try { + connection = JDBCUtils4.getConnection(); + statement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + statement.setObject(i + 1, parms[i]); + } + } + resultSet = statement.executeQuery(); + while (resultSet.next()) { + fangshe = new Fangshe(); + fangshe.setACCESSIONNUMBER(resultSet.getString("ACCESSIONNUMBER")); + fangshe.setProf(convertProf(resultSet.getString("PROF"))); + fangshe.setSource_id(resultSet.getString("source_id")); + fangshe.setFIRSTNAME(resultSet.getString("姓名")); + fangshe.setPATIENTSEX(resultSet.getString("性别")); + fangshe.setPATIENTAGE(resultSet.getString("年龄")); + fangshe.setPATIENT_ID(resultSet.getString("检查号")); + fangshe.setREQUESTINGDEPARTMENT(resultSet.getString("申请科室")); + fangshe.setBEDID(resultSet.getString("床号")); + fangshe.setINPATIENT_ID(resultSet.getString("门诊号")); + fangshe.setCLINICAL_ID(resultSet.getString("住院号")); + fangshe.setREQUESTEDPROCEDUREDESCRIPTION(resultSet.getString("检查部位")); + fangshe.setEXAMINEDESCRIPTION(resultSet.getString("检查所见")); + fangshe.setDIAGNOSISPROMPT(resultSet.getString("诊断提示")); + fangshe.setEXAMINEDATE(resultSet.getString("检查日期")); + fangshe.setREPORTDATE(resultSet.getString("报告日期")); + fangshe.setREPORTDOCTOR(convertName(resultSet.getString("报告医生"))); + fangshe.setAUDITINGDATE(resultSet.getString("审核日期")); + fangshe.setAUDITINGDOCTOR(convertName(resultSet.getString("审核医生"))); + fangsheList.add(fangshe); + } + } catch (Exception e) { + logger.log(e.toString()); + } finally { + JDBCUtils.release(resultSet, statement, connection); + } + return fangsheList; + } + + public String convertProf(String profName) { + Map profMap = new HashMap<>(); + profMap.put("1", "B超检查报告单"); + profMap.put("2", "CR检查报告单"); + profMap.put("3", "CT检查报告单"); + profMap.put("4", "MR检查报告单"); + profMap.put("5", "放射检查报告单"); + profMap.put("6", "DR检查报告单"); + profMap.put("7", "数字胃肠检查报告单"); + profMap.put("8", "DSA检查小C报告单"); + profMap.put("9", "DSA检查大C报告单"); + profMap.put("20", "骨密度检查报告单"); + profMap.put("22", "胃镜检查报告单"); + profMap.put("23", "肠镜检查报告单"); + profMap.put("24", "鼻咽喉镜检查报告单"); + profMap.put("25", "十二指肠镜检查报告单"); + profMap.put("26", "TCD检查报告单"); + profMap.put("27", "支气管检查报告单"); + profMap.put("28", "肺功能检查报告单"); + profMap.put("29", "心电图检查报告单"); + profMap.put("30", "病理检查报告单"); + profMap.put("32", "超声内镜报告单"); + profMap.put("33", "胶囊内镜检查报告单"); + profMap.put("34", "呼气试验检查报告单"); + profMap.put("36", "液基检查报告单"); + profMap.put("37", "细胞学检查报告单"); + profMap.put("38", "HPV检查报告单"); + profMap.put("39", "皮肤科检查报告单"); + if (StringUtils.isNoneBlank(profName)) { + return profMap.get(profName); + } + return ""; + } + + public String convertName(String name) { + if (StringUtils.isNoneBlank(name)) { + String[] strings = name.split("/"); + if (2 == strings.length) { + return strings[0]; + } else { + return name; + } + } else { + return ""; + } + } + + + public List getAssortIdBySource(String source) { + String sql = "select SubAssort from archive_detail where Source = ? order by UpLoadDateTime desc"; + Object[] parms = new Object[]{source}; + Archive_Detail archive_detail = null; + List details = new ArrayList<>(); + Connection connection = null; + PreparedStatement statement = null; + ResultSet resultSet = null; + try { + connection = JDBCUtils3.getConnection(); + statement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + statement.setObject(i + 1, parms[i]); + } + } + resultSet = statement.executeQuery(); + while (resultSet.next()) { + archive_detail = new Archive_Detail(); + archive_detail.setSubAssort(resultSet.getString("SubAssort")); + details.add(archive_detail); + } + } catch (Exception e) { + logger.log(e.toString()); + } finally { + JDBCUtils.release(resultSet, statement, connection); + } + return details; + } + + public String getPicPath(Fangshe source) { + String path = getXmlPath("pic"); + User user = getUserEntity(source.getREPORTDOCTOR()); + String str = ""; + if (null != user.getCode()) { + File file = new File(path + user.getCode() + ".png"); + if (file.exists()) { + str = path + user.getCode() + ".png"; + } + File file1 = new File(path + "介入科\\" + user.getCode() + ".png"); + if (file1.exists()) { + str = path + "介入科\\" + user.getCode() + ".png"; + } + File file2 = new File(path + "内镜中心\\" + user.getCode() + ".png"); + if (file2.exists()) { + str = path + "内镜中心\\" + user.getCode() + ".png"; + } + if (!StringUtils.isNoneBlank(str)) { + File file3 = new File(path + "B超\\" + source.getREPORTDOCTOR() + ".png"); + if (file3.exists()) { + str = path + "B超\\" + source.getREPORTDOCTOR() + ".png"; + } + File file4 = new File(path + "病理\\" + source.getREPORTDOCTOR() + ".png"); + if (file4.exists()) { + str = path + "病理\\" + source.getREPORTDOCTOR() + ".png"; + } + } + } else { + File file = new File(path + "B超\\" + source.getREPORTDOCTOR() + ".png"); + if (file.exists()) { + str = path + "B超\\" + source.getREPORTDOCTOR() + ".png"; + } + File file1 = new File(path + "病理\\" + source.getREPORTDOCTOR() + ".png"); + if (file1.exists()) { + str = path + "病理\\" + source.getREPORTDOCTOR() + ".png"; + } + } + if (!StringUtils.isNoneBlank(str)) { + logger.log("未签名医师:" + source.getProf() + "-:" + source.getREPORTDOCTOR()); + } + return str; + } + + public String getPicPath1(Fangshe source) { + String path = getXmlPath("pic"); + User user = getUserEntity(source.getAUDITINGDOCTOR()); + String str = ""; + if (null != user.getCode()) { + File file = new File(path + user.getCode() + ".png"); + if (file.exists()) { + str = path + user.getCode() + ".png"; + } + File file1 = new File(path + "介入科\\" + user.getCode() + ".png"); + if (file1.exists()) { + str = path + "介入科\\" + user.getCode() + ".png"; + } + File file2 = new File(path + "内镜中心\\" + user.getCode() + ".png"); + if (file2.exists()) { + str = path + "内镜中心\\" + user.getCode() + ".png"; + } + if (!StringUtils.isNoneBlank(str)) { + File file3 = new File(path + "B超\\" + source.getAUDITINGDOCTOR() + ".png"); + if (file3.exists()) { + str = path + "B超\\" + source.getAUDITINGDOCTOR() + ".png"; + } + File file4 = new File(path + "病理\\" + source.getAUDITINGDOCTOR() + ".png"); + if (file4.exists()) { + str = path + "病理\\" + source.getAUDITINGDOCTOR() + ".png"; + } + } + } else { + File file = new File(path + "B超\\" + source.getAUDITINGDOCTOR() + ".png"); + if (file.exists()) { + str = path + "B超\\" + source.getAUDITINGDOCTOR() + ".png"; + } + File file1 = new File(path + "病理\\" + source.getAUDITINGDOCTOR() + ".png"); + if (file1.exists()) { + str = path + "病理\\" + source.getAUDITINGDOCTOR() + ".png"; + } + } + if (!StringUtils.isNoneBlank(str)) { + logger.log("未签名医师:" + source.getProf() + "-:" + source.getAUDITINGDOCTOR()); + } + return str; + } + + + public User getUserEntity(String name) { + String sql = "select user_name from power_user where name=?"; + Object[] parms = new Object[]{name}; + Connection connection = null; + PreparedStatement statement = null; + ResultSet resultSet = null; + User user = new User(); + try { + connection = JDBCUtils5.getConnection(); + statement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + statement.setObject(i + 1, parms[i]); + } + } + resultSet = statement.executeQuery(); + while (resultSet.next()) { + user.setCode(resultSet.getString("user_name")); + } + } catch (Exception ex) { + + } finally { + JDBCUtils.release(resultSet, statement, connection); + } + return user; + } +} diff --git a/pacs/src/main/java/com/xjgs/service/PacsService.java b/pacs/src/main/java/com/xjgs/service/PacsService.java new file mode 100644 index 0000000..6a63a39 --- /dev/null +++ b/pacs/src/main/java/com/xjgs/service/PacsService.java @@ -0,0 +1,665 @@ +package com.xjgs.service; + +import com.xjgs.dao.JDBCUtils; +import com.xjgs.dao.JDBCUtils3; +import com.xjgs.dao.JDBCUtils4; +import com.xjgs.dao.JDBCUtils5; +import com.xjgs.util.FileUtil; +import com.xjgs.util.FtpUtil; +import com.xjgs.util.Logger; +import com.xjgs.util.PDFHelper; +import com.xjgs.vo.ArchiveMaster; +import com.xjgs.vo.Archive_Detail; +import com.xjgs.vo.Fangshe; +import com.xjgs.vo.User; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; + +import java.io.File; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.*; + +public class PacsService { + private static Logger logger = new Logger(); + //下载超声pdf并填入文件表 + public void uploadRadiation(String patientId) { + SimpleDateFormat dateFormat = new SimpleDateFormat ("yyyy-MM-dd"); + String format1 = dateFormat.format (new Date ()); + String rootPath = System.getProperty ("user.dir"); + rootPath = rootPath+"\\logs\\"+format1; + File fs = new File (rootPath); + if(!fs.isDirectory ()){ + fs.mkdirs (); + } + System.setProperty ("log.base",rootPath); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String format = sdf.format(new Date ()); + List archive_details = getAssortIdBySource ("pacs"); + List fangsheList = getRadiEntity (patientId); + for(Fangshe fangshe : fangsheList){ + boolean flag = true; + for (Archive_Detail archive_detail:archive_details) { + if(archive_detail.getSubAssort ().equals (fangshe.getSource_id ()+"_"+fangshe.getACCESSIONNUMBER())){ + flag = false; + } + } + if(flag){ + UUID uuid = UUID.randomUUID();//UUID唯一识别 + String id = uuid.toString(); + id = id.replace("-", ""); + Date date = new Date(); + writeRadiEntity(fangshe,id,getXmlPath("path"), date); + } + } + logger.log("患者记账号为:"+patientId+"的超声数据已同步,同步时间:"+format); + } + public List getRadiEntity(String patientId) { + String sql = "select ACCESSIONNUMBER,PROF,REQUESTEDPROCEDUREDESCRIPTION AS 检查部位,source_id,CLINICAL_ID, REPORTDATE as 报告日期,\n" + + "AUDITINGDATE as 审核日期,PATIENT_ID as 检查号,INPATIENT_ID as 住院号,FIRSTNAME as 患者姓名,EXAMINEDATE \n" + + "as 开始检查时间@,CONVERT(varchar, DATEPART(yy,REGISTERDATE))+'/'+\n" + + "CONVERT(varchar,DATEPART(mm,REGISTERDATE))+'/'+CONVERT(varchar,DATEPART(dd,REGISTERDATE)) +'/'+RTRIM(ACCESSIONNUMBER)\n" + + " +'/zip/' as path,REPORTDOCTOR AS 报告医生,AUDITINGDOCTOR AS 审核医生 from RIS_STUDIES where ACCESSIONNUMBER like'J%'\n" + + "AND REPORTDATE is not null and SOURCE_ID is not null and (PATIENTTYPE = '住院' or PATIENTTYPE='急诊') and CLINICAL_ID = ? order by REPORTDATE desc"; + + Fangshe fangshe = null; + ListfangsheList = new ArrayList<> (); + ResultSet resultSet = null; + Connection connection = null; + PreparedStatement statement = null; + Object[]parms = new Object[]{patientId}; + try { + connection = JDBCUtils4.getConnection(); + statement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + statement.setObject(i + 1, parms[i]); + } + } + resultSet = statement.executeQuery(); + while (resultSet.next()) { + fangshe = new Fangshe (); + fangshe.setACCESSIONNUMBER (resultSet.getString ("ACCESSIONNUMBER")); + fangshe.setSource_id (resultSet.getString ("source_id")); + fangshe.setINPATIENT_ID (resultSet.getString ("住院号")); + fangshe.setProf (convertProf (resultSet.getString ("PROF"))); + fangshe.setREQUESTEDPROCEDUREDESCRIPTION (resultSet.getString ("检查部位")); + fangshe.setREPORTDOCTOR (convertName (resultSet.getString ("报告医生"))); + fangshe.setAUDITINGDOCTOR (convertName (resultSet.getString ("审核医生"))); + fangshe.setREPORTDATE(resultSet.getString("报告日期")); + fangshe.setPath (resultSet.getString ("path")); + if(null !=fangshe.getPath()){ + fangsheList.add(fangshe); + } + } + } catch (Exception e) { + logger.log(e.toString()); + } + finally { + JDBCUtils.release(resultSet,statement,connection); + } + return fangsheList; + } + public void fanshe(String patientId){ + String temp = System.getProperty("user.dir")+"\\temp"; + File fs = new File (temp); + if(!fs.isDirectory ()){ + fs.mkdirs (); + } + String loccalPath = getXmlPath("path"); + ItextPdfImpl itextPdf = new ItextPdfImpl(); + ListfangsheList= getFangshe(patientId); + List archive_details = getAssortIdBySource ("pacs"); + Archive_Detail archiveDetail = null; + for(Fangshe fangshe:fangsheList){ + boolean flag = true; + for(Archive_Detail archive_detail:archive_details){ + if(archive_detail.getSubAssort ().equals(fangshe.getSource_id ()+"_"+fangshe.getACCESSIONNUMBER())){ + flag = false; + } + } + if(flag){ + String picPath = getPicPath(fangshe); + String picPath1 = getPicPath1 (fangshe); + UUID uuid = UUID.randomUUID();//UUID唯一识别 + String id = uuid.toString(); + id = id.replace("-", ""); + archiveDetail = new Archive_Detail(); + archiveDetail.setAssortId("EABEEB5D628449A7930F4C0A9953A754"); + archiveDetail.setSubAssort(fangshe.getSource_id ()+"_"+fangshe.getACCESSIONNUMBER()); + archiveDetail.setUploadDateTime(new Date()); + archiveDetail.setSource("pacs"); + archiveDetail.setFlag("0"); + archiveDetail.setTitle(fangshe.getREQUESTEDPROCEDUREDESCRIPTION().replaceAll ("\\s*","")); + try { + ArchiveMaster archiveMaster = pacsGetHisId(fangshe.getSource_id()); + if(StringUtils.isNoneBlank(archiveMaster.getPatientId ())){ + ArchiveMaster archiveMaster1 = getMasterIdByPa(archiveMaster.getPatientId()); + if(StringUtils.isNoneBlank(archiveMaster1.getId())){ + archiveMaster.setId(archiveMaster1.getId()); + } + else{ + uploadHomePageByPid(archiveMaster.getPatientId()); + ArchiveMaster id1 = getMasterIdByPa(archiveMaster.getPatientId()); + archiveMaster.setId(id1.getId()); + } + File file = new File("Z:\\pacs\\"+archiveMaster.getPatientId()); + if(!file.isDirectory ()){ + file.mkdirs(); + } + boolean b = itextPdf.writePdf (fangshe,temp + "\\" + id + ".pdf",picPath,picPath1,fangshe.getProf ()); + if(b && FileUtil.checkFileWritingOn(temp + "\\" + id + ".pdf")){ + FileUtils.copyFile (new File (temp+"\\"+id+".pdf"),new File (/*loccalPath+"\\pacs\\"+*/"Z:\\pacs\\"+archiveMaster.getPatientId()+"\\"+id+".pdf")); + archiveDetail.setPdfPath(/*loccalPath+"\\pacs\\"*/"G:\\pdf\\pacs\\"+archiveMaster.getPatientId()+"\\"+id+".pdf"); + archiveDetail.setMasterId(archiveMaster.getId()); + File file1 = new File (archiveDetail.getPdfPath ()); + if(file1.exists () && FileUtil.checkFileWritingOn(file1.getAbsolutePath())){ + writeArchiveDetail(archiveDetail); + } + } + } + }catch (Exception e){ + logger.log(e.toString()); + }finally { + File file2 = new File (temp+"\\"+id+".pdf"); + file2.delete (); + } + } + } + } + public int writeArchiveDetail(Archive_Detail archiveDetail) { + String sql = "insert into archive_detail(id,PDF_PATH,MasterID,UpLoadDateTime,AssortID,Source,SubAssort,Title,flag)values(replace(newid(), '-', '')," + + "?,?,?,?,?,?,?,?)"; + Connection connection = null; + PreparedStatement statement = null; + Object[] parms = new Object[]{archiveDetail.getPdfPath(), archiveDetail.getMasterId(), archiveDetail.getUploadDateTime(), archiveDetail.getAssortId(), archiveDetail.getSource(), archiveDetail.getSubAssort(), archiveDetail.getTitle(), archiveDetail.getFlag()}; + int j = 0; + try { + connection = JDBCUtils3.getConnection(); + statement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + if(parms[i] instanceof Date) { + parms[i] = new java.sql.Timestamp(((Date) parms[i]).getTime()); + } + statement.setObject(i + 1, parms[i]); + } + } + j = statement.executeUpdate(); + } catch (Exception e) { + logger.log(e.toString()); + }finally { + JDBCUtils.release(null,statement,connection); + } + return j; + } + public List getFangshe(String patientId){ + ResultSet resultSet = null; + Connection connection = null; + PreparedStatement statement = null; + String sql = "select ACCESSIONNUMBER,PROF,source_id,FIRSTNAME AS 姓名,PATIENTSEX AS 性别,PATIENTAGE AS 年龄,PATIENT_ID AS 检查号,\n" + + "REQUESTINGDEPARTMENT AS 申请科室,BEDID AS 床号,INPATIENT_ID AS 住院号,CLINICAL_ID AS 门诊号,\n" + + "REQUESTEDPROCEDUREDESCRIPTION AS 检查部位,EXAMINEDESCRIPTION AS 检查所见,DIAGNOSISPROMPT AS \n" + + "诊断提示,CONVERT(varchar, DATEPART(yy,EXAMINEDATE))+'年'+CONVERT(varchar, DATEPART(mm,EXAMINEDATE))+'月'+\n" + + "CONVERT(varchar, DATEPART(DD,EXAMINEDATE))+'日'AS 检查日期,CONVERT(varchar, DATEPART(yy,REPORTDATE))+'年'+\n" + + "CONVERT(varchar, DATEPART(mm,REPORTDATE))+'月'+CONVERT(varchar, DATEPART(DD,REPORTDATE))+'日' AS 报告日期,\n" + + "REPORTDOCTOR AS 报告医生,CONVERT(varchar, DATEPART(yy,AUDITINGDATE))+'年'+CONVERT(varchar, DATEPART(mm,AUDITINGDATE))+'月'+\n" + + "CONVERT(varchar, DATEPART(DD,AUDITINGDATE))+'日'AS 审核日期,AUDITINGDOCTOR AS 审核医生 from RIS_STUDIES\n" + + "where CLINICAL_ID = ? order by REPORTDATE desc"; + Fangshe fangshe = null; + ListfangsheList = new ArrayList<>(); + Object[]parms= new Object[]{patientId};; + try { + connection = JDBCUtils4.getConnection(); + statement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + statement.setObject(i + 1, parms[i]); + } + } + resultSet = statement.executeQuery(); + while (resultSet.next()){ + fangshe = new Fangshe(); + fangshe.setACCESSIONNUMBER (resultSet.getString ("ACCESSIONNUMBER")); + fangshe.setProf (convertProf (resultSet.getString ("PROF"))); + fangshe.setSource_id(resultSet.getString("source_id")); + fangshe.setFIRSTNAME(resultSet.getString("姓名")); + fangshe.setPATIENTSEX(resultSet.getString("性别")); + fangshe.setPATIENTAGE(resultSet.getString("年龄")); + fangshe.setPATIENT_ID(resultSet.getString("检查号")); + fangshe.setREQUESTINGDEPARTMENT(resultSet.getString("申请科室")); + fangshe.setBEDID(resultSet.getString("床号")); + fangshe.setINPATIENT_ID(resultSet.getString("门诊号")); + fangshe.setCLINICAL_ID(resultSet.getString("住院号")); + fangshe.setREQUESTEDPROCEDUREDESCRIPTION(resultSet.getString("检查部位")); + fangshe.setEXAMINEDESCRIPTION(resultSet.getString("检查所见")); + fangshe.setDIAGNOSISPROMPT(resultSet.getString("诊断提示")); + fangshe.setEXAMINEDATE(resultSet.getString("检查日期")); + fangshe.setREPORTDATE(resultSet.getString("报告日期")); + fangshe.setREPORTDOCTOR(convertName (resultSet.getString("报告医生"))); + fangshe.setAUDITINGDATE(resultSet.getString("审核日期")); + fangshe.setAUDITINGDOCTOR(convertName (resultSet.getString("审核医生"))); + fangsheList.add(fangshe); + } + } catch (Exception e) { + logger.log(e.toString()); + }finally { + JDBCUtils.release(resultSet,statement,connection); + } + return fangsheList; + } + public String convertName(String name){ + if(StringUtils.isNoneBlank (name)){ + String[] strings = name.split ("/"); + if(2 == strings.length){ + return strings[0]; + }else { + return name; + } + }else { + return ""; + } + } + public ArchiveMaster pacsGetHisId(String sourceId){ + String sql = "select fvisit_id,fappnote_no from mp.smp_pacs_appnote where fappnote_no = ?"; + Object[]parms = new Object[]{sourceId}; + ArchiveMaster archiveMaster = null; + ResultSet resultSet = null; + Connection connection = null; + PreparedStatement preparedStatement = null; + try { + connection = JDBCUtils.getConnection(); + preparedStatement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + preparedStatement.setObject(i + 1, parms[i]); + } + } + resultSet = preparedStatement.executeQuery(); + while (resultSet.next()){ + archiveMaster = new ArchiveMaster(); + archiveMaster.setPatientId(resultSet.getString("fvisit_id")); + } + } catch (SQLException e) { + logger.log(e.toString()); + } catch (Exception e) { + logger.log(e.toString()); + } finally { + JDBCUtils.release(resultSet,preparedStatement,connection); + } + return archiveMaster == null ? new ArchiveMaster():archiveMaster; + } + public Integer writeRadiEntity(Fangshe fangshe, String id, String localPath, Date date) { + String temp = System.getProperty("user.dir")+"\\temp"; + File fs = new File (temp); + if(!fs.isDirectory ()){ + fs.mkdirs (); + } + int j = 0; + Connection connection = null; + PreparedStatement statement = null; + Archive_Detail archiveDetail = new Archive_Detail (); + archiveDetail.setSubAssort (fangshe.getSource_id ()); + ArchiveMaster archiveMaster = pacsGetHisId (fangshe.getSource_id ()); + ArchiveMaster archiveMaster1 = null; + if(StringUtils.isNoneBlank (archiveMaster.getPatientId ())) { + try { + archiveMaster1 = getMasterIdByPa (archiveMaster.getPatientId ()); + if (StringUtils.isNoneBlank(archiveMaster1.getId ())) { + archiveMaster.setId (archiveMaster1.getId ()); + } else { + uploadHomePageByPid (archiveMaster.getPatientId ()); + ArchiveMaster id1 = getMasterIdByPa (archiveMaster.getPatientId ()); + archiveMaster.setId (id1.getId ()); + } + FtpUtil ftpUtil = new FtpUtil (); + ftpUtil.downloadFile (fangshe.getPath (), "yun.pdf", temp, id + ".pdf"); + File fd = new File (temp+"\\"+id + ".pdf"); + if (fd.exists() && FileUtil.checkFileWritingOn(temp+"\\"+id + ".pdf")) { + String picPath = getPicPath (fangshe); + String picPath1 = getPicPath1 (fangshe); + archiveDetail.setPdfPath ((localPath + "\\pacs\\" + archiveMaster.getPatientId () + "\\" + id + ".pdf")); + File file = new File (localPath + "\\pacs\\" + archiveMaster.getPatientId ()); + if (!file.isDirectory ()) { + file.mkdirs (); + } + PDFHelper.AddWatermark (temp + "\\" + id + ".pdf", picPath, picPath1, archiveDetail.getPdfPath ()); + if (new File (archiveDetail.getPdfPath ()).exists () && FileUtil.checkFileWritingOn(archiveDetail.getPdfPath())) { + logger.log("准备添加文件信息"); + archiveDetail.setMasterId (archiveMaster.getId ()); + archiveDetail.setUploadDateTime (date); + archiveDetail.setAssortId ("EABEEB5D628449A7930F4C0A9953A754"); + archiveDetail.setSource ("pacs"); + archiveDetail.setFlag ("0"); + archiveDetail.setSubAssort (fangshe.getSource_id ()+"_"+fangshe.getACCESSIONNUMBER()); + archiveDetail.setTitle (fangshe.getREQUESTEDPROCEDUREDESCRIPTION ().replaceAll ("\\s*","")); + String sql = "insert into archive_detail(ID,PDF_PATH,MasterID,UpLoadDateTime,AssortID,Source,flag,title,SubAssort)values(replace(newid(), '-', ''),?,?,?,?,?,?,?,?)"; + Object[] parms = new Object[]{archiveDetail.getPdfPath (), archiveDetail.getMasterId (), archiveDetail.getUploadDateTime (), archiveDetail.getAssortId (), archiveDetail.getSource (), archiveDetail.getFlag (), archiveDetail.getTitle (), archiveDetail.getSubAssort ()}; + connection = JDBCUtils3.getConnection (); + statement = connection.prepareStatement (sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + statement.setObject (i + 1, parms[i]); + } + } + j = statement.executeUpdate (); + } + } + } catch (Exception e) { + logger.log ("超声数据未同步_____"+archiveMaster.getPatientId ()); + } finally { + File file = new File (temp + "\\" + id + ".pdf"); + file.delete (); + JDBCUtils.release (null, statement, connection); + } + } + return j; + } + public void uploadHomePageByPid(String patientId){ + String sql = "select t.zyh as 住院号,t.jzh as 记账号,t.zycs as 住院次数,t.xm as 姓名,t.xb as 性别,t.ryrq as 入院日期,t.cyrq as 出院日期,t.sfzh as 身份证号,t.rybq as 入院科室,t.dqbq as 出院科室,t.rycw as 入院床位,hp.fdrname as 主管医生 " + + "from ndns.zl t left join hthis.p_doctor hp on t.dqys = hp.fdrid where t.jzh = ? order by t.jzh desc"; + ArchiveMaster master = null; + ResultSet resultSet = null; + Connection connection = null; + PreparedStatement statement = null; + Object[]parms = new Object[]{patientId}; + try { + connection = JDBCUtils.getConnection(); + statement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + statement.setObject(i + 1, parms[i]); + } + } + resultSet = statement.executeQuery(); + while (resultSet.next()) { + master = new ArchiveMaster(); + master.setInpNo(resultSet.getString("住院号").trim()); + master.setPatientId(resultSet.getString("记账号").trim()); + master.setVisitId(resultSet.getString("住院次数")); + master.setName(resultSet.getString("姓名")); + master.setSex(resultSet.getString("性别")); + master.setAdmissionDateTime(resultSet.getString("入院日期")); + master.setDischargeDateTime(resultSet.getString("出院日期")); + master.setIdNo(resultSet.getString("身份证号")); + master.setDeptAdmissionTo(resultSet.getString("入院科室")); + master.setDeptName(resultSet.getString("出院科室")); + master.setDoctorInCharge(resultSet.getString("主管医生")); + master.setBedId(resultSet.getString ("入院床位")); + if(null == master.getDischargeDateTime()|| master.getDischargeDateTime().isEmpty()){ + master.setStatus("在院"); + }else{ + master.setStatus("归档中"); + } + if ("2".equals(master.getSex())) { + master.setSex("女"); + } else { + master.setSex("男"); + } + writeHomeEntity(master); + } + } catch (Exception e) { + logger.log(e.toString()); + } + finally { + JDBCUtils.release(resultSet,statement,connection); + } + } + //新增首页数据 + int writeHomeEntity(ArchiveMaster archiveMaster) { + String sql = "insert into archive_master(id,patient_id,inp_no,visit_id,name,sex,dept_name,discharge_date_time," + + "archivestate,admission_date_time,dept_admission_to,doctor_in_charge,id_no,bed_id)values(replace(newid(), '-', ''),?,?,?,?,?,?,?,?,?,?,?,?,?)"; + Object[] parms = new Object[]{archiveMaster.getPatientId(), archiveMaster.getInpNo(), archiveMaster.getVisitId(), archiveMaster.getName(), archiveMaster.getSex(), archiveMaster.getDeptName(), archiveMaster.getDischargeDateTime(), archiveMaster.getStatus(), archiveMaster.getAdmissionDateTime(), archiveMaster.getDeptAdmissionTo(), archiveMaster.getDoctorInCharge(), archiveMaster.getIdNo(),archiveMaster.getBedId ()}; + Connection connection = null; + PreparedStatement statement = null; + int j = 0; + try { + connection = JDBCUtils3.getConnection(); + statement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + statement.setObject(i + 1, parms[i]); + } + } + j = statement.executeUpdate(); + } catch (Exception e) { + logger.log(e.toString()); + }finally { + JDBCUtils.release(null,statement,connection); + } + return j; + } + public ArchiveMaster getMasterIdByPa(String jzh){ + String sql = "select ID,patient_id from archive_master where patient_id = ?"; + Object[]parms = new Object[]{jzh}; + ArchiveMaster archiveMaster = null; + ResultSet resultSet = null; + Connection connection = null; + PreparedStatement statement = null; + try { + connection = JDBCUtils3.getConnection(); + statement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + statement.setObject(i + 1, parms[i]); + } + } + resultSet = statement.executeQuery(); + while (resultSet.next()){ + archiveMaster = new ArchiveMaster(); + archiveMaster.setId(resultSet.getString("ID")); + archiveMaster.setPatientId(resultSet.getString("patient_id")); + } + } catch (Exception e) { + logger.log(e.toString()); + } + finally { + JDBCUtils.release(resultSet,statement,connection); + } + return archiveMaster == null ? new ArchiveMaster():archiveMaster; + } + public String getPicPath(Fangshe source){ + String path = getXmlPath("pic"); + User user = getUserEntity (source.getREPORTDOCTOR ()); + String str = ""; + if(StringUtils.isNoneBlank(user.getCode())){ + File file = new File (path+user.getCode ()+".png"); + if(file.exists ()){ + str = path+user.getCode ()+".png"; + } + File file1 = new File (path+"介入科\\"+user.getCode ()+".png"); + if(file1.exists ()){ + str = path+"介入科\\"+user.getCode ()+".png"; + } + File file2 = new File (path+"内镜中心\\"+user.getCode ()+".png"); + if(file2.exists ()){ + str = path+"内镜中心\\"+user.getCode ()+".png"; + } + if(!StringUtils.isNoneBlank (str)){ + File file3 = new File (path+"B超\\"+source.getREPORTDOCTOR ()+".png"); + if(file3.exists ()){ + str = path+"B超\\"+source.getREPORTDOCTOR ()+".png"; + } + File file4 = new File (path+"病理\\"+source.getREPORTDOCTOR ()+".png"); + if(file4.exists ()){ + str = path+"病理\\"+source.getREPORTDOCTOR ()+".png"; + } + } + }else{ + File file = new File (path+"B超\\"+source.getREPORTDOCTOR ()+".png"); + if(file.exists ()){ + str = path+"B超\\"+source.getREPORTDOCTOR ()+".png"; + } + File file1 = new File (path+"病理\\"+source.getREPORTDOCTOR ()+".png"); + if(file1.exists ()){ + str = path+"病理\\"+source.getREPORTDOCTOR ()+".png"; + } + } + if(!StringUtils.isNoneBlank (str)){ + logger.log ("未签名医师:"+source.getProf ()+"-:"+source.getREPORTDOCTOR ()); + } + return str; + } + public String getPicPath1(Fangshe source){ + String path = getXmlPath("pic"); + User user = getUserEntity (source.getAUDITINGDOCTOR ()); + String str = ""; + if(StringUtils.isNoneBlank(user.getCode())){ + File file = new File (path+user.getCode ()+".png"); + if(file.exists ()){ + str = path+user.getCode ()+".png"; + } + File file1 = new File (path+"介入科\\"+user.getCode ()+".png"); + if(file1.exists ()){ + str = path+"介入科\\"+user.getCode ()+".png"; + } + File file2 = new File (path+"内镜中心\\"+user.getCode ()+".png"); + if(file2.exists ()){ + str = path+"内镜中心\\"+user.getCode ()+".png"; + } + if(!StringUtils.isNoneBlank (str)){ + File file3 = new File (path+"B超\\"+source.getAUDITINGDOCTOR ()+".png"); + if(file3.exists ()){ + str = path+"B超\\"+source.getAUDITINGDOCTOR ()+".png"; + } + File file4 = new File (path+"病理\\"+source.getAUDITINGDOCTOR ()+".png"); + if(file4.exists ()){ + str = path+"病理\\"+source.getAUDITINGDOCTOR ()+".png"; + } + } + }else{ + File file = new File (path+"B超\\"+source.getAUDITINGDOCTOR ()+".png"); + if(file.exists ()){ + str = path+"B超\\"+source.getAUDITINGDOCTOR ()+".png"; + } + File file1 = new File (path+"病理\\"+source.getAUDITINGDOCTOR ()+".png"); + if(file1.exists ()){ + str = path+"病理\\"+source.getAUDITINGDOCTOR ()+".png"; + } + } + if(!StringUtils.isNoneBlank (str)){ + logger.log ("未签名医师:"+source.getProf ()+"-:"+source.getAUDITINGDOCTOR ()); + } + return str; + } + public User getUserEntity(String name){ + String sql = "select user_name from power_user where name=?"; + Object[]parms = new Object[]{name}; + Connection connection = null; + PreparedStatement statement = null; + ResultSet resultSet = null; + User user = new User (); + try { + connection = JDBCUtils5.getConnection (); + statement = connection.prepareStatement (sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + statement.setObject(i + 1, parms[i]); + } + } + resultSet = statement.executeQuery (); + while (resultSet.next ()){ + user.setCode (resultSet.getString ("user_name")); + } + }catch (Exception ex){ + logger.log(ex.toString()); + }finally { + JDBCUtils.release (resultSet,statement,connection); + } + return user; + } + public String convertProf(String profName){ + MapprofMap = new HashMap<> (); + profMap.put ("1","B超检查报告单"); + profMap.put ("2","CR检查报告单"); + profMap.put ("3","CT检查报告单"); + profMap.put ("4","MR检查报告单"); + profMap.put ("5","放射检查报告单"); + profMap.put ("6","DR检查报告单"); + profMap.put ("7","数字胃肠检查报告单"); + profMap.put ("8","DSA检查小C报告单"); + profMap.put ("9","DSA检查大C报告单"); + profMap.put ("20","骨密度检查报告单"); + profMap.put ("22","胃镜检查报告单"); + profMap.put ("23","肠镜检查报告单"); + profMap.put ("24","鼻咽喉镜检查报告单"); + profMap.put ("25","十二指肠镜检查报告单"); + profMap.put ("26","TCD检查报告单"); + profMap.put ("27","支气管检查报告单"); + profMap.put ("28","肺功能检查报告单"); + profMap.put ("29","心电图检查报告单"); + profMap.put ("30","病理检查报告单"); + profMap.put ("32","超声内镜报告单"); + profMap.put ("33","胶囊内镜检查报告单"); + profMap.put ("34","呼气试验检查报告单"); + profMap.put ("36","液基检查报告单"); + profMap.put ("37","细胞学检查报告单"); + profMap.put ("38","HPV检查报告单"); + profMap.put ("39","皮肤科检查报告单"); + if(StringUtils.isNoneBlank (profName)){ + return profMap.get (profName); + } + return ""; + } + public ListgetAssortIdBySource(String source){ + String sql = "select SubAssort from archive_detail where Source = ? order by UpLoadDateTime desc"; + Object[]parms = new Object[]{source}; + Archive_Detail archive_detail = null; + Listdetails = new ArrayList<>(); + Connection connection = null; + PreparedStatement statement = null; + ResultSet resultSet = null; + try { + connection = JDBCUtils3.getConnection(); + statement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + statement.setObject(i + 1, parms[i]); + } + } + resultSet = statement.executeQuery(); + while (resultSet.next()){ + archive_detail = new Archive_Detail(); + archive_detail.setSubAssort(resultSet.getString("SubAssort")); + details.add(archive_detail); + } + }catch (Exception e){ + logger.log(e.toString()); + }finally { + JDBCUtils.release(resultSet,statement,connection); + } + return details; + } + public String getXmlPath(String elementName) { + Document doc = null; + try { + doc = new SAXReader ().read(this.getClass().getResourceAsStream("/localPath.xml")); + } catch (DocumentException e) { + e.printStackTrace(); + } + Element root = doc.getRootElement(); + Iterator itr = root.elementIterator(); + while(itr.hasNext()){ + Element element = (Element)itr.next(); + if(elementName.equals(element.getName())){ + return element.getTextTrim(); + } + } + return ""; + } + + public String pacs(ArchiveMaster archiveMaster){ + return ""; + } + + + + +} diff --git a/pacs/src/main/java/com/xjgs/service/RadiateService.java b/pacs/src/main/java/com/xjgs/service/RadiateService.java new file mode 100644 index 0000000..52ec762 --- /dev/null +++ b/pacs/src/main/java/com/xjgs/service/RadiateService.java @@ -0,0 +1,737 @@ +package com.xjgs.service; + + +import com.xjgs.dao.JDBCUtils; +import com.xjgs.dao.JDBCUtils3; +import com.xjgs.dao.JDBCUtils4; +import com.xjgs.dao.JDBCUtils5; +import com.xjgs.util.FileUtil; +import com.xjgs.util.FtpUtil; +import com.xjgs.util.Logger; +import com.xjgs.vo.*; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.*; + +public class RadiateService { + private static Logger logger = new Logger(); + public List getFansheEntity(){ + String sql = "select PATIENT_ID,REQUESTEDPROCEDUREDESCRIPTION,ACCESSIONNUMBER,STUDYUID,REPORTDATE,SOURCE_ID\n" + + ",\n" + + "( CAST( DATEPART(year,REPORTDATE) as nvarchar(4)) +'/' + CAST( DATEPART(MONTH,REPORTDATE) as nvarchar(2))+'/'+ CAST(DATEPART(DAY,REPORTDATE) as nvarchar(2))\n" + + "+'/1.2.277.0.10.'+rtrim(ACCESSIONNUMBER)+'/'\n" + + "+'1.2.277.0.10.'+rtrim(ACCESSIONNUMBER)+'/')\n" + + "as 'DCMFile',\n" + + "('1.2.277.0.10.5.1.4.1.1.88.11.'+rtrim(ACCESSIONNUMBER)+'.dcm')\n" + + "as 'DCMName' \n" + + "from RIS_STUDIES where \n" + + "PROF in (2,3,4,5,6) \n" + + "and REPORTDATE is not null\n" + + "and SOURCE_ID is not null\n" + + "and AUDITINGDATE between DATEADD(SS,-1036800,getdate()) and CONVERT(varchar(100), GETDATE(), 21) and (PATIENTTYPE = '住院' or PATIENTTYPE='急诊')\n" + + "order by REPORTDATE DESC"; + Connection connection = null; + PreparedStatement statement = null; + ResultSet resultSet = null; + Listris_studies = new ArrayList<> (); + Ris_Study ris_study = null; + try { + connection = JDBCUtils4.getConnection (); + statement = connection.prepareStatement (sql); + resultSet = statement.executeQuery (); + while (resultSet.next ()){ + ris_study = new Ris_Study (); + ris_study.setPatientId(resultSet.getString("PATIENT_ID")); + ris_study.setACCESSIONNUMBER(resultSet.getString("ACCESSIONNUMBER")); + ris_study.setRecord_name (resultSet.getString ("REQUESTEDPROCEDUREDESCRIPTION")); + ris_study.setSource_id (resultSet.getString("SOURCE_ID")); + ris_study.setReportdate (resultSet.getString ("REPORTDATE")); + ris_study.setPath (resultSet.getString ("DCMFile")); + ris_study.setFirstname (resultSet.getString ("DCMName")); + ris_studies.add (ris_study); + } + }catch (Exception ex){ + logger.log(ex.toString()); + }finally { + JDBCUtils.release (resultSet,statement,connection); + } + return ris_studies; + } + + public void loadDcmToPdf(Ris_Study ris_study) { + String temp = System.getProperty("user.dir") + "\\temp"; + File fs = new File(temp); + if (!fs.isDirectory()) { + fs.mkdirs(); + } + UUID uuid = UUID.randomUUID();//UUID唯一识别 + String id = uuid.toString(); + id = id.replace("-", ""); + FtpUtil ftpUtil = new FtpUtil(); + File file = new File(temp + "\\" + id + ".pdf"); + File file3 = new File(temp + "\\" + id + ".dcm"); + ftpUtil.downloadFile(ris_study.getPath(), ris_study.getFirstname(), temp, id + ".dcm"); + File fd = new File(temp + "\\" + id + ".dcm"); + boolean b = fd.exists(); + try { + if (b) { + DCM2PDF(temp + "\\" + id + ".dcm", temp + "\\" + id + ".pdf"); + if (file.exists()) { + Archive_Detail archiveDetail = new Archive_Detail(); + ArchiveMaster archiveMaster = pacsGetHisId(ris_study.getSource_id()); + ArchiveMaster archiveMaster1 = null; + if (StringUtils.isNoneBlank(archiveMaster.getPatientId())) { + archiveMaster1 = getMasterIdByPa(archiveMaster.getPatientId()); + if (StringUtils.isNoneBlank(archiveMaster1.getId())) { + archiveMaster.setId(archiveMaster1.getId()); + } else { + uploadHomePageByPid(archiveMaster.getPatientId()); + ArchiveMaster id1 = getMasterIdByPa(archiveMaster.getPatientId()); + archiveMaster.setId(id1.getId()); + } + archiveDetail.setMasterId(archiveMaster.getId()); + archiveDetail.setUploadDateTime(new Date()); + archiveDetail.setAssortId("EABEEB5D628449A7930F4C0A9953A754"); + archiveDetail.setSource("pacs"); + archiveDetail.setFlag("0"); + archiveDetail.setTitle(ris_study.getRecord_name().replaceAll("\\s*", "")); + archiveDetail.setSubAssort(ris_study.getSource_id() + "_" + ris_study.getACCESSIONNUMBER()); + archiveDetail.setPdfPath(getXmlPath("path") + "\\pacs\\" + archiveMaster.getPatientId() + "\\" + id + ".pdf"); + File file2 = new File(getXmlPath("path") + "\\pacs\\" + archiveMaster.getPatientId()); + if (!file2.isDirectory()) { + file2.mkdirs(); + } + FileUtils.copyFile(file, new File(archiveDetail.getPdfPath())); + File file1 = new File(archiveDetail.getPdfPath()); + if (file1.exists() && FileUtil.checkFileWritingOn(file1.getAbsolutePath())) { + writeArchiveDetail(archiveDetail); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String format = sdf.format(new Date()); + logger.log("dcm转化成功,同步时间:"+format); + } + } + } + } else { + fanshe(ris_study.getPatientId()); + } + } catch (Exception e) { + logger.log(e.toString()); + } finally { + file.delete(); + file3.delete(); + } + } + public void fanshe(String patient_id){ + String temp = System.getProperty("user.dir")+"\\temp"; + File fs = new File (temp); + if(!fs.isDirectory ()){ + fs.mkdirs (); + } + String loccalPath = getXmlPath("path"); + ItextPdfImpl itextPdf = new ItextPdfImpl(); + ListfangsheList= getFangshe(patient_id); + List archive_details = getAssortIdBySource ("pacs"); + Archive_Detail archiveDetail = null; + for(Fangshe fangshe:fangsheList){ + boolean flag = true; + for(Archive_Detail archive_detail:archive_details){ + if(archive_detail.getSubAssort ().equals(fangshe.getSource_id ()+"_"+fangshe.getACCESSIONNUMBER())){ + flag = false; + } + } + if(flag){ + String picPath = getPicPath(fangshe); + String picPath1 = getPicPath1 (fangshe); + UUID uuid = UUID.randomUUID();//UUID唯一识别 + String id = uuid.toString(); + id = id.replace("-", ""); + archiveDetail = new Archive_Detail(); + archiveDetail.setAssortId("EABEEB5D628449A7930F4C0A9953A754"); + archiveDetail.setSubAssort(fangshe.getSource_id ()+"_"+fangshe.getACCESSIONNUMBER()); + archiveDetail.setUploadDateTime(new Date()); + archiveDetail.setSource("pacs"); + archiveDetail.setFlag("0"); + archiveDetail.setTitle(fangshe.getREQUESTEDPROCEDUREDESCRIPTION().replaceAll ("\\s*","")); + try { + ArchiveMaster archiveMaster = pacsGetHisId(fangshe.getSource_id()); + if(StringUtils.isNoneBlank(archiveMaster.getPatientId ())){ + ArchiveMaster archiveMaster1 = getMasterIdByPa(archiveMaster.getPatientId()); + if(StringUtils.isNoneBlank(archiveMaster1.getId())){ + archiveMaster.setId(archiveMaster1.getId()); + } + else{ + uploadHomePageByPid(archiveMaster.getPatientId()); + ArchiveMaster id1 = getMasterIdByPa(archiveMaster.getPatientId()); + archiveMaster.setId(id1.getId()); + } + File file = new File(loccalPath+"\\pacs\\"+archiveMaster.getPatientId()); + if(!file.isDirectory ()){ + file.mkdirs(); + } + boolean b = itextPdf.writePdf (fangshe,temp + "\\" + id + ".pdf",picPath,picPath1,fangshe.getProf ()); + if(b && FileUtil.checkFileWritingOn(temp + "\\" + id + ".pdf")){ + FileUtils.copyFile (new File (temp+"\\"+id+".pdf"),new File (loccalPath+"\\pacs\\"+archiveMaster.getPatientId()+"\\"+id+".pdf")); + archiveDetail.setPdfPath(loccalPath+"\\pacs\\"+archiveMaster.getPatientId()+"\\"+id+".pdf"); + archiveDetail.setMasterId(archiveMaster.getId()); + File file1 = new File (archiveDetail.getPdfPath ()); + if(file1.exists () && FileUtil.checkFileWritingOn(file1.getAbsolutePath())){ + writeArchiveDetail(archiveDetail); + logger.log("模板打出报告>>>>>单号:"+patient_id); + } + } + } + }catch (Exception e){ + logger.log(e.toString()); + }finally { + File file2 = new File (temp+"\\"+id+".pdf"); + if(file2.exists()){ + file2.delete (); + } + } + } + } + } + public String getPicPath(Fangshe source){ + String path = getXmlPath("pic"); + User user = getUserEntity (source.getREPORTDOCTOR ()); + String str = ""; + if(null != user.getCode ()){ + File file = new File (path+user.getCode ()+".png"); + if(file.exists ()){ + str = path+user.getCode ()+".png"; + } + File file1 = new File (path+"介入科\\"+user.getCode ()+".png"); + if(file1.exists ()){ + str = path+"介入科\\"+user.getCode ()+".png"; + } + File file2 = new File (path+"内镜中心\\"+user.getCode ()+".png"); + if(file2.exists ()){ + str = path+"内镜中心\\"+user.getCode ()+".png"; + } + if(!StringUtils.isNoneBlank (str)){ + File file3 = new File (path+"B超\\"+source.getREPORTDOCTOR ()+".png"); + if(file3.exists ()){ + str = path+"B超\\"+source.getREPORTDOCTOR ()+".png"; + } + File file4 = new File (path+"病理\\"+source.getREPORTDOCTOR ()+".png"); + if(file4.exists ()){ + str = path+"病理\\"+source.getREPORTDOCTOR ()+".png"; + } + } + }else{ + File file = new File (path+"B超\\"+source.getREPORTDOCTOR ()+".png"); + if(file.exists ()){ + str = path+"B超\\"+source.getREPORTDOCTOR ()+".png"; + } + File file1 = new File (path+"病理\\"+source.getREPORTDOCTOR ()+".png"); + if(file1.exists ()){ + str = path+"病理\\"+source.getREPORTDOCTOR ()+".png"; + } + } + if(!StringUtils.isNoneBlank (str)){ + logger.log ("未签名医师:"+source.getProf ()+"-:"+source.getREPORTDOCTOR ()); + } + return str; + } + public String getPicPath1(Fangshe source){ + String path = getXmlPath("pic"); + User user = getUserEntity (source.getAUDITINGDOCTOR ()); + String str = ""; + if(null != user.getCode ()){ + File file = new File (path+user.getCode ()+".png"); + if(file.exists ()){ + str = path+user.getCode ()+".png"; + } + File file1 = new File (path+"介入科\\"+user.getCode ()+".png"); + if(file1.exists ()){ + str = path+"介入科\\"+user.getCode ()+".png"; + } + File file2 = new File (path+"内镜中心\\"+user.getCode ()+".png"); + if(file2.exists ()){ + str = path+"内镜中心\\"+user.getCode ()+".png"; + } + if(!StringUtils.isNoneBlank (str)){ + File file3 = new File (path+"B超\\"+source.getAUDITINGDOCTOR ()+".png"); + if(file3.exists ()){ + str = path+"B超\\"+source.getAUDITINGDOCTOR ()+".png"; + } + File file4 = new File (path+"病理\\"+source.getAUDITINGDOCTOR ()+".png"); + if(file4.exists ()){ + str = path+"病理\\"+source.getAUDITINGDOCTOR ()+".png"; + } + } + }else{ + File file = new File (path+"B超\\"+source.getAUDITINGDOCTOR ()+".png"); + if(file.exists ()){ + str = path+"B超\\"+source.getAUDITINGDOCTOR ()+".png"; + } + File file1 = new File (path+"病理\\"+source.getAUDITINGDOCTOR ()+".png"); + if(file1.exists ()){ + str = path+"病理\\"+source.getAUDITINGDOCTOR ()+".png"; + } + } + if(!StringUtils.isNoneBlank (str)){ + logger.log ("未签名医师:"+source.getProf ()+"-:"+source.getAUDITINGDOCTOR ()); + } + return str; + } + public User getUserEntity(String name){ + String sql = "select user_name from power_user where name=?"; + Object[]parms = new Object[]{name}; + Connection connection = null; + PreparedStatement statement = null; + ResultSet resultSet = null; + User user = new User (); + try { + connection = JDBCUtils5.getConnection (); + statement = connection.prepareStatement (sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + statement.setObject(i + 1, parms[i]); + } + } + resultSet = statement.executeQuery (); + while (resultSet.next ()){ + user.setCode (resultSet.getString ("user_name")); + } + }catch (Exception ex){ + + }finally { + JDBCUtils.release (resultSet,statement,connection); + } + return user; + } + public ListgetAssortIdBySource(String source){ + String sql = "select SubAssort from archive_detail where Source = ? order by UpLoadDateTime desc"; + Object[]parms = new Object[]{source}; + Archive_Detail archive_detail = null; + Listdetails = new ArrayList<>(); + Connection connection = null; + PreparedStatement statement = null; + ResultSet resultSet = null; + try { + connection = JDBCUtils3.getConnection(); + statement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + statement.setObject(i + 1, parms[i]); + } + } + resultSet = statement.executeQuery(); + while (resultSet.next()){ + archive_detail = new Archive_Detail(); + archive_detail.setSubAssort(resultSet.getString("SubAssort")); + details.add(archive_detail); + } + }catch (Exception e){ + logger.log(e.toString()); + }finally { + JDBCUtils.release(resultSet,statement,connection); + } + return details; + } + public List getFangshe(String patient_id){ + ResultSet resultSet = null; + Connection connection = null; + PreparedStatement statement = null; + String sql = "select ACCESSIONNUMBER,PROF,source_id,FIRSTNAME AS 姓名,PATIENTSEX AS 性别,PATIENTAGE AS 年龄,PATIENT_ID AS 检查号,\n" + + "REQUESTINGDEPARTMENT AS 申请科室,BEDID AS 床号,INPATIENT_ID AS 住院号,CLINICAL_ID AS 门诊号,\n" + + "REQUESTEDPROCEDUREDESCRIPTION AS 检查部位,EXAMINEDESCRIPTION AS 检查所见,DIAGNOSISPROMPT AS \n" + + "诊断提示,CONVERT(varchar, DATEPART(yy,EXAMINEDATE))+'年'+CONVERT(varchar, DATEPART(mm,EXAMINEDATE))+'月'+\n" + + "CONVERT(varchar, DATEPART(DD,EXAMINEDATE))+'日'AS 检查日期,CONVERT(varchar, DATEPART(yy,REPORTDATE))+'年'+\n" + + "CONVERT(varchar, DATEPART(mm,REPORTDATE))+'月'+CONVERT(varchar, DATEPART(DD,REPORTDATE))+'日' AS 报告日期,\n" + + "REPORTDOCTOR AS 报告医生,CONVERT(varchar, DATEPART(yy,AUDITINGDATE))+'年'+CONVERT(varchar, DATEPART(mm,AUDITINGDATE))+'月'+\n" + + "CONVERT(varchar, DATEPART(DD,AUDITINGDATE))+'日'AS 审核日期,AUDITINGDOCTOR AS 审核医生 from RIS_STUDIES\n" + + "where REPORTDATE is not null and PATIENT_ID=?"; + Fangshe fangshe = null; + ListfangsheList = new ArrayList<>(); + Object[]parms= new Object[]{patient_id}; + try { + connection = JDBCUtils4.getConnection(); + statement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + statement.setObject(i + 1, parms[i]); + } + } + resultSet = statement.executeQuery(); + while (resultSet.next()){ + fangshe = new Fangshe(); + fangshe.setACCESSIONNUMBER (resultSet.getString ("ACCESSIONNUMBER")); + fangshe.setProf (convertProf (resultSet.getString ("PROF"))); + fangshe.setSource_id(resultSet.getString("source_id")); + fangshe.setFIRSTNAME(resultSet.getString("姓名")); + fangshe.setPATIENTSEX(resultSet.getString("性别")); + fangshe.setPATIENTAGE(resultSet.getString("年龄")); + fangshe.setPATIENT_ID(resultSet.getString("检查号")); + fangshe.setREQUESTINGDEPARTMENT(resultSet.getString("申请科室")); + fangshe.setBEDID(resultSet.getString("床号")); + fangshe.setINPATIENT_ID(resultSet.getString("门诊号")); + fangshe.setCLINICAL_ID(resultSet.getString("住院号")); + fangshe.setREQUESTEDPROCEDUREDESCRIPTION(resultSet.getString("检查部位")); + fangshe.setEXAMINEDESCRIPTION(resultSet.getString("检查所见")); + fangshe.setDIAGNOSISPROMPT(resultSet.getString("诊断提示")); + fangshe.setEXAMINEDATE(resultSet.getString("检查日期")); + fangshe.setREPORTDATE(resultSet.getString("报告日期")); + fangshe.setREPORTDOCTOR(convertName (resultSet.getString("报告医生"))); + fangshe.setAUDITINGDATE(resultSet.getString("审核日期")); + fangshe.setAUDITINGDOCTOR(convertName (resultSet.getString("审核医生"))); + fangsheList.add(fangshe); + } + } catch (Exception e) { + logger.log(e.toString()); + }finally { + JDBCUtils.release(resultSet,statement,connection); + } + return fangsheList; + } + public void fangsheInfo(){ + List archive_details = pacsGetPatId (); + List fansheEntity = getFansheEntity (); + for(Ris_Study risStudy:fansheEntity){ + boolean flag = true; + for(Archive_Detail archive_detail:archive_details){ + if(archive_detail.getSubAssort().equals(risStudy.getSource_id()+"_"+risStudy.getACCESSIONNUMBER())){ + flag = false; + } + } + if(flag){ + loadDcmToPdf (risStudy); + } + } + } + public List pacsGetPatId(){ + String sql = "select SubAssort from archive_detail where Source = 'pacs'order by UpLoadDateTime desc"; + Archive_Detail archive_detail = null; + Listdetails = new ArrayList<>(); + Connection connection = null; + PreparedStatement statement = null; + ResultSet resultSet = null; + try { + connection = JDBCUtils3.getConnection(); + statement = connection.prepareStatement(sql); + resultSet = statement.executeQuery(); + while (resultSet.next()){ + archive_detail = new Archive_Detail(); + archive_detail.setSubAssort(resultSet.getString("SubAssort")); + details.add(archive_detail); + } + }catch (Exception e){ + logger.log(e.toString()); + }finally { + JDBCUtils.release(resultSet,statement,connection); + } + return details; + } + //增加病例文件信息表记录 + public int writeArchiveDetail(Archive_Detail archiveDetail) { + String sql = "insert into archive_detail(id,PDF_PATH,MasterID,UpLoadDateTime,AssortID,Source,SubAssort,Title,flag)values(replace(newid(), '-', '')," + + "?,?,?,?,?,?,?,?)"; + Connection connection = null; + PreparedStatement statement = null; + Object[] parms = new Object[]{archiveDetail.getPdfPath(), archiveDetail.getMasterId(), archiveDetail.getUploadDateTime(), archiveDetail.getAssortId(), archiveDetail.getSource(), archiveDetail.getSubAssort(), archiveDetail.getTitle(), archiveDetail.getFlag()}; + int j = 0; + try { + connection = JDBCUtils3.getConnection(); + statement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + statement.setObject(i + 1, parms[i]); + } + } + j = statement.executeUpdate(); + } catch (Exception e) { + logger.log(e.toString()); + }finally { + JDBCUtils.release(null,statement,connection); + } + return j; + } + public ArchiveMaster getMasterIdByPa(String jzh){ + String sql = "select ID,patient_id from archive_master where patient_id = ?"; + Object[]parms = new Object[]{jzh}; + ArchiveMaster archiveMaster = null; + ResultSet resultSet = null; + Connection connection = null; + PreparedStatement statement = null; + try { + connection = JDBCUtils3.getConnection(); + statement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + statement.setObject(i + 1, parms[i]); + } + } + resultSet = statement.executeQuery(); + while (resultSet.next()){ + archiveMaster = new ArchiveMaster(); + archiveMaster.setId(resultSet.getString("ID")); + archiveMaster.setPatientId(resultSet.getString("patient_id")); + } + } catch (Exception e) { + logger.log(e.toString()); + } + finally { + JDBCUtils.release(resultSet,statement,connection); + } + return archiveMaster == null ? new ArchiveMaster():archiveMaster; + } + public ArchiveMaster pacsGetHisId(String sourceId){ + String sql = "select fvisit_id,fappnote_no from mp.smp_pacs_appnote where fappnote_no = ?"; + Object[]parms = new Object[]{sourceId}; + ArchiveMaster archiveMaster = null; + ResultSet resultSet = null; + Connection connection = null; + PreparedStatement preparedStatement = null; + try { + connection = JDBCUtils.getConnection(); + preparedStatement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + preparedStatement.setObject(i + 1, parms[i]); + } + } + resultSet = preparedStatement.executeQuery(); + while (resultSet.next()){ + archiveMaster = new ArchiveMaster(); + archiveMaster.setPatientId(resultSet.getString("fvisit_id")); + } + } catch (SQLException e) { + logger.log(e.toString()); + } catch (Exception e) { + logger.log(e.toString()); + } finally { + JDBCUtils.release(resultSet,preparedStatement,connection); + } + return archiveMaster == null ? new ArchiveMaster():archiveMaster; + } + public void uploadHomePageByPid(String patientId){ + String sql = "select t.zyh as 住院号,t.jzh as 记账号,t.zycs as 住院次数,t.xm as 姓名,t.xb as 性别,t.ryrq as 入院日期,t.cyrq as 出院日期,t.sfzh as 身份证号,t.rybq as 入院科室,t.dqbq as 出院科室,t.rycw as 入院床位,hp.fdrname as 主管医生 " + + "from ndns.zl t left join hthis.p_doctor hp on t.dqys = hp.fdrid where t.jzh = ? order by t.jzh desc"; + ArchiveMaster master = null; + ResultSet resultSet = null; + Connection connection = null; + PreparedStatement statement = null; + Object[]parms = new Object[]{patientId}; + try { + connection = JDBCUtils.getConnection(); + statement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + statement.setObject(i + 1, parms[i]); + } + } + resultSet = statement.executeQuery(); + while (resultSet.next()) { + master = new ArchiveMaster(); + master.setInpNo(resultSet.getString("住院号").trim()); + master.setPatientId(resultSet.getString("记账号").trim()); + master.setVisitId(resultSet.getString("住院次数")); + master.setName(resultSet.getString("姓名")); + master.setSex(resultSet.getString("性别")); + master.setAdmissionDateTime(resultSet.getString("入院日期")); + master.setDischargeDateTime(resultSet.getString("出院日期")); + master.setIdNo(resultSet.getString("身份证号")); + master.setDeptAdmissionTo(resultSet.getString("入院科室")); + master.setDeptName(resultSet.getString("出院科室")); + master.setDoctorInCharge(resultSet.getString("主管医生")); + master.setBedId(resultSet.getString ("入院床位")); + if(null == master.getDischargeDateTime()|| master.getDischargeDateTime().isEmpty()){ + master.setStatus("在院"); + }else{ + master.setStatus("归档中"); + } + if ("2".equals(master.getSex())) { + master.setSex("女"); + } else { + master.setSex("男"); + } + writeHomeEntity(master); + } + } catch (Exception e) { + logger.log(e.toString()); + } + finally { + JDBCUtils.release(resultSet,statement,connection); + } + } + public String convertProf(String profName){ + MapprofMap = new HashMap<> (); + profMap.put ("1","B超检查报告单"); + profMap.put ("2","CR检查报告单"); + profMap.put ("3","CT检查报告单"); + profMap.put ("4","MR检查报告单"); + profMap.put ("5","放射检查报告单"); + profMap.put ("6","DR检查报告单"); + profMap.put ("7","数字胃肠检查报告单"); + profMap.put ("8","DSA检查小C报告单"); + profMap.put ("9","DSA检查大C报告单"); + profMap.put ("20","骨密度检查报告单"); + profMap.put ("22","胃镜检查报告单"); + profMap.put ("23","肠镜检查报告单"); + profMap.put ("24","鼻咽喉镜检查报告单"); + profMap.put ("25","十二指肠镜检查报告单"); + profMap.put ("26","TCD检查报告单"); + profMap.put ("27","支气管检查报告单"); + profMap.put ("28","肺功能检查报告单"); + profMap.put ("29","心电图检查报告单"); + profMap.put ("30","病理检查报告单"); + profMap.put ("32","超声内镜报告单"); + profMap.put ("33","胶囊内镜检查报告单"); + profMap.put ("34","呼气试验检查报告单"); + profMap.put ("36","液基检查报告单"); + profMap.put ("37","细胞学检查报告单"); + profMap.put ("38","HPV检查报告单"); + profMap.put ("39","皮肤科检查报告单"); + if(StringUtils.isNoneBlank (profName)){ + return profMap.get (profName); + } + return ""; + } + public String convertName(String name){ + if(StringUtils.isNoneBlank (name)){ + String[] strings = name.split ("/"); + if(2 == strings.length){ + return strings[0]; + }else { + return name; + } + }else { + return ""; + } + } + //新增首页数据 + int writeHomeEntity(ArchiveMaster archiveMaster) { + String sql = "insert into archive_master(id,patient_id,inp_no,visit_id,name,sex,dept_name,discharge_date_time," + + "archivestate,admission_date_time,dept_admission_to,doctor_in_charge,id_no,bed_id)values(replace(newid(), '-', ''),?,?,?,?,?,?,?,?,?,?,?,?,?)"; + Object[] parms = new Object[]{archiveMaster.getPatientId(), archiveMaster.getInpNo(), archiveMaster.getVisitId(), archiveMaster.getName(), archiveMaster.getSex(), archiveMaster.getDeptName(), archiveMaster.getDischargeDateTime(), archiveMaster.getStatus(), archiveMaster.getAdmissionDateTime(), archiveMaster.getDeptAdmissionTo(), archiveMaster.getDoctorInCharge(), archiveMaster.getIdNo(),archiveMaster.getBedId ()}; + Connection connection = null; + PreparedStatement statement = null; + int j = 0; + try { + connection = JDBCUtils3.getConnection(); + statement = connection.prepareStatement(sql); + if (parms != null && parms.length > 0) { + for (int i = 0; i < parms.length; i++) { + statement.setObject(i + 1, parms[i]); + } + } + j = statement.executeUpdate(); + } catch (Exception e) { + logger.log(e.toString()); + }finally { + JDBCUtils.release(null,statement,connection); + } + return j; + } + + private void DCM2PDF( String dcmFile, String toPDFFile) throws Exception + { + File oFile = null; + byte b1 = 37; + byte b2 = 80; + byte b3 = 68; + byte b4 = 70; + FileInputStream inputStream = null; + String pdfFile = toPDFFile; + File tFile = null; + FileOutputStream outputStream = null; + try { + oFile = new File(dcmFile); + + if(!(oFile.isFile() && oFile.exists())) + { + throw new Exception("DCM 文件读取失败=>"+dcmFile); + } + inputStream = new FileInputStream(oFile); + byte[] bs = new byte[(int) oFile.length()]; + inputStream.read(bs, 0, bs.length); + int seekPos = -1; + for (int i = 0; i < bs.length; i++) { + byte B1 = bs[i]; + byte B2 = 0; + byte B3 = 0; + byte B4 = 0; + if (i + 1 < bs.length) { + B2 = (byte)bs[i + 1]; + } + if (i + 2 < bs.length) { + B3 = (byte)bs[i + 2]; + } + if (i + 3 < bs.length) { + B4 = (byte)bs[i + 3]; + } + if (b1 == B1 && b2 == B2 && B3 == b3 && b4 == B4) { + seekPos = i; + break; + } + + } + + if (seekPos == -1) { + System.out.println("未发现2550 4446"); + throw new Exception("DCM 未读取到标志位=>"+dcmFile); + } + + tFile = new File(pdfFile); + if(tFile.isFile() && tFile.exists()) + { + throw new Exception("目标文件已经存在=>"+pdfFile); + } + outputStream = new FileOutputStream(tFile, true); + for (int i = seekPos; i < bs.length; i++) { + outputStream.write(bs[i]); + } + + + } catch (Exception ex) { + System.out.println("读写出错" + ex.getMessage()); + throw ex; + } finally { + try { + if (inputStream != null) { + inputStream.close(); + + } + if (outputStream != null) { + outputStream.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } + public String getXmlPath(String elementName) { + Document doc = null; + try { + doc = new SAXReader ().read(this.getClass().getResourceAsStream("/localPath.xml")); + } catch (DocumentException e) { + logger.log(e.toString()); + } + Element root = doc.getRootElement(); + Iterator itr = root.elementIterator(); + while(itr.hasNext()){ + Element element = (Element)itr.next(); + if(elementName.equals(element.getName())){ + return element.getTextTrim(); + } + } + return ""; + } + + +} diff --git a/pacs/src/main/java/com/xjgs/util/FileUtil.java b/pacs/src/main/java/com/xjgs/util/FileUtil.java new file mode 100644 index 0000000..d89ff17 --- /dev/null +++ b/pacs/src/main/java/com/xjgs/util/FileUtil.java @@ -0,0 +1,25 @@ +package com.xjgs.util; + +import java.io.File; + +/** + *

+ * CLASS_NAME + *

+ * + * @author ly + * @since 2020/7/15 14:46 + */ +public class FileUtil { + public static boolean checkFileWritingOn(String fileName) throws Exception { + long oldLen = 0; + long newLen = 0; + File file = new File(fileName); + newLen = file.length(); + if ((newLen - oldLen) > 0) { + return true; + } else { + return false; + } + } +} diff --git a/pacs/src/main/java/com/xjgs/util/FtpUtil.java b/pacs/src/main/java/com/xjgs/util/FtpUtil.java new file mode 100644 index 0000000..095ed18 --- /dev/null +++ b/pacs/src/main/java/com/xjgs/util/FtpUtil.java @@ -0,0 +1,299 @@ +package com.xjgs.util; + +import org.apache.commons.net.ftp.FTPClient; +import org.apache.commons.net.ftp.FTPFile; +import org.apache.commons.net.ftp.FTPReply; + +import java.io.*; +import java.net.MalformedURLException; + +public class FtpUtil { + private static Logger logger = new Logger(); + //ftp服务器地址 + //public String hostname = "10.36.116.102"; + public String hostname = "10.36.116.101"; + //ftp服务器端口号默认为21 + //public Integer port = 22 ; + public Integer port = 21 ; + //ftp登录账号 + //public String username = "docus_archive";//匿名登录 + public String username = "anonymous";//匿名登录 + //ftp登录密码 + //public String password = "sucod@904"; + public String password = "sucod@904"; + + public FTPClient ftpClient = null; + + /** + * 初始化ftp服务器 + */ + public void initFtpClient() { + ftpClient = new FTPClient(); + ftpClient.setControlEncoding("utf-8"); + try { + System.out.println("connecting...ftp服务器:"+this.hostname+":"+this.port); + ftpClient.connect(hostname, port); //连接ftp服务器 + ftpClient.login(username, password); //登录ftp服务器 + int replyCode = ftpClient.getReplyCode(); //是否成功登录服务器 + if(!FTPReply.isPositiveCompletion(replyCode)){ + System.out.println("connect failed...ftp服务器:"+this.hostname+":"+this.port); + } + System.out.println("connect successfu...ftp服务器:"+this.hostname+":"+this.port); + }catch (MalformedURLException e) { + logger.log(e.toString()); + }catch (IOException e) { + logger.log(e.toString()); + } + } + + /** + * 上传文件 + * @param pathname ftp服务保存地址 + * @param fileName 上传到ftp的文件名 + * @param originfilename 待上传文件的名称(绝对地址) * + * @return + */ + public boolean uploadFile( String pathname, String fileName,String originfilename){ + boolean flag = false; + InputStream inputStream = null; + try{ + System.out.println("开始上传文件"); + inputStream = new FileInputStream(new File(originfilename)); + initFtpClient(); + ftpClient.setFileType(ftpClient.BINARY_FILE_TYPE); + CreateDirecroty(pathname); + ftpClient.makeDirectory(pathname); + ftpClient.changeWorkingDirectory(pathname); + ftpClient.storeFile(fileName, inputStream); + inputStream.close(); + ftpClient.logout(); + flag = true; + System.out.println("上传文件成功"); + }catch (Exception e) { + System.out.println("上传文件失败"); + logger.log(e.toString()); + }finally{ + if(ftpClient.isConnected()){ + try{ + ftpClient.disconnect(); + }catch(IOException e){ + logger.log(e.toString()); + } + } + if(null != inputStream){ + try { + inputStream.close(); + } catch (IOException e) { + logger.log(e.toString()); + } + } + } + return true; + } + /** + * 上传文件 + * @param pathname ftp服务保存地址 + * @param fileName 上传到ftp的文件名 + * @param inputStream 输入文件流 + * @return + */ + public boolean uploadFile( String pathname, String fileName,InputStream inputStream){ + boolean flag = false; + try{ + System.out.println("开始上传文件"); + initFtpClient(); + ftpClient.setFileType(ftpClient.BINARY_FILE_TYPE); + CreateDirecroty(pathname); + ftpClient.makeDirectory(pathname); + ftpClient.changeWorkingDirectory(pathname); + ftpClient.storeFile(fileName, inputStream); + inputStream.close(); + ftpClient.logout(); + flag = true; + System.out.println("上传文件成功"); + }catch (Exception e) { + System.out.println("上传文件失败"); + logger.log(e.toString()); + }finally{ + if(ftpClient.isConnected()){ + try{ + ftpClient.disconnect(); + }catch(IOException e){ + logger.log(e.toString()); + } + } + if(null != inputStream){ + try { + inputStream.close(); + } catch (IOException e) { + logger.log(e.toString()); + } + } + } + return true; + } + //改变目录路径 + public boolean changeWorkingDirectory(String directory) { + boolean flag = true; + try { + flag = ftpClient.changeWorkingDirectory(directory); + if (flag) { + System.out.println("进入文件夹" + directory + " 成功!"); + + } else { + System.out.println("进入文件夹" + directory + " 失败!开始创建文件夹"); + } + } catch (IOException ioe) { + logger.log(ioe.toString()); + } + return flag; + } + + //创建多层目录文件,如果有ftp服务器已存在该文件,则不创建,如果无,则创建 + public boolean CreateDirecroty(String remote) throws IOException { + boolean success = true; + String directory = remote + "/"; + // 如果远程目录不存在,则递归创建远程服务器目录 + if (!directory.equalsIgnoreCase("/") && !changeWorkingDirectory(new String(directory))) { + int start = 0; + int end = 0; + if (directory.startsWith("/")) { + start = 1; + } else { + start = 0; + } + end = directory.indexOf("/", start); + String path = ""; + String paths = ""; + while (true) { + String subDirectory = new String(remote.substring(start, end).getBytes("GBK"), "iso-8859-1"); + path = path + "/" + subDirectory; + if (!existFile(path)) { + if (makeDirectory(subDirectory)) { + changeWorkingDirectory(subDirectory); + } else { + System.out.println("创建目录[" + subDirectory + "]失败"); + changeWorkingDirectory(subDirectory); + } + } else { + changeWorkingDirectory(subDirectory); + } + + paths = paths + "/" + subDirectory; + start = end + 1; + end = directory.indexOf("/", start); + // 检查所有目录是否创建完毕 + if (end <= start) { + break; + } + } + } + return success; + } + + //判断ftp服务器文件是否存在 + public boolean existFile(String path) throws IOException { + boolean flag = false; + FTPFile[] ftpFileArr = ftpClient.listFiles(path); + if (ftpFileArr.length > 0) { + flag = true; + } + return flag; + } + //创建目录 + public boolean makeDirectory(String dir) { + boolean flag = true; + try { + flag = ftpClient.makeDirectory(dir); + if (flag) { + System.out.println("创建文件夹" + dir + " 成功!"); + + } else { + System.out.println("创建文件夹" + dir + " 失败!"); + } + } catch (Exception e) { + logger.log(e.toString()); + } + return flag; + } + + /** * 下载文件 * + * @param pathname FTP服务器文件目录 * + * @param filename 文件名称 * + * @param localpath 下载后的文件路径 * + * @return */ + public boolean downloadFile(String pathname, String filename, String localpath,String localname){ + boolean flag = false; + OutputStream os=null; + try { + System.out.println("开始下载文件"); + initFtpClient(); + //切换FTP目录 + ftpClient.changeWorkingDirectory(pathname); + ftpClient.enterLocalPassiveMode(); + FTPFile[] ftpFiles = ftpClient.listFiles(); + for(FTPFile file : ftpFiles){ + if(filename.equalsIgnoreCase(file.getName())){ + File localFile = new File(localpath + "\\" + localname); + os = new FileOutputStream(localFile); + boolean b = ftpClient.retrieveFile(file.getName(), os); + if(b){ + flag = true; + System.out.println("下载文件成功"); + } + os.close(); + } + } + ftpClient.logout(); + } catch (Exception e) { + System.out.println("下载文件失败"); + logger.log(e.toString()); + } finally{ + if(ftpClient.isConnected()){ + try{ + ftpClient.disconnect(); + }catch(IOException e){ + logger.log(e.toString()); + } + } + if(null != os){ + try { + os.close(); + } catch (IOException e) { + logger.log(e.toString()); + } + } + } + return flag; + } + + /** * 删除文件 * + * @param pathname FTP服务器保存目录 * + * @param filename 要删除的文件名称 * + * @return */ + public boolean deleteFile(String pathname, String filename){ + boolean flag = false; + try { + System.out.println("开始删除文件"); + initFtpClient(); + //切换FTP目录 + ftpClient.changeWorkingDirectory(pathname); + ftpClient.dele(filename); + ftpClient.logout(); + flag = true; + System.out.println("删除文件成功"); + } catch (Exception e) { + System.out.println("删除文件失败"); + logger.log(e.toString()); + } finally { + if(ftpClient.isConnected()){ + try{ + ftpClient.disconnect(); + }catch(IOException e){ + logger.log(e.toString()); + } + } + } + return flag; + } +} diff --git a/pacs/src/main/java/com/xjgs/util/JsonResult.java b/pacs/src/main/java/com/xjgs/util/JsonResult.java new file mode 100644 index 0000000..2350ce1 --- /dev/null +++ b/pacs/src/main/java/com/xjgs/util/JsonResult.java @@ -0,0 +1,51 @@ +package com.xjgs.util; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +/** + * 这是一个给fastJSON/jackson准备的一个对象 + */ +public class JsonResult implements Serializable { + private Map dataMap = new HashMap<>(3); + + public JsonResult() { + } + + public String getCode() { + return dataMap.get("code").toString(); + } + + public void setCode(String code) { + this.dataMap.put("code", code); + } + + public String getMsg() { + return dataMap.get("msg").toString(); + } + + public void setMsg(String msg) { + this.dataMap.put("msg", msg); + } + + public Object getData() { + return dataMap.get("data"); + } + + public void setData(Object data) { + this.dataMap.put("data", data); + } + + public Map getDataMap() { + return dataMap; + } + + public void setDataMap(Map dataMap) { + this.dataMap = dataMap; + } + + public void put(String name, Object value) { + this.dataMap.put(name, value); + } +} diff --git a/pacs/src/main/java/com/xjgs/util/Logger.java b/pacs/src/main/java/com/xjgs/util/Logger.java new file mode 100644 index 0000000..d08094a --- /dev/null +++ b/pacs/src/main/java/com/xjgs/util/Logger.java @@ -0,0 +1,38 @@ +package com.xjgs.util; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class Logger { + public void log(String info){ + SimpleDateFormat dateFormat = new SimpleDateFormat ("yyyy-MM-dd"); + String format = dateFormat.format (new Date()); + File file = new File (System.getProperty("user.dir")+"\\logs\\"+format); + if(!file.isDirectory ()){ + file.mkdirs (); + } + OutputStream out = null; + try { + out = getOutputStream(file.getAbsolutePath ()+"\\log.log"); + out.write(info.getBytes("utf-8")); + out.write("\r\n".getBytes()); + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public OutputStream getOutputStream(String localpath) throws IOException { + File file = new File(localpath); + if (!file.exists()) { + file.createNewFile(); + return new FileOutputStream(file); + } else { + return new FileOutputStream(file, true); + } + } +} diff --git a/pacs/src/main/java/com/xjgs/util/PDFHelper.java b/pacs/src/main/java/com/xjgs/util/PDFHelper.java new file mode 100644 index 0000000..85d4b23 --- /dev/null +++ b/pacs/src/main/java/com/xjgs/util/PDFHelper.java @@ -0,0 +1,127 @@ +package com.xjgs.util; + +import com.itextpdf.text.Image; +import com.itextpdf.text.Rectangle; +import com.itextpdf.text.pdf.PdfContentByte; +import com.itextpdf.text.pdf.PdfReader; +import com.itextpdf.text.pdf.PdfStamper; +import com.itextpdf.text.pdf.PdfTemplate; +import com.sun.glass.ui.Size; +import org.apache.commons.lang3.StringUtils; +import org.junit.Test; + +import java.awt.*; +import java.io.*; +import java.util.UUID; + +public class PDFHelper { + + + public static void AddWatermark(String pdfPath, String img1, String img2, String toPath) throws Exception + { + String sFile = UUID.randomUUID().toString().replace("-", "").replace("{","").replace("}","")+".pdf"; + File tmpFile = new File(sFile); + FileOutputStream outputStream = new FileOutputStream(tmpFile); + PdfReader reader = new PdfReader(pdfPath); + PdfStamper pdfStamper = new PdfStamper(reader, outputStream); + try + { + float scaleP = 50; + + //这里是加第一个签名 + Image pImg1 = null; + if(StringUtils.isNoneBlank (img1)){ + pImg1 = Image.getInstance(img1); + pImg1.scalePercent(scaleP); + } + + + //第二个签名 + Image pImg2 = null; + if(StringUtils.isNoneBlank (img2)){ + pImg2 = Image.getInstance(img2); + pImg2.scalePercent(scaleP); + } + for (int i = 1; i <= reader.getNumberOfPages(); i++) + { + Rectangle pageSize = reader.getPageSize(i); + PdfContentByte cb = pdfStamper.getOverContent(i); + //设置签名位置 + if(null!=pImg1){ + Point pt = new Point((int)(pageSize.getWidth() / 2 - pImg1.getScaledWidth() / 2-40), 45); + pImg1.setAbsolutePosition((float)pt.getX(), (float)pt.getY()); + cb.addImage(pImg1); + + + + Point pt2 = new Point((int)(pageSize.getWidth() - pImg1.getScaledWidth() / 2-55), 45); + pImg2.setAbsolutePosition((float)pt2.getX(), (float)pt2.getY()); + cb.addImage(pImg2); + } + } + } + finally + { + if(pdfStamper!= null) + { + pdfStamper.close(); + } + if(outputStream!=null) + { + outputStream.close(); + } + if(reader !=null) { + reader.close(); + } + } + + //复制文件到toFile + copy(sFile, toPath); + } + + + private static int bufferSize = 10; + public static void copy(String source, String dest) throws Exception { + + File fDest = new File(dest); + if(fDest.isFile()&& fDest.exists()) + { + fDest.delete(); + } + + InputStream in = null; + OutputStream out = null; + try { + in = new FileInputStream(new File(source)); + out = new FileOutputStream(fDest); + + byte[] buffer = new byte[bufferSize]; + int len; + + while ((len = in.read(buffer)) > 0) { + out.write(buffer, 0, len); + } + } catch (Exception e) { + + } finally { + if(in!=null) + { + in.close(); + } + if(out!=null) + { + out.close(); + } + } + } + + private static void AddBackImageTemplate(PdfContentByte cb, Size ptSize, String srcImgPath, float x, float y) throws Exception + { + PdfTemplate pdfTemplate = cb.createTemplate(ptSize.width, ptSize.height); + Image pimg = Image.getInstance(srcImgPath); + pimg.setAbsolutePosition(0, 0); + pimg.scaleToFit(ptSize.width, ptSize.height); + pdfTemplate.addImage(pimg); + cb.addTemplate(pdfTemplate, x, y); + } +} diff --git a/pacs/src/main/java/com/xjgs/util/StringUtil.java b/pacs/src/main/java/com/xjgs/util/StringUtil.java new file mode 100644 index 0000000..7c9c08e --- /dev/null +++ b/pacs/src/main/java/com/xjgs/util/StringUtil.java @@ -0,0 +1,213 @@ +package com.xjgs.util; + +import org.apache.commons.lang3.StringUtils; + +import java.io.*; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; +import java.util.regex.Pattern; + +/** + * @description: 校验字符串的工具类 + * @author: ChenJ + * @date: 2022/5/9 17:32 + **/ +public class StringUtil { + /** + * 判断字符串是否为空 + * + * @param str 待判断的字符串 + * @return 空返回true + */ + public static boolean isEmpty(String str) { + // 通过str.trim去掉字符串多余的空格 + return str == null || "".equals(str.trim()); + } + + /** + * 判断是否是合法手机号 + * + * @param phone 被校验的手机号 + * @return 合法true + */ + public static boolean isPhoneNumber(String phone) { + return phone.matches("^1(3\\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\\d|9[0-35-9])\\d{8}$"); + } + + /** + * 判断查询的条件是否为空 + * + * @param s 字符串 + * @return 合法true + */ + public static boolean isBlankOrNull(String s) { + return StringUtils.isBlank(s) && StringUtils.isEmpty(s); + } + + /** + * 1.“@”的左边限制: + * 由a~z的英文字母(不区分大小写)开头 + * 可由英文字母、0~9的数字、点、减号或下划线组成 + * 长度为3~18个字符 + * 不能以点、减号结尾 + * 2.“@”的右边限制: + * 只能有一个点,点和"@"之间不能为空 + * 可由英文字母、0~9的数字、点、减号或下划线组成 + * 不能以点、减号或下划线结尾 + * + * @param email 被校验的手邮箱 + * @return 合法true + */ + public static boolean isEmail(String email) { + return Pattern.matches("^(\\w+([-.][A-Za-z0-9]+)*){3,18}@\\w+([-.][A-Za-z0-9]+)*\\.\\w+([-.][A-Za-z0-9]+)*$", email); + } + + public static boolean isIDNumber(String IDNumber) { + if (IDNumber == null || "".equals(IDNumber)) { + return false; + } + // 定义判别用户身份证号的正则表达式(15位或者18位,最后一位可以为字母) + String regularExpression = "(^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$)|" + + "(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}$)"; + //假设18位身份证号码:41000119910101123X 410001 19910101 123X + //^开头 + //[1-9] 第一位1-9中的一个 4 + //\\d{5} 五位数字 10001(前六位省市县地区) + //(18|19|20) 19(现阶段可能取值范围18xx-20xx年) + //\\d{2} 91(年份) + //((0[1-9])|(10|11|12)) 01(月份) + //(([0-2][1-9])|10|20|30|31)01(日期) + //\\d{3} 三位数字 123(第十七位奇数代表男,偶数代表女) + //[0-9Xx] 0123456789Xx其中的一个 X(第十八位为校验值) + //$结尾 + + //假设15位身份证号码:410001910101123 410001 910101 123 + //^开头 + //[1-9] 第一位1-9中的一个 4 + //\\d{5} 五位数字 10001(前六位省市县地区) + //\\d{2} 91(年份) + //((0[1-9])|(10|11|12)) 01(月份) + //(([0-2][1-9])|10|20|30|31)01(日期) + //\\d{3} 三位数字 123(第十五位奇数代表男,偶数代表女),15位身份证不含X + //$结尾 + boolean matches = IDNumber.matches(regularExpression); + //判断第18位校验值 + int num = 18; + if (matches) { + + if (IDNumber.length() == num) { + try { + char[] charArray = IDNumber.toCharArray(); + //前十七位加权因子 + int[] idCardWi = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2}; + //这是除以11后,可能产生的11位余数对应的验证码 + String[] idCardY = {"1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"}; + int sum = 0; + for (int i = 0; i < idCardWi.length; i++) { + int current = Integer.parseInt(String.valueOf(charArray[i])); + int count = current * idCardWi[i]; + sum += count; + } + char idCardLast = charArray[17]; + int idCardMod = sum % 11; + if (idCardY[idCardMod].toUpperCase().equals(String.valueOf(idCardLast).toUpperCase())) { + return true; + } else { + return false; + } + + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + } + return matches; + } + + + /** + * 把 Thu Dec 14 00:00:00 CST 2017 转换成自己想要的格式 + * + * @param date + * @param pattern 为自己定义的类型如“yyyy-MM-dd” + * @return + */ + public static String dateStringFormat(String date, String pattern) { + if (date == null || pattern == null) { + return null; + } + try { + Date formDate = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US).parse(date); + return new SimpleDateFormat(pattern, Locale.CHINA).format(formDate); + } catch (ParseException e) { + e.printStackTrace(); + } + return null; + } + + /** + * 把 yyyy-MM-dd HH:mm:ss的字符串时间 转换成 date类型 + * + * @param date 时间字符串 + * @return 返回Date类型的时间 + */ + public static Date StringFormatDate(String date) throws ParseException { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return simpleDateFormat.parse(date); + } + + + /** + * 将一个字符串转化为输入流 + * + * @param sInputString 待转化的字符串 + * @return 二进制的流 + */ + public static InputStream getStringStream(String sInputString) { + if (sInputString != null && !"".equals(sInputString.trim())) { + try { + ByteArrayInputStream tInputStringStream = new ByteArrayInputStream(sInputString.getBytes()); + return tInputStringStream; + } catch (Exception ex) { + ex.printStackTrace(); + } + } + return null; + } + + /** + * 将输入流转换成字符串 + * + * @param inputStream 输入流 + * @return 字符串 + */ + public static String inputStreamToString(InputStream inputStream) { + StringBuffer buffer = new StringBuffer(); + InputStreamReader inputStreamReader; + try { + inputStreamReader = new InputStreamReader(inputStream, "utf-8"); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader); + String str = null; + while ((str = bufferedReader.readLine()) != null) { + buffer.append(str); + } + // 释放资源 + bufferedReader.close(); + inputStreamReader.close(); + inputStream.close(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return buffer.toString(); + } + + public static Boolean isNum(String s) { + return Pattern.matches("^[-+]?(([0-9]+)([.]([0-9]+))?|([.]([0-9]+))?)$", s); + } +} diff --git a/pacs/src/main/java/com/xjgs/vo/ArchiveMaster.java b/pacs/src/main/java/com/xjgs/vo/ArchiveMaster.java new file mode 100644 index 0000000..f4f5335 --- /dev/null +++ b/pacs/src/main/java/com/xjgs/vo/ArchiveMaster.java @@ -0,0 +1,219 @@ +package com.xjgs.vo; + + +/** + * 病人基本信息类 + * */ +public class ArchiveMaster { + + private String id; + private String patientId; + private String inpNo; + private String visitId; + private String name; + private String sex; + private String deptName; + private String dischargeDateTime; + private String archiveState; + private String admissionDateTime; + private String deptAdmissionTo; + private String checkDoctor; + private String checkDatetime; + private String checkedDoctor; + private String checkedDatetime; + private String lockInfo; + private String doctorInCharge; + private String idNo; + private String dischargeDisposition; + private String deptCodeLend; + private String status; + private String bedId; + + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id == null ? null:id.trim(); + } + + + public String getPatientId() { + return patientId; + } + + public void setPatientId(String patientId) { + this.patientId = patientId == null ? null : patientId.trim(); + } + + + public String getInpNo() { + return inpNo; + } + + public void setInpNo(String inpNo) { + this.inpNo = inpNo == null ? null : inpNo.trim(); + } + + + public String getVisitId() { + return visitId; + } + + public void setVisitId(String visitId) { + this.visitId = visitId == null ? null : visitId.trim(); + } + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name == null ? null : name.trim(); + } + + + public String getSex() { + return sex; + } + + public void setSex(String sex) { + this.sex = sex == null ? null : sex.trim(); + } + + + public String getDeptName() { + return deptName; + } + + public void setDeptName(String deptName) { + this.deptName = deptName == null ? null : deptName.trim(); + } + + public String getArchiveState() { + return archiveState; + } + + public void setArchiveState(String archiveState) { + this.archiveState = archiveState == null ? null : archiveState.trim(); + } + + public String getDeptAdmissionTo() { + return deptAdmissionTo; + } + + public void setDeptAdmissionTo(String deptAdmissionTo) { + this.deptAdmissionTo = deptAdmissionTo == null ? null : deptAdmissionTo.trim(); + } + + + public String getCheckDoctor() { + return checkDoctor; + } + + public void setCheckDoctor(String checkDoctor) { + this.checkDoctor = checkDoctor == null ? null : checkDoctor.trim(); + } + + public String getCheckedDoctor() { + return checkedDoctor; + } + + public void setCheckedDoctor(String checkedDoctor) { + this.checkedDoctor = checkedDoctor == null ? null : checkedDoctor.trim(); + } + + public String getLockInfo() { + return lockInfo; + } + + public void setLockInfo(String lockInfo) { + this.lockInfo = lockInfo == null ? null : lockInfo.trim(); + } + + + public String getDoctorInCharge() { + return doctorInCharge; + } + + public void setDoctorInCharge(String doctorInCharge) { + this.doctorInCharge = doctorInCharge == null ? null : doctorInCharge.trim(); + } + + + public String getIdNo() { + return idNo; + } + + public void setIdNo(String idNo) { + this.idNo = idNo == null ? null : idNo.trim(); + } + + + public String getDischargeDisposition() { + return dischargeDisposition; + } + + public void setDischargeDisposition(String dischargeDisposition) { + this.dischargeDisposition = dischargeDisposition == null ? null : dischargeDisposition.trim(); + } + + + public String getDeptCodeLend() { + return deptCodeLend; + } + + public void setDeptCodeLend(String deptCodeLend) { + this.deptCodeLend = deptCodeLend == null ? null : deptCodeLend.trim(); + } + + public String getDischargeDateTime() { + return dischargeDateTime; + } + + public void setDischargeDateTime(String dischargeDateTime) { + this.dischargeDateTime = dischargeDateTime == null ? null:dischargeDateTime.trim(); + } + + public String getAdmissionDateTime() { + return admissionDateTime; + } + + public void setAdmissionDateTime(String admissionDateTime) { + this.admissionDateTime = admissionDateTime == null ? null : admissionDateTime.trim(); + } + + public String getCheckDatetime() { + return checkDatetime; + } + + public void setCheckDatetime(String checkDatetime) { + this.checkDatetime = checkDatetime == null ? null : checkDatetime.trim(); + } + + public String getCheckedDatetime() { + return checkedDatetime; + } + + public void setCheckedDatetime(String checkedDatetime) { + this.checkedDatetime = checkedDatetime == null ? null : checkedDatetime.trim(); + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status == null ? null :status.trim(); + } + + public String getBedId() { + return bedId; + } + + public void setBedId(String bedId) { + this.bedId = bedId == null ? null : bedId.trim (); + } +} diff --git a/pacs/src/main/java/com/xjgs/vo/Archive_Detail.java b/pacs/src/main/java/com/xjgs/vo/Archive_Detail.java new file mode 100644 index 0000000..1188459 --- /dev/null +++ b/pacs/src/main/java/com/xjgs/vo/Archive_Detail.java @@ -0,0 +1,112 @@ +package com.xjgs.vo; + +import java.util.Date; + +/** + * 病历文件类 + * */ +public class Archive_Detail { + private String id; + private String pdfPath; + private String masterId; + private Date uploadDateTime; + private String assortId; + private String source; + private String subAssort; + private String title; + private String flag; + private String sys; + public Archive_Detail(){} + public Archive_Detail(String id, String pdfPath, String masterId, Date uploadDateTime, String assortId, String source, String subAssort, String title, String flag, String sys) { + this.id = id; + this.pdfPath = pdfPath; + this.masterId = masterId; + this.uploadDateTime = uploadDateTime; + this.assortId = assortId; + this.source = source; + this.subAssort = subAssort; + this.title = title; + this.flag = flag; + this.sys = sys; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id == null ? null : id.trim(); + } + + public String getPdfPath() { + return pdfPath; + } + + public void setPdfPath(String pdfPath) { + this.pdfPath = pdfPath == null ? null : pdfPath.trim(); + } + + public String getMasterId() { + return masterId; + } + + public void setMasterId(String masterId) { + this.masterId = masterId == null ? null : masterId.trim(); + } + + public String getAssortId() { + return assortId; + } + + public void setAssortId(String assortId) { + this.assortId = assortId == null ? null : assortId.trim(); + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source == null ? null : source.trim(); + } + + public String getSubAssort() { + return subAssort; + } + + public void setSubAssort(String subAssort) { + this.subAssort = subAssort == null ? null : subAssort.trim(); + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title == null ? null : title.trim(); + } + + public String getFlag() { + return flag; + } + + public void setFlag(String flag) { + this.flag = flag == null ? null : flag.trim(); + } + + public String getSys() { + return sys; + } + + public void setSys(String sys) { + this.sys = sys == null ? null : sys.trim(); + } + + public Date getUploadDateTime() { + return uploadDateTime; + } + + public void setUploadDateTime(Date uploadDateTime) { + this.uploadDateTime = uploadDateTime; + } +} diff --git a/pacs/src/main/java/com/xjgs/vo/Fangshe.java b/pacs/src/main/java/com/xjgs/vo/Fangshe.java new file mode 100644 index 0000000..29a6563 --- /dev/null +++ b/pacs/src/main/java/com/xjgs/vo/Fangshe.java @@ -0,0 +1,225 @@ +package com.xjgs.vo; + +/** + * pacs 报告类 + * */ +public class Fangshe { + private String ACCESSIONNUMBER; + /** 路径 */ + private String path; + /** 类型 */ + private String prof; + private String source_id; + /** 姓名 */ + private String FIRSTNAME; + /** 性别 */ + private String PATIENTSEX; + /** 年龄 */ + private String PATIENTAGE; + /** 检查号 */ + private String PATIENT_ID; + /** 申请科室 */ + private String REQUESTINGDEPARTMENT; + /** 床号 */ + private String BEDID; + /** 住院 号 */ + private String INPATIENT_ID; + /** 门诊号 */ + private String CLINICAL_ID; + /** 检查部位 */ + private String REQUESTEDPROCEDUREDESCRIPTION; + /** 检查所见 */ + private String EXAMINEDESCRIPTION; + /** 诊断提示 */ + private String DIAGNOSISPROMPT; + /** 检查日期 */ + private String EXAMINEDATE; + /** 报告日期 */ + private String REPORTDATE; + /** 报告医生 */ + private String REPORTDOCTOR; + /** 审核日期 */ + private String AUDITINGDATE; + /** 审核医生 */ + private String AUDITINGDOCTOR; + public Fangshe(){ + } + public Fangshe(String FIRSTNAME, String PATIENTSEX, String PATIENTAGE, String PATIENT_ID, String REQUESTINGDEPARTMENT, String BEDID, String INPATIENT_ID, String CLINICAL_ID, String REQUESTEDPROCEDUREDESCRIPTION, String EXAMINEDESCRIPTION, String DIAGNOSISPROMPT, String EXAMINEDATE, String REPORTDATE, String REPORTDOCTOR, String AUDITINGDATE, String AUDITINGDOCTOR) { + this.FIRSTNAME = FIRSTNAME; + this.PATIENTSEX = PATIENTSEX; + this.PATIENTAGE = PATIENTAGE; + this.PATIENT_ID = PATIENT_ID; + this.REQUESTINGDEPARTMENT = REQUESTINGDEPARTMENT; + this.BEDID = BEDID; + this.INPATIENT_ID = INPATIENT_ID; + this.CLINICAL_ID = CLINICAL_ID; + this.REQUESTEDPROCEDUREDESCRIPTION = REQUESTEDPROCEDUREDESCRIPTION; + this.EXAMINEDESCRIPTION = EXAMINEDESCRIPTION; + this.DIAGNOSISPROMPT = DIAGNOSISPROMPT; + this.EXAMINEDATE = EXAMINEDATE; + this.REPORTDATE = REPORTDATE; + this.REPORTDOCTOR = REPORTDOCTOR; + this.AUDITINGDATE = AUDITINGDATE; + this.AUDITINGDOCTOR = AUDITINGDOCTOR; + } + + public String getFIRSTNAME() { + return FIRSTNAME; + } + + public void setFIRSTNAME(String FIRSTNAME) { + this.FIRSTNAME = FIRSTNAME == null? " ":FIRSTNAME.trim(); + } + + public String getPATIENTSEX() { + return PATIENTSEX; + } + + public void setPATIENTSEX(String PATIENTSEX) { + this.PATIENTSEX = PATIENTSEX == null?" ":PATIENTSEX.trim(); + } + + public String getPATIENTAGE() { + return PATIENTAGE; + } + + public void setPATIENTAGE(String PATIENTAGE) { + this.PATIENTAGE = PATIENTAGE == null?" ":PATIENTAGE.trim(); + } + + public String getPATIENT_ID() { + return PATIENT_ID; + } + + public void setPATIENT_ID(String PATIENT_ID) { + this.PATIENT_ID = PATIENT_ID == null?" ":PATIENT_ID.trim(); + } + + public String getREQUESTINGDEPARTMENT() { + return REQUESTINGDEPARTMENT; + } + + public void setREQUESTINGDEPARTMENT(String REQUESTINGDEPARTMENT) { + this.REQUESTINGDEPARTMENT = REQUESTINGDEPARTMENT == null?" ":REQUESTINGDEPARTMENT.trim(); + } + + public String getBEDID() { + return BEDID; + } + + public void setBEDID(String BEDID) { + this.BEDID = BEDID == null?" ":BEDID.trim(); + } + + public String getINPATIENT_ID() { + return INPATIENT_ID; + } + + public void setINPATIENT_ID(String INPATIENT_ID) { + this.INPATIENT_ID = INPATIENT_ID == null?"": INPATIENT_ID.trim(); + } + + public String getCLINICAL_ID() { + return CLINICAL_ID; + } + + public void setCLINICAL_ID(String CLINICAL_ID) { + this.CLINICAL_ID = CLINICAL_ID == null ? " " :CLINICAL_ID.trim(); + } + + public String getREQUESTEDPROCEDUREDESCRIPTION() { + return REQUESTEDPROCEDUREDESCRIPTION; + } + + public void setREQUESTEDPROCEDUREDESCRIPTION(String REQUESTEDPROCEDUREDESCRIPTION) { + this.REQUESTEDPROCEDUREDESCRIPTION = REQUESTEDPROCEDUREDESCRIPTION == null ? " ":REQUESTEDPROCEDUREDESCRIPTION.trim(); + } + + public String getEXAMINEDESCRIPTION() { + return EXAMINEDESCRIPTION; + } + + public void setEXAMINEDESCRIPTION(String EXAMINEDESCRIPTION) { + this.EXAMINEDESCRIPTION =EXAMINEDESCRIPTION == null? " ":EXAMINEDESCRIPTION; + } + + public String getDIAGNOSISPROMPT() { + return DIAGNOSISPROMPT; + } + + public void setDIAGNOSISPROMPT(String DIAGNOSISPROMPT) { + this.DIAGNOSISPROMPT = DIAGNOSISPROMPT== null? " ":DIAGNOSISPROMPT; + } + + public String getEXAMINEDATE() { + return EXAMINEDATE; + } + + public void setEXAMINEDATE(String EXAMINEDATE) { + this.EXAMINEDATE = EXAMINEDATE == null ? " " :EXAMINEDATE.trim(); + } + + public String getREPORTDATE() { + return REPORTDATE; + } + + public void setREPORTDATE(String REPORTDATE) { + this.REPORTDATE = REPORTDATE == null ? " ":REPORTDATE.trim(); + } + + public String getREPORTDOCTOR() { + return REPORTDOCTOR; + } + + public void setREPORTDOCTOR(String REPORTDOCTOR) { + this.REPORTDOCTOR = REPORTDOCTOR == null ? " ":REPORTDOCTOR.trim(); + } + + public String getAUDITINGDATE() { + return AUDITINGDATE; + } + + public void setAUDITINGDATE(String AUDITINGDATE) { + this.AUDITINGDATE = AUDITINGDATE == null ? " ":AUDITINGDATE.trim(); + } + + public String getAUDITINGDOCTOR() { + return AUDITINGDOCTOR; + } + + public void setAUDITINGDOCTOR(String AUDITINGDOCTOR) { + this.AUDITINGDOCTOR = AUDITINGDOCTOR == null ? " ":AUDITINGDOCTOR.trim(); + } + + public String getSource_id() { + return source_id; + } + + public void setSource_id(String source_id) { + this.source_id = source_id == null ? "" : source_id.trim(); + } + + public String getProf() { + return prof; + } + + public void setProf(String prof) { + this.prof = prof; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getACCESSIONNUMBER() { + return ACCESSIONNUMBER; + } + + public void setACCESSIONNUMBER(String ACCESSIONNUMBER) { + this.ACCESSIONNUMBER = ACCESSIONNUMBER.trim(); + } +} diff --git a/pacs/src/main/java/com/xjgs/vo/PacsVo.java b/pacs/src/main/java/com/xjgs/vo/PacsVo.java new file mode 100644 index 0000000..39b8f0b --- /dev/null +++ b/pacs/src/main/java/com/xjgs/vo/PacsVo.java @@ -0,0 +1,100 @@ +package com.xjgs.vo; + +import org.springframework.beans.factory.annotation.Autowired; + +/** + * @ClassName PacsVo + * @Description 查询pacs路径实体 + * @Author linjj + * @Date 2023/8/3 10:59 + * @Version 1.0 + */ + +public class PacsVo { + + private String PATIENTID; + + /**文件标题 + */ + private String REQUESTEDPROCEDUREDESCRIPTION; + + private String ACCESSIONNUMBER; + + private String STUDYUID; + + private String REPORTDATE; + + private String SOURCEID; + + /**文件路径 + */ + private String DCMFile; + + /**文件名 + */ + private String DCMName; + + public String getPATIENTID() { + return PATIENTID; + } + + public void setPATIENTID(String PATIENTID) { + this.PATIENTID = PATIENTID; + } + + public String getREQUESTEDPROCEDUREDESCRIPTION() { + return REQUESTEDPROCEDUREDESCRIPTION; + } + + public void setREQUESTEDPROCEDUREDESCRIPTION(String REQUESTEDPROCEDUREDESCRIPTION) { + this.REQUESTEDPROCEDUREDESCRIPTION = REQUESTEDPROCEDUREDESCRIPTION; + } + + public String getACCESSIONNUMBER() { + return ACCESSIONNUMBER; + } + + public void setACCESSIONNUMBER(String ACCESSIONNUMBER) { + this.ACCESSIONNUMBER = ACCESSIONNUMBER; + } + + public String getSTUDYUID() { + return STUDYUID; + } + + public void setSTUDYUID(String STUDYUID) { + this.STUDYUID = STUDYUID; + } + + public String getREPORTDATE() { + return REPORTDATE; + } + + public void setREPORTDATE(String REPORTDATE) { + this.REPORTDATE = REPORTDATE; + } + + public String getSOURCEID() { + return SOURCEID; + } + + public void setSOURCEID(String SOURCEID) { + this.SOURCEID = SOURCEID; + } + + public String getDCMFile() { + return DCMFile; + } + + public void setDCMFile(String DCMFile) { + this.DCMFile = DCMFile; + } + + public String getDCMName() { + return DCMName; + } + + public void setDCMName(String DCMName) { + this.DCMName = DCMName; + } +} diff --git a/pacs/src/main/java/com/xjgs/vo/Ris_Study.java b/pacs/src/main/java/com/xjgs/vo/Ris_Study.java new file mode 100644 index 0000000..cbcb9e7 --- /dev/null +++ b/pacs/src/main/java/com/xjgs/vo/Ris_Study.java @@ -0,0 +1,99 @@ +package com.xjgs.vo; + + +/** + * 超声报告类 + * */ +public class Ris_Study { + private String record_name; + private String source_id; + private String uuid; + private String reportdate; + private String patientId; + private String inpatientId; + private String firstname; + private String ACCESSIONNUMBER; + + public String getInpatientId() { + return inpatientId; + } + + public void setInpatientId(String inpatientId) { + this.inpatientId = inpatientId; + } + + private String Examinedate; + private String path; + + public String getReportdate() { + return reportdate; + } + + public void setReportdate(String reportdate) { + this.reportdate = reportdate; + } + + public String getPatientId() { + return patientId; + } + + public void setPatientId(String patientId) { + this.patientId = patientId; + } + + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getExaminedate() { + return Examinedate; + } + + public void setExaminedate(String examinedate) { + Examinedate = examinedate; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getSource_id() { + return source_id; + } + + public void setSource_id(String source_id) { + this.source_id = source_id == null ? "" : source_id.trim(); + } + + public String getRecord_name() { + return record_name; + } + + public void setRecord_name(String record_name) { + this.record_name = record_name; + } + + public String getACCESSIONNUMBER() { + return ACCESSIONNUMBER; + } + + public void setACCESSIONNUMBER(String ACCESSIONNUMBER) { + this.ACCESSIONNUMBER = ACCESSIONNUMBER == null ? "" : ACCESSIONNUMBER.trim(); + } +} diff --git a/pacs/src/main/java/com/xjgs/vo/User.java b/pacs/src/main/java/com/xjgs/vo/User.java new file mode 100644 index 0000000..5b19295 --- /dev/null +++ b/pacs/src/main/java/com/xjgs/vo/User.java @@ -0,0 +1,61 @@ +package com.xjgs.vo; + +/** + * 权限系统用户表 + * */ +public class User { + private String id; + private String code; + private String name; + private String password; + private String createDate; + private String departmentId; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getCreateDate() { + return createDate; + } + + public void setCreateDate(String createDate) { + this.createDate = createDate; + } + + public String getDepartmentId() { + return departmentId; + } + + public void setDepartmentId(String departmentId) { + this.departmentId = departmentId; + } +} diff --git a/pacs/src/main/resources/application.yml b/pacs/src/main/resources/application.yml new file mode 100644 index 0000000..3c32e9d --- /dev/null +++ b/pacs/src/main/resources/application.yml @@ -0,0 +1,43 @@ +server: + port: 8023 + #数据库 +spring: + datasource: +# db1: # 数据源1 +# jdbc-url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=gm_record +# username: sa +# password: admin123 +# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver +# db2: # 数据源2 +# jdbc-url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=qf_record +# username: sa +# password: admin123 +# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver + db1: # 数据源1 + jdbc-url: jdbc:sqlserver://10.36.116.108:1433;DatabaseName=emr_record + username: sa + password: xjgs+docus911 + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver + db2: # 数据源2 + jdbc-url: jdbc:sqlserver://10.36.116.100:1433;DatabaseName=pacsdb + username: BLGD + password: Blgd_123 + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver + jpa: + hibernate: + dialect: org.hibernate.dialect.SQLServer2008Dialect + hikari: + #是否为只读数据库 + read-only: false + # 等待连接池分配链接的最大时长 + connection-timeout: 60000 + # 一个链接idle状态最大时长 + idle-timeout: 60000 + validation-timeout: 3000 + # 一个链接最长的生命时长,超时没有被使用则被释放掉 简易比数据库超时时长少 30s + max-lifetime: 70000 + login-timeout: 5 + # 连接池允许的最大连接数 + maximum-pool-size: 60 + # 连接池维护的最小空闲连接数 + minimum-idle: 10 \ No newline at end of file diff --git a/pacs/src/main/resources/c3p0-config.xml b/pacs/src/main/resources/c3p0-config.xml new file mode 100644 index 0000000..263b28b --- /dev/null +++ b/pacs/src/main/resources/c3p0-config.xml @@ -0,0 +1,44 @@ + + + + + 10 + 0 + 60 + 10 + 200 + + + + oracle.jdbc.driver.OracleDriver + jdbc:oracle:thin:@192.168.10.6:1521/orc1 + pacs + pacs + + + + com.microsoft.sqlserver.jdbc.SQLServerDriver + jdbc:sqlserver://10.36.116.108:1433;databaseName=emr_record + sa + xjgs+docus911 + + + + com.microsoft.sqlserver.jdbc.SQLServerDriver + jdbc:sqlserver://10.36.116.100:1433;databaseName=pacsdb + BLGD + Blgd_123 + + + + com.mysql.jdbc.Driver + jdbc:mysql://10.36.116.108:3306/power?useUnicode=true&characterEncoding=utf-8&useSSL=false&autoReconnect=true&failOverReadOnly=false + root + docus@702 + 5 + 0 + 30 + 5 + 200 + + \ No newline at end of file diff --git a/pacs/src/main/resources/localPath.xml b/pacs/src/main/resources/localPath.xml new file mode 100644 index 0000000..7c1e083 --- /dev/null +++ b/pacs/src/main/resources/localPath.xml @@ -0,0 +1,5 @@ + + + f:\pdf + D:\JSWorking\SignedPictures\ + diff --git a/pacs/src/main/resources/log4j.properties b/pacs/src/main/resources/log4j.properties new file mode 100644 index 0000000..bb2c197 --- /dev/null +++ b/pacs/src/main/resources/log4j.properties @@ -0,0 +1,18 @@ +#设置日志的级别,定义日志信息的输出目的 +log4j.rootLogger=DEBUG, CA ,RFA +#定义CA的输出目的地为控制台 +log4j.appender.CA=org.apache.log4j.ConsoleAppender +#布局为 PatternLayout 可以灵活地指定布局模式。 +log4j.appender.CA.layout=org.apache.log4j.PatternLayout +#设置输出格式 +log4j.appender.CA.layout.ConversionPattern=%-d{yyyy-MM-dd HH\:mm\:ss} [%c]-[%p] %m%n +#定义R的输出目的地为文件,并且文件大小到达指定尺寸的时候产生一个新的文件 +log4j.appender.RFA=org.apache.log4j.RollingFileAppender +#设置输出的文件地址 +log4j.appender.RFA.File=${log.base}\\info.log +#设置文件大小为100 kb 文件到达100时,产生一个新文件, +#MaxBackupIndex 最大记录的文件数为1 超过删除较早的。 +log4j.appender.RFA.MaxFileSize=30720KB log4j.appender.RFA.MaxBackupIndex=1 +#以下和上面一样 +log4j.appender.RFA.layout=org.apache.log4j.PatternLayout +log4j.appender.RFA.layout.ConversionPattern=%p %t %c - %m%n \ No newline at end of file diff --git a/pacs/src/main/resources/mapper/Archive_DetailMapper.xml b/pacs/src/main/resources/mapper/Archive_DetailMapper.xml new file mode 100644 index 0000000..21acd13 --- /dev/null +++ b/pacs/src/main/resources/mapper/Archive_DetailMapper.xml @@ -0,0 +1,15 @@ + + + + + + + + + \ No newline at end of file diff --git a/pacs/src/main/resources/mapper2/PacsMapper.xml b/pacs/src/main/resources/mapper2/PacsMapper.xml new file mode 100644 index 0000000..76d0575 --- /dev/null +++ b/pacs/src/main/resources/mapper2/PacsMapper.xml @@ -0,0 +1,34 @@ + + + + + + + \ No newline at end of file diff --git a/pacs/src/main/resources/mybatis-config.xml b/pacs/src/main/resources/mybatis-config.xml new file mode 100644 index 0000000..d3db7d2 --- /dev/null +++ b/pacs/src/main/resources/mybatis-config.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file