Esempio 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
        }
Esempio 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
        }
Esempio n. 3
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);
        }