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.

153 lines
4.6 KiB

2 years ago
  1. using NPOI.POIFS.Properties;
  2. using Shentun.Peis.CustomerOrgs;
  3. using Shentun.Peis.DiagnosisFunctions;
  4. using Shentun.Peis.Models;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using TencentCloud.Ame.V20190916.Models;
  11. using Volo.Abp.Domain.Repositories;
  12. using Volo.Abp.Uow;
  13. using Xunit;
  14. using Xunit.Abstractions;
  15. namespace Shentun.Peis
  16. {
  17. public class DiagnosisFunctionAppServiceTest : PeisApplicationTestBase
  18. {
  19. private readonly IRepository<CustomerOrg, Guid> _repository;
  20. private readonly DiagnosisFunctionAppService _appService;
  21. private readonly ITestOutputHelper _output;
  22. private readonly IUnitOfWorkManager _unitOfWorkManager;
  23. public DiagnosisFunctionAppServiceTest(ITestOutputHelper testOutputHelper)
  24. {
  25. _output = testOutputHelper;
  26. _unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
  27. _repository = GetRequiredService<IRepository<CustomerOrg, Guid>>();
  28. _appService = GetRequiredService<DiagnosisFunctionAppService>();
  29. }
  30. [Fact]
  31. public void GetItemResult()
  32. {
  33. PatientDiagnosisInputArg patient = new PatientDiagnosisInputArg();
  34. patient.AsbitemId = Guid.NewGuid();
  35. patient.SexName = "男";
  36. patient.Age = 30;
  37. patient.Items = new List<ItemDiagnosisInputArg>()
  38. {
  39. new ItemDiagnosisInputArg()
  40. {
  41. ItemId = Guid.NewGuid(),
  42. ItemName = "身高",
  43. Result = "122"
  44. },
  45. new ItemDiagnosisInputArg()
  46. {
  47. ItemId = Guid.NewGuid(),
  48. ItemName = "体重",
  49. Result = "221"
  50. },
  51. new ItemDiagnosisInputArg()
  52. {
  53. ItemId = Guid.NewGuid(),
  54. ItemName = "体重指数",
  55. }
  56. };
  57. var result = GetItemResultSample(patient);
  58. _output.WriteLine("结果:"+result);
  59. string code = @"
  60. string result = """";
  61. decimal sg = 0;
  62. decimal tz = 0;
  63. foreach (var item in patient.Items)
  64. {
  65. if (item.ItemName == """")
  66. {
  67. if (decimal.TryParse(item.Result, out sg))
  68. {
  69. if (sg == 0)
  70. {
  71. return null;
  72. }
  73. }
  74. else
  75. {
  76. return null;
  77. }
  78. }
  79. if (item.ItemName == """")
  80. {
  81. if (decimal.TryParse(item.Result, out tz))
  82. {
  83. if (tz == 0)
  84. {
  85. return null;
  86. }
  87. }
  88. else
  89. {
  90. return null;
  91. }
  92. }
  93. }
  94. result = (tz /((sg/100) * (sg / 100))).ToString(""0.00"");
  95. return result;
  96. ";
  97. result = _appService.GetItemResult(patient, code);
  98. _output.WriteLine("动态结果:" + result);
  99. }
  100. public string GetItemResultSample(PatientDiagnosisInputArg patient)
  101. {
  102. string result = "";
  103. decimal sg = 0;
  104. decimal tz = 0;
  105. foreach (var item in patient.Items)
  106. {
  107. if (item.ItemName == "身高")
  108. {
  109. if (decimal.TryParse(item.Result, out sg))
  110. {
  111. if (sg == 0)
  112. {
  113. return null;
  114. }
  115. }
  116. else
  117. {
  118. return null;
  119. }
  120. }
  121. if (item.ItemName == "体重")
  122. {
  123. if (decimal.TryParse(item.Result, out tz))
  124. {
  125. if (tz == 0)
  126. {
  127. return null;
  128. }
  129. }
  130. else
  131. {
  132. return null;
  133. }
  134. }
  135. }
  136. result = (tz /((sg/100) * (sg / 100))).ToString("0.00");
  137. return result;
  138. }
  139. }
  140. }