public PatientDemographics GetPatientDemographic(Random randomizer) { return new PatientDemographics() { PatientId = Guid.NewGuid().ToString(), Age = randomizer.Next(18, 90), Gender = randomizer.NextListElement(_gender), Race = randomizer.NextListElement(_race), Region = randomizer.NextListElement(_regions) }; }
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<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); }
private static ICD9Entry GetSubsetEntry(Random randomizer, List<string> codes) { var code = randomizer.NextListElement(codes); var entries = _icd9Entries.Where(x => x.ICD9Code.StartsWith(code)).ToList(); return randomizer.NextListElement(entries); }
public int GetRandomHeightInInches(Random randomizer) { return randomizer.NextListElement(_weightInPoundsByHeightInInches.Keys.ToList()); }