|
@@ -133,6 +133,7 @@ namespace WingAIDiagnosisService.Service
|
|
|
var result = await CarotidDiagnosis(imageData);
|
|
|
var resultData = new DiagnosisImageResult()
|
|
|
{
|
|
|
+ DiagnosisOrgans = new List<DiagnosisOrganEnum>() { DiagnosisOrganEnum.CarotidArtery },
|
|
|
CarotidResult = result
|
|
|
};
|
|
|
return resultData;
|
|
@@ -161,6 +162,7 @@ namespace WingAIDiagnosisService.Service
|
|
|
}
|
|
|
return new DiagnosisImageResult();
|
|
|
}
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 生成AI报告
|
|
|
/// </summary>
|
|
@@ -171,27 +173,34 @@ namespace WingAIDiagnosisService.Service
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- var manager = await CreateDiagnosisManagerAsync(request);
|
|
|
- var reportPerImages = manager.GetReportResults();
|
|
|
- var diagnosisConclusion = GetDiagnosisConclusion(reportPerImages);
|
|
|
-
|
|
|
- var diagnosisResult = new List<DiagnosisPerImageDTO>();
|
|
|
- foreach (var item in reportPerImages)
|
|
|
+ if (request.Organ == DiagnosisOrganEnum.CarotidArtery)
|
|
|
{
|
|
|
- var aiFileToken = await UploadFileAsync(item.AILocalImagePath, Path.GetFileName(item.AILocalImagePath));
|
|
|
- var perImageResult = Newtonsoft.Json.JsonConvert.DeserializeObject<DiagnosisPerImageDTO>(Newtonsoft.Json.JsonConvert.SerializeObject(item));
|
|
|
- perImageResult.RemedicalCode = item.RemedicalCode;
|
|
|
- perImageResult.DataType = (RemedicalFileDataTypeEnum)item.DataType;
|
|
|
- perImageResult.Pixel = item.Pixel;
|
|
|
- perImageResult.AIFileToken = aiFileToken;
|
|
|
- diagnosisResult.Add(perImageResult);
|
|
|
-
|
|
|
+ var result = await GetCarotidAIMeasureResult(request);
|
|
|
+ return result;
|
|
|
}
|
|
|
- return new DiagnosisReportResult
|
|
|
+ else
|
|
|
{
|
|
|
- DiagnosisConclusion = (DiagnosisConclusionEnum)diagnosisConclusion,
|
|
|
- DiagnosisResult = diagnosisResult,
|
|
|
- };
|
|
|
+ var manager = await CreateDiagnosisManagerAsync(request);
|
|
|
+ var reportPerImages = manager.GetReportResults();
|
|
|
+ var diagnosisConclusion = GetDiagnosisConclusion(reportPerImages);
|
|
|
+
|
|
|
+ var diagnosisResult = new List<DiagnosisPerImageDTO>();
|
|
|
+ foreach (var item in reportPerImages)
|
|
|
+ {
|
|
|
+ var aiFileToken = await UploadFileAsync(item.AILocalImagePath, Path.GetFileName(item.AILocalImagePath));
|
|
|
+ var perImageResult = Newtonsoft.Json.JsonConvert.DeserializeObject<DiagnosisPerImageDTO>(Newtonsoft.Json.JsonConvert.SerializeObject(item));
|
|
|
+ perImageResult.RemedicalCode = item.RemedicalCode;
|
|
|
+ perImageResult.DataType = (RemedicalFileDataTypeEnum)item.DataType;
|
|
|
+ perImageResult.Pixel = item.Pixel;
|
|
|
+ perImageResult.AIFileToken = aiFileToken;
|
|
|
+ diagnosisResult.Add(perImageResult);
|
|
|
+ }
|
|
|
+ return new DiagnosisReportResult
|
|
|
+ {
|
|
|
+ DiagnosisConclusion = (DiagnosisConclusionEnum)diagnosisConclusion,
|
|
|
+ DiagnosisResult = diagnosisResult,
|
|
|
+ };
|
|
|
+ }
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
@@ -200,6 +209,86 @@ namespace WingAIDiagnosisService.Service
|
|
|
return new DiagnosisReportResult();
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 获取颈动脉ai报告数据
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request">生成AI报告请求实体</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private async Task<DiagnosisReportResult> GetCarotidAIMeasureResult(DiagnosisReportRequest request)
|
|
|
+ {
|
|
|
+ var result = new DiagnosisReportResult()
|
|
|
+ {
|
|
|
+ DiagnosisConclusion = DiagnosisConclusionEnum.NoObviousLesion
|
|
|
+ };
|
|
|
+ var orderedExamDatas = request.RemedicalList.OrderByDescending(m => m.CarotidResult?.CarotidScanType).Where(m => m.CarotidResult?.MeasureImageFiles != null && m.CarotidResult.MeasureImageFiles.Count > 0);
|
|
|
+ if (orderedExamDatas?.Count() > 0)
|
|
|
+ {
|
|
|
+ DiagnosisRemicalDTO leftData = null;
|
|
|
+ //left
|
|
|
+ var leftExamDatas = orderedExamDatas.Where(m => m.CarotidResult.CarotidScanType == CarotidScanTypeEnum.CarotidLeft);
|
|
|
+ if (leftExamDatas.Any())
|
|
|
+ {
|
|
|
+ foreach (var leftItem in leftExamDatas)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(leftItem.CarotidResult.MeasureResult))
|
|
|
+ {
|
|
|
+ result.DiagnosisConclusion = DiagnosisConclusionEnum.Unrecognized;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //leftItem.CarotidResult.MeasureResult = "{\"IntimaResult\":{\"IsSuccess\":true,\"AntIntima\":{\"IntimaThick\":0.0,\"IsSuccess\":false},\"PostIntima\":{\"IntimaThick\":0.75,\"IsSuccess\":true}},\"IsYImageSuccess\":false,\"PlaqueResult\":{\"PlaquePostion\":0,\"PlaqueCountType\":2,\"PlaqueType\":0,\"PlaqueWidth\":1.75,\"PlaqueHeight\":3.76,\"Stenosis\":10.37,\"IsSuccess\":true}}";
|
|
|
+ var measureResult = JsonConvert.DeserializeObject<CarotidAIMeasureResult>(leftItem.CarotidResult.MeasureResult) ?? new CarotidAIMeasureResult();
|
|
|
+ if (measureResult.PlaqueResult?.PlaqueCountType != Carotid.Utilities.DetectPlaque.PlaqueCountType.NoPlaque)
|
|
|
+ {
|
|
|
+ leftData = leftItem;
|
|
|
+ result.DiagnosisConclusion = DiagnosisConclusionEnum.Other;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (leftData == null)
|
|
|
+ {
|
|
|
+ leftData = leftExamDatas.First();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (leftData != null)
|
|
|
+ {
|
|
|
+ result.CarotidResult.Add(leftData);
|
|
|
+ }
|
|
|
+ //right
|
|
|
+ float intimaThickStandard = 1.0f;
|
|
|
+ DiagnosisRemicalDTO rightData = null;
|
|
|
+ var rightExamDatas = orderedExamDatas.Where(m => m.CarotidResult.CarotidScanType == CarotidScanTypeEnum.CarotidRight);
|
|
|
+ if (rightExamDatas.Any())
|
|
|
+ {
|
|
|
+ foreach (var rightItem in rightExamDatas)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(rightItem.CarotidResult.MeasureResult))
|
|
|
+ {
|
|
|
+ result.DiagnosisConclusion = DiagnosisConclusionEnum.Unrecognized;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //rightItem.CarotidResult.MeasureResult = "{\"IntimaResult\":{\"IsSuccess\":true,\"AntIntima\":{\"IntimaThick\":0.0,\"IsSuccess\":false},\"PostIntima\":{\"IntimaThick\":0.75,\"IsSuccess\":true}},\"IsYImageSuccess\":false,\"PlaqueResult\":{\"PlaquePostion\":0,\"PlaqueCountType\":2,\"PlaqueType\":0,\"PlaqueWidth\":1.75,\"PlaqueHeight\":3.76,\"Stenosis\":10.37,\"IsSuccess\":true}}";
|
|
|
+ var measureResult = JsonConvert.DeserializeObject<CarotidAIMeasureResult>(rightItem.CarotidResult.MeasureResult) ?? new CarotidAIMeasureResult();
|
|
|
+ if (measureResult.IntimaResult?.PostIntima?.IntimaThick > intimaThickStandard)
|
|
|
+ {
|
|
|
+ rightData = rightItem;
|
|
|
+ result.DiagnosisConclusion = DiagnosisConclusionEnum.Other;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (rightData == null)
|
|
|
+ {
|
|
|
+ rightData = rightExamDatas.First();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (rightData != null)
|
|
|
+ {
|
|
|
+ result.CarotidResult.Add(rightData);
|
|
|
+ }
|
|
|
+ Logger.WriteLineInfo($"AIDiagnosisService package carotidAIMeasureResult finished, CarotidLeftRemedicalCode:{ leftData?.RemedicalCode }, CarotidLeft:{ leftData?.CarotidResult?.MeasureResult }, CarotidRightRemedicalCode:{ rightData?.RemedicalCode }, CarotidRight:" + rightData?.CarotidResult?.MeasureResult);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
private async Task<BaseDiagnosis> CreateDiagnosisManagerAsync(DiagnosisReportRequest request)
|
|
|
{
|
|
|
var recordResults = new List<DiagnosisPerImageModel>();
|