当前位置: 首页>>代码示例>>C#>>正文


C# Random.NextListElement方法代码示例

本文整理汇总了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)
     };
 }
开发者ID:ryanpeelman,项目名称:EMRG,代码行数:11,代码来源:PatientDemographicBuilder.cs

示例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);
        }
开发者ID:ryanpeelman,项目名称:EMRG,代码行数:28,代码来源:PatientProcedureBuilder.cs

示例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);
        }
开发者ID:ryanpeelman,项目名称:EMRG,代码行数:41,代码来源:PatientDiagnosisBuilder.cs

示例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);
 }
开发者ID:ryanpeelman,项目名称:EMRG,代码行数:6,代码来源:PatientDiagnosisBuilder.cs

示例5: GetRandomHeightInInches

 public int GetRandomHeightInInches(Random randomizer)
 {
     return randomizer.NextListElement(_weightInPoundsByHeightInInches.Keys.ToList());
 }
开发者ID:ryanpeelman,项目名称:EMRG,代码行数:4,代码来源:BodyMetricGenerator.cs


注:本文中的System.Random.NextListElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。