|
@@ -8,9 +8,12 @@ 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.StringUtil;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
@@ -32,6 +35,8 @@ public class THR03075 extends QCCatalogue {
|
|
|
if (doctorAdviceDocs.size() == 0 || threeLevelWardDocs.size() == 0) {
|
|
|
return;
|
|
|
}
|
|
|
+ //抗生素及开医嘱时间(包括减用过抗生素的时间) key:抗生素名 "2020-08-20,2020-08-21 ..."
|
|
|
+ Map<String, List<String>> antibioticDate = Maps.newHashMap();
|
|
|
//抗生素减用集合 key:抗生素名 value: 0:未减用,1及以上:减用次数
|
|
|
Map<String, Integer> antibioticStatus = Maps.newHashMap();
|
|
|
//抗生素及各初始剂量 key:抗生素名 value:抗生素第一次使用时剂量
|
|
@@ -49,51 +54,118 @@ public class THR03075 extends QCCatalogue {
|
|
|
.map(x -> x.get("医嘱项目名称"))
|
|
|
.forEach(y -> antibioticStatus.put(y.replaceAll("[\\[国产\\]\\[进口\\]\\[合信\\]\\[合资\\]]", ""), 0));
|
|
|
|
|
|
- String drugName = null, value = null;
|
|
|
+ String drugName = null, value = null, startDateStr = null;
|
|
|
for (Map<String, String> structMap : docAdvStruct) {
|
|
|
drugName = structMap.get("医嘱项目名称");
|
|
|
value = structMap.get("医嘱单次剂量");
|
|
|
+ startDateStr = structMap.get("医嘱开始时间");
|
|
|
drugName = drugName.replaceAll("[\\[国产\\]\\[进口\\]\\[合信\\]\\[合资\\]]", "");
|
|
|
- double v = -1;
|
|
|
- try {
|
|
|
- v = Double.parseDouble(getNumber(value));
|
|
|
- } catch (Exception e) {
|
|
|
- System.out.println("THR03075: " + 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);
|
|
|
- }
|
|
|
- }
|
|
|
+ collectAntibioticInfo(antibioticDate, antibioticStatus, antibioticValue, drugName, value, startDateStr);
|
|
|
}
|
|
|
|
|
|
- //抗生素减用过的集合
|
|
|
- List<String> reduceAntibiotic = Lists.newArrayList();
|
|
|
- //把抗生素减用次数过的抗生素塞进抗生素减用过的集合
|
|
|
+ //把抗生素没减用过的抗生素塞进抗生素减用过的集合
|
|
|
for (Map.Entry<String, Integer> as : antibioticStatus.entrySet()) {
|
|
|
- if (as.getValue() > 0) {
|
|
|
- reduceAntibiotic.add(as.getKey());
|
|
|
+ if (as.getValue() == 0) {
|
|
|
+ antibioticDate.remove(as.getKey());
|
|
|
}
|
|
|
}
|
|
|
//抗生素减用过的集合如果为空,则一个抗生素都没有减用过,直接返回0
|
|
|
- if (reduceAntibiotic.size() == 0) {
|
|
|
+ if (antibioticDate.size() == 0) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ //查房记录中抗生素及查房时间(包括减用过抗生素的时间) key:抗生素名 "2020-08-20,2020-08-21 ..."
|
|
|
+ Map<String, List<String>> antibioticDateWard = Maps.newHashMap();
|
|
|
+ //查房记录中抗生素减用集合 key:抗生素名 value: 0:未减用,1及以上:减用次数
|
|
|
+ Map<String, Integer> antibioticStatusWard = Maps.newHashMap();
|
|
|
+ //查房记录中抗生素及各初始剂量 key:抗生素名 value:抗生素第一次使用时剂量
|
|
|
+ Map<String, Double> antibioticValueWard = Maps.newHashMap();
|
|
|
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 (doc.getThreeLevelWardLabel().size() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ ThreeLevelWardLabel label = doc.getThreeLevelWardLabel().get(0);
|
|
|
+ List<Drug> drugs = label.getDrugs();
|
|
|
+ for (Drug drug : drugs) {
|
|
|
+ if (drug.getConsumption() != null) {
|
|
|
+ String consumption = drug.getConsumption().getName();
|
|
|
+ collectAntibioticInfo(antibioticDateWard, antibioticStatusWard, antibioticValueWard, drug.getName(), consumption, doc.getStructureMap().get("查房日期"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //把查房记录中没减用过的抗生素删除
|
|
|
+ for (Map.Entry<String, Integer> as : antibioticStatusWard.entrySet()) {
|
|
|
+ if (as.getValue() == 0) {
|
|
|
+ antibioticDateWard.remove(as.getKey());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if (reduceAntibiotic.size() > 0) {
|
|
|
+ List<String> miss = Lists.newArrayList();
|
|
|
+ String drugKey = null, start = null, change = null, wardStartStr = null, wardChangeStr = null;
|
|
|
+ List<String> dateList = null;
|
|
|
+ for (Map.Entry<String, List<String>> ad : antibioticDate.entrySet()) {
|
|
|
+ drugKey = ad.getKey();
|
|
|
+ if (!antibioticDateWard.containsKey(drugKey)) {
|
|
|
+ miss.add(drugKey);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ dateList = ad.getValue();
|
|
|
+ int matchNum = 0;
|
|
|
+ for (int i = 0; i < dateList.size() - 1; i++) {
|
|
|
+ start = dateList.get(i); //抗生素开医嘱时间
|
|
|
+ change = dateList.get(i + 1); //抗生素用量改变时间
|
|
|
+ Date adStart = StringUtil.parseDateTime(start);
|
|
|
+ Date adChange = StringUtil.parseDateTime(change);
|
|
|
+ List<String> wardDateStr = antibioticDateWard.get(drugKey);
|
|
|
+ for (int j = 0; j < wardDateStr.size() - 1; j++) {
|
|
|
+ wardStartStr = wardDateStr.get(j); //查房记录开抗生素时间
|
|
|
+ wardChangeStr = wardDateStr.get(j + 1); //查房记录改变抗生素用量时间
|
|
|
+ Date wardStart = StringUtil.parseDateTime(wardStartStr);
|
|
|
+ Date wardChange = StringUtil.parseDateTime(wardChangeStr);
|
|
|
+ if (!CatalogueUtil.compareTime(adStart, wardStart, 48 * 60L) && !CatalogueUtil.compareTime(adChange, wardChange, 48 * 60L)) {
|
|
|
+ matchNum++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (dateList.size() - 1 != matchNum) {
|
|
|
+ miss.add(drugKey);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (miss.size() > 0) {
|
|
|
status.set("-1");
|
|
|
- info.set(reduceAntibiotic.toString().replaceAll("[\\[\\]]", ""));
|
|
|
+ info.set(miss.toString().replaceAll("[\\[\\]]", ""));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 收集抗生素各种信息
|
|
|
+ *
|
|
|
+ * @param antibioticDate 抗生素使用所有时间
|
|
|
+ * @param antibioticStatus 抗生素用量改变状态
|
|
|
+ * @param antibioticValue 抗生素及用量
|
|
|
+ * @param drugName 抗生素名称
|
|
|
+ * @param value 抗生素用量
|
|
|
+ * @param startDateStr 抗生素使用时间(医嘱开始时间或查房时间)
|
|
|
+ */
|
|
|
+ private void collectAntibioticInfo(Map<String, List<String>> antibioticDate, Map<String, Integer> antibioticStatus, Map<String, Double> antibioticValue, String drugName, String value, String startDateStr) {
|
|
|
+ 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);
|
|
|
+ antibioticDate.put(drugName, Lists.newArrayList(startDateStr));
|
|
|
+ } else {
|
|
|
+ double beforeValue = antibioticValue.get(drugName);
|
|
|
+ if (beforeValue > v) {
|
|
|
+ antibioticValue.put(drugName, v);//更新该抗生素使用值为更小的值
|
|
|
+ antibioticStatus.put(drugName, antibioticStatus.get(drugName) + 1);
|
|
|
+ antibioticDate.get(drugName).add(startDateStr);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|