示例#1
0
        ///
        /// <summary>   Updates the display list.
        ///             Fills the HoH value with their information, followed by the family informaition underneath </summary>
        ///
        /// <remarks>   2019-04-20. </remarks>
        ///
        public void UpdateDisplayList()
        {
            if (lstSearchResults != null)       //Ensure list is null if it is not
            {
                lstSearchResults.Items.Clear(); //Clear the items
                scrollList.Height = 0;
            }

            //Format the head of household string to be listed in the the hoh of household tex block
            string k;

            k = String.Format("{0} {1}, {2}, {3}, {4}, {5}", hohFamily[0].FirstName, hohFamily[0].LastName, hohFamily[0].HCN, hohFamily[0].MInitial, hohFamily[0].DoB.ToLongDateString(), hohFamily[0].Gender);
            hohName.FontSize = 15;
            hohName.Text     = k;

            //Set the appropriate text boxes to the correct values
            headOfHousehold          = (Patient_HoH)hohFamily[0];
            addressTextBlock.Text    = headOfHousehold.AddressLine1;
            addressTwoTextBlock.Text = headOfHousehold.AddressLine2;
            cityTextBlock.Text       = headOfHousehold.City;
            provtextBlock.Text       = headOfHousehold.Province;
            pPCodeTextBlock.Text     = headOfHousehold.PostalCode;
            pNumTextBlock.Text       = headOfHousehold.Phone;


            int colourController = 0;

            foreach (Patient p in hohFamily.Skip(1)) //Skip the head of household
            {
                //Insert a list of fmaily members in the scrollviewer
                Label l = new Label();
                l.Content             = String.Format("{0} {1}, {2}, {3}, {4}, {5}", p.FirstName, p.LastName, p.HCN, p.MInitial, p.DoB.ToLongDateString(), p.Gender);
                l.FontSize            = 15;
                l.HorizontalAlignment = HorizontalAlignment.Center;

                //Alternate colours
                if (colourController % 2 == 0)
                {
                    l.Background = Brushes.White;
                }
                else
                {
                    l.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225));
                }
                colourController++;

                scrollList.Height += l.Height; //Adjust the height

                lstSearchResults.Items.Add(l);
            }
        }
        ///
        /// <summary>   Event handler. Called by SubmitBtn for click events.
        ///             ensures all required items are valid and then submits the request to
        ///             update the HoH or dependant</summary>
        ///
        /// <remarks>   2019-04-20. </remarks>
        ///
        /// <param name="sender">   Source of the event. </param>
        /// <param name="e">        Routed event information. </param>
        ///

        private void SubmitBtn_Click(object sender, RoutedEventArgs e)
        {
            bool passOrFail = false;

            if (CanSubmit()) //Ensure all required information was submitted.
            {
                //If any dependant information is not valid, set them to blank
                if (!addressBool)
                {
                    addressTextBox.Text = "";
                }
                if (!addressTwoBool)
                {
                    addressTwoTextbox.Text = "";
                }
                if (!cityBool)
                {
                    cityTextBox.Text = "";
                }
                if (provComboBox.SelectedIndex == 0)
                {
                    provComboBox.Text = "  ";
                }
                if (!pCodeBool)
                {
                    pCodeTextBox.Text = "";
                }
                if (!pNumberBool)
                {
                    pNumberTextBox.Text = "";
                }

                //Send either patient or dependent depending on type.
                //Send it to the factory
                if (patient.GetType() == typeof(Patient_HoH)) //patient is a hoh
                {
                    //If patient is HOH... See if a HOH is entered... Make patient a depenendant..  Then HCN_To_Dependant...
                    //Then update.
                    if (hohTextBox.Text != "" && hohEnteredBool) //Change hohTo Dependant
                    {
                        hohToDependant[0] = hcnTextBox.Text;
                        hohToDependant[1] = lNameTextBox.Text;
                        hohToDependant[2] = fNameTextBox.Text;
                        hohToDependant[3] = mInitialTextBox.Text;
                        hohToDependant[4] = dobPicker.Text;
                        hohToDependant[5] = Gender.ToString();
                        hohToDependant[6] = hohTextBox.Text;

                        passOrFail = Database.HoH_To_Dependant(hohToDependant); //See if the cahnge is allowed,
                        //Not allowed if the HoH has dependants themself


                        if (passOrFail)
                        {
                            //Get a new patient and update..
                            patientDependant = (Patient_Dependant)PatientFactory.Create(hohToDependant);
                            patientDependant.Update();
                        }
                        else
                        {
                            UpdateHoH();
                        }
                    }
                    else
                    {
                        UpdateHoH(); //HoH info did not change.. Update HoH
                    }
                }
                else
                {
                    //If PAtietn is dependant... No HoH is entered... We use Dependant_To_Hoh()... Then update after.. Otherwise just update what has been updated.
                    if (!hohEnteredBool)
                    {
                        dependantToHoh[2] = fNameTextBox.Text;
                        dependantToHoh[1] = lNameTextBox.Text;
                        dependantToHoh[0] = hcnTextBox.Text;
                        dependantToHoh[3] = mInitialTextBox.Text;
                        dependantToHoh[5] = Gender.ToString();
                        dependantToHoh[4] = dobPicker.Text;

                        dependantToHoh[6]  = addressTextBox.Text;
                        dependantToHoh[7]  = addressTwoTextbox.Text;
                        dependantToHoh[8]  = cityTextBox.Text;
                        dependantToHoh[10] = provComboBox.SelectedValue.ToString();
                        dependantToHoh[9]  = pCodeTextBox.Text;
                        dependantToHoh[11] = pNumberTextBox.Text;

                        //Make the dependent a HoH
                        Database.Dependant_To_HoH(dependantToHoh);

                        if (passOrFail)
                        {
                            //Create a new HoH
                            patientHoh = (Patient_HoH)PatientFactory.Create(dependantToHoh);

                            patientHoh.Update(); //Update the patient
                        }
                        else
                        {
                            UpdateDependant();
                        }
                    }
                    else //Hoh did not switch.. Update dependant.
                    {
                        UpdateDependant();
                    }
                }

                ResetBoxes();     //Reset all boxes
                StartNewSearch(); //Start a new search
            }
        }
        ///
        /// <summary>   Fill chart. Fills all the textboxes with the information that the user returned from
        ///             the search screen.</summary>
        ///
        /// <remarks>   2019-04-20. </remarks>
        ///

        public void FillChart()
        {
            //Fill All the textboxes.
            fNameTextBox.Text     = patient.FirstName;
            lNameTextBox.Text     = patient.LastName;
            hcnTextBox.Text       = patient.HCN;
            mInitialTextBox.Text  = patient.MInitial;
            dobPicker.DisplayDate = patient.DoB;
            dobPicker.Text        = patient.DoB.ToString();

            //Select the proper gender textboxes.
            if (patient.Gender == 'M')
            {
                maleButton.IsChecked = true;
                Gender = 'M';
            }
            else if (patient.Gender == 'F')
            {
                femaleButton.IsChecked = true;
                Gender = 'F';
            }
            else
            {
                otherButton.IsChecked = true;
                Gender = 'X';
            }

            //Fill in the patient's HOH details. Enable textboxes
            if (patient.GetType() == typeof(Patient_HoH))
            {
                patientHoh = (Patient_HoH)patient;

                addressTextBox.Text      = patientHoh.AddressLine1;
                addressTextBox.IsEnabled = true;

                addressTwoTextbox.Text      = patientHoh.AddressLine2;
                addressTwoTextbox.IsEnabled = true;
                //Prov selection.
                for (i = 0; i < provComboBox.Items.Count; i++)
                {
                    if (string.Compare(patientHoh.Province, provComboBox.Items[i].ToString()) == 0)
                    {
                        provComboBox.SelectedIndex = i;
                    }
                }
                if (patientHoh.Province == "  ")
                {
                    provComboBox.SelectedIndex = 0;
                }

                provComboBox.IsEnabled = true;

                pCodeTextBox.Text      = patientHoh.PostalCode;
                pCodeTextBox.IsEnabled = true;

                cityTextBox.Text      = patientHoh.City;
                cityTextBox.IsEnabled = true;

                pNumberTextBox.Text      = patientHoh.Phone;
                pNumberTextBox.IsEnabled = true;
            }
            //Fill in patients HoH details, do not make them modifiable.
            if (patient.GetType() == typeof(Patient_Dependant))
            {
                patientDependant = (Patient_Dependant)patient;
                hohTextBox.Text  = patientDependant.HoH_HCN;

                fillPatient = Database.HoH_GetAutoFill(patientDependant.HoH_HCN);

                addressTextBox.Text      = fillPatient[0];
                addressTextBox.IsEnabled = false;

                addressTwoTextbox.Text      = fillPatient[2];
                addressTwoTextbox.IsEnabled = false;

                cityTextBox.Text      = fillPatient[1];
                cityTextBox.IsEnabled = false;

                //Selection of the province
                for (i = 0; i < provComboBox.Items.Count; i++)
                {
                    if (string.Compare(fillPatient[4], provComboBox.Items[i].ToString()) == 0)
                    {
                        provComboBox.SelectedIndex = i;
                    }
                }

                if (fillPatient[4] == "  ")
                {
                    provComboBox.SelectedIndex = 0;
                }
                provComboBox.IsEnabled = false;

                pCodeTextBox.Text      = fillPatient[3];
                pCodeTextBox.IsEnabled = false;

                pNumberTextBox.Text      = fillPatient[5];
                pNumberTextBox.IsEnabled = false;
            }
        }