//Display Bedlist static void DisplayBeds(List <Bed> bedsList) { Console.WriteLine("{0,-10}{1,-15}{2,-10}{3,-10}{4,-15}{5,-15}", "No", "Ward Type", "Ward No", "Bed No", "Availability", "Daily Rate"); int count = 1; foreach (Bed b in bedsList) { if (b is ClassABed) { ClassABed cab = (ClassABed)b; Console.WriteLine("{0,-10}{1,-15}{2,-10}{3,-10}{4,-15}{5,-15}", count, "A", cab.WardNo, cab.BedNo, cab.Available, cab.DailyRate); } else if (b is ClassBBed) { ClassBBed cbb = (ClassBBed)b; Console.WriteLine("{0,-10}{1,-15}{2,-10}{3,-10}{4,-15}{5,-15}", count, "B", cbb.WardNo, cbb.BedNo, cbb.Available, cbb.DailyRate); } else if (b is ClassCBed) { ClassCBed ccb = (ClassCBed)b; Console.WriteLine("{0,-10}{1,-15}{2,-10}{3,-10}{4,-15}{5,-15}", count, "C", ccb.WardNo, ccb.BedNo, ccb.Available, ccb.DailyRate); } else { Console.WriteLine("Bed not found"); } count++; } }
public double CalculateCharges() { double total = 0; int daysin = 0; foreach (BedStay bs in Stay.BedstayList) { DateTime admission = bs.StartBedstay; DateTime?discharge = bs.EndBedstay.GetValueOrDefault(); daysin = Convert.ToInt32(discharge - admission); Bed bed = bs.Bed; if (bed is ClassABed) { ClassABed cla = (ClassABed)bs.Bed; double c = bed.CalculateCharges(CitizenStatus, daysin); total += c; } else if (bed is ClassBBed) { ClassABed cla = (ClassABed)bs.Bed; double c = bed.CalculateCharges(CitizenStatus, daysin); total += c; } else if (bed is ClassCBed) { ClassABed cla = (ClassABed)bs.Bed; double c = bed.CalculateCharges(CitizenStatus, daysin); total += c; } } return(total); }
static void TransferPatient(List <Patient> pList, List <Bed> bList) { DisplayPatientsM(pList); Console.Write("Enter patientID number: "); string p_ID = Console.ReadLine(); DisplayBeds(bList); Console.Write("Select bed to transfer: "); int num = Convert.ToInt32(Console.ReadLine()); BedStay bedStay = new BedStay(); Console.Write("Date of Transfer (DD/MM/YYYY): "); string d = Console.ReadLine(); string[] d2 = d.Split('/'); DateTime Transfer = new DateTime(Convert.ToInt32(d2[2]), Convert.ToInt32(d2[1]), Convert.ToInt32(d2[0])); Bed N = bList[num - 1]; if (N.Available != false) { if (N is ClassABed) { ClassABed ba = (ClassABed)N; Console.Write("Any accompanying guest?(Additional $100 per day)[Y/N]: "); string answer = Console.ReadLine().ToUpper(); if (answer == "Y") { ba.AccompanyingPerson = true; bedStay = new BedStay(Transfer, ba); } else if (answer == "N") { ba.AccompanyingPerson = false; bedStay = new BedStay(Transfer, ba); } else { Console.WriteLine("Incorrect Input, Please Try again..."); } } else if (N is ClassBBed) { ClassBBed bb = (ClassBBed)N; Console.Write("Is AirCon needed (Additional $50 per week)? [Y/N]: "); string answer = Console.ReadLine().ToUpper(); if (answer == "Y") { bb.AirCon = true; bedStay = new BedStay(Transfer, bb); } else if (answer == "N") { bb.AirCon = false; bedStay = new BedStay(Transfer, bb); } else { Console.WriteLine("Incorrect Input, Please Try again..."); } } else { ClassCBed bc = (ClassCBed)N; Console.Write("Is a portable TV required (Additional $30 one time cost) [Y/N]: "); string answer = Console.ReadLine().ToUpper(); if (answer == "Y") { bc.PortableTv = true; bedStay = new BedStay(Transfer, bc); } else if (answer == "N") { bc.PortableTv = false; bedStay = new BedStay(Transfer, bc); } else { Console.WriteLine("Incorrect Input, Please Try again..."); } } foreach (Patient p in pList) { if (p.Id == p_ID) { p.Stay.BedstayList[p.Stay.BedstayList.Count - 1].EndBedstay = Transfer; p.Stay.BedstayList[p.Stay.BedstayList.Count - 1].Bed.Available = true; Console.WriteLine("{0} will be transferred to Ward {1} Bed {2} on {3}", p.Name, N.WardNo, N.BedNo, Transfer.ToString("dd/MM/yyyy")); p.Stay.AddBedstay(bedStay); } } N.Available = false; } }
static void RegisterHospitalStay(List <Patient> pList, List <Bed> bList) { DisplayPatientsRetrieve(pList); Console.Write("Enter patient ID number: "); string Patientid = Console.ReadLine().ToUpper(); DisplayBeds(bList); Console.Write("\nSelect bed to stay: "); int bednum = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter Date of Admission (DD/MM/YYYY): "); string d = Console.ReadLine(); string[] d2 = d.Split('/'); DateTime Dates = new DateTime(Convert.ToInt32(d2[2]), Convert.ToInt32(d2[1]), Convert.ToInt32(d2[0])); BedStay newbedStay = new BedStay(); Bed b = bList[bednum - 1]; if (b.Available != false) { if (b is ClassABed) { ClassABed bl = (ClassABed)b; Console.Write("Any accompanying guest?(Additional $100 per day)[Y/N]: "); string answer = Console.ReadLine().ToUpper(); if (answer == "Y") { bl.AccompanyingPerson = true; newbedStay = new BedStay(Dates, bl); } else if (answer == "N") { bl.AccompanyingPerson = false; newbedStay = new BedStay(Dates, bl); } else { Console.WriteLine("Incorrect Input, Please Try again..."); } } else if (b is ClassBBed) { ClassBBed bb = (ClassBBed)b; Console.Write("Is AirCon needed? [Y/N]: "); string answer = Console.ReadLine().ToUpper(); if (answer == "Y") { bb.AirCon = true; newbedStay = new BedStay(Dates, bb); } else if (answer == "N") { bb.AirCon = false; newbedStay = new BedStay(Dates, bb); } else { Console.WriteLine("Incorrect Input, Please Try again..."); } } else { ClassCBed bc = (ClassCBed)b; Console.Write("Is a portable TV required? [Y/N]: "); string answer = Console.ReadLine().ToUpper(); if (answer == "Y") { bc.PortableTv = true; newbedStay = new BedStay(Dates, bc); } else if (answer == "N") { bc.PortableTv = false; newbedStay = new BedStay(Dates, bc); } else { Console.WriteLine("Incorrect Input, Please Try again..."); } } foreach (Patient p in pList) { if (p.Id == Patientid) { Stay NewStay = new Stay(Dates, p); NewStay.AddBedstay(newbedStay); p.Stay = NewStay; p.Status = "Admitted"; } } b.Available = false; Console.WriteLine("\n\nStay registration successful!\n"); } else { Console.WriteLine("Bed does not exist. ."); Console.WriteLine("Stay registration unsucessful\n"); } }
static void Addnewbed(List <Bed> blist) { Console.Write("Enter Ward Type [A/B/C]: "); string wt = Console.ReadLine(); Console.Write("Enter Ward No.: "); int wn = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter Bed No.: "); int bn = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter Daily Rate: $"); double dr = Convert.ToDouble(Console.ReadLine()); Console.Write("Enter Available [Y/N]: "); string av = Console.ReadLine(); if (wt == "A") { if (av == "Y") { Bed cab = new ClassABed(wn, bn, dr, true); blist.Add(cab); Console.WriteLine("Bed added successfully."); } else if (av == "N") { Bed cab = new ClassABed(wn, bn, dr, false); blist.Add(cab); Console.WriteLine("Bed added successfully."); } } if (wt == "B") { if (av == "Y") { Bed cab = new ClassBBed(wn, bn, dr, true); blist.Add(cab); Console.WriteLine("Bed added successfully."); } else if (av == "N") { Bed cab = new ClassBBed(wn, bn, dr, false); blist.Add(cab); Console.WriteLine("Bed added successfully."); } } if (wt == "C") { if (av == "Y") { Bed cab = new ClassCBed(wn, bn, dr, true); blist.Add(cab); Console.WriteLine("Bed added successfully."); } else if (av == "N") { Bed cab = new ClassCBed(wn, bn, dr, false); blist.Add(cab); Console.WriteLine("Bed added successfully."); } } }
static void Dischargepayment(List <Patient> patientsList) { try { Console.Write("Enter patient ID number: "); string pid = Console.ReadLine().ToUpper(); Console.Write("Date of discharge (DD/MM/YYYY): "); string dod1 = Console.ReadLine(); DateTime dod = Convert.ToDateTime(dod1); foreach (Patient p in patientsList) { if (p.Id == pid) { 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("\n======Stay ======"); Console.WriteLine("Admission Date: {0}", p.Stay.AdmittedDate); Console.WriteLine("Discharge Date: {0}", dod); p.Stay.DischargedDate = dod; p.Stay.IsPaid = false; int count = 1; foreach (BedStay bs in p.Stay.BedstayList) { DateTime endstaydate = Convert.ToDateTime(bs.EndBedstay); int daysDiff = Convert.ToInt32(bs.StartBedstay.Day - endstaydate.Day); Console.WriteLine("\n======Bed # {0} ======", count); Console.WriteLine("Ward number: {0}", bs.Bed.WardNo); Console.WriteLine("Bed number: {0}", bs.Bed.BedNo); Console.WriteLine("Ward Class: {0}", "A"); Console.WriteLine("Start of bed stay: {0}", bs.StartBedstay); Console.WriteLine("End of bed stay: {0}", bs.EndBedstay); if (bs.Bed is ClassABed) { ClassABed cab = (ClassABed)bs.Bed; Console.WriteLine("Accompanying Person: {0}", cab.AccompanyingPerson); bs.Bed.CalculateCharges(p.CitizenStatus, daysDiff); } else if (bs.Bed is ClassBBed) { ClassBBed cbb = (ClassBBed)bs.Bed; Console.WriteLine("AirCon: {0}", cbb.AirCon); bs.Bed.CalculateCharges(p.CitizenStatus, daysDiff); } else if (bs.Bed is ClassCBed) { ClassCBed ccb = (ClassCBed)bs.Bed; Console.WriteLine("Avaliable: {0}", ccb.Available); bs.Bed.CalculateCharges(p.CitizenStatus, daysDiff); } Console.WriteLine("Number of days stayed: {0}", daysDiff); count++; } Console.WriteLine("[Press any key to proceed with payment]"); Console.ReadKey(); Console.WriteLine("\nCommencing payment...\n"); if (p is Child) { Child ch = (Child)p; Console.WriteLine("${0} has been deducted from CDA", ch.CdaBalance); double chcost = ch.CalculateCharges(); if (ch.CdaBalance > chcost) { ch.CdaBalance -= chcost; chcost = 0; Console.WriteLine("New CDA balance: ${0}", ch.CdaBalance); Console.WriteLine("Sub-total: ${0} has been paid by cash", chcost); Console.WriteLine("Payment Successful!"); p.Stay.IsPaid = true; } else if (ch.CdaBalance < chcost) { chcost -= ch.CdaBalance; ch.CdaBalance = 0; Console.WriteLine("New CDA balance: ${0}", ch.CdaBalance); Console.WriteLine("Sub-total: ${0} has been paid by cash", chcost); Console.WriteLine("Payment Successful!"); p.Stay.IsPaid = true; } else if (ch.CdaBalance == chcost) { chcost = 0; ch.CdaBalance = 0; Console.WriteLine("New CDA balance: ${0}", ch.CdaBalance); Console.WriteLine("Sub-total: ${0} has been paid by cash", chcost); Console.WriteLine("Payment Successful!"); p.Stay.IsPaid = true; } else { Console.WriteLine("Error in calculating Balance"); } } else if (p is Adult) { Adult ad = (Adult)p; Console.WriteLine("${0} has been deducted from Medisave", ad.MedisaveBalance); double adcost = ad.CalculateCharges(); if (ad.MedisaveBalance > adcost) { ad.MedisaveBalance -= adcost; adcost = 0; Console.WriteLine("New CDA balance: ${0}", ad.MedisaveBalance); Console.WriteLine("Sub-total: ${0} has been paid by cash", adcost); Console.WriteLine("Payment Successful!"); p.Stay.IsPaid = true; } else if (ad.MedisaveBalance < adcost) { adcost -= ad.MedisaveBalance; ad.MedisaveBalance = 0; Console.WriteLine("New CDA balance: ${0}", ad.MedisaveBalance); Console.WriteLine("Sub-total: ${0} has been paid by cash", adcost); Console.WriteLine("Payment Successful!"); p.Stay.IsPaid = true; } else if (ad.MedisaveBalance == adcost) { adcost = 0; ad.MedisaveBalance = 0; Console.WriteLine("New CDA balance: ${0}", ad.MedisaveBalance); Console.WriteLine("Sub-total: ${0} has been paid by cash", adcost); Console.WriteLine("Payment Successful!"); p.Stay.IsPaid = true; } else { Console.WriteLine("Error in calculating Balance"); } } else if (p is Senior) { Senior sn = (Senior)p; Console.WriteLine("Total Cost has been reduced by half"); double sncost = sn.CalculateCharges(); Console.WriteLine("Sub-total: ${0} has been paid by cash", sncost); Console.WriteLine("Payment Successful!"); p.Stay.IsPaid = true; } else { Console.WriteLine("Error in Patient (Child/Adult/Senior) Class"); } } } } catch { Console.WriteLine("Unable to Discharge or Settle payments"); } }
//InIt List static void InitData(List <Patient> pList, List <Bed> bList) { // read csv lines from patients string[] lines = File.ReadAllLines("patients(1).csv"); for (int l = 1; l < lines.Length; l++) { string[] info = lines[l].Split(','); if (Convert.ToInt32(info[2]) <= 12) { if (info[4] == "SC") { Patient child = new Child(info[1], info[0], Convert.ToInt32(info[2]), Convert.ToChar(info[3]), info[4], "Registered", Convert.ToDouble(info[5])); pList.Add(child); } else { Patient child = new Child(info[1], info[0], Convert.ToInt32(info[2]), Convert.ToChar(info[3]), info[4], "Registered", 0); pList.Add(child); } } else if (Convert.ToInt32(info[2]) < 64) { if (info[4] == "SC" || info[4] == "PR") { Patient adult = new Adult(info[1], info[0], Convert.ToInt32(info[2]), Convert.ToChar(info[3]), info[4], "Registered", Convert.ToDouble(info[5])); pList.Add(adult); } else { Patient adult = new Adult(info[1], info[0], Convert.ToInt32(info[2]), Convert.ToChar(info[3]), info[4], "Registered", 0); pList.Add(adult); } } else { Senior senior = new Senior(info[1], info[0], Convert.ToInt32(info[2]), Convert.ToChar(info[3]), info[4], "Registered"); pList.Add(senior); } } //Read from Beds.csv try { string[] sents = File.ReadAllLines("beds.csv"); for (int l = 1; l < sents.Length; l++) { string[] sbed = sents[l].Split(','); if (sbed[0] == "A") { Bed cab = new ClassABed(Convert.ToInt32(sbed[1]), Convert.ToInt32(sbed[2]), Convert.ToDouble(sbed[4]), true); bList.Add(cab); } else if (sbed[0] == "B") { Bed cbb = new ClassBBed(Convert.ToInt32(sbed[1]), Convert.ToInt32(sbed[2]), Convert.ToDouble(sbed[4]), true); bList.Add(cbb); } else if (sbed[0] == "C") { Bed ccb = new ClassCBed(Convert.ToInt32(sbed[1]), Convert.ToInt32(sbed[2]), Convert.ToDouble(sbed[4]), true); bList.Add(ccb); } } } catch { Console.WriteLine("Unable to Read File/File does not exist"); } }