|
@@ -0,0 +1,111 @@
|
|
|
+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.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.util.StringUtil;
|
|
|
+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-18 19:13
|
|
|
+ * @desc 减用抗生素未记录
|
|
|
+ **/
|
|
|
+@Component
|
|
|
+public class THR03075 extends QCCatalogue {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ //抗生素减用集合 key:抗生素名 value: 0:未减用,1及以上:减用次数
|
|
|
+ Map<String, Integer> antibioticStatus = Maps.newHashMap();
|
|
|
+ //抗生素及各初始剂量 key:抗生素名 value:抗生素第一次使用时剂量
|
|
|
+ Map<String, Double> antibioticValue = Maps.newHashMap();
|
|
|
+
|
|
|
+ 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());
|
|
|
+
|
|
|
+ docAdvStruct
|
|
|
+ .stream()
|
|
|
+ .map(x -> x.get("医嘱项目名称"))
|
|
|
+ .forEach(y -> antibioticStatus.put(y.replaceAll("[\\[国产\\]\\[进口\\]\\[合信\\]\\[合资\\]]", ""), 0));
|
|
|
+
|
|
|
+ String drugName = null, value = null;
|
|
|
+ for (Map<String, String> structMap : docAdvStruct) {
|
|
|
+ drugName = structMap.get("医嘱项目名称");
|
|
|
+ value = structMap.get("医嘱单次剂量");
|
|
|
+ drugName = drugName.replaceAll("[\\[国产\\]\\[进口\\]\\[合信\\]\\[合资\\]]", "");
|
|
|
+ double v = -1;
|
|
|
+ try {
|
|
|
+ v = Double.parseDouble(getNumber(value));
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("THR03074: " + drugName + ":" + value + "医嘱单次剂量解析异常");
|
|
|
+ }
|
|
|
+ if (!antibioticValue.containsKey(drugName) && v > 0) {
|
|
|
+ antibioticValue.put(drugName, v);
|
|
|
+ } else {
|
|
|
+ double beforeValue = antibioticValue.get(drugName);
|
|
|
+ if (beforeValue > v) {
|
|
|
+ antibioticValue.put(drugName, v);//更新该抗生素使用值为更小的值
|
|
|
+ antibioticStatus.put(drugName, antibioticStatus.get(drugName) + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //抗生素减用过的集合
|
|
|
+ List<String> reduceAntibiotic = Lists.newArrayList();
|
|
|
+ //把抗生素减用次数过的抗生素塞进抗生素减用过的集合
|
|
|
+ for (Map.Entry<String, Integer> as : antibioticStatus.entrySet()) {
|
|
|
+ if (as.getValue() > 0) {
|
|
|
+ reduceAntibiotic.add(as.getKey());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //抗生素减用过的集合如果为空,则一个抗生素都没有减用过,直接返回0
|
|
|
+ if (reduceAntibiotic.size() == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ThreeLevelWardDoc> allDoctorWradDocs = threeLevelWardDocs.get(0).getAllDoctorWradDocs();
|
|
|
+ for (ThreeLevelWardDoc doc : allDoctorWradDocs) {
|
|
|
+ Map<String, String> structureMap = doc.getStructureMap();
|
|
|
+ String content = CatalogueUtil.structureMapJoin(structureMap, Lists.newArrayList("体检", "病情记录"));
|
|
|
+ reduceAntibiotic.removeIf(content::contains);//如果查房文本包含该抗生素,则从抗生素减用过的集合中删除该抗生素
|
|
|
+ }
|
|
|
+
|
|
|
+ if (reduceAntibiotic.size() > 0) {
|
|
|
+ status.set("-1");
|
|
|
+ info.set(reduceAntibiotic.toString().replaceAll("[\\[\\]]", ""));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|