程序包 com.midi.his.sdk

类 HisClient

java.lang.Object
com.midi.his.sdk.HisClient
所有已实现的接口:
AutoCloseable

public final class HisClient extends Object implements AutoCloseable
医惠集成平台(HIP/ESB)HIS 接口客户端,SDK 的唯一入口。

构建:地址与密钥来自外部配置,不在代码里硬编码。


 // 1) 从 classpath 的 his-sdk.properties 装载
 HisClient client = HisClient.builder()
         .config("his-sdk.properties")
         .build();

 // 2) 由 Spring 等手段注入 Properties
 Properties props = ...;
 HisClient client = HisClient.builder().config(props).build();

 // 3) 装载后再覆盖个别项
 HisClient client = HisClient.builder()
         .config(HisConfig.builder()
                 .queryEndpoints("http://10.1.69.28/Ewell_WS_SUU", "http://10.1.69.29/Ewell_WS_SUU")
                 .pushEndpoints("http://10.1.69.28/Ewell_WS_PUU")
                 .userName("SUU")
                 .password(System.getenv("HIS_PASSWORD"))
                 .sourceSysCode("SUU")
                 .queryTargetSysCode("S00")
                 .pushTargetSysCode("S02")
                 .hospCode("GH01")
                 .build())
         .build();
 

用法:


 QueryResult<Department> depts = client.query().departments(
         QuerySpec.create().eq("INVALID_FLAG", "0").orderBy("DEPT_CODE", SortOrder.ASC));
 for (Department d : depts.data()) {
     log.info("{} {}", d.getDeptCode(), d.getDeptName());
 }

 ExamReport report = new ExamReport();
 report.setReportNo("R202606030001");
 // ... 其余必填字段见 HisClient 文档与 README
 PushResult result = client.push().examReport(PushRecord.insert(report.getReportNo(), report));
 

线程安全:实例构造完成后全部字段不可变,底层 OkHttpClient 自带连接池, 可以在多线程间共享同一个 HisClient;建议整个应用共用一个实例并在退出时 close()。QuerySpec 是每调用创建的可变对象,不要跨线程复用。

失败语义:超时与连接类故障按 his.retry.* 自动重试;重试只覆盖 "业务结果未知"的情况,平台已返回业务码时不再重发。推送重试可能造成重复投递, 消费方需按 Msg/@id 幂等。

  • 方法详细资料

    • create

      public static HisClient create(HisConfig config)
      用给定配置快速创建客户端(自建 HTTP 客户端)。
      参数:
      config - 运行配置
      返回:
      客户端
    • create

      public static HisClient create(Properties properties)
      用 Properties 快速创建客户端。
      参数:
      properties - his.* 配置
      返回:
      客户端
    • createFrom

      public static HisClient createFrom(String resourceOrFile)
      从 classpath 资源或磁盘文件创建客户端。
      参数:
      resourceOrFile - 资源名或文件路径;传 null 使用 his-sdk.properties
      返回:
      客户端
    • builder

      public static HisClient.Builder builder()
      返回:
      新的构建器
    • query

      public QueryServiceApi query()
      查询接口(消费侧)。
      返回:
      科室、病区、职工、检查申请单查询
    • push

      public PushServiceApi push()
      推送接口(提供侧)。
      返回:
      PACS 报告推送与检查执行状态回写
    • config

      public HisConfig config()
      返回:
      生效的配置,密码在 toString 中已掩码
    • httpClient

      public okhttp3.OkHttpClient httpClient()
      返回:
      使用的 HTTP 客户端,可用于指标采集或共享给其它组件
    • close

      public void close()
      释放本客户端自建的连接池与线程;传入外部 OkHttpClient 时不会关闭它。
      指定者:
      close 在接口中 AutoCloseable
    • closeAndWait

      public void closeAndWait(long timeoutMillis) throws InterruptedException
      等待正在执行的调用结束并关闭客户端,适合在应用停机钩子里调用。
      参数:
      timeoutMillis - 最长等待时间
      抛出:
      InterruptedException - 等待被打断