//Create
        public void Create(string name, DateTime dateOfBirth, List <string> morbidityGroupNames, MorbidityGroupRepository morbidityGroupRepository)
        {
            Patient patient = new Patient()
            {
                Name = name, DateOfBirth = dateOfBirth
            };

            patient.PatientMorbidityGroups = new List <PatientMorbidityGroup>();

            foreach (var morbidityGroupName in morbidityGroupNames)
            {
                MorbidityGroup morbidityGroup = morbidityGroupRepository.GetByName(morbidityGroupName);
                if (morbidityGroup != null)
                {
                    PatientMorbidityGroup patientMorbidityGroup = new PatientMorbidityGroup()
                    {
                        MorbidityGroup = morbidityGroup, Patient = patient
                    };
                    patient.PatientMorbidityGroups.Add(patientMorbidityGroup);
                    if (morbidityGroup.PatientMorbidityGroups == null)
                    {
                        morbidityGroup.PatientMorbidityGroups = new List <PatientMorbidityGroup>();
                    }
                    morbidityGroup.PatientMorbidityGroups.Add(patientMorbidityGroup);
                }
            }
            Insert(patient);
        }
        //GetAllInMorbidityGroup
        public IEnumerable <Patient> GetAllInMorbidityGroups(List <string> morbidityGroupNames, MorbidityGroupRepository morbidityGroupRepository)
        {
            var            patients         = GetAll();
            List <Patient> assignedPatients = new List <Patient>();
            int            groupCount;

            foreach (var patient in patients)
            {
                groupCount = 0;
                foreach (var morbidityGroupName in morbidityGroupNames)
                {
                    MorbidityGroup morbidityGroup = morbidityGroupRepository.GetByName(morbidityGroupName);
                    if (morbidityGroup != null)
                    {
                        if (FindMorbidityGroupForPatient(morbidityGroup, patient))
                        {
                            groupCount++;
                        }
                    }
                }
                if (groupCount == morbidityGroupNames.Count)
                {
                    assignedPatients.Add(patient);
                }
            }
            return(assignedPatients);
        }