當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。