|
@@ -1,20 +1,22 @@
|
|
|
package com.lantone.qc.trans.wenfuyi;
|
|
|
|
|
|
-import com.google.common.collect.Lists;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import org.apache.commons.collections.MapUtils;
|
|
|
+import org.jsoup.Jsoup;
|
|
|
+import org.jsoup.nodes.Document;
|
|
|
+import org.jsoup.nodes.Element;
|
|
|
+import org.jsoup.select.Elements;
|
|
|
+
|
|
|
import com.lantone.qc.pub.model.doc.BeHospitalizedDoc;
|
|
|
import com.lantone.qc.pub.model.vo.MedrecVo;
|
|
|
-import com.lantone.qc.pub.util.FastJsonUtils;
|
|
|
import com.lantone.qc.trans.ModelDocTrans;
|
|
|
import com.lantone.qc.trans.comsis.ModelDocGenerate;
|
|
|
-import com.lantone.qc.trans.comsis.OrdinaryAssistant;
|
|
|
-import com.lantone.qc.trans.wenfuyi.util.BeHospitalizedHtmlAnalysis;
|
|
|
-import com.lantone.qc.trans.wenfuyi.util.WenFuYiHtmlAnalysis;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.collections.MapUtils;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
+import com.lantone.qc.trans.wenfuyi.util.WenFuYiHtmlAnalysisUtil;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
/**
|
|
|
* @Description: 入院记录文档生成
|
|
@@ -27,55 +29,64 @@ public class BeHospitalizedDocTrans extends ModelDocTrans {
|
|
|
@Override
|
|
|
public BeHospitalizedDoc extract(MedrecVo medrecVo) {
|
|
|
BeHospitalizedDoc beHospitalizedDoc = null;
|
|
|
- try {
|
|
|
- /*Map<String, Object> contentMap = ((List<Map>) medrecVo.getContent().get("content")).get(0);
|
|
|
- String content = contentMap.get("htmlText").toString();*/
|
|
|
- List<Map> map = (List<Map>) medrecVo.getContent().get("content");
|
|
|
- StringBuffer sb = new StringBuffer();
|
|
|
- Map<String, Object> contentMap = null;
|
|
|
- if (map.size() > 1) {
|
|
|
- for (Map<String, Object> a : map) {
|
|
|
- sb.append(a.get("htmlText"));
|
|
|
- if (a.get("recTitle").toString().contains("(一)") || a.get("recTitle").toString().contains("(一)")) {
|
|
|
- contentMap = a;
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- contentMap = ((List<Map>) medrecVo.getContent().get("content")).get(0);
|
|
|
- }
|
|
|
- String content = sb.toString();
|
|
|
- Map<String, String> structureMap = null;
|
|
|
- if (map.get(0).get("isParsed") != null && "1".equals(map.get(0).get("isParsed").toString())) {
|
|
|
- structureMap = (Map) FastJsonUtils.getJsonToMap(content);
|
|
|
- } else {
|
|
|
- String recTitle = contentMap.get("recTitle").toString();
|
|
|
- String recTypeId = contentMap.get("recTypeId").toString();
|
|
|
- WenFuYiHtmlAnalysis wenFuYiHtmlAnalysis = new BeHospitalizedHtmlAnalysis();
|
|
|
- Map<String, String> sourceMap;
|
|
|
- if (StringUtils.isNotBlank(content)) {
|
|
|
- sourceMap = wenFuYiHtmlAnalysis.analysis(content, recTitle, recTypeId);
|
|
|
- } else{
|
|
|
- sourceMap = wenFuYiHtmlAnalysis.analysis(contentMap.get("htmlText").toString(), recTitle, recTypeId);
|
|
|
- }
|
|
|
- if (MapUtils.isNotEmpty(sourceMap)) {
|
|
|
- structureMap = OrdinaryAssistant.mapKeyContrast(sourceMap, keyContrasts);
|
|
|
- structureMap.put("记录编号", contentMap.get("recId").toString());
|
|
|
- structureMap.put("病历号", contentMap.get("behospitalCode") == null ? null : contentMap.get("behospitalCode").toString());
|
|
|
- }
|
|
|
- }
|
|
|
- if (MapUtils.isNotEmpty(structureMap)) {
|
|
|
- beHospitalizedDoc = ModelDocGenerate.beHospitalizedDocGen(structureMap);
|
|
|
- beHospitalizedDoc.setPageData((Map) structureMap);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error(e.getMessage(), e);
|
|
|
+ List<Map> map = (List<Map>) medrecVo.getContent().get("content");
|
|
|
+
|
|
|
+ Map<String, String> result = new HashMap<>();
|
|
|
+ for (Map data : map) {
|
|
|
+ Document doc = Jsoup.parse(""+data.get("htmlText"));
|
|
|
+ String recTypeId = ""+data.get("recTypeId");
|
|
|
+
|
|
|
+ result.put("记录编号", data.get("recId").toString());
|
|
|
+ result.put("病历号", data.get("behospitalCode") == null ? null : data.get("behospitalCode").toString());
|
|
|
+
|
|
|
+ if(recTypeId.equals("住院病例(-)")) { //住院病例(-)
|
|
|
+ Elements select = doc.select(".tymc");
|
|
|
+ for (Element element : select) {
|
|
|
+ for (String key : new String[]{"姓名","邮编","性别","单位","年龄","身份证号","婚姻","户口地址","民族","联系电话","出生地","入院日期","职业","病史陈述者"}) {
|
|
|
+ if(!result.containsKey(key) && element.text().replace(" ", "").contains(key)) {
|
|
|
+ result.put(key, element.nextElementSibling().text());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ select = doc.select(".c001");
|
|
|
+ result.put("主诉", select.get(0).nextElementSibling().text());
|
|
|
+ result.put("现病史", select.get(1).nextElementSibling().text());
|
|
|
+ }else if(recTypeId.equals("住院病例(二)")) {//住院病例(二)
|
|
|
+ String html = doc.text();
|
|
|
+ result.put("既往史", html.substring(4, html.indexOf("系统回顾")));
|
|
|
+ result.put("系统回顾", html.substring(html.indexOf("系统回顾")+5, html.indexOf("个人史")));
|
|
|
+ result.put("个人史", html.substring(html.indexOf("个人史")+4, html.indexOf("婚育史")));
|
|
|
+ result.put("婚育史", html.substring(html.indexOf("婚育史")+4, html.indexOf("家族史")));
|
|
|
+ result.put("家族史", html.substring(html.indexOf("家族史")+4, html.indexOf("专项评估")));
|
|
|
+ result.put("家族史", html.substring(html.indexOf("专项评估")+5));
|
|
|
+ }else if(recTypeId.equals("住院病例(三))")) {//住院病例(三)
|
|
|
+ String html = doc.text();
|
|
|
+ result.put("一般情况", html);
|
|
|
+ }else if(recTypeId.equals("住院病例(五))")) {//住院病例(五)
|
|
|
+ Elements select = doc.select("div");
|
|
|
+ result.put("特殊检查", select.get(0).text());
|
|
|
+ result.put("实验室检查", select.get(1).text());
|
|
|
+ result.put("辅助检查", "特殊检查:" + result.get("特殊检查") + ";实验室检查:" + result.get("实验室检查"));
|
|
|
+
|
|
|
+ result.put("初步诊断", select.get(2).text());
|
|
|
+
|
|
|
+ result.put("初步诊断医师签名日期",doc.select("table td").first().select("span").last().text());
|
|
|
+ result.put("上级医师签名", doc.select("table td").first().select("img").get(0).parent().html());
|
|
|
+ result.put("初步诊断医师签名", doc.select("table td").first().select(".tyz").first().text());
|
|
|
+
|
|
|
+ result.put("修正诊断",select.get(3).text());
|
|
|
+
|
|
|
+ result.put("修正诊断医师签名日期",doc.select("table td").last().select("span").last().text());
|
|
|
+ result.put("修正诊断医师签名", doc.select("table td").last().select("img").get(0).parent().html());
|
|
|
+ }
|
|
|
+ WenFuYiHtmlAnalysisUtil.insertModuleId("1", recTypeId, result);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (MapUtils.isNotEmpty(result)) {
|
|
|
+ beHospitalizedDoc = ModelDocGenerate.beHospitalizedDocGen(result);
|
|
|
+ beHospitalizedDoc.setPageData((Map) result);
|
|
|
}
|
|
|
return beHospitalizedDoc;
|
|
|
}
|
|
|
|
|
|
- private List<String> keyContrasts = Lists.newArrayList(
|
|
|
-
|
|
|
-
|
|
|
- );
|
|
|
-
|
|
|
}
|