修改一版
parent
6cffb32af4
commit
56aa39cf4d
|
@ -22,7 +22,7 @@ namespace IRaCIS.Application.Services
|
||||||
public class ReadingQuestionService : BaseService
|
public class ReadingQuestionService : BaseService
|
||||||
{
|
{
|
||||||
|
|
||||||
public IRepository<SubjectVisit> _subjectVisitRepository;
|
private readonly IRepository<SubjectVisit> _subjectVisitRepository;
|
||||||
private readonly IRepository<ReadingQuestionCriterionSystem> _readingQuestionCriterionSystemRepository;
|
private readonly IRepository<ReadingQuestionCriterionSystem> _readingQuestionCriterionSystemRepository;
|
||||||
private readonly IRepository<ReadingQuestionCriterionTrial> _readingQuestionCriterionTrialRepository;
|
private readonly IRepository<ReadingQuestionCriterionTrial> _readingQuestionCriterionTrialRepository;
|
||||||
private readonly IRepository<ReadingQuestionSystem> _readingQuestionSystemRepository;
|
private readonly IRepository<ReadingQuestionSystem> _readingQuestionSystemRepository;
|
||||||
|
@ -32,25 +32,25 @@ namespace IRaCIS.Application.Services
|
||||||
private readonly IRepository<Dictionary> _dictionaryRepository;
|
private readonly IRepository<Dictionary> _dictionaryRepository;
|
||||||
private readonly IRepository<PreviousPDF> _previousPDFRepository;
|
private readonly IRepository<PreviousPDF> _previousPDFRepository;
|
||||||
|
|
||||||
public ReadingQuestionService(IRepository<SubjectVisit> subjectVisitRepository,
|
public ReadingQuestionService(
|
||||||
|
IRepository<SubjectVisit> subjectVisitRepository,
|
||||||
IRepository<ReadingQuestionCriterionSystem> readingQuestionCriterionSystemRepository,
|
IRepository<ReadingQuestionCriterionSystem> readingQuestionCriterionSystemRepository,
|
||||||
IRepository<ReadingQuestionCriterionTrial> readingQuestionCriterionTrialRepository,
|
IRepository<ReadingQuestionCriterionTrial> readingQuestionCriterionTrialRepository,
|
||||||
IRepository<ReadingQuestionSystem> readingQuestionSystemRepository,
|
IRepository<ReadingQuestionSystem> readingQuestionSystemRepository,
|
||||||
IRepository<ReadingQuestionTrial> readingQuestionTrialRepository,
|
IRepository<ReadingQuestionTrial> readingQuestionTrialRepository,
|
||||||
IRepository<ClinicalDataTrialSet> ClinicalDataTrialSetRepository,
|
IRepository<ClinicalDataTrialSet> ClinicalDataTrialSetRepository,
|
||||||
IRepository<ClinicalDataSystemSet> ClinicalDataSystemSetRepository,
|
IRepository<ClinicalDataSystemSet> ClinicalDataSystemSetRepository,
|
||||||
IRepository<Dictionary> dictionaryRepository,
|
IRepository<Dictionary> dictionaryRepository,
|
||||||
IRepository<PreviousPDF> previousPDFRepository
|
IRepository<PreviousPDF> previousPDFRepository
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_subjectVisitRepository = subjectVisitRepository;
|
this._subjectVisitRepository = subjectVisitRepository;
|
||||||
this._readingQuestionCriterionSystemRepository = readingQuestionCriterionSystemRepository;
|
this._readingQuestionCriterionSystemRepository = readingQuestionCriterionSystemRepository;
|
||||||
this._readingQuestionCriterionTrialRepository = readingQuestionCriterionTrialRepository;
|
this._readingQuestionCriterionTrialRepository = readingQuestionCriterionTrialRepository;
|
||||||
this._readingQuestionSystemRepository = readingQuestionSystemRepository;
|
this._readingQuestionSystemRepository = readingQuestionSystemRepository;
|
||||||
this._readingQuestionTrialRepository = readingQuestionTrialRepository;
|
this._readingQuestionTrialRepository = readingQuestionTrialRepository;
|
||||||
_clinicalDataTrialSetRepository = ClinicalDataTrialSetRepository;
|
this._clinicalDataTrialSetRepository = ClinicalDataTrialSetRepository;
|
||||||
_clinicalDataSystemSetRepository = ClinicalDataSystemSetRepository;
|
this._clinicalDataSystemSetRepository = ClinicalDataSystemSetRepository;
|
||||||
this._dictionaryRepository = dictionaryRepository;
|
this._dictionaryRepository = dictionaryRepository;
|
||||||
this._previousPDFRepository = previousPDFRepository;
|
this._previousPDFRepository = previousPDFRepository;
|
||||||
}
|
}
|
||||||
|
@ -107,17 +107,13 @@ namespace IRaCIS.Application.Services
|
||||||
private async Task AddSystemQuestionCriterion()
|
private async Task AddSystemQuestionCriterion()
|
||||||
{
|
{
|
||||||
var useSystemQuestionCriterionIds = _readingQuestionCriterionSystemRepository.Select(x => x.CriterionId);
|
var useSystemQuestionCriterionIds = _readingQuestionCriterionSystemRepository.Select(x => x.CriterionId);
|
||||||
|
|
||||||
var dictionaryParentId =await _dictionaryRepository.Where(x => x.Code == "ReadingStandard").Select(x => x.Id).FirstOrDefaultAsync();
|
var dictionaryParentId =await _dictionaryRepository.Where(x => x.Code == "ReadingStandard").Select(x => x.Id).FirstOrDefaultAsync();
|
||||||
|
|
||||||
var criterionList = await _dictionaryRepository.Where(x => x.ParentId == dictionaryParentId && !useSystemQuestionCriterionIds.Contains(x.Id))
|
var criterionList = await _dictionaryRepository.Where(x => x.ParentId == dictionaryParentId && !useSystemQuestionCriterionIds.Contains(x.Id))
|
||||||
.Select(x => new CriterionList()
|
.Select(x => new CriterionList()
|
||||||
{
|
{
|
||||||
Id = x.Id,
|
Id = x.Id,
|
||||||
Value = x.Value
|
Value = x.Value
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
|
|
||||||
|
|
||||||
List<ReadingQuestionCriterionSystem> needAddCriterionList = new List<ReadingQuestionCriterionSystem>();
|
List<ReadingQuestionCriterionSystem> needAddCriterionList = new List<ReadingQuestionCriterionSystem>();
|
||||||
criterionList.ForEach(x =>
|
criterionList.ForEach(x =>
|
||||||
{
|
{
|
||||||
|
@ -126,9 +122,7 @@ namespace IRaCIS.Application.Services
|
||||||
CriterionId = x.Id,
|
CriterionId = x.Id,
|
||||||
CriterionName = x.Value,
|
CriterionName = x.Value,
|
||||||
IsEnable = false,
|
IsEnable = false,
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
await _readingQuestionCriterionSystemRepository.AddRangeAsync(needAddCriterionList);
|
await _readingQuestionCriterionSystemRepository.AddRangeAsync(needAddCriterionList);
|
||||||
|
|
||||||
|
@ -181,16 +175,16 @@ namespace IRaCIS.Application.Services
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除系统问题
|
/// 删除系统问题
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="readingQuestionSystemId"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpDelete("{readingQuestionSystemId:guid}")]
|
[HttpDelete("{readingQuestionSystemId:guid}")]
|
||||||
public async Task<IResponseOutput> DeleteReadingQuestionSystem(Guid readingQuestionSystemId)
|
public async Task<IResponseOutput> DeleteReadingQuestionSystem(Guid id)
|
||||||
{
|
{
|
||||||
if (await _readingQuestionSystemRepository.AnyAsync(x => x.ParentId == readingQuestionSystemId))
|
if (await _readingQuestionSystemRepository.AnyAsync(x => x.ParentId == id))
|
||||||
{
|
{
|
||||||
return ResponseOutput.NotOk("此问题存在子问题,请先删除子问题");
|
return ResponseOutput.NotOk("此问题存在子问题,请先删除子问题");
|
||||||
}
|
}
|
||||||
await _readingQuestionSystemRepository.DeleteFromQueryAsync(t => t.Id == readingQuestionSystemId);
|
await _readingQuestionSystemRepository.DeleteFromQueryAsync(t => t.Id == id);
|
||||||
var success = await _readingQuestionSystemRepository.SaveChangesAsync();
|
var success = await _readingQuestionSystemRepository.SaveChangesAsync();
|
||||||
return ResponseOutput.Result(success);
|
return ResponseOutput.Result(success);
|
||||||
}
|
}
|
||||||
|
@ -205,10 +199,8 @@ namespace IRaCIS.Application.Services
|
||||||
var trialUsrSystemIds = _readingQuestionCriterionTrialRepository.Where(x => x.TrialId == trialId && x.ReadingQuestionCriterionSystemId != null)
|
var trialUsrSystemIds = _readingQuestionCriterionTrialRepository.Where(x => x.TrialId == trialId && x.ReadingQuestionCriterionSystemId != null)
|
||||||
.Select(x => x.ReadingQuestionCriterionSystemId);
|
.Select(x => x.ReadingQuestionCriterionSystemId);
|
||||||
var needAddSystemDataList = await _readingQuestionCriterionSystemRepository.Where(x => !trialUsrSystemIds.Contains(x.Id)&&x.IsEnable).Include(x=>x.ReadingQuestionSystemList).ToListAsync();
|
var needAddSystemDataList = await _readingQuestionCriterionSystemRepository.Where(x => !trialUsrSystemIds.Contains(x.Id)&&x.IsEnable).Include(x=>x.ReadingQuestionSystemList).ToListAsync();
|
||||||
|
|
||||||
List<ReadingQuestionCriterionTrial> needAddCriterionList = new List<ReadingQuestionCriterionTrial>();
|
List<ReadingQuestionCriterionTrial> needAddCriterionList = new List<ReadingQuestionCriterionTrial>();
|
||||||
List<ReadingQuestionTrial> needAddQuestionList = new List<ReadingQuestionTrial>();
|
List<ReadingQuestionTrial> needAddQuestionList = new List<ReadingQuestionTrial>();
|
||||||
|
|
||||||
needAddSystemDataList.ForEach(x =>
|
needAddSystemDataList.ForEach(x =>
|
||||||
{
|
{
|
||||||
var criterion = new ReadingQuestionCriterionTrial()
|
var criterion = new ReadingQuestionCriterionTrial()
|
||||||
|
@ -219,25 +211,14 @@ namespace IRaCIS.Application.Services
|
||||||
TrialId = trialId,
|
TrialId = trialId,
|
||||||
Id = NewId.NextGuid(),
|
Id = NewId.NextGuid(),
|
||||||
};
|
};
|
||||||
|
|
||||||
List<ReadingQuestionSystem> systemQuestionList = x.ReadingQuestionSystemList.Clone();
|
List<ReadingQuestionSystem> systemQuestionList = x.ReadingQuestionSystemList.Clone();
|
||||||
|
|
||||||
List<ReadingQuestionTrial> readingQuestionTrialList = new List<ReadingQuestionTrial>();
|
List<ReadingQuestionTrial> readingQuestionTrialList = new List<ReadingQuestionTrial>();
|
||||||
|
|
||||||
SetChildParentQuestion(criterion.Id, trialId, systemQuestionList, readingQuestionTrialList);
|
SetChildParentQuestion(criterion.Id, trialId, systemQuestionList, readingQuestionTrialList);
|
||||||
|
|
||||||
|
|
||||||
needAddCriterionList.Add(criterion);
|
needAddCriterionList.Add(criterion);
|
||||||
|
|
||||||
needAddQuestionList.AddRange(readingQuestionTrialList);
|
needAddQuestionList.AddRange(readingQuestionTrialList);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
await _readingQuestionCriterionTrialRepository.AddRangeAsync(needAddCriterionList);
|
await _readingQuestionCriterionTrialRepository.AddRangeAsync(needAddCriterionList);
|
||||||
|
|
||||||
await _readingQuestionTrialRepository.AddRangeAsync(needAddQuestionList);
|
await _readingQuestionTrialRepository.AddRangeAsync(needAddQuestionList);
|
||||||
|
|
||||||
await _readingQuestionTrialRepository.SaveChangesAsync();
|
await _readingQuestionTrialRepository.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,12 +327,12 @@ namespace IRaCIS.Application.Services
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除项目问题标准(项目)
|
/// 删除项目问题标准(项目)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="readingQuestionCriterionTrialId"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpDelete("{readingQuestionCriterionTrialId:guid}")]
|
[HttpDelete("{id:guid}")]
|
||||||
public async Task<IResponseOutput> DeleteReadingQuestionCriterionTrial(Guid readingQuestionCriterionTrialId)
|
public async Task<IResponseOutput> DeleteReadingQuestionCriterionTrial(Guid id)
|
||||||
{
|
{
|
||||||
await _readingQuestionCriterionTrialRepository.DeleteFromQueryAsync(t => t.Id == readingQuestionCriterionTrialId);
|
await _readingQuestionCriterionTrialRepository.DeleteFromQueryAsync(t => t.Id == id);
|
||||||
var success = await _readingQuestionCriterionTrialRepository.SaveChangesAsync();
|
var success = await _readingQuestionCriterionTrialRepository.SaveChangesAsync();
|
||||||
return ResponseOutput.Result(success);
|
return ResponseOutput.Result(success);
|
||||||
}
|
}
|
||||||
|
@ -389,16 +370,16 @@ namespace IRaCIS.Application.Services
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除项目问题(项目)
|
/// 删除项目问题(项目)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="readingQuestionTrialId"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpDelete("{readingQuestionTrialId:guid}")]
|
[HttpDelete("{readingQuestionTrialId:guid}")]
|
||||||
public async Task<IResponseOutput> DeleteReadingQuestionTrial(Guid readingQuestionTrialId)
|
public async Task<IResponseOutput> DeleteReadingQuestionTrial(Guid id)
|
||||||
{
|
{
|
||||||
if (await _readingQuestionTrialRepository.AnyAsync(x => x.ParentId == readingQuestionTrialId))
|
if (await _readingQuestionTrialRepository.AnyAsync(x => x.ParentId == id))
|
||||||
{
|
{
|
||||||
return ResponseOutput.NotOk("此问题存在子问题,请先删除子问题");
|
return ResponseOutput.NotOk("此问题存在子问题,请先删除子问题");
|
||||||
}
|
}
|
||||||
await _readingQuestionTrialRepository.DeleteFromQueryAsync(t => t.Id == readingQuestionTrialId);
|
await _readingQuestionTrialRepository.DeleteFromQueryAsync(t => t.Id == id);
|
||||||
var success = await _readingQuestionTrialRepository.SaveChangesAsync();
|
var success = await _readingQuestionTrialRepository.SaveChangesAsync();
|
||||||
return ResponseOutput.Result(success);
|
return ResponseOutput.Result(success);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue