Assignment 2 Patient Data Create a Patient class for the Wri

Assignment 2: Patient Data

Create a Patient class for the Wrightstown Hospital Billing Department. Include a patient ID number, name, age, and amount due to the hospital. Include properties and any other methods you need. Override the ToString() method to return all the details for a patient. Write an application that prompts the user for data for five Patients. Sort them in patient ID number order and display them all, including a total amount owed.

Save the program as PatientDemo.cs.

Using the Patient class as a base, derive an InsuredPatient class. An InsuredPatient contains all the data of a Patient, plus fields to hold an insurance company name, and the percentage of the hospital bill the insurance company will pay. Insurance payments are based on the following table:

Create an array of five InsuredPatient objects. Create a program that justifies the following:

Prompts the user for all the patient data, plus the name of the insurance company; the insurance company set accessor determines the percentage paid.

Overrides the parent class ToString() method to include the name of the insurance company, the percent paid, and the amount due after the insurance has been applied to the bill.

Sorts all the records in ID number order and displays them with a total amount due from all insured patients.

Save the program as PatientDemo2.cs.

Write an application that uses an extension method for the Patient class. The method computes and returns a Patient\'s quarterly insurance payment (one-fourth of the annual premium). The application should allow the user to enter data for five Patients and then display all the Patient data for each, including the quarterly payment.

Save the program as PatientDemo3.cs.

Embed the programs in a Microsoft Word document.

Cite any sources in APA format on a separate page.

Name your document SU_ITS2105_W4_A2_LastName_FirstInitial.doc.

Submit your document to the W4: Assignment 2 Dropbox by Tuesday, November 8, 2016.

Here is my program for the PatientDemo.cs

I have so many errors I do not even know where to start. I am trying to play catch up. I have been in the extremely ill and trying to find help to get through this class.

namespace PatientDemo2
{
    class Patient //Wrightstown Hospital Billing Department
    {

        public static void PatientEntry(string PID, string FirstName, string LastName, string Age);

        public string PIdNumber { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public int Age { get; set; }

    }
    class InsuredPatient //Insurance Company Information
    {
        public static void InsuredPatient(string PID, string InsCompany, double percent);

        //Insurance Company and Portion of bill paid by insurance (%)

        public string PIdNumber { get; set; }
        public string InsCompany { get; set; }
        public double PercentPaid { get; set; }

        //Ins Co
        public string WrightstownMutual { get; set; }
        public string RedUmbrella { get; set; }
        public string AllOtherCompanies { get; set; }

        //set variables for InsCo Code percentage paid
        public double WM1 = 0.80;
        public double RU2 = 0.60;
        public double AOC3 = 0.25;
    }

    static void Main();
    
        //set variable
        //string FirstName = first;
        //string LastName = last;
        //int Age = age;
        //double AmountDue = amtDue;
        //string PID = [5];

        //int (i = 0: i< (5); i++);
   
        //determine which insurance co was selected
        // double ServiceAmount = svcAmt;
        // public double PercentPaid = percentPaid;
        //public string PID;

        //enter Patient data
        Console.Writeline(users.ToStringTable new[5] (\"PID:\", \"First Name:\"; \"Last Name:\"; \"Patient Age\";
        \"Insurance Company \"; \"Insurance Company Code\";);
        Console.Readline();
        // calculate the percentage owed.
        // Amount due based on the insurance company selected.
        ServiceAmount = Convert.ToDecimal(Console.ReadLine());

            //if WM1 = 0.80
              
               // else
                //RU2 = 0.60
                //else
                //AOC3 = 0.25
             
     
        //start data sort and build the table

        Console.Writeline(users.ToStringTable new[] (\"PID:\", \"First Name:\"; \"Last Name:\"; \"Patient Age\";
        \"Insurance Company \"; \"Insurance Company Code\"; \"Percent Paid by Insurance\";);
        Console.Writeline(\"\ ------------------------------------------------------\");
        Array.Sort(PID);
        Console.Writeline(\"\ ------------------------------------------------------\");
  
         //Pause to display the results.
         Console.WriteLine(\"Press Enter to terminate... \");
         Console.Read();
}

Solution

Main.cs

using System;
using PatientLib;

namespace ex
{
   class MainClass
   {
       public static void Main (string[] args)
       {
           //PatientDemo1();
           PatientDemo2();
       }
       public static void PatientDemo1()
       {
           int id,age;
           string name;
           double amtOwed,totalAmtOwed = 0;
          
           Patient[] patients = new Patient[5];
           for (int i = 0; i < patients.Length; i++)
           {
               Patient.GetPatientId(out id);
               foreach (Patient item in patients)
               {
                   if (item != null)
                   {
                       while (item.Id == id)
                       {
                           Console.WriteLine(\"{0} is already taken\",item.Id);
                           Console.WriteLine(\"patient id\'s must be unique!\");
                           Patient.GetPatientId(out id);
                       }
                   }
               }
               Patient.GetPatientAge(out age);
               Patient.GetPatientName(out name);
               Patient.GetPatientAmtOwed(out amtOwed);
               patients[i] = new Patient(id,age,amtOwed,name);
               totalAmtOwed += amtOwed;
           }
           Array.Sort(patients);
           foreach (Patient item in patients)
           {
                   Console.WriteLine(item);  
           }  
           Console.WriteLine(\"total amount owed: {0}\",totalAmtOwed.ToString(\"C\"));  
       }
              
       public static void PatientDemo2()
       {
           int id,age;
           string name,insuranceCompany;
           double amtOwed,totalAmtOwed = 0;
          
           InsuredPatient[] insuredPatients = new InsuredPatient[5];
           for (int i = 0; i < insuredPatients.Length; i++)
           {
               InsuredPatient.GetPatientId(out id);
               foreach (InsuredPatient item in insuredPatients)
               {
                   if (item != null)
                   {
                       while (item.Id == id)
                       {
                           Console.WriteLine(\"{0} is already taken\",item.Id);
                           Console.WriteLine(\"patient id\'s must be unique!\");
                           InsuredPatient.GetPatientId(out id);
                       }
                   }
               }
               InsuredPatient.GetPatientAge(out age);
               InsuredPatient.GetPatientName(out name);
               InsuredPatient.GetPatientAmtOwed(out amtOwed);
               InsuredPatient.GetInsuranceName(out insuranceCompany);
              
               insuredPatients[i] = new InsuredPatient(insuranceCompany,id,age,amtOwed,name);
               // hack around since amtOwed logic only kicks in after the constructor
               amtOwed = insuredPatients[i].AmountDue;
               totalAmtOwed += amtOwed;
           }
           Array.Sort(insuredPatients);
           foreach (InsuredPatient item in insuredPatients)
           {
                   Console.WriteLine(item);  
           }  
           Console.WriteLine(\"total amount owed: {0}\",totalAmtOwed.ToString(\"C\"));  
       }
   }
}

InsuredPatient.cs

using System;

namespace PatientLib
{
   public class InsuredPatient : Patient,IComparable
   {
       private static double[] insurancePercentages = {.8,.6,.25};
       private static string[] insuranceNames = {\"Wrightstown Mutual\",\"Red Umbrella\",\"All other companies\"};
      
       private string insuranceCompany;
       private double insuranceDiscount;
      
       InsuredPatient () : base(){}
      
       public InsuredPatient (string insuranceCompany,int id,int age,double amt,string name) : base(id,age,amt,name)
       {
           this.InsuranceCompany = insuranceCompany;
          
           // amountDue has special logic applied
           this.AmountDue = amt;
       }

       // this guy sets the insuranceDiscount in addition to it\'s normal duties
       public string InsuranceCompany {
           get {
               return this.insuranceCompany;
           }
           set {
               insuranceCompany = value;
               for (int i = 0; i < insuranceNames.Length; i++) {
                   if (insuranceCompany.Equals(insuranceNames[i]))
                   {
                       insuranceDiscount = insurancePercentages[i];
                       break;
                   }
               }
           }
       }
      
       public double InsuranceDiscount {
           get {
               return this.insuranceDiscount;
           }
       }
      
       // here\'s the special logic referred to above...a discount, w00t
       public override double AmountDue {
           get {
               return this.amountDue;
           }
           set {
               amountDue = value - value*this.InsuranceDiscount;
           }
       }
      
       public new int CompareTo (object obj)
       {
           return base.CompareTo(obj);
       }

       public override bool Equals (object obj)
       {
           return base.Equals (obj);
       }

       public override int GetHashCode ()
       {
           return base.GetHashCode ();
       }
      
       public override string ToString ()
       {
           return string.Format(\"[InsuredPatient: Id={0}, Age={1}, AmountDue={2}, Name={3}, InsuranceCompany={4}, InsuranceDiscount={5}]\",
                                 Id,Age,AmountDue.ToString(\"C\"),
                                 Name,InsuranceCompany,InsuranceDiscount.ToString(\"P\"));
       }
      
       public static void GetInsuranceName(out string name)
       {
           int choice;
           string menu = \"enter the number corresponding to the patient\'s insurance company\ \";
           for (int i=0; i < insuranceNames.Length; i++)
           {
               menu += i+1+\". \"+insuranceNames[i]+\"\ \";
           }
           menu += \"\ $ \";
          
           Console.Write(menu);
          
           while (!Int32.TryParse(Console.ReadLine(),out choice))
           {
               Console.WriteLine(\"error. please enter the number next to the insurance option that most closely matches the patient\'s situation\");
               Console.Write(menu);
              
           }
           name = insuranceNames[choice -1];
       }

   }
}


Patient.cs

using System;
namespace PatientLib
{
   public class Patient : IComparable
   {
       protected int id,age;
       protected double amountDue;
       protected string name;
      
       public Patient (){}
      
       public Patient (int id, int age, double amountDue, string name)
       {
           this.Id = id;
           this.Age = age;
           this.AmountDue = amountDue;
           this.Name = name;
       }

       public int Id {
           get {
               return this.id;
           }
           set {
               id = value;
           }
       }

       public int Age {
           get {
               return this.age;
           }
           set {
               age = value;
           }
       }

       public virtual double AmountDue {
           get {
               return this.amountDue;
           }
           set {
               amountDue = value;
           }
       }

       public string Name {
           get {
               return this.name;
           }
           set {
               name = value;
           }
       }
      
       public override bool Equals (object obj)
       {
           if (obj == null)
               return false;
           if (ReferenceEquals (this, obj))
               return true;
           if (obj.GetType () != typeof(Patient))
               return false;
           Patient other = (Patient)obj;
           return Id == other.Id;
       }

       public override int GetHashCode ()
       {
           unchecked {
               return Id;
           }
       }
      
       public int CompareTo (object obj)
       {
           if (!(obj is Patient))
           {
               throw new ArgumentException (
                   \"can\'t compare objects of differing types\");
           }
           Patient p = (Patient) obj;
           if (this.Id == p.Id) return 0;
           return this.Id < p.Id ? 1: -1;
       }

      
       public override string ToString ()
       {
           // the hell is wrong w/ this line?
           //return string.Format (\"[Patient: Id={0}, Age={1}, AmountDue={2}, Name={3}]\",
               //Id, Age, AmountDue.ToString, Name);
           string tmp = string.Format(\"[Patient: Id={0}, Age={1}, AmountDue={2}, Name={3}]\",Id,Age,AmountDue.ToString(\"C\"),Name);
           return tmp;
       }
          
       public static void GetPatientId(out int id)
       {
           string message = \"enter the patient\'s id number\ $ \";
           Console.Write (message);
           while (!Int32.TryParse(Console.ReadLine(),out id)) {
               Console.WriteLine(\"error, please enter a number for the patient\'s id\");  
               Console.Write (message);
           }
       }
      
       public static void GetPatientName(out string name)
       {
           string message = \"enter the patient\'s name\ $ \";
           Console.Write (message);
           name = Console.ReadLine();
       }
      
       public static void GetPatientAmtOwed(out double amt)
       {
           string message = \"enter the amount owed by the patient\ $ \";
           Console.Write (message);
           while (!Double.TryParse(Console.ReadLine(),out amt)) {
               Console.WriteLine(\"error, please enter a number for the amount owed by the patient\");
               Console.Write(message);
           }
       }
      
       public static void GetPatientAge(out int age)
       {
           string message = \"enter the patient\'s age\ $ \";
           Console.Write(message);
           while (!Int32.TryParse(Console.ReadLine(),out age)) {
               Console.WriteLine(\"error, please enter a number for the patient\'s age\");
               Console.Write(message);
           }
       }

   }
}

Assignment 2: Patient Data Create a Patient class for the Wrightstown Hospital Billing Department. Include a patient ID number, name, age, and amount due to the
Assignment 2: Patient Data Create a Patient class for the Wrightstown Hospital Billing Department. Include a patient ID number, name, age, and amount due to the
Assignment 2: Patient Data Create a Patient class for the Wrightstown Hospital Billing Department. Include a patient ID number, name, age, and amount due to the
Assignment 2: Patient Data Create a Patient class for the Wrightstown Hospital Billing Department. Include a patient ID number, name, age, and amount due to the
Assignment 2: Patient Data Create a Patient class for the Wrightstown Hospital Billing Department. Include a patient ID number, name, age, and amount due to the
Assignment 2: Patient Data Create a Patient class for the Wrightstown Hospital Billing Department. Include a patient ID number, name, age, and amount due to the
Assignment 2: Patient Data Create a Patient class for the Wrightstown Hospital Billing Department. Include a patient ID number, name, age, and amount due to the
Assignment 2: Patient Data Create a Patient class for the Wrightstown Hospital Billing Department. Include a patient ID number, name, age, and amount due to the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site