Browse Source

预约

master
DESKTOP-G961P6V\Zhh 1 year ago
parent
commit
0c80cc4b43
  1. 2
      src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/CreateAppointPatientRegisterDto.cs
  2. 8
      src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs
  3. 4
      src/Shentun.WebPeis.Application/WebPeisApplicationAutoMapperProfile.cs
  4. 22
      src/Shentun.WebPeis.Domain/AppointPatientRegisters/AppointPatientRegisterManager.cs
  5. 66
      test/Shentun.WebPeis.Application.Tests/AppointPatientRegisterAppServiceTest.cs
  6. 14
      test/Shentun.WebPeis.EntityFrameworkCore.Tests/EntityFrameworkCore/Applications/EfCoreAppointPatientRegisterAppServiceTest.cs

2
src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/CreateAppointPatientRegisterDto.cs

@ -33,6 +33,6 @@ namespace Shentun.WebPeis.AppointPatientRegisters
public decimal? Weight { get; set; } public decimal? Weight { get; set; }
public List<CreateAppointRegisterAsbitemDto> AppointRegisterAsbitems { get; set; } = new List<CreateAppointRegisterAsbitemDto>();
public List<CreateAppointRegisterAsbitemDto> Asbitems { get; set; } = new List<CreateAppointRegisterAsbitemDto>();
} }
} }

8
src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs

@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Shentun.WebPeis.AppointRegisterAsbitems;
using Shentun.WebPeis.Models; using Shentun.WebPeis.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -36,10 +37,15 @@ namespace Shentun.WebPeis.AppointPatientRegisters
} }
[HttpPost("api/app/AppointPatientRegister/Create")] [HttpPost("api/app/AppointPatientRegister/Create")]
public async Task CreateAsync(CreateAppointPatientRegisterDto input)
public async Task<AppointPatientRegisterDto> CreateAsync(CreateAppointPatientRegisterDto input)
{ {
var entity = ObjectMapper.Map<CreateAppointPatientRegisterDto, AppointPatientRegister>(input); var entity = ObjectMapper.Map<CreateAppointPatientRegisterDto, AppointPatientRegister>(input);
var asbitems = ObjectMapper.Map<List<CreateAppointRegisterAsbitemDto>, List<AppointRegisterAsbitem>>(input.Asbitems);
entity.AppointRegisterAsbitems = asbitems;
entity = await _appointPatientRegisterManager.CreateAsync(entity); entity = await _appointPatientRegisterManager.CreateAsync(entity);
await _repository.InsertAsync(entity);
var result = ObjectMapper.Map<AppointPatientRegister, AppointPatientRegisterDto>(entity);
return result;
} }
} }
} }

4
src/Shentun.WebPeis.Application/WebPeisApplicationAutoMapperProfile.cs

@ -1,6 +1,7 @@
using AutoMapper; using AutoMapper;
using Shentun.Peis.MaritalStatuss; using Shentun.Peis.MaritalStatuss;
using Shentun.WebPeis.AppointPatientRegisters; using Shentun.WebPeis.AppointPatientRegisters;
using Shentun.WebPeis.AppointRegisterAsbitems;
using Shentun.WebPeis.Kinships; using Shentun.WebPeis.Kinships;
using Shentun.WebPeis.MaritalStatuss; using Shentun.WebPeis.MaritalStatuss;
using Shentun.WebPeis.MedicalPackages; using Shentun.WebPeis.MedicalPackages;
@ -59,5 +60,8 @@ public class WebPeisApplicationAutoMapperProfile : Profile
CreateMap<CreateAppointPatientRegisterDto, AppointPatientRegister>(); CreateMap<CreateAppointPatientRegisterDto, AppointPatientRegister>();
CreateMap<AppointPatientRegister, AppointPatientRegisterDto>(); CreateMap<AppointPatientRegister, AppointPatientRegisterDto>();
CreateMap<CreateAppointRegisterAsbitemDto, AppointRegisterAsbitem>();
} }
} }

22
src/Shentun.WebPeis.Domain/AppointPatientRegisters/AppointPatientRegisterManager.cs

@ -53,7 +53,11 @@ namespace Shentun.WebPeis.AppointPatientRegisters
public async Task<AppointPatientRegister> CreateAsync(AppointPatientRegister entity) public async Task<AppointPatientRegister> CreateAsync(AppointPatientRegister entity)
{ {
await Verify(entity); await Verify(entity);
//entity
entity.AppointPatientRegisterId = GuidGenerator.Create();
foreach (var appointRegisterAsbitem in entity.AppointRegisterAsbitems)
{
appointRegisterAsbitem.AppointPatientRegisterId = entity.AppointPatientRegisterId;
}
return entity; return entity;
} }
private async Task Verify(AppointPatientRegister entity) private async Task Verify(AppointPatientRegister entity)
@ -133,6 +137,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters
} }
foreach (var appointRegisterAsbitem in entity.AppointRegisterAsbitems) foreach (var appointRegisterAsbitem in entity.AppointRegisterAsbitems)
{ {
if(appointRegisterAsbitem.ChargePrice < 0) if(appointRegisterAsbitem.ChargePrice < 0)
{ {
throw new UserFriendlyException("价格不能小于0"); throw new UserFriendlyException("价格不能小于0");
@ -145,6 +150,21 @@ namespace Shentun.WebPeis.AppointPatientRegisters
{ {
throw new UserFriendlyException("数量不能小于1"); throw new UserFriendlyException("数量不能小于1");
} }
if (customerOrg.CustomerOrgId == GuidFlag.PersonCustomerOrgId)
{
appointRegisterAsbitem.PayTypeFlag = PayTypeFlag.PersonPay;
}
else
{
//在这里要判断属于分组的免费,不属于分组的自费
if (appointRegisterAsbitem.PayTypeFlag != PayTypeFlag.PersonPay &&
appointRegisterAsbitem.PayTypeFlag != PayTypeFlag.OrgPay)
{
throw new UserFriendlyException("支付类别错误");
}
}
appointRegisterAsbitem.IsCharge = 'N';
} }
} }
} }

66
test/Shentun.WebPeis.Application.Tests/AppointPatientRegisterAppServiceTest.cs

@ -0,0 +1,66 @@
using Shentun.WebPeis.AppointPatientRegisters;
using Shentun.WebPeis.AppointRegisterAsbitems;
using Shentun.WebPeis.Enums;
using Shentun.WebPeis.Models;
using Shentun.WebPeis.Persons;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Modularity;
using Volo.Abp.Uow;
using Xunit;
using Xunit.Abstractions;
namespace Shentun.WebPeis
{
public class AppointPatientRegisterAppServiceTest<TStartupModule> : WebPeisApplicationTestBase<TStartupModule>
where TStartupModule : IAbpModule
{
private readonly IRepository<AppointPatientRegister> _repository;
private readonly AppointPatientRegisterAppService _appService;
private readonly ITestOutputHelper _output;
private readonly IUnitOfWorkManager _unitOfWorkManager;
public AppointPatientRegisterAppServiceTest(ITestOutputHelper output)
{
_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
_repository = GetRequiredService<IRepository<AppointPatientRegister>>();
_appService = GetRequiredService<AppointPatientRegisterAppService>();
_output = output;
}
[Fact]
public async Task CreateAsync()
{
using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
{
var entity = new CreateAppointPatientRegisterDto()
{
PersonId = new Guid("3a12d7fa-63f1-d549-c2f8-01123e5b7a8a"),
CustomerOrgGroupId = null,
CustomerOrgId = GuidFlag.PersonCustomerOrgId,
MedicalCenterId = new Guid("150da355-dfbf-466b-9697-355836a862c4"),
MedicalPackageId = null,
MedicalStartDate = DateTime.Now,
CustomerOrgRegisterId = GuidFlag.PersonCustomerOrgRegisterId,
PregnantFlag = PregnantFlag.None,
Height = 170,
Weight = 60
};
entity.Asbitems.Add(
new CreateAppointRegisterAsbitemDto()
{
AsbitemId = new Guid("3a126b34-f6f0-56a1-e899-a092874acde7"),
Amount = 1,
ChargePrice = (decimal)30.5
}
);
var newEntity = await _appService.CreateAsync(entity);
await unitOfWork.CompleteAsync();
}
}
}
}

14
test/Shentun.WebPeis.EntityFrameworkCore.Tests/EntityFrameworkCore/Applications/EfCoreAppointPatientRegisterAppServiceTest.cs

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit.Abstractions;
namespace Shentun.WebPeis.EntityFrameworkCore.Applications
{
public class EfCoreAppointPatientRegisterAppServiceTest : AppointPatientRegisterAppServiceTest<WebPeisEntityFrameworkCoreTestModule>
{
public EfCoreAppointPatientRegisterAppServiceTest(ITestOutputHelper output) : base(output) { }
}
}
Loading…
Cancel
Save