|
@@ -18,19 +18,22 @@ import java.util.regex.Pattern;
|
|
|
public class tzAdmissionNote {
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
- String path = "C:/Users/dev_1/Desktop/dcsj/test.txt";
|
|
|
- String str = readFile(path);
|
|
|
+ List<String> words = Lists.newArrayList("0101-0201", "0201-0301", "0301-0401", "0401-0501", "0501-0601", "0601-0701", "0701-0801", "0801-0901", "0901-1001", "1001-1101", "1101-1201");
|
|
|
+ for (String word : words) {
|
|
|
+ String path = "C:/Users/dev_1/Desktop/dcsj/" + word + ".txt";
|
|
|
+ readFile(path);
|
|
|
+ }
|
|
|
+
|
|
|
// List<Map<String, String>> xmlMaps = WritXmlSelect();
|
|
|
// System.out.println(xmlMaps);
|
|
|
// AcquirePatientName(xmlMaps);
|
|
|
}
|
|
|
|
|
|
// 读取文件内容
|
|
|
- public static String readFile(String path) {//路径
|
|
|
+ public static void readFile(String path) {//路径
|
|
|
File file = new File(path);
|
|
|
StringBuffer result = new StringBuffer();
|
|
|
List<String> caseList = new ArrayList<>();
|
|
|
- Map<String, String> structureMap = new HashMap<>();
|
|
|
try {
|
|
|
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));//构造一个BufferedReader类来读取文件
|
|
|
String line = null;
|
|
@@ -42,21 +45,21 @@ public class tzAdmissionNote {
|
|
|
}
|
|
|
}
|
|
|
if (caseList.size() > 0) {
|
|
|
- analysisList(caseList, structureMap);
|
|
|
+ analysisList(caseList);
|
|
|
}
|
|
|
br.close();
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- return result.toString();
|
|
|
}
|
|
|
|
|
|
//切出每一个个病历
|
|
|
- private static void analysisList(List<String> caseList, Map<String, String> structureMap) {
|
|
|
+ private static void analysisList(List<String> caseList) {
|
|
|
for (String content : caseList) {
|
|
|
+ Map<String, String> structureMap = new HashMap<>();
|
|
|
String[] split = content.split("\t");
|
|
|
if (split.length > 4) {
|
|
|
- structureMap.put("病案号", split[0]);
|
|
|
+ structureMap.put("病历号", split[0]);
|
|
|
if (split[1].equals("F")) {
|
|
|
structureMap.put("性别", "女");
|
|
|
} else {
|
|
@@ -75,31 +78,162 @@ public class tzAdmissionNote {
|
|
|
if (StringUtil.isNotBlank(content)) {
|
|
|
List<String> sortTitles = sortTitles(titles, content);
|
|
|
cutByTitles(content, sortTitles, 0, structureMap, true);
|
|
|
- structureMap = OrdinaryAssistant.mapKeyContrast(structureMap, consultationResults_pageDataTitles);
|
|
|
- storage(structureMap);
|
|
|
+ if (structureMap.containsKey("处理结果")) {
|
|
|
+ structureMap.put("处理", structureMap.get("处理结果"));
|
|
|
+ }
|
|
|
+ if (structureMap != null) {
|
|
|
+ storage(structureMap);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- private static List<String> consultationResults_pageDataTitles = Lists.newArrayList(
|
|
|
- "处理结果=处理"
|
|
|
- );
|
|
|
-
|
|
|
-
|
|
|
private static void storage(Map<String, String> structureMap) {
|
|
|
Connection conn = null;
|
|
|
Statement stmt = null;
|
|
|
PreparedStatement ps = null;
|
|
|
ResultSet rs = null;
|
|
|
- String sql = "insert into str_admission_note(name,price,bookCount,author) values(?,?,?,?)";
|
|
|
+ String sql =
|
|
|
+ "insert into str_admission_note(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) values(?,?,?,?,?,?,?,?,?," +
|
|
|
+ "?,?,?,?,?,?,?,?,?,?," +
|
|
|
+ "?,?,?)";
|
|
|
try {
|
|
|
conn = DBUtil.getConnection();
|
|
|
ps = conn.prepareStatement(sql);
|
|
|
|
|
|
-// ps.setString(1, );
|
|
|
-// ps.setDouble(2, );
|
|
|
-// ps.setInt(3, );
|
|
|
-// ps.setString(4, );
|
|
|
+ //behospital_code
|
|
|
+ if (structureMap.containsKey("病历号")) {
|
|
|
+ ps.setString(1, structureMap.get("病历号"));
|
|
|
+ } else {
|
|
|
+ ps.setString(1, null);
|
|
|
+ }
|
|
|
+ //sex
|
|
|
+ if (structureMap.containsKey("性别")) {
|
|
|
+ ps.setString(2, structureMap.get("性别"));
|
|
|
+ } else {
|
|
|
+ ps.setString(2, null);
|
|
|
+ }
|
|
|
+ //age
|
|
|
+ if (structureMap.containsKey("年龄")) {
|
|
|
+ ps.setString(3, structureMap.get("年龄"));
|
|
|
+ } else {
|
|
|
+ ps.setString(3, null);
|
|
|
+ }
|
|
|
+ //chief
|
|
|
+ if (structureMap.containsKey("主诉")) {
|
|
|
+ ps.setString(4, structureMap.get("主诉"));
|
|
|
+ } else {
|
|
|
+ ps.setString(4, null);
|
|
|
+ }
|
|
|
+ //present
|
|
|
+ if (structureMap.containsKey("现病史")) {
|
|
|
+ ps.setString(5, structureMap.get("现病史"));
|
|
|
+ } else {
|
|
|
+ ps.setString(5, null);
|
|
|
+ }
|
|
|
+ //past_history
|
|
|
+ if (structureMap.containsKey("既往史")) {
|
|
|
+ ps.setString(6, structureMap.get("既往史"));
|
|
|
+ } else {
|
|
|
+ ps.setString(6, null);
|
|
|
+ }
|
|
|
+ //personal_history
|
|
|
+ if (structureMap.containsKey("个人史")) {
|
|
|
+ ps.setString(7, structureMap.get("个人史"));
|
|
|
+ } else {
|
|
|
+ ps.setString(7, null);
|
|
|
+ }
|
|
|
+ //menstrual_history
|
|
|
+ if (structureMap.containsKey("月经史")) {
|
|
|
+ ps.setString(8, structureMap.get("月经史"));
|
|
|
+ } else {
|
|
|
+ ps.setString(8, null);
|
|
|
+ }
|
|
|
+ //marital_history
|
|
|
+ if (structureMap.containsKey("婚育史")) {
|
|
|
+ ps.setString(9, structureMap.get("婚育史"));
|
|
|
+ } else {
|
|
|
+ ps.setString(9, null);
|
|
|
+ }
|
|
|
+ //family_history
|
|
|
+ if (structureMap.containsKey("家族史")) {
|
|
|
+ ps.setString(10, structureMap.get("家族史"));
|
|
|
+ } else {
|
|
|
+ ps.setString(10, null);
|
|
|
+ }
|
|
|
+ //physique_exam
|
|
|
+ if (structureMap.containsKey("专科检查")) {
|
|
|
+ ps.setString(11, structureMap.get("专科检查"));
|
|
|
+ } else {
|
|
|
+ ps.setString(11, null);
|
|
|
+ }
|
|
|
+ //spirit_exam
|
|
|
+ if (structureMap.containsKey("精神检查")) {
|
|
|
+ ps.setString(12, structureMap.get("精神检查"));
|
|
|
+ } else {
|
|
|
+ ps.setString(12, null);
|
|
|
+ }
|
|
|
+ //diagnosis
|
|
|
+ if (structureMap.containsKey("诊断")) {
|
|
|
+ ps.setString(13, structureMap.get("诊断"));
|
|
|
+ } else {
|
|
|
+ ps.setString(13, null);
|
|
|
+ }
|
|
|
+ //dispose
|
|
|
+ if (structureMap.containsKey("处理")) {
|
|
|
+ ps.setString(14, structureMap.get("处理"));
|
|
|
+ } else {
|
|
|
+ ps.setString(14, null);
|
|
|
+ }
|
|
|
+ //announcements
|
|
|
+ if (structureMap.containsKey("注意事项")) {
|
|
|
+ ps.setString(15, structureMap.get("注意事项"));
|
|
|
+ } else {
|
|
|
+ ps.setString(15, null);
|
|
|
+ }
|
|
|
+ //western
|
|
|
+ if (structureMap.containsKey("西药")) {
|
|
|
+ ps.setString(16, structureMap.get("西药"));
|
|
|
+ } else {
|
|
|
+ ps.setString(16, null);
|
|
|
+ }
|
|
|
+ //examine
|
|
|
+ if (structureMap.containsKey("检查")) {
|
|
|
+ ps.setString(17, structureMap.get("检查"));
|
|
|
+ } else {
|
|
|
+ ps.setString(17, null);
|
|
|
+ }
|
|
|
+ //vulva
|
|
|
+ if (structureMap.containsKey("外阴")) {
|
|
|
+ ps.setString(18, structureMap.get("外阴"));
|
|
|
+ } else {
|
|
|
+ ps.setString(18, null);
|
|
|
+ }
|
|
|
+ //vagina
|
|
|
+ if (structureMap.containsKey("阴道")) {
|
|
|
+ ps.setString(19, structureMap.get("阴道"));
|
|
|
+ } else {
|
|
|
+ ps.setString(19, null);
|
|
|
+ }
|
|
|
+ //cervix
|
|
|
+ if (structureMap.containsKey("宫颈")) {
|
|
|
+ ps.setString(20, structureMap.get("宫颈"));
|
|
|
+ } else {
|
|
|
+ ps.setString(20, null);
|
|
|
+ }
|
|
|
+ //uterus
|
|
|
+ if (structureMap.containsKey("子宫")) {
|
|
|
+ ps.setString(21, structureMap.get("子宫"));
|
|
|
+ } else {
|
|
|
+ ps.setString(21, null);
|
|
|
+ }
|
|
|
+ //accessories
|
|
|
+ if (structureMap.containsKey("双附件")) {
|
|
|
+ ps.setString(22, structureMap.get("双附件"));
|
|
|
+ } else {
|
|
|
+ ps.setString(22, null);
|
|
|
+ }
|
|
|
int row = ps.executeUpdate();
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -121,6 +255,7 @@ public class tzAdmissionNote {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -160,7 +295,8 @@ public class tzAdmissionNote {
|
|
|
* @param depth 递归深度,也就是titles取值时的下标值
|
|
|
* @param structureMap 存储结构化数据
|
|
|
*/
|
|
|
- public static void cutByTitles(String line, List<String> titles, int depth, Map<String, String> structureMap, Boolean flag) {
|
|
|
+ public static void cutByTitles(String line, List<String> titles, int depth, Map<
|
|
|
+ String, String> structureMap, Boolean flag) {
|
|
|
if (depth > titles.size() || titles.size() == 0) {
|
|
|
return;
|
|
|
}
|