You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
177 lines
6.6 KiB
177 lines
6.6 KiB
using Shentun.WebPeis.AppointPatientRegisters;
|
|
using Shentun.WebPeis.Asbitems;
|
|
using Shentun.WebPeis.Models;
|
|
using Shentun.WebPeis.Persons;
|
|
using Shentun.WebPeis.QuestionRegisters;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp.Domain.Repositories;
|
|
using Volo.Abp.Modularity;
|
|
using Volo.Abp.Uow;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Shentun.WebPeis
|
|
{
|
|
public class QuestionRegisterAppServiceTest<TStartupModule> : WebPeisApplicationTestBase<TStartupModule>
|
|
where TStartupModule : IAbpModule
|
|
{
|
|
private readonly IRepository<QuestionRegister> _repository;
|
|
private readonly QuestionRegisterAppService _appService;
|
|
private readonly ITestOutputHelper _output;
|
|
private readonly IUnitOfWorkManager _unitOfWorkManager;
|
|
public QuestionRegisterAppServiceTest(ITestOutputHelper output)
|
|
{
|
|
_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
|
|
_repository = GetRequiredService<IRepository<QuestionRegister>>();
|
|
_appService = GetRequiredService<QuestionRegisterAppService>();
|
|
_output = output;
|
|
}
|
|
|
|
[Fact]
|
|
public async Task GetByPersonId()
|
|
{
|
|
using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
|
|
{
|
|
|
|
var entity = await _appService.GetByPersonIdAsync(new PersonIdInputDto()
|
|
{
|
|
PersonId = new Guid("3a12d72c-19d9-e8b2-71f6-cf283103e191") // 3a12d7fa-63f1-d549-c2f8-01123e5b7a8a
|
|
});
|
|
foreach (var item in entity.QuestionRegisterItems)
|
|
{
|
|
_output.WriteLine("-----------" + item.QuestionName + "-" + item.AnswerType );
|
|
foreach (var answer in item.QuestionRegisterAnswers)
|
|
{
|
|
_output.WriteLine(answer.QuestionAnswerName + "-" + answer.ChildAnswerType + answer.IsSelected);
|
|
//answer.IsSelected = 'Y';
|
|
foreach(var childAnswer in answer.Childs)
|
|
{
|
|
_output.WriteLine("----"+childAnswer.QuestionAnswerName + childAnswer.IsSelected);
|
|
//childAnswer.IsSelected = 'Y';
|
|
}
|
|
}
|
|
}
|
|
//var questionRegister = await _repository.FindAsync(o=>o.QuestionRegisterId == entity.QuestionRegisterId);
|
|
//if(questionRegister == null)
|
|
//{
|
|
// await _appService.CreateAsync(entity);
|
|
//}
|
|
//else
|
|
//{
|
|
// await _appService.UpdateAsync(entity);
|
|
//}
|
|
|
|
await unitOfWork.CompleteAsync();
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public async Task GetSubjectTypeListByPersonIdAsync()
|
|
{
|
|
using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
|
|
{
|
|
|
|
var entity = await _appService.GetSubjectTypeListByPersonIdAsync(new PersonIdInputDto()
|
|
{
|
|
PersonId = new Guid("3a12d72c-19d9-e8b2-71f6-cf283103e191") // 3a12d7fa-63f1-d549-c2f8-01123e5b7a8a
|
|
});
|
|
foreach (var item in entity)
|
|
{
|
|
_output.WriteLine("-----------" + item.QuestionSubjectTypeName );
|
|
foreach (var answer in item.Answers)
|
|
{
|
|
_output.WriteLine(answer.QuestionAnswerName );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
await unitOfWork.CompleteAsync();
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public async Task GetQuestionRegisterListByPersonIdAsync()
|
|
{
|
|
using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
|
|
{
|
|
|
|
var entity = await _appService.GetQuestionRegisterListByPersonIdAsync(new PersonIdInputDto()
|
|
{
|
|
PersonId = new Guid("3a12d72c-19d9-e8b2-71f6-cf283103e191") // 3a12d7fa-63f1-d549-c2f8-01123e5b7a8a
|
|
});
|
|
foreach (var item in entity)
|
|
{
|
|
_output.WriteLine("-----------" + item.QuestionName);
|
|
foreach (var answer in item.Answers)
|
|
{
|
|
_output.WriteLine(answer.Answer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
await unitOfWork.CompleteAsync();
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public async Task GetDiseaseRiskListByPersonIdAsync()
|
|
{
|
|
using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
|
|
{
|
|
|
|
var entity = await _appService.GetDiseaseRiskListByPersonIdAsync(new PersonIdInputDto()
|
|
{
|
|
PersonId = new Guid("3a12d72c-19d9-e8b2-71f6-cf283103e191") // 3a12d7fa-63f1-d549-c2f8-01123e5b7a8a
|
|
});
|
|
foreach (var item in entity)
|
|
{
|
|
_output.WriteLine(item.DiseaseRiskName + item.DiseaseRiskLevelName);
|
|
|
|
}
|
|
await unitOfWork.CompleteAsync();
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public async Task GetDiseaseRiskByPersonDiseaseRiskIdAsync()
|
|
{
|
|
using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
|
|
{
|
|
|
|
var entity = await _appService.GetDiseaseRiskByPersonDiseaseRiskIdAsync(new PersonDiseaseRiskIdInputDto()
|
|
{
|
|
PersonId = new Guid("3a12d72c-19d9-e8b2-71f6-cf283103e191"), // 3a12d7fa-63f1-d549-c2f8-01123e5b7a8a
|
|
DiseaseRiskId = new Guid("81c57075-4809-488b-aaa4-7e717c9f74a2")
|
|
});
|
|
_output.WriteLine(entity.DiseaseRiskName + entity.DiseaseRiskLevelName + entity.Explain + entity.Suggestion);
|
|
foreach (var item in entity.DiseaseRiskLevels)
|
|
{
|
|
_output.WriteLine(item.DiseaseRiskLevelName);
|
|
|
|
}
|
|
_output.WriteLine("----推荐项目----");
|
|
foreach (var item in entity.Asbitems)
|
|
{
|
|
_output.WriteLine(item.AsbitemName );
|
|
|
|
}
|
|
_output.WriteLine("----风险因素----");
|
|
|
|
foreach (var item in entity.Answers)
|
|
{
|
|
_output.WriteLine(item.Answer);
|
|
|
|
}
|
|
await unitOfWork.CompleteAsync();
|
|
}
|
|
}
|
|
}
|
|
}
|