|
@@ -8,10 +8,12 @@ import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
|
|
|
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;
|
|
|
+import com.lantone.qc.pub.model.doc.operation.PreoperativeDiscussionDoc;
|
|
|
import com.lantone.qc.pub.model.doc.ward.AttendingDoctorWardDoc;
|
|
|
import com.lantone.qc.pub.model.doc.ward.DirectorDoctorWardDoc;
|
|
|
import com.lantone.qc.pub.model.doc.ward.GeneralDoctorWardDoc;
|
|
|
import com.lantone.qc.pub.model.vo.MedrecVo;
|
|
|
+import com.lantone.qc.pub.util.FastJsonUtils;
|
|
|
import com.lantone.qc.pub.util.SpringContextUtil;
|
|
|
import com.lantone.qc.pub.util.StringUtil;
|
|
|
import com.lantone.qc.trans.ModelDocTrans;
|
|
@@ -19,10 +21,8 @@ import com.lantone.qc.trans.comsis.OrdinaryAssistant;
|
|
|
import lombok.Setter;
|
|
|
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.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description: 查房记录文档生成
|
|
@@ -31,7 +31,7 @@ import java.util.Map;
|
|
|
*/
|
|
|
@Setter
|
|
|
public class TaiZhouThreeLevelWardDocTrans extends ModelDocTrans {
|
|
|
-
|
|
|
+ private String modeId = "4";
|
|
|
private List<String> recTitles;
|
|
|
private List<OperationDoc> operationDocs;
|
|
|
|
|
@@ -53,26 +53,31 @@ public class TaiZhouThreeLevelWardDocTrans extends ModelDocTrans {
|
|
|
|
|
|
private void classifyThreeLevelWardDoc(ThreeLevelWardDoc result, Map<String, Object> contentMap) {
|
|
|
String content = contentMap.get("xmlText").toString();
|
|
|
- Map<String, String> sourceMap = TzXmlUtil.getXmlToMapForTZ(content);
|
|
|
- sourceMap.put("mode_id=" + contentMap.get("modeId").toString(), "");
|
|
|
- String recTitle = contentMap.get("recTitle").toString();
|
|
|
- if (recTitles.contains(recTitle)) {
|
|
|
- sourceMap.put("rec_title=" + contentMap.get("recTitle").toString(), "");
|
|
|
- }
|
|
|
- Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(sourceMap, keyContrasts);
|
|
|
+ Map<String, String> structureMap = null;
|
|
|
+ if (contentMap.get("isParsed") != null && "1".equals(contentMap.get("isParsed").toString())) {
|
|
|
+ structureMap = (Map) FastJsonUtils.getJsonToMap(content);
|
|
|
+ } else {
|
|
|
+ Map<String, String> sourceMap = TzXmlUtil.getXmlToMapForTZ(content);
|
|
|
+ sourceMap.put("mode_id=" + contentMap.get("modeId").toString(), "");
|
|
|
+ String recTitle = contentMap.get("recTitle").toString();
|
|
|
+ if (recTitles.contains(recTitle)) {
|
|
|
+ sourceMap.put("rec_title=" + contentMap.get("recTitle").toString(), "");
|
|
|
+ }
|
|
|
+ structureMap = OrdinaryAssistant.mapKeyContrast(sourceMap, keyContrasts, modeId);
|
|
|
|
|
|
- if (StringUtils.isEmpty(structureMap.get("查房日期"))) {
|
|
|
- return;
|
|
|
- }
|
|
|
- //不能简单的标准转化,如果有查房标题,优先使用
|
|
|
- if (StringUtils.isEmpty(structureMap.get("查房标题")) && StringUtils.isNotEmpty(structureMap.get("查房备注"))) {
|
|
|
- structureMap.put("查房标题", structureMap.get("查房备注"));
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(structureMap.get("查房标题")) && StringUtils.isNotEmpty(structureMap.get("查房类别"))) {
|
|
|
- structureMap.put("查房标题", structureMap.get("查房类别"));
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(structureMap.get("查房标题")) && StringUtils.isNotEmpty(structureMap.get("上级查房医生职称"))) {
|
|
|
- structureMap.put("查房标题", structureMap.get("上级查房医生职称"));
|
|
|
+ if (StringUtils.isEmpty(structureMap.get("查房日期"))) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //不能简单的标准转化,如果有查房标题,优先使用
|
|
|
+ if (StringUtils.isEmpty(structureMap.get("查房标题")) && StringUtils.isNotEmpty(structureMap.get("查房备注"))) {
|
|
|
+ structureMap.put("查房标题", structureMap.get("查房备注"));
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(structureMap.get("查房标题")) && StringUtils.isNotEmpty(structureMap.get("查房类别"))) {
|
|
|
+ structureMap.put("查房标题", structureMap.get("查房类别"));
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(structureMap.get("查房标题")) && StringUtils.isNotEmpty(structureMap.get("上级查房医生职称"))) {
|
|
|
+ structureMap.put("查房标题", structureMap.get("上级查房医生职称"));
|
|
|
+ }
|
|
|
}
|
|
|
//总的查房记录 汇总
|
|
|
ThreeLevelWardDoc allDoctorWradDoc = new ThreeLevelWardDoc();
|
|
@@ -107,14 +112,15 @@ public class TaiZhouThreeLevelWardDocTrans extends ModelDocTrans {
|
|
|
private DirectorDoctorWardDoc findDirectorDoctorWardDoc(Map<String, String> structureMap) {
|
|
|
String title = structureMap.get("查房标题");
|
|
|
String recordDateStr = structureMap.get("查房日期");
|
|
|
+ String chiefSurgeon = structureMap.get("主刀医师");
|
|
|
Date recordDate = StringUtil.parseDateTime(recordDateStr);
|
|
|
DirectorDoctorWardDoc directorDoctorWardDoc = null;
|
|
|
if (StringUtils.isNotEmpty(title)) {
|
|
|
if (title.contains("主刀")) {
|
|
|
- String doctorTitle = getDoctorTitle(operationDocs, recordDate, "主刀医师");
|
|
|
+ String doctorTitle = getDoctorTitle(chiefSurgeon, operationDocs, recordDate, "主刀医师");
|
|
|
title = title.replace("主刀", doctorTitle);
|
|
|
} else if (title.contains("一助")) {
|
|
|
- String doctorTitle = getDoctorTitle(operationDocs, recordDate, "一助");
|
|
|
+ String doctorTitle = getDoctorTitle(chiefSurgeon, operationDocs, recordDate, "一助");
|
|
|
title = title.replace("一助", doctorTitle);
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(subTitle(title)) && subTitle(title).contains("主任")) { //标题有代字)
|
|
@@ -134,14 +140,15 @@ public class TaiZhouThreeLevelWardDocTrans extends ModelDocTrans {
|
|
|
private AttendingDoctorWardDoc findAttendingDoctorWardDoc(Map<String, String> structureMap) {
|
|
|
String title = structureMap.get("查房标题");
|
|
|
String recordDateStr = structureMap.get("查房日期");
|
|
|
+ String chiefSurgeon = structureMap.get("主刀医师");
|
|
|
Date recordDate = StringUtil.parseDateTime(recordDateStr);
|
|
|
AttendingDoctorWardDoc attendingDoctorWardDoc = null;
|
|
|
if (StringUtils.isNotEmpty(title)) {
|
|
|
if (title.contains("主刀")) {
|
|
|
- String doctorTitle = getDoctorTitle(operationDocs, recordDate, "主刀医师");
|
|
|
+ String doctorTitle = getDoctorTitle(chiefSurgeon, operationDocs, recordDate, "主刀医师");
|
|
|
title = title.replace("主刀", doctorTitle);
|
|
|
} else if (title.contains("一助")) {
|
|
|
- String doctorTitle = getDoctorTitle(operationDocs, recordDate, "一助");
|
|
|
+ String doctorTitle = getDoctorTitle(chiefSurgeon, operationDocs, recordDate, "一助");
|
|
|
title = title.replace("一助", doctorTitle);
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(subTitle(title)) && subTitle(title).contains("主治")) { //标题有代字)
|
|
@@ -162,10 +169,26 @@ public class TaiZhouThreeLevelWardDocTrans extends ModelDocTrans {
|
|
|
);
|
|
|
|
|
|
public static String subTitle(String srcText) {
|
|
|
- if (StringUtil.isNotBlank(srcText) && srcText.contains("代") && srcText.indexOf("代") != srcText.length() - 1) {
|
|
|
- srcText = srcText.substring(srcText.lastIndexOf("代") + 1);
|
|
|
+ String title = "";
|
|
|
+ if (StringUtil.isNotBlank(srcText)) {
|
|
|
+ //标题不包含代字,直接返回原标题
|
|
|
+ if (!srcText.contains("代")) {
|
|
|
+ return srcText;
|
|
|
+ }
|
|
|
+ //有携、兼字时,取携、兼字之前部分
|
|
|
+ if (srcText.contains("携")) {
|
|
|
+ title += srcText.substring(0, srcText.indexOf("携"));
|
|
|
+ } else if (srcText.contains("兼")) {
|
|
|
+ title += srcText.substring(0, srcText.indexOf("兼"));
|
|
|
+ }
|
|
|
+ //有代字时,取代字之后部分
|
|
|
+ if (srcText.contains("代") && srcText.indexOf("代") != srcText.length() - 1) {
|
|
|
+ title += srcText.substring(srcText.lastIndexOf("代") + 1);
|
|
|
+ } else {
|
|
|
+ return srcText;
|
|
|
+ }
|
|
|
}
|
|
|
- return srcText;
|
|
|
+ return title;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -174,16 +197,63 @@ public class TaiZhouThreeLevelWardDocTrans extends ModelDocTrans {
|
|
|
* @param operationDocs
|
|
|
* @return
|
|
|
*/
|
|
|
- public static String getDoctorTitle(List<OperationDoc> operationDocs, Date recordDate, String findTitle) {
|
|
|
+ public static String getDoctorTitle(String chiefSurgeonFromWard, List<OperationDoc> operationDocs, Date recordDate, String findTitle) {
|
|
|
String title = "";
|
|
|
SpecialStorageUtil specialStorageUtil = SpringContextUtil.getBean("specialStorageUtil");
|
|
|
Map<String, Object> surgeon = specialStorageUtil.getJsonStringValue(KernelConstants.HOSPITAL_DOCTOR_MAP);
|
|
|
if (surgeon == null) {
|
|
|
return title;
|
|
|
}
|
|
|
+ //如果查房记录中有主刀医师姓名,直接用这个姓名获取对应职称
|
|
|
+ if (StringUtil.isNotBlank(chiefSurgeonFromWard)) {
|
|
|
+ Map<String, String> doctor = (Map) surgeon.get(chiefSurgeonFromWard);
|
|
|
+ if (doctor != null) {
|
|
|
+ title = doctor.get("professor");
|
|
|
+ if (StringUtil.isNotBlank(title)) {
|
|
|
+ return title;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //只有术前小结,没有手术记录情况下,直接取术前小结的医师姓名
|
|
|
+ long operationCount = operationDocs.stream().map(OperationDoc::getOperationRecordDoc).filter(Objects::nonNull).count();
|
|
|
+ long preoperativeCount = operationDocs.stream().map(OperationDoc::getPreoperativeDiscussionDoc).filter(Objects::nonNull).count();
|
|
|
+ if (operationCount == 0 && preoperativeCount > 0) {
|
|
|
+ long timeDiff = 0L;
|
|
|
+ List<PreoperativeDiscussionDoc> preoperativeDoc = operationDocs.stream().map(OperationDoc::getPreoperativeDiscussionDoc).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ for (PreoperativeDiscussionDoc doc : preoperativeDoc) {
|
|
|
+ Map<String, String> structureMap = doc.getStructureMap();
|
|
|
+ String chiefSurgeon = structureMap.get(findTitle + "签名");
|
|
|
+ String operatorEndDateStr = structureMap.get("主刀医师签字时间");
|
|
|
+ if (StringUtil.isBlank(chiefSurgeon) || StringUtil.isBlank(operatorEndDateStr)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map<String, String> doctor = (Map) surgeon.get(chiefSurgeon);
|
|
|
+ if (doctor != null) {
|
|
|
+ String professor = doctor.get("professor");
|
|
|
+ Date operatorEndDate = StringUtil.parseDateTime(operatorEndDateStr);
|
|
|
+ if (operatorEndDate != null) {
|
|
|
+ long timeDifference = timeDifference(operatorEndDate, recordDate);
|
|
|
+ if (timeDifference == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (timeDiff == 0 || timeDiff > timeDifference) {
|
|
|
+ /* 取距离此次主刀医师查房最近的一次术前讨论时间 */
|
|
|
+ timeDiff = timeDifference;
|
|
|
+ title = professor;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotBlank(title)) {
|
|
|
+ return title;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/* 用于存放手术结束时间距离查房时间最近的一次时间差 */
|
|
|
long timeDiff = 0L;
|
|
|
- for (OperationDoc operationDoc : operationDocs) {
|
|
|
+ for (
|
|
|
+ OperationDoc operationDoc : operationDocs) {
|
|
|
OperationRecordDoc operationRecordDoc = operationDoc.getOperationRecordDoc();
|
|
|
if (operationRecordDoc == null) {
|
|
|
continue;
|