示例#1
0
        ///<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();
        }
示例#2
0
        ///<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;
        }