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


C# Random.NextPercent方法代码示例

本文整理汇总了C#中System.Random.NextPercent方法的典型用法代码示例。如果您正苦于以下问题:C# Random.NextPercent方法的具体用法?C# Random.NextPercent怎么用?C# Random.NextPercent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Random的用法示例。


在下文中一共展示了Random.NextPercent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: GetPatientTherapies

        public IEnumerable<PatientTherapy> GetPatientTherapies(Fixture fixture, Random randomizer, PatientDemographics demographic, int maxNumberOfPatientTherapies)
        {
            fixture.Customize<PatientTherapy>(pt => pt.With(x => x.PatientId, demographic.PatientId)
                                                      .Without(x => x.DDID)
                                                      .Without(x => x.RXNorm)
                                                      .Without(x => x.StopDate));

            var therapies = fixture.CreateMany<PatientTherapy>(randomizer.Next(0, maxNumberOfPatientTherapies + 1));
            foreach (var therapy in therapies)
            {
                var daysOnTherapy = randomizer.Next(1, 365);
                therapy.StopDate = new DateTime(Math.Min(therapy.StartDate.AddDays(daysOnTherapy).Ticks, DateTime.Now.Ticks));

                var hasFavoredTherapy = randomizer.NextPercent() <= ChanceOfHavingFavoredCondition;
                if (hasFavoredTherapy)
                {
                    var pair = randomizer.NextDictionaryPair(_favoredTherapies);
                    therapy.NDC = pair.Key;
                    therapy.DrugName = pair.Value;
                }
                else
                {
                    therapy.NDC = NDCGenerator.GetRandomNDC(randomizer);
                }
            }

            return therapies.OrderBy(x => x.StartDate);
        }
开发者ID:ryanpeelman,项目名称:EMRG,代码行数:28,代码来源:PatientTherapyBuilder.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: GetPatientLabs

        public IEnumerable<PatientLab> GetPatientLabs(Fixture fixture, Random randomizer, PatientDemographics demographic, int maxNumberOfPatientLabs)
        {
            fixture.Customize<PatientLab>(pl => pl.With(x => x.PatientId, demographic.PatientId));

            var labs = fixture.CreateMany<PatientLab>(randomizer.Next(0, maxNumberOfPatientLabs + 1)).OrderBy(x => x.LabDate);
            foreach (var lab in labs)
            {
                var hasFavoredLab = randomizer.NextPercent() <= ChanceOfHavingFavoredLab;
                if (hasFavoredLab)
                {
                    var pair = randomizer.NextDictionaryPair(_favoredLabs);
                    lab.LabName = pair.Key.Replace("[NORMAL]", string.Empty).Replace("[ABNORMAL]", string.Empty);
                    lab.Value = pair.Value.Invoke(randomizer);
                }
            }

            return labs;
        }
开发者ID:ryanpeelman,项目名称:EMRG,代码行数:18,代码来源:PatientLabBuilder.cs

示例5: GetBMI

        public double GetBMI(Random randomizer, bool obese = false, double? baseBMI = null)
        {
            var minimumBMI = obese ? MinimumObeseBMI : MinimumNormalBMI;
            var maximumBMI = obese ? MaximumObeseBMI : MaximumNormalBMI;

            var bmi = baseBMI ?? randomizer.Next(minimumBMI, maximumBMI + 1);
            if (baseBMI.HasValue)
            {
                var hasBMIChanged = randomizer.NextPercent() <= ChanceOfBMIChange;
                if (hasBMIChanged)
                {
                    var direction = randomizer.NextDouble() > 0.5 ? 1 : -1;
                    var delta = randomizer.Next(0, MaximumDelta + 1) * direction;
                    bmi += delta;
                }
            }

            return Math.Max(Math.Min(bmi, maximumBMI), minimumBMI);
        }
开发者ID:ryanpeelman,项目名称:EMRG,代码行数:19,代码来源:BodyMetricGenerator.cs

示例6: Main

        static void Main(string[] args)
        {
            var randomizer = new Random((int)DateTime.Now.Ticks);

            var allClaimsTherapies = new List<ClaimsTherapy>();
            var allClaimsUtilizations = new List<ClaimsUtilization>();
            var allPatientAllergies = new List<PatientAllergy>();
            var allPatientClinicals = new List<PatientClinical>();
            var allPatientDemographics = new List<PatientDemographics>();
            var allPatientDiagnoses = new List<PatientDiagnosis>();
            var allPatientLabs = new List<PatientLab>();
            var allPatientProcedures = new List<PatientProcedure>();
            var allPatientTherapies = new List<PatientTherapy>();
            var allPatientUtilizations = new List<PatientUtilization>();

            var fixture = new Fixture();
            fixture.Customizations.Add(new PatientSpecimenBuilder());

            int maxNumberOfClaimsTherapies = 5;
            int maxNumberOfClaimsUtilizations = 10;
            int maxNumberOfPatientAllergies = 5;
            int maxNumberOfPatientClinicals = 10;
            int maxNumberOfPatientDiagnoses = 10;
            int maxNumberOfPatientLabs = 20;
            int maxNumberOfPatientProcedures = 5;
            int maxNumberOfPatientTherapies = 20;
            int maxNumberOfPatientUtilizations = 15;
            int numberOfPatients = 50;
            for (int i = 0; i < numberOfPatients; i++)
            {
                var alcoholAbuse = fixture.Create<bool>();
                var drugAbuse = fixture.Create<bool>();
                var smoker = fixture.Create<bool>();

                var chanceOfObesity = 15;
                var obese = randomizer.NextPercent() < chanceOfObesity;

                var demographic = PatientDemographicBuilder.Instance.GetPatientDemographic(randomizer);
                var clinicals = PatientClinicalBuilder.Instance.GetPatientClinicals(fixture, randomizer, demographic, alcoholAbuse, drugAbuse, smoker, obese, maxNumberOfPatientClinicals);
                var utilizations = PatientUtilizationBuilder.Instance.GetPatientUtilizations(fixture, randomizer, demographic, maxNumberOfPatientUtilizations);
                var diagnoses = PatientDiagnosisBuilder.Instance.GetPatientDiagnoses(fixture, randomizer, demographic, maxNumberOfPatientDiagnoses);
                var labs = PatientLabBuilder.Instance.GetPatientLabs(fixture, randomizer, demographic, maxNumberOfPatientLabs);
                var therapies = PatientTherapyBuilder.Instance.GetPatientTherapies(fixture, randomizer, demographic, maxNumberOfPatientTherapies);
                var allergies = PatientAllergyBuilder.Instance.GetPatientAllergies(fixture, randomizer, demographic, maxNumberOfPatientAllergies);
                var procedures = PatientProcedureBuilder.Instance.GetPatientProcedures(fixture, randomizer, demographic, maxNumberOfPatientProcedures);
                var claimsUtilizations = ClaimsUtilizationBuilder.Instance.GetClaimsUtilizations(fixture, randomizer, demographic, alcoholAbuse, drugAbuse, maxNumberOfClaimsUtilizations);
                var claimsTherapies = ClaimsTherapyBuilder.Instance.GetClaimsTherapies(fixture, randomizer, demographic, alcoholAbuse, drugAbuse, maxNumberOfClaimsTherapies);

                allClaimsTherapies.AddRange(claimsTherapies);
                allClaimsUtilizations.AddRange(claimsUtilizations);
                allPatientAllergies.AddRange(allergies);
                allPatientClinicals.AddRange(clinicals);
                allPatientDemographics.Add(demographic);
                allPatientDiagnoses.AddRange(diagnoses);
                allPatientLabs.AddRange(labs);
                allPatientProcedures.AddRange(procedures);
                allPatientTherapies.AddRange(therapies);
                allPatientUtilizations.AddRange(utilizations);
            }

            string FOLDERPATH = "c:\\temp";
            string timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
            var writer = new CsvWriter();
            writer.WriteToFile($"{FOLDERPATH}\\{timestamp}.unofficial.patientdemographics.csv", allPatientDemographics);
            writer.WriteToFile($"{FOLDERPATH}\\{timestamp}.unofficial.patientclinicals.csv", allPatientClinicals);
            writer.WriteToFile($"{FOLDERPATH}\\{timestamp}.unofficial.patientutilizations.csv", allPatientUtilizations);
            writer.WriteToFile($"{FOLDERPATH}\\{timestamp}.unofficial.patientdiagnoses.csv", allPatientDiagnoses);
            writer.WriteToFile($"{FOLDERPATH}\\{timestamp}.unofficial.patientlabs.csv", allPatientLabs);
            writer.WriteToFile($"{FOLDERPATH}\\{timestamp}.unofficial.patienttherapies.csv", allPatientTherapies);
            writer.WriteToFile($"{FOLDERPATH}\\{timestamp}.unofficial.patientallergies.csv", allPatientAllergies);
            writer.WriteToFile($"{FOLDERPATH}\\{timestamp}.unofficial.patientprocedures.csv", allPatientProcedures);
            writer.WriteToFile($"{FOLDERPATH}\\{timestamp}.unofficial.claimstherapies.csv", allClaimsTherapies);
            writer.WriteToFile($"{FOLDERPATH}\\{timestamp}.unofficial.claimsutilizations.csv", allClaimsUtilizations);
        }
开发者ID:ryanpeelman,项目名称:EMRG,代码行数:74,代码来源:Program.cs


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