Beispiel #1
0
 private List <TBService> GetTbServices()
 {
     return(contextProvider.WithContext(context =>
     {
         return context.TbService
         .Where(tbService => !tbService.IsLegacy)
         .ToList();
     }));
 }
 public void Initialise()
 {
     countries          = contextProvider.WithContext(context => context.Country.ToList());
     ethnicities        = contextProvider.WithContext(context => context.Ethnicity.ToList());
     sexes              = contextProvider.WithContext(context => context.Sex.ToList());
     testPatientDetails = new Faker <PatientDetails>()
                          .RuleFor(p => p.FamilyName, f => f.Name.LastName())
                          .RuleFor(p => p.GivenName, f => f.Name.FirstName())
                          .RuleFor(p => p.NhsNumber, f => f.Random.ReplaceNumbers("9#########"))
                          .RuleFor(p => p.NhsNumberNotKnown, f => false)
                          .RuleFor(p => p.Dob, f => f.Date.Between(StartOf1920, EndOf2014))
                          .RuleFor(p => p.CountryId, f => countries.Single(c => c.IsoCode == Countries.UkCode).CountryId)
                          .RuleFor(p => p.YearOfUkEntry, f => null)
                          // It would be good to use real addresses, but a bit of extra work (there are too many postcodes to choose at random).
                          .RuleFor(p => p.NoFixedAbode, f => true)
                          .RuleFor(p => p.Address, f => null)
                          .RuleFor(p => p.Postcode, f => null)
                          .RuleFor(p => p.PostcodeToLookup, f => null)
                          .RuleFor(p => p.EthnicityId, f => f.PickRandom(ethnicities).EthnicityId)
                          .RuleFor(p => p.SexId, f => f.PickRandom(sexes).SexId);
 }
        public void Initialise()
        {
            hospitals  = contextProvider.WithContext(context => context.Hospital.Where(h => !h.IsLegacy).ToList());
            tbServices = contextProvider.WithContext(context =>
            {
                return(context.TbService
                       .Where(s => !s.IsLegacy && s.Code != LondonClinicCode)
                       .ToList());
            });
            caseManagers = contextProvider.WithContext(context =>
            {
                return(context.User
                       .Include(u => u.CaseManagerTbServices)
                       .Where(u => u.IsCaseManager)
                       .ToList());
            });

            testHospitalDetails = new Faker <HospitalDetails>()
                                  .RuleFor(h => h.TBServiceCode, f => f.PickRandom(tbServices).Code)
                                  .RuleFor(h => h.HospitalId, (f, hd) => f.PickRandom(hospitals.Where(h => h.TBServiceCode == hd.TBServiceCode)).HospitalId)
                                  .RuleFor(h => h.CaseManagerId, (f, hd) => f.PickRandom(caseManagers.Where(cm => cm.CaseManagerTbServices.Any(s => s.TbServiceCode == hd.TBServiceCode))).Id);
        }
Beispiel #4
0
        public void Initialise()
        {
            testTypes = contextProvider.WithContext(context =>
            {
                return(context.ManualTestType
                       .Include(tt => tt.ManualTestTypeSampleTypes)
                       .ToList());
            });

            testData = new Faker <TestData>()
                       .RuleFor(tr => tr.HasTestCarriedOut, f => f.Random.Bool(0.8f))
                       .RuleFor(tr => tr.ManualTestResults, GenerateResults);
        }
Beispiel #5
0
        public void GenerateNotifications(int numberOfNotificationsToGenerate)
        {
            Console.WriteLine("Initialising services...");
            patientDetailsGenerator = new PatientDetailsGenerator(contextProvider);
            patientDetailsGenerator.Initialise();

            hospitalDetailsGenerator = new HospitalDetailsGenerator(contextProvider);
            hospitalDetailsGenerator.Initialise();

            testResultGenerator = new TestResultGenerator(contextProvider);
            testResultGenerator.Initialise();

            // Split into batches to avoid performance degradation of having too much data in context.
            foreach (var batch in Enumerable.Range(0, numberOfNotificationsToGenerate).Batch(BatchSize))
            {
                var notifications = batch.Select(_ => GenerateNotification()).ToList();
                contextProvider.WithContext(context =>
                {
                    Console.WriteLine("Saving batch of notifications in database...");
                    context.AddRange(notifications);
                    context.SaveChanges();
                });
            }
        }