コード例 #1
0
        private IEnumerable <DecisionSupportResult> PersistentMentalStatusCheck(Patient patient)
        {
            var results = new List <DecisionSupportResult>();

            if (patient.Data.PersistentMentalStatusChanges == Trilean.Yes ||
                patient.Data.CerebralContusionsSuspected == Trilean.Yes)
            {
                return(MriCheck(patient));
            }

            var dataNeeded = new List <string>();

            if (patient.Data.PersistentMentalStatusChanges == Trilean.Unknown)
            {
                dataNeeded.Add(nameof(Observations.PersistentMentalStatusChanges));
            }
            if (patient.Data.CerebralContusionsSuspected == Trilean.Unknown)
            {
                dataNeeded.Add(nameof(Observations.CerebralContusionsSuspected));
            }

            if (dataNeeded.Count > 0)
            {
                results.Add(DecisionSupportResult.NeedMoreData(RuleLabel, dataNeeded));
                return(results);
            }

            results.Add(DoNotHospitalize());
            return(results);
        }
        private IEnumerable <DecisionSupportResult> CheckMentalStatusOrPalpableSkullFracture(Patient patient,
                                                                                             ICollection <DecisionSupportResult> results)
        {
            if (patient.Data.SignsOfAlteredMentalStatus == Trilean.Yes ||
                patient.Data.SignsOfPalpableSkullFracture == Trilean.Yes)
            {
                results.Add(DecisionSupportResult.ActionRecommended(RuleLabel, CtRecommended));
                return(results);
            }
            if (patient.Data.SignsOfAlteredMentalStatus == Trilean.Unknown ||
                patient.Data.SignsOfPalpableSkullFracture == Trilean.Unknown)
            {
                var dataNeeded = new List <string>();
                if (patient.Data.SignsOfAlteredMentalStatus == Trilean.Unknown)
                {
                    dataNeeded.Add(nameof(patient.Data.SignsOfAlteredMentalStatus));
                }
                if (patient.Data.SignsOfPalpableSkullFracture == Trilean.Unknown)
                {
                    dataNeeded.Add(nameof(patient.Data.SignsOfPalpableSkullFracture));
                }

                results.Add(DecisionSupportResult.NeedMoreData(RuleLabel, dataNeeded));
                return(results);
            }
            return(CheckHematomaLocSevereInjuryOrAbnormalBehavior(patient, results));
        }
        private IEnumerable <DecisionSupportResult> CheckHematomaLocSevereInjuryOrAbnormalBehavior(Patient patient,
                                                                                                   ICollection <DecisionSupportResult> results)
        {
            var findings = new List <bool>
            {
                patient.Data.OptScalpHematoma == Trilean.Yes,
                patient.Data.LossOfConsciousness == Trilean.Yes &&
                patient.Data.LossOfConsciousnessTime.HasValue &&
                patient.Data.LossOfConsciousnessTime.Value >= TimeSpan.FromSeconds(5),
                patient.Data.SevereMechanismOfInjury == Trilean.Yes,
                patient.Data.AbnormalBehaviorPerParentalAssessment == Trilean.Yes
            };

            var findingCount = findings.Count(finding => finding);

            switch (findingCount)
            {
            case 0:
                if (patient.Data.OptScalpHematoma == Trilean.Unknown ||
                    patient.Data.LossOfConsciousness == Trilean.Unknown ||
                    (patient.Data.LossOfConsciousness == Trilean.Yes && patient.Data.LossOfConsciousnessTime == null) ||
                    patient.Data.SevereMechanismOfInjury == Trilean.Unknown ||
                    patient.Data.AbnormalBehaviorPerParentalAssessment == Trilean.Unknown)
                {
                    var dataNeeded = new List <string>();
                    if (patient.Data.OptScalpHematoma == Trilean.Unknown)
                    {
                        dataNeeded.Add(nameof(patient.Data.OptScalpHematoma));
                    }
                    if (patient.Data.LossOfConsciousness == Trilean.Unknown)
                    {
                        dataNeeded.Add(nameof(patient.Data.LossOfConsciousness));
                    }
                    if (patient.Data.LossOfConsciousness == Trilean.Yes && patient.Data.LossOfConsciousnessTime == null)
                    {
                        dataNeeded.Add(nameof(patient.Data.LossOfConsciousnessTime));
                    }
                    if (patient.Data.SevereMechanismOfInjury == Trilean.Unknown)
                    {
                        dataNeeded.Add(nameof(patient.Data.SevereMechanismOfInjury));
                    }
                    if (patient.Data.AbnormalBehaviorPerParentalAssessment == Trilean.Unknown)
                    {
                        dataNeeded.Add(nameof(patient.Data.AbnormalBehaviorPerParentalAssessment));
                    }

                    results.Add(DecisionSupportResult.NeedMoreData(RuleLabel, dataNeeded));
                    return(results);
                }
                results.Add(DecisionSupportResult.ActionRecommended(RuleLabel, CtNotRecommended));
                return(results);

            case 1:
                return(CheckWorseningSymptomsOrAge(patient, results));

            default:
                results.Add(DecisionSupportResult.ActionRecommended(RuleLabel, CtRecommended));
                return(results);
            }
        }
        private IEnumerable <DecisionSupportResult> CheckMentalStatusOrBasilarSkullFracture(Patient patient,
                                                                                            ICollection <DecisionSupportResult> results)
        {
            if (patient.Data.SignsOfAlteredMentalStatus == Trilean.Yes ||
                patient.Data.SignsOfBasilarSkullFracture == Trilean.Yes)
            {
                results.Add(DecisionSupportResult.ActionRecommended(RuleLabel, CtRecommended));
                return(results);
            }
            if (patient.Data.SignsOfAlteredMentalStatus == Trilean.Unknown ||
                patient.Data.SignsOfBasilarSkullFracture == Trilean.Unknown)
            {
                var dataNeeded = new List <string>();
                if (patient.Data.SignsOfAlteredMentalStatus == Trilean.Unknown)
                {
                    dataNeeded.Add(nameof(patient.Data.SignsOfAlteredMentalStatus));
                }
                if (patient.Data.SignsOfBasilarSkullFracture == Trilean.Unknown)
                {
                    dataNeeded.Add(nameof(patient.Data.SignsOfBasilarSkullFracture));
                }

                results.Add(DecisionSupportResult.NeedMoreData(RuleLabel, dataNeeded));
                return(results);
            }
            return(CheckLocVomitingSevereInjuryOrHeadache(patient, results));
        }
        public async Task <IEnumerable <DecisionSupportResult> > EvaluateAsync(Patient patient)
        {
            await Task.Delay(10); // TODO: remove this if other async methodology included

            var results = new List <DecisionSupportResult>();

            if (patient.Data.CtImagingTaken == Trilean.Yes)
            {
                results.Add(DecisionSupportResult.NoAction(RuleLabel));
                return(results);
            }

            switch (patient.Data.GlasgowComaScale)
            {
            case 15:
                // gcs is 15, so check age
                return(CheckAge(patient, results));

            case var gcs when gcs == 13 || gcs == 14:
                results.Add(DecisionSupportResult.ActionRecommended(RuleLabel, CtRecommended));
                return(results);

            case null:
                results.Add(DecisionSupportResult.NeedMoreData(RuleLabel, nameof(patient.Data.GlasgowComaScale)));
                return(results);

            default:
                results.Add(DecisionSupportResult.NoAction(RuleLabel));
                return(results);
            }
        }
        private IEnumerable <DecisionSupportResult> CheckWorseningSymptomsOrAge(Patient patient,
                                                                                ICollection <DecisionSupportResult> results)
        {
            if (patient.Data.WorseningSymptoms == Trilean.Yes ||
                (!Equals(patient.Age, null) && patient.Age < ThreeMonthsOfAge))
            {
                results.Add(DecisionSupportResult.ActionRecommended(RuleLabel, CtRecommended));
                return(results);
            }
            if (patient.Data.WorseningSymptoms == Trilean.Unknown ||
                Equals(patient.Age, null))
            {
                var dataNeeded = new List <string>();
                if (patient.Data.WorseningSymptoms == Trilean.Unknown)
                {
                    dataNeeded.Add(nameof(patient.Data.WorseningSymptoms));
                }
                if (Equals(patient.Age, null))
                {
                    dataNeeded.Add(nameof(patient.Age));
                }

                results.Add(DecisionSupportResult.NeedMoreData(RuleLabel, dataNeeded));
                return(results);
            }

            results.Add(DecisionSupportResult.ActionRecommended(RuleLabel, ObservationInHospital));
            return(results);
        }
コード例 #7
0
        private static IEnumerable <DecisionSupportResult> MriRecommendedResults()
        {
            var results = new DecisionSupportResult[2];

            results[0] = DecisionSupportResult.ActionRecommended(RuleLabel, MriRecommended);
            results[1] = DecisionSupportResult.NeedMoreData(RuleLabel, nameof(Observations.MriTaken));
            return(results);
        }
        private IEnumerable <DecisionSupportResult> CheckLocVomitingSevereInjuryOrHeadache(Patient patient,
                                                                                           ICollection <DecisionSupportResult> results)
        {
            if (patient.Data.LossOfConsciousness == Trilean.Unknown ||
                patient.Data.Vomiting == Trilean.Unknown ||
                patient.Data.SevereMechanismOfInjury == Trilean.Unknown ||
                patient.Data.SevereHeadache == Trilean.Unknown)
            {
                var dataNeeded = new List <string>();
                if (patient.Data.LossOfConsciousness == Trilean.Unknown)
                {
                    dataNeeded.Add(nameof(patient.Data.LossOfConsciousness));
                }
                if (patient.Data.Vomiting == Trilean.Unknown)
                {
                    dataNeeded.Add(nameof(patient.Data.Vomiting));
                }
                if (patient.Data.SevereMechanismOfInjury == Trilean.Unknown)
                {
                    dataNeeded.Add(nameof(patient.Data.SevereMechanismOfInjury));
                }
                if (patient.Data.SevereHeadache == Trilean.Unknown)
                {
                    dataNeeded.Add(nameof(patient.Data.SevereHeadache));
                }

                results.Add(DecisionSupportResult.NeedMoreData(RuleLabel, dataNeeded));
                return(results);
            }

            var findings = new List <Trilean>
            {
                patient.Data.LossOfConsciousness,
                patient.Data.Vomiting,
                patient.Data.SevereMechanismOfInjury,
                patient.Data.SevereHeadache
            };

            var findingCount = findings.Count(finding => finding == Trilean.Yes);

            switch (findingCount)
            {
            case 0:
                results.Add(DecisionSupportResult.ActionRecommended(RuleLabel, CtNotRecommended));
                return(results);

            case 1:
                return(CheckWorseningSymptomsOrAge(patient, results));

            default:
                results.Add(DecisionSupportResult.ActionRecommended(RuleLabel, CtRecommended));
                return(results);
            }
        }
        private IEnumerable <DecisionSupportResult> CheckAge(Patient patient, ICollection <DecisionSupportResult> results)
        {
            switch (patient.Age)
            {
            case null:
                results.Add(DecisionSupportResult.NeedMoreData(RuleLabel, nameof(Patient.Age)));
                return(results);

            case var age when age < TwoYearsOfAge:
                return(CheckMentalStatusOrPalpableSkullFracture(patient, results));

            default:
                return(CheckMentalStatusOrBasilarSkullFracture(patient, results));
            }
        }
        public async Task <IEnumerable <DecisionSupportResult> > EvaluateAsync(Patient patient)
        {
            await Task.Delay(10); // TODO: remove this if other async methodology included

            var results = new List <DecisionSupportResult>();

            if (!patient.Data.RestRecommended.HasValue)
            {
                results.Add(DecisionSupportResult.NeedMoreData(RuleLabel, nameof(Observations.RestRecommended)));
            }
            else
            {
                results.Add(
                    patient.Data.RestRecommendedDays.HasValue
                        ? ManagementPlanRecommendation(
                        string.Format(DaysRestTemplate, patient.Data.RestRecommendedDays))
                        : DecisionSupportResult.NeedMoreData(RuleLabel, nameof(Observations.RestRecommendedDays)));
            }

            if (patient.Data.SevereHeadache == Trilean.Yes)
            {
                results.Add(ManagementPlanRecommendation(HeadacheDrugs));
            }

            if (patient.Data.LightNoiseSensitivity == Trilean.Yes)
            {
                results.Add(ManagementPlanRecommendation(SunglassesEarplugs));
            }

            if (!patient.Data.IncludeSchoolRecommendations.HasValue)
            {
                results.Add(DecisionSupportResult.NeedMoreData(RuleLabel, nameof(Observations.IncludeSchoolRecommendations)));
            }
            else if (patient.Data.IncludeSchoolRecommendations.Value)
            {
                results.Add(ManagementPlanRecommendation(SchoolRecommendations));
            }

            if (!string.IsNullOrWhiteSpace(patient.Data.CustomDischargeInstructions))
            {
                results.Add(ManagementPlanRecommendation(patient.Data.CustomDischargeInstructions));
            }

            return(results);
        }
コード例 #11
0
        private IEnumerable <DecisionSupportResult> CerebralContusionsFromBluntTraumaCheck(Patient patient)
        {
            var results = new List <DecisionSupportResult>();

            switch (patient.Data.MinorBluntHeadTraumaContusions)
            {
            case Trilean.Unknown:
                results.Add(DecisionSupportResult.NeedMoreData(RuleLabel, nameof(Observations.MinorBluntHeadTraumaContusions)));
                return(results);

            case Trilean.Yes:
                return(ContusionsSmallAndIsolatedCheck(patient));

            case Trilean.No:
                return(PersistentMentalStatusCheck(patient));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #12
0
        private IEnumerable <DecisionSupportResult> CtImagingTaken(Patient patient)
        {
            var results = new List <DecisionSupportResult>();

            switch (patient.Data.CtImagingResultsAbnormal)
            {
            case Trilean.Unknown:
                results.Add(DecisionSupportResult.NeedMoreData(RuleLabel, nameof(Observations.CtImagingResultsAbnormal)));
                return(results);

            case Trilean.Yes:
                results.Add(Hospitalize());
                return(results);

            case Trilean.No:
                return(CerebralContusionsFromBluntTraumaCheck(patient));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #13
0
        private IEnumerable <DecisionSupportResult> MriResultsCheck(Patient patient)
        {
            var results = new List <DecisionSupportResult>();

            switch (patient.Data.MriResultsAbnormal)
            {
            case Trilean.Unknown:
                results.Add(DecisionSupportResult.NeedMoreData(RuleLabel, nameof(Observations.MriResultsAbnormal)));
                break;

            case Trilean.Yes:
                results.Add(Hospitalize());
                break;

            case Trilean.No:
                results.Add(DoNotHospitalize());
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(results);
        }
コード例 #14
0
        public async Task <IEnumerable <DecisionSupportResult> > EvaluateAsync(Patient patient)
        {
            await Task.Delay(10); // TODO: remove this if other async methodology included

            var results = new List <DecisionSupportResult>();

            if ((patient.Data.MriTaken == Trilean.Yes && patient.Data.MriResultsAbnormal == Trilean.Yes) ||
                patient.Data.SevereSymptoms == Trilean.Yes ||
                patient.Data.ChronicDiseases == Trilean.Yes ||
                (patient.Data.GlasgowComaScale.HasValue && patient.Data.GlasgowComaScale.Value <= 13) ||
                (patient.Data.CtImagingTaken == Trilean.Yes && patient.Data.CtImagingResultsAbnormal == Trilean.Yes))
            {
                results.Add(Hospitalize());
                return(results);
            }

            // skull fracture and hematoma are single findings, so flatten all the possible results for each into a single count
            var findings = new Dictionary <string, Trilean>
            {
                { nameof(Observations.ConcussionHistory), patient.Data.ConcussionHistory },
                { nameof(Observations.SignsOfAlteredMentalStatus), patient.Data.SignsOfAlteredMentalStatus },
                { nameof(Observations.LossOfConsciousness), patient.Data.LossOfConsciousness },
                { nameof(Observations.Vomiting), patient.Data.Vomiting },
                { nameof(Observations.SevereHeadache), patient.Data.SevereHeadache },
                { nameof(Observations.SevereMechanismOfInjury), patient.Data.SevereMechanismOfInjury },
                { nameof(Observations.AbnormalBehaviorPerParentalAssessment), patient.Data.AbnormalBehaviorPerParentalAssessment }
            };
            var skullFractureFindings = new Dictionary <string, Trilean>
            {
                { nameof(Observations.SignsOfBasilarSkullFracture), patient.Data.SignsOfBasilarSkullFracture },
                { nameof(Observations.SignsOfPalpableSkullFracture), patient.Data.SignsOfPalpableSkullFracture },
                { nameof(Observations.SignsOfOtherSkullFracture), patient.Data.SignsOfOtherSkullFracture }
            };
            var hematomaFindings = new Dictionary <string, Trilean>
            {
                { nameof(Observations.OptScalpHematoma), patient.Data.OptScalpHematoma },
                { nameof(Observations.OtherScalpHematoma), patient.Data.OtherScalpHematoma }
            };

            var findingCount = findings.Count(finding => finding.Value == Trilean.Yes);

            if (skullFractureFindings.Any(sff => sff.Value == Trilean.Yes))
            {
                findingCount++;
            }
            if (hematomaFindings.Any(hf => hf.Value == Trilean.Yes))
            {
                findingCount++;
            }
            if (findingCount >= 3)
            {
                results.Add(Hospitalize());
                return(results);
            }

            var dataNeeded = new List <string>();

            dataNeeded.AddRange(findings.Merge(skullFractureFindings).Merge(hematomaFindings)
                                .Where(finding => finding.Value == Trilean.Unknown).Select(fm => fm.Key));
            if (patient.Data.SevereSymptoms == Trilean.Unknown)
            {
                dataNeeded.Add(nameof(Observations.SevereSymptoms));
            }
            if (patient.Data.ChronicDiseases == Trilean.Unknown)
            {
                dataNeeded.Add(nameof(Observations.ChronicDiseases));
            }
            if (patient.Data.MriTaken == Trilean.Yes && patient.Data.MriResultsAbnormal == Trilean.Unknown)
            {
                dataNeeded.Add(nameof(Observations.MriResultsAbnormal));
            }

            if (dataNeeded.Count > 0)
            {
                results.Add(DecisionSupportResult.NeedMoreData(RuleLabel, dataNeeded));
                return(results);
            }

            switch (patient.Data.CtImagingTaken)
            {
            case Trilean.Unknown:
                results.Add(DecisionSupportResult.NeedMoreData(RuleLabel, nameof(Observations.CtImagingTaken)));
                return(results);

            case Trilean.Yes:
                return(CtImagingTaken(patient));

            case Trilean.No:
                return(CtImagingNotTaken(patient));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }