|
@@ -14,7 +14,6 @@ import com.lantone.qc.pub.model.doc.operation.OperationDiscussionDoc;
|
|
|
import com.lantone.qc.pub.model.doc.operation.OperationDoc;
|
|
|
import com.lantone.qc.pub.model.doc.operation.OperationRecordDoc;
|
|
|
import com.lantone.qc.pub.model.entity.Drug;
|
|
|
-import com.lantone.qc.pub.model.label.ThreeLevelWardLabel;
|
|
|
import com.lantone.qc.pub.util.DateUtil;
|
|
|
import com.lantone.qc.pub.util.StringUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -28,7 +27,7 @@ import java.util.stream.Collectors;
|
|
|
/**
|
|
|
* @ClassName : THR02985
|
|
|
* @Description : 医嘱有抗生素使用病程无记录
|
|
|
- * 药品类型(0.普药 1.抗生素 2.抗生素)
|
|
|
+ * 药品类型(0.普药 1.抗生素 2.激素)
|
|
|
* @Author : 胡敬
|
|
|
* @Date: 2020-06-23 10:04
|
|
|
*/
|
|
@@ -50,6 +49,7 @@ public class THR02985 extends QCCatalogue {
|
|
|
SimilarityUtil similarityUtil;
|
|
|
|
|
|
public void start(InputInfo inputInfo, OutputInfo outputInfo) {
|
|
|
+ status.set("0");
|
|
|
List<DoctorAdviceDoc> doctorAdviceDocs = inputInfo.getDoctorAdviceDocs();
|
|
|
List<ThreeLevelWardDoc> threeLevelWardDocs = inputInfo.getThreeLevelWardDocs();
|
|
|
FirstCourseRecordDoc firstCourseRecordDoc = inputInfo.getFirstCourseRecordDoc();
|
|
@@ -58,12 +58,10 @@ public class THR02985 extends QCCatalogue {
|
|
|
LeaveHospitalDoc leaveHospitalDoc = inputInfo.getLeaveHospitalDoc();
|
|
|
List<ConsultationDoc> consultationDocs = inputInfo.getConsultationDocs();
|
|
|
if (doctorAdviceDocs.size() == 0 || threeLevelWardDocs.size() == 0) {
|
|
|
- status.set("0");
|
|
|
return;
|
|
|
}
|
|
|
List<ThreeLevelWardDoc> allDoctorWradDocs = threeLevelWardDocs.get(0).getAllDoctorWradDocs();
|
|
|
if (allDoctorWradDocs.size() == 0) {
|
|
|
- status.set("0");
|
|
|
return;
|
|
|
}
|
|
|
Map<Date, String> doctorAdviceDrugMap = Maps.newLinkedHashMap();
|
|
@@ -91,52 +89,78 @@ public class THR02985 extends QCCatalogue {
|
|
|
}
|
|
|
|
|
|
Map<String, Date> info = Maps.newLinkedHashMap();
|
|
|
+ Map<String, List<Drug>> infoModel = Maps.newLinkedHashMap();
|
|
|
+ String dateStr = null;
|
|
|
//入院记录中获取信息
|
|
|
- if (beHospitalizedDoc != null) {
|
|
|
+ /*if (beHospitalizedDoc != null) {
|
|
|
Map<String, String> structureMap = beHospitalizedDoc.getStructureMap();
|
|
|
getInfo(info, structureMap, "入院记录", "入院日期", "治疗计划");
|
|
|
- }
|
|
|
+ }*/
|
|
|
//从首程治疗计划中获取信息
|
|
|
if (firstCourseRecordDoc != null) {
|
|
|
- Map<String, String> structureMap = firstCourseRecordDoc.getStructureMap();
|
|
|
- getInfo(info, structureMap, "首次病程录", "记录时间", "治疗计划");
|
|
|
+ getInfo(info, firstCourseRecordDoc.getStructureMap(), "首次病程录", "记录时间", "治疗计划");
|
|
|
+ if (firstCourseRecordDoc.getDrugLabel() != null) {
|
|
|
+ List<Drug> drugs = firstCourseRecordDoc.getDrugLabel().getDrugs();
|
|
|
+ dateStr = firstCourseRecordDoc.getStructureMap().get("记录时间");
|
|
|
+ if (StringUtil.isNotBlank(dateStr)) {
|
|
|
+ getInfo(infoModel, dateStr, drugs);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ //从查房记录中获取信息
|
|
|
+ List<ThreeLevelWardDoc> wardDocs = allDoctorWradDocs
|
|
|
+ .stream()
|
|
|
+ .filter(x -> StringUtil.isNotBlank(x.getStructureMap().get("查房日期")) && x.getThreeLevelWardLabel().size() > 0)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ wardDocs.forEach(x -> getInfo(info, x.getStructureMap(), "查房记录", "查房日期", "病情记录", "治疗计划和措施"));
|
|
|
+ wardDocs.forEach(x -> getInfo(infoModel, x.getStructureMap().get("查房日期"), x.getThreeLevelWardLabel().get(x.getThreeLevelWardLabel().size() - 1).getDrugs()));
|
|
|
+
|
|
|
//从手术记录中获取信息
|
|
|
if (operationDocs.size() > 0) {
|
|
|
//手术记录
|
|
|
- List<Map<String, String>> operationRecordStructMap = operationDocs
|
|
|
+ List<OperationRecordDoc> operationRecordDocs = operationDocs
|
|
|
.stream()
|
|
|
.map(OperationDoc::getOperationRecordDoc)
|
|
|
.filter(Objects::nonNull)
|
|
|
- .map(OperationRecordDoc::getStructureMap)
|
|
|
+ .filter(x -> x.getOperationRecordLabel() != null && StringUtil.isNotBlank(x.getStructureMap().get("病历日期")))
|
|
|
.collect(Collectors.toList());
|
|
|
- operationRecordStructMap.forEach(x -> getInfo(info, x, "手术记录", "病历日期", "手术经过"));
|
|
|
+ operationRecordDocs.forEach(x -> getInfo(info, x.getStructureMap(), "手术记录", "病历日期", "手术经过"));
|
|
|
+ operationRecordDocs.forEach(x -> getInfo(infoModel, x.getStructureMap().get("病历日期"), x.getOperationRecordLabel().getDrugs()));
|
|
|
//术后首程
|
|
|
- List<Map<String, String>> operationDiscussionStructMap = operationDocs
|
|
|
+ List<OperationDiscussionDoc> operationDiscussionDocs = operationDocs
|
|
|
.stream()
|
|
|
.map(OperationDoc::getOperationDiscussionDoc)
|
|
|
.filter(Objects::nonNull)
|
|
|
- .map(OperationDiscussionDoc::getStructureMap)
|
|
|
+ .filter(x -> x.getOperationDiscussionLabel() != null && StringUtil.isNotBlank(x.getStructureMap().get("记录日期")))
|
|
|
.collect(Collectors.toList());
|
|
|
- operationDiscussionStructMap.forEach(x -> getInfo(info, x, "术后首程", "记录日期", "手术经过", "治疗计划和措施"));
|
|
|
+ operationDiscussionDocs.forEach(x -> getInfo(info, x.getStructureMap(), "术后首程", "记录日期", "手术经过", "治疗计划和措施"));
|
|
|
+ operationDiscussionDocs.forEach(x -> getInfo(infoModel, x.getStructureMap().get("记录日期"), x.getOperationDiscussionLabel().getDrugs()));
|
|
|
}
|
|
|
|
|
|
//从会诊记录中获取信息
|
|
|
if (consultationDocs.size() > 0) {
|
|
|
- List<Map<String, String>> consultationResultStructMap = consultationDocs
|
|
|
+ List<ConsultationResultsDoc> consultationResultsDocs = consultationDocs
|
|
|
.stream()
|
|
|
.map(ConsultationDoc::getConsultationResultsDoc)
|
|
|
.filter(Objects::nonNull)
|
|
|
- .map(ConsultationResultsDoc::getStructureMap)
|
|
|
+ .filter(x -> x.getConsultationResultLabel() != null && StringUtil.isNotBlank(x.getStructureMap().get("会诊日期及时间")))
|
|
|
.collect(Collectors.toList());
|
|
|
- consultationResultStructMap.forEach(x -> getInfo(info, x, "会诊结果单", "会诊日期及时间", "会诊意见"));
|
|
|
+ consultationResultsDocs.forEach(x -> getInfo(info, x.getStructureMap(), "会诊结果单", "会诊日期及时间", "会诊意见"));
|
|
|
+ consultationResultsDocs.forEach(x -> getInfo(infoModel, x.getStructureMap().get("会诊日期及时间"), x.getConsultationResultLabel().getDrugs()));
|
|
|
}
|
|
|
|
|
|
//从出院小结中获取信息
|
|
|
if (leaveHospitalDoc != null) {
|
|
|
- Map<String, String> structureMap = leaveHospitalDoc.getStructureMap();
|
|
|
- getInfo(info, structureMap, "出院小结", "出院时间", "诊治经过", "出院带药");
|
|
|
+ getInfo(info, leaveHospitalDoc.getStructureMap(), "出院小结", "出院时间", "诊治经过", "出院带药");
|
|
|
+ if (leaveHospitalDoc.getLeaveHospitalLabel() != null) {
|
|
|
+ List<Drug> drugs = leaveHospitalDoc.getLeaveHospitalLabel().getDrugs();
|
|
|
+ dateStr = leaveHospitalDoc.getStructureMap().get("出院时间");
|
|
|
+ if (StringUtil.isNotBlank(dateStr)) {
|
|
|
+ getInfo(info, leaveHospitalDoc.getStructureMap(), "出院小结", "出院时间", "诊治经过", "出院带药");
|
|
|
+ getInfo(infoModel, dateStr, drugs);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
String infoStr = "";
|
|
@@ -144,12 +168,9 @@ public class THR02985 extends QCCatalogue {
|
|
|
Date doctorAdviceDate = doctorAdviceDrug.getKey();
|
|
|
String drugs = doctorAdviceDrug.getValue();
|
|
|
drugs = removeBracket(drugs).replaceAll("[^\u4e00-\u9fa5]", "");
|
|
|
- String drugStandardWord = similarityUtil.getDrugStandardWord(drugs);
|
|
|
- if (StringUtil.isNotBlank(drugStandardWord)) {
|
|
|
- drugs = drugStandardWord;
|
|
|
- }
|
|
|
Set<String> splitDrugs = CatalogueUtil.getRegexWords(drugs, "[((\\[][^\\[\\]()()]+[\\]))]")
|
|
|
.stream().filter(x -> !x.equals("合资") && !x.equals("进口") && !x.equals("国产")).collect(Collectors.toSet());
|
|
|
+ /**********************************************先文本匹配************************************************/
|
|
|
String missDrug = "";
|
|
|
for (Map.Entry<String, Date> map : info.entrySet()) {
|
|
|
missDrug = getMissDrug(map.getKey(), map.getValue(), doctorAdviceDate, splitDrugs, 2, missDrug);
|
|
@@ -161,57 +182,36 @@ public class THR02985 extends QCCatalogue {
|
|
|
if (StringUtil.isBlank(missDrug)) {
|
|
|
continue;
|
|
|
}
|
|
|
+ /**********************************************文本匹配没有找到药,再走模型************************************************/
|
|
|
boolean modelFind = false;
|
|
|
- int wardNum = 0;
|
|
|
- for (ThreeLevelWardDoc threeLevelWardDoc : allDoctorWradDocs) {
|
|
|
- /*****************纯文本匹配******************/
|
|
|
- Map<String, String> wardDocStructureMap = threeLevelWardDoc.getStructureMap();
|
|
|
- String wardDateStr = wardDocStructureMap.get("查房日期");
|
|
|
- String content = wardDocStructureMap.get("病情记录") + wardDocStructureMap.get("治疗计划和措施");
|
|
|
- Date wardDate = StringUtil.parseDateTime(wardDateStr);
|
|
|
- missDrug = getMissDrug(content, wardDate, doctorAdviceDate, splitDrugs, 2, missDrug);
|
|
|
- //当前抗生素药(drugs)在查房记录中已找到,直接跳出当前查房记录的循环
|
|
|
- if ((doctorAdviceDate.before(wardDate) && !CatalogueUtil.compareTime(doctorAdviceDate, wardDate, 2 * 24 * 60L))
|
|
|
- || (wardDate.before(doctorAdviceDate) && !CatalogueUtil.compareTime(wardDate, doctorAdviceDate, 24 * 60L))) {
|
|
|
- /*****************药品相似度模型******************/
|
|
|
- List<ThreeLevelWardLabel> label = threeLevelWardDoc.getThreeLevelWardLabel();
|
|
|
- if (label.size() > 0) {
|
|
|
- List<Drug> drugList = label.get(0).getDrugs();
|
|
|
- for (Drug drug : drugList) {
|
|
|
- for (String adDrug : splitDrugs) {
|
|
|
- if (compareStandard(drug.getName(), adDrug)) {
|
|
|
- modelFind = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (modelFind) {
|
|
|
+ for (Map.Entry<String, List<Drug>> modelMap : infoModel.entrySet()) {
|
|
|
+ dateStr = modelMap.getKey();
|
|
|
+ List<Drug> diags = modelMap.getValue();
|
|
|
+ Date date = StringUtil.parseDateTime(dateStr);
|
|
|
+ //医嘱开始时间往后2天或往前一天找药
|
|
|
+ if ((doctorAdviceDate.before(date) && !CatalogueUtil.compareTime(doctorAdviceDate, date, 48 * 60L))
|
|
|
+ || (date.before(doctorAdviceDate) && !CatalogueUtil.compareTime(date, doctorAdviceDate, 24 * 60L))) {
|
|
|
+ for (String adDrug : splitDrugs) {
|
|
|
+ for (Drug courseDrug : diags) {
|
|
|
+ if (compareStandard(courseDrug.getName(), adDrug)) {
|
|
|
+ modelFind = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (StringUtil.isNotBlank(missDrug) && !modelFind) {//missDrug不为空,只有两种可能:1.确实是缺失的药 2.字符串为“时间不匹配”
|
|
|
- wardNum++; //当前所有查房记录都没找到药,该医嘱时间再与系统当前时间对比,若超过48小时则提示该药缺失
|
|
|
- }
|
|
|
- if (StringUtil.isBlank(missDrug) || modelFind) {
|
|
|
+ if (modelFind) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- //如果目前所有查房记录都没有
|
|
|
- if (wardNum == allDoctorWradDocs.size() && CatalogueUtil.compareTime(doctorAdviceDate, new Date(), 48 * 60L)) {
|
|
|
- infoStr = CatalogueUtil.concatInfo(infoStr, splitDrugs.toString().replaceAll("[\\[\\]]", "") + "(" + DateUtil.formatDate(doctorAdviceDate) + ")");
|
|
|
- continue;
|
|
|
- }
|
|
|
|
|
|
- if (StringUtil.isNotBlank(missDrug) && !"时间不匹配".equals(missDrug) && !modelFind) {
|
|
|
- infoStr = CatalogueUtil.concatInfo(infoStr, missDrug + "(" + DateUtil.formatDate(doctorAdviceDate) + ")");
|
|
|
+ if (StringUtil.isNotBlank(missDrug) && !modelFind && CatalogueUtil.compareTime(doctorAdviceDate, new Date(), 48 * 60L)) {
|
|
|
+ infoStr = CatalogueUtil.concatInfo(infoStr, splitDrugs.toString().replaceAll("[\\[\\]]", "") + "(" + DateUtil.formatDate(doctorAdviceDate) + ")");
|
|
|
}
|
|
|
}
|
|
|
if (StringUtil.isNotBlank(infoStr)) {
|
|
|
this.status.set("-1");
|
|
|
this.info.set(infoStr);
|
|
|
- } else {
|
|
|
- this.status.set("0");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -232,6 +232,14 @@ public class THR02985 extends QCCatalogue {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void getInfo(Map<String, List<Drug>> info, String dateKey, List<Drug> drugs) {
|
|
|
+ if (info.containsKey(dateKey)) {
|
|
|
+ info.get(dateKey).addAll(drugs);
|
|
|
+ } else {
|
|
|
+ info.put(dateKey, drugs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 核心:从文本中找药
|
|
|
*
|