|
@@ -0,0 +1,212 @@
|
|
|
+package com.lantone.qc.kernel.catalogue.threelevelward;
|
|
|
+
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.google.common.collect.Maps;
|
|
|
+import com.lantone.qc.kernel.catalogue.QCCatalogue;
|
|
|
+import com.lantone.qc.kernel.util.CatalogueUtil;
|
|
|
+import com.lantone.qc.kernel.util.SimilarityUtil;
|
|
|
+import com.lantone.qc.pub.model.InputInfo;
|
|
|
+import com.lantone.qc.pub.model.OutputInfo;
|
|
|
+import com.lantone.qc.pub.model.doc.DoctorAdviceDoc;
|
|
|
+import com.lantone.qc.pub.model.doc.ThreeLevelWardDoc;
|
|
|
+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;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author HUJING
|
|
|
+ * @create 2020-08-26 10:51
|
|
|
+ * @desc 医嘱与病程记录抗生素剂量不一致
|
|
|
+ **/
|
|
|
+@Component
|
|
|
+public class THR03076 extends QCCatalogue {
|
|
|
+ @Autowired
|
|
|
+ SimilarityUtil similarityUtil;
|
|
|
+
|
|
|
+ public void start(InputInfo inputInfo, OutputInfo outputInfo) {
|
|
|
+ status.set("0");
|
|
|
+ List<DoctorAdviceDoc> doctorAdviceDocs = inputInfo.getDoctorAdviceDocs();
|
|
|
+ List<ThreeLevelWardDoc> threeLevelWardDocs = inputInfo.getThreeLevelWardDocs();
|
|
|
+ if (doctorAdviceDocs.size() == 0 || threeLevelWardDocs.size() == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Map<String, String>> docAdvStruct = doctorAdviceDocs
|
|
|
+ .stream()
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .map(DoctorAdviceDoc::getStructureMap)
|
|
|
+ .filter(x -> StringUtil.isNotBlank(x.get("药品类型")) && x.get("药品类型").contains("抗生素") && StringUtil.isNotBlank(x.get("医嘱单次剂量")))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ //抗生素及开医嘱时间 <抗生素名,<抗生素用量,[抗生素使用时间...]>>
|
|
|
+ Map<String, Map<Double, List<String>>> antibioticInfo = Maps.newLinkedHashMap();
|
|
|
+ String drugName = null, value = null, startDateStr = null;
|
|
|
+ for (Map<String, String> structMap : docAdvStruct) {
|
|
|
+ drugName = structMap.get("医嘱项目名称");
|
|
|
+ value = structMap.get("医嘱单次剂量");
|
|
|
+ startDateStr = structMap.get("医嘱开始时间");
|
|
|
+ drugName = removeBracket(drugName);
|
|
|
+ String drugStandardWord = similarityUtil.getDrugStandardWord(drugName);
|
|
|
+ if (StringUtil.isNotBlank(drugStandardWord)) {
|
|
|
+ drugName = drugStandardWord;
|
|
|
+ }
|
|
|
+ collectAntibioticInfo(antibioticInfo, drugName, value, startDateStr);
|
|
|
+ }
|
|
|
+
|
|
|
+ //抗生素及开医嘱时间 <抗生素名,<抗生素用量,[抗生素使用时间...]>>
|
|
|
+ Map<String, Map<Double, List<String>>> antibioticWardInfo = Maps.newLinkedHashMap();
|
|
|
+ List<ThreeLevelWardDoc> allDoctorWradDocs = threeLevelWardDocs.get(0).getAllDoctorWradDocs();
|
|
|
+ for (ThreeLevelWardDoc doc : allDoctorWradDocs) {
|
|
|
+ if (doc.getThreeLevelWardLabel().size() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ ThreeLevelWardLabel label = doc.getThreeLevelWardLabel().get(0);
|
|
|
+ List<Drug> drugs = label.getDrugs();
|
|
|
+ for (Drug drug : drugs) {
|
|
|
+ String wardDrug = drug.getName();
|
|
|
+ wardDrug = removeBracket(wardDrug);
|
|
|
+ String drugStandardWord = similarityUtil.getDrugStandardWord(wardDrug);
|
|
|
+ if (StringUtil.isNotBlank(drugStandardWord)) {
|
|
|
+ wardDrug = drugStandardWord;
|
|
|
+ }
|
|
|
+ if (drug.getConsumption() != null) {
|
|
|
+ String consumption = drug.getConsumption().getName();
|
|
|
+ collectAntibioticInfo(antibioticWardInfo, wardDrug, consumption, doc.getStructureMap().get("查房日期"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 1.医嘱中开了抗生素,查房记录中没有该抗生素,则医嘱中该抗生素出现过的所有时间都会提示出来
|
|
|
+ * 2.医嘱中开了抗生素,查房记录中有该抗生素:
|
|
|
+ * 2.1 医嘱中该抗生素某使用量(如50),查房记录中没有该使用量(如只有100),则医嘱中该抗生素使用量出现过的所有时间都会提示出来
|
|
|
+ * 2.2 医嘱中该抗生素某使用量(如50),查房记录中也有该使用量,对比这两个时间,若医嘱时间两天内的查房记录没有该使用量,则该医嘱时间会提示出来
|
|
|
+ */
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ String drugKey = null;
|
|
|
+ for (Map.Entry<String, Map<Double, List<String>>> ai : antibioticInfo.entrySet()) {
|
|
|
+ drugKey = ai.getKey();
|
|
|
+ if (!antibioticWardInfo.containsKey(drugKey)) {
|
|
|
+ for (Map.Entry<Double, List<String>> ad : ai.getValue().entrySet()) {
|
|
|
+ for (String date : ad.getValue()) {
|
|
|
+ infoAppend(sb, drugKey, ad.getKey(), date);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Map<Double, List<String>> adValueDate = ai.getValue();
|
|
|
+ Map<Double, List<String>> wardValueDate = antibioticWardInfo.get(drugKey);
|
|
|
+ for (Map.Entry<Double, List<String>> adMap : adValueDate.entrySet()) {
|
|
|
+ Double adUsage = adMap.getKey();
|
|
|
+ List<String> adDateList = adMap.getValue();
|
|
|
+ if (wardValueDate.containsKey(adUsage)) {
|
|
|
+ int num = 0;
|
|
|
+ List<String> wardDateList = wardValueDate.get(adUsage);
|
|
|
+ for (String adDate : adDateList) {
|
|
|
+ for (String wardDate : wardDateList) {
|
|
|
+ if (!CatalogueUtil.compareTime(StringUtil.parseDateTime(adDate), StringUtil.parseDateTime(wardDate), 48 * 60L)) {
|
|
|
+ //如果医嘱中该药使用量的医嘱时间,两天内的查房记录中也有该用量,则找到,num+1
|
|
|
+ num++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (num == 0) {
|
|
|
+ infoAppend(sb, drugKey, adUsage, adDate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //遗嘱中该抗生素使用量在查房记录中没出现过,全部提示出来药品名+时间
|
|
|
+ for (String adDate : adDateList) {
|
|
|
+ infoAppend(sb, drugKey, adUsage, adDate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (sb.toString().length() > 0) {
|
|
|
+ status.set("-1");
|
|
|
+ info.set(sb.toString().substring(0, sb.toString().length() - 1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 拼接提示信息
|
|
|
+ *
|
|
|
+ * @param sb
|
|
|
+ * @param drugKey
|
|
|
+ * @param date
|
|
|
+ */
|
|
|
+ private void infoAppend(StringBuffer sb, String drugKey, double value, String date) {
|
|
|
+ sb.append(drugKey).append("->").append(value)
|
|
|
+ .append("(").append(DateUtil.formatDate(StringUtil.parseDateTime(date))).append(")").append(",");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 收集抗生素各种信息
|
|
|
+ *
|
|
|
+ * @param antibioticInfo 抗生素使用量及所有时间
|
|
|
+ * @param drugName 抗生素名称
|
|
|
+ * @param value 抗生素用量
|
|
|
+ * @param startDateStr 抗生素使用时间(医嘱开始时间或查房时间)
|
|
|
+ */
|
|
|
+ private void collectAntibioticInfo(Map<String, Map<Double, List<String>>> antibioticInfo, String drugName, String value, String startDateStr) {
|
|
|
+ Map<Double, List<String>> antibioticValueList = null;
|
|
|
+ double v = -1;
|
|
|
+ try {
|
|
|
+ v = Double.parseDouble(getNumber(value));
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("THR03076: " + drugName + ":" + value + "解析异常");
|
|
|
+ }
|
|
|
+ if (v < 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!antibioticInfo.containsKey(drugName)) {
|
|
|
+ //存该抗生素使用第1个值
|
|
|
+ antibioticValueList = Maps.newLinkedHashMap();
|
|
|
+ antibioticValueList.put(v, Lists.newArrayList(startDateStr));
|
|
|
+ antibioticInfo.put(drugName, antibioticValueList);
|
|
|
+ } else {
|
|
|
+ antibioticValueList = antibioticInfo.get(drugName);
|
|
|
+ //存该抗生素使用量第n个时间
|
|
|
+ if (antibioticValueList.containsKey(v)) {
|
|
|
+ antibioticValueList.get(v).add(startDateStr);
|
|
|
+ } else {
|
|
|
+ //存该抗生素使用量第1个时间
|
|
|
+ antibioticValueList.put(v, Lists.newArrayList(startDateStr));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getNumber(String content) {
|
|
|
+ String group = "";
|
|
|
+ String compile = "([1-9]\\d*\\.?\\d*)|(0\\.\\d*[1-9]|\\.\\d*[1-9]|0)";
|
|
|
+ Pattern p = Pattern.compile(compile);
|
|
|
+ Matcher matcher = p.matcher(content);
|
|
|
+ if (matcher.find()) {
|
|
|
+ group = matcher.group(0);
|
|
|
+ }
|
|
|
+ return group;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 如果文本包含中括号([海正]美罗培南针),取括号之后的文字
|
|
|
+ *
|
|
|
+ * @param str
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String removeBracket(String str) {
|
|
|
+ if (str.contains("]") && str.indexOf("]") != str.length() - 1) {
|
|
|
+ return str.substring(str.indexOf("]") + 1);
|
|
|
+ }
|
|
|
+ return str;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|