Esempio n. 1
0
        public IEnumerable<PatientTherapy> GetPatientTherapies(Fixture fixture, Random randomizer, PatientDemographics demographic, int maxNumberOfPatientTherapies)
        {
            fixture.Customize<PatientTherapy>(pt => pt.With(x => x.PatientId, demographic.PatientId)
                                                      .Without(x => x.DDID)
                                                      .Without(x => x.RXNorm)
                                                      .Without(x => x.StopDate));

            var therapies = fixture.CreateMany<PatientTherapy>(randomizer.Next(0, maxNumberOfPatientTherapies + 1));
            foreach (var therapy in therapies)
            {
                var daysOnTherapy = randomizer.Next(1, 365);
                therapy.StopDate = new DateTime(Math.Min(therapy.StartDate.AddDays(daysOnTherapy).Ticks, DateTime.Now.Ticks));

                var hasFavoredTherapy = randomizer.NextPercent() <= ChanceOfHavingFavoredCondition;
                if (hasFavoredTherapy)
                {
                    var pair = randomizer.NextDictionaryPair(_favoredTherapies);
                    therapy.NDC = pair.Key;
                    therapy.DrugName = pair.Value;
                }
                else
                {
                    therapy.NDC = NDCGenerator.GetRandomNDC(randomizer);
                }
            }

            return therapies.OrderBy(x => x.StartDate);
        }
Esempio n. 2
0
        public IEnumerable<PatientLab> GetPatientLabs(Fixture fixture, Random randomizer, PatientDemographics demographic, int maxNumberOfPatientLabs)
        {
            fixture.Customize<PatientLab>(pl => pl.With(x => x.PatientId, demographic.PatientId));

            var labs = fixture.CreateMany<PatientLab>(randomizer.Next(0, maxNumberOfPatientLabs + 1)).OrderBy(x => x.LabDate);
            foreach (var lab in labs)
            {
                var hasFavoredLab = randomizer.NextPercent() <= ChanceOfHavingFavoredLab;
                if (hasFavoredLab)
                {
                    var pair = randomizer.NextDictionaryPair(_favoredLabs);
                    lab.LabName = pair.Key.Replace("[NORMAL]", string.Empty).Replace("[ABNORMAL]", string.Empty);
                    lab.Value = pair.Value.Invoke(randomizer);
                }
            }

            return labs;
        }