Example #1
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 #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!");
            }
        }
Example #3
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!");
            }
        }
 public void AddBedStay(BedStay bs)
 {
     BedStayList.Add(bs);
 }