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.

244 lines
7.5 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
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. /// <summary>
  31. /// 体重指数测试结果
  32. /// </summary>
  33. [Fact]
  34. public void GetItemCalculateResultTzzsTest()
  35. {
  36. PatientItemCalculateInput patient = new PatientItemCalculateInput();
  37. patient.SexName = "男";
  38. patient.Age = 30;
  39. patient.Items = new List<ItemResultInput>()
  40. {
  41. new ItemResultInput()
  42. {
  43. ItemId = Guid.NewGuid(),
  44. ItemName = "身高",
  45. Result = "122"
  46. },
  47. new ItemResultInput()
  48. {
  49. ItemId = Guid.NewGuid(),
  50. ItemName = "体重",
  51. Result = "221"
  52. },
  53. new ItemResultInput()
  54. {
  55. ItemId = Guid.NewGuid(),
  56. ItemName = "体重指数",
  57. }
  58. };
  59. var result = GetItemCalculateResultTzzs(patient);
  60. _output.WriteLine("结果:"+result);
  61. string code = @"
  62. string result = """";
  63. decimal sg = 0;
  64. decimal tz = 0;
  65. foreach (var item in patient.Items)
  66. {
  67. if (item.ItemName == """")
  68. {
  69. if (decimal.TryParse(item.Result, out sg))
  70. {
  71. if (sg == 0)
  72. {
  73. return null;
  74. }
  75. }
  76. else
  77. {
  78. return null;
  79. }
  80. }
  81. if (item.ItemName == """")
  82. {
  83. if (decimal.TryParse(item.Result, out tz))
  84. {
  85. if (tz == 0)
  86. {
  87. return null;
  88. }
  89. }
  90. else
  91. {
  92. return null;
  93. }
  94. }
  95. }
  96. result = (tz /((sg/100) * (sg / 100))).ToString(""0.00"");
  97. return result;
  98. ";
  99. DiagnosisBuilder diagnosisBuilder = new DiagnosisBuilder();
  100. result = diagnosisBuilder.GetItemCalculateResult(patient, code);
  101. _output.WriteLine("动态结果:" + result);
  102. }
  103. /// <summary>
  104. /// 体重指数
  105. /// </summary>
  106. /// <param name="patient"></param>
  107. /// <returns></returns>
  108. public string GetItemCalculateResultTzzs(PatientItemCalculateInput patient)
  109. {
  110. string result = "";
  111. decimal sg = 0;
  112. decimal tz = 0;
  113. foreach (var item in patient.Items)
  114. {
  115. if (item.ItemName == "身高")
  116. {
  117. if (decimal.TryParse(item.Result, out sg))
  118. {
  119. if (sg == 0)
  120. {
  121. return null;
  122. }
  123. }
  124. else
  125. {
  126. return null;
  127. }
  128. }
  129. if (item.ItemName == "体重")
  130. {
  131. if (decimal.TryParse(item.Result, out tz))
  132. {
  133. if (tz == 0)
  134. {
  135. return null;
  136. }
  137. }
  138. else
  139. {
  140. return null;
  141. }
  142. }
  143. }
  144. result = (tz /((sg/100) * (sg / 100))).ToString("0.00");
  145. return result;
  146. }
  147. /// <summary>
  148. /// 乙肝五项
  149. /// </summary>
  150. [Fact]
  151. public void GetAsbitemDiagnosisResultTest()
  152. {
  153. var patient = new PatientAsbitemDiagnosisInput();
  154. patient.SexName = "男";
  155. patient.Age = 30;
  156. patient.Items = new List<ItemResultInput>()
  157. {
  158. new ItemResultInput()
  159. {
  160. ItemId = Guid.NewGuid(),
  161. ItemName = "身高",
  162. Result = "122"
  163. },
  164. new ItemResultInput()
  165. {
  166. ItemId = Guid.NewGuid(),
  167. ItemName = "体重",
  168. Result = "221"
  169. },
  170. new ItemResultInput()
  171. {
  172. ItemId = Guid.NewGuid(),
  173. ItemName = "体重指数",
  174. }
  175. };
  176. var result = GetAsbitemDiagnosisResult(patient);
  177. _output.WriteLine("结果:" + result);
  178. string code = @"
  179. string result = """";
  180. decimal sg = 0;
  181. decimal tz = 0;
  182. foreach (var item in patient.Items)
  183. {
  184. if (item.ItemName == """")
  185. {
  186. if (decimal.TryParse(item.Result, out sg))
  187. {
  188. if (sg == 0)
  189. {
  190. return null;
  191. }
  192. }
  193. else
  194. {
  195. return null;
  196. }
  197. }
  198. if (item.ItemName == """")
  199. {
  200. if (decimal.TryParse(item.Result, out tz))
  201. {
  202. if (tz == 0)
  203. {
  204. return null;
  205. }
  206. }
  207. else
  208. {
  209. return null;
  210. }
  211. }
  212. }
  213. result = (tz /((sg/100) * (sg / 100))).ToString(""0.00"");
  214. return result;
  215. ";
  216. DiagnosisBuilder diagnosisBuilder = new DiagnosisBuilder();
  217. result = diagnosisBuilder.GetAsbitemDiagnosisResult(patient, code);
  218. _output.WriteLine("动态结果:" + result);
  219. }
  220. public string GetAsbitemDiagnosisResult(PatientAsbitemDiagnosisInput patient)
  221. {
  222. string result = "";
  223. return result;
  224. }
  225. }
  226. }