|
@@ -1,14 +1,23 @@
|
|
|
package com.lantone.qc.kernel;
|
|
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.lantone.qc.trans.util.http.db.DBUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
+import java.io.*;
|
|
|
import java.sql.Connection;
|
|
|
import java.sql.ResultSet;
|
|
|
import java.sql.SQLException;
|
|
|
import java.sql.Statement;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
+import org.apache.poi.hpsf.DocumentSummaryInformation;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
+import org.apache.poi.ss.usermodel.Cell;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
+
|
|
|
@Slf4j
|
|
|
public class tzdiagnosisTest {
|
|
|
|
|
@@ -60,7 +69,72 @@ public class tzdiagnosisTest {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- ReplaceSensitivity(map);
|
|
|
+ for (String diag : diagLists) {
|
|
|
+ String path = "D:/单诊断分类/1000.txt";
|
|
|
+ List<String> caseList = readFile(path);
|
|
|
+ if (caseList.contains(diag)) {
|
|
|
+ System.out.println(diag + "\n");
|
|
|
+ ReplaceSen(diag);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+// ReplaceSensitivity(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void ReplaceSen(String diag) {
|
|
|
+ Connection conn = null;
|
|
|
+ Statement stmt = null;
|
|
|
+ ResultSet rs = null;
|
|
|
+ try {
|
|
|
+ conn = DBUtil.getConnection();
|
|
|
+ stmt = conn.createStatement();
|
|
|
+ rs = stmt.executeQuery("SELECT * FROM str_admission_note WHERE diagnosis='" + diag + "'");
|
|
|
+ Map<String, List<String>> diagnosisMap = new HashMap<>();
|
|
|
+ while (rs.next()) {
|
|
|
+ List<String> diagnosisList = new ArrayList<>();
|
|
|
+ int num = 0;
|
|
|
+ for (int i = 1; i < 23; i++) {
|
|
|
+ diagnosisList.add(rs.getString(i));
|
|
|
+ }
|
|
|
+ if (diagnosisMap.containsKey(rs.getString(1))) {
|
|
|
+ String strNum = rs.getString(1) + "_" + num++;
|
|
|
+ diagnosisMap.put(strNum, diagnosisList);
|
|
|
+ } else {
|
|
|
+ diagnosisMap.put(rs.getString(1), diagnosisList);
|
|
|
+ }
|
|
|
+
|
|
|
+// String medRecordNum = rs.getString(1);
|
|
|
+// System.out.println(
|
|
|
+// medRecordNum + "\t" + rs.getString(2) + "\t" + rs.getString(2) + "\t"
|
|
|
+// + rs.getString(3) + "\t" + rs.getString(4) + "\t" + rs.getString(5) + "\t"
|
|
|
+// + rs.getString(6) + "\t" + rs.getString(7) + "\t" + rs.getString(8) + "\t"
|
|
|
+// + rs.getString(9) + "\t" + rs.getString(10) + "\t" + rs.getString(11) + "\t"
|
|
|
+// + rs.getString(12) + "\t" + rs.getString(13) + "\t" + rs.getString(14) + "\t"
|
|
|
+// + rs.getString(15) + "\t" + rs.getString(16) + "\t" + rs.getString(17) + "\t"
|
|
|
+// + rs.getString(18) + "\t" + rs.getString(19) + "\t" + rs.getString(20) + "\t"
|
|
|
+// + rs.getString(21) + "\t" + rs.getString(22));
|
|
|
+ }
|
|
|
+ str(diagnosisMap, diag);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (rs != null) {
|
|
|
+ rs.close();
|
|
|
+ rs = null;
|
|
|
+ }
|
|
|
+ if (stmt != null) {
|
|
|
+ stmt.close();
|
|
|
+ stmt = null;
|
|
|
+ }
|
|
|
+ if (conn != null) {
|
|
|
+ conn.close();
|
|
|
+ conn = null;
|
|
|
+ }
|
|
|
+ } catch (SQLException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private static void ReplaceSensitivity(Map<String, String> map) {
|
|
@@ -106,4 +180,84 @@ public class tzdiagnosisTest {
|
|
|
return diagnosisList;
|
|
|
}
|
|
|
|
|
|
+ public static void str(Map<String, List<String>> diagnosisMap, String diag) throws Exception {
|
|
|
+ //创建HSSFWorkbook工作薄对象
|
|
|
+ HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
+ //创建HSSFSheet对象
|
|
|
+ HSSFSheet sheet = workbook.createSheet("sheet1");
|
|
|
+ int rowIndex = 0, columnIndex = 0;
|
|
|
+ //表头
|
|
|
+ Row row = sheet.createRow(rowIndex++);
|
|
|
+ List<String> keys = Lists.newArrayList("behospital_code",
|
|
|
+ "sex",
|
|
|
+ "age",
|
|
|
+ "chief",
|
|
|
+ "present",
|
|
|
+ "past_history",
|
|
|
+ "personal_history",
|
|
|
+ "menstrual_history",
|
|
|
+ "marital_history",
|
|
|
+ "family_history",
|
|
|
+ "physique_exam",
|
|
|
+ "spirit_exam",
|
|
|
+ "diagnosis",
|
|
|
+ "dispose",
|
|
|
+ "announcements",
|
|
|
+ "western",
|
|
|
+ "examine",
|
|
|
+ "vulva",
|
|
|
+ "vagina",
|
|
|
+ "cervix",
|
|
|
+ "uterus",
|
|
|
+ "accessories");
|
|
|
+ for (int i = 0; i < keys.size(); i++) {
|
|
|
+ Cell cel = row.createCell(columnIndex++);
|
|
|
+ cel.setCellValue(keys.get(i));
|
|
|
+ }
|
|
|
+
|
|
|
+ //内容for (Map.Entry<Character, CHNCharacter> entry : words.entrySet()) {
|
|
|
+ if (diagnosisMap != null && !diagnosisMap.isEmpty()) {
|
|
|
+ for (Map.Entry<String, List<String>> dataList : diagnosisMap.entrySet()) {
|
|
|
+ row = sheet.createRow(rowIndex++);
|
|
|
+ for (int j = 0; j < dataList.getValue().size(); j++) {
|
|
|
+ for (int i = 0; i < keys.size(); i++) {
|
|
|
+ Cell cell = row.createCell(i);
|
|
|
+ cell.setCellValue(dataList.getValue().get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //创建文档信息
|
|
|
+ workbook.createInformationProperties();
|
|
|
+ //获取DocumentSummaryInformation对象
|
|
|
+ DocumentSummaryInformation documentSummaryInformation = workbook.getDocumentSummaryInformation();
|
|
|
+ documentSummaryInformation.setCategory("类别:Excel文件");//类别
|
|
|
+ documentSummaryInformation.setManager("管理者:王军");//管理者
|
|
|
+ documentSummaryInformation.setCompany("公司:Action");//公司
|
|
|
+
|
|
|
+ //文档输出
|
|
|
+ FileOutputStream out = new FileOutputStream("D:/单诊断分类/(" + diag + ")" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()).toString() + ".xls");
|
|
|
+ workbook.write(out);
|
|
|
+ out.close();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 读取文件内容
|
|
|
+ public static List<String> readFile(String path) {//路径
|
|
|
+ File file = new File(path);
|
|
|
+ List<String> caseList = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));//构造一个BufferedReader类来读取文件
|
|
|
+ String line = null;
|
|
|
+ while ((line = br.readLine()) != null) {//使用readLine方法,一次读一行
|
|
|
+ caseList.add(line);
|
|
|
+ }
|
|
|
+ br.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return caseList;
|
|
|
+ }
|
|
|
+
|
|
|
}
|