Browse Source

预约

master
DESKTOP-G961P6V\Zhh 2 years ago
parent
commit
fe730ccd96
  1. 5
      src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/AppointPatientRegisterDto.cs
  2. 6
      src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/AppointPatientRegisterInputDto.cs
  3. 2
      src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/CreateAppointPatientRegisterDto.cs
  4. 1
      src/Shentun.WebPeis.Application.Contracts/AppointSchedules/AppointScheduleDateDto.cs
  5. 11
      src/Shentun.WebPeis.Application.Contracts/AppointSchedules/AppointScheduleDateInputDto.cs
  6. 61
      src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs
  7. 1
      src/Shentun.WebPeis.Application/AppointSchedules/AppointScheduleAppService.cs
  8. 14
      test/Shentun.WebPeis.Application.Tests/AppointPatientRegisterAppServiceTest.cs

5
src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/AppointPatientRegisterDto.cs

@ -112,10 +112,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters
/// </summary> /// </summary>
public decimal? Weight { get; set; } public decimal? Weight { get; set; }
/// <summary>
/// 预约组合项目
/// </summary>
public List<AppointRegisterAsbitemDto> AppointRegisterAsbitems { get; set; } = new List<AppointRegisterAsbitemDto>();
} }
} }

6
src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/IdNoOrMobilePhoneInputDto.cs → src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/AppointPatientRegisterInputDto.cs

@ -4,10 +4,14 @@ using System.Text;
namespace Shentun.WebPeis.AppointPatientRegisters namespace Shentun.WebPeis.AppointPatientRegisters
{ {
public class IdNoOrMobilePhoneInputDto
public class AppointPatientRegisterInputDto
{ {
public Guid? MedicalCenterId { get; set; }
public string IdNo { get; set; } public string IdNo { get; set; }
public string MobilePhone { get; set; } public string MobilePhone { get; set; }
public DateTime? AppointStartDate { get; set; }
public DateTime? AppointStopDate { get; set; }
} }
} }

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

@ -43,7 +43,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters
/// 体检中心 /// 体检中心
/// </summary> /// </summary>
public Guid MedicalCenterId { get; set; }
public Guid? MedicalCenterId { get; set; }
/// <summary> /// <summary>
/// 单位登记ID /// 单位登记ID
/// </summary> /// </summary>

1
src/Shentun.WebPeis.Application.Contracts/AppointSchedules/AppointScheduleDateDto.cs

@ -6,6 +6,7 @@ namespace Shentun.WebPeis.AppointSchedules
{ {
public class AppointScheduleDateDto public class AppointScheduleDateDto
{ {
public Guid AppointScheduleId { get; set; }
public DateTime AppointDate { get; set; } public DateTime AppointDate { get; set; }
public char IsWork { get; set; } = 'Y'; public char IsWork { get; set; } = 'Y';
public char IsFull { get; set; } = 'N'; public char IsFull { get; set; } = 'N';

11
src/Shentun.WebPeis.Application.Contracts/AppointSchedules/AppointScheduleDateInputDto.cs

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.WebPeis.AppointSchedules
{
public class AppointScheduleDateInputDto
{
public DateTime AppointDate { get; set; }
}
}

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

@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc;
using Shentun.WebPeis.AppointRegisterAsbitems; using Shentun.WebPeis.AppointRegisterAsbitems;
using Shentun.WebPeis.CustomerOrgs; using Shentun.WebPeis.CustomerOrgs;
using Shentun.WebPeis.Models; using Shentun.WebPeis.Models;
using Shentun.WebPeis.OrganizationUnits;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@ -38,6 +39,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters
private readonly CacheService _cacheService; private readonly CacheService _cacheService;
private readonly AppointPatientRegisterManager _appointPatientRegisterManager; private readonly AppointPatientRegisterManager _appointPatientRegisterManager;
private readonly CustomerOrgManager _customerOrgManager; private readonly CustomerOrgManager _customerOrgManager;
private readonly WebPeisOrganizationUnitManager _webPeisOrganizationUnitManager;
public AppointPatientRegisterAppService(IRepository<AppointPatientRegister> repository, public AppointPatientRegisterAppService(IRepository<AppointPatientRegister> repository,
CacheService cacheService, CacheService cacheService,
IRepository<ItemType> itemTypeRepository, IRepository<ItemType> itemTypeRepository,
@ -51,7 +53,8 @@ namespace Shentun.WebPeis.AppointPatientRegisters
IRepository<Asbitem> asbitemRepository, IRepository<Asbitem> asbitemRepository,
IRepository<CustomerOrg> customerOrgRepository, IRepository<CustomerOrg> customerOrgRepository,
IRepository<MedicalPackageDetail> medicalPackageDetailRepository, IRepository<MedicalPackageDetail> medicalPackageDetailRepository,
IRepository<CustomerOrgGroupDetail> customerOrgGroupDetailRepository
IRepository<CustomerOrgGroupDetail> customerOrgGroupDetailRepository,
WebPeisOrganizationUnitManager webPeisOrganizationUnitManager
) )
{ {
_repository = repository; _repository = repository;
@ -68,6 +71,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters
_customerOrgRepository = customerOrgRepository; _customerOrgRepository = customerOrgRepository;
_medicalPackageDetailRepository = medicalPackageDetailRepository; _medicalPackageDetailRepository = medicalPackageDetailRepository;
_customerOrgGroupDetailRepository = customerOrgGroupDetailRepository; _customerOrgGroupDetailRepository = customerOrgGroupDetailRepository;
_webPeisOrganizationUnitManager = webPeisOrganizationUnitManager;
} }
@ -77,6 +81,23 @@ namespace Shentun.WebPeis.AppointPatientRegisters
var entity = ObjectMapper.Map<CreateAppointPatientRegisterDto, AppointPatientRegister>(input); var entity = ObjectMapper.Map<CreateAppointPatientRegisterDto, AppointPatientRegister>(input);
var asbitems = ObjectMapper.Map<List<CreateAppointRegisterAsbitemDto>, List<AppointRegisterAsbitem>>(input.Asbitems); var asbitems = ObjectMapper.Map<List<CreateAppointRegisterAsbitemDto>, List<AppointRegisterAsbitem>>(input.Asbitems);
entity.AppointRegisterAsbitems = asbitems; entity.AppointRegisterAsbitems = asbitems;
Guid medicalCenterId;
if (input.MedicalCenterId == null || input.MedicalCenterId == Guid.Empty)
{
var webPeisOrganizationUnit = await _webPeisOrganizationUnitManager.GetMedicalCenterListAsync();
if (webPeisOrganizationUnit.Count > 1 || webPeisOrganizationUnit.Count == 0)
{
throw new UserFriendlyException("体检中心参数不能为空");
}
medicalCenterId = webPeisOrganizationUnit.First().Id;
}
else
{
medicalCenterId = (Guid)input.MedicalCenterId;
}
entity.MedicalCenterId = medicalCenterId;
entity = await _appointPatientRegisterManager.CreateAsync(entity); entity = await _appointPatientRegisterManager.CreateAsync(entity);
await _repository.InsertAsync(entity); await _repository.InsertAsync(entity);
var result = ObjectMapper.Map<AppointPatientRegister, AppointPatientRegisterDto>(entity); var result = ObjectMapper.Map<AppointPatientRegister, AppointPatientRegisterDto>(entity);
@ -84,10 +105,42 @@ namespace Shentun.WebPeis.AppointPatientRegisters
} }
[HttpPost("api/app/AppointPatientRegister/GetListByIdNoOrMobilePhone")] [HttpPost("api/app/AppointPatientRegister/GetListByIdNoOrMobilePhone")]
public async Task<List<AppointPatientRegisterDto>> GetListByIdNoOrMobilePhoneAsync(IdNoOrMobilePhoneInputDto input)
public async Task<List<AppointPatientRegisterDto>> GetListByFilterAsync(AppointPatientRegisterInputDto input)
{ {
if (input == null) throw new UserFriendlyException("参数不能为空"); if (input == null) throw new UserFriendlyException("参数不能为空");
Guid medicalCenterId;
if (input.MedicalCenterId == null || input.MedicalCenterId == Guid.Empty )
{
var webPeisOrganizationUnit = await _webPeisOrganizationUnitManager.GetMedicalCenterListAsync();
if (webPeisOrganizationUnit.Count > 1 || webPeisOrganizationUnit.Count == 0)
{
throw new UserFriendlyException("体检中心参数不能为空");
}
medicalCenterId = webPeisOrganizationUnit.First().Id;
}
else
{
medicalCenterId = (Guid) input.MedicalCenterId;
}
if(input.AppointStartDate == null )
{
input.AppointStartDate = DateTime.Now.Date;
}
else
{
input.AppointStartDate = ((DateTime)input.AppointStartDate).Date;
}
if (input.AppointStopDate == null)
{
input.AppointStopDate = DateTime.Now.Date.AddDays(3650);
}
else
{
input.AppointStopDate = ((DateTime)input.AppointStopDate).Date.AddDays(1);
}
if (string.IsNullOrWhiteSpace(input.MobilePhone) && string.IsNullOrWhiteSpace(input.IdNo)) if (string.IsNullOrWhiteSpace(input.MobilePhone) && string.IsNullOrWhiteSpace(input.IdNo))
{ {
throw new UserFriendlyException("手机号和身份证必须至少填一个"); throw new UserFriendlyException("手机号和身份证必须至少填一个");
@ -109,7 +162,9 @@ namespace Shentun.WebPeis.AppointPatientRegisters
on appointRegisterAsbitem.AsbitemId equals asbitem.AsbitemId on appointRegisterAsbitem.AsbitemId equals asbitem.AsbitemId
join customerOrg in await _customerOrgRepository.GetQueryableAsync() join customerOrg in await _customerOrgRepository.GetQueryableAsync()
on appointPatientRegister.CustomerOrgId equals customerOrg.CustomerOrgId on appointPatientRegister.CustomerOrgId equals customerOrg.CustomerOrgId
where appointPatientRegister.AppointDate >= DateTime.Now.Date.AddDays(-10)
where appointPatientRegister.MedicalCenterId == medicalCenterId &&
appointPatientRegister.AppointDate >= input.AppointStartDate &&
appointPatientRegister.AppointDate < input.AppointStopDate
orderby appointPatientRegister.AppointDate orderby appointPatientRegister.AppointDate
select new select new
{ {

1
src/Shentun.WebPeis.Application/AppointSchedules/AppointScheduleAppService.cs

@ -91,6 +91,7 @@ namespace Shentun.WebPeis.AppointSchedules
var list = appointSchedules.GroupBy(o => o.appointSchedule) var list = appointSchedules.GroupBy(o => o.appointSchedule)
.Select(x => new AppointScheduleDateDto() .Select(x => new AppointScheduleDateDto()
{ {
AppointScheduleId = x.Key.AppointScheduleId,
AppointDate = x.Key.AppointDate, AppointDate = x.Key.AppointDate,
IsWork = (x.Key.AmNumberLimit + x.Key.PmNumberLimit) == 0 ? 'N' : 'Y', IsWork = (x.Key.AmNumberLimit + x.Key.PmNumberLimit) == 0 ? 'N' : 'Y',
IsFull = (x.Key.AmNumberLimit + x.Key.PmNumberLimit) <= x.Key.AppointScheduleTimes.Sum(m => m.AppointNumber) ? 'Y' : 'N' IsFull = (x.Key.AmNumberLimit + x.Key.PmNumberLimit) <= x.Key.AppointScheduleTimes.Sum(m => m.AppointNumber) ? 'Y' : 'N'

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

@ -72,23 +72,21 @@ namespace Shentun.WebPeis
} }
[Fact] [Fact]
public async Task GetListByIdNoOrMobilePhoneAsync()
public async Task GetListByFilterAsync()
{ {
using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true)) using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
{ {
var entity = new IdNoOrMobilePhoneInputDto()
var entity = new AppointPatientRegisterInputDto()
{ {
MobilePhone = "18911254911"
MobilePhone = "18911254911",
AppointStartDate = DateTime.Now.AddDays(-10),
}; };
var list = await _appService.GetListByIdNoOrMobilePhoneAsync(entity);
var list = await _appService.GetListByFilterAsync(entity);
foreach (var item in list) foreach (var item in list)
{ {
_output.WriteLine(item.PersonName); _output.WriteLine(item.PersonName);
foreach(var asbitem in item.AppointRegisterAsbitems)
{
_output.WriteLine(asbitem.AsbitemName);
}
} }
await unitOfWork.CompleteAsync(); await unitOfWork.CompleteAsync();
} }

Loading…
Cancel
Save