|
|
|
@ -14,8 +14,14 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
{ |
|
|
|
public class PatientRegisterChargeRepository : EfCoreRepository<PeisDbContext, PatientRegister, Guid>, IPatientRegisterChargeRepository |
|
|
|
{ |
|
|
|
public PatientRegisterChargeRepository(IDbContextProvider<PeisDbContext> dbContextProvider) : base(dbContextProvider) |
|
|
|
private readonly CacheService _cacheService; |
|
|
|
|
|
|
|
public PatientRegisterChargeRepository( |
|
|
|
IDbContextProvider<PeisDbContext> dbContextProvider, |
|
|
|
CacheService cacheService |
|
|
|
) : base(dbContextProvider) |
|
|
|
{ |
|
|
|
_cacheService = cacheService; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -28,17 +34,14 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
{ |
|
|
|
var dbContext = await GetDbContextAsync(); |
|
|
|
|
|
|
|
List<CustomerOrg> customerOrgs = dbContext.CustomerOrgs.ToList(); |
|
|
|
|
|
|
|
|
|
|
|
var query = (from a in dbContext.PatientRegisters |
|
|
|
join b in dbContext.Patients on a.PatientId equals b.Id into bb |
|
|
|
from ab in bb.DefaultIfEmpty() |
|
|
|
join c in dbContext.Sexes on a.SexId equals c.Id into cc |
|
|
|
from ac in cc.DefaultIfEmpty() |
|
|
|
join d in dbContext.Charges on a.Id equals d.PatientRegisterId |
|
|
|
join e in dbContext.ChargeBacks on d.Id equals e.ChargeId |
|
|
|
where d.ChargeFlag == '1' |
|
|
|
select new { a, ab, ac, d, e } |
|
|
|
select new { a, ab, d, e } |
|
|
|
); |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(input.StartDate) && !string.IsNullOrEmpty(input.EndDate)) |
|
|
|
@ -63,8 +66,7 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
query = query.Where(m => m.a.PatientRegisterNo == input.PatientRegisterNo); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var entlist = query.OrderBy(o => o.a.CreationTime).Select(s => new GetPatientRegisterChargeBackListDto |
|
|
|
var entlist = query.ToList().OrderBy(o => o.a.CreationTime).Select(s => new GetPatientRegisterChargeBackListDto |
|
|
|
{ |
|
|
|
PatientRegisterId = s.a.Id, |
|
|
|
Address = s.ab.Address, |
|
|
|
@ -73,8 +75,8 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
ChargeBackId = s.e.Id, |
|
|
|
InvoiceNo = s.d.InvoiceNo, |
|
|
|
InvoiceOrgName = s.d.InvoiceOrgName, |
|
|
|
CustomerOrgName = EntityHelper.GetCustomerOrgNameNoSql(customerOrgs, s.a.CustomerOrgId), |
|
|
|
CustomerOrgParentName = EntityHelper.GetCustomerOrgParentNameNoSql(customerOrgs, s.a.CustomerOrgId), |
|
|
|
CustomerOrgName = _cacheService.GetCustomerOrgAsync(s.a.CustomerOrgId).GetAwaiter().GetResult().DisplayName, |
|
|
|
CustomerOrgParentName = _cacheService.GetTopCustomerOrgAsync(s.a.CustomerOrgId).GetAwaiter().GetResult().DisplayName, |
|
|
|
Email = s.ab.Email, |
|
|
|
IdNo = s.ab.IdNo, |
|
|
|
IsVip = s.a.IsVip, |
|
|
|
@ -84,7 +86,7 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
PatientNo = s.ab.PatientNo, |
|
|
|
PatientRegisterNo = s.a.PatientRegisterNo, |
|
|
|
Salesman = s.a.Salesman, |
|
|
|
SexId = s.ac.DisplayName, |
|
|
|
SexId = _cacheService.GetSexNameAsync(s.a.SexId).GetAwaiter().GetResult(), |
|
|
|
Telephone = s.ab.Telephone |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
@ -101,20 +103,16 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
|
|
|
|
var dbContext = await GetDbContextAsync(); |
|
|
|
|
|
|
|
List<CustomerOrg> customerOrgs = dbContext.CustomerOrgs.ToList(); |
|
|
|
|
|
|
|
|
|
|
|
var query = (from a in dbContext.PatientRegisters |
|
|
|
join b in dbContext.Patients on a.PatientId equals b.Id into bb |
|
|
|
from ab in bb.DefaultIfEmpty() |
|
|
|
join c in dbContext.Sexes on a.SexId equals c.Id into cc |
|
|
|
from ac in cc.DefaultIfEmpty() |
|
|
|
join d in dbContext.Charges on a.Id equals d.PatientRegisterId |
|
|
|
where d.ChargeFlag == '0' |
|
|
|
select new { a, ab, ac, d } |
|
|
|
select new { a, ab, d } |
|
|
|
); |
|
|
|
|
|
|
|
var sss = query.ToQueryString(); |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(input.StartDate) && !string.IsNullOrEmpty(input.EndDate)) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.a.CreationTime >= Convert.ToDateTime(input.StartDate) && |
|
|
|
@ -138,7 +136,7 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var entlist = query.OrderBy(o => o.a.CreationTime).Select(s => new GetPatientRegisterChargeListDto |
|
|
|
var entlist = query.ToList().OrderBy(o => o.a.CreationTime).Select(s => new GetPatientRegisterChargeListDto |
|
|
|
{ |
|
|
|
PatientRegisterId = s.a.Id, |
|
|
|
Address = s.ab.Address, |
|
|
|
@ -146,8 +144,8 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
ChargeId = s.d.Id, |
|
|
|
InvoiceNo = s.d.InvoiceNo, |
|
|
|
InvoiceOrgName = s.d.InvoiceOrgName, |
|
|
|
CustomerOrgName = EntityHelper.GetCustomerOrgNameNoSql(customerOrgs, s.a.CustomerOrgId), |
|
|
|
CustomerOrgParentName = EntityHelper.GetCustomerOrgParentNameNoSql(customerOrgs, s.a.CustomerOrgId), |
|
|
|
CustomerOrgName = _cacheService.GetCustomerOrgAsync(s.a.CustomerOrgId).GetAwaiter().GetResult().DisplayName, |
|
|
|
CustomerOrgParentName = _cacheService.GetTopCustomerOrgAsync(s.a.CustomerOrgId).GetAwaiter().GetResult().DisplayName, |
|
|
|
Email = s.ab.Email, |
|
|
|
IdNo = s.ab.IdNo, |
|
|
|
IsVip = s.a.IsVip, |
|
|
|
@ -157,7 +155,7 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
PatientNo = s.ab.PatientNo, |
|
|
|
PatientRegisterNo = s.a.PatientRegisterNo, |
|
|
|
Salesman = s.a.Salesman, |
|
|
|
SexId = s.ac.DisplayName, |
|
|
|
SexId = _cacheService.GetSexNameAsync(s.a.SexId).GetAwaiter().GetResult(), |
|
|
|
Telephone = s.ab.Telephone |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
@ -175,16 +173,15 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
{ |
|
|
|
var dbContext = await GetDbContextAsync(); |
|
|
|
|
|
|
|
List<CustomerOrg> customerOrgs = dbContext.CustomerOrgs.ToList(); |
|
|
|
|
|
|
|
var query = (from a in dbContext.PatientRegisters.Where(m => dbContext.RegisterCheckAsbitems.Where(rsb => rsb.IsCharge == 'N' && rsb.PayTypeFlag == PayTypeFlag.PersonPay).Select(s => s.PatientRegisterId).Contains(m.Id)) |
|
|
|
join b in dbContext.Patients on a.PatientId equals b.Id into bb |
|
|
|
from ab in bb.DefaultIfEmpty() |
|
|
|
join c in dbContext.Sexes on a.SexId equals c.Id into cc |
|
|
|
from ac in cc.DefaultIfEmpty() |
|
|
|
select new { a, ab, ac } |
|
|
|
select new { a, ab } |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(input.StartDate) && !string.IsNullOrEmpty(input.EndDate)) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.a.CreationTime >= Convert.ToDateTime(input.StartDate) && |
|
|
|
@ -204,13 +201,13 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var entlist = query.OrderBy(o => o.a.CreationTime).Select(s => new GetPatientRegisterNotChargedListDto |
|
|
|
var entlist = query.ToList().OrderBy(o => o.a.CreationTime).Select(s => new GetPatientRegisterNotChargedListDto |
|
|
|
{ |
|
|
|
PatientRegisterId = s.a.Id, |
|
|
|
Address = s.ab.Address, |
|
|
|
Age = s.a.Age, |
|
|
|
CustomerOrgName = EntityHelper.GetCustomerOrgNameNoSql(customerOrgs, s.a.CustomerOrgId), |
|
|
|
CustomerOrgParentName = EntityHelper.GetCustomerOrgParentNameNoSql(customerOrgs, s.a.CustomerOrgId), |
|
|
|
CustomerOrgName = _cacheService.GetCustomerOrgAsync(s.a.CustomerOrgId).GetAwaiter().GetResult().DisplayName, |
|
|
|
CustomerOrgParentName = _cacheService.GetTopCustomerOrgAsync(s.a.CustomerOrgId).GetAwaiter().GetResult().DisplayName, |
|
|
|
Email = s.ab.Email, |
|
|
|
IdNo = s.ab.IdNo, |
|
|
|
IsVip = s.a.IsVip, |
|
|
|
@ -220,7 +217,7 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
PatientNo = s.ab.PatientNo, |
|
|
|
PatientRegisterNo = s.a.PatientRegisterNo, |
|
|
|
Salesman = s.a.Salesman, |
|
|
|
SexId = s.ac.DisplayName, |
|
|
|
SexId = _cacheService.GetSexNameAsync(s.a.SexId).GetAwaiter().GetResult(), |
|
|
|
Telephone = s.ab.Telephone |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
|