Exemplo n.º 1
0
        private void CreateTestDataForDebug()
        {
#if DEBUG
            // This is some test data to assist in the UI Designer
            Expecting.Add(new PmsAppointment()
            {
                PatientName = "Postlethwaite, Brian", PatientMobilePhone = "0423857505", ArrivalStatus = Hl7.Fhir.Model.Appointment.AppointmentStatus.Pending, AppointmentStartTime = DateTime.Parse("9:45am"), PractitionerName = "Dr Nathan Pinskier"
            });
            Expecting.Add(new PmsAppointment()
            {
                PatientName = "Esler, Brett", PatientMobilePhone = "0423083847", ArrivalStatus = Hl7.Fhir.Model.Appointment.AppointmentStatus.Pending, AppointmentStartTime = DateTime.Parse("10:00am"), PractitionerName = "Dr Nathan Pinskier"
            });
            Waiting.Add(new PmsAppointment()
            {
                PatientName = "Grieve, Grahame", PatientMobilePhone = "0423083847", ArrivalStatus = Hl7.Fhir.Model.Appointment.AppointmentStatus.Arrived, AppointmentStartTime = DateTime.Parse("10:00am"), PractitionerName = "Dr Nathan Pinskier"
            });
            RoomMappings.Add(new DoctorRoomLabelMapping()
            {
                PractitionerFhirID  = "1",
                PractitionerName    = "Dr Nathan",
                LocationName        = "Room 1",
                LocationDescription = "Proceed through the main lobby and its the 3rd door on the right"
            });
            RoomMappings.Add(new DoctorRoomLabelMapping()
            {
                PractitionerFhirID  = "1",
                PractitionerName    = "Dr Smith",
                LocationName        = "Room 2",
                LocationDescription = "Proceed through the main lobby and its the 2nd door on the right"
            });
#endif
        }
Exemplo n.º 2
0
        public Model()
        {
#if DEBUG
            // This is some test data to assist in the UI Designer
            Expecting.Add(new PmsAppointment()
            {
                ArrivalTime = "10:35am", PatientName = "Postlethwaite, Brian", PatientMobilePhone = "0423857505", ArrivalStatus = "Pending", AppointmentStartTime = "9:45am", PractitionerName = "Dr Nathan Pinskier"
            });
            Expecting.Add(new PmsAppointment()
            {
                ArrivalTime = "10:35am", PatientName = "Esler, Brett", PatientMobilePhone = "0423083847", ArrivalStatus = "Pending", AppointmentStartTime = "10:00am", PractitionerName = "Dr Nathan Pinskier"
            });
            Waiting.Add(new PmsAppointment()
            {
                ArrivalTime = "10:35am", PatientName = "Grieve, Grahame", PatientMobilePhone = "0423083847", ArrivalStatus = "Arrived", AppointmentStartTime = "10:00am", PractitionerName = "Dr Nathan Pinskier"
            });
            RoomMappings.Add(new DoctorRoomLabelMappings()
            {
                PractitionerFhirID  = "1",
                PractitionerName    = "Dr Nathan",
                LocationName        = "Room 1",
                LocationDescription = "Proceed through the main lobby and its the 3rd door on the right"
            });
#endif
        }
Exemplo n.º 3
0
        void Arrive()

        {
            var customers = Enumerable.Range(0, Empirical.Sample(DefaultRS, Config.ArrivalGroupSizeProbs)).Select(i => new Customer()).ToList();

            foreach (var c in customers)
            {
                c.Id          = ++CustomersCount;
                c.ArrivalTime = ClockTime;
            }
            AllCustomers.AddRange(customers);
            Waiting.Add(customers);
            Start();
            Log("{0} arrived.", customers.Count);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Распределение задач по коллекциям
 /// </summary>
 private void Distribution()
 {
     foreach (PlannerTask task in Queue)
     {
         if (task.TaskStatus == State.Waiting)
         {
             Waiting.Add(task);
         }
         if (task.TaskStatus == State.InProgress)
         {
             InProgress.Add(task);
         }
         if (task.TaskStatus == State.Perfomed)
         {
             Perfomed.Add(task);
         }
     }
 }
Exemplo n.º 5
0
        public async Task Initialize(Dispatcher dispatcher)
        {
            // read the settings from storage
            Settings.CopyFrom(await Storage.LoadSettings());
            if (Settings.SystemIdentifier == Guid.Empty)
            {
                // this only occurs when the system hasn't had one allocated
                // so we can create a new one, then save the settings.
                // (this will force an empty setting file with the System Identifier if needed)
                Settings.AllocateNewSystemIdentifier();
                await Storage.SaveSettings(Settings);
            }

            // read the room mappings from storage
            RoomMappings.Clear();
            foreach (var map in await Storage.LoadRoomMappings())
            {
                RoomMappings.Add(map);
            }

            Templates.Clear();
            foreach (var template in await Storage.LoadTemplates())
            {
                Templates.Add(template);
            }
            AddMissingTemplates();

            // reload any unmatched messages
            var messages = await Storage.LoadUnprocessableMessages(DisplayingDate);

            foreach (var item in messages)
            {
                UnprocessableMessages.Add(item);
            }

            PmsSimulator.Initialize(Storage);
            if (!IsSimulation)
            {
                FhirApptReader = new FhirAppointmentReader(FhirAppointmentReader.GetServerConnection);
                SmsProcessor.Initialize(Settings);
            }
            logger.Log(1, "Start up");
            if (!String.IsNullOrEmpty(Settings.AdministratorPhone))
            {
                logger.Log(1, "Send SMS to " + Settings.AdministratorPhone);
                try
                {
                    SmsProcessor.SendMessage(new SmsMessage(Settings.AdministratorPhone, "System is starting"));
                    if (!IsSimulation)
                    {
                        App.AdministratorPhone = Settings.AdministratorPhone;
                        App.SmsSender          = SmsProcessor;
                    }
                }
                catch (Exception ex)
                {
                    System.Windows.MessageBox.Show("Error sending message: " + ex.Message);
                }
            }

            // setup the background worker routines
            ReadSmsMessage = new BackgroundProcess(Settings, serverStatuses.IncomingSmsReader, dispatcher, async() =>
            {
                // Logic to run on this process
                // (called every settings.interval)
                StatusBarMessage            = $"Last read SMS messages at {DateTime.Now.ToLongTimeString()}";
                var engine                  = PrepareMessagingEngine();
                List <PmsAppointment> appts = new List <PmsAppointment>();
                appts.AddRange(Appointments);
                var messagesReceived = await engine.SmsSender.ReceiveMessages();
                serverStatuses.IncomingSmsReader.Use(messagesReceived.Count());
                engine.ProcessIncomingMessages(appts, messagesReceived);
            });

            ScanAppointments = new BackgroundProcess(Settings, serverStatuses.AppointmentScanner, dispatcher, async() =>
            {
                // Logic to run on this process
                // (called every settings.interval)
                var engine = PrepareMessagingEngine();
                List <PmsAppointment> appts = await FhirApptReader.SearchAppointments(this.DisplayingDate, RoomMappings, Storage);
                serverStatuses.Oridashi.Use(1);
                serverStatuses.AppointmentScanner.Use(engine.ProcessTodaysAppointments(appts));

                // Now update the UI once we've processed it all
                Expecting.Clear();
                Waiting.Clear();
                Appointments.Clear();
                foreach (var appt in appts)
                {
                    Appointments.Add(appt);
                    if (appt.ArrivalStatus == Hl7.Fhir.Model.Appointment.AppointmentStatus.Booked)
                    {
                        Expecting.Add(appt);
                    }
                    else if (appt.ArrivalStatus == Hl7.Fhir.Model.Appointment.AppointmentStatus.Arrived)
                    {
                        Waiting.Add(appt);
                    }
                }
            });

            ProcessUpcomingAppointments = new BackgroundProcess(Settings, serverStatuses.UpcomingAppointmentProcessor, dispatcher, async() =>
            {
                // Logic to run on this process
                // (called every settings.intervalUpcoming)
                var engine = PrepareMessagingEngine();
                List <PmsAppointment> appts = new List <PmsAppointment>();
                appts.AddRange(await FhirApptReader.SearchAppointments(this.DisplayingDate.AddDays(1), RoomMappings, Storage));
                appts.AddRange(await FhirApptReader.SearchAppointments(this.DisplayingDate.AddDays(2), RoomMappings, Storage));
                serverStatuses.Oridashi.Use(1);
                serverStatuses.UpcomingAppointmentProcessor.Use(engine.ProcessUpcomingAppointments(appts));
            }, true);
        }
Exemplo n.º 6
0
        public int AlphaBeta(Piece[][] board, int deept, int alpha, int beta, PieceColor self, PieceColor match)
        {
            if (deept == 0)
            {
                ++Count;
                //return GetBoardValueNew(board, self);
                //return GetBoardValueNew(board, self) - GetBoardValueNew(board, match);
                return((new Random()).Next(-100, 10000));
            }

            if (deept % 2 == 0)
            {
                //MAX
                for (var x = scanBegin.X; x < scanEnd.X; ++x)
                {
                    for (var y = scanBegin.Y; y < scanEnd.Y; ++y)
                    {
                        if (board[x][y].Color != PieceColor.None)
                        {
                            continue;
                        }

                        //尝试下子
                        board[x][y].Color = self;

                        var val = AlphaBeta(board, deept - 1, alpha, beta, self, match);
                        //取消下子
                        board[x][y].Color = PieceColor.None;

                        if (deept == 4 && val >= Max)
                        {
                            if (val > Max)
                            {
                                Max = val;
                                Waiting.Clear();
                            }
                            Waiting.Add(new Point(x, y));
                        }

                        if (val > alpha)
                        {
                            alpha = val;
                        }

                        if (alpha >= beta)
                        {
                            return(alpha);
                        }
                    }
                }

                return(alpha);
            }
            else
            {
                //MIN
                for (var x = scanBegin.X; x < scanEnd.X; ++x)
                {
                    for (var y = scanBegin.Y; y < scanEnd.Y; ++y)
                    {
                        if (board[x][y].Color != PieceColor.None)
                        {
                            continue;
                        }

                        //尝试下子
                        board[x][y].Color = match;

                        var val = AlphaBeta(board, deept - 1, alpha, beta, self, match);
                        //取消下子
                        board[x][y].Color = PieceColor.None;

                        if (val < beta)
                        {
                            beta = val;
                        }

                        if (alpha >= beta)
                        {
                            return(beta);
                        }
                    }
                }

                return(beta);
            }
        }