|
|
|
@ -34,60 +34,69 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
{ |
|
|
|
var dbContext = await GetDbContextAsync(); |
|
|
|
|
|
|
|
|
|
|
|
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 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, d, e } |
|
|
|
); |
|
|
|
|
|
|
|
var query = from patientRegister in dbContext.PatientRegisters |
|
|
|
join patient in dbContext.Patients on patientRegister.PatientId equals patient.Id |
|
|
|
join charge in dbContext.Charges on patientRegister.Id equals charge.PatientRegisterId |
|
|
|
join chargeBack in dbContext.ChargeBacks on charge.Id equals chargeBack.ChargeId |
|
|
|
join chargeBackPay in dbContext.ChargeBackPays on chargeBack.Id equals chargeBackPay.ChargeBackId |
|
|
|
where charge.ChargeFlag == ChargeFlag.ChargeBack |
|
|
|
select new |
|
|
|
{ |
|
|
|
patientRegister, |
|
|
|
patient, |
|
|
|
charge, |
|
|
|
chargeBack, |
|
|
|
chargeBackPay |
|
|
|
}; |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(input.StartDate) && !string.IsNullOrEmpty(input.EndDate)) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.a.CreationTime >= Convert.ToDateTime(input.StartDate) && |
|
|
|
m.a.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1)); |
|
|
|
query = query.Where(m => m.chargeBack.CreationTime >= Convert.ToDateTime(input.StartDate) && |
|
|
|
m.chargeBack.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1)); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(input.InvoiceNo)) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.d.InvoiceNo == input.InvoiceNo); |
|
|
|
query = query.Where(m => m.charge.InvoiceNo == input.InvoiceNo); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(input.PatientName)) |
|
|
|
{ |
|
|
|
query = query.Where(m => !string.IsNullOrEmpty(m.a.PatientName) && m.a.PatientName.Contains(input.InvoiceNo)); |
|
|
|
query = query.Where(m => m.patientRegister.PatientName == input.PatientName); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(input.PatientNo)) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.ab.PatientNo == input.PatientNo); |
|
|
|
query = query.Where(m => m.patient.PatientNo == input.PatientNo); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(input.PatientRegisterNo)) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.a.PatientRegisterNo == input.PatientRegisterNo); |
|
|
|
query = query.Where(m => m.patientRegister.PatientRegisterNo == input.PatientRegisterNo); |
|
|
|
} |
|
|
|
|
|
|
|
var entlist = query.ToList().OrderBy(o => o.a.CreationTime).Select(s => new GetPatientRegisterChargeBackListDto |
|
|
|
{ |
|
|
|
PatientRegisterId = s.a.Id, |
|
|
|
Address = s.ab.Address, |
|
|
|
Age = s.a.Age, |
|
|
|
ChargeId = s.d.Id, |
|
|
|
ChargeBackId = s.e.Id, |
|
|
|
InvoiceNo = s.d.InvoiceNo, |
|
|
|
InvoiceOrgName = s.d.InvoiceOrgName, |
|
|
|
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, |
|
|
|
MedicalTimes = s.a.MedicalTimes, |
|
|
|
MobileTelephone = s.ab.MobileTelephone, |
|
|
|
PatientName = s.a.PatientName, |
|
|
|
PatientNo = s.ab.PatientNo, |
|
|
|
PatientRegisterNo = s.a.PatientRegisterNo, |
|
|
|
Salesman = s.a.Salesman, |
|
|
|
SexId = _cacheService.GetSexNameAsync(s.a.SexId).GetAwaiter().GetResult(), |
|
|
|
Telephone = s.ab.Telephone |
|
|
|
var entlist = query.OrderBy(o => o.chargeBack.CreationTime).ToList().GroupBy(g => g.chargeBack).Select(s => new GetPatientRegisterChargeBackListDto |
|
|
|
{ |
|
|
|
PatientRegisterId = s.FirstOrDefault().patientRegister.Id, |
|
|
|
Address = s.FirstOrDefault().patient.Address, |
|
|
|
Age = s.FirstOrDefault().patientRegister.Age, |
|
|
|
ChargeId = s.FirstOrDefault().charge.Id, |
|
|
|
ChargeBackId = s.Key.Id, |
|
|
|
InvoiceNo = s.FirstOrDefault().charge.InvoiceNo, |
|
|
|
InvoiceOrgName = s.FirstOrDefault().charge.InvoiceOrgName, |
|
|
|
CustomerOrgName = _cacheService.GetCustomerOrgAsync(s.FirstOrDefault().patientRegister.CustomerOrgId).GetAwaiter().GetResult().DisplayName, |
|
|
|
CustomerOrgParentName = _cacheService.GetTopCustomerOrgAsync(s.FirstOrDefault().patientRegister.CustomerOrgId).GetAwaiter().GetResult().DisplayName, |
|
|
|
Email = s.FirstOrDefault().patient.Email, |
|
|
|
IdNo = s.FirstOrDefault().patient.IdNo, |
|
|
|
IsVip = s.FirstOrDefault().patientRegister.IsVip, |
|
|
|
MedicalTimes = s.FirstOrDefault().patientRegister.MedicalTimes, |
|
|
|
MobileTelephone = s.FirstOrDefault().patient.MobileTelephone, |
|
|
|
PatientName = s.FirstOrDefault().patientRegister.PatientName, |
|
|
|
PatientNo = s.FirstOrDefault().patient.PatientNo, |
|
|
|
PatientRegisterNo = s.FirstOrDefault().patientRegister.PatientRegisterNo, |
|
|
|
Salesman = s.FirstOrDefault().patientRegister.Salesman, |
|
|
|
SexId = _cacheService.GetSexNameAsync(s.FirstOrDefault().patientRegister.SexId).GetAwaiter().GetResult(), |
|
|
|
Telephone = s.FirstOrDefault().patient.Telephone, |
|
|
|
ChargeBackName = _cacheService.GetSurnameAsync(s.Key.CreatorId).GetAwaiter().GetResult(), |
|
|
|
ChargeBackTime = DataHelper.ConversionDateToString(s.Key.CreationTime), |
|
|
|
ChargeBackMoney = s.Sum(sm => sm.chargeBackPay.BackMoeny) |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
return entlist; |
|
|
|
@ -103,60 +112,68 @@ namespace Shentun.Peis.PatientRegisters |
|
|
|
|
|
|
|
var dbContext = await GetDbContextAsync(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 d in dbContext.Charges on a.Id equals d.PatientRegisterId |
|
|
|
where d.ChargeFlag == '0' |
|
|
|
select new { a, ab, d } |
|
|
|
); |
|
|
|
|
|
|
|
var query = from patientRegister in dbContext.PatientRegisters |
|
|
|
join patient in dbContext.Patients on patientRegister.PatientId equals patient.Id |
|
|
|
join charge in dbContext.Charges on patientRegister.Id equals charge.PatientRegisterId |
|
|
|
join chargePay in dbContext.ChargePays on charge.Id equals chargePay.ChargeId |
|
|
|
where charge.ChargeFlag == ChargeFlag.Charge |
|
|
|
select new |
|
|
|
{ |
|
|
|
patientRegister, |
|
|
|
patient, |
|
|
|
charge, |
|
|
|
chargePay |
|
|
|
}; |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(input.StartDate) && !string.IsNullOrEmpty(input.EndDate)) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.a.CreationTime >= Convert.ToDateTime(input.StartDate) && |
|
|
|
m.a.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1)); |
|
|
|
query = query.Where(m => m.charge.CreationTime >= Convert.ToDateTime(input.StartDate) && |
|
|
|
m.charge.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1)); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(input.InvoiceNo)) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.d.InvoiceNo == input.InvoiceNo); |
|
|
|
query = query.Where(m => m.charge.InvoiceNo == input.InvoiceNo); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(input.PatientName)) |
|
|
|
{ |
|
|
|
query = query.Where(m => !string.IsNullOrEmpty(m.a.PatientName) && m.a.PatientName.Contains(input.InvoiceNo)); |
|
|
|
query = query.Where(m => !string.IsNullOrEmpty(m.patientRegister.PatientName) && m.patientRegister.PatientName.Contains(input.InvoiceNo)); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(input.PatientNo)) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.ab.PatientNo == input.PatientNo); |
|
|
|
query = query.Where(m => m.patient.PatientNo == input.PatientNo); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(input.PatientRegisterNo)) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.a.PatientRegisterNo == input.PatientRegisterNo); |
|
|
|
query = query.Where(m => m.patientRegister.PatientRegisterNo == input.PatientRegisterNo); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var entlist = query.ToList().OrderBy(o => o.a.CreationTime).Select(s => new GetPatientRegisterChargeListDto |
|
|
|
{ |
|
|
|
PatientRegisterId = s.a.Id, |
|
|
|
Address = s.ab.Address, |
|
|
|
Age = s.a.Age, |
|
|
|
ChargeId = s.d.Id, |
|
|
|
InvoiceNo = s.d.InvoiceNo, |
|
|
|
InvoiceOrgName = s.d.InvoiceOrgName, |
|
|
|
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, |
|
|
|
MedicalTimes = s.a.MedicalTimes, |
|
|
|
MobileTelephone = s.ab.MobileTelephone, |
|
|
|
PatientName = s.a.PatientName, |
|
|
|
PatientNo = s.ab.PatientNo, |
|
|
|
PatientRegisterNo = s.a.PatientRegisterNo, |
|
|
|
Salesman = s.a.Salesman, |
|
|
|
SexId = _cacheService.GetSexNameAsync(s.a.SexId).GetAwaiter().GetResult(), |
|
|
|
Telephone = s.ab.Telephone |
|
|
|
var entlist = query.OrderBy(o => o.charge.CreationTime).ToList().GroupBy(g => g.charge).Select(s => new GetPatientRegisterChargeListDto |
|
|
|
{ |
|
|
|
PatientRegisterId = s.FirstOrDefault().patientRegister.Id, |
|
|
|
Address = s.FirstOrDefault().patient.Address, |
|
|
|
Age = s.FirstOrDefault().patientRegister.Age, |
|
|
|
ChargeId = s.Key.Id, |
|
|
|
InvoiceNo = s.Key.InvoiceNo, |
|
|
|
InvoiceOrgName = s.Key.InvoiceOrgName, |
|
|
|
CustomerOrgName = _cacheService.GetCustomerOrgAsync(s.FirstOrDefault().patientRegister.CustomerOrgId).GetAwaiter().GetResult().DisplayName, |
|
|
|
CustomerOrgParentName = _cacheService.GetTopCustomerOrgAsync(s.FirstOrDefault().patientRegister.CustomerOrgId).GetAwaiter().GetResult().DisplayName, |
|
|
|
Email = s.FirstOrDefault().patient.Email, |
|
|
|
IdNo = s.FirstOrDefault().patient.IdNo, |
|
|
|
IsVip = s.FirstOrDefault().patientRegister.IsVip, |
|
|
|
MedicalTimes = s.FirstOrDefault().patientRegister.MedicalTimes, |
|
|
|
MobileTelephone = s.FirstOrDefault().patient.MobileTelephone, |
|
|
|
PatientName = s.FirstOrDefault().patientRegister.PatientName, |
|
|
|
PatientNo = s.FirstOrDefault().patient.PatientNo, |
|
|
|
PatientRegisterNo = s.FirstOrDefault().patientRegister.PatientRegisterNo, |
|
|
|
Salesman = s.FirstOrDefault().patientRegister.Salesman, |
|
|
|
SexId = _cacheService.GetSexNameAsync(s.FirstOrDefault().patientRegister.SexId).GetAwaiter().GetResult(), |
|
|
|
Telephone = s.FirstOrDefault().patient.Telephone, |
|
|
|
ChargeName = _cacheService.GetSurnameAsync(s.Key.CreatorId).GetAwaiter().GetResult(), |
|
|
|
ChargeTime = DataHelper.ConversionDateToString(s.Key.CreationTime), |
|
|
|
ChargeMoney = s.Sum(sm => sm.chargePay.ChargeMoney) |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
return entlist; |
|
|
|
|