Esempio n. 1
0
        /// <summary>
        /// Validate Treatment room to make sure all required information is present
        /// A treatment room needs to have a unique name
        /// </summary>
        /// <param name="room"></param>
        /// <returns>true = treatment room information is valid; false = treatment room information is invalid</returns>
        public bool TreatmentRoomValidation(TreatmentRoom room)
        {
            // treatment room information can not be null
            if (room == null)
            {
                return(false);
            }

            // treatment room must have a name.
            if (string.IsNullOrEmpty(room.RoomName))
            {
                return(false);
            }

            // treamtent room must have a unique name.
            if (PatientSchedulerContext.TreatmentRooms != null)
            {
                return
                    (PatientSchedulerContext.TreatmentRooms.All(
                         treatmentRoom =>
                         CultureInfo.CurrentCulture.CompareInfo.Compare(treatmentRoom.RoomName,
                                                                        room.RoomName, CompareOptions.IgnoreCase) != 0));
            }

            return(true);
        }
    private void InputManager()
    {
        var ray = cam.ScreenPointToRay(Input.mousePosition);

        if (Input.GetMouseButtonDown(1))
        {
            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider.tag == "Untagged")
                {
                    selectionManager.DeselectCurrent();
                }

                if (hit.collider.tag == "NPC")
                {
                    WindowManager.Instance.ShowNPCData(hit.transform.GetComponent <NPCLink>().NPCObject.GetComponent <Patient>());
                }
            }
        }

        if (Input.GetMouseButtonDown(0))
        {
            if (Physics.Raycast(ray, out hit))
            {
                /*if (hit.transform.tag == "Untagged" && selectionManager.SelectedObject != null)
                 * {
                 *  selectionManager.DeselectCurrent();
                 * }*/

                if (/*hit.collider.gameObject.name == "[Radio]"*/ hit.collider.tag == "Radio")
                {
                    hit.collider.GetComponent <Radio>().Switch();
                }

                if (hit.collider.tag == "NPC")
                {
                    ;
                    selectionManager.Select(hit.collider.GetComponent <NPCLink>().NPCObject);
                    //Instantiate(clickEffect, hit.transform.position + Vector3.up, Quaternion.identity);
                }

                if (hit.transform.tag == "TreatmentRoom")
                {
                    TreatmentRoom selectedRoom = hit.collider.GetComponent <RoomLink>().Room;
                    if (selectionManager.SelectedObject != null && selectionManager.SelectedObject.GetComponent <Patient>() != null)
                    {
                        if (!selectedRoom.IsInUse)
                        {
                            selectionManager.SelectedObject.GetComponent <Patient>().npcComponent.SetPath(selectedRoom.roomEntry.position);
                        }
                        else
                        {
                            selectedRoom.HighlightDisplay();
                        }
                    }
                }
            }
        }
    }
        public void TestMethodPatientHasBreastCancerAndResourceIsTreatmentRoomWithSimpleCapabilitiesReturnsTrue()
        {
            var p    = new Patient("A Patient", PatientCondition.Cancer, ConditionTopography.Breast);
            var room = new TreatmentRoom("Simple Room", new TreatmentMachine("machine 1", TreatmentMachineCapabilities.Simple));

            var resourceRule = new TreatmentResourceRule();

            Assert.IsTrue(resourceRule.IsResourceValid(room, p));
        }
Esempio n. 4
0
 private Capability GetCapabilitiesOfARoom(TreatmentRoom room)
 {
     return(HospitalConfiguration.GetInstance()
            .TreatmentMachines
            .Where(tm => tm.Name == room.TreatmentMachine)
            .Select(rm => rm.Capability)
            .ToList()
            .First());
 }
Esempio n. 5
0
        public void InsertTreatmentRoom_InvalidMachine()
        {
            var room = new TreatmentRoom
            {
                Name = "Test",
                TreatmentMachineId = "Invalid"
            };

            _context.Add(room);
            Assert.Throws <DbUpdateException>(() => _context.SaveChanges());
        }
        private void ImportRooms(JsonDataFileImporterReader importer)
        {
            var rooms = importer.Rooms(_filePath);

            foreach (var room in rooms)
            {
                var r = new TreatmentRoom
                {
                    Name = room.Name,
                    TreatmentMachineId = room.TreatmentMachine
                };
                _context.Add(r);
            }
            _context.SaveChanges();
        }
        public Task <bool> Handle(RegisterTreatmentRoomCommand request, CancellationToken cancellationToken)
        {
            if (!request.IsValid())
            {
                NotifyValidationErrors(request);
                return(Task.FromResult(false));
            }

            var treatmentRoom = new TreatmentRoom(Guid.NewGuid(), request.TreatmentMachineId, request.Name);

            _treatmentRoomRepository.Add(treatmentRoom);

            if (Commit())
            {
                _mediator.RaiseEvent(new TreatmentRoomRegisteredEvent(treatmentRoom.Id, treatmentRoom.TreatmentMachineId, treatmentRoom.Name));
            }

            return(Task.FromResult(true));
        }
        /**
         * Adds a room to the provided practice.
         */
        private void addRoomToPractice(DentalPractice practice)
        {
            TreatmentRoom newTreatmentRoom;
            int           roomNo;

            try
            {
                roomNo = practice.getRooms().Count + 1;                         //Adds +1 to current room no.

                newTreatmentRoom = new TreatmentRoom(roomNo, practice, "", ""); //"", "" are for the dentist & nurse
                manageRoom(newTreatmentRoom);                                   //Runs manageRoom to set up new treatment room
                practice.getRooms().Add(newTreatmentRoom);                      //Adds the treatment room to practice.
                DataIO.saveAllRooms(practice);                                  //writes to file
            }
            catch (Exception e)
            {
                GeneralFunctions.errorHandler(e);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Schedule a consultation if all the validations satisfies the conditions.
        /// </summary>
        /// <param name="rooms"></param>
        /// <param name="doctors"></param>
        /// <param name="startDay"></param>
        /// <returns>Consultaion for a patient.</returns>
        private static Consultation ScheduleConsultation(List <TreatmentRoom> rooms, List <Doctor> doctors, int startDay)
        {
            for (int day = startDay; day < Calendar.NUM_DAYS; day++)
            {
                bool   isDoctorAvailable = false;
                Doctor availableDoctor   = new Doctor();
                foreach (Doctor doctor in doctors)
                {
                    if (doctor.calender.IsAvailable(day))
                    {
                        isDoctorAvailable = true;
                        availableDoctor   = doctor;
                        break;
                    }
                }

                bool          isRoomAvailable = false;
                TreatmentRoom availableRoom   = new TreatmentRoom();
                foreach (TreatmentRoom room in rooms)
                {
                    if (room.calender.IsAvailable(day))
                    {
                        isRoomAvailable = true;
                        availableRoom   = room;
                        break;
                    }
                }

                if (isRoomAvailable && isDoctorAvailable)
                {
                    Consultation consultation = new Consultation();
                    consultation.doctor           = availableDoctor;
                    consultation.room             = availableRoom;
                    consultation.ConsultationDate = DateTime.Now.AddDays(day);
                    consultation.RegistrationDate = DateTime.Now.AddDays(startDay - 1);
                    availableDoctor.calender.Book(day);
                    availableRoom.calender.Book(day);
                    return(consultation);
                }
            }
            throw new InvalidOperationException("No availability for appointment");
        }
        public Task <bool> Handle(ReserveTreatmentRoomCommand request, CancellationToken cancellationToken)
        {
            if (!request.IsValid())
            {
                NotifyValidationErrors(request);
                return(Task.FromResult(false));
            }

            var existingTreatmentRoom = _treatmentRoomRepository.GetById(request.Id);
            var treatmentRoom         = new TreatmentRoom(existingTreatmentRoom.Id, request.TreatmentMachineId,
                                                          existingTreatmentRoom.Name);

            _treatmentRoomRepository.Update(treatmentRoom);

            if (Commit())
            {
                _mediator.RaiseEvent(new TreatmentRoomReservedEvent(existingTreatmentRoom.Id, request.ReservationDay, existingTreatmentRoom.TreatmentMachineId));
            }

            return(Task.FromResult(true));
        }
        /**
         * Deletes a treatment room.
         */
        private void deleteRoom(TreatmentRoom room, bool singleRoom)
        {
            DentalPractice       parentPractice;
            List <TreatmentRoom> rooms;
            string roomPath;

            try
            {
                parentPractice = room.getPractice();                                                                                      //practice that room belongs to
                roomPath       = DataIO.practicePath + "\\" + parentPractice.getLocation() + "\\Rooms\\" + room.getRoomNumber() + ".txt"; //Find the file path to the room, to be deleted
                File.Delete(roomPath);                                                                                                    //Deletes the file
                rooms = parentPractice.getRooms();                                                                                        //Gets practice associated to room
                rooms.Remove(room);                                                                                                       //Remove the room from the practice.
                if (singleRoom)
                {
                    restructureRooms(parentPractice); //No point running this when all rooms are being removed but just in case.
                }
            }
            catch (Exception e)
            {
                GeneralFunctions.errorHandler(e);
            }
        }
        /// <summary>
        /// Create a consulation object
        /// </summary>
        /// <param name="patient"></param>
        /// <param name="doctor"></param>
        /// <param name="consulationDate"></param>
        /// <param name="registrationDate"></param>
        /// <param name="treatmentRoom"></param>
        /// <returns></returns>
        private static Consultation CreateConsultation(Patient patient, Doctor doctor, DateTime consulationDate, DateTime registrationDate, TreatmentRoom treatmentRoom)
        {
            var consultation = new Consultation
            {
                RegistrationDate = registrationDate,
                ConsultationDate = consulationDate,
                Patient          = patient,
                Doctor           = doctor,
                TreatmentRoom    = treatmentRoom,
            };

            return(consultation);
        }
        /**
         * Shows the interface to manage a room.
         */
        private void manageRoom(TreatmentRoom room)
        {
            string       response;
            bool         invalidResponse;
            Staff        userToCheck;
            DentistNurse userToAssign;

            try
            {
                invalidResponse = true;

                while (invalidResponse) // Prints all staff at practice.
                {
                    DataPrinting.printStaffAtPractice(room.getPractice());
                    Console.Write("Dentist to assign: (Enter nothing to skip)");
                    response = Console.ReadLine();
                    Console.Clear();

                    if (response != "")
                    {
                        if (DataSearching.userExists(response))                    //Validates the response
                        {
                            userToCheck = (Staff)DataSearching.findUser(response); //Find staff users with the given username response.
                            if (userToCheck is DentistNurse)
                            {
                                userToAssign = (DentistNurse)DataSearching.findUser(response); //Checks wether they are dentist or nurse and find them usign findUser method

                                if (userToAssign.getPractitionerType() != "Dentist")           //if not equal to dentist
                                {
                                    Console.WriteLine("Selected staff is not dentist.");
                                }
                                else
                                {
                                    room.setDentist(userToAssign); // sets the given room to the dentist user.
                                    invalidResponse = false;
                                }
                            }
                            else
                            {
                                Console.WriteLine("Selected staff is not dentist.");
                            }
                        }
                        else
                        {
                            Console.WriteLine("user does not exist.");
                        }
                    }
                    else
                    {
                        invalidResponse = false;
                    }
                }

                invalidResponse = true;

                while (invalidResponse) // Selecting the Nurse. works the same as Dentist
                {
                    DataPrinting.printStaffAtPractice(room.getPractice());
                    Console.Write("Nurse to assign: (Enter nothing to skip)");
                    response = Console.ReadLine();
                    Console.Clear();

                    if (response != "")
                    {
                        if (DataSearching.userExists(response))
                        {
                            userToCheck = (Staff)DataSearching.findUser(response);
                            if (userToCheck is DentistNurse)
                            {
                                userToAssign = (DentistNurse)DataSearching.findUser(response);

                                if (userToAssign.getPractitionerType() != "Nurse")
                                {
                                    Console.WriteLine("Selected staff is not nurse.");
                                }
                                else
                                {
                                    room.setNurse(userToAssign);
                                    invalidResponse = false;
                                }
                            }
                            else
                            {
                                Console.WriteLine("Selected staff is not nurse.");
                            }
                        }
                        else
                        {
                            Console.WriteLine("user does not exist.");
                        }
                    }
                    else
                    {
                        invalidResponse = false;
                    }
                }
            }
            catch (Exception e)
            {
                GeneralFunctions.errorHandler(e);
            }
        }
Esempio n. 14
0
 public abstract bool CanTreat(TreatmentRoom room);