//Ryan's initial idea
        //public abstract double CalculateCharges();

        public double CalculateCharges()
        {
            double total = 0;

            foreach (BedStay bes in Stay.BedStayList)
            {
                DateTime endstaydate = Convert.ToDateTime(bes.EndBedStay);
                double   staydays    = (endstaydate - bes.StartBedStay.Date).TotalDays;

                int noofdays = Convert.ToInt32(staydays);
                if (bes.Bed is ClassABed)
                {
                    ClassABed abed = (ClassABed)bes.Bed;
                    total = total + abed.CalculateCharges(CitizenStatus, noofdays);
                }
                else if (bes.Bed is ClassBBed)
                {
                    ClassBBed bbed = (ClassBBed)bes.Bed;
                    total = total + bbed.CalculateCharges(CitizenStatus, noofdays);
                }
                else if (bes.Bed is ClassCBed)
                {
                    ClassCBed cbed = (ClassCBed)bes.Bed;
                    total = total + cbed.CalculateCharges(CitizenStatus, noofdays);
                }
            }
            return(total);
        }
Example #2
0
        static void DisplayAllBeds(List <Bed> bList)
        {
            Console.WriteLine("{0, -10} {1, -10} {2, -10} {3, -10} {4, -10} {5, -10} ", "No", "Type", "Ward No", "Bed No", "Daily Rate", "Available");
            int counter = 1;//for the no of beds

            foreach (Bed b in bList)
            {
                if (b is ClassABed)                //To display according to type
                {
                    ClassABed abed = (ClassABed)b; //Downcasting
                    Console.WriteLine("{0, -10} {1, -10} {2, -10} {3, -10} {4, -10} {5, -10}", counter, "A", abed.WardNo, abed.BedNo, abed.DailyRate, abed.Available);
                }

                else if (b is ClassBBed)
                {
                    ClassBBed bbed = (ClassBBed)b; //Downcasting
                    Console.WriteLine("{0, -10} {1, -10} {2, -10} {3, -10} {4, -10} {5, -10}", counter, "B", bbed.WardNo, bbed.BedNo, bbed.DailyRate, bbed.Available);
                }

                else if (b is ClassCBed)
                {
                    ClassCBed cbed = (ClassCBed)b; //Downcasting
                    Console.WriteLine("{0, -10} {1, -10} {2, -10} {3, -10} {4, -10} {5, -10}", counter, "C", cbed.WardNo, cbed.BedNo, cbed.DailyRate, cbed.Available);
                }
                counter++;
            }
        }
Example #3
0
        //For option 10
        static void DischargePayment(List <Patient> patientlist, List <Bed> bList)
        {
            //Extra charges
            double charges = 0;
            //For number of Bed records
            int counter = 1;

            Console.Write("Enter patient ID number to discharge: ");
            //Input patient to discharge
            string patientid = Console.ReadLine();

            //Input Date of discharge
            Console.Write("Date of discharge (DD/MM/YYYY): ");
            DateTime disdate = Convert.ToDateTime(Console.ReadLine()).Date;


            foreach (Patient p in patientlist)
            {
                if (p.Id == patientid)
                {
                    //p.Status = "Discharged";
                    Console.WriteLine("Name of patient: {0}", p.Name);
                    Console.WriteLine("ID number: {0}", p.Id);
                    Console.WriteLine("Citizenship status: {0}", p.CitizenStatus);
                    Console.WriteLine("Gender: {0}", p.Gender);
                    Console.WriteLine("Status: {0}", p.Status);
                    Console.WriteLine();
                    Console.WriteLine("=====Stay=====");
                    Console.WriteLine("Admission date: {0}", p.Stay.AdmittedDate);
                    p.Stay.DischargeDate = disdate; //Updating patient discharge date
                    Console.WriteLine("Discharge date: {0}", p.Stay.DischargeDate);
                    if (p.Stay.IsPaid == true)      //Payment status
                    {
                        Console.WriteLine("Payment status: Paid");
                    }

                    else if (p.Stay.IsPaid == false)
                    {
                        Console.WriteLine("Payment status: Unpaid");
                    }


                    foreach (BedStay bes in p.Stay.BedStayList)
                    {
                        //Bed records

                        Console.WriteLine("======Bed #{0}=======", counter);
                        Console.WriteLine("Ward Number: {0}", bes.Bed.WardNo);
                        Console.WriteLine("Start of bed stay: {0}", bes.StartBedStay);
                        BedStay  last            = p.Stay.BedStayList[p.Stay.BedStayList.Count - 1];
                        DateTime lastendstaydate = Convert.ToDateTime(last.EndBedStay);
                        int      result          = DateTime.Compare(lastendstaydate, disdate);
                        if (result == -1)
                        {
                            last.EndBedStay = disdate;
                            Console.WriteLine("End of bed stay: {0}", bes.EndBedStay); //ensure that the last object has a proper endbedstay object
                        }
                        else
                        {
                            Console.WriteLine("End of bed stay : {0}", bes.EndBedStay);
                        }

                        //Calculating number of days
                        DateTime endstaydate = Convert.ToDateTime(bes.EndBedStay);
                        double   staydays    = (endstaydate - bes.StartBedStay.Date).TotalDays;

                        if (bes.Bed is ClassABed) //Checking what type of bed is  it
                        {
                            ClassABed abed = (ClassABed)bes.Bed;
                            Console.WriteLine("Ward Class: A");
                            Console.WriteLine("Accompanying Person: {0} ", abed.AccompanyingPerson);
                            if (abed.AccompanyingPerson == true) //If have accompanying person it is 100 more
                            {
                                charges = charges + 100;
                            }
                        }

                        else if (bes.Bed is ClassBBed)
                        {
                            ClassBBed bbed = (ClassBBed)bes.Bed;
                            Console.WriteLine("Ward Class: B");
                            Console.WriteLine("Air con: {0}", bbed.AirCon);
                            if (bbed.AirCon == true && staydays >= 8) //If have aircon and stay is longer than 8 days
                            {
                                charges = charges + 100;
                            }
                            else if (bbed.AirCon == true) //If only have aircon
                            {
                                charges = charges + 50;
                            }
                        }

                        else if (bes.Bed is ClassCBed)
                        {
                            ClassCBed cbed = (ClassCBed)bes.Bed;
                            Console.WriteLine("Ward Class: C");
                            Console.WriteLine("Portable TV: {0}", cbed.PortableTv);
                            if (cbed.PortableTv == true) //If have portable tv
                            {
                                charges = charges + 30;
                            }
                        }
                        Console.WriteLine();
                        Console.WriteLine("Number of days stayed: {0}", staydays);

                        counter = counter + 1;//Increasing the number of records
                    }
                    Console.WriteLine("============");
                    double patientcharge = charges + p.CalculateCharges();

                    if (p is Child && p.CitizenStatus == "SC") //if is it child and Singaporean citizen
                    {
                        Child c = (Child)p;                    //Downcast
                        Console.WriteLine("Total Charges pending: ${0}", patientcharge);
                        Console.WriteLine("CDA balance: ${0}", c.CdaBalance);
                        Console.WriteLine("To deduct from CDA: ${0}", c.CdaBalance);
                        Console.WriteLine("[Press any key to proceed with payment]");
                        Console.ReadKey();
                        Console.WriteLine("Commencing payment...");
                        Console.WriteLine();
                        Console.WriteLine("${0} has been deducted from CDA balance.", c.CdaBalance);
                        double childcharge = charges + c.CalculateCharges();
                        Console.WriteLine("New CDA balance : $0");
                        Console.WriteLine("Subtotal: ${0} has been paid by cash", childcharge);
                        Console.WriteLine();
                        p.Stay.IsPaid = true;
                        p.Status      = "Discharged";
                        Console.WriteLine("Payment successful");
                    }
                    else if (p is Adult && (p.CitizenStatus == "SC" || p.CitizenStatus == "PR")) //if it is adult and a citzen/PR
                    {
                        Adult a = (Adult)p;                                                      //Downcast
                        Console.WriteLine("Total Charges pending: ${0}", patientcharge + a.MedisaveBalance);
                        Console.WriteLine("Medisave Balance: {0}", a.MedisaveBalance);
                        Console.WriteLine("To deduct from Medisave: {0}", a.MedisaveBalance);
                        Console.WriteLine("[Press any key to proceed with payment]");
                        Console.ReadKey();
                        Console.WriteLine("Commencing payment...");
                        Console.WriteLine();
                        Console.WriteLine("${0} has been deducted from Medisave balance", a.MedisaveBalance);
                        double adultcharge = charges + a.CalculateCharges();
                        Console.WriteLine("New Medisave Balance: $0");
                        Console.WriteLine("Subtotal: ${0} has been paid by cash", adultcharge);
                        Console.WriteLine();
                        p.Stay.IsPaid = true;
                        p.Status      = "Discharged";
                        Console.WriteLine("Payment successful");
                    }
                    else
                    {
                        Console.WriteLine("Total Charges pending: ${0}", patientcharge);
                        Console.WriteLine("[Press any key to proceed with payment]");
                        Console.ReadKey();
                        Console.WriteLine("Commencing payment...");
                        Console.WriteLine();
                        Console.WriteLine("Subtotal: ${0} has been paid by cash", patientcharge);
                        Console.WriteLine();
                        p.Stay.IsPaid = true;
                        p.Status      = "Discharged";
                        Console.WriteLine("Payment successful");
                    }
                }
            }
        }
Example #4
0
        //For Option 4
        static void AddBed(List <Bed> bList)
        {
            //inputs
            Console.Write("Enter Ward Type[A/B/C]: ");
            string wardtype = Console.ReadLine().ToUpper(); //Validation

            Console.Write("Enter Ward No: ");
            int wardno = Convert.ToInt32(Console.ReadLine());

            Console.Write("Enter Bed No: ");
            int bedno = Convert.ToInt32(Console.ReadLine());

            Console.Write("Enter Daily Rate:$ ");
            double drate = Convert.ToDouble(Console.ReadLine());

            Console.Write("Enter Available[Y/N]: ");
            string available = Console.ReadLine().ToUpper(); //Validation
            string bedtrue   = "Yes";
            string bedfalse  = "No";

            Console.WriteLine();
            Console.WriteLine("Bed added successfully");

            if (wardtype == "A" && available == "Y") //Find out the class and availability
            {
                ClassABed newabedtrue = new ClassABed(wardno, bedno, drate, true);
                bList.Add(newabedtrue);
                using (StreamWriter file = new StreamWriter(@"beds.csv", true)) //append csv file
                {
                    string bed = "\n" + wardtype + ',' + wardno + ',' + bedno + ',' + bedtrue + ',' + drate;
                    file.Write(bed);
                }
            }

            else if (wardtype == "A" && available == "N") //if availability is no
            {
                ClassABed newabedfalse = new ClassABed(wardno, bedno, drate, false);
                bList.Add(newabedfalse);
                using (StreamWriter file = new StreamWriter(@"beds.csv", true)) //append csv file
                {
                    string bed = "\n" + wardtype + ',' + wardno + ',' + bedno + ',' + bedfalse + ',' + drate;
                    file.Write(bed);
                }
            }

            if (wardtype == "B" && available == "Y")
            {
                ClassBBed newbbedtrue = new ClassBBed(wardno, bedno, drate, true);
                bList.Add(newbbedtrue);
                using (StreamWriter file = new StreamWriter(@"beds.csv", true)) //append csv file
                {
                    string bed = "\n" + wardtype + ',' + wardno + ',' + bedno + ',' + bedtrue + ',' + drate;
                    file.Write(bed);
                }
            }

            else if (wardtype == "B" && available == "N")
            {
                ClassBBed newbbedfalse = new ClassBBed(wardno, bedno, drate, false);
                bList.Add(newbbedfalse);
                using (StreamWriter file = new StreamWriter(@"beds.csv", true)) //append csv file
                {
                    string bed = "\n" + wardtype + ',' + wardno + ',' + bedno + ',' + bedfalse + ',' + drate;
                    file.Write(bed);
                }
            }

            if (wardtype == "C" && available == "Y")
            {
                ClassCBed newcbedtrue = new ClassCBed(wardno, bedno, drate, true);
                bList.Add(newcbedtrue);
                using (StreamWriter file = new StreamWriter(@"beds.csv", true)) //append csv file
                {
                    string bed = "\n" + wardtype + ',' + wardno + ',' + bedno + ',' + bedtrue + ',' + drate;
                    file.Write(bed);
                }
            }

            else if (wardtype == "C" && available == "N")
            {
                ClassCBed newcbedfalse = new ClassCBed(wardno, bedno, drate, false);
                bList.Add(newcbedfalse);
                using (StreamWriter file = new StreamWriter(@"beds.csv", true)) //append csv file
                {
                    string bed = "\n" + wardtype + ',' + wardno + ',' + bedno + ',' + bedfalse + ',' + drate;
                    file.Write(bed);
                }
            }

            else
            {
                Console.WriteLine("Bed added unsccesffuly. Please try again");
            }
        }
Example #5
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 #6
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!");
            }
        }