Exemple #1
0
        // Ryan's Methods //
        static void InitPatients(List <Patient> patientList)
        {
            string[] patientRaw = File.ReadAllLines(@"patients.csv");
            for (int i = 1; i < patientRaw.Length; i++)
            {
                string[] pData = patientRaw[i].Split(",");

                /* pData[0] : Name
                 * pData[1] : Nric Number
                 * pData[2] : Age
                 * pData[3] : Gender
                 * pData[4] : Citizenship
                 * pData[5] : CDA/Medisave Balance (if any)
                 */


                int    age  = Convert.ToInt32(pData[2]);
                string cs   = pData[4];
                string stat = "Registered";
                if (age >= 0 && age <= 12)
                {
                    if (cs == "SC" || cs == "sc")
                    {
                        //                    Nric       Name     Age  Gender                   Cts  status   CDA/Medisave
                        Patient p = new Child(pData[1], pData[0], age, Convert.ToChar(pData[3]), cs, stat, Convert.ToDouble(pData[5]));
                        patientList.Add(p);
                    }
                    else if (cs == "Foreigner" || cs == "PR" || cs == "pr")
                    {
                        Patient p = new Child(pData[1], pData[0], age, Convert.ToChar(pData[3]), cs, stat, 0.0);
                        patientList.Add(p);
                    }
                }
                else if (age <= 64)
                {
                    if (cs == "SC" || cs == "sc" || cs == "PR" || cs == "pr") //Validaton for casing
                    {
                        Patient p = new Adult(pData[1], pData[0], age, Convert.ToChar(pData[3]), cs, stat, Convert.ToDouble(pData[5]));
                        patientList.Add(p);
                    }
                    else if (cs == "Foreigner")
                    {
                        Patient p = new Adult(pData[1], pData[0], age, Convert.ToChar(pData[3]), cs, stat, 0.0);
                        patientList.Add(p);
                    }
                }
                else if (age >= 65)
                {
                    Patient p = new Senior(pData[1], pData[0], age, Convert.ToChar(pData[3]), cs, stat);
                    patientList.Add(p);
                }
            }
        }
Exemple #2
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");
                    }
                }
            }
        }
Exemple #3
0
        static void RegisterPatient(List <Patient> patientList)
        {
            Console.WriteLine("Option 3. Register Patient");
            Console.Write("Enter Name: ");
            string n = Console.ReadLine();

            Console.Write("Enter Identification Number: ");
            string id = Console.ReadLine();

            if (!readID(id))
            {
                Console.WriteLine("Incorrect input type!");
                return;
            }
            Console.Write("Enter Age: ");

            string userinput = Console.ReadLine();
            int    age;

            if (!int.TryParse(userinput, out age))
            {
                // ERROR
                Console.WriteLine("Incorrect Input type! Enter an integer!");
                return;
            }
            Console.Write("Enter Gender [M/F]: ");
            string g = Console.ReadLine().Trim().ToUpper();

            if (g != "M" && g != "F")
            {
                Console.WriteLine("Incorrect Input type! Enter a character either M or F!");
                return;
            }

            Console.Write("Enter Citizenship Status [SC/PR/Foreigner]: ");
            string cs = Console.ReadLine().ToUpper().Trim();

            if (cs != "SC" && cs != "PR" && cs != "FOREIGNER")
            {
                Console.WriteLine("Incorrect Citizenship Type!");
                return;
            }
            string stat    = "Registered";
            double subsidy = 0.0;


            if (age >= 0 && age <= 12)
            {
                // only if condition is met, subsidy will be updated accordingly
                // if not met, will remain as 0.
                if (cs == "SC")
                {
                    Console.Write("Enter CDA Balance: ");
                    subsidy = Convert.ToDouble(Console.ReadLine());
                }
                Patient p = new Child(id, n, age, Convert.ToChar(g), cs, stat, subsidy);
                patientList.Add(p);
                using (StreamWriter file = new StreamWriter(@"Patients.csv", true))
                {
                    string line = n + ',' + id + ',' + age + ',' + g + ',' + cs + ',' + subsidy;
                    file.Write(line);
                }
                Console.WriteLine($"\n{n} was successfully registered!\n");
            }
            else if (age <= 64)
            {
                if (cs == "SC" || cs == "PR")
                {
                    Console.Write("Enter Medisave Balance: ");
                    subsidy = Convert.ToDouble(Console.ReadLine());
                }
                Patient p = new Adult(id, n, age, Convert.ToChar(g), cs, stat, subsidy);
                patientList.Add(p);
                using (StreamWriter file = new StreamWriter(@"Patients.csv", true))
                {
                    string line = n + ',' + id + ',' + age + ',' + g + ',' + cs + ',' + subsidy;
                    file.Write(line);
                }
                Console.WriteLine($"\n{n} was successfully registered!\n");
            }
            else if (age >= 65)
            {
                Patient p = new Senior(id, n, age, Convert.ToChar(g), cs, stat);
                patientList.Add(p);
                using (StreamWriter file = new StreamWriter(@"Patients.csv", true))
                {
                    string line = n + ',' + id + ',' + age + ',' + g + ',' + cs + ',' + subsidy;
                    file.Write(line);
                }
                Console.WriteLine($"\n{n} was successfully registered!\n");
            }
        }