private void BtnUpdate_Click(object sender, RoutedEventArgs e)
 {
     Logging.Log("Patient data is updated using Edit Patient pop up window from PatientView page");
     patientToUpdate = (Patient)this.DataContext;
     demographics.UpdatePatient(patientToUpdate);
     BtnClose_Click(sender, e);
 }
        public void Functional_UpdatePatient()
        {
            // in this test we test that demographics class actually add the patient to database
            try
            {
                Demographics d = new Demographics();

                Patient p = new Patient(d);
                p.FirstName   = "Divyangbhai";
                p.LastName    = "Dankhara";
                p.HCN         = "0987654321AB";
                p.MInitial    = "A";
                p.DateOfBirth = "12111997";
                p.Sex         = "M";
                p.HeadOfHouse = "1234567890AB";

                d.AddNewPatient(p);
                p.LastName = "dankhara1";

                // here we are updating the patient that we have just added with new last name.
                d.UpdatePatient(p);

                Patient Dp = d.GetPatientByHCN(p.HCN);
                if (!(Dp.LastName == p.LastName))
                {
                    Assert.Fail();
                }
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }
 public void Null_UpdatePatient()
 {
     try
     {
         Demographics d = new Demographics();
         d.UpdatePatient(null);
     }
     catch (Exception)
     {
         Assert.Fail();
     }
 }
        /**
         * \brief <b>Brief Description</b> - Execute <b><i>class method</i></b> - Entry point into the update patient menu
         * \details <b>Details</b>
         *
         * This takes in the scheduling, demographics and billing libraries
         *
         * \return <b>void</b>
         */
        public void Execute(Scheduling scheduling, Demographics demographics, Billing billing)
        {
            // display the getting patient menu and get the requested patient
            Patient patient        = GetPatient.Get(MenuCodes.PATIENTS, "Patients", 1);
            Patient updatedPatient = new Patient();

            do
            {
                // check if the user canceled during the patient selection screen
                if (patient == null)
                {
                    break;
                }

                // run the get patient menu but instead of adding it to the database it returns it
                AddPatientCommand addPatientCommand = new AddPatientCommand();
                updatedPatient = addPatientCommand.Execute(patient.ShowInfo(), true, demographics);

                // check if the user canceled during data entry
                if (updatedPatient != null)
                {
                    // update the patient information in the database
                    updatedPatient.PatientID = patient.PatientID;
                    demographics.UpdatePatient(updatedPatient);

                    // display a success message
                    Container.DisplayContent(new List <Pair <string, string> >()
                    {
                        { new Pair <string, string>("Patient updated successfully.", "") }
                    },
                                             0, 1, MenuCodes.PATIENTS, "Patients", Description);

                    // wait for user to read message and confirm
                    Console.ReadKey();
                    break;
                }
                else
                {
                    // display error message
                    Container.DisplayContent(new List <Pair <string, string> >()
                    {
                        { new Pair <string, string>("An error was encountered while updating patient.", "") }
                    },
                                             0, 1, MenuCodes.PATIENTS, "Patients", Description);

                    // wait for user to read message and confirm
                    Console.ReadKey();
                    break;
                }
            } while (patient != null && updatedPatient != null);
        }