private User CreateUserRecord(Clinic clinic, List <User> users, string role)
        {
            bool isMale = PeopleDataProvider.IsMale();

            var user = new User()
            {
                Id              = entityIdIncrement++,
                FirstName       = PeopleDataProvider.GetRandomFirstName(isMale),
                LastName        = PeopleDataProvider.GetRandomLastName(isMale),
                Photo           = GetBytesFromImage(GetNextPhotoUrl(isMale)),
                CanVisitWebSite = false,
                Clinic          = clinic,
                Patients        = new List <Patient>(),
                Role            = role
            };

            CreateUserLoginName(user, users);
            users.Add(user);
            clinic.Doctors.Add(user);
            return(user);
        }
        public void PopulatePatientInfoAndDemographics(Patient patient, DemoPatientState patientState)
        {
            var isMale    = PeopleDataProvider.IsMale();
            var firstName = PeopleDataProvider.GetRandomFirstName(isMale);
            var lastName  = PeopleDataProvider.GetRandomLastName(isMale);
            var initials  = firstName.Substring(0, 1) + lastName.Substring(0, 1);

            initials = initials.ToUpperInvariant();

            patient.PatientInitials = initials;

            if (patientState == DemoPatientState.NotEnrolled)
            {
                return;
            }
            int dice = randomGenerator.Next(100);

            if (dice < 97)
            {
                patient.IsActive = true;
            }


            //TODO: change per patient state
            patient.IsEnrolled = true;
            patient.EnrollDate = DateTime.Now.AddDays(-randomGenerator.Next(10) * (int)patientState);

            patient.RandomisationDate   = patient.EnrollDate.Value.AddDays(randomGenerator.Next(0, 2));
            patient.RandomisationNumber = randomGenerator.Next(10000);
            patient.IsCompleted         = true;


            //Baseline visit
            var baselineVisit = patient.Visits.First(v => v.VisitType == VisitType.Baseline);

            baselineVisit.ExpectedVisitDate = patient.RandomisationDate;
            if (patientState >= DemoPatientState.BaselineOnly)
            {
                SetRealVisitDateAndTime(baselineVisit);
            }
            //Day 1 Visit
            var day1Day = patient.Visits.First(v => v.VisitType == VisitType.Day1);

            day1Day.ExpectedVisitDate =
                (baselineVisit.VisitDate ?? baselineVisit.ExpectedVisitDate).Value.AddDays(randomGenerator.Next(3));
            if (patientState >= DemoPatientState.Day1Only)
            {
                SetRealVisitDateAndTime(day1Day);

                //Adverse Event section only for patients passed 1st day
                dice = randomGenerator.Next(100);
                if (dice > 85)
                {
                    AddAdverseEventVisit(patient);
                }
                if (dice > 95)
                {
                    AddAdverseEventVisit(patient);
                }
            }


            //Day 10 visit
            var day10Day = patient.Visits.First(v => v.VisitType == VisitType.Day10);

            day10Day.ExpectedVisitDate = (day1Day.VisitDate ?? day1Day.ExpectedVisitDate).Value.AddDays(10);
            if (patientState >= DemoPatientState.AllVisits)
            {
                SetRealVisitDateAndTime(day10Day);
            }


            PopulateBaselineVisit(baselineVisit, isMale);
            if (patientState == DemoPatientState.BaselineOnly)
            {
                return;
            }
            PopulateDay1Visit(day1Day, baselineVisit);

            if (patientState == DemoPatientState.Day1Only)
            {
                return;
            }
            PopulateDay10Visit(day10Day, day1Day);
        }