public void Handle(CTStatusNotification domainEvent) { _repository.UpdateStatus(domainEvent.ExtractId, domainEvent.Status, domainEvent.Stats, domainEvent.StatusInfo, true); if (domainEvent.UpdatePatient) { var patientStats = _extractRepository.GetSent(domainEvent.PatientExtractId); _repository.UpdateStatus(domainEvent.PatientExtractId, domainEvent.Status, patientStats, "", true); } }
public ExtractHistory HasStarted(Guid extractId) { var history = _extractHistoryRepository.GetLatest(extractId); if (null == history) { _extractHistoryRepository.UpdateStatus(extractId, ExtractStatus.Idle); return(_extractHistoryRepository.GetLatest(extractId)); } return(history); }
public void Handle(HtsStatusNotification domainEvent) { _repository.UpdateStatus(domainEvent.ExtractId, domainEvent.Status, domainEvent.Stats, domainEvent.StatusInfo, true); }
public async Task <IActionResult> Send([FromBody] SendPackageDTO packageDTO) { if (!packageDTO.IsValid()) { return(BadRequest()); } try { if (packageDTO.Docket.IsSameAs("PSMART")) { //check if sending var extractHistory = _psmartExtractService.HasStarted(packageDTO.ExtractId.Value, ExtractStatus.Sending, ExtractStatus.Sent); if (null != extractHistory && extractHistory.IsSending()) { //prevent sending var eventHistory = _psmartExtractService.GetStatus(packageDTO.ExtractId.Value); if (null != eventHistory) { return(Ok(new { IsComplete = false, IsSending = true, eEvent = eventHistory })); } } var psmartdata = _psmartStageRepository.GetAll().ToList(); if (psmartdata.Count > 0) { var psmartDTO = psmartdata.Select(x => new SmartMessage { Eid = x.EId, Id = x.Uuid, PayLoad = x.Shr }).ToList() .ToList(); var bag = new SmartMessageBag(psmartDTO); _extractHistoryRepository.UpdateStatus(packageDTO.ExtractId.Value, ExtractStatus.Sending); var response = await _psmartSendService.SendAsync(packageDTO, bag); if (null != response) { if (response.IsValid()) { // update sent _extractHistoryRepository.UpdateStatus(packageDTO.ExtractId.Value, ExtractStatus.Sent, bag.Message.Count); _psmartExtractService.Complete(packageDTO.ExtractId.Value); _psmartStageRepository.UpdateStatus(bag.Message.Select(x => x.Eid), response.IsValid(), response.RequestId); var history = _psmartExtractService.GetStatus(packageDTO.ExtractId.Value); if (null != history) { return(Ok(new { IsComplete = true, IsSending = false, eEvent = history })); } return(Ok(response)); } } } } return(BadRequest()); } catch (Exception e) { var msg = $"Error loading {nameof(Extract)}(s)"; Log.Error(msg); Log.Error($"{e}"); return(StatusCode(500, msg)); } }