using Castle.Core.Logging;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Shentun.Peis.CommonCharTypes;
using Shentun.Peis.CustomerOrgRegisters;
using Shentun.Peis.CustomerOrgs;
using Shentun.Peis.Enums;
using Shentun.Peis.Models;
using Shentun.Peis.Patients;
using Shentun.Peis.RegisterAsbitems;
using Shentun.Peis.RegisterChecks;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Security;
using System.Threading.Tasks;
using TencentCloud.Cwp.V20180228.Models;
using TencentCloud.Mps.V20190612.Models;
using TencentCloud.Npp.V20190823.Models;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Identity;
using Volo.Abp.ObjectMapping;
namespace Shentun.Peis.PatientRegisters
{
///
/// 人员体检登记
///
[ApiExplorerSettings(GroupName = "Work")]
//[Authorize]
public class PatientRegisterAppService : CrudAppService<
PatientRegister, //The Book entity
PatientRegisterDto, //Used to show books
Guid, //Primary key of the book entity
PagedAndSortedResultRequestDto, //Used for paging/sorting
CreatePatientRegisterDto,
UpdatePatientRegisterDto>
{
private readonly IRepository _repository;
private readonly IRepository _patientrepository;
private readonly IRepository _userRepository;
private readonly IRepository _sexRepository;
private readonly IRepository _birthPlaceRepository;
private readonly IRepository _maritalStatusRepository;
private readonly IRepository _nationRepository;
private readonly IRepository _customerOrgGroupRepository;
private readonly IRepository _customerOrgGroupDetailRepository;
private readonly IRepository _customerOrgRepository;
private readonly IRepository _personnelTypeRepository;
private readonly IRepository _medicalTypeRepository;
private readonly IRepository _sexHormoneTermRepository;
private readonly IRepository _payModeRepository;
private readonly IRepository _registerAsbitemRepository;
private readonly IRepository _registerCheckRepository;
private readonly IRepository _registerCheckItemRepository;
private readonly IRepository- _itemRepository;
private readonly IPatientRegisterChargeRepository _patientRegisterChargeRepository;
private readonly ILogger _logger;
private readonly CustomerOrgManager _customerOrgManager;
private readonly CustomerOrgRegisterManager _customerOrgRegisterManager;
private readonly PatientManager _patientManager;
private readonly PatientRegisterManager _patientRegisterManager;
private readonly RegisterAsbitemManager _registerAsbitemManager;
//private readonly IRepository _customerOrgRepository;
//private readonly IRepository _primarykeyBuilderRepository;
//private readonly IRepository _sysParmValueRepository;
private readonly PatientRegisterManager _manager;
public PatientRegisterAppService(
IRepository repository,
IRepository patientrepository,
IRepository userRepository,
IRepository sexRepository,
IRepository birthPlaceRepository,
IRepository maritalStatusRepository,
IRepository nationRepository,
IRepository customerOrgGroupRepository,
IRepository customerOrgGroupDetailRepository,
IRepository customerOrgRepository,
IRepository personnelTypeRepository,
IRepository medicalTypeRepository,
IRepository sexHormoneTermRepository,
IRepository payModeRepository,
IRepository registerAsbitemRepository,
IRepository registerCheckRepository,
IRepository registerCheckItemRepository,
IRepository
- itemRepository,
//IRepository sysParmValueRepository,
//IRepository customerOrgRepository,
//IRepository primarykeyBuilderRepository,
IPatientRegisterChargeRepository patientRegisterChargeRepository,
ILogger logger,
CustomerOrgManager customerOrgManager,
CustomerOrgRegisterManager customerOrgRegisterManager,
PatientManager patientManager,
PatientRegisterManager patientRegisterManager,
RegisterAsbitemManager registerAsbitemManager,
PatientRegisterManager manager)
: base(repository)
{
this._repository = repository;
this._patientrepository = patientrepository;
this._userRepository = userRepository;
this._sexRepository = sexRepository;
this._birthPlaceRepository = birthPlaceRepository;
this._maritalStatusRepository = maritalStatusRepository;
this._nationRepository = nationRepository;
this._customerOrgGroupRepository = customerOrgGroupRepository;
this._customerOrgGroupDetailRepository = customerOrgGroupDetailRepository;
this._customerOrgRepository = customerOrgRepository;
this._personnelTypeRepository = personnelTypeRepository;
this._medicalTypeRepository = medicalTypeRepository;
this._sexHormoneTermRepository = sexHormoneTermRepository;
this._payModeRepository = payModeRepository;
this._registerAsbitemRepository = registerAsbitemRepository;
this._registerCheckRepository = registerCheckRepository;
this._registerCheckItemRepository = registerCheckItemRepository;
this._itemRepository = itemRepository;
this._patientRegisterChargeRepository = patientRegisterChargeRepository;
this._logger = logger;
this._customerOrgManager = customerOrgManager;
this._customerOrgRegisterManager = customerOrgRegisterManager;
this._patientManager = patientManager;
this._patientRegisterManager = patientRegisterManager;
this._registerAsbitemManager = registerAsbitemManager;
//this._customerOrgRepository = customerOrgRepository;
//this._primarykeyBuilderRepository = primarykeyBuilderRepository;
//this._sysParmValueRepository = sysParmValueRepository;
_manager = manager;
}
///
/// 获取通过主键
///
///
///
public override async Task GetAsync(Guid id)
{
return await base.GetAsync(id);
}
///
/// 编辑反写接口,包含档案表跟登记表的信息
///
/// 登记表ID
///
public async Task GetInfoOrPatientAsync(Guid PatientRegisterId)
{
var ent = (await _repository.GetDbSetAsync()).Include(x => x.Patient).Where(m => m.Id == PatientRegisterId).FirstOrDefault();
var entdto = new PatientRegisterOrNoDto();
if (ent != null)
{
var userList = await _userRepository.GetListAsync();
entdto = new PatientRegisterOrNoDto
{
Age = ent.Age,
AuditDate = ent.AuditDate.ToString(),
Id = ent.Id,
AuditDoctor = ent.AuditDoctor,
BirthDate = ent.BirthDate.ToString(),
CompleteFlag = ent.CompleteFlag,
CreationTime = ent.CreationTime,
CreatorId = ent.CreatorId,
CustomerOrgGroupId = ent.CustomerOrgGroupId,
CustomerOrgId = ent.CustomerOrgId,
CustomerOrgRegisterId = ent.CustomerOrgRegisterId,
GuidePrintTimes = ent.GuidePrintTimes,
InterposeMeasure = ent.InterposeMeasure,
IsAudit = ent.IsAudit,
IsLock = ent.IsLock,
IsMedicalStart = ent.IsMedicalStart,
IsNameHide = ent.IsNameHide,
IsPhoneFollow = ent.IsPhoneFollow,
IsRecoverGuide = ent.IsRecoverGuide,
IsUpload = ent.IsUpload,
IsVip = ent.IsVip,
JobCardNo = ent.JobCardNo,
JobPost = ent.JobPost,
JobTitle = ent.JobTitle,
LastModificationTime = ent.LastModificationTime,
LastModifierId = ent.LastModifierId,
MaritalStatusId = ent.MaritalStatusId,
MedicalCardNo = ent.MedicalCardNo,
MedicalConclusionId = ent.MedicalConclusionId,
MedicalPackageId = ent.MedicalPackageId,
MedicalStartDate = ent.MedicalStartDate.ToString(),
MedicalTimes = ent.MedicalTimes,
MedicalTypeId = ent.MedicalTypeId,
OrganizationUnitId = ent.OrganizationUnitId,
PatientId = ent.PatientId,
PatientName = ent.PatientName,
PatientRegisterNo = ent.PatientRegisterNo,
PersonnelTypeId = ent.PersonnelTypeId,
Photo = ent.Photo,
Remark = ent.Remark,
ReportPrintTimes = ent.ReportPrintTimes,
Salesman = ent.Salesman,
SexHormoneTermId = ent.SexHormoneTermId,
SexId = ent.SexId,
SummaryDate = ent.SummaryDate.ToString(),
SummaryDoctor = ent.SummaryDoctor,
ThirdInfo = ent.ThirdInfo,
CreatorName = EntityHelper.GetUserNameNoSql(userList, ent.CreatorId),
LastModifierName = EntityHelper.GetUserNameNoSql(userList, ent.LastModifierId),
Address = ent.Patient.Address, //档案表信息
BirthPlaceId = ent.Patient.BirthPlaceId,
DisplayName = ent.Patient.DisplayName,
Email = ent.Patient.Email,
IdNo = ent.Patient.IdNo,
MobileTelephone = ent.Patient.MobileTelephone,
NationId = ent.Patient.NationId,
PatientNo = ent.Patient.PatientNo,
PatientPassword = ent.Patient.PatientPassword,
PostalCode = ent.Patient.PostalCode,
Telephone = ent.Patient.Telephone,
CustomerOrgName = "",
CustomerOrgParentName = ""
};
}
return entdto;
}
///
/// 获取列表 人员体检
///
///
///
[RemoteService(false)]
public override async Task> GetListAsync(PagedAndSortedResultRequestDto input)
{
return await base.GetListAsync(input);
}
///
/// 获取档案登记列表 带联合搜索条件
///
///
///
[HttpPost("api/app/patientregister/getlistinfilter")]
public async Task> GetListInFilterAsync(GetListInSearchDto input)
{
var userList = await _userRepository.GetListAsync();
var customerOrgList = await _customerOrgRepository.GetListAsync();
//Stopwatch stopwatch = Stopwatch.StartNew();
//stopwatch.Start();
#region MyRegion
var entlist = (await _repository.GetDbSetAsync()).Include(x => x.Patient).AsQueryable();
if (!string.IsNullOrEmpty(input.PatientNo))
entlist = entlist.Where(m => m.Patient.PatientNo == input.PatientNo);
if (!string.IsNullOrEmpty(input.IdNo))
entlist = entlist.Where(m => m.Patient.IdNo == input.IdNo);
if (!string.IsNullOrEmpty(input.PatientName))
entlist = entlist.Where(m => !string.IsNullOrEmpty(m.PatientName) && m.PatientName.Contains(input.PatientName));
if (!string.IsNullOrEmpty(input.PatientRegisterNo))
entlist = entlist.Where(m => m.PatientRegisterNo == input.PatientRegisterNo);
if (input.SexId != null)
if (input.SexId.ToString() != ForSexFlag.All)
entlist = entlist.Where(m => m.SexId == input.SexId);
if (!string.IsNullOrEmpty(input.StartDate) && !string.IsNullOrEmpty(input.EndDate))
entlist = entlist.Where(m => m.CreationTime >= Convert.ToDateTime(input.StartDate) &&
m.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1));
if (input.CompleteFlag != null)
entlist = entlist.Where(m => m.CompleteFlag == input.CompleteFlag);
if (input.CustomerOrgId != null && input.CustomerOrgId != Guid.Empty)
{
var CustomerOrgIds = await _customerOrgManager.GetCustomerOrgChildrenId(input.CustomerOrgId.Value);
entlist = entlist.Where(m => CustomerOrgIds.Contains(m.CustomerOrgId));
}
#endregion
int totalCount = entlist.Count();
entlist = entlist.Skip(input.SkipCount * input.MaxResultCount).Take(input.MaxResultCount);
var entdto = entlist.Select(s => new PatientRegisterOrNoDto
{
CreationTime = s.CreationTime,
CreatorId = s.CreatorId,
Id = s.Id,
LastModificationTime = s.LastModificationTime,
LastModifierId = s.LastModifierId,
ThirdInfo = s.ThirdInfo,
SummaryDoctor = s.SummaryDoctor,
SummaryDate = s.SummaryDate.ToString(),
SexId = s.SexId,
Age = s.Age,
AuditDate = s.AuditDate.ToString(),
AuditDoctor = s.AuditDoctor,
BirthDate = s.BirthDate.ToString(),
CompleteFlag = s.CompleteFlag,
CustomerOrgGroupId = s.CustomerOrgGroupId,
CustomerOrgId = s.CustomerOrgId,
CustomerOrgRegisterId = s.CustomerOrgRegisterId,
GuidePrintTimes = s.GuidePrintTimes,
InterposeMeasure = s.InterposeMeasure,
IsAudit = s.IsAudit,
IsLock = s.IsLock,
IsMedicalStart = s.IsMedicalStart,
IsNameHide = s.IsNameHide,
IsPhoneFollow = s.IsPhoneFollow,
IsRecoverGuide = s.IsRecoverGuide,
IsUpload = s.IsUpload,
IsVip = s.IsVip,
JobCardNo = s.JobCardNo,
JobPost = s.JobPost,
JobTitle = s.JobTitle,
MaritalStatusId = s.MaritalStatusId,
MedicalCardNo = s.MedicalCardNo,
MedicalConclusionId = s.MedicalConclusionId,
MedicalPackageId = s.MedicalPackageId,
MedicalStartDate = s.MedicalStartDate.ToString(),
MedicalTimes = s.MedicalTimes,
MedicalTypeId = s.MedicalTypeId,
OrganizationUnitId = s.OrganizationUnitId,
PatientId = s.PatientId,
PatientName = s.PatientName,
PatientRegisterNo = s.PatientRegisterNo,
PersonnelTypeId = s.PersonnelTypeId,
Photo = s.Photo,
Remark = s.Remark,
ReportPrintTimes = s.ReportPrintTimes,
Salesman = s.Salesman,
SexHormoneTermId = s.SexHormoneTermId,
CreatorName = EntityHelper.GetUserNameNoSql(userList, s.CreatorId),
LastModifierName = EntityHelper.GetUserNameNoSql(userList, s.LastModifierId),
Address = s.Patient.Address, //档案表信息
BirthPlaceId = s.Patient.BirthPlaceId,
DisplayName = s.Patient.DisplayName,
Email = s.Patient.Email,
IdNo = s.Patient.IdNo,
MobileTelephone = s.Patient.MobileTelephone,
NationId = s.Patient.NationId,
PatientNo = s.Patient.PatientNo,
PatientPassword = s.Patient.PatientPassword,
PostalCode = s.Patient.PostalCode,
Telephone = s.Patient.Telephone,
CustomerOrgName = EntityHelper.GetCustomerOrgNameNoSql(customerOrgList, s.CustomerOrgId),
CustomerOrgParentId = EntityHelper.GetParentNoSql(customerOrgList, s.CustomerOrgId),
CustomerOrgParentName = EntityHelper.GetCustomerOrgParentNameNoSql(customerOrgList, s.CustomerOrgId)
}).ToList();
return new PagedResultDto(totalCount, entdto);
//return entdto;
//stopwatch.Stop();
//var s2 = stopwatch.ElapsedMilliseconds;
//return entdto.Take(100).ToList();
}
///
/// 获取档案登记信息 根据档案号或者条码号(档案号条件返回最新的一条)
///
///
///
public async Task GetPatientRegisterOrPatientAsync(GetPatientRegisterOrPatientDto input)
{
var entdto = new PatientRegisterOrNoDto();
#region MyRegion
var entlist = (await _repository.GetDbSetAsync()).Include(x => x.Patient).ToList();
if (input.SType == 1)
entlist = entlist.Where(m => m.PatientRegisterNo == input.PatientRegisterNo).ToList();
else
entlist = entlist.Where(m => m.Patient.PatientNo == input.PatientNo).OrderByDescending(o => o.MedicalTimes).ToList();
var ent = entlist.FirstOrDefault();
#endregion
if (ent != null)
{
var userList = await _userRepository.GetListAsync();
var customerOrgList = await _customerOrgRepository.GetListAsync();
entdto = new PatientRegisterOrNoDto
{
CreationTime = ent.CreationTime,
CreatorId = ent.CreatorId,
Id = ent.Id,
LastModificationTime = ent.LastModificationTime,
LastModifierId = ent.LastModifierId,
ThirdInfo = ent.ThirdInfo,
SummaryDoctor = ent.SummaryDoctor,
SummaryDate = ent.SummaryDate.ToString(),
SexId = ent.SexId,
Age = ent.Age,
AuditDate = ent.AuditDate.ToString(),
AuditDoctor = ent.AuditDoctor,
BirthDate = ent.BirthDate.ToString(),
CompleteFlag = ent.CompleteFlag,
CustomerOrgGroupId = ent.CustomerOrgGroupId,
CustomerOrgId = ent.CustomerOrgId,
CustomerOrgRegisterId = ent.CustomerOrgRegisterId,
GuidePrintTimes = ent.GuidePrintTimes,
InterposeMeasure = ent.InterposeMeasure,
IsAudit = ent.IsAudit,
IsLock = ent.IsLock,
IsMedicalStart = ent.IsMedicalStart,
IsNameHide = ent.IsNameHide,
IsPhoneFollow = ent.IsPhoneFollow,
IsRecoverGuide = ent.IsRecoverGuide,
IsUpload = ent.IsUpload,
IsVip = ent.IsVip,
JobCardNo = ent.JobCardNo,
JobPost = ent.JobPost,
JobTitle = ent.JobTitle,
MaritalStatusId = ent.MaritalStatusId,
MedicalCardNo = ent.MedicalCardNo,
MedicalConclusionId = ent.MedicalConclusionId,
MedicalPackageId = ent.MedicalPackageId,
MedicalStartDate = ent.MedicalStartDate.ToString(),
MedicalTimes = ent.MedicalTimes,
MedicalTypeId = ent.MedicalTypeId,
OrganizationUnitId = ent.OrganizationUnitId,
PatientId = ent.PatientId,
PatientName = ent.PatientName,
PatientRegisterNo = ent.PatientRegisterNo,
PersonnelTypeId = ent.PersonnelTypeId,
Photo = ent.Photo,
Remark = ent.Remark,
ReportPrintTimes = ent.ReportPrintTimes,
Salesman = ent.Salesman,
SexHormoneTermId = ent.SexHormoneTermId,
CreatorName = EntityHelper.GetUserNameNoSql(userList, ent.CreatorId),
LastModifierName = EntityHelper.GetUserNameNoSql(userList, ent.LastModifierId),
Address = ent.Patient.Address, //档案表信息
BirthPlaceId = ent.Patient.BirthPlaceId,
DisplayName = ent.Patient.DisplayName,
Email = ent.Patient.Email,
IdNo = ent.Patient.IdNo,
MobileTelephone = ent.Patient.MobileTelephone,
NationId = ent.Patient.NationId,
PatientNo = ent.Patient.PatientNo,
PatientPassword = ent.Patient.PatientPassword,
PostalCode = ent.Patient.PostalCode,
Telephone = ent.Patient.Telephone,
CustomerOrgName = EntityHelper.GetCustomerOrgNameNoSql(customerOrgList, ent.CustomerOrgId),
CustomerOrgParentId = EntityHelper.GetParentNoSql(customerOrgList, ent.CustomerOrgId),
CustomerOrgParentName = EntityHelper.GetCustomerOrgParentNameNoSql(customerOrgList, ent.CustomerOrgId)
};
}
else
{
entdto = null;
}
return entdto;
}
/////
///// 创建 登记档案 弃用
/////
/////
/////
//[RemoteService(false)]
//public override async Task CreateAsync(CreatePatientRegisterDto input)
//{
// var createEntity = ObjectMapper.Map(input);
// var createPatientEntity = ObjectMapper.Map(input);
// var entity = await _manager.CreateAsync(createEntity, createPatientEntity);
// var dto = ObjectMapper.Map(entity);
// return dto;
//}
///
/// 创建 登记档案 用这个 返回信息包含了档案跟登记信息
///
///
///
[HttpPost("api/patientregister/createreturninfo")]
public async Task CreateReturnInfoAsync(CreatePatientRegisterDto input)
{
PatientRegisterOrNoDto msg = new PatientRegisterOrNoDto();
var createEntity = ObjectMapper.Map(input);
var createPatientEntity = ObjectMapper.Map(input);
var entity = await _manager.CreateAsync(createEntity, createPatientEntity, input.IsMaxMedicalTimes);
if (entity != null)
{
msg = await GetPatientRegisterOrNo(entity.Id);
}
return msg;
}
///
/// 更新
///
/// 登记表ID
/// 更新参数(包含档案跟登记)
///
[HttpPost("api/patientregister/updatepatientregister")]
public async Task UpdatePatientRegisterAsync(Guid PatientRegisterId, UpdatePatientRegisterDto input)
{
var patientRegisterEnt = await Repository.GetAsync(PatientRegisterId);
var patientEnt = await _patientrepository.GetAsync(input.PatientId);
var patientRegisterSourceEntity = ObjectMapper.Map(input);
var patientSourceEntity = ObjectMapper.Map(input);
_patientManager.UpdateAsync(patientSourceEntity, patientEnt);
_manager.UpdateAsync(patientRegisterSourceEntity, patientRegisterEnt);
await _patientrepository.UpdateAsync(patientEnt);
patientRegisterEnt = await Repository.UpdateAsync(patientRegisterEnt);
return ObjectMapper.Map(patientRegisterEnt);
}
///
/// 修改人员照片
///
///
///
[HttpPost]
public async Task UpdatePhotoAsync(UpdatePhotoDto input)
{
var ent = await _repository.GetAsync(input.PatientRegisterId);
if (ent != null)
{
ent.Photo = input.Photo;
var newent = await _repository.UpdateAsync(ent);
return ObjectMapper.Map(newent);
}
else
{
return new PatientRegisterDto();
}
}
/////
///// 修改人员照片 二进制
/////
/////
/////
//[HttpPost]
//public async Task UpdatePhoto2Async(UpdatePhoto2Dto input)
//{
// var ent = await _repository.GetAsync(input.PatientRegisterId);
// if (ent != null)
// {
// ent.Photo = input.Photo;
// var newent = await _repository.UpdateAsync(ent);
// return ObjectMapper.Map(newent);
// }
// else
// {
// return new PatientRegisterDto();
// }
//}
//
///
/// 上传图片 手动拼接"http://81.70.217.145/"
///
///
public string UpLoadImg(UpdatePhotoDto input)
{
//_logger.LogInformation(input.Photo);
string imgurl = "UpLoad/" + input.PatientRegisterId;
var isupload = ImageHelper.Base64StrToImage(input.Photo, imgurl);
if (!string.IsNullOrEmpty(isupload))
return isupload;
else
return "";
}
///
/// 删除
///
///
///
public override async Task DeleteAsync(Guid id)
{
await _manager.CheckAndDeleteAsync(id);
}
///
/// 批量删除
///
///
///
[HttpPost]
public async Task DeleteManyAsync(DeletePatientRegisterManyDto input)
{
if (input.PatientRegisterIds.Count > 0)
{
var entlist = await _repository.GetListAsync(m => input.PatientRegisterIds.Contains(m.Id));
if (entlist.Count > 0)
{
foreach (var ent in entlist)
{
await _manager.CheckAndDeleteAsync(ent.Id);
}
}
}
else
{
throw new UserFriendlyException($"无可删除数据");
}
}
///
/// 人员签到 批量
///
/// 登记表ID集合
///
[HttpPost("api/app/patientregister/updatesigninmany")]
public async Task
> UpdateSignInManyAsync(List PatientRegisterIds)
{
List msg = new List();
if (!PatientRegisterIds.Any())
throw new UserFriendlyException($"请求参数有误");
foreach (var PatientRegisterId in PatientRegisterIds)
{
var entity = await Repository.FindAsync(f => f.Id == PatientRegisterId && f.IsMedicalStart != 'Y');
if (entity != null)
{
entity.IsMedicalStart = 'Y';
entity.MedicalStartDate = DateOnly.FromDateTime(DateTime.Now);
var newentity = await Repository.UpdateAsync(entity);
msg.Add(ObjectMapper.Map(newentity));
}
}
return msg;
}
///
/// 批量回收表格,暂时不加是否签到跟是否做完体检的判断
///
///
///
[HttpPost("api/app/patientregister/updaterecoverguidemany")]
public async Task> UpdateRecoverGuideManyAsync(List PatientRegisterIds)
{
List msg = new List();
if (!PatientRegisterIds.Any())
throw new UserFriendlyException($"请求参数有误");
foreach (var PatientRegisterId in PatientRegisterIds)
{
var newentity = await _manager.UpdateRecoverGuideAsync(PatientRegisterId);
msg.Add(ObjectMapper.Map(newentity));
}
return msg;
}
/////
///// 人员签到
/////
///// 登记表ID
/////
//public async Task UpdateSignIn(Guid PatientRegisterId)
//{
// var entity = await Repository.GetAsync(PatientRegisterId);
// if (entity == null)
// {
// throw new UserFriendlyException($"最后一次体检还未结束,不能新开,请结束最后一次体检");
// }
// else
// {
// entity.IsMedicalStart = 'N';
// entity.MedicalStartDate = DateOnly.FromDateTime(DateTime.Now);
// var newentity = await Repository.UpdateAsync(entity);
// return ObjectMapper.Map(newentity);
// }
//}
/////
///// 回收表格,暂时不加是否签到跟是否做完体检的判断
/////
/////
/////
//public async Task UpdateRecoverGuideAsync(Guid PatientRegisterId)
//{
// var entity = await _manager.UpdateRecoverGuideAsync(PatientRegisterId);
// return ObjectMapper.Map(entity);
//}
///
/// 修改人员锁定状态
///
/// 人员登记ID
/// 是否锁住(Y N)
///
public async Task UpdatePatientRegisterIsLockAsync(Guid PatientRegisterId, char IsLock)
{
PatientRegisterDto msg = new PatientRegisterDto();
var ent = await _repository.GetAsync(PatientRegisterId);
if (ent != null)
{
ent.IsLock = IsLock;
var newent = await _repository.UpdateAsync(ent);
msg = ObjectMapper.Map(newent);
}
return msg;
}
///
/// 更改总检审核医生信息(保存时,医生跟日期不传时取默认登录的用户跟当前时间;取消时,如果不传就不更新医生跟日期,只更新状态)
///
///
///
[HttpPost("api/app/patientregister/updatepatientregisterauditordoctor")]
public async Task UpdatePatientRegisterAuditorDoctorAsync(UpdatePatientRegisterAuditorDoctorDto input)
{
if (input == null || input.PatientRegisterId == Guid.Empty)
{
throw new UserFriendlyException("请求参数有误");
}
var entity = await _repository.GetAsync(input.PatientRegisterId);
var entitydto = ObjectMapper.Map(input);
var newentity = await _manager.UpdatePatientRegisterAuditorDoctorAsync(entitydto, entity);
return ObjectMapper.Map(newentity);
}
///
/// 更改总检检查医生信息(保存时,医生跟日期不传时取默认登录的用户跟当前时间;取消时,如果不传就不更新医生跟日期,只更新状态)
///
///
///
[HttpPost("api/app/patientregister/updatepatientregistersummarydoctor")]
public async Task UpdatePatientRegisterSummaryDoctorAsync(UpdatePatientRegisterSummaryDoctorDto input)
{
if (input == null || input.PatientRegisterId == Guid.Empty)
{
throw new UserFriendlyException("请求参数有误");
}
var entity = await _repository.GetAsync(input.PatientRegisterId);
var entitydto = ObjectMapper.Map(input);
var newentity = await _manager.UpdatePatientRegisterSummaryDoctorAsync(entitydto, entity);
return ObjectMapper.Map(newentity);
}
///
/// 批量修改指引单打印次数 原有基础上加1
///
///
///
[HttpPost("api/app/patientregister/updatepatientregisterguideprinttimesmany")]
public async Task UpdatePatientRegisterGuidePrintTimesManyAsync(List Ids)
{
var entlist = await _repository.GetListAsync(m => Ids.Contains(m.Id));
entlist.ForEach(f => f.GuidePrintTimes = (f.GuidePrintTimes == null ? (short?)1 : (short?)(f.GuidePrintTimes + 1)));
}
///
/// 批量修改体检报告打印次数 原有基础上加1
///
///
///
[HttpPost("api/app/patientregister/updatepatientregisterreportprinttimesmany")]
public async Task UpdatePatientRegisterReportPrintTimesManyAsync(List Ids)
{
var entlist = await _repository.GetListAsync(m => Ids.Contains(m.Id));
entlist.ForEach(f => f.ReportPrintTimes = (f.ReportPrintTimes == null ? (short?)1 : (short?)(f.ReportPrintTimes + 1)));
}
///
/// 导入体检名单操作
///
///
///
[HttpPost("api/app/patientregister/createpatientregisterexcel")]
public async Task CreatePatientRegisterExcelAsync(CreatePatientRegisterExcelDto input)
{
ResultDto msg;
if (input != null)
{
//自动创建部门
#region 转换性别、出生地、婚姻状况、民族数据、单位分组、人员类别、体检类别、性激素期限
//转换性别ID
char? SexId = null;
if (!DateHelper.IsNullOrEmpty(input.SexName))
{
var SexEnt = await _sexRepository.FindAsync(m => m.DisplayName == input.SexName);
if (SexEnt != null)
{
SexId = SexEnt.Id;
}
else
{
return new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "性别不存在" };
}
}
//出生地
Guid? BirthPlaceId = null;
if (!DateHelper.IsNullOrEmpty(input.BirthPlaceName))
{
var BirthPlaceEnt = await _birthPlaceRepository.FindAsync(m => m.DisplayName == input.BirthPlaceName);
if (BirthPlaceEnt != null)
{
BirthPlaceId = BirthPlaceEnt.Id;
}
else
{
return new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "出生地不存在" };
}
}
//婚姻状况
char? MaritalStatusId = null;
if (!DateHelper.IsNullOrEmpty(input.MaritalStatusName))
{
var MaritalStatusEnt = await _maritalStatusRepository.FindAsync(m => m.DisplayName == input.MaritalStatusName);
if (MaritalStatusEnt != null)
{
MaritalStatusId = MaritalStatusEnt.Id;
}
else
{
return new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "婚姻状况不存在" };
}
}
//民族
string? NationId = null;
if (!DateHelper.IsNullOrEmpty(input.NationName))
{
var NationEnt = await _nationRepository.FindAsync(m => m.DisplayName == input.NationName);
if (NationEnt != null)
{
NationId = NationEnt.NationId;
}
else
{
return new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "民族不存在" };
}
}
//单位分组
Guid? CustomerOrgGroupId = null;
if (!DateHelper.IsNullOrEmpty(input.CustomerOrgGroupName))
{
var CustomerOrgGroupEnt = await _customerOrgGroupRepository.FindAsync(m => m.DisplayName == input.CustomerOrgGroupName);
if (CustomerOrgGroupEnt != null)
{
CustomerOrgGroupId = CustomerOrgGroupEnt.Id;
}
else
{
return new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "单位分组不存在" };
}
}
//体检类别
Guid? MedicalTypeId = null;
if (!DateHelper.IsNullOrEmpty(input.MedicalTypeName))
{
var MedicalTypeEnt = await _medicalTypeRepository.FindAsync(m => m.DisplayName == input.MedicalTypeName);
if (MedicalTypeEnt != null)
{
MedicalTypeId = MedicalTypeEnt.Id;
}
else
{
return new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "体检类别不存在" };
}
}
//人员类别
Guid? PersonnelTypeId = null;
if (!DateHelper.IsNullOrEmpty(input.PersonnelTypeName))
{
var PersonnelTypeEnt = await _personnelTypeRepository.FindAsync(m => m.DisplayName == input.PersonnelTypeName);
if (PersonnelTypeEnt != null)
{
PersonnelTypeId = PersonnelTypeEnt.Id;
}
else
{
return new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "人员类别不存在" };
}
}
//性激素期限
Guid? SexHormoneTermId = null;
if (!DateHelper.IsNullOrEmpty(input.SexHormoneTermName))
{
var SexHormoneTermEnt = await _sexHormoneTermRepository.FindAsync(m => m.DisplayName == input.SexHormoneTermName);
if (SexHormoneTermEnt != null)
{
SexHormoneTermId = SexHormoneTermEnt.Id;
}
else
{
return new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "性激素期限不存在" };
}
}
//支付方式
string? PayModeId = null;
if (!DateHelper.IsNullOrEmpty(input.PayTypeFlag))
{
var PayModeEnt = await _payModeRepository.FindAsync(m => m.DisplayName == input.PayTypeFlag);
if (PayModeEnt != null)
{
PayModeId = PayModeEnt.Id;
}
else
{
return new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "支付方式不存在" };
}
}
#endregion
Guid PatientId = Guid.Empty;
#region 判断重名逻辑 先不判断 直接生成新的
#endregion
#region 生成档案信息
var createPatientEntity = new Patient
{
Address = input.Address,
BirthDate = PageHelper.ConvertDate(input.BirthDate),
Telephone = input.Telephone,
SexId = SexId,
BirthPlaceId = BirthPlaceId,
DisplayName = input.PatientName,
IdNo = input.IdNo,
Email = input.Email,
MaritalStatusId = MaritalStatusId,
MobileTelephone = input.MobileTelephone,
NationId = NationId,
// PatientNo = input.PatientNo,
PatientPassword = "",
PostalCode = input.PostalCode
};
if (input.IsAutoCreatePatientNo == 'Y')
{
//根据工卡号生成档案号
if (DateHelper.IsNullOrEmpty(input.JobCardNo))
{
return new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "工卡号不能为空" };
}
else
{
if (input.JobCardNo.Trim().Length >= input.CardStartNum + input.CardLength)
{
string PatientNo = input.JobCardNo.Trim().Substring(input.CardStartNum, input.CardLength); //截取工卡号做档案号
createPatientEntity.PatientNo = PatientNo;
var PatientEnt_New = await _patientrepository.InsertAsync(createPatientEntity, true);
if (PatientEnt_New != null)
PatientId = PatientEnt_New.Id;
}
else
{
return new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "工卡号长度不够" };
}
}
}
else
{
var PatientEnt_New = await _patientManager.CreateAsync(input.OrganizationUnitId.Value, createPatientEntity);
if (PatientEnt_New != null)
PatientId = PatientEnt_New.Id;
}
#endregion
#region 部门判断 需要生成的进行生成,更新单位ID
//_customerOrgRepository
if (!DateHelper.IsNullOrEmpty(input.DepartmentName))
{
var departmentent = await _customerOrgRepository.FindAsync(m => m.ParentId == input.CustomerOrgId && m.DisplayName == input.DepartmentName); //当前单位下一级
if (departmentent != null)
{
input.CustomerOrgId = departmentent.Id; //找到部门,单位ID为下级的部门ID
}
else
{
if (input.IsAutoCreateDepartment == 'Y')
{
var parentCustomerOrgEnt = await _customerOrgRepository.FindAsync(m => m.Id == input.CustomerOrgId); //当前单位下一级
if (parentCustomerOrgEnt != null)
{
var customerOrg_Insert = new CustomerOrg
{
Accounts = parentCustomerOrgEnt.Accounts,
Address = parentCustomerOrgEnt.Address,
Bank = parentCustomerOrgEnt.Bank,
DisplayName = input.DepartmentName,
Fax = parentCustomerOrgEnt.Fax,
InvoiceName = parentCustomerOrgEnt.InvoiceName,
IsActive = parentCustomerOrgEnt.IsActive,
IsLock = parentCustomerOrgEnt.IsLock,
OrganizationUnitId = parentCustomerOrgEnt.OrganizationUnitId,
//DisplayOrder = parentCustomerOrgEnt.DisplayOrder,
OrgTypeId = parentCustomerOrgEnt.OrgTypeId,
ParentId = parentCustomerOrgEnt.ParentId,
// PathCode = parentCustomerOrgEnt.PathCode,
PostalCode = parentCustomerOrgEnt.PostalCode,
Remark = parentCustomerOrgEnt.Remark,
ShortName = parentCustomerOrgEnt.ShortName,
// SimpleCode = parentCustomerOrgEnt.SimpleCode,
Telephone = parentCustomerOrgEnt.Telephone
};
var DepartmentEnt = await _customerOrgManager.CreateAsync(customerOrg_Insert);
var DepartmentReturn = await _customerOrgRepository.InsertAsync(DepartmentEnt, true);
if (DepartmentReturn != null)
{
input.CustomerOrgId = DepartmentReturn.Id; //单位ID转为 生成的部门ID
}
}
}
}
}
#endregion
#region 获取单位体检次数 根据单位ID 转换为一级单位ID
Guid CustomerOrgParentId = EntityHelper.GetParentNoSql(await _customerOrgRepository.GetListAsync(), input.CustomerOrgId); //一级单位ID
Guid CustomerOrgRegisterId = Guid.Empty; //最新单位次数ID
if (CustomerOrgParentId != Guid.Empty)
{
var customerOrgRegisterEnt = await _customerOrgRegisterManager.GetMaxAsync(CustomerOrgParentId);
if (customerOrgRegisterEnt != null)
CustomerOrgRegisterId = customerOrgRegisterEnt.Id;
}
#endregion
var createPatientRegisterEntity = new PatientRegister
{
Age = input.Age,
AuditDate = PageHelper.ConvertDate(input.AuditDate),
AuditDoctor = input.AuditDoctor,
BirthDate = PageHelper.ConvertDate(input.BirthDate),
CompleteFlag = input.CompleteFlag,
CustomerOrgGroupId = CustomerOrgGroupId,
CustomerOrgId = input.CustomerOrgId,
CustomerOrgRegisterId = CustomerOrgRegisterId,
GuidePrintTimes = input.GuidePrintTimes,
InterposeMeasure = input.InterposeMeasure,
IsAudit = input.IsAudit,
IsLock = input.IsLock,
IsMedicalStart = input.IsMedicalStart,
IsNameHide = input.IsNameHide,
IsPhoneFollow = input.IsPhoneFollow,
IsRecoverGuide = input.IsRecoverGuide,
IsUpload = input.IsUpload,
IsVip = input.IsVip,
JobCardNo = input.JobCardNo,
JobPost = input.JobPost,
JobTitle = input.JobTitle,
MaritalStatusId = MaritalStatusId,
MedicalCardNo = input.MedicalCardNo,
MedicalConclusionId = input.MedicalConclusionId,
MedicalPackageId = null,
MedicalStartDate = PageHelper.ConvertDate(input.MedicalStartDate),
MedicalTimes = 1,
MedicalTypeId = MedicalTypeId,
OrganizationUnitId = input.OrganizationUnitId,
PatientId = PatientId,
PatientName = input.PatientName,
PatientRegisterNo = await _patientRegisterManager.CreatePatientRegisterNo(input.OrganizationUnitId.Value),
PersonnelTypeId = PersonnelTypeId,
Photo = input.Photo,
Remark = input.Remark,
ReportPrintTimes = input.ReportPrintTimes,
Salesman = input.Salesman,
SexHormoneTermId = SexHormoneTermId,
SexId = SexId,
SummaryDate = PageHelper.ConvertDate(input.SummaryDate),
SummaryDoctor = input.SummaryDoctor,
ThirdInfo = input.ThirdInfo
};
var patientRegisterEntity_New = await _repository.InsertAsync(createPatientRegisterEntity, true);
if (patientRegisterEntity_New != null)
{
#region 导入registerasbitem相关数据
//生成registerasbitem数据 根据登记Id和单位分组Id
var customerOrgGroupDetailList = (await _customerOrgGroupDetailRepository.GetDbSetAsync()).Include(x => x.Asbitem)
.Where(m => m.CustomerOrgGroupId == CustomerOrgGroupId)
.Select(s => new RegisterAsbitem
{
Amount = 1,
AsbitemId = s.AsbitemId,
ChargePrice = s.Price,
GroupPackageId = CustomerOrgGroupId,
IsCharge = 'N',
PatientRegisterId = patientRegisterEntity_New.Id,
PayTypeFlag = PayModeId,
StandardPrice = s.Asbitem.Price
}).ToList();
foreach (var item in customerOrgGroupDetailList)
{
await _registerAsbitemManager.CreateAsync(input.OrganizationUnitId.Value, item, true);
}
#endregion
msg = new ResultDto { code = 1, msg = "[数据:" + input.PatientName + "]=>" + "导入成功" };
}
else
{
msg = new ResultDto { code = 1, msg = "[数据:" + input.PatientName + "]=>" + "导入失败" };
}
}
else
{
msg = new ResultDto { code = -1, msg = "[数据:" + input.PatientName + "]=>" + "请求参数有误" };
}
return msg;
}
#region 调整分组
///
/// 调整体检人员分组
///
///
[HttpPost("api/app/patientregister/updatepatientregistercustomerorggroup")]
public async Task UpdatePatientRegisterCustomerOrgGroupAsync(UpdatePatientRegisterCustomerOrgGroupDto input)
{
//当前人员信息
var patientRegisterEnt = (await _repository.GetDbSetAsync())
.Include(x => x.RegisterAsbitems)
.ThenInclude(x => x.RegisterCheck)
.Where(m => m.Id == input.PatientRegisterId).FirstOrDefault();
if (patientRegisterEnt != null)
{
if (patientRegisterEnt.CustomerOrgId == null || patientRegisterEnt.CustomerOrgId == Guid.Empty)
{
throw new UserFriendlyException("个人体检不支持调整");
}
if (patientRegisterEnt.CompleteFlag == '3')
{
throw new UserFriendlyException("当前体检人员已完成总检");
}
if (patientRegisterEnt.CustomerOrgGroupId == input.CustomerOrgGroupId)
{
throw new UserFriendlyException("当前体检人员已在此分组");
}
//原有分组下的组合项目
//var oldGroupAsbitemList = await _customerOrgGroupDetailRepository.GetListAsync(m => m.CustomerOrgGroupId == patientRegisterEnt.CustomerOrgGroupId);
var oldGroupAsbitemList = (await _customerOrgGroupDetailRepository.GetDbSetAsync())
.Include(x => x.Asbitem)
.Where(m => m.CustomerOrgGroupId == patientRegisterEnt.CustomerOrgGroupId).ToList();
//需要调整的分组包含的组合项目
//var newGroupAsbitemList = await _customerOrgGroupDetailRepository.GetListAsync(m => m.CustomerOrgGroupId == input.CustomerOrgGroupId);
var newGroupAsbitemList = (await _customerOrgGroupDetailRepository.GetDbSetAsync())
.Include(x => x.Asbitem)
.Where(m => m.CustomerOrgGroupId == input.CustomerOrgGroupId).ToList();
var registerAsbitem = patientRegisterEnt.RegisterAsbitems; //当前登记的组合项目
if (registerAsbitem.Any())
{
//删除操作
List ReserveList = new List(); //保留项目
List DeleteList = new List(); //删除项目
foreach (var item in registerAsbitem)
{
//判断是否为已收费、已检、弃检
if (item.IsCharge == 'Y' || item.RegisterCheck.CompleteFlag != '0')
{
//保留
ReserveList.Add(item);
}
else
{
if (input.IsReserveAddAsbitem == 'Y')
{
//保留额外项目
if (oldGroupAsbitemList.Where(m => m.AsbitemId == item.AsbitemId).Count() == 0)
{
//额外项目
ReserveList.Add(item);
}
else
{
DeleteList.Add(item);
}
}
else
{
DeleteList.Add(item);
}
}
}
await _registerAsbitemRepository.DeleteManyAsync(DeleteList);
//遍历查询保留的项目是否存在新分组,如果存在,修改新分组的ID,然后list里面剔除项目
ReserveList.ForEach(reserveitem =>
{
var IsnewGroupAsbitem = newGroupAsbitemList.Find(m => m.AsbitemId == reserveitem.AsbitemId); //项目是否存在新分组内
if (IsnewGroupAsbitem != null)
{
//新分组内有需要保留的项目
reserveitem.GroupPackageId = input.CustomerOrgGroupId; //修改之前项目的分组ID
//从list里面删除新分组包含的组合项目
newGroupAsbitemList.Remove(IsnewGroupAsbitem);
}
else
{
reserveitem.GroupPackageId = null; //不包含,修改为null
}
});
await _registerAsbitemRepository.UpdateManyAsync(ReserveList); //修改保留项目的分组
}
if (newGroupAsbitemList.Any())
{
//需要处理的新分组下的数据 重复的已剔除
var newRegisterAsbitemList = newGroupAsbitemList.Select(s => new RegisterAsbitem
{
Amount = 1,
AsbitemId = s.AsbitemId,
ChargePrice = s.Price,
GroupPackageId = input.CustomerOrgGroupId,
IsCharge = 'N',
PatientRegisterId = input.PatientRegisterId,
PayTypeFlag = input.PayTypeFlag,
StandardPrice = s.Asbitem.Price
}).ToList();
foreach (var item in newRegisterAsbitemList)
{
await _registerAsbitemManager.CreateAsync(patientRegisterEnt.OrganizationUnitId.Value, item, true);
}
}
patientRegisterEnt.CustomerOrgGroupId = input.CustomerOrgGroupId;
await _repository.UpdateAsync(patientRegisterEnt);
}
else
{
throw new UserFriendlyException("人员不存在");
}
}
#endregion
#region 登记完返回的数据
private async Task GetPatientRegisterOrNo(Guid PatientRegisterId)
{
// var entold = await _repository.GetAsync(PatientRegisterId);
var ent = (await _repository.GetDbSetAsync()).Include(x => x.Patient).Where(m => m.Id == PatientRegisterId).FirstOrDefault();
// var entold = await _repository.FindAsync(m=>m.Id== PatientRegisterId);
var entdto = new PatientRegisterOrNoDto();
if (ent != null)
{
var userList = await _userRepository.GetListAsync();
entdto = new PatientRegisterOrNoDto
{
Age = ent.Age,
AuditDate = ent.AuditDate.ToString(),
Id = ent.Id,
AuditDoctor = ent.AuditDoctor,
BirthDate = ent.BirthDate.ToString(),
CompleteFlag = ent.CompleteFlag,
CreationTime = ent.CreationTime,
CreatorId = ent.CreatorId,
CustomerOrgGroupId = ent.CustomerOrgGroupId,
CustomerOrgId = ent.CustomerOrgId,
CustomerOrgRegisterId = ent.CustomerOrgRegisterId,
GuidePrintTimes = ent.GuidePrintTimes,
InterposeMeasure = ent.InterposeMeasure,
IsAudit = ent.IsAudit,
IsLock = ent.IsLock,
IsMedicalStart = ent.IsMedicalStart,
IsNameHide = ent.IsNameHide,
IsPhoneFollow = ent.IsPhoneFollow,
IsRecoverGuide = ent.IsRecoverGuide,
IsUpload = ent.IsUpload,
IsVip = ent.IsVip,
JobCardNo = ent.JobCardNo,
JobPost = ent.JobPost,
JobTitle = ent.JobTitle,
LastModificationTime = ent.LastModificationTime,
LastModifierId = ent.LastModifierId,
MaritalStatusId = ent.MaritalStatusId,
MedicalCardNo = ent.MedicalCardNo,
MedicalConclusionId = ent.MedicalConclusionId,
MedicalPackageId = ent.MedicalPackageId,
MedicalStartDate = ent.MedicalStartDate.ToString(),
MedicalTimes = ent.MedicalTimes,
MedicalTypeId = ent.MedicalTypeId,
OrganizationUnitId = ent.OrganizationUnitId,
PatientId = ent.PatientId,
PatientName = ent.PatientName,
PatientRegisterNo = ent.PatientRegisterNo,
PersonnelTypeId = ent.PersonnelTypeId,
Photo = ent.Photo,
Remark = ent.Remark,
ReportPrintTimes = ent.ReportPrintTimes,
Salesman = ent.Salesman,
SexHormoneTermId = ent.SexHormoneTermId,
SexId = ent.SexId,
SummaryDate = ent.SummaryDate.ToString(),
SummaryDoctor = ent.SummaryDoctor,
ThirdInfo = ent.ThirdInfo,
CreatorName = EntityHelper.GetUserNameNoSql(userList, ent.CreatorId),
LastModifierName = EntityHelper.GetUserNameNoSql(userList, ent.LastModifierId),
Address = ent.Patient.Address, //档案表信息
BirthPlaceId = ent.Patient.BirthPlaceId,
DisplayName = ent.Patient.DisplayName,
Email = ent.Patient.Email,
IdNo = ent.Patient.IdNo,
MobileTelephone = ent.Patient.MobileTelephone,
NationId = ent.Patient.NationId,
PatientNo = ent.Patient.PatientNo,
PatientPassword = ent.Patient.PatientPassword,
PostalCode = ent.Patient.PostalCode,
Telephone = ent.Patient.Telephone,
CustomerOrgName = "",
CustomerOrgParentName = ""
};
}
return entdto;
}
#endregion
#region 收费、退费、未收费
///
/// 收费
///
///
///
[HttpPost("api/app/patientregister/getpatientregisterchargelist")]
public async Task> GetPatientRegisterChargeListAsync(PatientRegisterChargeRequestDto input)
{
PatientRegisterChargeEfCoreDto patientRegisterChargeEfCoreDto = new PatientRegisterChargeEfCoreDto
{
EndDate = input.EndDate,
InvoiceNo = input.InvoiceNo,
PatientName = input.PatientName,
PatientNo = input.PatientNo,
PatientRegisterNo = input.PatientRegisterNo,
StartDate = input.StartDate
};
var patientRegisterChargeList = await _patientRegisterChargeRepository.GetPatientRegisterChargeListAsync(patientRegisterChargeEfCoreDto);
int totalCount = patientRegisterChargeList.Count;
patientRegisterChargeList = patientRegisterChargeList.Skip(input.SkipCount * input.MaxResultCount).Take(input.MaxResultCount).ToList();
return new PagedResultDto(totalCount, patientRegisterChargeList);
}
///
/// 未收费
///
///
///
[HttpPost("api/app/patientregister/getpatientregisternotchargedlist")]
public async Task> GetPatientRegisterNotChargedListAsync(PatientRegisterChargeRequestDto input)
{
PatientRegisterChargeEfCoreDto patientRegisterChargeEfCoreDto = new PatientRegisterChargeEfCoreDto
{
EndDate = input.EndDate,
InvoiceNo = input.InvoiceNo,
PatientName = input.PatientName,
PatientNo = input.PatientNo,
PatientRegisterNo = input.PatientRegisterNo,
StartDate = input.StartDate
};
var patientRegisterNotChargedList = await _patientRegisterChargeRepository.GetPatientRegisterNotChargedListAsync(patientRegisterChargeEfCoreDto);
int totalCount = patientRegisterNotChargedList.Count;
patientRegisterNotChargedList = patientRegisterNotChargedList.Skip(input.SkipCount * input.MaxResultCount).Take(input.MaxResultCount).ToList();
return new PagedResultDto(totalCount, patientRegisterNotChargedList);
}
///
/// 退费
///
///
///
[HttpPost("api/app/patientregister/getpatientregisterchargebacklist")]
public async Task> GetPatientRegisterChargeBackListAsync(PatientRegisterChargeRequestDto input)
{
PatientRegisterChargeEfCoreDto patientRegisterChargeEfCoreDto = new PatientRegisterChargeEfCoreDto
{
EndDate = input.EndDate,
InvoiceNo = input.InvoiceNo,
PatientName = input.PatientName,
PatientNo = input.PatientNo,
PatientRegisterNo = input.PatientRegisterNo,
StartDate = input.StartDate
};
var patientRegisterChargeBackList = await _patientRegisterChargeRepository.GetPatientRegisterChargeBackListAsync(patientRegisterChargeEfCoreDto);
int totalCount = patientRegisterChargeBackList.Count;
patientRegisterChargeBackList = patientRegisterChargeBackList.Skip(input.SkipCount * input.MaxResultCount).Take(input.MaxResultCount).ToList();
return new PagedResultDto(totalCount, patientRegisterChargeBackList);
}
#endregion
#region 查询体检人员项目情况
///
/// 查询体检人员的项目状况
///
///
[HttpGet("api/app/patientregister/getpatientregisteritemstatus")]
public async Task GetPatientRegisterItemStatusAsync(Guid PatientRegisterId)
{
//未检组合项目
var UnCheckedAsbitem = (await _registerAsbitemRepository.GetDbSetAsync())
.Include(x => x.Asbitem)
.Include(x => x.RegisterCheck)
.Where(m => m.PatientRegisterId == PatientRegisterId && m.RegisterCheck.CompleteFlag == '0').OrderBy(o => o.Asbitem.DisplayOrder).Select(s => s.Asbitem.DisplayName).ToList();
//弃检检组合项目
var GiveUpAsbitem = (await _registerAsbitemRepository.GetDbSetAsync())
.Include(x => x.Asbitem)
.Include(x => x.RegisterCheck)
.Where(m => m.PatientRegisterId == PatientRegisterId && m.RegisterCheck.CompleteFlag == '2').OrderBy(o => o.Asbitem.DisplayOrder).Select(s => s.Asbitem.DisplayName).ToList();
//组合项目已检,项目无明细的项目
var registerAsbItemQueryable = await _registerAsbitemRepository.GetQueryableAsync();
var registerCheckQueryable = await _registerCheckRepository.GetQueryableAsync();
var registerCheckItemQueryable = await _registerCheckItemRepository.GetQueryableAsync();
var itemQueryable = await _itemRepository.GetQueryableAsync();
var CheckedNullValueItem = (from a in registerCheckItemQueryable
join b in registerCheckQueryable on a.RegisterCheckId equals b.Id
join c in registerAsbItemQueryable on b.Id equals c.RegisterCheckId
join d in itemQueryable on a.ItemId equals d.Id into dd
from ad in dd.DefaultIfEmpty()
where (c.PatientRegisterId == PatientRegisterId && string.IsNullOrEmpty(a.Result) && b.CompleteFlag == '1')
orderby ad.DisplayOrder ascending
select new { ItemName = ad.DisplayName }).Select(s => s.ItemName).ToList();
//组合项目已检,项目弃检
var CheckedGiveUpItem = (from a in registerCheckItemQueryable
join b in registerCheckQueryable on a.RegisterCheckId equals b.Id
join c in registerAsbItemQueryable on b.Id equals c.RegisterCheckId
join d in itemQueryable on a.ItemId equals d.Id into dd
from ad in dd.DefaultIfEmpty()
where (c.PatientRegisterId == PatientRegisterId && b.CompleteFlag == '1' && !string.IsNullOrEmpty(a.Result) && a.Result.Contains("放弃检查"))
orderby ad.DisplayOrder ascending
select new { ItemName = ad.DisplayName }).Select(s => s.ItemName).ToList();
var entdto = new GetPatientRegisterItemStatusDto
{
GiveUpAsbitem = GiveUpAsbitem,
CheckedGiveUpItem = CheckedGiveUpItem,
CheckedNullValueItem = CheckedNullValueItem,
UnCheckedAsbitem = UnCheckedAsbitem
};
return entdto;
}
#endregion
}
}