|
|
|
@ -248,8 +248,8 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
|
|
|
|
|
ocrResultAdd(ocrResultDTOList, value.getFieldName(), field, inputText, null, probability, imgPath, value.getFieldName() + "参数未获取到结果", false, ruleInfo);
|
|
|
|
|
} else if (StringUtils.isBlank(inputText)) {
|
|
|
|
|
//没有输入值.
|
|
|
|
|
fieldRightMap.put(field, true);
|
|
|
|
|
ocrResultAdd(ocrResultDTOList, value.getFieldName(), field, inputText, text, probability, imgPath, "没有输入值不做匹配", true, ruleInfo);
|
|
|
|
|
fieldRightMap.put(field, false);
|
|
|
|
|
ocrResultAdd(ocrResultDTOList, value.getFieldName(), field, inputText, text, probability, imgPath, "没有输入值", false, ruleInfo);
|
|
|
|
|
} else if ("0".equals(ruleInfo)) {
|
|
|
|
|
//不必校验,有识别到就行,通过
|
|
|
|
|
fieldRightMap.put(field, true);
|
|
|
|
@ -694,11 +694,16 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
|
|
|
|
|
i1++;
|
|
|
|
|
String semanticResultJson = ocrIdentifyDetail.getSemanticResult();
|
|
|
|
|
String imgPath = ocrIdentifyDetail.getImageUrl();
|
|
|
|
|
if (StringUtils.isBlank(semanticResultJson)) continue;
|
|
|
|
|
if (StringUtils.isBlank(semanticResultJson)) {continue;}
|
|
|
|
|
String doctorName = simulateChecksVO.getDoctorName();
|
|
|
|
|
String hospitalName = simulateChecksVO.getHospitalName();
|
|
|
|
|
String departmentName = simulateChecksVO.getDepartmentName();
|
|
|
|
|
String time = simulateChecksVO.getTime();
|
|
|
|
|
String patientName = simulateChecksVO.getPatientName();
|
|
|
|
|
String medicalRecordNumber = simulateChecksVO.getMedicalRecordNumber();
|
|
|
|
|
String admissionDate = simulateChecksVO.getAdmissionDate();
|
|
|
|
|
String bornDate = simulateChecksVO.getBornDate();
|
|
|
|
|
String age = simulateChecksVO.getAge();
|
|
|
|
|
List<JSONObject> sourceJson = new ArrayList<>();
|
|
|
|
|
if (StringUtils.isNotBlank(doctorName)) {
|
|
|
|
|
sourceJson.add(JSONObject.parseObject(String.format("{\"tag\":\"doctorName\", \"inputText\":\"%s\"}", doctorName)));
|
|
|
|
@ -712,6 +717,21 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
|
|
|
|
|
if (StringUtils.isNotBlank(time)) {
|
|
|
|
|
sourceJson.add(JSONObject.parseObject(String.format("{\"tag\":\"time\", \"inputText\":\"%s\"}", time)));
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(patientName)) {
|
|
|
|
|
sourceJson.add(JSONObject.parseObject(String.format("{\"tag\":\"patientName\", \"inputText\":\"%s\"}", patientName)));
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(medicalRecordNumber)) {
|
|
|
|
|
sourceJson.add(JSONObject.parseObject(String.format("{\"tag\":\"medicalRecordNumber\", \"inputText\":\"%s\"}", medicalRecordNumber)));
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(admissionDate)) {
|
|
|
|
|
sourceJson.add(JSONObject.parseObject(String.format("{\"tag\":\"admissionDate\", \"inputText\":\"%s\"}", admissionDate)));
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(bornDate)) {
|
|
|
|
|
sourceJson.add(JSONObject.parseObject(String.format("{\"tag\":\"bornDate\", \"inputText\":\"%s\"}", bornDate)));
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(age)) {
|
|
|
|
|
sourceJson.add(JSONObject.parseObject(String.format("{\"tag\":\"age\", \"inputText\":\"%s\"}", age)));
|
|
|
|
|
}
|
|
|
|
|
JSONObject semanticResult = JSONObject.parseObject(ocrIdentifyDetail.getSemanticResult());
|
|
|
|
|
|
|
|
|
|
//判断是不是网络图片
|
|
|
|
@ -769,7 +789,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
|
|
|
|
|
StringBuilder rMessage = new StringBuilder();
|
|
|
|
|
//==========================
|
|
|
|
|
for (CheckSemanticModel value : checkSemanticModelMap.values()) {
|
|
|
|
|
String field = value.getField();
|
|
|
|
|
String field = value.getField();//字段 name.
|
|
|
|
|
String fieldName = value.getFieldName();//校验的字段名称
|
|
|
|
|
String ruleInfo = value.getRuleInfo();//是否绝对判断 0-绝对判断,1-不绝对判断
|
|
|
|
|
String inputText = value.getInputText();//校验文本 ,ocr识别的文本如果不包含该内容,则算作失败
|
|
|
|
@ -816,6 +836,46 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else if (Arrays.asList("患者姓名","患者").contains(s)) {
|
|
|
|
|
for (String s1 : Arrays.asList("患者姓名","患者")) {
|
|
|
|
|
JSONArray semantic_result = semanticResult.getJSONObject("semantic_result").getJSONArray(s1);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(semantic_result)) {
|
|
|
|
|
jsonArray.addAll(semantic_result);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else if (Arrays.asList("病历号").contains(s)) {
|
|
|
|
|
for (String s1 : Arrays.asList("病历号")) {
|
|
|
|
|
JSONArray semantic_result = semanticResult.getJSONObject("semantic_result").getJSONArray(s1);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(semantic_result)) {
|
|
|
|
|
jsonArray.addAll(semantic_result);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else if (Arrays.asList("入院日期").contains(s)) {
|
|
|
|
|
for (String s1 : Arrays.asList("入院日期")) {
|
|
|
|
|
JSONArray semantic_result = semanticResult.getJSONObject("semantic_result").getJSONArray(s1);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(semantic_result)) {
|
|
|
|
|
jsonArray.addAll(semantic_result);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else if (Arrays.asList("出生日期").contains(s)) {
|
|
|
|
|
for (String s1 : Arrays.asList("出生日期")) {
|
|
|
|
|
JSONArray semantic_result = semanticResult.getJSONObject("semantic_result").getJSONArray(s1);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(semantic_result)) {
|
|
|
|
|
jsonArray.addAll(semantic_result);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else if (Arrays.asList("年龄").contains(s)) {
|
|
|
|
|
for (String s1 : Arrays.asList("年龄")) {
|
|
|
|
|
JSONArray semantic_result = semanticResult.getJSONObject("semantic_result").getJSONArray(s1);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(semantic_result)) {
|
|
|
|
|
jsonArray.addAll(semantic_result);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
jsonArray = semanticResult.getJSONObject("semantic_result").getJSONArray(s);
|
|
|
|
|
}
|
|
|
|
@ -935,6 +995,35 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
|
|
|
|
|
}else{
|
|
|
|
|
newResultDTOList.add(o);
|
|
|
|
|
}
|
|
|
|
|
//脱敏处理
|
|
|
|
|
String tagName = o.getTagName();
|
|
|
|
|
String ocrText = o.getOcrText();
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
if ("患者姓名".equals(tagName)) {
|
|
|
|
|
// 保留第一个字,其余用 "*" 替代
|
|
|
|
|
int length = Math.max(0, ocrText.length() - 1);
|
|
|
|
|
for (int i = 0; i < length; i++) {
|
|
|
|
|
sb.append("*");
|
|
|
|
|
}
|
|
|
|
|
String desensitizedText = ocrText.substring(0, 1) + sb.toString();
|
|
|
|
|
o.setOcrText(desensitizedText);
|
|
|
|
|
}
|
|
|
|
|
if ("联系方式".equals(tagName) || "身份证号".equals(tagName)){
|
|
|
|
|
String desensitizedText = desensitizeText(ocrText); // 自定义的脱敏方法
|
|
|
|
|
// 更新脱敏后的值
|
|
|
|
|
o.setOcrText(desensitizedText);
|
|
|
|
|
}
|
|
|
|
|
if ("家庭住址".equals(tagName) || "工作地址".equals(tagName) || "病情陈述人".equals(tagName)
|
|
|
|
|
|| "户籍地".equals(tagName)){
|
|
|
|
|
|
|
|
|
|
sb.append(ocrText.charAt(0));
|
|
|
|
|
for (int i = 1; i < ocrText.length() - 1; i++) {
|
|
|
|
|
sb.append("*");
|
|
|
|
|
}
|
|
|
|
|
sb.append(ocrText.charAt(ocrText.length() - 1));
|
|
|
|
|
String desensitizedText= sb.toString();
|
|
|
|
|
o.setOcrText(desensitizedText);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ocrResultDTOList = newResultDTOList;
|
|
|
|
|
}
|
|
|
|
@ -949,10 +1038,34 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
|
|
|
|
|
responseBody.put("min",min);
|
|
|
|
|
responseBody.put("max",max);
|
|
|
|
|
responseBody.put("detailList", ocrResultDTOList);
|
|
|
|
|
//============
|
|
|
|
|
return responseBody;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 自定义的脱敏方法,对字段进行半脱敏
|
|
|
|
|
private String desensitizeText(String text) {
|
|
|
|
|
StringBuilder sb = new StringBuilder(text);
|
|
|
|
|
if (text == null) {
|
|
|
|
|
return text;
|
|
|
|
|
}else if (text.length() == 11){ //手机号脱敏
|
|
|
|
|
for (int i = 3; i < sb.length() - 4; i++) {
|
|
|
|
|
sb.setCharAt(i, '*');
|
|
|
|
|
}
|
|
|
|
|
return sb.toString();
|
|
|
|
|
}else if(text.length() == 14){ //身份证号码脱敏
|
|
|
|
|
for (int i = 3; i < sb.length() - 4; i++) {
|
|
|
|
|
sb.setCharAt(i, '*');
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
sb.append(text.charAt(0));
|
|
|
|
|
for (int i = 1; i < text.length() - 1; i++) {
|
|
|
|
|
sb.append("*");
|
|
|
|
|
}
|
|
|
|
|
sb.append(text.charAt(text.length() - 1));
|
|
|
|
|
return sb.toString();
|
|
|
|
|
}
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void executeTask() {
|
|
|
|
|
//获取任务
|
|
|
|
|