Browse Source

预约

master
DESKTOP-G961P6V\Zhh 1 year ago
parent
commit
eb12f9ef8a
  1. 94
      src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/AppointPatientRegisterDto.cs
  2. 11
      src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/AppointPatientRegisterIdInputDto.cs
  3. 13
      src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/IdNoOrMobilePhoneInputDto.cs
  4. 11
      src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/MobilePhoneInputDto.cs
  5. 45
      src/Shentun.WebPeis.Application.Contracts/AppointRegisterAsbitems/AppointRegisterAsbitemDto.cs
  6. 2
      src/Shentun.WebPeis.Application.Contracts/Asbitems/DiseaseScreeningTypeAsbitemDto.cs
  7. 181
      src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs
  8. 42
      test/Shentun.WebPeis.Application.Tests/AppointPatientRegisterAppServiceTest.cs

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

@ -1,37 +1,121 @@
using System;
using Shentun.WebPeis.AppointRegisterAsbitems;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace Shentun.WebPeis.AppointPatientRegisters namespace Shentun.WebPeis.AppointPatientRegisters
{ {
/// <summary>
/// 预约信息
/// </summary>
public class AppointPatientRegisterDto public class AppointPatientRegisterDto
{ {
/// <summary>
/// 预约登记ID
/// </summary>
public Guid AppointPatientRegisterId { get; set; } public Guid AppointPatientRegisterId { get; set; }
/// <summary>
/// 人员ID
/// </summary>
public Guid PersonId { get; set; } public Guid PersonId { get; set; }
/// <summary>
/// 姓名
/// </summary>
public string PersonName { get; set; }
/// <summary>
/// 身份证号
/// </summary>
public string? IdNo { get; set; }
/// <summary>
/// 性别ID
/// </summary>
public char SexId { get; set; }
/// <summary>
/// 性别名称
/// </summary>
public string SexName { get; set; }
/// <summary>
/// 婚姻状况ID
/// </summary>
public char MaritalStatusId { get; set; }
/// <summary>
/// 婚姻状况名称
/// </summary>
public string MaritalStatusName { get; set; }
/// <summary>
/// 单位ID
/// </summary>
public Guid CustomerOrgId { get; set; } public Guid CustomerOrgId { get; set; }
/// <summary>
/// 单位名称
/// </summary>
public string CustomerOrgName { get; set; }
public string ChildCustomerOrgName { get; set; }
/// <summary>
/// 单位分组ID
/// </summary>
public Guid? CustomerOrgGroupId { get; set; } public Guid? CustomerOrgGroupId { get; set; }
/// <summary>
/// 单位分组名称
/// </summary>
public string CustomerOrgGroupName { get; set; }
/// <summary>
/// 套餐ID
/// </summary>
public Guid? MedicalPackageId { get; set; } public Guid? MedicalPackageId { get; set; }
/// <summary>
/// 套餐名称
/// </summary>
public string MedicalPackageName { get; set; }
/// <summary>
/// 完成标志
/// </summary>
public char CompleteFlag { get; set; } public char CompleteFlag { get; set; }
/// <summary>
/// 预约日期
/// </summary>
public DateTime MedicalStartDate { get; set; }
public DateTime AppointDate { get; set; }
/// <summary>
/// 备注
/// </summary>
public string? Remark { get; set; } public string? Remark { get; set; }
/// <summary>
/// 体检中心ID
/// </summary>
public Guid MedicalCenterId { get; set; } public Guid MedicalCenterId { get; set; }
/// <summary>
/// 单位登记ID
/// </summary>
public Guid CustomerOrgRegisterId { get; set; } public Guid CustomerOrgRegisterId { get; set; }
public string? ConcurrencyStamp { get; set; }
/// <summary>
/// 备孕标志
/// </summary>
public char PregnantFlag { get; set; } public char PregnantFlag { get; set; }
public string PregnantFlagName { get; set; }
/// <summary>
/// 身高
/// </summary>
public decimal? Height { get; set; } public decimal? Height { get; set; }
/// <summary>
/// 体重
/// </summary>
public decimal? Weight { get; set; } public decimal? Weight { get; set; }
/// <summary>
/// 预约组合项目
/// </summary>
public List<AppointRegisterAsbitemDto> AppointRegisterAsbitems { get; set; } = new List<AppointRegisterAsbitemDto>();
} }
} }

11
src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/AppointPatientRegisterIdInputDto.cs

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.WebPeis.AppointPatientRegisters
{
public class AppointPatientRegisterIdInputDto
{
public Guid AppointPatientRegisterId { get; set; }
}
}

13
src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/IdNoOrMobilePhoneInputDto.cs

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.WebPeis.AppointPatientRegisters
{
public class IdNoOrMobilePhoneInputDto
{
public string IdNo { get; set; }
public string MobilePhone { get; set; }
}
}

11
src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/MobilePhoneInputDto.cs

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.WebPeis.AppointPatientRegisters
{
public class MobilePhoneInputDto
{
public string MobilePhone { get; set; }
}
}

45
src/Shentun.WebPeis.Application.Contracts/AppointRegisterAsbitems/AppointRegisterAsbitemDto.cs

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.WebPeis.AppointRegisterAsbitems
{
public class AppointRegisterAsbitemDto
{
/// <summary>
/// 主键
/// </summary>
public Guid AppointRegisterAsbitemId { get; set; }
/// <summary>
/// 组合项目ID
/// </summary>
public Guid AsbitemId { get; set; }
public string AsbitemName { get; set; }
/// <summary>
/// 预约主档ID
/// </summary>
public Guid AppointPatientRegisterId { get; set; }
/// <summary>
/// 标准价格
/// </summary>
public decimal StandardPrice { get; set; }
/// <summary>
/// 收费价格
/// </summary>
public decimal ChargePrice { get; set; }
/// <summary>
/// 支付类别标准
/// </summary>
public char PayTypeFlag { get; set; }
/// <summary>
/// 是否收费
/// </summary>
public char IsCharge { get; set; }
/// <summary>
/// 数量
/// </summary>
public short Amount { get; set; }
public char IsInMedicalPackage { get; set; } = 'N';
}
}

2
src/Shentun.WebPeis.Application.Contracts/Asbitems/DiseaseScreeningTypeAsbitemDto.cs

@ -9,7 +9,7 @@ namespace Shentun.WebPeis.Asbitems
public string DiseaseScreeningTypeId { get; set; } public string DiseaseScreeningTypeId { get; set; }
public string DiseaseScreeningTypeName { get; set; } public string DiseaseScreeningTypeName { get; set; }
public int DisplayOrder { get; set; } public int DisplayOrder { get; set; }
public List<DiseaseScreeningTypeAsbitem> Asbitems = new List<DiseaseScreeningTypeAsbitem>();
public List<DiseaseScreeningTypeAsbitem> Asbitems { get; set; } = new List<DiseaseScreeningTypeAsbitem>();
} }
public class DiseaseScreeningTypeAsbitem public class DiseaseScreeningTypeAsbitem

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

@ -1,14 +1,19 @@
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Shentun.WebPeis.AppointRegisterAsbitems; using Shentun.WebPeis.AppointRegisterAsbitems;
using Shentun.WebPeis.CustomerOrgs;
using Shentun.WebPeis.Models; using Shentun.WebPeis.Models;
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
using Volo.Abp.Identity;
using static Volo.Abp.Identity.Settings.IdentitySettingNames;
namespace Shentun.WebPeis.AppointPatientRegisters namespace Shentun.WebPeis.AppointPatientRegisters
{ {
@ -21,14 +26,32 @@ namespace Shentun.WebPeis.AppointPatientRegisters
{ {
private readonly IRepository<AppointPatientRegister> _repository; private readonly IRepository<AppointPatientRegister> _repository;
private readonly IRepository<AppointRegisterAsbitem> _appointRegisterAsbitemRepository; private readonly IRepository<AppointRegisterAsbitem> _appointRegisterAsbitemRepository;
private readonly IRepository<Person> _personRepository;
private readonly IRepository<CustomerOrg> _customerOrgRepository;
private readonly IRepository<IdentityUser> _identityUserRepository;
private readonly IRepository<Asbitem> _asbitemRepository;
private readonly IRepository<ItemType> _itemTypeRepository; private readonly IRepository<ItemType> _itemTypeRepository;
private readonly IRepository<MedicalPackage> _medicalPackageRepository;
private readonly IRepository<MedicalPackageDetail> _medicalPackageDetailRepository;
private readonly IRepository<CustomerOrgGroup> _customerOrgGroupRepository;
private readonly IRepository<CustomerOrgGroupDetail> _customerOrgGroupDetailRepository;
private readonly CacheService _cacheService; private readonly CacheService _cacheService;
private readonly AppointPatientRegisterManager _appointPatientRegisterManager; private readonly AppointPatientRegisterManager _appointPatientRegisterManager;
private readonly CustomerOrgManager _customerOrgManager;
public AppointPatientRegisterAppService(IRepository<AppointPatientRegister> repository, public AppointPatientRegisterAppService(IRepository<AppointPatientRegister> repository,
CacheService cacheService, CacheService cacheService,
IRepository<ItemType> itemTypeRepository, IRepository<ItemType> itemTypeRepository,
AppointPatientRegisterManager appointPatientRegisterManager, AppointPatientRegisterManager appointPatientRegisterManager,
IRepository<AppointRegisterAsbitem> appointRegisterAsbitemRepository
IRepository<AppointRegisterAsbitem> appointRegisterAsbitemRepository,
IRepository<Person> personRepository,
IRepository<IdentityUser> identityUserRepository,
CustomerOrgManager customerOrgManager,
IRepository<MedicalPackage> medicalPackageRepository,
IRepository<CustomerOrgGroup> customerOrgGroupRepository,
IRepository<Asbitem> asbitemRepository,
IRepository<CustomerOrg> customerOrgRepository,
IRepository<MedicalPackageDetail> medicalPackageDetailRepository,
IRepository<CustomerOrgGroupDetail> customerOrgGroupDetailRepository
) )
{ {
_repository = repository; _repository = repository;
@ -36,6 +59,15 @@ namespace Shentun.WebPeis.AppointPatientRegisters
_itemTypeRepository = itemTypeRepository; _itemTypeRepository = itemTypeRepository;
_appointPatientRegisterManager = appointPatientRegisterManager; _appointPatientRegisterManager = appointPatientRegisterManager;
_appointRegisterAsbitemRepository = appointRegisterAsbitemRepository; _appointRegisterAsbitemRepository = appointRegisterAsbitemRepository;
_personRepository = personRepository;
_identityUserRepository = identityUserRepository;
_customerOrgManager = customerOrgManager;
_medicalPackageRepository = medicalPackageRepository;
_customerOrgGroupRepository = customerOrgGroupRepository;
_asbitemRepository = asbitemRepository;
_customerOrgRepository = customerOrgRepository;
_medicalPackageDetailRepository = medicalPackageDetailRepository;
_customerOrgGroupDetailRepository = customerOrgGroupDetailRepository;
} }
@ -50,5 +82,152 @@ namespace Shentun.WebPeis.AppointPatientRegisters
var result = ObjectMapper.Map<AppointPatientRegister, AppointPatientRegisterDto>(entity); var result = ObjectMapper.Map<AppointPatientRegister, AppointPatientRegisterDto>(entity);
return result; return result;
} }
[HttpPost("api/app/AppointPatientRegister/GetByIdNoOrMobilePhone")]
public async Task<List<AppointPatientRegisterDto>> GetByIdNoOrMobilePhoneAsync(IdNoOrMobilePhoneInputDto input)
{
if (input == null) throw new UserFriendlyException("参数不能为空");
if (string.IsNullOrWhiteSpace(input.MobilePhone) && string.IsNullOrWhiteSpace(input.IdNo))
{
throw new UserFriendlyException("手机号和身份证必须至少填一个");
}
var query = (from user in await _identityUserRepository.GetQueryableAsync()
join person in await _personRepository.GetQueryableAsync()
on user.Id equals person.PersonId
join appointPatientRegister in await _repository.GetQueryableAsync()
on person.PersonId equals appointPatientRegister.PersonId
join medicalPackage in await _medicalPackageRepository.GetQueryableAsync()
on appointPatientRegister.MedicalPackageId equals medicalPackage.MedicalPackageId into canEmptyMedicalPackage
from haveMedicalPackage in canEmptyMedicalPackage.DefaultIfEmpty()
join customerOrgGroup in await _customerOrgGroupRepository.GetQueryableAsync()
on appointPatientRegister.CustomerOrgGroupId equals customerOrgGroup.CustomerOrgGroupId into canEmptyCustomerOrgGroup
from haveCustomerOrgGroup in canEmptyCustomerOrgGroup.DefaultIfEmpty()
join appointRegisterAsbitem in await _appointRegisterAsbitemRepository.GetQueryableAsync()
on appointPatientRegister.AppointPatientRegisterId equals appointRegisterAsbitem.AppointPatientRegisterId
join asbitem in await _asbitemRepository.GetQueryableAsync()
on appointRegisterAsbitem.AsbitemId equals asbitem.AsbitemId
join customerOrg in await _customerOrgRepository.GetQueryableAsync()
on appointPatientRegister.CustomerOrgId equals customerOrg.CustomerOrgId
orderby appointPatientRegister.AppointDate
select new
{
user,
person,
appointPatientRegister,
appointRegisterAsbitem,
asbitem,
haveMedicalPackage,
haveCustomerOrgGroup,
customerOrg
}
);
if (!string.IsNullOrWhiteSpace(input.IdNo))
{
if (input.IdNo.Length != 18)
{
throw new UserFriendlyException("身份证长度必须是18位");
}
query = query.Where(o => o.person.IdNo == input.IdNo);
}
else
{
if (input.MobilePhone.Length != 11)
{
throw new UserFriendlyException("手机号长度必须是11位");
}
query = query.Where(o => o.user.PhoneNumber == input.MobilePhone);
}
var appointPatientRegisterDtos = query.ToList();
var list = appointPatientRegisterDtos.GroupBy(o => o.appointPatientRegister)
.Select(o => new AppointPatientRegisterDto()
{
AppointPatientRegisterId = o.FirstOrDefault().appointPatientRegister.AppointPatientRegisterId,
PersonId = o.FirstOrDefault().appointPatientRegister.PersonId,
PersonName = o.FirstOrDefault().user.Name,
IdNo = o.FirstOrDefault().person.IdNo,
SexId = o.FirstOrDefault().person.SexId,
MaritalStatusId = o.FirstOrDefault().person.MaritalStatusId,
CustomerOrgId = o.FirstOrDefault().appointPatientRegister.CustomerOrgId,
ChildCustomerOrgName = o.FirstOrDefault().customerOrg.PathCode.Length == 5 ? "" : o.FirstOrDefault().customerOrg.CustomerOrgName,
CustomerOrgGroupId = o.FirstOrDefault().appointPatientRegister.CustomerOrgGroupId,
CustomerOrgGroupName = o.FirstOrDefault().haveCustomerOrgGroup == null ? "" : o.FirstOrDefault().haveCustomerOrgGroup.DisplayName,
CustomerOrgRegisterId = o.FirstOrDefault().appointPatientRegister.CustomerOrgRegisterId,
MedicalPackageId = o.FirstOrDefault().appointPatientRegister.MedicalPackageId,
MedicalPackageName = o.FirstOrDefault().haveMedicalPackage == null ? "" : o.FirstOrDefault().haveMedicalPackage.MedicalPackageName,
MedicalCenterId = o.FirstOrDefault().appointPatientRegister.MedicalCenterId,
CompleteFlag = o.FirstOrDefault().appointPatientRegister.CompleteFlag,
AppointDate = o.FirstOrDefault().appointPatientRegister.AppointDate,
Remark = o.FirstOrDefault().appointPatientRegister.Remark,
PregnantFlag = o.FirstOrDefault().appointPatientRegister.PregnantFlag,
Height = o.FirstOrDefault().appointPatientRegister.Height,
Weight = o.FirstOrDefault().appointPatientRegister.Weight,
SexName = _cacheService.GetSexNameAsync(o.FirstOrDefault().person.SexId).Result,
MaritalStatusName = _cacheService.GetMaritalStatusNameAsync(o.FirstOrDefault().person.MaritalStatusId).Result,
CustomerOrgName = _customerOrgManager.GetTopCustomerOrgAsync(o.FirstOrDefault().appointPatientRegister.CustomerOrgId).Result.CustomerOrgName
}).ToList();
return list;
}
[HttpPost("api/app/AppointPatientRegister/GetAppointRegisterAsbitemListById")]
public async Task<List<AppointRegisterAsbitemDto>> GetAppointRegisterAsbitemListByIdAsync(AppointPatientRegisterIdInputDto input)
{
var appointPatientRegister = await _repository.GetAsync(o => o.AppointPatientRegisterId == input.AppointPatientRegisterId);
var appointRegisterAsbitemDtos = (
from appointRegisterAsbitem in await _appointRegisterAsbitemRepository.GetQueryableAsync()
join asbitem in await _asbitemRepository.GetQueryableAsync()
on appointRegisterAsbitem.AsbitemId equals asbitem.AsbitemId
orderby appointPatientRegister.AppointDate
where appointRegisterAsbitem.AppointPatientRegisterId == input.AppointPatientRegisterId
select new AppointRegisterAsbitemDto()
{
AppointPatientRegisterId = input.AppointPatientRegisterId,
AsbitemId = appointRegisterAsbitem.AsbitemId,
AsbitemName = asbitem.AsbitemName,
StandardPrice = appointRegisterAsbitem.StandardPrice,
ChargePrice = appointRegisterAsbitem.ChargePrice,
Amount = appointRegisterAsbitem.Amount,
IsCharge = appointRegisterAsbitem.IsCharge
}
).ToList();
List<Guid> asbitems = new List<Guid>();
if (appointPatientRegister.MedicalPackageId != null)
{
asbitems = (await _medicalPackageDetailRepository.GetQueryableAsync())
.Where(o => o.MedicalPackageId == appointPatientRegister.MedicalPackageId)
.Select(x => x.AsbitemId).ToList();
;
}
else if (appointPatientRegister.CustomerOrgGroupId != null)
{
asbitems = (await _customerOrgGroupDetailRepository.GetQueryableAsync())
.Where(o => o.CustomerOrgGroupId == appointPatientRegister.CustomerOrgGroupId)
.Select(x => x.AsbitemId).ToList();
}
appointRegisterAsbitemDtos.ForEach(o =>
{
if (asbitems.Where(x => x == o.AsbitemId).ToList().Any())
{
o.IsInMedicalPackage = 'Y';
}
});
return appointRegisterAsbitemDtos;
}
} }
} }

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

@ -70,5 +70,47 @@ namespace Shentun.WebPeis
await unitOfWork.CompleteAsync(); await unitOfWork.CompleteAsync();
} }
} }
[Fact]
public async Task GetByIdNoOrMobilePhoneAsync()
{
using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
{
var entity = new IdNoOrMobilePhoneInputDto()
{
MobilePhone = "18911254911"
};
var list = await _appService.GetByIdNoOrMobilePhoneAsync(entity);
foreach (var item in list)
{
_output.WriteLine(item.PersonName);
foreach(var asbitem in item.AppointRegisterAsbitems)
{
_output.WriteLine(asbitem.AsbitemName);
}
}
await unitOfWork.CompleteAsync();
}
}
[Fact]
public async Task GetAppointRegisterAsbitemListById()
{
using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
{
var entity = new AppointPatientRegisterIdInputDto()
{
AppointPatientRegisterId = new Guid("3a12ec60-278d-1814-753b-87ff8782aa26")
};
var list = await _appService.GetAppointRegisterAsbitemListByIdAsync(entity);
foreach (var item in list)
{
_output.WriteLine(item.AsbitemName);
}
await unitOfWork.CompleteAsync();
}
}
} }
} }
Loading…
Cancel
Save