///<summary>Fills both the Specialty and Clinic combo boxes according to the available clinics to the user and the unused specialties for the patient. ///Only fills the combo box of clinics with clinics that are associated to specialties that have not been used for this patient yet. ///E.g. Even if the user has access to Clinic X, if there is already a clone of this patient for Clinic X, it will no longer show. ///Throws exceptions that should be shown to the user which should then be followed by closing the window.</summary> private void FillClinicComboBoxes() { _dictSpecialtyClinics = new Dictionary <long, List <Clinic> >(); //Fill the list of clinics for this user. List <Clinic> listClinicsForUser = Clinics.GetForUserod(Security.CurUser); //Make a deep copy of the list of clinics so that we can filter down to the clinics that have no specialty specified if all are hidden. List <Clinic> listClinicsNoSpecialty = listClinicsForUser.Select(x => x.Copy()).ToList(); //Fill the list of defLinks used by clones of this patient. List <long> listClonePatNum = PatientLinks.GetPatNumsLinkedFrom(_patientMaster.PatNum, PatientLinkType.Clone); List <DefLink> listPatCurDefLinks = DefLinks.GetListByFKeys(listClonePatNum, DefLinkType.Patient); //Fill the list of clinics defLink List <DefLink> listClinicDefLinks = DefLinks.GetDefLinksByType(DefLinkType.Clinic); //Filter out any specialties that are currently in use by clones of this patient. if (listPatCurDefLinks.Count > 0) { listClinicDefLinks.RemoveAll(x => x.DefNum.In(listPatCurDefLinks.Select(y => y.DefNum).ToList())); } //Get all non-hidden specialties List <Def> listSpecialtyDefs = Defs.GetDefsForCategory(DefCat.ClinicSpecialty, true); //If there are specialties present, we need to know which clinics have no specialty set so that the user can always make clones for that specialty. if (listSpecialtyDefs.Count > 0) { listClinicsNoSpecialty.RemoveAll(x => x.ClinicNum.In(listClinicDefLinks.Select(y => y.FKey).ToList())); } //Remove all clinics that do not have any specialties from the original list of clinics for the user. listClinicsForUser.RemoveAll(x => !x.ClinicNum.In(listClinicDefLinks.Select(y => y.FKey).ToList())); //Filter out any specialties that are not associated to any available clinics for this user. listSpecialtyDefs.RemoveAll(x => !x.DefNum.In(listClinicDefLinks.Select(y => y.DefNum).ToList())); //Lump all of the left over specialties into a dictionary and slap the associated clinics to them. comboSpecialty.Items.Clear(); //Create a dummy specialty of 0 if there are any clinics that do not have a specialty. if (listClinicsNoSpecialty != null && listClinicsNoSpecialty.Count > 0) { comboSpecialty.Items.Add(new ODBoxItem <Def>(Lan.g(this, "Unspecified"), new Def() { DefNum = 0 })); _dictSpecialtyClinics[0] = listClinicsNoSpecialty; } foreach (Def specialty in listSpecialtyDefs) { comboSpecialty.Items.Add(new ODBoxItem <Def>(specialty.ItemName, specialty)); //Get a list of all deflinks for the def List <DefLink> listLinkForDef = listClinicDefLinks.FindAll(x => x.DefNum == specialty.DefNum).ToList(); _dictSpecialtyClinics[specialty.DefNum] = listClinicsForUser.FindAll(x => x.ClinicNum.In(listLinkForDef.Select(y => y.FKey).ToList())); } //If there are no specialties to show, we need to let the user know that they need to associate at least one clinic to a specialty. if (_dictSpecialtyClinics.Count < 1) { MsgBox.Show(this, "This patient already has a clone for every Clinic Specialty available.\r\n" + "In the main menu, click Setup, Definitions, Clinic Specialties category to add new specialties.\r\n" + "In the main menu, click Lists, Clinics, and double click a clinic to set a Specialty."); DialogResult = DialogResult.Abort; return; } comboSpecialty.SelectedIndex = 0; FillComboClinic(); }
private void butClone_Click(object sender, EventArgs e) { if (!IsValid()) { return; //A message should have already shown to the user. } long clinicNum = 0; long defNum = 0; if (PrefC.HasClinicsEnabled) { clinicNum = ((ODBoxItem <Clinic>)comboClinic.SelectedItem).Tag.ClinicNum; } defNum = ((ODBoxItem <Def>)comboSpecialty.SelectedItem).Tag.DefNum; Patient clone = Patients.CreateCloneAndSynch(_patientMaster, _familyCur, _listInsPlans, _listInsSubs, _listBenefits, _provNumSelected, clinicNum); if (clone != null) { PatNumClone = clone.PatNum; if (defNum != 0) { DefLinks.Insert(new DefLink() { DefNum = defNum, FKey = PatNumClone, LinkType = DefLinkType.Patient, }); } } DialogResult = DialogResult.OK; }
///<summary>Used in the case when clinics are disabled. Requires special logic that doesn't use clinics.</summary> private void FillComboSpecialtyNoClinics() { //Get all non-hidden specialties List <Def> listSpecialtyDefs = Defs.GetDefsForCategory(DefCat.ClinicSpecialty, true); //Fill the list of defLinks used by clones of this patient. List <long> listClonePatNums = PatientLinks.GetPatNumsLinkedFrom(_patientMaster.PatNum, PatientLinkType.Clone); List <DefLink> listPatCurDefLinks = DefLinks.GetListByFKeys(listClonePatNums, DefLinkType.Patient); //Filter out any specialties that are currently in use by clones of this patient. if (listPatCurDefLinks.Count > 0) { listSpecialtyDefs.RemoveAll(x => x.DefNum.In(listPatCurDefLinks.Select(y => y.DefNum).ToList())); } comboSpecialty.Items.Clear(); //Create a dummy specialty of 0. Always allow the user to make Unspecified clones. comboSpecialty.Items.Add(new ODBoxItem <Def>(Lan.g(this, "Unspecified"), new Def() { DefNum = 0 })); foreach (Def specialty in listSpecialtyDefs) { comboSpecialty.Items.Add(new ODBoxItem <Def>(specialty.ItemName, specialty)); } comboSpecialty.SelectedIndex = 0; }
private void FormClinics_Load(object sender, System.EventArgs e) { if (ListClinics == null) { ListClinics = Clinics.GetAllForUserod(Security.CurUser); } if (_listClinicDefLinksAll == null) { _listClinicDefLinksAll = DefLinks.GetDefLinksByType(DefLinkType.Clinic); } ListClinicsOld = ListClinics.Select(x => x.Copy()).ToList(); _listClinicDefLinksAllOld = _listClinicDefLinksAll.Select(x => x.Copy()).ToList(); _listDefLinkClinicSpecialties = GetDefLinkClinicList(); _listClinicSpecialtyDefs = Defs.GetDefsForCategory(DefCat.ClinicSpecialty); checkOrderAlphabetical.Checked = PrefC.GetBool(PrefName.ClinicListIsAlphabetical); _dictClinicalCounts = Clinics.GetClinicalPatientCount(); if (IsSelectionMode) { butAdd.Visible = false; butOK.Visible = true; groupClinicOrder.Visible = false; groupMovePats.Visible = false; int widthDiff = (groupClinicOrder.Width - butOK.Width); this.MinimumSize = new Size(this.MinimumSize.Width - widthDiff, this.MinimumSize.Height); this.Width -= widthDiff; gridMain.Width += widthDiff; checkShowHidden.Visible = false; checkShowHidden.Checked = false; } else { if (checkOrderAlphabetical.Checked) { butUp.Enabled = false; butDown.Enabled = false; } else { butUp.Enabled = true; butDown.Enabled = true; } } if (IsMultiSelect) { butSelectAll.Visible = true; butSelectNone.Visible = true; gridMain.SelectionMode = GridSelectionMode.MultiExtended; } FillGrid(); for (int i = 0; i < gridMain.Rows.Count; i++) { if (ListSelectedClinicNums.Contains(((Clinic)gridMain.Rows[i].Tag).ClinicNum)) { gridMain.SetSelected(i, true); } } }
public static DefLink CreateDefLink(long defNum, long fKey, DefLinkType linkType) { DefLink defLink = new DefLink() { DefNum = defNum, FKey = fKey, LinkType = linkType, }; DefLinks.Insert(defLink); return(defLink); }
private void FormClinics_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (IsSelectionMode) { return; } bool hasClinicChanges = false; if (Clinics.Sync(ListClinics, ListClinicsOld)) { hasClinicChanges = true; } if (Prefs.UpdateBool(PrefName.ClinicListIsAlphabetical, checkOrderAlphabetical.Checked)) { DataValid.SetInvalid(InvalidType.Prefs); } _listClinicDefLinksAll.Clear(); foreach (DefLinkClinic defLinkClinic in _listDefLinkClinicSpecialties) { if (defLinkClinic.ListDefLink.Exists(x => x.DefLinkNum == 0)) { defLinkClinic.ListDefLink.ForEach(x => x.FKey = defLinkClinic.Clinic.ClinicNum); } _listClinicDefLinksAll.AddRange(defLinkClinic.ListDefLink); } if (DefLinks.Sync(_listClinicDefLinksAll, _listClinicDefLinksAllOld)) { hasClinicChanges = true; } //Joe - Now that we have called sync on ListClinics we want to make sure that each clinic has program properties for PayConnect and XCharge //We are doing this because of a previous bug that caused some customers to have over 3.4 million duplicate rows in their programproperty table long payConnectProgNum = Programs.GetProgramNum(ProgramName.PayConnect); long xChargeProgNum = Programs.GetProgramNum(ProgramName.Xcharge); //Don't need to do this for PaySimple, because these will get generated as needed in FormPaySimpleSetup bool hasChanges = ProgramProperties.InsertForClinic(payConnectProgNum, ListClinics.Select(x => x.ClinicNum) .Where(x => ProgramProperties.GetListForProgramAndClinic(payConnectProgNum, x).Count == 0).ToList()); hasChanges = ProgramProperties.InsertForClinic(xChargeProgNum, ListClinics.Select(x => x.ClinicNum) .Where(x => ProgramProperties.GetListForProgramAndClinic(xChargeProgNum, x).Count == 0).ToList()) || hasChanges;//prevent short curcuit if (hasChanges) { DataValid.SetInvalid(InvalidType.Programs); } if (hasClinicChanges) { DataValid.SetInvalid(InvalidType.Providers); } }
private void butDelete_Click(object sender, EventArgs e) { try { Defs.Delete(_defCur); //Web Sched New Pat Appt appointment type defs are associated to appointment type and operatory deflinks. Clean them up. DefLinks.DeleteAllForDef(_defCur.DefNum, DefLinkType.AppointmentType); DefLinks.DeleteAllForDef(_defCur.DefNum, DefLinkType.Operatory); IsDeleted = true; DialogResult = DialogResult.OK; } catch (ApplicationException ex) { MessageBox.Show(ex.Message); } }
public FormDefEditWSNPApptTypes(Def defCur) { InitializeComponent(); Lan.F(this); _defCur = defCur; checkHidden.Checked = _defCur.IsHidden; textName.Text = _defCur.ItemName; //Look for an associated appointment type. List <DefLink> listDefLinks = DefLinks.GetDefLinksByType(DefLinkType.AppointmentType); DefLink defLink = listDefLinks.FirstOrDefault(x => x.DefNum == _defCur.DefNum); if (defLink != null) { _apptTypeCur = AppointmentTypes.GetFirstOrDefault(x => x.AppointmentTypeNum == defLink.FKey); } FillTextValue(); }
private void FillGridWSNPAReasons() { List <Def> listDefs = Defs.GetDefsForCategory(DefCat.WebSchedNewPatApptTypes, true); List <DefLink> listDefLinks = DefLinks.GetDefLinksByType(DefLinkType.AppointmentType); List <AppointmentType> listApptTypes = AppointmentTypes.GetWhere(x => listDefLinks.Any(y => y.FKey == x.AppointmentTypeNum), true); //The combo box within the available times group box should always reflect the grid. comboWSNPADefApptType.Items.Clear(); gridWSNPAReasons.BeginUpdate(); gridWSNPAReasons.ListGridColumns.Clear(); gridWSNPAReasons.ListGridColumns.Add(new GridColumn(Lan.g(this, "Reason"), 120)); gridWSNPAReasons.ListGridColumns.Add(new GridColumn(Lan.g(this, "Pattern"), 0)); gridWSNPAReasons.ListGridRows.Clear(); GridRow row; foreach (Def def in listDefs) { AppointmentType apptType = null; DefLink defLink = listDefLinks.FirstOrDefault(x => x.DefNum == def.DefNum); if (defLink == null) { continue; //Corruption? } apptType = listApptTypes.FirstOrDefault(x => x.AppointmentTypeNum == defLink.FKey); if (apptType == null) { continue; //Corruption? } row = new GridRow(); row.Cells.Add(def.ItemName); row.Cells.Add((string.IsNullOrEmpty(apptType.Pattern) ? Lan.g(this, "(use procedure time pattern)") : Appointments.ConvertPatternFrom5(apptType.Pattern))); gridWSNPAReasons.ListGridRows.Add(row); comboWSNPADefApptType.Items.Add(def.ItemName, def); } gridWSNPAReasons.EndUpdate(); if (comboWSNPADefApptType.Items.Count > 0) { comboWSNPADefApptType.SelectedIndex = 0; //Select Default. } }
private void FormClinics_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (IsSelectionMode) { return; } if (Prefs.UpdateBool(PrefName.ClinicListIsAlphabetical, checkOrderAlphabetical.Checked)) { DataValid.SetInvalid(InvalidType.Prefs); } bool hasClinicChanges = Clinics.Sync(ListClinics, _listClinicsOld); //returns true if clinics were updated/inserted/deleted //Update the ClinicNum on all specialties associated to each clinic. ListClinics.ForEach(x => x.ListClinicSpecialtyDefLinks.ForEach(y => y.FKey = x.ClinicNum)); List <DefLink> listAllClinicSpecialtyDefLinks = ListClinics.SelectMany(x => x.ListClinicSpecialtyDefLinks).ToList(); hasClinicChanges |= DefLinks.Sync(listAllClinicSpecialtyDefLinks, _listClinicDefLinksAllOld); hasClinicChanges |= CorrectItemOrders(); //Joe - Now that we have called sync on ListClinics we want to make sure that each clinic has program properties for PayConnect and XCharge //We are doing this because of a previous bug that caused some customers to have over 3.4 million duplicate rows in their programproperty table long payConnectProgNum = Programs.GetProgramNum(ProgramName.PayConnect); long xChargeProgNum = Programs.GetProgramNum(ProgramName.Xcharge); //Don't need to do this for PaySimple, because these will get generated as needed in FormPaySimpleSetup bool hasChanges = ProgramProperties.InsertForClinic(payConnectProgNum, ListClinics.Select(x => x.ClinicNum).Where(x => ProgramProperties.GetListForProgramAndClinic(payConnectProgNum, x).Count == 0).ToList()); hasChanges |= ProgramProperties.InsertForClinic(xChargeProgNum, ListClinics.Select(x => x.ClinicNum).Where(x => ProgramProperties.GetListForProgramAndClinic(xChargeProgNum, x).Count == 0).ToList()); if (hasChanges) { DataValid.SetInvalid(InvalidType.Programs); } if (hasClinicChanges) { DataValid.SetInvalid(InvalidType.Providers); } }
private void butOK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textName.Text.Trim())) { MsgBox.Show(this, "Reason required."); return; } if (_apptTypeCur == null) { MsgBox.Show(this, "Appointment Type required."); return; } _defCur.ItemName = PIn.String(textName.Text); if (_defCur.IsNew) { Defs.Insert(_defCur); } else { Defs.Update(_defCur); } DefLinks.SetFKeyForDef(_defCur.DefNum, _apptTypeCur.AppointmentTypeNum, DefLinkType.AppointmentType); DialogResult = DialogResult.OK; }
private void FormClinics_Load(object sender, System.EventArgs e) { checkOrderAlphabetical.Checked = PrefC.GetBool(PrefName.ClinicListIsAlphabetical); if (ListClinics == null) { ListClinics = Clinics.GetAllForUserod(Security.CurUser); if (IncludeHQInList) { ListClinics.Insert(0, new Clinic() { ClinicNum = 0, Description = Lan.g(this, "Headquarters"), Abbr = Lan.g(this, "HQ") }); } //if alphabetical checkbox is checked/unchecked it triggers a pref cache refresh, but does not refill the clinic cache, so we need to sort here //in case the pref was changed since last time this was opened. ListClinics.Sort(ClinicSort); } _listClinicsOld = ListClinics.Select(x => x.Copy()).ToList(); _listClinicDefLinksAllOld = DefLinks.GetDefLinksByType(DefLinkType.Clinic); _dictClinicalCounts = new SerializableDictionary <long, int>(); if (IsSelectionMode) { butAdd.Visible = false; butOK.Visible = true; groupClinicOrder.Visible = false; groupMovePats.Visible = false; int widthDiff = (groupClinicOrder.Width - butOK.Width); MinimumSize = new Size(MinimumSize.Width - widthDiff, MinimumSize.Height); Width -= widthDiff; gridMain.Width += widthDiff; butSelectAll.Location = new Point(butSelectAll.Location.X + widthDiff, butSelectAll.Location.Y); butSelectNone.Location = new Point(butSelectNone.Location.X + widthDiff, butSelectNone.Location.Y); checkShowHidden.Visible = false; checkShowHidden.Checked = false; } else { if (checkOrderAlphabetical.Checked) { butUp.Enabled = false; butDown.Enabled = false; } _dictClinicalCounts = Clinics.GetClinicalPatientCount(); } if (IsMultiSelect) { butSelectAll.Visible = true; butSelectNone.Visible = true; gridMain.SelectionMode = GridSelectionMode.MultiExtended; } FillGrid(false); if (!ListSelectedClinicNums.IsNullOrEmpty()) { for (int i = 0; i < gridMain.ListGridRows.Count; i++) { if (ListSelectedClinicNums.Contains(((Clinic)gridMain.ListGridRows[i].Tag).ClinicNum)) { gridMain.SetSelected(i, true); } } } }