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
153 lines
4.6 KiB
using NPOI.POIFS.Properties;
|
|
using Shentun.Peis.CustomerOrgs;
|
|
using Shentun.Peis.DiagnosisFunctions;
|
|
using Shentun.Peis.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using TencentCloud.Ame.V20190916.Models;
|
|
using Volo.Abp.Domain.Repositories;
|
|
using Volo.Abp.Uow;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Shentun.Peis
|
|
{
|
|
public class DiagnosisFunctionAppServiceTest : PeisApplicationTestBase
|
|
{
|
|
private readonly IRepository<CustomerOrg, Guid> _repository;
|
|
private readonly DiagnosisFunctionAppService _appService;
|
|
private readonly ITestOutputHelper _output;
|
|
private readonly IUnitOfWorkManager _unitOfWorkManager;
|
|
public DiagnosisFunctionAppServiceTest(ITestOutputHelper testOutputHelper)
|
|
{
|
|
_output = testOutputHelper;
|
|
_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
|
|
_repository = GetRequiredService<IRepository<CustomerOrg, Guid>>();
|
|
_appService = GetRequiredService<DiagnosisFunctionAppService>();
|
|
}
|
|
|
|
[Fact]
|
|
public void GetItemResult()
|
|
{
|
|
PatientDiagnosisInputArg patient = new PatientDiagnosisInputArg();
|
|
patient.AsbitemId = Guid.NewGuid();
|
|
patient.SexName = "男";
|
|
patient.Age = 30;
|
|
patient.Items = new List<ItemDiagnosisInputArg>()
|
|
{
|
|
new ItemDiagnosisInputArg()
|
|
{
|
|
ItemId = Guid.NewGuid(),
|
|
ItemName = "身高",
|
|
Result = "122"
|
|
},
|
|
new ItemDiagnosisInputArg()
|
|
{
|
|
ItemId = Guid.NewGuid(),
|
|
ItemName = "体重",
|
|
Result = "221"
|
|
},
|
|
new ItemDiagnosisInputArg()
|
|
{
|
|
ItemId = Guid.NewGuid(),
|
|
ItemName = "体重指数",
|
|
}
|
|
};
|
|
var result = GetItemResultSample(patient);
|
|
_output.WriteLine("结果:"+result);
|
|
string code = @"
|
|
string result = """";
|
|
decimal sg = 0;
|
|
decimal tz = 0;
|
|
foreach (var item in patient.Items)
|
|
{
|
|
if (item.ItemName == ""身高"")
|
|
{
|
|
if (decimal.TryParse(item.Result, out sg))
|
|
{
|
|
if (sg == 0)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
|
|
}
|
|
if (item.ItemName == ""体重"")
|
|
{
|
|
if (decimal.TryParse(item.Result, out tz))
|
|
{
|
|
if (tz == 0)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
|
|
}
|
|
}
|
|
result = (tz /((sg/100) * (sg / 100))).ToString(""0.00"");
|
|
return result;
|
|
";
|
|
|
|
|
|
|
|
result = _appService.GetItemResult(patient, code);
|
|
_output.WriteLine("动态结果:" + result);
|
|
|
|
|
|
}
|
|
|
|
|
|
public string GetItemResultSample(PatientDiagnosisInputArg patient)
|
|
{
|
|
string result = "";
|
|
decimal sg = 0;
|
|
decimal tz = 0;
|
|
foreach (var item in patient.Items)
|
|
{
|
|
if (item.ItemName == "身高")
|
|
{
|
|
if (decimal.TryParse(item.Result, out sg))
|
|
{
|
|
if (sg == 0)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
|
|
}
|
|
if (item.ItemName == "体重")
|
|
{
|
|
if (decimal.TryParse(item.Result, out tz))
|
|
{
|
|
if (tz == 0)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
|
|
}
|
|
}
|
|
result = (tz /((sg/100) * (sg / 100))).ToString("0.00");
|
|
return result;
|
|
}
|
|
}
|
|
}
|