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.

140 lines
5.1 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. using Shentun.WebPeis.AppointPatientRegisters;
  2. using Shentun.WebPeis.AppointRegisterAsbitems;
  3. using Shentun.WebPeis.Enums;
  4. using Shentun.WebPeis.Models;
  5. using Shentun.WebPeis.Persons;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using Volo.Abp.Domain.Repositories;
  12. using Volo.Abp.Modularity;
  13. using Volo.Abp.Uow;
  14. using Xunit;
  15. using Xunit.Abstractions;
  16. namespace Shentun.WebPeis
  17. {
  18. public class AppointPatientRegisterAppServiceTest<TStartupModule> : WebPeisApplicationTestBase<TStartupModule>
  19. where TStartupModule : IAbpModule
  20. {
  21. private readonly IRepository<AppointPatientRegister> _repository;
  22. private readonly AppointPatientRegisterAppService _appService;
  23. private readonly ITestOutputHelper _output;
  24. private readonly IUnitOfWorkManager _unitOfWorkManager;
  25. public AppointPatientRegisterAppServiceTest(ITestOutputHelper output)
  26. {
  27. _unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
  28. _repository = GetRequiredService<IRepository<AppointPatientRegister>>();
  29. _appService = GetRequiredService<AppointPatientRegisterAppService>();
  30. _output = output;
  31. }
  32. [Fact]
  33. public async Task CreateAsync()
  34. {
  35. using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
  36. {
  37. var entity = new CreateAppointPatientRegisterDto()
  38. {
  39. PersonId = new Guid("3a12d7fa-63f1-d549-c2f8-01123e5b7a8a"),
  40. CustomerOrgGroupId = null,
  41. CustomerOrgId = GuidFlag.PersonCustomerOrgId,
  42. MedicalCenterId = new Guid("150da355-dfbf-466b-9697-355836a862c4"),
  43. MedicalPackageId = null,
  44. AppointDate = DateTime.Now,
  45. CustomerOrgRegisterId = GuidFlag.PersonCustomerOrgRegisterId,
  46. PregnantFlag = PregnantFlag.None,
  47. Height = 170,
  48. Weight = 60
  49. };
  50. entity.Asbitems.Add(
  51. new CreateAppointRegisterAsbitemDto()
  52. {
  53. AsbitemId = new Guid("3a126b34-f6f0-56a1-e899-a092874acde7"),
  54. Amount = 1,
  55. ChargePrice = (decimal)30.5
  56. }
  57. );
  58. entity.Asbitems.Add(
  59. new CreateAppointRegisterAsbitemDto()
  60. {
  61. AsbitemId = new Guid("3a126b35-1163-6b80-6b57-7b5a7bc9e935"),
  62. Amount = 2,
  63. ChargePrice = (decimal)50.45
  64. }
  65. );
  66. var newEntity = await _appService.CreateAsync(entity);
  67. await unitOfWork.CompleteAsync();
  68. }
  69. }
  70. [Fact]
  71. public async Task GetListByFilterAsync()
  72. {
  73. using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
  74. {
  75. var entity = new AppointPatientRegisterInputDto()
  76. {
  77. MobilePhone = "18911254911",
  78. AppointStartDate = DateTime.Now.AddDays(-10),
  79. };
  80. var list = await _appService.GetListByFilterAsync(entity);
  81. foreach (var item in list)
  82. {
  83. _output.WriteLine(item.PersonName);
  84. }
  85. await unitOfWork.CompleteAsync();
  86. }
  87. }
  88. [Fact]
  89. public async Task GetAppointRegisterAsbitemListById()
  90. {
  91. using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
  92. {
  93. var entity = new AppointPatientRegisterIdInputDto()
  94. {
  95. AppointPatientRegisterId = new Guid("3a12ec60-278d-1814-753b-87ff8782aa26")
  96. };
  97. var list = await _appService.GetAppointRegisterAsbitemListByIdAsync(entity);
  98. foreach (var item in list)
  99. {
  100. _output.WriteLine(item.AsbitemName);
  101. }
  102. await unitOfWork.CompleteAsync();
  103. }
  104. }
  105. [Fact]
  106. public async Task GetRecommendMedicalPackageListByPersonIdAsync()
  107. {
  108. using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
  109. {
  110. var entity = new PersonIdInputDto()
  111. {
  112. PersonId = new Guid("3a12d72c-19d9-e8b2-71f6-cf283103e191")
  113. };
  114. var list = await _appService.GetRecommendMedicalPackageListByPersonIdAsync(entity);
  115. foreach (var item in list)
  116. {
  117. _output.WriteLine(item.MedicalPackageName);
  118. foreach(var item2 in item.Asbitems)
  119. {
  120. _output.WriteLine(item2.AsbitemName + "-" + item2.IsBelongMedicalPackage);
  121. }
  122. }
  123. await unitOfWork.CompleteAsync();
  124. }
  125. }
  126. }
  127. }