Ejemplo n.º 1
0
        public async void ViewItemClick()
        {
            if (SelectedItem == null)
            {
                return;
            }

            // Populate edit history from database
            var history = await db.GetReferralHistoryDetails(SelectedItem.ID);

            foreach (var entry in history)
            {
                HistoryData historyDataItem = new HistoryData
                {
                    EditTime = entry["editTime"],
                    Name     = entry["name"],
                    CAD      = entry["cad"],
                    Status   = entry["status"],
                    DOD      = entry["dod"],
                    ReqTime  = entry["reqTime"],
                    Nature   = entry["nature"],
                    Provider = entry["provider"]
                };
                ReferralHistory.Add(historyDataItem);
            }

            EditReferralItem = SelectedItem;
            string oldProvider = EditReferralItem.Provider;

            NewReferralDialog newReferralDialog = new NewReferralDialog()
            {
                Owner       = Application.Current.MainWindow,
                Title       = "Edit Referral Item Data",
                DataContext = this
            };

            if (EditReferralItem.Provider == "MAS")
            {
                newReferralDialog.RadioButton_MAS.IsChecked = true;
            }
            else
            {
                newReferralDialog.RadioButton_Logisticare.IsChecked = true;
            }

            if (newReferralDialog.ShowDialog() == true)
            {
                // Cleanup the referral object
                EditReferralItem.PatientName   = EditReferralItem.PatientName.Trim();
                EditReferralItem.CAD           = EditReferralItem.CAD.Trim();
                EditReferralItem.RequestedTime = EditReferralItem.RequestedTime.Trim();
                EditReferralItem.Nature        = EditReferralItem.Nature.Trim();
                if (newReferralDialog.RadioButton_MAS.IsChecked == true)
                {
                    EditReferralItem.Provider = "MAS";
                }
                else
                {
                    EditReferralItem.Provider = "Logisticare";
                }

                await Task.Run(async() =>
                {
                    // Moved referral?  Drop event and reset CallStatus to an active state
                    if (oldProvider != EditReferralItem.Provider)
                    {
                        EditReferralItem.CallStatus = "Active";
                    }

                    var result             = await db.UpdateReferral(EditReferralItem);
                    StatusMessageAPIStatus = $"UpdateReferral: ID = {EditReferralItem.ID}, {result.Trim()}";
                    if (result.Trim() == "false")
                    {
                        MessageBox.Show("Referenced object is no longer flagged as active.  Edits cancelled",
                                        "Informational", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    }
                });

                // pop referral from observable collection if provider has changed
                if (oldProvider != EditReferralItem.Provider)
                {
                    ObservableCollection <ReferralData> obsCol;

                    if (EditReferralItem.Provider == "MAS")
                    {
                        obsCol = ReferralCollectionLogisticare;
                    }
                    else
                    {
                        obsCol = ReferralCollectionMAS;
                    }

                    var obj = obsCol.SingleOrDefault(a => a.ID == EditReferralItem.ID);
                    if (obj != null)
                    {
                        obsCol.Remove(obj);
                    }
                }
            }
            SelectedItem = null;
            ReferralHistory.Clear();
        }
Ejemplo n.º 2
0
        /*
         * UI Command Implementations
         */

        public async void NewReferralButtonClick()
        {
            EditReferralItem = new ReferralData
            {
                ID              = "0",
                PatientName     = string.Empty,
                CAD             = string.Empty,
                CallStatus      = "Active",
                DateOfDischarge = DateTime.Now.ToString("M-d-yyyy"),
                RequestedTime   = string.Empty,
                CallTaker       = Environment.UserName.ToLower(),
                Nature          = string.Empty,
                Provider        = string.Empty,
                CreatedDate     = DateTime.Now.ToString("M-d-yyyy"),
                CreatedTime     = DateTime.Now.ToString("HH:mm:ss")
            };

            NewReferralDialog newReferralDialog = new NewReferralDialog()
            {
                Owner       = Application.Current.MainWindow,
                DataContext = this
            };

            newReferralDialog.RadioButton_MAS.IsChecked = true;

            if (newReferralDialog.ShowDialog() == true)
            {
                if (EditReferralItem.PatientName == string.Empty)
                {
                    EditReferralItem.PatientName = "<none>";
                }
                if (EditReferralItem.CAD == string.Empty)
                {
                    EditReferralItem.CAD = "<none>";
                }
                if (EditReferralItem.RequestedTime == string.Empty)
                {
                    EditReferralItem.RequestedTime = "<none>";
                }
                if (EditReferralItem.Nature == string.Empty)
                {
                    EditReferralItem.Nature = "<none>";
                }
                if (newReferralDialog.RadioButton_MAS.IsChecked == true)
                {
                    EditReferralItem.Provider = "MAS";
                }
                else
                {
                    EditReferralItem.Provider = "Logisticare";
                }

                // Cleanup the referral object
                EditReferralItem.PatientName   = EditReferralItem.PatientName.Trim();
                EditReferralItem.CAD           = EditReferralItem.CAD.Trim();
                EditReferralItem.RequestedTime = EditReferralItem.RequestedTime.Trim();
                EditReferralItem.Nature        = EditReferralItem.Nature.Trim();

                await Task.Run(async() =>
                {
                    var result             = await db.InsertIntoCollection(EditReferralItem);
                    StatusMessageAPIStatus = result;
                });
            }
        }