Beispiel #1
0
        /// <summary>
        /// Formats the interval.
        /// </summary>
        /// <param name="cdaInterval">Interval</param>
        /// <returns>Narrative text.</returns>
        public static string Format(CdaInterval cdaInterval)
        {
            if (cdaInterval == null)
            {
                return(null);
            }

            if (cdaInterval.ShowOngoingInNarrative.HasValue && cdaInterval.ShowOngoingInNarrative.Value)
            {
                return("(ongoing)");
            }

            if (cdaInterval.Type == IntervalType.Low || cdaInterval.Type == IntervalType.Value)
            {
                // Low
                return(cdaInterval.Low.NarrativeText());
            }
            if (cdaInterval.Type == IntervalType.Width)
            {
                // Width
                return(Format(cdaInterval.IntervalWidth));
            }
            if (cdaInterval.Type == IntervalType.LowWidth)
            {
                // Low/Width
                return(Format(cdaInterval.IntervalWidth) + " after " + cdaInterval.Low.NarrativeText());
            }
            if (cdaInterval.Type == IntervalType.LowHigh)
            {
                // Low/High
                return(cdaInterval.Low.NarrativeText() + " -> " + cdaInterval.High.NarrativeText());
            }
            if (cdaInterval.Type == IntervalType.Center)
            {
                // Center
                return(cdaInterval.Center.NarrativeText());
            }
            if (cdaInterval.Type == IntervalType.CenterWidth)
            {
                // Center/Width
                return(cdaInterval.Center.NarrativeText() + " " + Format(cdaInterval.IntervalWidth) + "");
            }
            if (cdaInterval.Type == IntervalType.High)
            {
                // High
                return(cdaInterval.High.NarrativeText());
            }
            if (cdaInterval.Type == IntervalType.HighWidth)
            {
                // High/Width
                return(Format(cdaInterval.IntervalWidth) + " before " + cdaInterval.High.NarrativeText());
            }

            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// Creates and Hydrates the reviewed medical history section for the Shared Health Summary
        ///
        /// Note: the data used within this method is intended as a guide and should be replaced.
        /// </summary>
        /// <returns>A Hydrated ReviewedMedicalHistory object</returns>
        private static IMedicalHistory CreateMedicalHistory(Boolean mandatorySectionsOnly)
        {
            var medicalHistory = BaseCDAModel.CreateMedicalHistory();

            if (!mandatorySectionsOnly)
            {
                // NOTE: This section demonstrates the different combinations of Procedure's, Medical History Item's & diagnosis
                var procedureList       = new List <Procedure>();
                var medicalHistoryItems = new List <IMedicalHistoryItem>();
                var diagnosisList       = new List <IProblemDiagnosis>();

                // Procedures
                var procedure1 = BaseCDAModel.CreateProcedure();
                procedure1.Comment           = "L Procedure Comment";
                procedure1.ProcedureName     = BaseCDAModel.CreateCodableText("301040004", CodingSystem.SNOMED, "Primary closed wire fixation of fracture");
                procedure1.ProcedureDateTime = CdaInterval.CreateLowHigh(new ISO8601DateTime(DateTime.Now.AddDays(-402), ISO8601DateTime.Precision.Day),
                                                                         new ISO8601DateTime(DateTime.Now.AddDays(-400), ISO8601DateTime.Precision.Day));
                procedure1.ShowOngoingInNarrative = true;
                procedureList.Add(procedure1);

                var prodcedure2 = BaseCDAModel.CreateProcedure();
                prodcedure2.Comment           = "Comment";
                prodcedure2.ProcedureName     = BaseCDAModel.CreateCodableText("388544006", CodingSystem.SNOMED, "Crab RAST");
                prodcedure2.ProcedureDateTime = CdaInterval.CreateLow(new ISO8601DateTime(DateTime.Now.AddDays(-400), ISO8601DateTime.Precision.Day));
                procedureList.Add(prodcedure2);

                // Uncategorised Medical History Items
                var medicalHistoryItem = BaseCDAModel.CreateMedicalHistoryItem();
                medicalHistoryItem.DateTimeInterval       = CdaInterval.CreateLow(new ISO8601DateTime(DateTime.Now.AddDays(-400), ISO8601DateTime.Precision.Day));
                medicalHistoryItem.ShowOngoingInNarrative = true;
                medicalHistoryItem.ItemDescription        = "Uncategorised Medical History item description";
                medicalHistoryItem.ItemComment            = "Item Comment";
                medicalHistoryItems.Add(medicalHistoryItem);

                var medicalHistoryItem1 = BaseCDAModel.CreateMedicalHistoryItem();
                medicalHistoryItem1.ShowOngoingInNarrative = true;
                medicalHistoryItem1.ItemDescription        = "Uncategorised Medical History item description here";
                medicalHistoryItem1.ItemComment            = "Item Comment";
                medicalHistoryItems.Add(medicalHistoryItem1);

                var medicalHistoryItem2 = BaseCDAModel.CreateMedicalHistoryItem();
                var ongoingInterval2    = CdaInterval.CreateLowHigh(
                    new ISO8601DateTime(DateTime.Now.AddDays(-400), ISO8601DateTime.Precision.Day),
                    new ISO8601DateTime(DateTime.Now.AddDays(0), ISO8601DateTime.Precision.Day));

                medicalHistoryItem2.DateTimeInterval = ongoingInterval2;
                medicalHistoryItem2.ItemDescription  = "Uncategorised Medical History item description here";
                medicalHistoryItem2.ItemComment      = "Item Comment";
                medicalHistoryItems.Add(medicalHistoryItem2);

                var medicalHistoryItem3 = BaseCDAModel.CreateMedicalHistoryItem();
                var ongoingInterval3    = CdaInterval.CreateHigh(new ISO8601DateTime(DateTime.Now.AddDays(200), ISO8601DateTime.Precision.Day));
                medicalHistoryItem3.DateTimeInterval = ongoingInterval3;
                medicalHistoryItem3.ItemDescription  = "Uncategorised Medical History item description here";
                medicalHistoryItem3.ItemComment      = "Item Comment 4";
                medicalHistoryItems.Add(medicalHistoryItem3);

                // Problem Diagnosis
                var diagnosis = BaseCDAModel.CreateProblemDiagnosis();

                // This fails Schematron - Ignore
                //diagnosis.ProblemDiagnosisIdentification = BaseCDAModel.CreateCodableText("57883007", CodingSystem.SNOMED, "Renin test diet",
                //"Renin test diet [Left, Right]", // NOTE: Qualifier codes must be provided as [value,value] in the codes original text for the narrative
                //new List<QualifierCode>
                //{
                //    // Qualifier Code
                //    BaseCDAModel.CreateQualifierCode(
                //        // Name
                //        BaseCDAModel.CreateCodableText("272741003", CodingSystem.SNOMED, "Laterality"),
                //        // Value
                //        BaseCDAModel.CreateCodableText("7771000", CodingSystem.SNOMED, "Left")
                //    ),

                //    // Qualifier Code
                //    BaseCDAModel.CreateQualifierCode(
                //        // Name
                //        BaseCDAModel.CreateCodableText("272741003", CodingSystem.SNOMED, "Laterality"),
                //        // Value
                //        BaseCDAModel.CreateCodableText("24028007", CodingSystem.SNOMED, "Right")
                //    )
                //});

                diagnosis.ProblemDiagnosisIdentification = BaseCDAModel.CreateCodableText("57883007", CodingSystem.SNOMED, "Renin test diet", "Renin test diet [Left, Right]");

                diagnosis.DateOfOnset = new ISO8601DateTime(DateTime.Now.AddYears(-2), ISO8601DateTime.Precision.Day);
                diagnosis.DateOfResolutionRemission = new ISO8601DateTime(DateTime.Now.AddYears(-1), ISO8601DateTime.Precision.Day);
                diagnosis.Comment = "Comment";
                diagnosis.ShowOngoingDateInNarrative = true;
                diagnosisList.Add(diagnosis);

                var diagnosis1 = SharedHealthSummary.CreateProblemDiagnosis();
                diagnosis1.ProblemDiagnosisIdentification = BaseCDAModel.CreateCodableText("72940007", CodingSystem.SNOMED, "Acute abscess of areola");
                diagnosisList.Add(diagnosis1);

                var diagnosis2 = SharedHealthSummary.CreateProblemDiagnosis();
                diagnosis2.ProblemDiagnosisIdentification = BaseCDAModel.CreateCodableText("36083008", CodingSystem.SNOMED, "Sick sinus syndrome");
                diagnosisList.Add(diagnosis2);

                var diagnosis3 = SharedHealthSummary.CreateProblemDiagnosis();
                diagnosis3.Comment = "Diuretic induced";
                diagnosis3.ProblemDiagnosisIdentification = BaseCDAModel.CreateCodableText("162311003", CodingSystem.SNOMED, "Heavy head");
                diagnosisList.Add(diagnosis3);

                var diagnosis4 = SharedHealthSummary.CreateProblemDiagnosis();
                diagnosis4.ProblemDiagnosisIdentification = BaseCDAModel.CreateCodableText("258245003", CodingSystem.SNOMED, "G4 grade");
                diagnosis4.DateOfResolutionRemission      = new ISO8601DateTime(DateTime.Parse("27 Feb 2007"), ISO8601DateTime.Precision.Day);
                diagnosisList.Add(diagnosis4);

                var diagnosis5 = SharedHealthSummary.CreateProblemDiagnosis();
                diagnosis5.ProblemDiagnosisIdentification = BaseCDAModel.CreateCodableText("396275006", CodingSystem.SNOMED, "Osteoarthritis");
                diagnosis5.DateOfOnset = new ISO8601DateTime(DateTime.Parse("01 Jan 2000"), ISO8601DateTime.Precision.Day);
                diagnosis5.ShowOngoingDateInNarrative = true;
                diagnosisList.Add(diagnosis5);

                var diagnosis6 = SharedHealthSummary.CreateProblemDiagnosis();
                diagnosis6.Comment = "Cementless";
                diagnosis6.ProblemDiagnosisIdentification = BaseCDAModel.CreateCodableText("43408002", CodingSystem.SNOMED, "Red reflex");
                diagnosis6.DateOfOnset = new ISO8601DateTime(DateTime.Parse("27 Feb 2007"), ISO8601DateTime.Precision.Day);
                diagnosis6.ShowOngoingDateInNarrative = true;
                diagnosisList.Add(diagnosis6);

                var diagnosis7 = SharedHealthSummary.CreateProblemDiagnosis();
                diagnosis7.Comment = "T-score less than -3";
                diagnosis7.ProblemDiagnosisIdentification = BaseCDAModel.CreateCodableText("286114007", CodingSystem.SNOMED, "Does not do dusting");
                diagnosis7.DateOfOnset = new ISO8601DateTime(DateTime.Parse("01 Jan 2007"), ISO8601DateTime.Precision.Day);
                diagnosis7.ShowOngoingDateInNarrative = true;
                diagnosisList.Add(diagnosis7);

                var diagnosis8 = SharedHealthSummary.CreateProblemDiagnosis();
                diagnosis8.Comment = "Comment";
                diagnosis8.ProblemDiagnosisIdentification = BaseCDAModel.CreateCodableText("248515009", CodingSystem.SNOMED, "Lump in lid margin");
                diagnosis8.DateOfOnset = new ISO8601DateTime(DateTime.Parse("01 Aug 2010"), ISO8601DateTime.Precision.Day);
                diagnosis8.DateOfResolutionRemission = new ISO8601DateTime(DateTime.Parse("01 Sep 2010"), ISO8601DateTime.Precision.Day);
                diagnosisList.Add(diagnosis8);

                var diagnosis9 = SharedHealthSummary.CreateProblemDiagnosis();
                diagnosis9.Comment = "Diagnosis Comment";
                diagnosis9.ShowOngoingDateInNarrative     = true;
                diagnosis9.ProblemDiagnosisIdentification = BaseCDAModel.CreateCodableText("200608005", CodingSystem.SNOMED, "Boil of back");
                diagnosis9.DateOfOnset = new ISO8601DateTime(DateTime.Parse("01 Aug 2010"), ISO8601DateTime.Precision.Day);
                diagnosis9.DateOfResolutionRemission = new ISO8601DateTime(DateTime.Parse("01 Sep 2010"), ISO8601DateTime.Precision.Day);
                diagnosisList.Add(diagnosis9);

                var diagnosis10 = SharedHealthSummary.CreateProblemDiagnosis();
                diagnosis10.ProblemDiagnosisIdentification = BaseCDAModel.CreateCodableText("267032009", CodingSystem.SNOMED, "Tired all the time");
                diagnosis10.DateOfOnset = new ISO8601DateTime(DateTime.Parse("01 Aug 2010"), ISO8601DateTime.Precision.Day);
                diagnosis10.ShowOngoingDateInNarrative = true;
                diagnosisList.Add(diagnosis10);

                medicalHistory.MedicalHistoryItems = medicalHistoryItems;
                medicalHistory.Procedures          = procedureList;
                medicalHistory.ProblemDiagnosis    = diagnosisList;
            }
            else
            {
                // NOTE : NotAsked is not a valid entry in context of a Shared Health Summary
                medicalHistory.ProblemDiagnosisExclusionStatement       = BaseCDAModel.CreateStatement();
                medicalHistory.ProblemDiagnosisExclusionStatement.Value = NCTISGlobalStatementValues.NoneSupplied;

                medicalHistory.ProceduresExclusionStatement       = BaseCDAModel.CreateStatement();
                medicalHistory.ProceduresExclusionStatement.Value = NCTISGlobalStatementValues.NoneSupplied;
            }

            return(medicalHistory);
        }
Beispiel #3
0
        /// <summary>
        /// Creates and Hydrates the Diagnoses Intervention section for the Event Summary
        ///
        /// Note: the data used within this method is intended as a guide and should be replaced.
        /// </summary>
        /// <returns>A Hydrated DiagnosesIntervention object</returns>
        private static DiagnosesIntervention CreateDiagnosesIntervention(Boolean mandatorySectionsOnly)
        {
            var diagnosesInterventions = EventSummary.CreateDiagnosesInterventions();

            if (!mandatorySectionsOnly)
            {
                // NOTE: This section demonstrates the different combinations of Procedure's, Medical History Item's & diagnosis

                var procedureList       = new List <Procedure>();
                var medicalHistoryItems = new List <IMedicalHistoryItem>();
                var diagnosisList       = new List <IProblemDiagnosisEventSummary>();

                // Procedures
                var procedure = EventSummary.CreateProcedure();
                procedure.Comment           = "Procedure Comment";
                procedure.ProcedureName     = BaseCDAModel.CreateCodableText("301040004", CodingSystem.SNOMED, "Primary closed wire fixation of fracture");
                procedure.ProcedureDateTime = CdaInterval.CreateLowHigh(new ISO8601DateTime(DateTime.Now.AddDays(-402), ISO8601DateTime.Precision.Day), new ISO8601DateTime(DateTime.Now.AddDays(-400), ISO8601DateTime.Precision.Day));
                procedureList.Add(procedure);

                var prodcedure2 = EventSummary.CreateProcedure();
                prodcedure2.Comment           = "Comment";
                prodcedure2.ProcedureName     = BaseCDAModel.CreateCodableText("388544006", CodingSystem.SNOMED, "Crab RAST");
                prodcedure2.ProcedureDateTime = CdaInterval.CreateLow(new ISO8601DateTime(DateTime.Now.AddDays(-400), ISO8601DateTime.Precision.Day));
                procedureList.Add(prodcedure2);

                var prodcedure3 = EventSummary.CreateProcedure();
                prodcedure3.Comment                = "Comment";
                prodcedure3.ProcedureName          = BaseCDAModel.CreateCodableText("388544006", CodingSystem.SNOMED, "Crab RAST");
                prodcedure3.ProcedureDateTime      = CdaInterval.CreateHigh(new ISO8601DateTime(DateTime.Now.AddDays(-400), ISO8601DateTime.Precision.Day));
                prodcedure3.ShowOngoingInNarrative = true;
                procedureList.Add(prodcedure3);

                // Medical History Items
                var medicalHistoryItem = EventSummary.CreateMedicalHistoryItem();
                medicalHistoryItem.DateTimeInterval       = CdaInterval.CreateLow(new ISO8601DateTime(DateTime.Now.AddDays(-400), ISO8601DateTime.Precision.Day));
                medicalHistoryItem.ShowOngoingInNarrative = true;
                medicalHistoryItem.ItemDescription        = "Medical history item description";
                medicalHistoryItem.ItemComment            = "Medical History Item Comment";
                medicalHistoryItems.Add(medicalHistoryItem);

                var medicalHistoryItem1 = EventSummary.CreateMedicalHistoryItem();
                medicalHistoryItem1.ShowOngoingInNarrative = true;
                medicalHistoryItem1.ItemDescription        = "Medical history item description here";
                medicalHistoryItem1.ItemComment            = "Item Comment";
                medicalHistoryItems.Add(medicalHistoryItem1);

                var medicalHistoryItem2 = EventSummary.CreateMedicalHistoryItem();
                var ongoingInterval2    = CdaInterval.CreateLowHigh(
                    new ISO8601DateTime(DateTime.Now.AddDays(-400), ISO8601DateTime.Precision.Day),
                    new ISO8601DateTime(DateTime.Now.AddDays(200), ISO8601DateTime.Precision.Day));
                medicalHistoryItem2.DateTimeInterval = ongoingInterval2;
                medicalHistoryItem2.ItemDescription  = "Medical history item description here";
                medicalHistoryItem2.ItemComment      = "Item Comment";
                medicalHistoryItems.Add(medicalHistoryItem2);

                var medicalHistoryItem3 = EventSummary.CreateMedicalHistoryItem();
                var ongoingInterval3    = CdaInterval.CreateHigh(
                    new ISO8601DateTime(DateTime.Now.AddDays(200), ISO8601DateTime.Precision.Day));
                medicalHistoryItem3.DateTimeInterval = ongoingInterval3;
                medicalHistoryItem3.ItemDescription  = "Medical history item description here";
                medicalHistoryItem3.ItemComment      = "Item Comment";
                medicalHistoryItems.Add(medicalHistoryItem3);

                // Problem Diagnosis for Event Summary
                var diagnosis = EventSummary.CreateProblemDiagnosis();
                diagnosis.ProblemDiagnosisIdentification = BaseCDAModel.CreateCodableText("282859003", CodingSystem.SNOMED, "Able to maintain a sitting position", "Able to maintain a sitting position");

                diagnosis.DateOfOnset = new ISO8601DateTime(DateTime.Now.AddYears(-2), ISO8601DateTime.Precision.Day);
                diagnosis.Comment     = "Solved this";
                diagnosisList.Add(diagnosis);

                diagnosesInterventions.UncategorisedMedicalHistoryItem = medicalHistoryItems;
                diagnosesInterventions.Procedures       = procedureList;
                diagnosesInterventions.ProblemDiagnosis = diagnosisList;
            }

            return(diagnosesInterventions);
        }
Beispiel #4
0
        /// <summary>
        /// This is used for sorting purposes only in the narrative
        /// </summary>
        /// <param name="cdaInterval">Interval</param>
        /// <param name="showOngoingInNarrative">A Boolean of Show Ongoing In Narrative is set</param>
        /// <returns>Narrative text.</returns>
        public static DateTime GetFirstDateTimeOfDurrationForNarrativeSorting(CdaInterval cdaInterval, Boolean?showOngoingInNarrative)
        {
            if (showOngoingInNarrative.HasValue && showOngoingInNarrative.Value)
            {
                if (cdaInterval != null && cdaInterval.Low != null && cdaInterval.High == null)
                {
                    return(cdaInterval.Low.DateTime);
                }

                // NOTE: Add -1 day to nest the ongoing items correctly in the sorting order
                return(DateTime.MaxValue.AddDays(-1));
            }

            if (cdaInterval != null)
            {
                if (cdaInterval.Type == IntervalType.Low)
                {
                    // Low
                    return(cdaInterval.Low.DateTime);
                }
                if (cdaInterval.Type == IntervalType.LowWidth)
                {
                    // Low/Width
                    return(cdaInterval.Low.DateTime);
                }
                if (cdaInterval.Type == IntervalType.LowHigh)
                {
                    if (cdaInterval.Low != null)
                    {
                        return(cdaInterval.Low.DateTime);
                    }

                    if (cdaInterval.High != null)
                    {
                        return(cdaInterval.High.DateTime);
                    }
                }
                if (cdaInterval.Type == IntervalType.Center)
                {
                    // Center
                    return(cdaInterval.Center.DateTime);
                }
                if (cdaInterval.Type == IntervalType.CenterWidth)
                {
                    // Center/Width
                    return(cdaInterval.Center.DateTime);
                }
                if (cdaInterval.Type == IntervalType.High)
                {
                    // High
                    return(cdaInterval.High.DateTime);
                }
                if (cdaInterval.Type == IntervalType.HighWidth)
                {
                    // High/Width
                    return(cdaInterval.High.DateTime);
                }
            }

            return(DateTime.MaxValue);
        }