anerx
4 months ago
31 changed files with 820 additions and 392 deletions
@ -1,27 +0,0 @@ |
|||||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|
||||
//
|
|
||||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|
||||
|
|
||||
using Admin.NET.Core; |
|
||||
using SqlSugar; |
|
||||
|
|
||||
namespace Admin.NET.Bodk.Genetic.Entities; |
|
||||
|
|
||||
[SugarTable("bodk_genetic_item_test_result")] |
|
||||
public class GeneticItemTestResultEntity : EntityBase |
|
||||
{ |
|
||||
public long GeneticTestResultId { get; set; } |
|
||||
|
|
||||
public string Name { get; set; } |
|
||||
|
|
||||
public float Growth { get; set; } |
|
||||
|
|
||||
public float AverageRiskScore { get; set; } |
|
||||
|
|
||||
public float RiskScore { get; set; } |
|
||||
|
|
||||
public int RiskLevel { get; set; } |
|
||||
|
|
||||
[SugarColumn(IsJson = true, IsNullable = true, ColumnDataType = "TEXT")] |
|
||||
public List<Genetic.Models.Genetic>? Genetics { get; set; } |
|
||||
} |
|
@ -1,48 +0,0 @@ |
|||||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|
||||
//
|
|
||||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|
||||
|
|
||||
using Admin.NET.Core; |
|
||||
using SqlSugar; |
|
||||
|
|
||||
namespace Admin.NET.Bodk.Genetic.Entities; |
|
||||
|
|
||||
[SugarTable("bodk_genetic_test_result")] |
|
||||
public class GeneticTestResultEntity : EntityBase |
|
||||
{ |
|
||||
public long CustomerId { get; set; } |
|
||||
|
|
||||
[SugarColumn(IsNullable = true)] |
|
||||
public string? Code { get; set; } |
|
||||
|
|
||||
[SugarColumn(IsNullable = true)] |
|
||||
public string? TestType { get; set; } |
|
||||
|
|
||||
public string Barcode { get; set; } |
|
||||
|
|
||||
[SugarColumn(IsNullable = true)] |
|
||||
public GeneticTestStatus? Status { get; set; } |
|
||||
|
|
||||
[SugarColumn(IsNullable = true)] |
|
||||
public DateTime? GenerationTime { get; set; } |
|
||||
|
|
||||
[SugarColumn(IsNullable = true)] |
|
||||
public DateTime? CollectionTime { get; set; } |
|
||||
} |
|
||||
|
|
||||
public enum GeneticTestStatus |
|
||||
{ |
|
||||
Sampled = 1, |
|
||||
Sent, |
|
||||
Resampling, |
|
||||
Received, |
|
||||
Analyzing, |
|
||||
ReAnalyzing, |
|
||||
UnderReview, |
|
||||
UnderReviewComplete, |
|
||||
NotPassed, |
|
||||
Completed, |
|
||||
Terminated, |
|
||||
Paused, |
|
||||
Failed |
|
||||
} |
|
@ -0,0 +1,42 @@ |
|||||
|
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
||||
|
//
|
||||
|
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
||||
|
|
||||
|
using Admin.NET.Core; |
||||
|
using SqlSugar; |
||||
|
|
||||
|
namespace Admin.NET.Bodk.Genetic.Entities.Reports; |
||||
|
|
||||
|
[SugarTable("bodk_gene_testing_report")] |
||||
|
public class GeneTestingReportEntity : EntityBase |
||||
|
{ |
||||
|
public long CustomerId { get; set; } |
||||
|
|
||||
|
public string? Barcode { get; set; } |
||||
|
|
||||
|
public string? SampleType { get; set; } |
||||
|
|
||||
|
public string? TestingType { get; set; } |
||||
|
|
||||
|
public string? TestingMethod { get; set; } |
||||
|
|
||||
|
public DateTime? SubmissionTime { get; set; } |
||||
|
|
||||
|
public DateTime? ReportTime { get; set; } |
||||
|
|
||||
|
public bool? SampleQuality { get; set; } |
||||
|
|
||||
|
public bool? DnaExtraction { get; set; } |
||||
|
|
||||
|
public bool? Pcr { get; set; } |
||||
|
|
||||
|
public bool? TofMs { get; set; } |
||||
|
|
||||
|
public bool? GenotypingAnalysis { get; set; } |
||||
|
|
||||
|
public bool? GeneticRiskAssessment { get; set; } |
||||
|
|
||||
|
public bool? Report { get; set; } |
||||
|
|
||||
|
[SugarColumn(IsIgnore = true)] public List<GeneTestingTumorReportEntity>? Tumors { get; set; } |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
||||
|
//
|
||||
|
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
||||
|
|
||||
|
using Admin.NET.Bodk.Genetic.Entities.Tumors; |
||||
|
using Admin.NET.Core; |
||||
|
using SqlSugar; |
||||
|
|
||||
|
namespace Admin.NET.Bodk.Genetic.Entities.Reports; |
||||
|
|
||||
|
[SugarTable("bodk_gene_testing_tumor_locus_report")] |
||||
|
public class GeneTestingTumorLocusReportEntity : EntityBase |
||||
|
{ |
||||
|
public long TumorId { get; set; } |
||||
|
public long LocusId { get; set; } |
||||
|
|
||||
|
public long RiskId { get; set; } |
||||
|
|
||||
|
[SugarColumn(IsIgnore = true)] public GeneLocusEntity? Locus { get; set; } |
||||
|
|
||||
|
[SugarColumn(IsIgnore = true)] public GeneTypeEntity? Risk { get; set; } |
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
||||
|
//
|
||||
|
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
||||
|
|
||||
|
using Admin.NET.Bodk.Genetic.Entities.Tumors; |
||||
|
using Admin.NET.Core; |
||||
|
using SqlSugar; |
||||
|
|
||||
|
namespace Admin.NET.Bodk.Genetic.Entities.Reports; |
||||
|
|
||||
|
[SugarTable("bodk_gene_testing_tumor_report")] |
||||
|
public class GeneTestingTumorReportEntity : EntityBase |
||||
|
{ |
||||
|
public long ReportId { get; set; } |
||||
|
|
||||
|
public long TumorId { get; set; } |
||||
|
|
||||
|
public float RiskScore { get; set; } |
||||
|
|
||||
|
public int RiskLevel { get; set; } |
||||
|
|
||||
|
[SugarColumn(IsIgnore = true)] public TumorEntity? TumorDescription { get; set; } |
||||
|
|
||||
|
[SugarColumn(IsIgnore = true)] public List<GeneTestingTumorLocusReportEntity>? Loci { get; set; } |
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
||||
|
//
|
||||
|
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
||||
|
|
||||
|
using Admin.NET.Core; |
||||
|
using SqlSugar; |
||||
|
|
||||
|
namespace Admin.NET.Bodk.Genetic.Entities.Tumors; |
||||
|
|
||||
|
[SugarTable("bodk_gene_locus")] |
||||
|
public class GeneLocusEntity:EntityBase |
||||
|
{ |
||||
|
public string Name { get; set; } |
||||
|
public string Position { get; set; } |
||||
|
[SugarColumn(IsIgnore = true)] |
||||
|
public List<GeneTypeEntity> Types { get; set; } |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
||||
|
//
|
||||
|
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
||||
|
|
||||
|
using Admin.NET.Core; |
||||
|
using SqlSugar; |
||||
|
|
||||
|
namespace Admin.NET.Bodk.Genetic.Entities.Tumors; |
||||
|
|
||||
|
[SugarTable("bodk_gene_locus_risk")] |
||||
|
public class GeneLocusRiskEntity:EntityBase |
||||
|
{ |
||||
|
public long LocusId { get; set; } |
||||
|
public long RiskId { get; set; } |
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
||||
|
//
|
||||
|
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
||||
|
|
||||
|
using Admin.NET.Core; |
||||
|
using SqlSugar; |
||||
|
|
||||
|
namespace Admin.NET.Bodk.Genetic.Entities.Tumors; |
||||
|
|
||||
|
[SugarTable("bodk_tumor")] |
||||
|
public class TumorEntity : EntityBase |
||||
|
{ |
||||
|
public string Code { get; set; } |
||||
|
public string TumorName { get; set; } |
||||
|
public string Description { get; set; } |
||||
|
public double AvaRiskScore { get; set; } |
||||
|
[SugarColumn(IsIgnore = true)] public List<GeneLocusEntity> GeneLoci { get; set; } |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
||||
|
//
|
||||
|
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
||||
|
|
||||
|
using Admin.NET.Core; |
||||
|
using SqlSugar; |
||||
|
|
||||
|
namespace Admin.NET.Bodk.Genetic.Entities.Tumors; |
||||
|
|
||||
|
[SugarTable("bodk_tumor_gene_locus")] |
||||
|
public class TumorGeneLocusEntity:EntityBase |
||||
|
{ |
||||
|
public long TumorId { get; set; } |
||||
|
public long LocusId { get; set; } |
||||
|
} |
@ -0,0 +1,255 @@ |
|||||
|
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
||||
|
//
|
||||
|
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
||||
|
|
||||
|
using System.ComponentModel; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using Admin.NET.Bodk.Core; |
||||
|
using Admin.NET.Bodk.Genetic.Entities.Reports; |
||||
|
using Admin.NET.Bodk.Genetic.Entities.Tumors; |
||||
|
using Admin.NET.Bodk.Genetic.Models.Reports; |
||||
|
using Admin.NET.Core; |
||||
|
using Admin.NET.Core.Service; |
||||
|
using Furion.FriendlyException; |
||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer; |
||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
|
||||
|
namespace Admin.NET.Bodk.Genetic; |
||||
|
|
||||
|
[ApiDescriptionSettings(Groups = new[] { "Bodk Groups" }, Name = "GeneReport", Description = "基因检测服务")] |
||||
|
public class GeneReportService( |
||||
|
UserManager userManager, |
||||
|
SysOrgService sysOrgService, |
||||
|
SysUserService sysUserService, |
||||
|
SqlSugarRepository<GeneTestingTumorLocusReportEntity> geneTestingTumorLocusReportRepository, |
||||
|
SqlSugarRepository<GeneTestingReportEntity> reportRepository, |
||||
|
SqlSugarRepository<GeneTestingTumorReportEntity> geneTestingTumorReportRepository) |
||||
|
: ServiceBase(userManager, sysOrgService, sysUserService) |
||||
|
{ |
||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)] |
||||
|
[DisplayName("Add")] |
||||
|
public async Task AddReport(AddReportInput input) |
||||
|
{ |
||||
|
var db = geneTestingTumorLocusReportRepository.Context; |
||||
|
try |
||||
|
{ |
||||
|
await db.Ado.BeginTranAsync(); |
||||
|
var entity = new GeneTestingReportEntity() |
||||
|
{ |
||||
|
SampleType = input.SampleType, |
||||
|
TestingType = input.TestingType, |
||||
|
TestingMethod = input.TestingMethod, |
||||
|
TofMs = input.TofMs, |
||||
|
GenotypingAnalysis = input.GenotypingAnalysis, |
||||
|
SampleQuality = input.SampleQuality, |
||||
|
GeneticRiskAssessment = input.GeneticRiskAssessment, |
||||
|
Barcode = input.Barcode, |
||||
|
DnaExtraction = input.DnaExtraction, |
||||
|
CustomerId = input.CustomerId, |
||||
|
ReportTime = input.ReportTime, |
||||
|
Report = input.Report, |
||||
|
Pcr = input.Pcr, |
||||
|
SubmissionTime = input.SubmissionTime, |
||||
|
}; |
||||
|
entity = await AddBefore(entity); |
||||
|
var reportId = await db.Insertable(entity).ExecuteReturnSnowflakeIdAsync(); |
||||
|
foreach (var tumor in input.Tumors) |
||||
|
{ |
||||
|
var tumorEntity = new GeneTestingTumorReportEntity() |
||||
|
{ |
||||
|
TumorId = tumor.TumorId, |
||||
|
RiskScore = tumor.RiskScore, |
||||
|
RiskLevel = tumor.RiskLevel, |
||||
|
ReportId = reportId |
||||
|
}; |
||||
|
tumorEntity = await AddBefore(tumorEntity); |
||||
|
var tumorId = await db.Insertable(tumorEntity).ExecuteReturnSnowflakeIdAsync(); |
||||
|
foreach (var locus in tumor.Loci) |
||||
|
{ |
||||
|
var locusEntity = new GeneTestingTumorLocusReportEntity() |
||||
|
{ |
||||
|
LocusId = locus.LocusId, |
||||
|
RiskId = locus.RiskId, |
||||
|
TumorId = tumorId |
||||
|
}; |
||||
|
locusEntity = await AddBefore(locusEntity); |
||||
|
await db.Insertable(locusEntity).ExecuteReturnSnowflakeIdAsync(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
await db.Ado.CommitTranAsync(); |
||||
|
} |
||||
|
catch |
||||
|
{ |
||||
|
await db.Ado.RollbackTranAsync(); |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)] |
||||
|
[DisplayName("GetList")] |
||||
|
public async Task<List<ReportOutput>> GetList([Required] long customerId) |
||||
|
{ |
||||
|
var db = reportRepository.Context; |
||||
|
var reports = await db.Queryable<GeneTestingReportEntity>() |
||||
|
.Where(r => r.CustomerId == customerId) |
||||
|
.Select(r => new ReportOutput() |
||||
|
{ |
||||
|
SampleType = r.SampleType, |
||||
|
TestingType = r.TestingType, |
||||
|
TestingMethod = r.TestingMethod, |
||||
|
TofMs = r.TofMs, |
||||
|
GenotypingAnalysis = r.GenotypingAnalysis, |
||||
|
SampleQuality = r.SampleQuality, |
||||
|
GeneticRiskAssessment = r.GeneticRiskAssessment, |
||||
|
Barcode = r.Barcode, |
||||
|
DnaExtraction = r.DnaExtraction, |
||||
|
CustomerId = r.CustomerId, |
||||
|
Id = r.Id, |
||||
|
ReportTime = r.ReportTime, |
||||
|
Report = r.Report, |
||||
|
Pcr = r.Pcr, |
||||
|
SubmissionTime = r.SubmissionTime |
||||
|
}).ToListAsync(); |
||||
|
foreach (var report in reports) |
||||
|
{ |
||||
|
var tumors = await db.Queryable<GeneTestingTumorReportEntity>() |
||||
|
.LeftJoin<TumorEntity>((r, t) => r.TumorId == t.Id) |
||||
|
.Where(r => r.ReportId == report.Id) |
||||
|
.Select((r, t) => new TumorOutput() |
||||
|
{ |
||||
|
AvaRiskScore = t.AvaRiskScore, |
||||
|
TumorName = t.TumorName, |
||||
|
Description = t.Description, |
||||
|
Code = t.Code, |
||||
|
RiskScore = r.RiskScore, |
||||
|
RiskLevel = r.RiskLevel, |
||||
|
ReportId = report.Id, |
||||
|
TumorId = r.TumorId, |
||||
|
Id = r.Id, |
||||
|
}).ToListAsync(); |
||||
|
foreach (var tumor in tumors) |
||||
|
{ |
||||
|
var loci = await db.Queryable<GeneTestingTumorLocusReportEntity>() |
||||
|
.LeftJoin<GeneLocusEntity>((l, gl) => l.LocusId == gl.Id) |
||||
|
.LeftJoin<GeneTypeEntity>((l, gl, gt) => l.RiskId == gt.Id) |
||||
|
.Where(l => l.TumorId == tumor.Id) |
||||
|
.Select((l, gl, gt) => new LocusOutput() |
||||
|
{ |
||||
|
Description = gt.Description, |
||||
|
Risk = gt.Risk, |
||||
|
GenekType = gt.GenekType, |
||||
|
Position = gl.Position, |
||||
|
LocusName = gl.Name, |
||||
|
Id = l.Id, |
||||
|
}).ToListAsync(); |
||||
|
tumor.Loci = loci; |
||||
|
} |
||||
|
|
||||
|
report.Tumors = tumors; |
||||
|
} |
||||
|
|
||||
|
return reports; |
||||
|
} |
||||
|
|
||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)] |
||||
|
[DisplayName("Bind")] |
||||
|
public async Task<long> Bind(BindInput input) |
||||
|
{ |
||||
|
GeneTestingReportEntity entity = new GeneTestingReportEntity() |
||||
|
{ |
||||
|
CustomerId = input.CustomerId, |
||||
|
Barcode = input.Barcode |
||||
|
}; |
||||
|
entity = await AddBefore(entity); |
||||
|
return await reportRepository.InsertReturnSnowflakeIdAsync(entity); |
||||
|
} |
||||
|
|
||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)] |
||||
|
[DisplayName("Update")] |
||||
|
public async Task UpdateReport(UpdateReportInput input) |
||||
|
{ |
||||
|
var db = geneTestingTumorLocusReportRepository.Context; |
||||
|
try |
||||
|
{ |
||||
|
await db.Ado.BeginTranAsync(); |
||||
|
var entity = new GeneTestingReportEntity() |
||||
|
{ |
||||
|
Id = input.Id, |
||||
|
SampleType = input.SampleType, |
||||
|
TestingType = input.TestingType, |
||||
|
TestingMethod = input.TestingMethod, |
||||
|
TofMs = input.TofMs, |
||||
|
GenotypingAnalysis = input.GenotypingAnalysis, |
||||
|
SampleQuality = input.SampleQuality, |
||||
|
GeneticRiskAssessment = input.GeneticRiskAssessment, |
||||
|
Barcode = input.Barcode, |
||||
|
DnaExtraction = input.DnaExtraction, |
||||
|
CustomerId = input.CustomerId, |
||||
|
ReportTime = input.ReportTime, |
||||
|
Report = input.Report, |
||||
|
Pcr = input.Pcr, |
||||
|
SubmissionTime = input.SubmissionTime, |
||||
|
}; |
||||
|
entity = await UpdateBefore(entity); |
||||
|
await db.Updateable(entity).ExecuteCommandAsync(); |
||||
|
foreach (var tumor in input.Tumors) |
||||
|
{ |
||||
|
var tumorEntity = new GeneTestingTumorReportEntity() |
||||
|
{ |
||||
|
TumorId = tumor.TumorId, |
||||
|
RiskScore = tumor.RiskScore, |
||||
|
RiskLevel = tumor.RiskLevel, |
||||
|
ReportId = input.Id |
||||
|
}; |
||||
|
long tumorId = 0; |
||||
|
if (tumor.Id is null) |
||||
|
{ |
||||
|
tumorEntity = await AddBefore(tumorEntity); |
||||
|
tumorId = await db.Insertable(tumorEntity).ExecuteReturnSnowflakeIdAsync(); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
tumorEntity.Id=tumor.Id.Value; |
||||
|
tumorEntity = await UpdateBefore(tumorEntity); |
||||
|
await db.Updateable<TumorEntity>(tumorEntity).ExecuteCommandAsync(); |
||||
|
tumorId = tumor.Id.Value; |
||||
|
} |
||||
|
|
||||
|
foreach (var locus in tumor.Loci) |
||||
|
{ |
||||
|
var locusEntity = new GeneTestingTumorLocusReportEntity() |
||||
|
{ |
||||
|
LocusId = locus.LocusId, |
||||
|
RiskId = locus.RiskId, |
||||
|
TumorId = tumorId |
||||
|
}; |
||||
|
if (locus.Id is null) |
||||
|
{ |
||||
|
locusEntity = await AddBefore(locusEntity); |
||||
|
await db.Insertable(locusEntity).ExecuteReturnSnowflakeIdAsync(); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
locusEntity.Id=locus.Id.Value; |
||||
|
locusEntity = await UpdateBefore(locusEntity); |
||||
|
await db.Updateable(locusEntity).ExecuteCommandAsync(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
await db.Ado.CommitTranAsync(); |
||||
|
} |
||||
|
catch |
||||
|
{ |
||||
|
await db.Ado.RollbackTranAsync(); |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// public async Task<ReportOutput> GetSingle([Required] string barcode)
|
||||
|
// {
|
||||
|
// }
|
||||
|
} |
@ -1,176 +0,0 @@ |
|||||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|
||||
//
|
|
||||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|
||||
|
|
||||
using System.ComponentModel; |
|
||||
using Admin.NET.Bodk.Genetic.Entities; |
|
||||
using Admin.NET.Bodk.Genetic.Models; |
|
||||
using Admin.NET.Core; |
|
||||
using Furion.DatabaseAccessor; |
|
||||
using Furion.DependencyInjection; |
|
||||
using Furion.DynamicApiController; |
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer; |
|
||||
using Microsoft.AspNetCore.Authorization; |
|
||||
using Microsoft.AspNetCore.Mvc; |
|
||||
using Nest; |
|
||||
using SqlSugar; |
|
||||
|
|
||||
namespace Admin.NET.Bodk.Genetic; |
|
||||
|
|
||||
[ApiDescriptionSettings(Groups = new[] { "Bodk Groups" }, Name = "Genetic", Description = "基因检测服务")] |
|
||||
public class GeneticTestService : IDynamicApiController, ITransient |
|
||||
{ |
|
||||
private readonly SqlSugarRepository<GeneticTestResultEntity> _resultRepository; |
|
||||
|
|
||||
private readonly SqlSugarRepository<GeneticItemTestResultEntity> _itemRepository; |
|
||||
|
|
||||
public GeneticTestService(SqlSugarRepository<GeneticTestResultEntity> resultRepository, |
|
||||
SqlSugarRepository<GeneticItemTestResultEntity> itemRepository) |
|
||||
{ |
|
||||
_resultRepository = resultRepository; |
|
||||
_itemRepository = itemRepository; |
|
||||
} |
|
||||
|
|
||||
[UnitOfWork] |
|
||||
[ApiDescriptionSettings(Name = "GetList"), HttpPost] |
|
||||
[DisplayName("GetList")] |
|
||||
public async Task<SqlSugarPagedList<GeneticTestResultOutput>> GetList(GeneticTestResultQueryInput queryInput) |
|
||||
{ |
|
||||
return await _resultRepository.AsQueryable() |
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(queryInput.Code), |
|
||||
m => queryInput.Code != null && m.Code.Contains(queryInput.Code)) |
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(queryInput.Barcode), |
|
||||
m => queryInput.Barcode != null && m.Code.Contains(queryInput.Barcode)) |
|
||||
.WhereIF(queryInput.CustomerId is not null, m => m.CustomerId == queryInput.CustomerId) |
|
||||
.WhereIF(queryInput.Status is not null, |
|
||||
m => m.Status == queryInput.Status) |
|
||||
.Select<GeneticTestResultOutput>((u) => new Models.GeneticTestResultOutput() |
|
||||
{ |
|
||||
Id = u.Id, |
|
||||
CustomerId = u.CustomerId, |
|
||||
Code = u.Code, |
|
||||
Status = u.Status, |
|
||||
Barcode = u.Barcode, |
|
||||
GenerationTime = u.GenerationTime, |
|
||||
CollectionTime = u.CollectionTime, |
|
||||
CreateTime = u.CreateTime, |
|
||||
CreateUserId = u.CreateUserId, |
|
||||
CreateUserName = u.CreateUserName, |
|
||||
UpdateTime = u.UpdateTime, |
|
||||
UpdateUserId = u.UpdateUserId, |
|
||||
UpdateUserName = u.UpdateUserName, |
|
||||
TestType = u.TestType, |
|
||||
IsDelete = u.IsDelete |
|
||||
}) |
|
||||
.Mapper(r => |
|
||||
{ |
|
||||
r.Items = _itemRepository.AsQueryable().Where(i => i.GeneticTestResultId == r.Id) |
|
||||
.Select(i => new GeneticItemOutput() |
|
||||
{ |
|
||||
RiskLevel = i.RiskLevel, |
|
||||
CreateUserId = i.CreateUserId, |
|
||||
CreateUserName = i.CreateUserName, |
|
||||
CreateTime = i.CreateTime, |
|
||||
UpdateUserId = i.UpdateUserId, |
|
||||
UpdateUserName = i.UpdateUserName, |
|
||||
UpdateTime = i.UpdateTime, |
|
||||
GeneticTestResultId = i.GeneticTestResultId, |
|
||||
IsDelete = i.IsDelete, |
|
||||
RiskScore = i.RiskScore, |
|
||||
Growth = i.Growth, |
|
||||
AverageRiskScore = i.AverageRiskScore, |
|
||||
Genetics = i.Genetics, |
|
||||
Name = i.Name |
|
||||
}).ToList(); |
|
||||
}) |
|
||||
.ToPagedListAsync(queryInput.Page, queryInput.PageSize); |
|
||||
} |
|
||||
|
|
||||
[UnitOfWork] |
|
||||
[ApiDescriptionSettings(Name = "Add"), HttpPost] |
|
||||
[DisplayName("Add")] |
|
||||
public async Task<long?> AddGeneticTestResult(GeneticTestResultInput input) |
|
||||
{ |
|
||||
var id = await _resultRepository.InsertReturnSnowflakeIdAsync(new GeneticTestResultEntity() |
|
||||
{ |
|
||||
CustomerId = input.CustomerId, |
|
||||
Code = input.Code, |
|
||||
Status = input.Status, |
|
||||
Barcode = input.Barcode, |
|
||||
GenerationTime = input.GenerationTime, |
|
||||
CollectionTime = input.CollectionTime, |
|
||||
TestType = input.TestType |
|
||||
}); |
|
||||
if (input.Items is not null) |
|
||||
{ |
|
||||
await _itemRepository.InsertRangeAsync(input.Items.Select(i => new GeneticItemTestResultEntity() |
|
||||
{ |
|
||||
Name = i.Name, |
|
||||
RiskScore = i.RiskScore, |
|
||||
RiskLevel = i.RiskLevel, |
|
||||
AverageRiskScore = i.AverageRiskScore, |
|
||||
Genetics = i.Genetics, |
|
||||
Growth = i.Growth, |
|
||||
GeneticTestResultId = id |
|
||||
}).ToArray()); |
|
||||
} |
|
||||
|
|
||||
return id; |
|
||||
} |
|
||||
|
|
||||
[UnitOfWork] |
|
||||
[ApiDescriptionSettings(Name = "Update"), HttpPost] |
|
||||
[DisplayName("Update")] |
|
||||
public async Task UpdateGeneticTestResult(GeneticTestResultUpdateInput input) |
|
||||
{ |
|
||||
await _resultRepository.UpdateAsync(new GeneticTestResultEntity() |
|
||||
{ |
|
||||
Id = input.Id, |
|
||||
CustomerId = input.CustomerId, |
|
||||
Code = input.Code, |
|
||||
Status = input.Status, |
|
||||
Barcode = input.Barcode, |
|
||||
GenerationTime = input.GenerationTime, |
|
||||
TestType = input.TestType, |
|
||||
CollectionTime = input.CollectionTime |
|
||||
}); |
|
||||
if (input.Items is not null) |
|
||||
{ |
|
||||
await _itemRepository.DeleteAsync(i => i.GeneticTestResultId == input.Id); |
|
||||
await _itemRepository.InsertRangeAsync(input.Items.Select(i => new GeneticItemTestResultEntity() |
|
||||
{ |
|
||||
Name = i.Name, |
|
||||
RiskScore = i.RiskScore, |
|
||||
RiskLevel = i.RiskLevel, |
|
||||
AverageRiskScore = i.AverageRiskScore, |
|
||||
Genetics = i.Genetics, |
|
||||
Growth = i.Growth, |
|
||||
GeneticTestResultId = input.Id |
|
||||
}).ToArray()); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
[UnitOfWork] |
|
||||
[ApiDescriptionSettings(Name = "Delete"), HttpPost] |
|
||||
[DisplayName("Delete")] |
|
||||
public async Task DeleteGeneticTestResult(long? id) |
|
||||
{ |
|
||||
await _resultRepository.DeleteByIdAsync(id); |
|
||||
await _itemRepository.DeleteAsync(i => i.GeneticTestResultId == id); |
|
||||
} |
|
||||
|
|
||||
[ApiDescriptionSettings(Name = "Bind"), HttpPost] |
|
||||
[DisplayName("Bind")] |
|
||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)] |
|
||||
public async Task<long> BindGeneticTestBarcode(BindGeneticTestBarcodeInput input) |
|
||||
{ |
|
||||
var entity = new GeneticTestResultEntity() |
|
||||
{ |
|
||||
CustomerId = input.CustomerId, |
|
||||
Barcode = input.Barcode, |
|
||||
Status = GeneticTestStatus.Sampled |
|
||||
}; |
|
||||
var id = await _resultRepository.InsertReturnSnowflakeIdAsync(entity); |
|
||||
return id; |
|
||||
} |
|
||||
} |
|
@ -1,26 +0,0 @@ |
|||||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|
||||
//
|
|
||||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|
||||
|
|
||||
using Admin.NET.Bodk.Genetic.Entities; |
|
||||
|
|
||||
namespace Admin.NET.Bodk.Genetic.Models; |
|
||||
|
|
||||
public class GeneticItemOutput : GeneticItemTestResultEntity |
|
||||
{ |
|
||||
} |
|
||||
|
|
||||
public class GeneticItemInput |
|
||||
{ |
|
||||
public string Name { get; set; } |
|
||||
|
|
||||
public float Growth { get; set; } |
|
||||
|
|
||||
public float AverageRiskScore { get; set; } |
|
||||
|
|
||||
public float RiskScore { get; set; } |
|
||||
|
|
||||
public int RiskLevel { get; set; } |
|
||||
|
|
||||
public List<Genetic>? Genetics { get; set; } |
|
||||
} |
|
@ -1,62 +0,0 @@ |
|||||
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|
||||
//
|
|
||||
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|
||||
|
|
||||
using Admin.NET.Bodk.Genetic.Entities; |
|
||||
using Admin.NET.Core; |
|
||||
|
|
||||
namespace Admin.NET.Bodk.Genetic.Models; |
|
||||
|
|
||||
public class GeneticTestResultQueryInput : BasePageInput |
|
||||
{ |
|
||||
public long? CustomerId { get; set; } |
|
||||
|
|
||||
public string? Code { get; set; } |
|
||||
|
|
||||
public string? Barcode { get; set; } |
|
||||
|
|
||||
public GeneticTestStatus? Status { get; set; } |
|
||||
} |
|
||||
|
|
||||
public class GeneticTestResultInput |
|
||||
{ |
|
||||
public long CustomerId { get; set; } |
|
||||
|
|
||||
public string Code { get; set; } |
|
||||
|
|
||||
public string Barcode { get; set; } |
|
||||
|
|
||||
public string TestType { get; set; } |
|
||||
|
|
||||
public GeneticTestStatus Status { get; set; } |
|
||||
|
|
||||
public DateTime GenerationTime { get; set; } |
|
||||
|
|
||||
public DateTime CollectionTime { get; set; } |
|
||||
|
|
||||
public List<GeneticItemInput>? Items { get; set; } |
|
||||
} |
|
||||
|
|
||||
public class GeneticTestResultUpdateInput : BaseIdInput |
|
||||
{ |
|
||||
public long CustomerId { get; set; } |
|
||||
|
|
||||
public string Code { get; set; } |
|
||||
|
|
||||
public string Barcode { get; set; } |
|
||||
|
|
||||
public string TestType { get; set; } |
|
||||
|
|
||||
public GeneticTestStatus Status { get; set; } |
|
||||
|
|
||||
public DateTime GenerationTime { get; set; } |
|
||||
|
|
||||
public DateTime CollectionTime { get; set; } |
|
||||
|
|
||||
public List<GeneticItemInput>? Items { get; set; } |
|
||||
} |
|
||||
|
|
||||
public class GeneticTestResultOutput : GeneticTestResultEntity |
|
||||
{ |
|
||||
public List<GeneticItemOutput>? Items { get; set; } |
|
||||
} |
|
@ -0,0 +1,65 @@ |
|||||
|
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
||||
|
//
|
||||
|
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
||||
|
|
||||
|
using Admin.NET.Core; |
||||
|
|
||||
|
namespace Admin.NET.Bodk.Genetic.Models.Reports; |
||||
|
|
||||
|
public class AddReportInput |
||||
|
{ |
||||
|
public long CustomerId { get; set; } |
||||
|
|
||||
|
public string? Barcode { get; set; } |
||||
|
|
||||
|
public string? SampleType { get; set; } |
||||
|
|
||||
|
public string? TestingType { get; set; } |
||||
|
|
||||
|
public string? TestingMethod { get; set; } |
||||
|
|
||||
|
public DateTime? SubmissionTime { get; set; } |
||||
|
|
||||
|
public DateTime? ReportTime { get; set; } |
||||
|
|
||||
|
public bool? SampleQuality { get; set; } |
||||
|
|
||||
|
public bool? DnaExtraction { get; set; } |
||||
|
|
||||
|
public bool? Pcr { get; set; } |
||||
|
|
||||
|
public bool? TofMs { get; set; } |
||||
|
|
||||
|
public bool? GenotypingAnalysis { get; set; } |
||||
|
|
||||
|
public bool? GeneticRiskAssessment { get; set; } |
||||
|
|
||||
|
public bool? Report { get; set; } |
||||
|
|
||||
|
public List<AddTumorReportInput> Tumors { get; set; } = []; |
||||
|
} |
||||
|
|
||||
|
public class AddTumorReportInput |
||||
|
{ |
||||
|
public long? Id { get; set; } |
||||
|
public long TumorId { get; set; } |
||||
|
|
||||
|
public float RiskScore { get; set; } |
||||
|
|
||||
|
public int RiskLevel { get; set; } |
||||
|
|
||||
|
public List<AddTumorLocusReportInput> Loci { get; set; } = []; |
||||
|
} |
||||
|
|
||||
|
public class AddTumorLocusReportInput |
||||
|
{ |
||||
|
public long? Id { get; set; } |
||||
|
public long LocusId { get; set; } |
||||
|
|
||||
|
public long RiskId { get; set; } |
||||
|
} |
||||
|
|
||||
|
public class UpdateReportInput : AddReportInput |
||||
|
{ |
||||
|
public long Id { get; set; } |
||||
|
} |
@ -0,0 +1,85 @@ |
|||||
|
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
||||
|
//
|
||||
|
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
||||
|
|
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using Admin.NET.Core; |
||||
|
|
||||
|
namespace Admin.NET.Bodk.Genetic.Models.Reports; |
||||
|
|
||||
|
public class QueryReportInput : BasePageInput |
||||
|
{ |
||||
|
[Required(ErrorMessage = "客户Id不能为空")] public long CustomerId { get; set; } |
||||
|
} |
||||
|
|
||||
|
public class ReportOutput |
||||
|
{ |
||||
|
public long Id { get; set; } |
||||
|
public long CustomerId { get; set; } |
||||
|
|
||||
|
public string? Barcode { get; set; } |
||||
|
|
||||
|
public string? SampleType { get; set; } |
||||
|
|
||||
|
public string? TestingType { get; set; } |
||||
|
|
||||
|
public string? TestingMethod { get; set; } |
||||
|
|
||||
|
public DateTime? SubmissionTime { get; set; } |
||||
|
|
||||
|
public DateTime? ReportTime { get; set; } |
||||
|
|
||||
|
public bool? SampleQuality { get; set; } |
||||
|
|
||||
|
public bool? DnaExtraction { get; set; } |
||||
|
|
||||
|
public bool? Pcr { get; set; } |
||||
|
|
||||
|
public bool? TofMs { get; set; } |
||||
|
|
||||
|
public bool? GenotypingAnalysis { get; set; } |
||||
|
|
||||
|
public bool? GeneticRiskAssessment { get; set; } |
||||
|
|
||||
|
public bool? Report { get; set; } |
||||
|
|
||||
|
public List<TumorOutput> Tumors { get; set; } = new List<TumorOutput>(); |
||||
|
} |
||||
|
|
||||
|
public class TumorOutput |
||||
|
{ |
||||
|
public long Id { get; set; } |
||||
|
|
||||
|
public long ReportId { get; set; } |
||||
|
|
||||
|
public long TumorId { get; set; } |
||||
|
|
||||
|
public string Code { get; set; } |
||||
|
|
||||
|
public string TumorName { get; set; } |
||||
|
|
||||
|
public string Description { get; set; } |
||||
|
|
||||
|
public double RiskScore { get; set; } |
||||
|
|
||||
|
public double AvaRiskScore { get; set; } |
||||
|
|
||||
|
public int RiskLevel { get; set; } |
||||
|
|
||||
|
public List<LocusOutput> Loci { get; set; } = []; |
||||
|
} |
||||
|
|
||||
|
public class LocusOutput |
||||
|
{ |
||||
|
public long Id { get; set; } |
||||
|
|
||||
|
public string Description { get; set; } |
||||
|
|
||||
|
public string GenekType { get; set; } |
||||
|
|
||||
|
public bool Risk { get; set; } |
||||
|
|
||||
|
public string LocusName { get; set; } |
||||
|
|
||||
|
public string Position { get; set; } |
||||
|
} |
@ -0,0 +1,93 @@ |
|||||
|
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
||||
|
//
|
||||
|
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
||||
|
|
||||
|
using System.ComponentModel; |
||||
|
using Admin.NET.Bodk.Core; |
||||
|
using Admin.NET.Bodk.Genetic.Entities.Tumors; |
||||
|
using Admin.NET.Core; |
||||
|
using Admin.NET.Core.Service; |
||||
|
using Furion.FriendlyException; |
||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer; |
||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using SqlSugar; |
||||
|
|
||||
|
namespace Admin.NET.Bodk.Genetic; |
||||
|
|
||||
|
[ApiDescriptionSettings(Groups = new[] { "Bodk Groups" }, Name = "Tumor", Description = "肿瘤服务")] |
||||
|
public class TumorService( |
||||
|
UserManager userManager, |
||||
|
SysOrgService sysOrgService, |
||||
|
SysUserService sysUserService, |
||||
|
SqlSugarRepository<TumorEntity> tumorRepository, |
||||
|
SqlSugarRepository<TumorGeneLocusEntity> tumorGeneLocusRepository, |
||||
|
SqlSugarRepository<GeneLocusRiskEntity> geneLocusRiskRepository, |
||||
|
SqlSugarRepository<GeneLocusEntity> geneLocusRepository, |
||||
|
SqlSugarRepository<GeneTypeEntity> geneTypeRepository) |
||||
|
: ServiceBase(userManager, sysOrgService, sysUserService) |
||||
|
{ |
||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)] |
||||
|
[DisplayName("获取肿瘤信息")] |
||||
|
public async Task<TumorEntity?> GetTumor(string code) |
||||
|
{ |
||||
|
var tumor = await tumorRepository.AsQueryable() |
||||
|
.FirstAsync(t => t.Code == code); |
||||
|
if (tumor is null) |
||||
|
throw Oops.Oh("肿瘤Code不存在"); |
||||
|
var locusIds = await tumorGeneLocusRepository.AsQueryable() |
||||
|
.Where(tl => tl.TumorId == tumor.Id).Select(l => l.LocusId).ToListAsync(); |
||||
|
var geneLoci = await geneLocusRepository.AsQueryable() |
||||
|
.Where(gl => locusIds.Contains(gl.Id)).ToListAsync(); |
||||
|
foreach (var geneLocus in geneLoci) |
||||
|
{ |
||||
|
var riskIds = await geneLocusRiskRepository.AsQueryable() |
||||
|
.Where(r => r.LocusId == geneLocus.Id).Select(r => r.RiskId).ToListAsync(); |
||||
|
geneLocus.Types = await geneTypeRepository.AsQueryable() |
||||
|
.Where(t => riskIds.Contains(t.Id)).ToListAsync(); |
||||
|
} |
||||
|
|
||||
|
tumor.GeneLoci = geneLoci; |
||||
|
return tumor; |
||||
|
} |
||||
|
|
||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)] |
||||
|
[DisplayName("添加一条肿瘤记录")] |
||||
|
public async Task AddTumor(TumorEntity tumor) |
||||
|
{ |
||||
|
var db = tumorRepository.Context; |
||||
|
try |
||||
|
{ |
||||
|
await db.Ado.BeginTranAsync(); |
||||
|
var tumorId = await db.Insertable(tumor).ExecuteReturnSnowflakeIdAsync(); |
||||
|
tumor.Id = tumorId; |
||||
|
foreach (var geneLocus in tumor.GeneLoci) |
||||
|
{ |
||||
|
var locusId = await db.Insertable(geneLocus).ExecuteReturnSnowflakeIdAsync(); |
||||
|
var tumorGeneLocusEntity = new TumorGeneLocusEntity() |
||||
|
{ |
||||
|
LocusId = locusId, |
||||
|
TumorId = tumorId |
||||
|
}; |
||||
|
await db.Insertable(tumorGeneLocusEntity).ExecuteCommandAsync(); |
||||
|
foreach (var risk in geneLocus.Types) |
||||
|
{ |
||||
|
var riskId = await db.Insertable(risk).ExecuteReturnSnowflakeIdAsync(); |
||||
|
var geneLocusRiskEntity = new GeneLocusRiskEntity() |
||||
|
{ |
||||
|
RiskId = riskId, |
||||
|
LocusId = locusId |
||||
|
}; |
||||
|
await db.Insertable(geneLocusRiskEntity).ExecuteCommandAsync(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
await db.Ado.CommitTranAsync(); |
||||
|
} |
||||
|
catch |
||||
|
{ |
||||
|
await db.Ado.RollbackTranAsync(); |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
||||
|
//
|
||||
|
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
||||
|
|
||||
|
namespace Admin.NET.Core.Service; |
||||
|
|
||||
|
public class SysStationServiceService: IDynamicApiController, ITransient |
||||
|
{ |
||||
|
|
||||
|
} |
Loading…
Reference in new issue