|
@@ -1,18 +1,25 @@
|
|
package com.lantone.qc.kernel.catalogue.threelevelward;
|
|
package com.lantone.qc.kernel.catalogue.threelevelward;
|
|
|
|
|
|
|
|
+import com.google.common.collect.Lists;
|
|
import com.lantone.qc.kernel.catalogue.QCCatalogue;
|
|
import com.lantone.qc.kernel.catalogue.QCCatalogue;
|
|
|
|
+import com.lantone.qc.kernel.util.RegexUtil;
|
|
import com.lantone.qc.pub.model.InputInfo;
|
|
import com.lantone.qc.pub.model.InputInfo;
|
|
import com.lantone.qc.pub.model.OutputInfo;
|
|
import com.lantone.qc.pub.model.OutputInfo;
|
|
-import com.lantone.qc.pub.model.doc.DoctorAdviceDoc;
|
|
|
|
|
|
+import com.lantone.qc.pub.model.doc.FirstPageRecordDoc;
|
|
|
|
+import com.lantone.qc.pub.model.doc.MedicalRecordInfoDoc;
|
|
import com.lantone.qc.pub.model.doc.ThreeLevelWardDoc;
|
|
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.OperationDoc;
|
|
|
|
+import com.lantone.qc.pub.model.doc.operation.OperationRecordDoc;
|
|
import com.lantone.qc.pub.util.DateUtil;
|
|
import com.lantone.qc.pub.util.DateUtil;
|
|
|
|
+import com.lantone.qc.pub.util.ListUtil;
|
|
import com.lantone.qc.pub.util.StringUtil;
|
|
import com.lantone.qc.pub.util.StringUtil;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @ClassName : THR03090
|
|
* @ClassName : THR03090
|
|
@@ -23,66 +30,193 @@ import java.util.Objects;
|
|
@Component
|
|
@Component
|
|
public class THR03090 extends QCCatalogue {
|
|
public class THR03090 extends QCCatalogue {
|
|
public void start(InputInfo inputInfo, OutputInfo outputInfo) {
|
|
public void start(InputInfo inputInfo, OutputInfo outputInfo) {
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ * 1.判断病历中是否存在【手术记录】,若存在则继续,否则通过
|
|
|
|
+ * 2.获取【手术记录】的【手术时间/手术日期】,若结构数据标签不存在获取【手术开始时间/手术开始日期】,不存在非未填写。
|
|
|
|
+ * 3.用取到的手术日期判断与【住院信息表/病案首页]中的【入院日期/入院时间】为同一天,则此手术记录不做判断直接通过。
|
|
|
|
+ * 4.用取到的手术日期往前两天内查找【查房记录】,判断查房记录的标题是否含有【术前】和【主刀】若存在则通过。
|
|
|
|
+ * 5.若不存在,5.1获取【手术记录】中【主刀医师/主刀】结构数据;从手术日期往前两天内查找查房记录,判断查房记录的标题是否含有【主刀医师/主刀】真实姓名,若存在则通过。结构数据未填写还以第四步为准。
|
|
|
|
+ * 5.2若手术记录中没有【主刀医师/主刀】结构数据,获取【手术人员/手术者及助手名称】结构数据中填写的第一个姓名为主刀医师。结构数据未填写还以第四步为准。获取时需要分离带职称(主任/副主任/主治/住院/副教授/教授/研究生/总住院/进修医/住培医)和多余特殊符号后对比】
|
|
|
|
+ * 6.手术日期未取到,判断整份病历查房记录的标题是否含有【术前】和【主刀】若存在则通过。
|
|
|
|
+ */
|
|
|
|
+
|
|
status.set("0");
|
|
status.set("0");
|
|
List<ThreeLevelWardDoc> threeLevelWardDocs = inputInfo.getThreeLevelWardDocs();
|
|
List<ThreeLevelWardDoc> threeLevelWardDocs = inputInfo.getThreeLevelWardDocs();
|
|
- long cou = inputInfo.getOperationDocs().stream().map(OperationDoc::getOperationRecordDoc).filter(Objects::nonNull).count();
|
|
|
|
- if (cou == 0) {
|
|
|
|
|
|
+ List<OperationDoc> operationDocs = inputInfo.getOperationDocs();
|
|
|
|
+ FirstPageRecordDoc firstPageRecordDoc = inputInfo.getFirstPageRecordDoc();
|
|
|
|
+ MedicalRecordInfoDoc medicalRecordInfoDoc = inputInfo.getMedicalRecordInfoDoc();
|
|
|
|
+ //记录缺少术前查房记录的手术记录
|
|
|
|
+ List<OperationRecordDoc> unList = Lists.newArrayList();
|
|
|
|
+
|
|
|
|
+ if (operationDocs == null || operationDocs.size() == 0) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- if (threeLevelWardDocs.size() == 0 && cou > 0) {
|
|
|
|
- status.set("-1");
|
|
|
|
|
|
+
|
|
|
|
+ List<OperationRecordDoc> operationRecordDocs = operationDocs.stream()
|
|
|
|
+ .map(OperationDoc::getOperationRecordDoc)
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ if (ListUtil.isEmpty(operationRecordDocs)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- List<OperationDoc> operationDocs = inputInfo.getOperationDocs();
|
|
|
|
- if (operationDocs == null || operationDocs.size() == 0) {
|
|
|
|
- return;
|
|
|
|
|
|
+
|
|
|
|
+ Date beDate = null;
|
|
|
|
+ Date beDate_hp = null;
|
|
|
|
+ if (StringUtil.isNotBlank(medicalRecordInfoDoc.getStructureMap().get("behospitalDate"))) {
|
|
|
|
+ beDate = DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(medicalRecordInfoDoc.getStructureMap().get("behospitalDate")));
|
|
}
|
|
}
|
|
- String operationStartDate = "";
|
|
|
|
- if (operationDocs.get(operationDocs.size() - 1).getOperationRecordDoc() != null) {
|
|
|
|
- Map<String, String> operationDocStructureMap = operationDocs.get(operationDocs.size() - 1).getOperationRecordDoc().getStructureMap();
|
|
|
|
- operationStartDate = operationDocStructureMap.get("手术开始时间");
|
|
|
|
- if (operationStartDate.contains("年月日")) {
|
|
|
|
- operationStartDate = DateUtil.nowString();
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ if (StringUtil.isNotBlank(firstPageRecordDoc.getStructureMap().get("入院时间"))) {
|
|
|
|
+ beDate_hp = DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(firstPageRecordDoc.getStructureMap().get("入院时间")));
|
|
}
|
|
}
|
|
|
|
|
|
- if (StringUtil.isBlank(operationStartDate) || StringUtil.parseDateTime(operationStartDate) == null) {
|
|
|
|
|
|
+ //筛选手术日期不等于入院日期的手术记录
|
|
|
|
+ Date finalBeDate_hp = beDate_hp;
|
|
|
|
+ Date finalBeDate = beDate;
|
|
|
|
+ List<OperationRecordDoc> filterOperationRecordDocs = operationRecordDocs.stream().filter(i -> i.getStructureMap() != null
|
|
|
|
+ && filterDate(i.getStructureMap()) != null
|
|
|
|
+ && (DateUtil.getFirstTimeOfDay(filterDate(i.getStructureMap())).getTime() != finalBeDate.getTime()
|
|
|
|
+ || DateUtil.getFirstTimeOfDay(filterDate(i.getStructureMap())).getTime() != finalBeDate_hp.getTime()))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ if (ListUtil.isEmpty(filterOperationRecordDocs)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- List<ThreeLevelWardDoc> allDoctorWradDocs = threeLevelWardDocs.get(0).getAllDoctorWradDocs();
|
|
|
|
- for (ThreeLevelWardDoc threeLevelWard : allDoctorWradDocs) {
|
|
|
|
- Map<String, String> structureMap = threeLevelWard.getStructureMap();
|
|
|
|
- String makeTitle = structureMap.get("查房标题");
|
|
|
|
- String writTitle = structureMap.get("文书标题");
|
|
|
|
- String makeDate = structureMap.get("查房日期");
|
|
|
|
- if (StringUtil.isNotBlank(makeDate) && StringUtil.parseDateTime(makeDate).before(StringUtil.parseDateTime(operationStartDate))) {
|
|
|
|
- if (((StringUtil.isNotBlank(makeTitle) && makeTitle.contains("主刀")) || (StringUtil.isNotBlank(writTitle) && writTitle.contains("主刀"))
|
|
|
|
- || ((StringUtil.isNotBlank(makeTitle) && makeTitle.contains("术前")) || (StringUtil.isNotBlank(writTitle) && writTitle.contains("术前"))))) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ List<ThreeLevelWardDoc> allThreeLevelWardDocs = Lists.newArrayList();
|
|
|
|
+ if (ListUtil.isNotEmpty(threeLevelWardDocs)) {
|
|
|
|
+ allThreeLevelWardDocs = threeLevelWardDocs.stream()
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
+ .filter(i -> ListUtil.isNotEmpty(i.getAllDoctorWradDocs()))
|
|
|
|
+ .flatMap(i -> i.getAllDoctorWradDocs().stream())
|
|
|
|
+ .distinct()
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ } else {
|
|
|
|
+ status.set("-1");
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
- //判断医嘱里有无手术
|
|
|
|
- List<DoctorAdviceDoc> doctorAdviceDocs = inputInfo.getDoctorAdviceDocs();
|
|
|
|
- if (doctorAdviceDocs.size() == 0) {
|
|
|
|
|
|
+ if (ListUtil.isEmpty(allThreeLevelWardDocs)) {
|
|
|
|
+ status.set("-1");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- for (DoctorAdviceDoc dad : doctorAdviceDocs) {
|
|
|
|
- String name = dad.getStructureMap().get("医嘱项目名称");
|
|
|
|
- if (name.contains("非手术") || name.contains("手术室") || (name.contains("手术") && name.contains("取消")) || (name.contains("暂停") && name.contains("手术")) || name.contains("静脉穿刺置管术") || name.startsWith("停") || name.contains("前一次")
|
|
|
|
- || name.contains("特殊病人手术使用一次性卫生材料") || name.contains("人免疫缺陷病毒抗体检测免费")) {
|
|
|
|
- continue;
|
|
|
|
|
|
+
|
|
|
|
+ for (OperationRecordDoc recordDoc : filterOperationRecordDocs) {
|
|
|
|
+ Date opDate = filterDate(recordDoc.getStructureMap());
|
|
|
|
+ Boolean isExist = false;
|
|
|
|
+ for (ThreeLevelWardDoc threeLevelWard : allThreeLevelWardDocs) {
|
|
|
|
+ Map<String, String> structureMap = threeLevelWard.getStructureMap();
|
|
|
|
+ String makeTitle = structureMap.get("查房标题");
|
|
|
|
+ String writTitle = structureMap.get("文书标题");
|
|
|
|
+ String makeDate = structureMap.get("查房日期");
|
|
|
|
+ if (StringUtil.isNotBlank(makeDate)
|
|
|
|
+ && StringUtil.parseDateTime(makeDate).before(opDate)
|
|
|
|
+ && StringUtil.parseDateTime(makeDate).after(DateUtil.addDay(DateUtil.getFirstTimeOfDay(opDate), -2))) {
|
|
|
|
+ //查房记录的标题是否含有【术前】和【主刀】
|
|
|
|
+ if (((StringUtil.isNotBlank(makeTitle) && makeTitle.contains("主刀")) || (StringUtil.isNotBlank(writTitle) && writTitle.contains("主刀")))
|
|
|
|
+ && ((StringUtil.isNotBlank(makeTitle) && makeTitle.contains("术前")) || (StringUtil.isNotBlank(writTitle) && writTitle.contains("术前")))) {
|
|
|
|
+ isExist = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //【主刀医师/主刀】结构数据
|
|
|
|
+ String operatorName = recordDoc.getStructureMap().get("主刀医师");
|
|
|
|
+ if (StringUtil.isBlank(operatorName)) {
|
|
|
|
+ operatorName = recordDoc.getStructureMap().get("主刀");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //获取【手术人员/手术者及助手名称】
|
|
|
|
+ if (StringUtil.isBlank(operatorName)) {
|
|
|
|
+ String operatorNames = recordDoc.getStructureMap().get("手术人员");
|
|
|
|
+ if (StringUtil.isBlank(operatorNames)) {
|
|
|
|
+ operatorNames = recordDoc.getStructureMap().get("手术者及助手名称");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtil.isNotBlank(operatorNames)) {
|
|
|
|
+ operatorNames = operatorNames.replaceAll("、|;", " ")
|
|
|
|
+ .replaceAll(":|:", "=");
|
|
|
|
+ String[] operatorNameArr = operatorNames.split(" ");
|
|
|
|
+ if (operatorNameArr.length > 0) {
|
|
|
|
+ String[] ky = operatorNameArr[0].split("=");
|
|
|
|
+ if (ky.length > 1) {
|
|
|
|
+ operatorName = ky[1].trim();
|
|
|
|
+ } else {
|
|
|
|
+ operatorName = operatorNameArr[0].trim();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //主任/副主任/主治/住院/副教授/教授/研究生/总住院/进修医/住培医
|
|
|
|
+ if (StringUtil.isNotBlank(operatorName)) {
|
|
|
|
+ operatorName = operatorName.trim().replaceAll("主任|副主任|主治|住院|副教授|教授|研究生|总住院|进修医|住培医", "");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //查房记录的标题是否含有【主刀医师/主刀】真实姓名
|
|
|
|
+ if (StringUtil.isNotBlank(operatorName)) {
|
|
|
|
+ if (StringUtil.isNotBlank(makeTitle) && makeTitle.contains(operatorName)
|
|
|
|
+ || StringUtil.isNotBlank(writTitle) && writTitle.contains(operatorName)) {
|
|
|
|
+ isExist = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- if (name.contains("手术")) {
|
|
|
|
- status.set("-1");
|
|
|
|
|
|
+ //没有查房记录或没有术前两天内查房记录
|
|
|
|
+ if (!isExist) {
|
|
|
|
+ unList.add(recordDoc);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //手术日期未取到,判断整份病历查房记录的标题是否含有【术前】和【主刀】若存在则通过
|
|
|
|
+ filterOperationRecordDocs = operationRecordDocs.stream().filter(i -> i.getStructureMap() != null
|
|
|
|
+ && filterDate(i.getStructureMap()) != null)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ if (ListUtil.isEmpty(filterOperationRecordDocs)) {
|
|
|
|
+ List<ThreeLevelWardDoc> threeLevelWardDocList = threeLevelWardDocs.stream().filter(i -> i.getStructureMap() != null
|
|
|
|
+ && (StringUtil.isNotBlank(i.getStructureMap().get("查房标题")) && RegexUtil.getRegexRes(i.getStructureMap().get("查房标题"), "术前|主刀")
|
|
|
|
+ || StringUtil.isNotBlank(i.getStructureMap().get("文书标题")) && RegexUtil.getRegexRes(i.getStructureMap().get("文书标题"), "术前|主刀")))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ if (ListUtil.isNotEmpty(threeLevelWardDocList)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (cou > 0) {
|
|
|
|
|
|
+ if (ListUtil.isNotEmpty(unList)) {
|
|
status.set("-1");
|
|
status.set("-1");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取【手术记录】的【手术时间/手术日期】,若结构数据标签不存在获取【手术开始时间/手术开始日期】,不存在非未填写。
|
|
|
|
+ */
|
|
|
|
+ public Date filterDate(Map<String, String> structureMap) {
|
|
|
|
+ String strDate = "";
|
|
|
|
+ if (structureMap.containsKey("手术时间")) {
|
|
|
|
+ strDate = structureMap.get("手术时间");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtil.isBlank(strDate)
|
|
|
|
+ && structureMap.containsKey("手术日期")) {
|
|
|
|
+ strDate = structureMap.get("手术日期");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (StringUtil.isBlank(strDate)
|
|
|
|
+ && !structureMap.containsKey("手术时间")
|
|
|
|
+ && !structureMap.containsKey("手术日期")) {
|
|
|
|
+
|
|
|
|
+ if (structureMap.containsKey("手术开始时间")) {
|
|
|
|
+ strDate = structureMap.get("手术开始时间");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtil.isBlank(strDate)
|
|
|
|
+ && structureMap.containsKey("手术开始日期")) {
|
|
|
|
+ strDate = structureMap.get("手术开始日期");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (StringUtil.isNotBlank(strDate)) {
|
|
|
|
+ return StringUtil.parseDateTime(strDate);
|
|
|
|
+ } else {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|