Example #1
0
        static void TransferPatientToAnotherBed(List <Patient> patientList, List <Bed> bedList)
        {
            DisplayPatients(patientList, true);
            Console.Write("Enter patient ID number: ");
            string  pNo = Console.ReadLine();
            Patient p   = SearchPatient(patientList, pNo);

            if (p == null || p.Status != "Admitted")
            {
                return;
            }

            Stay s = p.Stay;

            DisplayAllBeds(bedList);
            Console.Write("Select Bed to transfer to: ");
            int newBNo = Convert.ToInt32(Console.ReadLine());

            //validation to keep int entered in check
            if (newBNo <= bedList.Count && newBNo > 0)
            {
                Bed b = bedList[newBNo - 1];

                Console.Write("Date of transfer [DD/MM/YYYY]: ");
                DateTime transferDate = Convert.ToDateTime(Console.ReadLine());
                //DateTime transferDate;
                //if (!DateTime.TryParse(Console.ReadLine(), out transferDate))
                //{
                //    Console.WriteLine("Invalid date. Please match the requested format.");
                //    return;
                //}

                b.Available = false;
                for (int i = 0; i < p.Stay.BedStayList.Count; i++)
                {
                    p.Stay.BedStayList[i].EndBedStay = transferDate;
                }
                BedStay transferBed = new BedStay(transferDate, b);


                if (b is ClassABed)
                {
                    Console.Write("Any accompanying guest? (Additional $100 per day) [Y/N]: ");
                    string accGuest = Console.ReadLine().ToUpper();
                    //ClassABed cab = (ClassABed)b;
                    ClassABed clab = new ClassABed(b.WardNo, b.BedNo, b.DailyRate, b.Available);
                    clab.AccompanyingPerson = CheckOption(accGuest);
                    transferBed             = new BedStay(transferDate, clab);
                }
                else if (b is ClassBBed)
                {
                    Console.Write("Do you want to upgrade to an Air-Conditioned variant? (Additional $50 per week) [Y/N]: ");
                    string ac = Console.ReadLine().ToUpper();
                    //ClassBBed cbb = (ClassBBed)b;
                    ClassBBed clbb = new ClassBBed(b.WardNo, b.BedNo, b.DailyRate, b.Available);
                    clbb.AirCon = CheckOption(ac);
                    transferBed = new BedStay(transferDate, clbb);
                }
                else if (b is ClassCBed)
                {
                    Console.Write("Do you want to rent a portable TV? (One-Time Cost of $30) [Y/N]: ");
                    string pTV = Console.ReadLine().ToUpper();
                    //ClassCBed ccb = (ClassCBed)b;
                    ClassCBed clcb = new ClassCBed(b.WardNo, b.BedNo, b.DailyRate, b.Available);
                    clcb.PortableTv = CheckOption(pTV);
                    transferBed     = new BedStay(transferDate, clcb);
                }
                s.AddBedStay(transferBed);
                Console.WriteLine(p.Name + " will be transferred to Ward " + b.WardNo +
                                  " Bed " + b.BedNo + " on " + transferDate.ToString("dd/MM/yyyy") + ".\n");
            }
            else
            {
                Console.WriteLine("No such bed found!");
            }
        }
Example #2
0
        static void RegisterHospitalStay(List <Patient> patientList, List <Bed> bedList)
        {
            //Prompt for and read patient NRIC number
            Console.Write("Enter Patient ID Number: ");
            string pNo = Console.ReadLine();

            Patient p = SearchPatient(patientList, pNo);

            if (p != null)
            {
                DisplayAllBeds(bedList);
                //Prompt for and read preferred bed
                Console.Write("Select bed to stay: ");
                int index = Convert.ToInt32(Console.ReadLine());
                //Bed b = SearchBed(bedList, bedNo);
                if (index <= bedList.Count && index > 0)
                {
                    Bed b = bedList[index - 1];
                    Console.Write("Enter date of admission [DD/MM/YYYY]: ");
                    //Issue with Time at the end
                    DateTime admDate = Convert.ToDateTime(Console.ReadLine()).Date;

                    Stay s = new Stay(admDate, p);

                    //initialisation of BedStay to prevent errors
                    BedStay bs = new BedStay(admDate, b);
                    if (b is ClassABed)
                    {
                        Console.Write("Any accompanying guest? (Additional $100 per day) [Y/N]: ");
                        string accGuest = Console.ReadLine().ToUpper();
                        //ClassABed cab = (ClassABed)b;
                        ClassABed clab = new ClassABed(b.WardNo, b.BedNo, b.DailyRate, b.Available);
                        clab.AccompanyingPerson = CheckOption(accGuest);
                        bs = new BedStay(admDate, clab);
                    }
                    else if (b is ClassBBed)
                    {
                        Console.Write("Do you want to upgrade to an Air-Conditioned variant? (Additional $50 per week) [Y/N]: ");
                        string ac = Console.ReadLine().ToUpper();
                        //ClassBBed cbb = (ClassBBed)b;
                        ClassBBed clbb = new ClassBBed(b.WardNo, b.BedNo, b.DailyRate, b.Available);
                        clbb.AirCon = CheckOption(ac);
                        bs          = new BedStay(admDate, clbb);
                    }
                    else if (b is ClassCBed)
                    {
                        Console.Write("Do you want to rent a portable TV? (One-Time Cost of $30) [Y/N]: ");
                        string pTV = Console.ReadLine().ToUpper();
                        //ClassCBed ccb = (ClassCBed)b;
                        ClassCBed clcb = new ClassCBed(b.WardNo, b.BedNo, b.DailyRate, b.Available);
                        clcb.PortableTv = CheckOption(pTV);
                        bs = new BedStay(admDate, clcb);
                    }
                    s.AddBedStay(bs);
                    p.Stay      = s;
                    p.Status    = "Admitted";
                    b.Available = false;
                    Console.WriteLine("Stay registration successful!");
                }
                else
                {
                    Console.WriteLine("Stay registration unsuccessful!");
                }
            }
            else
            {
                Console.WriteLine("Patient not found!");
            }
        }