diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs index f0a39509..4af2079a 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs @@ -65,7 +65,7 @@ namespace BMA.EHR.Application.Repositories.Commands #region " List Receiver " - private async Task> GetReceiverForByCommndTypeAsync(Command command) + public async Task> GetReceiverForByCommndTypeAsync(Command command) { var result = new List(); @@ -708,7 +708,7 @@ namespace BMA.EHR.Application.Repositories.Commands .ToListAsync(); // 2. Query - var appointPeople = await _dbContext.Set() + var appointPeople = await _dbContext.Set() .Include(x => x.Profile) .ThenInclude(x => x.Prefix) //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) @@ -1607,33 +1607,34 @@ namespace BMA.EHR.Application.Repositories.Commands if (command == null) throw new Exception(GlobalMessages.CommandNotFound); - var appointPeople = await _dbContext.Set() - .Include(x => x.Prefix) - .Include(x => x.OrganizationPosition) - .ThenInclude(x => x!.Organization) - //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) - .Where(x => selected.Contains(x.Id)) - .OrderBy(x => x.ExamNumber) - .ToListAsync(); + var ap = (await GetReceiverForByCommndTypeAsync(command)).Where(x => selected.Contains(x.RefPlacementProfileId!.Value)); + + //var appointPeople = await _dbContext.Set() + // .Include(x => x.Prefix) + // .Include(x => x.OrganizationPosition) + // .ThenInclude(x => x!.Organization) + // //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) + // .Where(x => selected.Contains(x.Id)) + // .OrderBy(x => x.ExamNumber) + // .ToListAsync(); _dbContext.Set().RemoveRange(command.Receivers); await _dbContext.SaveChangesAsync(); var seq = 1; - foreach (var item in appointPeople) + foreach (var item in ap) { - var receiver = new CommandReceiver { Sequence = seq, CitizenId = item.CitizenId!, - Prefix = item.Prefix!.Name, - FirstName = item.Firstname!, - LastName = item.Lastname!, - RefPlacementProfileId = item.Id + Prefix = item.Prefix, + FirstName = item.FirstName!, + LastName = item.LastName!, + RefPlacementProfileId = item.RefPlacementProfileId }; - seq++; + seq++; command.Receivers.Add(receiver); } await _dbContext.SaveChangesAsync(); diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index 88b79589..9993216d 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -393,6 +393,9 @@ namespace BMA.EHR.Command.Service.Controllers conclusionFireDate = data.ConclusionFireDate, conclusionFireResolution = data.ConclusionFireResolution, + OrderStatusValue = data.CommandStatusId, + OrderStatusName = data.CommandStatus.Name, + }; return Success(result);