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); }
public IEnumerable<PatientProcedure> GetPatientProcedures(Fixture fixture, Random randomizer, PatientDemographics demographic, int maxNumberOfPatientProcedures) { fixture.Customize<PatientProcedure>(pp => pp.With(x => x.PatientId, demographic.PatientId) .Without(x => x.CptHcpcs)); var procedures = fixture.CreateMany<PatientProcedure>(randomizer.Next(0, maxNumberOfPatientProcedures + 1)).ToList(); foreach (var procedure in procedures) { procedure.ProcedureDate = procedure.ProcedureDate.Date; var hasFavoredProcedure = randomizer.NextPercent() <= ChanceOfHavingFavoredProcedure; procedure.CptHcpcs = hasFavoredProcedure ? randomizer.NextListElement(_favoredProcedureCodes) : GetRandomProcedure(randomizer); var isProcedureRecent = randomizer.NextPercent() <= ChanceOfHavingRecentProcedure; if(isProcedureRecent) { var oldestRecentDateTime = DateTime.Today.AddMonths(-6); if(procedure.ProcedureDate < oldestRecentDateTime) { var maximumNumberOfDaysForRecent = (int)(DateTime.Today - oldestRecentDateTime).TotalDays; var daysAgo = randomizer.Next(1, maximumNumberOfDaysForRecent); procedure.ProcedureDate = DateTime.Today.AddDays(-daysAgo); } } } return procedures.OrderBy(x => x.ProcedureDate); }
public IEnumerable<PatientUtilization> GetPatientUtilizations(Fixture fixture, Random randomizer, PatientDemographics demographic, int maxNumberOfPatientUtilizations) { fixture.Customize<PatientUtilization>(pu => pu.With(x => x.PatientId, demographic.PatientId)); var utilizations = fixture.CreateMany<PatientUtilization>(randomizer.Next(0, maxNumberOfPatientUtilizations + 1)); return utilizations.OrderBy(x => x.ActivityDate); }
public IEnumerable<ClaimsUtilization> GetClaimsUtilizations(Fixture fixture, Random randomizer, PatientDemographics demographic, bool alcoholAbuse, bool drugAbuse, int maxNumberOfClaimsUtilizations) { fixture.Customize<ClaimsUtilization>(cu => cu.With(x => x.PatientId, demographic.PatientId) .With(x => x.Age, demographic.Age) .With(x => x.Gender, demographic.Gender) .With(x => x.Region, demographic.Region) .With(x => x.AlcoholAbuse, alcoholAbuse) .With(x => x.DrugAbuse, drugAbuse) .Without(x => x.ICD10)); var claimsUtilizations = fixture.CreateMany<ClaimsUtilization>(randomizer.Next(0, maxNumberOfClaimsUtilizations + 1)); return claimsUtilizations.OrderBy(x => x.ActivityDate); }
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; }
public IEnumerable<PatientAllergy> GetPatientAllergies(Fixture fixture, Random randomizer, PatientDemographics demographic, int maxNumberOfPatientAllergies) { fixture.Customize<PatientAllergy>(pa => pa.With(x => x.PatientId, demographic.PatientId) .Without(x => x.DDID) .Without(x => x.NDC) .Without(x => x.RXNorm)); var allergies = fixture.CreateMany<PatientAllergy>(randomizer.Next(0, maxNumberOfPatientAllergies + 1)); foreach(var allergy in allergies) { if (allergy.AllergyType == Enumerations.Allergy.Drug) { allergy.NDC = NDCGenerator.GetRandomNDC(randomizer); } } return allergies.OrderBy(x => x.DiagnosisDate); }
public IEnumerable<PatientClinical> GetPatientClinicals(Fixture fixture, Random randomizer, PatientDemographics demographic, bool alcoholAbuse, bool drugAbuse, bool smoker, bool obese, int maxNumberOfPatientClinicals) { fixture.Customize<PatientClinical>(pc => pc.With(x => x.PatientId, demographic.PatientId) .With(x => x.AlcoholAbuse, alcoholAbuse) .With(x => x.DrugAbuse, drugAbuse) .With(x => x.Smoker, smoker) .With(x => x.BMI, BodyMetricGenerator.Instance.GetBMI(randomizer, obese)) .Without(x => x.Weight)); var heightInInches = BodyMetricGenerator.Instance.GetRandomHeightInInches(randomizer); var clinicals = fixture.CreateMany<PatientClinical>(randomizer.Next(0, maxNumberOfPatientClinicals + 1)).ToList(); foreach (var clinical in clinicals) { clinical.BMI = BodyMetricGenerator.Instance.GetBMI(randomizer, obese, clinical.BMI); clinical.Weight = BodyMetricGenerator.Instance.GetWeightInKilograms(clinical.BMI, heightInInches); } return clinicals.OrderBy(x => x.ObservationDate); }
public IEnumerable<ClaimsTherapy> GetClaimsTherapies(Fixture fixture, Random randomizer, PatientDemographics demographic, bool alcoholAbuse, bool drugAbuse, int maxNumberOfClaimsTherapies) { fixture.Customize<ClaimsTherapy>(ct => ct.With(x => x.PatientId, demographic.PatientId) .With(x => x.Age, demographic.Age) .With(x => x.Gender, demographic.Gender) .With(x => x.Region, demographic.Region) .With(x => x.AlcoholAbuse, alcoholAbuse) .With(x => x.DrugAbuse, drugAbuse) .Without(x => x.DDID) .Without(x => x.RXNorm)); var claimsTherapies = fixture.CreateMany<ClaimsTherapy>(randomizer.Next(0, maxNumberOfClaimsTherapies + 1)).OrderBy(x => x.StartDate); foreach (var claimTherapy in claimsTherapies) { var daysOnTherapy = randomizer.Next(1, 365); claimTherapy.StopDate = new DateTime(Math.Min(claimTherapy.StartDate.AddDays(daysOnTherapy).Ticks, DateTime.Now.Ticks)); } return claimsTherapies.OrderBy(x => x.StartDate); }
public IEnumerable<PatientDiagnosis> GetPatientDiagnoses(Fixture fixture, Random randomizer, PatientDemographics demographic, int maxNumberOfPatientDiagnoses) { fixture.Customize<PatientDiagnosis>(pd => pd.With(x => x.PatientId, demographic.PatientId) .Without(x => x.DiagnosisDescription) .Without(x => x.ICD9) .Without(x => x.ICD10)); var diagnoses = fixture.CreateMany<PatientDiagnosis>(randomizer.Next(0, maxNumberOfPatientDiagnoses + 1)).ToList(); foreach (var diagnosis in diagnoses) { var hasFavoredDiagnosis = randomizer.NextPercent() <= ChanceOfHavingFavoredDiagnosis; var entry = hasFavoredDiagnosis ? GetSubsetEntry(randomizer, _favoredDiagnosisCodes) : randomizer.NextListElement(_icd9Entries); DecoratePatientDiagnosisFromICD9Entry(diagnosis, entry); } var hasInclusionDiagnosis = randomizer.NextPercent() <= ChanceOfHavingInclusionDiagnosis; if (hasInclusionDiagnosis) { var entry = GetSubsetEntry(randomizer, _inclusionDiagnosisCodes); if (entry != null) { var diagnosis = fixture.Create<PatientDiagnosis>(); DecoratePatientDiagnosisFromICD9Entry(diagnosis, entry); diagnoses.Add(diagnosis); } } var hasExclusionDiagnosis = randomizer.NextPercent() <= ChanceOfHavingExclusionDiagnosis; if (hasExclusionDiagnosis) { var entry = GetSubsetEntry(randomizer, _exclusionDiagnosisCodes); if (entry != null) { var diagnosis = fixture.Create<PatientDiagnosis>(); DecoratePatientDiagnosisFromICD9Entry(diagnosis, entry); diagnoses.Add(diagnosis); } } return diagnoses.OrderBy(x => x.DiagnosisDate); }