|
@@ -1,8 +1,11 @@
|
|
|
package com.lantone.qc.trans.xiamen;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
+import com.google.common.collect.Maps;
|
|
|
import com.lantone.qc.dbanaly.util.KernelConstants;
|
|
|
import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
|
|
|
+import com.lantone.qc.pub.model.InputInfo;
|
|
|
+import com.lantone.qc.pub.model.doc.FirstPageRecordDoc;
|
|
|
import com.lantone.qc.pub.model.doc.ThreeLevelWardDoc;
|
|
|
import com.lantone.qc.pub.model.doc.operation.OperationDoc;
|
|
|
import com.lantone.qc.pub.model.doc.operation.OperationRecordDoc;
|
|
@@ -20,10 +23,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections.MapUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
-import java.util.Calendar;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @Description: 查房记录文档生成
|
|
@@ -35,24 +35,111 @@ import java.util.Map;
|
|
|
public class XiamenThreeLevelWardDocTrans extends ModelDocTrans {
|
|
|
|
|
|
private List<OperationDoc> operationDocs;
|
|
|
+ private InputInfo inputInfo;
|
|
|
|
|
|
@Override
|
|
|
public List<ThreeLevelWardDoc> extract(MedrecVo medrecVo) {
|
|
|
+
|
|
|
+ Map<String, String> PhysicianTitleMap = Maps.newHashMap();
|
|
|
+ //病案首页
|
|
|
+ FirstPageRecordDoc firstPageRecordDoc = inputInfo.getFirstPageRecordDoc();
|
|
|
+ if (firstPageRecordDoc != null && firstPageRecordDoc.getStructureMap() != null) {
|
|
|
+ Map<String, String> structureMap = firstPageRecordDoc.getStructureMap();
|
|
|
+ PhysicianTitleMap.put("主任医师", structureMap.get("主任医师"));
|
|
|
+ PhysicianTitleMap.put("主治医师", structureMap.get("主治医师"));
|
|
|
+ }
|
|
|
+
|
|
|
List<ThreeLevelWardDoc> retList = Lists.newArrayList();
|
|
|
ThreeLevelWardDoc threeLevelWardDoc = new ThreeLevelWardDoc();
|
|
|
List<Map<String, Object>> contentMaps = (List) medrecVo.getContent().get("content");
|
|
|
contentMaps.forEach(contentMap -> {
|
|
|
try {
|
|
|
- classifyThreeLevelWardDoc(threeLevelWardDoc, contentMap);
|
|
|
+ classifyThreeLevelWardDoc(threeLevelWardDoc, contentMap, PhysicianTitleMap);
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage(), e);
|
|
|
}
|
|
|
});
|
|
|
+ //厦门查房无主治的情况(查房中高职称+低职称查房,低职称为主治查房)
|
|
|
+ theWardsManage(threeLevelWardDoc);
|
|
|
retList.add(threeLevelWardDoc);
|
|
|
return retList;
|
|
|
}
|
|
|
|
|
|
- private void classifyThreeLevelWardDoc(ThreeLevelWardDoc threeLevelWardDoc, Map<String, Object> contentMap) {
|
|
|
+ //厦门查房无主治的情况(查房中高职称+低职称查房,低职称为主治查房)
|
|
|
+ private void theWardsManage(ThreeLevelWardDoc threeLevelWardDoc) {
|
|
|
+ //科主任
|
|
|
+ boolean department = false;
|
|
|
+ //主任
|
|
|
+ boolean director = false;
|
|
|
+ //副主任
|
|
|
+ boolean deputyDirector = false;
|
|
|
+ List<ThreeLevelWardDoc> allDoctorWradDocs = threeLevelWardDoc.getAllDoctorWradDocs();
|
|
|
+ if (threeLevelWardDoc.getAttendingDoctorWardDocs().size() == 0) {
|
|
|
+ for (ThreeLevelWardDoc t : allDoctorWradDocs) {
|
|
|
+ Map<String, String> structureMap = t.getStructureMap();
|
|
|
+ String title = structureMap.get("查房标题");
|
|
|
+ if(StringUtil.isBlank(title)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (title.contains("科主任")) {
|
|
|
+ department = true;
|
|
|
+ }
|
|
|
+ if (title.contains("主任") && !title.contains("科主任") && !title.contains("副主任")) {
|
|
|
+ director = true;
|
|
|
+ }
|
|
|
+ if (title.contains("副主任")) {
|
|
|
+ deputyDirector = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //存在科主任并且存在副主任或主任
|
|
|
+ if (department && (director || deputyDirector)) {
|
|
|
+ for (ThreeLevelWardDoc t : allDoctorWradDocs) {
|
|
|
+ Map<String, String> structureMap = t.getStructureMap();
|
|
|
+ String title = structureMap.get("查房标题");
|
|
|
+ if(StringUtil.isBlank(title)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!title.contains("科主任") && (title.contains("副主任") || title.contains("主任"))) {
|
|
|
+// structureMap.put("查房标题", title.replace("副主任", "主治").replace("主任", "主治"));
|
|
|
+ AttendingDoctorWardDoc attendingDoctorWardDoc = null;
|
|
|
+ attendingDoctorWardDoc = new AttendingDoctorWardDoc();
|
|
|
+ attendingDoctorWardDoc.setStructureMap(structureMap);
|
|
|
+ attendingDoctorWardDoc.setPageData((Map) structureMap);
|
|
|
+ if (attendingDoctorWardDoc != null) {
|
|
|
+ threeLevelWardDoc.addAttendingDoctorWardDoc(attendingDoctorWardDoc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+// AttendingDoctorWardDoc attendingDoctorWardDoc = findAttendingDoctorWardDoc(structureMap);
|
|
|
+// if (attendingDoctorWardDoc != null) {
|
|
|
+// threeLevelWardDoc.addAttendingDoctorWardDoc(attendingDoctorWardDoc);
|
|
|
+// }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //不存在科主任并且存在副主任或主任
|
|
|
+ if (director && deputyDirector) {
|
|
|
+ for (ThreeLevelWardDoc t : allDoctorWradDocs) {
|
|
|
+ Map<String, String> structureMap = t.getStructureMap();
|
|
|
+ String title = structureMap.get("查房标题");
|
|
|
+ if(StringUtil.isBlank(title)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+// structureMap.put("查房标题", title.replace("副主任", "主治"));
|
|
|
+ if (title.contains("副主任")) {
|
|
|
+ AttendingDoctorWardDoc attendingDoctorWardDoc = null;
|
|
|
+ attendingDoctorWardDoc = new AttendingDoctorWardDoc();
|
|
|
+ attendingDoctorWardDoc.setStructureMap(structureMap);
|
|
|
+ attendingDoctorWardDoc.setPageData((Map) structureMap);
|
|
|
+ if (attendingDoctorWardDoc != null) {
|
|
|
+ threeLevelWardDoc.addAttendingDoctorWardDoc(attendingDoctorWardDoc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void classifyThreeLevelWardDoc(ThreeLevelWardDoc threeLevelWardDoc, Map<String, Object> contentMap, Map<String, String> PhysicianTitleMap) {
|
|
|
String content = contentMap.get("xmlText").toString();
|
|
|
Map<String, String> structureMap = null;
|
|
|
if (contentMap.get("isParsed") != null && "1".equals(contentMap.get("isParsed").toString())) {
|
|
@@ -99,12 +186,12 @@ public class XiamenThreeLevelWardDocTrans extends ModelDocTrans {
|
|
|
threeLevelWardDoc.addAllDoctorWradDoc(allDoctorWradDoc);
|
|
|
|
|
|
//主任医师查房
|
|
|
- DirectorDoctorWardDoc directorDoctorWardDoc = findDirectorDoctorWardDoc(structureMap);
|
|
|
+ DirectorDoctorWardDoc directorDoctorWardDoc = findDirectorDoctorWardDoc(structureMap, PhysicianTitleMap);
|
|
|
if (directorDoctorWardDoc != null) {
|
|
|
- threeLevelWardDoc.addDirectorDoctorWardDoc(findDirectorDoctorWardDoc(structureMap));
|
|
|
+ threeLevelWardDoc.addDirectorDoctorWardDoc(directorDoctorWardDoc);
|
|
|
}
|
|
|
//主治医师查房
|
|
|
- AttendingDoctorWardDoc attendingDoctorWardDoc = findAttendingDoctorWardDoc(structureMap);
|
|
|
+ AttendingDoctorWardDoc attendingDoctorWardDoc = findAttendingDoctorWardDoc(structureMap, PhysicianTitleMap);
|
|
|
if (attendingDoctorWardDoc != null) {
|
|
|
threeLevelWardDoc.addAttendingDoctorWardDoc(attendingDoctorWardDoc);
|
|
|
}
|
|
@@ -123,12 +210,16 @@ public class XiamenThreeLevelWardDocTrans extends ModelDocTrans {
|
|
|
*
|
|
|
* @param structureMap
|
|
|
*/
|
|
|
- private DirectorDoctorWardDoc findDirectorDoctorWardDoc(Map<String, String> structureMap) {
|
|
|
+ private DirectorDoctorWardDoc findDirectorDoctorWardDoc(Map<String, String> structureMap, Map<String, String> PhysicianTitleMap) {
|
|
|
String title = structureMap.get("查房标题");
|
|
|
String content = structureMap.get("病情记录");
|
|
|
String writTitle = structureMap.get("文书标题");
|
|
|
String recordDateStr = structureMap.get("查房日期");
|
|
|
Date recordDate = StringUtil.parseDateTime(recordDateStr);
|
|
|
+ String directorDoctor = "";
|
|
|
+ if (PhysicianTitleMap != null && PhysicianTitleMap.size() > 0) {
|
|
|
+ directorDoctor = PhysicianTitleMap.get("主任医师");
|
|
|
+ }
|
|
|
//标题有代字
|
|
|
DirectorDoctorWardDoc directorDoctorWardDoc = null;
|
|
|
if (StringUtil.isNotBlank(title)) {
|
|
@@ -140,7 +231,8 @@ public class XiamenThreeLevelWardDocTrans extends ModelDocTrans {
|
|
|
title = title.replace("一助", doctorTitle);
|
|
|
}
|
|
|
if ((StringUtils.isNotEmpty(subTitle(title)) && subTitle(title).contains("主任")) || findDirector(content)
|
|
|
- || title.contains("多学科联合") || endocrinologyTitle(title)) {
|
|
|
+ || title.contains("多学科联合") || endocrinologyTitle(title)
|
|
|
+ || (StringUtil.isNotEmpty(directorDoctor) && title.contains(directorDoctor))) {
|
|
|
directorDoctorWardDoc = new DirectorDoctorWardDoc();
|
|
|
directorDoctorWardDoc.setStructureMap(structureMap);
|
|
|
directorDoctorWardDoc.setPageData((Map) structureMap);
|
|
@@ -156,7 +248,8 @@ public class XiamenThreeLevelWardDocTrans extends ModelDocTrans {
|
|
|
writTitle = writTitle.replace("一助", doctorTitle);
|
|
|
}
|
|
|
if ((StringUtils.isNotEmpty(subTitle(writTitle)) && subTitle(writTitle).contains("主任")) || findDirector(content)
|
|
|
- || writTitle.contains("多学科联合") || endocrinologyTitle(writTitle)) {
|
|
|
+ || writTitle.contains("多学科联合") || endocrinologyTitle(writTitle)
|
|
|
+ || (StringUtil.isNotEmpty(directorDoctor) && writTitle.contains(directorDoctor))) {
|
|
|
directorDoctorWardDoc = new DirectorDoctorWardDoc();
|
|
|
directorDoctorWardDoc.setStructureMap(structureMap);
|
|
|
directorDoctorWardDoc.setPageData((Map) structureMap);
|
|
@@ -170,12 +263,16 @@ public class XiamenThreeLevelWardDocTrans extends ModelDocTrans {
|
|
|
*
|
|
|
* @param structureMap
|
|
|
*/
|
|
|
- private AttendingDoctorWardDoc findAttendingDoctorWardDoc(Map<String, String> structureMap) {
|
|
|
+ private AttendingDoctorWardDoc findAttendingDoctorWardDoc(Map<String, String> structureMap, Map<String, String> PhysicianTitleMap) {
|
|
|
String title = structureMap.get("查房标题");
|
|
|
String writTitle = structureMap.get("文书标题");
|
|
|
String content = structureMap.get("病情记录");
|
|
|
String recordDateStr = structureMap.get("查房日期");
|
|
|
Date recordDate = StringUtil.parseDateTime(recordDateStr);
|
|
|
+ String behospitalDoctor = "";
|
|
|
+ if (PhysicianTitleMap != null && PhysicianTitleMap.size() > 0) {
|
|
|
+ behospitalDoctor = PhysicianTitleMap.get("主治医师");
|
|
|
+ }
|
|
|
AttendingDoctorWardDoc attendingDoctorWardDoc = null;
|
|
|
//标题有代字
|
|
|
if (StringUtil.isNotBlank(title)) {
|
|
@@ -187,7 +284,8 @@ public class XiamenThreeLevelWardDocTrans extends ModelDocTrans {
|
|
|
title = title.replace("一助", doctorTitle);
|
|
|
}
|
|
|
if ((StringUtils.isNotEmpty(subTitle(title)) && subTitle(title).contains("主治"))
|
|
|
- || findAttend(content) || title.contains("多学科联合") || endocrinologyTitle(title) || xiamenTitle(title)) {
|
|
|
+ || (StringUtil.isNotBlank(content) && findAttend(content)) || title.contains("多学科联合") || endocrinologyTitle(title)
|
|
|
+ || (StringUtil.isNotEmpty(behospitalDoctor) && title.contains(behospitalDoctor))) {
|
|
|
attendingDoctorWardDoc = new AttendingDoctorWardDoc();
|
|
|
attendingDoctorWardDoc.setStructureMap(structureMap);
|
|
|
attendingDoctorWardDoc.setPageData((Map) structureMap);
|
|
@@ -204,7 +302,8 @@ public class XiamenThreeLevelWardDocTrans extends ModelDocTrans {
|
|
|
writTitle = writTitle.replace("一助", doctorTitle);
|
|
|
}
|
|
|
if ((StringUtils.isNotEmpty(subTitle(writTitle)) && subTitle(writTitle).contains("主治"))
|
|
|
- || findAttend(content) || writTitle.contains("多学科联合") || endocrinologyTitle(writTitle) || xiamenTitle(title)) {
|
|
|
+ ||(StringUtil.isNotBlank(content) && findAttend(content)) || writTitle.contains("多学科联合") || endocrinologyTitle(writTitle)
|
|
|
+ || (StringUtil.isNotEmpty(behospitalDoctor) && writTitle.contains(behospitalDoctor))) {
|
|
|
attendingDoctorWardDoc = new AttendingDoctorWardDoc();
|
|
|
attendingDoctorWardDoc.setStructureMap(structureMap);
|
|
|
attendingDoctorWardDoc.setPageData((Map) structureMap);
|
|
@@ -225,15 +324,15 @@ public class XiamenThreeLevelWardDocTrans extends ModelDocTrans {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 厦门科主任+主任查房处理
|
|
|
+ * 主任+主任查房处理
|
|
|
*
|
|
|
* @param title
|
|
|
* @return
|
|
|
*/
|
|
|
- private boolean xiamenTitle(String title) {
|
|
|
- String regex = ".*科主任.*主任.*";
|
|
|
- return title.matches(regex);
|
|
|
- }
|
|
|
+// private boolean xiamenTitle(String title) {
|
|
|
+// String regex = ".*主任.*主任.*";
|
|
|
+// return title.matches(regex);
|
|
|
+// }
|
|
|
|
|
|
/**
|
|
|
* 共同照护讨论记录中找主任查房
|