|
@@ -2,7 +2,6 @@ package com.lantone.qc.trans.changx;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
-import com.google.common.collect.Sets;
|
|
|
import com.lantone.qc.pub.model.doc.transferrecord.TransferIntoDoc;
|
|
|
import com.lantone.qc.pub.model.doc.transferrecord.TransferOutDoc;
|
|
|
import com.lantone.qc.pub.model.doc.transferrecord.TransferRecordDoc;
|
|
@@ -10,12 +9,17 @@ import com.lantone.qc.pub.model.vo.MedrecVo;
|
|
|
import com.lantone.qc.pub.util.ListUtil;
|
|
|
import com.lantone.qc.pub.util.StringUtil;
|
|
|
import com.lantone.qc.trans.ModelDocTrans;
|
|
|
+import com.lantone.qc.trans.changx.util.CxXmlUtil;
|
|
|
import com.lantone.qc.trans.comsis.ModelDocGenerate;
|
|
|
+import com.lantone.qc.trans.comsis.OrdinaryAssistant;
|
|
|
import com.lantone.qc.trans.comsis.Preproc;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Comparator;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
-import java.util.Set;
|
|
|
+import java.util.TreeMap;
|
|
|
|
|
|
/**
|
|
|
* @Description: 转科记录文档生成
|
|
@@ -25,30 +29,88 @@ import java.util.Set;
|
|
|
public class ChangxTransferRecordDocTrans extends ModelDocTrans {
|
|
|
|
|
|
@Override
|
|
|
- public List<TransferRecordDoc> extract(MedrecVo medrecVo) {
|
|
|
- List<TransferRecordDoc> retList = Lists.newArrayList();
|
|
|
+ public TransferRecordDoc extract(MedrecVo medrecVo) {
|
|
|
+ TransferRecordDoc transferRecordDoc = new TransferRecordDoc();
|
|
|
|
|
|
Map<String, List<String>> contentMap = (Map) medrecVo.getContent().get("content");
|
|
|
if (contentMap == null) {
|
|
|
- return retList;
|
|
|
+ return transferRecordDoc;
|
|
|
}
|
|
|
-
|
|
|
- Map<String, TransferIntoDoc> transferIntoDocMap = getTransferIntoDocMap(contentMap.get("转入"));
|
|
|
- Map<String, TransferOutDoc> transferOutDocMap = getTransferOutDocMap(contentMap.get("转出"));
|
|
|
-
|
|
|
- Set<String> transferRecordNameSet = Sets.newHashSet();
|
|
|
- transferRecordNameSet.addAll(transferIntoDocMap.keySet());
|
|
|
- transferRecordNameSet.addAll(transferOutDocMap.keySet());
|
|
|
-
|
|
|
- transferRecordNameSet.forEach(transferRecordName -> {
|
|
|
- TransferRecordDoc transferRecordDoc = new TransferRecordDoc();
|
|
|
- transferRecordDoc.setTransferRecordName(transferRecordName);
|
|
|
- transferRecordDoc.setTransferIntoDoc(transferIntoDocMap.get(transferRecordName));
|
|
|
- transferRecordDoc.setTransferOutDoc(transferOutDocMap.get(transferRecordName));
|
|
|
- retList.add(transferRecordDoc);
|
|
|
+ List<String> into = contentMap.get("转入记录");
|
|
|
+ List<String> out = contentMap.get("转出记录");
|
|
|
+ List<String> all = new ArrayList<>();
|
|
|
+ all.addAll(into);
|
|
|
+ all.addAll(out);
|
|
|
+ Map<String, TransferIntoDoc> transferIntoDocMap = getTransferIntoDocMap(into);
|
|
|
+ Map<String, TransferOutDoc> transferOutDocMap = getTransferOutDocMap(out);
|
|
|
+ Map<String, TransferRecordDoc> transferAllDocMap = getTransferAllDocMap(all);
|
|
|
+
|
|
|
+ //转入
|
|
|
+ Map<Date, TransferIntoDoc> dateRecordIn = new TreeMap<>(new Comparator<Date>() {
|
|
|
+ @Override
|
|
|
+ public int compare(Date o1, Date o2) {
|
|
|
+ // 升序排列
|
|
|
+ return o1.compareTo(o2);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ for (TransferIntoDoc transferIntoDoc : transferIntoDocMap.values()) {
|
|
|
+ Map<String, String> structureMap = transferIntoDoc.getStructureMap();
|
|
|
+ String inDateStr = structureMap.get("转科日期");
|
|
|
+ if (StringUtil.isBlank(inDateStr)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Date inDate = StringUtil.parseDateTime(inDateStr);
|
|
|
+ if (inDate == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ dateRecordIn.put(inDate, transferIntoDoc);
|
|
|
+ }
|
|
|
+ transferRecordDoc.setTransferIntoDocs(new ArrayList<>(dateRecordIn.values()));
|
|
|
+ //转出
|
|
|
+ Map<Date, TransferOutDoc> dateRecordOut = new TreeMap<>(new Comparator<Date>() {
|
|
|
+ @Override
|
|
|
+ public int compare(Date o1, Date o2) {
|
|
|
+ // 升序排列
|
|
|
+ return o1.compareTo(o2);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ for (TransferOutDoc transferOutDoc : transferOutDocMap.values()) {
|
|
|
+ Map<String, String> structureMap = transferOutDoc.getStructureMap();
|
|
|
+ String outDateStr = structureMap.get("转科日期");
|
|
|
+ if (StringUtil.isBlank(outDateStr)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Date outDate = StringUtil.parseDateTime(outDateStr);
|
|
|
+ if (outDate == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ dateRecordOut.put(outDate, transferOutDoc);
|
|
|
+ }
|
|
|
+ transferRecordDoc.setTransferOutDocs(new ArrayList<>(dateRecordOut.values()));
|
|
|
+
|
|
|
+ //全部转科记录
|
|
|
+ Map<Date, TransferRecordDoc> dateRecordAll = new TreeMap<>(new Comparator<Date>() {
|
|
|
+ @Override
|
|
|
+ public int compare(Date o1, Date o2) {
|
|
|
+ // 升序排列
|
|
|
+ return o1.compareTo(o2);
|
|
|
+ }
|
|
|
});
|
|
|
+ for (TransferRecordDoc transferRecordAllDoc : transferAllDocMap.values()) {
|
|
|
+ Map<String, String> structureMap = transferRecordAllDoc.getStructureMap();
|
|
|
+ String transferDateStr = structureMap.get("转科日期");
|
|
|
+ if (StringUtil.isBlank(transferDateStr)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Date transferDate = StringUtil.parseDateTime(transferDateStr);
|
|
|
+ if (transferDate == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ dateRecordAll.put(transferDate, transferRecordAllDoc);
|
|
|
+ }
|
|
|
+ transferRecordDoc.setAllTransferDocs(new ArrayList<>(dateRecordAll.values()));
|
|
|
|
|
|
- return retList;
|
|
|
+ return transferRecordDoc;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -74,49 +136,48 @@ public class ChangxTransferRecordDocTrans extends ModelDocTrans {
|
|
|
}
|
|
|
|
|
|
private TransferIntoDoc getTransferIntoDoc(String content) {
|
|
|
- Map<String, String> pageData = Preproc.extract_doc_pub(true, transferInto_pageDataTitles, content);
|
|
|
- pageData.put("病程记录内容",
|
|
|
- pageData.get("病程记录内容")
|
|
|
- .replace(pageData.get("病程记录时间"), "")
|
|
|
- .replace(pageData.get("病程记录名称"), "")
|
|
|
- );
|
|
|
-
|
|
|
- List<String> targetTitles = Lists.newArrayList();
|
|
|
- transferInto_sourceTitles.forEach(sourceTitle -> {
|
|
|
- String targetTitle = "";
|
|
|
- for (int index = 0; index < sourceTitle.length(); index++) {
|
|
|
- if (index == sourceTitle.length() - 1) {
|
|
|
- targetTitle += sourceTitle.substring(index, index + 1);
|
|
|
- } else {
|
|
|
- targetTitle += sourceTitle.substring(index, index + 1) + "[\\s\\p{Zs}]*";
|
|
|
- }
|
|
|
- }
|
|
|
- targetTitles.add(targetTitle);
|
|
|
- });
|
|
|
+ Map<String, String> xmlNodeValueMap = CxXmlUtil.firstLevelNodeValue("//DocObjContent//Region", content);
|
|
|
+ Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(xmlNodeValueMap, keyContrasts);
|
|
|
|
|
|
- Map<String, String> sourceMap = Preproc.extract_doc_pub(true, targetTitles, content);
|
|
|
- sourceMap.put("记录时间", sourceMap.get("病程记录时间"));
|
|
|
-
|
|
|
- TransferIntoDoc transferIntoDoc = ModelDocGenerate.transferIntoDocGen(sourceMap);
|
|
|
+// sourceMap.put("记录时间", sourceMap.get("病程记录时间"));
|
|
|
+ TransferIntoDoc transferIntoDoc = new TransferIntoDoc();
|
|
|
transferIntoDoc.setText(content);
|
|
|
- transferIntoDoc.setPageData((Map) pageData);
|
|
|
+ transferIntoDoc.setStructureMap(structureMap);
|
|
|
+ transferIntoDoc.setPageData((Map)xmlNodeValueMap);
|
|
|
|
|
|
return transferIntoDoc;
|
|
|
}
|
|
|
|
|
|
- private List<String> transferInto_pageDataTitles = Lists.newArrayList(
|
|
|
- "病程记录时间",
|
|
|
- "病程记录名称",
|
|
|
- "病程记录内容",
|
|
|
- "记录医师"
|
|
|
- );
|
|
|
- private List<String> transferInto_sourceTitles = Lists.newArrayList(
|
|
|
- "病程记录时间",
|
|
|
- "病程记录名称",
|
|
|
- "病程记录内容",
|
|
|
- "记录时间",
|
|
|
- "记录医师"
|
|
|
- );
|
|
|
+ /**************************************************全部*******************************************************/
|
|
|
+ private Map<String, TransferRecordDoc> getTransferAllDocMap(List<String> contents) {
|
|
|
+ Map<String, TransferRecordDoc> retMap = Maps.newHashMap();
|
|
|
+ if (ListUtil.isEmpty(contents)) {
|
|
|
+ return retMap;
|
|
|
+ }
|
|
|
+ int index = 1;
|
|
|
+ String transferRecordName = null;
|
|
|
+ for (String content : contents) {
|
|
|
+ if (StringUtil.isBlank(content)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ transferRecordName = index + "";
|
|
|
+ TransferRecordDoc transferRecordDoc = getTransferAllDoc(content);
|
|
|
+ transferRecordDoc.setTransferRecordName(transferRecordName);
|
|
|
+ retMap.put(transferRecordName, transferRecordDoc);
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ return retMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ private TransferRecordDoc getTransferAllDoc(String content) {
|
|
|
+ Map<String, String> xmlNodeValueMap = CxXmlUtil.firstLevelNodeValue("//DocObjContent//Region", content);
|
|
|
+ Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(xmlNodeValueMap, keyContrasts);
|
|
|
+ TransferRecordDoc transferAllDoc = new TransferRecordDoc();
|
|
|
+ transferAllDoc.setText(content);
|
|
|
+ transferAllDoc.setStructureMap(structureMap);
|
|
|
+ transferAllDoc.setPageData((Map) xmlNodeValueMap);
|
|
|
+ return transferAllDoc;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
/**************************************************转出*******************************************************/
|
|
@@ -141,48 +202,26 @@ public class ChangxTransferRecordDocTrans extends ModelDocTrans {
|
|
|
}
|
|
|
|
|
|
private TransferOutDoc getTransferOutDoc(String content) {
|
|
|
- Map<String, String> pageData = Preproc.extract_doc_pub(true, transferOut_pageDataTitles, content);
|
|
|
- pageData.put("病程记录内容",
|
|
|
- pageData.get("病程记录内容")
|
|
|
- .replace(pageData.get("病程记录时间"), "")
|
|
|
- .replace(pageData.get("病程记录名称"), "")
|
|
|
- );
|
|
|
-
|
|
|
- List<String> targetTitles = Lists.newArrayList();
|
|
|
- transferOut_sourceTitles.forEach(sourceTitle -> {
|
|
|
- String targetTitle = "";
|
|
|
- for (int index = 0; index < sourceTitle.length(); index++) {
|
|
|
- if (index == sourceTitle.length() - 1) {
|
|
|
- targetTitle += sourceTitle.substring(index, index + 1);
|
|
|
- } else {
|
|
|
- targetTitle += sourceTitle.substring(index, index + 1) + "[\\s\\p{Zs}]*";
|
|
|
- }
|
|
|
- }
|
|
|
- targetTitles.add(targetTitle);
|
|
|
- });
|
|
|
+ Map<String, String> xmlNodeValueMap = CxXmlUtil.firstLevelNodeValue("//DocObjContent//Region", content);
|
|
|
+ Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(xmlNodeValueMap, keyContrasts);
|
|
|
|
|
|
- Map<String, String> sourceMap = Preproc.extract_doc_pub(true, targetTitles, content);
|
|
|
- sourceMap.put("记录时间", sourceMap.get("病程记录时间"));
|
|
|
-
|
|
|
- TransferOutDoc transferOutDoc = ModelDocGenerate.transferOutDocGen(sourceMap);
|
|
|
+ TransferOutDoc transferOutDoc = new TransferOutDoc();
|
|
|
transferOutDoc.setText(content);
|
|
|
- transferOutDoc.setPageData((Map) pageData);
|
|
|
+ transferOutDoc.setStructureMap(structureMap);
|
|
|
+ transferOutDoc.setPageData((Map) xmlNodeValueMap);
|
|
|
|
|
|
return transferOutDoc;
|
|
|
}
|
|
|
|
|
|
- private List<String> transferOut_pageDataTitles = Lists.newArrayList(
|
|
|
- "病程记录时间",
|
|
|
- "病程记录名称",
|
|
|
- "病程记录内容",
|
|
|
- "记录医师"
|
|
|
- );
|
|
|
- private List<String> transferOut_sourceTitles = Lists.newArrayList(
|
|
|
- "病程记录时间",
|
|
|
- "病程记录名称",
|
|
|
- "病程记录内容",
|
|
|
- "记录时间",
|
|
|
- "记录医师"
|
|
|
+ private List<String> keyContrasts = Lists.newArrayList(
|
|
|
+ "转出日期=转科日期",
|
|
|
+ "转入日期=转科日期",
|
|
|
+ "转出日期=转科日期",
|
|
|
+ "姓名++++患者姓名=姓名",
|
|
|
+ "签名++++=医师签名",
|
|
|
+ "++++入院日期=入院日期",
|
|
|
+ "入院诊断++++初步诊断=初步诊断",
|
|
|
+ "转入目的++++目的=转入目的",
|
|
|
+ "转出目的++++目的=转出目的"
|
|
|
);
|
|
|
-
|
|
|
}
|