|
@@ -1,114 +1,84 @@
|
|
|
package com.diagbot.model.ai.process;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.diagbot.biz.push.entity.Item;
|
|
|
import com.diagbot.model.ai.model.EntityEnum;
|
|
|
import com.diagbot.model.ai.model.Lemma;
|
|
|
-import com.diagbot.model.entity.*;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
+import com.diagbot.model.entity.BodyPart;
|
|
|
+import com.diagbot.model.entity.Pacs;
|
|
|
+import com.diagbot.model.label.PacsLabel;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
public class EntityProcessPacs extends EntityProcess {
|
|
|
|
|
|
- public List<Pacs> extractEntity(JSONObject aiOut, Map<String, String> name_uniqueName) {
|
|
|
- //辅检情况
|
|
|
- List<Pacs> pacses = new ArrayList<>();
|
|
|
- List<Lemma> pacsLemmas = createEntityTree(aiOut, EntityEnum.AUXILIARY_EXAMINATION.toString());
|
|
|
+ public void extractEntity(JSONObject aiOut, PacsLabel pacsLabel) {
|
|
|
+ // 获取描述和部位的关系
|
|
|
+ Map<String, List<BodyPart>> bodyMap = new LinkedHashMap<>();
|
|
|
+ List<Lemma> pacsLemmas = createEntityTree(aiOut, EntityEnum.AUXILIARY_DESCRIPT.toString());
|
|
|
for (Lemma lemma : pacsLemmas) {
|
|
|
- Pacs pacs = new Pacs();
|
|
|
- if(StringUtils.isBlank(lemma.getText().trim())){
|
|
|
- continue;
|
|
|
- }
|
|
|
- pacs.setName(lemma.getText());
|
|
|
- if(name_uniqueName.containsKey(lemma.getText())){
|
|
|
- pacs.setStandName(lemma.getText());
|
|
|
- }
|
|
|
+ List<BodyPart> bodyPartList = new ArrayList<>();
|
|
|
if (lemma.isHaveChildren()) {
|
|
|
- List<BodyPart> bodyPartList = new ArrayList<>();
|
|
|
- List<Diag> diseaseList = new ArrayList<>();
|
|
|
for (Lemma relationLemma : lemma.getRelationLemmas()) {
|
|
|
- if (relationLemma.getProperty().equals(EntityEnum.AUXILIARY_DESCRIPT.toString())) {
|
|
|
- pacs.setPacsValues(addPacsValue(relationLemma));
|
|
|
- } else if (relationLemma.getProperty().equals(EntityEnum.BODY.toString())) {
|
|
|
- bodyPartList.add(addBodyPart(relationLemma));
|
|
|
-// pacs.setBodyPart(addBodyPart(relationLemma));
|
|
|
- } else if(relationLemma.getProperty().equals(EntityEnum.DIEASE.toString())){
|
|
|
- diseaseList.add(addDiag(relationLemma));
|
|
|
- } else if (relationLemma.getProperty().equals(EntityEnum.OUTERCOURTYARD.toString())) {
|
|
|
- pacs.setOuterCourtyard(addOuterCourtyard(relationLemma));
|
|
|
+ if (relationLemma.getProperty().equals(EntityEnum.BODY.toString())) {
|
|
|
+ BodyPart bodyPart = new BodyPart();
|
|
|
+ bodyPart.setName(relationLemma.getText());
|
|
|
+ bodyPart.setStandName(relationLemma.getText());
|
|
|
+ bodyPartList.add(bodyPart);
|
|
|
}
|
|
|
}
|
|
|
- pacs.setBodyPartList(bodyPartList);
|
|
|
- pacs.setDisease(diseaseList);
|
|
|
+ bodyMap.put(lemma.getText(), bodyPartList);
|
|
|
}
|
|
|
- pacses.add(pacs);
|
|
|
- }
|
|
|
- //辅检时间(不是辅检具体项目时间)
|
|
|
- List<Lemma> pdLemmas = createEntityTree(aiOut, EntityEnum.TIME.toString());
|
|
|
- for (Lemma lemma : pdLemmas) {
|
|
|
- PD pd = new PD();
|
|
|
- pd.setName(lemma.getText());
|
|
|
- Pacs pacs = new Pacs();
|
|
|
- pacs.setPd(pd);
|
|
|
- pacses.add(pacs);
|
|
|
}
|
|
|
- return pacses;
|
|
|
- }
|
|
|
|
|
|
- /**
|
|
|
- * 添加辅助检查描述
|
|
|
- *
|
|
|
- * @param relationLemma
|
|
|
- * @return
|
|
|
- */
|
|
|
- private PacsValue addPacsValue(Lemma relationLemma) {
|
|
|
- PacsValue pacsValue = new PacsValue();
|
|
|
- pacsValue.setName(relationLemma.getText());
|
|
|
- pacsValue.setStandName(relationLemma.getText());
|
|
|
- return pacsValue;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 添加身体部位
|
|
|
- *
|
|
|
- * @param relationLemma
|
|
|
- * @return
|
|
|
- */
|
|
|
- private BodyPart addBodyPart(Lemma relationLemma) {
|
|
|
- BodyPart bodyPart = new BodyPart();
|
|
|
- bodyPart.setName(relationLemma.getText());
|
|
|
- bodyPart.setStandName(relationLemma.getText());
|
|
|
- return bodyPart;
|
|
|
- }
|
|
|
-
|
|
|
- private Diag addDiag(Lemma relationLemma) {
|
|
|
- Diag bodyPart = new Diag();
|
|
|
- bodyPart.setName(relationLemma.getText());
|
|
|
- bodyPart.setStandName(relationLemma.getText());
|
|
|
- return bodyPart;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 添加外院
|
|
|
- *
|
|
|
- * @param relationLemma
|
|
|
- * @return
|
|
|
- */
|
|
|
- private OuterCourtyard addOuterCourtyard(Lemma relationLemma) {
|
|
|
- OuterCourtyard outerCourtyard = new OuterCourtyard();
|
|
|
- outerCourtyard.setName(relationLemma.getText());
|
|
|
- if (relationLemma.isHaveChildren()) {
|
|
|
- outerCourtyard.setPd(findTime(relationLemma));
|
|
|
- for (Lemma lemma : relationLemma.getRelationLemmas()) {
|
|
|
- if (lemma.getProperty().equals(EntityEnum.AUXILIARY_DESCRIPT.toString())) {
|
|
|
- outerCourtyard.setPacsValue(addPacsValue(lemma));
|
|
|
- break;
|
|
|
+ //辅助检查
|
|
|
+ List<Lemma> pacsAll = createEntityTree(aiOut, EntityEnum.AUXILIARY_EXAMINATION.toString());
|
|
|
+ List<Pacs> disList = new ArrayList<>();
|
|
|
+ for (Lemma lemma : pacsAll) {
|
|
|
+ if (lemma.isHaveChildren()) {
|
|
|
+ for (Lemma relationLemma : lemma.getRelationLemmas()) {
|
|
|
+ if (relationLemma.getProperty().equals(EntityEnum.DIEASE.toString())) {
|
|
|
+ // 辅检诊断信息
|
|
|
+ Pacs dis = new Pacs();
|
|
|
+ dis.setName(relationLemma.getText());
|
|
|
+ dis.setStandName(relationLemma.getText());
|
|
|
+ disList.add(dis);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return outerCourtyard;
|
|
|
+ //所有项目
|
|
|
+ List<Item> collect = Lists.newArrayList();
|
|
|
+ if(ListUtil.isNotEmpty(pacsAll)){
|
|
|
+ collect = pacsAll.stream().map(x -> {
|
|
|
+ Item item = new Item();
|
|
|
+ item.setName(x.getText());
|
|
|
+ item.setUniqueName(x.getText());
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ //描述和部位的关系
|
|
|
+ List<Pacs> pacsResults = Lists.newArrayList();
|
|
|
+ if(bodyMap != null && bodyMap.size() > 0){
|
|
|
+ bodyMap.forEach((x,y) -> {
|
|
|
+ Pacs pacs = new Pacs();
|
|
|
+ pacs.setName(x);
|
|
|
+ pacs.setStandName(x);
|
|
|
+ pacs.setBodyPartList(y);
|
|
|
+ pacsResults.add(pacs);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ pacsLabel.setDisease(disList);
|
|
|
+ pacsLabel.setItem(collect);
|
|
|
+ pacsLabel.setPacsResults(pacsResults);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|