浏览代码

去除需进诊断模型的文本空格(两个中文字之间去除空格)

hujing 5 年之前
父节点
当前提交
da92cae9af

+ 6 - 1
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/BeHospitalizedAI.java

@@ -109,14 +109,19 @@ public class BeHospitalizedAI extends ModelAI {
                 putContent(crfContent, medicalTextType.get(3), pacs_text, Content.pacs);//辅助检查(暂用主诉现病史模型,之后会新训练单独模型再做修改)
             }
             if (beHospitalizedDoc.getInitialDiagLabel().isCrfLabel()) {
-                putContent(crfContent, medicalTextType.get(6), initial_diag_text, Content.initial_diag);//初步诊断
+                if (StringUtil.isNotBlank(initial_diag_text)) {
+                    initial_diag_text = CatalogueUtil.removeBetweenWordSpace(initial_diag_text);
+                    putContent(crfContent, medicalTextType.get(6), initial_diag_text, Content.initial_diag);//初步诊断
+                }
             }
             if (StringUtils.isNotEmpty(revised_diag_text) && beHospitalizedDoc.getRevisedDiagLabel().isCrfLabel()) {
                 //修正诊断
+                revised_diag_text = CatalogueUtil.removeBetweenWordSpace(revised_diag_text);
                 putContent(crfContent, medicalTextType.get(6), revised_diag_text, Content.revised_diag);
             }
             if (StringUtils.isNotEmpty(supple_diag_text) && beHospitalizedDoc.getSuppleDiagLabel().isCrfLabel()) {
                 //补充诊断
+                supple_diag_text = CatalogueUtil.removeBetweenWordSpace(supple_diag_text);
                 putContent(crfContent, medicalTextType.get(6), supple_diag_text, Content.supple_diag);
             }
             JSONObject midData = loadAI(crfContent, crfServiceClient);

+ 9 - 4
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/FirstCourseRecordAI.java

@@ -7,6 +7,7 @@ import com.lantone.qc.kernel.client.SimilarityServiceClient;
 import com.lantone.qc.kernel.structure.ai.process.EntityProcessClinic;
 import com.lantone.qc.kernel.structure.ai.process.EntityProcessDiag;
 import com.lantone.qc.kernel.structure.ai.process.EntityProcessTreatPlan;
+import com.lantone.qc.kernel.util.CatalogueUtil;
 import com.lantone.qc.pub.Content;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.doc.FirstCourseRecordDoc;
@@ -45,18 +46,22 @@ public class FirstCourseRecordAI extends ModelAI {
             //putContent(crfContent, medicalTextType.get(0), firstCourseRecordDoc.getCaseCharacteristicLabel().getText(), Content.case_feature);
             //初步诊断
             if (StringUtils.isNotEmpty(structureMap.get(Content.initial_diag))) {
-                putContent(crfContent, medicalTextType.get(1), structureMap.get(Content.initial_diag), Content.initial_diag);
+                String initial_diag = CatalogueUtil.removeBetweenWordSpace(structureMap.get(Content.initial_diag));
+                putContent(crfContent, medicalTextType.get(1), initial_diag, Content.initial_diag);
             } else if (firstCourseRecordDoc.getInitialDiagLabel() != null && StringUtil.isNotBlank(firstCourseRecordDoc.getInitialDiagLabel().getText())) {
-                putContent(crfContent, medicalTextType.get(1), firstCourseRecordDoc.getInitialDiagLabel().getText(), Content.initial_diag);
+                String initial_diag = CatalogueUtil.removeBetweenWordSpace(firstCourseRecordDoc.getInitialDiagLabel().getText());
+                putContent(crfContent, medicalTextType.get(1), initial_diag, Content.initial_diag);
             }
 
             //诊断依据
             //putContent(crfContent, medicalTextType.get(0), firstCourseRecordDoc.getDiagnosisLabel().getText(), Content.diag_basis);
             //鉴别诊断
             if (StringUtils.isNotEmpty(structureMap.get("鉴别诊断"))) {
-                putContent(crfContent, medicalTextType.get(1), structureMap.get("鉴别诊断"), "鉴别诊断");
+                String diffDiag = CatalogueUtil.removeBetweenWordSpace(structureMap.get("鉴别诊断"));
+                putContent(crfContent, medicalTextType.get(1), diffDiag, "鉴别诊断");
             } else if (firstCourseRecordDoc.getDifferentialDiagLabel() != null && StringUtil.isNotBlank(firstCourseRecordDoc.getDifferentialDiagLabel().getText())) {
-                putContent(crfContent, medicalTextType.get(1), firstCourseRecordDoc.getDifferentialDiagLabel().getText(), "鉴别诊断");
+                String diffDiag = CatalogueUtil.removeBetweenWordSpace(firstCourseRecordDoc.getDifferentialDiagLabel().getText());
+                putContent(crfContent, medicalTextType.get(1), diffDiag, "鉴别诊断");
             }
             //诊疗计划
             if (StringUtils.isNotEmpty(structureMap.get("诊疗计划")) && StringUtils.isNotEmpty(structureMap.get("需求评估"))) {

+ 5 - 2
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/LeaveHospitalAI.java

@@ -4,11 +4,13 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.lantone.qc.kernel.client.CRFServiceClient;
 import com.lantone.qc.kernel.structure.ai.process.EntityProcessLeaveHospital;
+import com.lantone.qc.kernel.util.CatalogueUtil;
 import com.lantone.qc.pub.Content;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.doc.LeaveHospitalDoc;
 import com.lantone.qc.pub.model.label.DiagLabel;
 import com.lantone.qc.pub.model.label.LeaveHospitalLabel;
+import com.lantone.qc.pub.util.StringUtil;
 import org.apache.commons.lang3.StringUtils;
 
 import java.util.Arrays;
@@ -46,8 +48,9 @@ public class LeaveHospitalAI extends ModelAI {
                 //                    putContent(crfContent, medicalTextType.get(1), leaveHospitalStructureMap.get(Content.inStatus), Content.inStatus);
                 //                }
                 //出院诊断
-                if (leaveHospitalStructureMap.get(Content.dischargeDiag) != null) {
-                    putContent(crfContent, medicalTextType.get(1), leaveHospitalStructureMap.get(Content.dischargeDiag), Content.dischargeDiag);
+                if (StringUtil.isNotBlank(leaveHospitalStructureMap.get(Content.dischargeDiag))) {
+                    String dischargeDiag = CatalogueUtil.removeBetweenWordSpace(leaveHospitalStructureMap.get(Content.dischargeDiag));
+                    putContent(crfContent, medicalTextType.get(1), dischargeDiag, Content.dischargeDiag);
                 }
             }
         }

+ 11 - 0
kernel/src/main/java/com/lantone/qc/kernel/util/CatalogueUtil.java

@@ -357,4 +357,15 @@ public class CatalogueUtil {
         }
         return StringUtil.parseDateTime(dateStr);
     }
+
+    /**
+     * 去除两个中文字之间空格
+     * @param str
+     * @return
+     */
+    public static String removeBetweenWordSpace(String str){
+        Pattern pattern = Pattern.compile("(?<=[\\x{4e00}-\\x{9fa5}])\\s(?=[\\x{4e00}-\\x{9fa5}])");
+        Matcher m = pattern.matcher("1.偏瘫 2.脑出血恢复期 3.高血压 4.前列腺增生 5.Ⅰ度 房室传导阻滞 6.左 肾结石 7.颈动脉硬化 伴右侧斑块形成");
+        return m.replaceAll("");
+    }
 }