本文整理汇总了C#中System.Random.NextListElement方法的典型用法代码示例。如果您正苦于以下问题:C# Random.NextListElement方法的具体用法?C# Random.NextListElement怎么用?C# Random.NextListElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Random
的用法示例。
在下文中一共展示了Random.NextListElement方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPatientDemographic
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)
};
}
示例2: GetPatientProcedures
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);
}
示例3: GetPatientDiagnoses
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);
}
示例4: GetSubsetEntry
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);
}
示例5: GetRandomHeightInInches
public int GetRandomHeightInInches(Random randomizer)
{
return randomizer.NextListElement(_weightInPoundsByHeightInInches.Keys.ToList());
}