Browse Source

血清送检申请单区域列表和检测指标列表

陈长荣 2 weeks ago
parent
commit
07b52d6a3b

+ 4 - 0
jfcloud-gene-biz/pom.xml

@@ -34,6 +34,10 @@
       <groupId>com.baomidou</groupId>
       <artifactId>mybatis-plus-extension</artifactId>
     </dependency>
+    <dependency>
+      <groupId>com.microsoft.sqlserver</groupId>
+      <artifactId>mssql-jdbc</artifactId>
+    </dependency>
 
     <dependency>
       <groupId>com.github.jfcloud</groupId>

+ 31 - 0
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/lis/config/LisDb.java

@@ -0,0 +1,31 @@
+package com.github.jfcloud.gene.lis.config;
+
+import cn.hutool.db.Db;
+import cn.hutool.db.ds.simple.SimpleDataSource;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+@Slf4j
+@Component
+public class LisDb {
+
+    @Value("${lis.enable:false}")
+    private boolean enable;
+
+    private SimpleDataSource dataSource;
+
+    public LisDb(LisDbProperty lisDbProperty) {
+        if (lisDbProperty == null) {
+            return;
+        }
+        dataSource = new SimpleDataSource(lisDbProperty.getUrl(), lisDbProperty.getUsername(), lisDbProperty.getPassword());
+    }
+
+    public Db getDb() {
+        if (dataSource == null) {
+            throw new RuntimeException("LIS数据库未配置");
+        }
+        return Db.use(dataSource);
+    }
+}

+ 18 - 0
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/lis/config/LisDbProperty.java

@@ -0,0 +1,18 @@
+package com.github.jfcloud.gene.lis.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties(prefix = "lis.datasource")
+@Data
+public class LisDbProperty {
+
+    private String url;
+
+    private String username;
+
+    private String password;
+
+}

+ 19 - 0
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/lis/vo/AreaItem.java

@@ -0,0 +1,19 @@
+package com.github.jfcloud.gene.lis.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Schema(description = "检验项目")
+@Data
+public class AreaItem {
+
+    @Schema(description = "id")
+    private Long id;
+
+    @Schema(description = "名称")
+    private String name;
+
+    @Schema(description = "地址")
+    private String address;
+
+}

+ 21 - 0
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/lis/vo/DictItem.java

@@ -0,0 +1,21 @@
+package com.github.jfcloud.gene.lis.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Schema(description = "检验项目")
+@Data
+public class DictItem {
+
+    @Schema(description = "id")
+    private Long id;
+
+    @Schema(description = "名称")
+    private String name;
+
+    @Schema(description = "英文名称")
+    private String engName;
+
+    @Schema(description = "单位")
+    private String unit;
+}

+ 64 - 0
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/sample/controller/SampleCheckItemSerumController.java

@@ -0,0 +1,64 @@
+package com.github.jfcloud.gene.sample.controller;
+
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.db.Entity;
+import com.github.jfcloud.common.core.util.R;
+import com.github.jfcloud.gene.lis.config.LisDb;
+import com.github.jfcloud.gene.lis.vo.AreaItem;
+import com.github.jfcloud.gene.lis.vo.DictItem;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Tag(name = "样本送检申请单-血清")
+@RestController
+@RequestMapping("/sample/check/item/serum")
+@RequiredArgsConstructor
+public class SampleCheckItemSerumController {
+
+    private final LisDb lisDb;
+
+    @SneakyThrows
+    @Operation(summary = "获取检测指标")
+    @GetMapping("/target")
+    public R<List<DictItem>> getCheckItemTarget(@RequestParam(required = false) String name) {
+        String sql = "select id, name, eng_name, unit from dbo.HT_DICT_ITEM where status=1 and type=0 %s order by id desc";
+        if (StrUtil.isNotBlank(name)) {
+            sql = String.format(sql, "and name like '%" + name + "%'");
+        } else {
+            sql = String.format(sql, "");
+        }
+        List<Entity> entities = lisDb.getDb().query(sql);
+        List<DictItem> dictItems = entities.stream()
+                .map(entity -> entity.toBeanWithCamelCase(new DictItem()))
+                .collect(Collectors.toList());
+        return R.ok(dictItems);
+    }
+
+    @SneakyThrows
+    @Operation(summary = "获取区域")
+    @GetMapping("/area")
+    public R<List<AreaItem>> getCheckItemArea(@RequestParam(required = false) String name) {
+        String sql = "select id, name, address from dbo.HT_INFO_HSP where status=1 %s order by id desc";
+        if (StrUtil.isNotBlank(name)) {
+            sql = String.format(sql, "and name like '%" + name + "%'");
+        } else {
+            sql = String.format(sql, "");
+        }
+        List<Entity> entities = lisDb.getDb().query(sql);
+        List<AreaItem> dictItems = entities.stream()
+                .map(entity -> entity.toBeanWithCamelCase(new AreaItem()))
+                .collect(Collectors.toList());
+        return R.ok(dictItems);
+    }
+}