Exemple #1
0
        private async Task FetchNurseStatusAsync(IFusionProcess process, CancellationToken token)
        {
            IEnumerable <PatientStatus> statusses;

            try
            {
                statusses = (await process.NurseStatusAsync("*", token)).Stale();

                foreach (var status in statusses)
                {
                    logService.Debug($"Patient: '{status.Id}' received for : '{process.FusionId}' with status '{status.Type}'.");
                }
            }
            catch (Exception ex)
            {
                throw new ScheduleException(ScheduleException.NurseStatusFailure, process.FusionId, ex);
            }

            var allowNoPatients = configStore.Value.Fuse.AllowFusionsWithoutPatients;

            if (!allowNoPatients &&
                !statusses.Any())
            {
                var builder = new StringBuilder();
                builder.AppendLine(ScheduleException.NurseUnhealthyPatientsPrefix);
                builder.AppendLine();
                builder.AppendLine("No patients created for this fusion.");

                throw new ScheduleException(builder.ToString(), process.FusionId);
            }

            var unhealthyStatusses = statusses
                                     .Where(_ => _.Type == PatientStatusType.Red)
                                     .ToArray();

            if (unhealthyStatusses.Any())
            {
                var builder = new StringBuilder();
                builder.AppendLine(ScheduleException.NurseUnhealthyPatientsPrefix);

                foreach (var status in unhealthyStatusses)
                {
                    builder.AppendLine();
                    builder.AppendLine($"Id: {status.Id}");
                    builder.AppendLine($"Status: {status.Type.ToString()}");
                    builder.AppendLine($"Reason: {status.Reason}");
                }

                throw new ScheduleException(builder.ToString(), process.FusionId);
            }
        }
Exemple #2
0
        private async Task <FusionStatus> GetFusionStatusAsync(
            IFusionProcess process,
            string patientPattern,
            CancellationToken token)
        {
            try
            {
                var patients = await process.NurseStatusAsync(patientPattern, token);

                return(new FusionStatus(process.FusionId, patients));
            }
            catch (Exception ex)
            {
                return(new FusionStatus(process.FusionId, new[] {
                    new PatientStatus(unknownPatientId, PatientStatusType.Red, ex.ToString())
                }));
            }
        }