本文整理匯總了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());
}