From 872bd5497e582d48920ba7304a1365d2e33dabbf Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Fri, 30 Aug 2024 10:07:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=80=E5=8E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DiagnosisFunctionAppServiceTest.cs | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/test/Shentun.Peis.Application.Tests/DiagnosisFunctionAppServiceTest.cs b/test/Shentun.Peis.Application.Tests/DiagnosisFunctionAppServiceTest.cs index 9753802..4c4c9a8 100644 --- a/test/Shentun.Peis.Application.Tests/DiagnosisFunctionAppServiceTest.cs +++ b/test/Shentun.Peis.Application.Tests/DiagnosisFunctionAppServiceTest.cs @@ -969,5 +969,88 @@ namespace Shentun.Peis return msg; } + + + /// + /// 测试血压函数 + /// + [Fact] + public void GetAsbitemDiagnosisResultXyTest() + { + var patient = new PatientAsbitemDiagnosisInput(); + patient.SexName = "男"; + patient.Age = 30; + patient.Items = new List() + { + new ItemResultInput() + { + ItemId = Guid.NewGuid(), + ItemName = "血压", + Result = "140/86" + } + }; + var result = GetAsbitemDiagnosisResultXy(patient); + _output.WriteLine("结果:" + result); + return; + + + } + + /// + /// 血压函数 + /// + /// + /// + public string GetAsbitemDiagnosisResultXy(PatientAsbitemDiagnosisInput patient) + { + decimal sbp = 0; + string msg = null; + decimal dbp = 0; + var itemResult = ""; + foreach (var item in patient.Items) + { + if (item.ItemName == "血压") + { + itemResult = item.Result; + } + + } + if (string.IsNullOrWhiteSpace(itemResult)) + { + return null; + } + int indexBefore = itemResult.IndexOf("/"); + string before = itemResult.Substring(0, indexBefore); + int indexAfter = itemResult.IndexOf("/") + 1; + string after = itemResult.Substring(indexAfter); + + if (!String.IsNullOrEmpty(before) && !String.IsNullOrEmpty(after)) + { + + if (!decimal.TryParse(before, out sbp)) + { + return null; + } + if (!decimal.TryParse(after, out dbp)) + { + return null; + } + if ((sbp >= 90 && sbp <= 139) && (dbp >= 60 && dbp <= 89)) + { + msg = "血压正常"; + } + else if (sbp > 139 || dbp > 89) + { + msg = "血压升高"; + } + else if (sbp < 90 || dbp < 60) + { + msg = "血压降低"; + } + return msg; + } + + return itemResult; + } } }