Beispiel #1
0
        public List <MedicalHistory> Extract(CdaXmlDocument cdaDocument)
        {
            var medicalHistoryItems = new List <MedicalHistory>();

            var problemDiagnosis = LoadProblemDiagnosis(cdaDocument);

            if (problemDiagnosis != null && problemDiagnosis.Any())
            {
                medicalHistoryItems.AddRange(problemDiagnosis.ToArray());
            }

            var procedures = LoadProcedures(cdaDocument);

            if (procedures != null && procedures.Any())
            {
                medicalHistoryItems.AddRange(procedures.ToArray());
            }

            var otherMedicalHistoryItem = LoadOtherMedicalHistoryItems(cdaDocument);

            if (otherMedicalHistoryItem != null && otherMedicalHistoryItem.Any())
            {
                medicalHistoryItems.AddRange(otherMedicalHistoryItem.ToArray());
            }

            return(medicalHistoryItems.Any() ? medicalHistoryItems : null);
        }
        public DocumentMetadata Extract(CdaXmlDocument cdaDocument)
        {
            // Document code
            var documentCode = cdaDocument.GetCodableText(_documentXPaths.Get("DocumentCode"));

            // Effective time
            var effectiveDateTime = cdaDocument.GetDateTimeValue(_documentXPaths.Get("EffectiveTime"));

            // Document ID
            var documentId = cdaDocument.GetId(_documentXPaths.Get("DocumentId"));

            // Document Title from title field
            string title     = null;
            var    titleNode = cdaDocument.SelectSingleNode(_documentXPaths.Get("Title"));

            if (titleNode != null)
            {
                title = titleNode.InnerText;
            }

            Id linkId = cdaDocument.GetId(_documentXPaths.Get("LinkId"));

            var documentMetadata = new DocumentMetadata
            {
                TemplateId    = cdaDocument.TemplateId,
                DocumentCode  = documentCode,
                EffectiveTime = effectiveDateTime,
                DocumentId    = documentId,
                Title         = title,
                LinkId        = linkId
            };

            return(documentMetadata);
        }
        public List <Medication> Extract(CdaXmlDocument cdaDocument)
        {
            var medications     = new List <Medication>();
            var medicationNodes = cdaDocument.SelectNodes(_documentXPaths.Get("Medication"));

            if (medicationNodes == null)
            {
                return(null);
            }

            foreach (XmlNode medicationNode in medicationNodes)
            {
                var medication = new Medication();

                var medicineNode = cdaDocument.SelectSingleNode(medicationNode, _documentXPaths.Get("Medicine")) as XmlElement;

                medication.Medicine = cdaDocument.GetCodableText(medicineNode);

                medication.GenericName = cdaDocument.SelectSingleNode(medicationNode, _documentXPaths.Get("GenericName"))?.InnerText;

                var clinicalIndication = cdaDocument.SelectSingleNode(medicationNode, _documentXPaths.Get("ClinicalIndication"));

                medication.ClinicalIndications = clinicalIndication == null ? null : clinicalIndication.InnerText;

                var directions = cdaDocument.SelectSingleNode(medicationNode, _documentXPaths.Get("Directions"));

                medication.Directions = directions == null || string.IsNullOrWhiteSpace(directions.InnerText) ? null : directions.InnerText;

                medication.Strength = cdaDocument.SelectSingleNode(medicationNode, _documentXPaths.Get("Strength"))?.InnerText;

                if (directions != null)
                {
                    var directionsNullFlavourAttribute = directions.Attributes["nullFlavor"];

                    if (directionsNullFlavourAttribute != null)
                    {
                        medication.DirectionsNullFlavour = directionsNullFlavourAttribute.Value;
                    }
                }

                var comments = cdaDocument.SelectSingleNode(medicationNode,
                                                            _documentXPaths.Get("Comments"));
                medication.Comment = comments == null ? null : comments.InnerText;

                XmlNode nameNode = cdaDocument.SelectSingleNode(medicationNode, _documentXPaths.Get("GenericName"));
                if (nameNode != null)
                {
                    medication.GenericName = nameNode.InnerText;
                }

                medication.Status = cdaDocument.GetCodableText(medicationNode, _documentXPaths.Get("Status"));

                medications.Add(medication);
            }

            return(medications);
        }
Beispiel #4
0
        public AdvanceCareInformation Extract(CdaXmlDocument cdaDocument)
        {
            PersonName documentAuthorPersonName = null;
            PersonName personName = cdaDocument.GetPersonName(this._documentXPaths.Get("DocumentAuthorPersonName"));
            bool       flag       = personName != null;

            if (flag)
            {
                documentAuthorPersonName = personName;
            }
            return(new AdvanceCareInformation
            {
                DocumentAuthorPersonName = documentAuthorPersonName
            });
        }
Beispiel #5
0
        public SubjectOfCare Extract(CdaXmlDocument cdaDocument)
        {
            var subjectOfCare = new SubjectOfCare();

            var patientNode = cdaDocument.SelectSingleNode(_documentXPaths.Get("SubjectOfCare"));

            var identifier = cdaDocument.SelectSingleNode(patientNode, _documentXPaths.Get("SubjectOfCareIhi"));

            string ihi = null;

            if (identifier != null && identifier.Attributes != null && identifier.Attributes["root"] != null)
            {
                ihi = identifier.Attributes["root"].InnerText;
            }

            if (!String.IsNullOrWhiteSpace(ihi) && ihi.Contains("."))
            {
                ihi = ihi.Split('.').Last();
            }

            subjectOfCare.Ihi = ihi;

            var gender = cdaDocument.GetCodableText(patientNode, _documentXPaths.Get("SubjectOfCareAdministrativeGenderCode"));

            if (gender != null)
            {
                subjectOfCare.AdmnistrativeGenderCode = gender.Code;
            }

            var birthTime = cdaDocument.GetDateTimeValue(patientNode, _documentXPaths.Get("SubjectOfCareBirthTime"));

            subjectOfCare.BirthTime = birthTime == null ? null as DateTime? : birthTime.Value;

            var personName = cdaDocument.GetPersonName(_documentXPaths.Get("SubjectOfCarePersonName"));

            subjectOfCare.PersonName = personName;

            subjectOfCare.MedicareNumber = cdaDocument.GetString(_documentXPaths.Get("MedicareNumberEntityIdentifier"));

            if (string.IsNullOrWhiteSpace(subjectOfCare.MedicareNumber))
            {
                subjectOfCare.MedicareNumber = cdaDocument.GetString(_documentXPaths.Get("MedicareNumberEntitlements"));
            }

            subjectOfCare.DvaNumber = cdaDocument.GetString(_documentXPaths.Get("DvaNumber"));

            return(subjectOfCare);
        }
        public ConsumerNote Extract(CdaXmlDocument cdaDocument)
        {
            var noteTitleNode   = cdaDocument.SelectSingleNode(_documentXPaths.Get("NoteTitle"));
            var noteDescription = cdaDocument.SelectSingleNode(_documentXPaths.Get("NoteDescription"));

            if (noteTitleNode == null && noteDescription == null)
            {
                return(null);
            }

            var consumerNote = new ConsumerNote
            {
                Title       = noteTitleNode != null ? noteTitleNode.InnerText : null,
                Description = noteDescription != null ? noteDescription.InnerText : null,
            };

            return(consumerNote);
        }
Beispiel #7
0
        public List <Immunisation> Extract(CdaXmlDocument document)
        {
            var nodes = document.SelectNodes(_documentXPaths.Get("Immunisation"));

            if (nodes == null || nodes.Count == 0)
            {
                return(null);
            }

            return
                ((from XmlNode node in nodes
                  select new Immunisation
            {
                Medicine = document.GetRelativeCode(node, _documentXPaths.Get("ImmunisationItem")),
                SequenceNumber = document.GetString(node, _documentXPaths.Get("VaccineSequenceNumber")),
                DateTime = document.GetDateTimeValue(node, _documentXPaths.Get("MedicationActionDate"))
            }
                  ).ToList());
        }
Beispiel #8
0
        public List <AdverseReaction> Extract(CdaXmlDocument document)
        {
            var nodes = document.SelectNodes(_documentXPaths.Get("AdverseReactions"));

            if (nodes == null || nodes.Count == 0)
            {
                return(null);
            }

            return
                ((from XmlNode node in nodes
                  select new AdverseReaction
            {
                AdverseReactionId = document.GetString(node, _documentXPaths.Get("AdverseReactionsId")),
                SubstanceAgent = document.GetRelativeCode(node, _documentXPaths.Get("SubstanceAgent")),
                AdverseReactionType = document.GetRelativeCode(node, _documentXPaths.Get("AdverseReactionType")),
                Manifestations = document.GetListOfRelativeCodableText(node, _documentXPaths.Get("Manifestations"))
            }
                  ).ToList());
        }
Beispiel #9
0
        private IList <MedicalHistory> LoadProcedures(CdaXmlDocument cdaDocument)
        {
            IList <MedicalHistory> proceduresList = new List <MedicalHistory>();

            //ProcedureStartDateTime
            var proceduresNodes = cdaDocument.SelectNodes(_documentXPaths.Get("Procedures"));

            if (proceduresNodes != null)
            {
                foreach (XmlElement procedureNode in proceduresNodes)
                {
                    var proceduresItem = new MedicalHistory
                    {
                        MedicalHistoryItemType = MedicalHistoryType.Procedure
                    };

                    // Procedure name
                    proceduresItem.MedicalHistoryItem = cdaDocument.GetRelativeCode(procedureNode, _documentXPaths.Get("ProcedureName"));

                    // Procedure Comment
                    proceduresItem.Comment = cdaDocument.GetString(procedureNode, _documentXPaths.Get("ProcedureComment"));

                    // Date/time started
                    var startedDateTime = cdaDocument.GetDateTimeValue(procedureNode, _documentXPaths.Get("ProcedureStartDateTime"));

                    if (startedDateTime.HasValue)
                    {
                        proceduresItem.Interval = new Interval
                        {
                            Start = startedDateTime
                        };
                    }

                    proceduresList.Add(proceduresItem);
                }
            }

            return(proceduresList.Any() ? proceduresList : null);
        }
        public List <PharmaceuticalBenefitItem> Extract(CdaXmlDocument cdaDocument)
        {
            var pbsItems = new List <PharmaceuticalBenefitItem>();

            var pbsNodes = cdaDocument.SelectNodes(_documentXPaths.Get("PharmaceuticalBenefitItems"));

            if (pbsNodes == null)
            {
                return(null);
            }

            foreach (XmlNode pbsNode in pbsNodes)
            {
                var pbsItem = new PharmaceuticalBenefitItem();

                pbsItem.ItemCode = cdaDocument.GetCodableText(cdaDocument.SelectSingleNode(pbsNode, _documentXPaths.Get("ItemCode")) as XmlElement);

                pbsItem.ManufacturerCode = cdaDocument.GetString(cdaDocument.SelectSingleNode(pbsNode, _documentXPaths.Get("ManufacturerCode")) as XmlAttribute);

                pbsItem.Brand = cdaDocument.GetString(pbsNode, _documentXPaths.Get("Brand"));

                pbsItem.ItemGenericName = cdaDocument.GetString(cdaDocument.SelectSingleNode(pbsNode, _documentXPaths.Get("GenericName")) as XmlAttribute);

                pbsItem.ItemFormAndStrength = cdaDocument.GetString(pbsNode, _documentXPaths.Get("ItemFormAndStrength"));

                pbsItem.DateOfSupply = cdaDocument.GetDateTimeValue(pbsNode, _documentXPaths.Get("DateOfSupply"));

                pbsItem.DateOfPrescribing = cdaDocument.GetDateTimeValue(pbsNode, _documentXPaths.Get("DateOfPrescribing"));

                pbsItem.Quantity = cdaDocument.GetString(pbsNode, _documentXPaths.Get("Quantity"));

                pbsItem.NumberOfRepeats = cdaDocument.GetString(pbsNode, _documentXPaths.Get("NumberOfRepeats"));

                pbsItems.Add(pbsItem);
            }

            return(pbsItems);
        }
Beispiel #11
0
        private IList <MedicalHistory> LoadOtherMedicalHistoryItems(CdaXmlDocument cdaDocument)
        {
            IList <MedicalHistory> otherMedicalHistoryList = new List <MedicalHistory>();

            var otherMedicalHistoryItemNodes = cdaDocument.SelectNodes(_documentXPaths.Get("OtherMedicalHistoryItem"));

            if (otherMedicalHistoryItemNodes != null)
            {
                foreach (XmlElement historyItemNode in otherMedicalHistoryItemNodes)
                {
                    var otherMedicalHistoryItem = new MedicalHistory
                    {
                        MedicalHistoryItemType = MedicalHistoryType.OtherMedicalHistoryItem
                    };

                    // Medical History Item Description
                    var description = cdaDocument.GetString(historyItemNode, _documentXPaths.Get("OtherMedicalHistoryItemDescription"));
                    if (!string.IsNullOrWhiteSpace(description))
                    {
                        otherMedicalHistoryItem.MedicalHistoryItem = new CodableText {
                            OriginalText = description
                        };
                    }

                    // Medical History Item Time Interval
                    otherMedicalHistoryItem.Interval = cdaDocument.GetInterval(historyItemNode, _documentXPaths.Get("OtherMedicalHistoryItemTimeInterval"));

                    // Medical History Item Comment
                    otherMedicalHistoryItem.Comment = cdaDocument.GetString(historyItemNode, _documentXPaths.Get("OtherMedicalHistoryItemComment"));

                    otherMedicalHistoryList.Add(otherMedicalHistoryItem);
                }
            }

            return(otherMedicalHistoryList.Any() ? otherMedicalHistoryList : null);
        }
        public DiagnosticImaging Extract(CdaXmlDocument cdaDocument)
        {
            var di = new DiagnosticImaging();

            var diDocNode = cdaDocument.SelectSingleNode(_documentXPaths.Get("DIDocument"));

            var diReportDateTime = cdaDocument.GetDateTimeValue(diDocNode, _documentXPaths.Get("DIReportDateTime"));

            if (diReportDateTime != null)
            {
                di.ReportDateTime = diReportDateTime.Value;
            }

            var diReportDescription = cdaDocument.SelectSingleNode(diDocNode, _documentXPaths.Get("DIReportDescription"));

            if (diReportDescription != null)
            {
                di.ReportDescription = diReportDescription.InnerText;
            }

            var diReportStatus = cdaDocument.GetCodableText(diDocNode, _documentXPaths.Get("DIReportStatus"));

            di.ReportStatus = diReportStatus;

            var diReportIntegrityCheck = cdaDocument.SelectSingleNode(diDocNode, _documentXPaths.Get("DIReportIntegrityCheck"));

            if (diReportIntegrityCheck != null)
            {
                di.ReportIntegrityCheck = diReportIntegrityCheck.Value;
            }

            var diReportMediaType = cdaDocument.SelectSingleNode(diDocNode, _documentXPaths.Get("DIReportMediaType"));

            if (diReportMediaType != null)
            {
                di.ReportMediaType = diReportMediaType.Value;
            }

            var diReportDocName = cdaDocument.SelectSingleNode(diDocNode, _documentXPaths.Get("DIReportDocName"));

            if (diReportDocName != null)
            {
                di.ReportDocName = diReportDocName.Value;
            }

            var accessionNumber = cdaDocument.GetId(_documentXPaths.Get("AccessionNumber"));

            di.AccessionNumber = accessionNumber;

            var radXpath = _documentXPaths.Get("Radiologist");
            var radNode  = cdaDocument.SelectSingleNode(radXpath);

            var radiologistIdentifier = cdaDocument.SelectSingleNode(radNode, _documentXPaths.Get("RadiologistIdentifier"));

            if (radiologistIdentifier != null)
            {
                di.RadiologistIdentifier = radiologistIdentifier.Value.Replace("1.2.36.1.2001.1003.0.", "");
            }

            var radiologistOrganisationName = cdaDocument.SelectSingleNode(radNode, _documentXPaths.Get("RadiologistOrganisationName"));

            if (radiologistOrganisationName != null)
            {
                di.OrganisationName = radiologistOrganisationName.InnerText;
            }

            var radiologistOrganisationIdentifier = cdaDocument.SelectSingleNode(radNode, _documentXPaths.Get("RadiologistOrganisationIdentifier"));

            if (radiologistOrganisationIdentifier != null)
            {
                di.OrganisationIdentifier = radiologistOrganisationIdentifier.Value.Replace("1.2.36.1.2001.1003.0.", "");
            }

            if (radXpath != null)
            {
                List <Telecom> radiologistContactDetails = cdaDocument.GetTelecoms(radXpath + "/" + _documentXPaths.Get("RadiologistContactDetails"));
                if (radiologistContactDetails != null)
                {
                    di.ContactDetails = radiologistContactDetails;
                }

                var personName = cdaDocument.GetPersonName(radXpath + "/" + _documentXPaths.Get("RadiologistName"));
                if (personName != null)
                {
                    di.Radiologist = personName;
                }
            }

            // 1..* results
            di.ImagingExaminationResults = new List <ImagingExaminationResult>();

            var diTestResults = cdaDocument.SelectNodes(_documentXPaths.Get("DITestResults"));

            if (diTestResults != null && diTestResults.Count > 0)
            {
                foreach (XmlNode results in diTestResults)
                {
                    ImagingExaminationResult ier = new ImagingExaminationResult();
                    ier.ExamResultName       = cdaDocument.GetCodableText(results, _documentXPaths.Get("DIExamResultName"));
                    ier.Modality             = cdaDocument.GetCodableText(results, _documentXPaths.Get("DIModality"));
                    ier.AnatomicalRegion     = cdaDocument.GetCodableText(results, _documentXPaths.Get("DIAnatomicalRegion"));
                    ier.OverallResultStatus  = cdaDocument.GetCodableText(results, _documentXPaths.Get("DIOverallResultStatus"));
                    ier.ImageDateTime        = cdaDocument.GetDateTimeValue(results, _documentXPaths.Get("DIImageDateTime")).Value;
                    ier.ExaminationProcedure = cdaDocument.SelectSingleNode(results, _documentXPaths.Get("DIExaminationProcedure")).InnerText;
                    ier.ObservationDateTime  = cdaDocument.GetDateTimeValue(results, _documentXPaths.Get("DIObservationDateTime")).Value;
                    ier.AnatomicalSites      = new List <AnatomicalSite>();

                    var targetSiteCode = cdaDocument.SelectNodes(results, _documentXPaths.Get("DIAnatomicalSite"));

                    foreach (XmlNode anatomicalSite in targetSiteCode)
                    {
                        AnatomicalSite anSite = new AnatomicalSite();
                        anSite.NameOfLocation = cdaDocument.GetCodableText(anatomicalSite as XmlElement);
                        anSite.Side           = cdaDocument.GetCodableText(anatomicalSite, _documentXPaths.Get("DIAnatomicalSiteSide"));
                        anSite.Description    = anatomicalSite != null ? anSite.NameOfLocation.OriginalText : null;

                        ier.AnatomicalSites.Add(anSite);
                    }

                    di.ImagingExaminationResults.Add(ier);
                }
            }

            return(di);
        }
Beispiel #13
0
        public Author Extract(CdaXmlDocument cdaDocument)
        {
            // Author name
            PersonName authorName = null;
            PersonName personName = cdaDocument.GetPersonName(_documentXPaths.Get("AuthorPersonName"));

            if (personName != null)
            {
                authorName = personName;
            }

            // Telecom
            List <Telecom> telecoms = cdaDocument.GetTelecoms(_documentXPaths.Get("AuthorTelecoms"));

            // Author HPII
            string hpii         = null;
            var    idRootAttrib = cdaDocument.SelectSingleNode(_documentXPaths.Get("AuthorHpii"));

            if (idRootAttrib != null)
            {
                hpii = idRootAttrib.Value;
                hpii = hpii.Substring(hpii.Length - 16);
            }

            // Author IHI
            string ihi           = null;
            var    ihiRootAttrib = cdaDocument.SelectSingleNode(_documentXPaths.Get("AuthorIhi"));

            if (ihiRootAttrib != null)
            {
                ihi = ihiRootAttrib.Value;
                ihi = ihi.Substring(ihi.Length - 16);
            }

            // Organisation name
            string organisationName     = null;
            var    organisationNameElem = cdaDocument.SelectSingleNode(_documentXPaths.Get("AuthorOrganisationName"));

            if (organisationNameElem != null)
            {
                organisationName = organisationNameElem.InnerText;
            }

            // Organisation HPIO
            string hpio = null;
            var    organisationIdAttrib = cdaDocument.SelectSingleNode(_documentXPaths.Get("AuthorOrganisationHpio"));

            if (organisationIdAttrib != null)
            {
                hpio = organisationIdAttrib.Value;
                hpio = hpio.Substring(hpio.Length - 16);
            }

            var authorOrg = new Author
            {
                AuthorName       = authorName,
                AuthorHpii       = hpii,
                AuthorIhi        = ihi,
                OrganisationName = organisationName,
                OrganisationHpio = hpio,
                Telecoms         = telecoms
            };

            return(authorOrg);
        }
Beispiel #14
0
        private IList <MedicalHistory> LoadProblemDiagnosis(CdaXmlDocument cdaDocument)
        {
            IList <MedicalHistory> problemDiagnosiList = new List <MedicalHistory>();

            var problemDiagnosisNodes = cdaDocument.SelectNodes(_documentXPaths.Get("ProblemDiagnosis"));

            if (problemDiagnosisNodes != null)
            {
                foreach (XmlElement problemNode in problemDiagnosisNodes)
                {
                    var proceduresItem = new MedicalHistory
                    {
                        MedicalHistoryItemType = MedicalHistoryType.ProblemDiagnosis
                    };

                    // Problem Diagnosis Identification
                    proceduresItem.MedicalHistoryItem = cdaDocument.GetRelativeCode(problemNode, _documentXPaths.Get("ProblemDiagnosisIdentification"));

                    // Problem Diagnosis Comment
                    proceduresItem.Comment = cdaDocument.GetString(problemNode, _documentXPaths.Get("ProblemDiagnosisComment"));

                    // Medical History Type
                    proceduresItem.ProblemDiagnosisType = cdaDocument.GetRelativeCode(problemNode, _documentXPaths.Get("ProblemDiagnosisType"));

                    // Problem Diagnosis Date Of Onset
                    var onsetDateTime = cdaDocument.GetDateTimeValue(problemNode, _documentXPaths.Get("ProblemDiagnosisDateOfOnset"));

                    // Note: Date Of Resolution Remission has been mapped to a Date in the SCS even though it is an Interval.
                    //       There therefore is a need to check the LOW, HIGH and VALUE in that order and return the interval high value for the MedicalHistory Interval.

                    DateTime?dateOfResolution = null;
                    // Get Date Of Resolution Interval
                    var dateOfResolutionInterval = cdaDocument.GetInterval(problemNode, _documentXPaths.Get("ProblemDiagnosisDateOfResolutionRemission"));

                    if (dateOfResolutionInterval != null)
                    {
                        if (dateOfResolutionInterval.Start.HasValue)
                        {
                            dateOfResolution = dateOfResolutionInterval.Start;
                        }

                        if (dateOfResolutionInterval.End.HasValue)
                        {
                            dateOfResolution = dateOfResolutionInterval.End;
                        }
                    }

                    if (!dateOfResolution.HasValue)
                    {
                        // Get Date Of Resolution Attribute Value
                        dateOfResolution = cdaDocument.GetDateTimeValue(problemNode, string.Format("{0}{1}", _documentXPaths.Get("ProblemDiagnosisDateOfResolutionRemission"), "/@value"));
                    }

                    if (onsetDateTime.HasValue || dateOfResolution.HasValue)
                    {
                        proceduresItem.Interval = new Interval
                        {
                            Start = onsetDateTime.HasValue ? onsetDateTime : null,
                            End   = dateOfResolution.HasValue ? dateOfResolution : null
                        };
                    }

                    problemDiagnosiList.Add(proceduresItem);
                }
            }

            return(problemDiagnosiList.Any() ? problemDiagnosiList : null);
        }
        public Pathology Extract(CdaXmlDocument cdaDocument)
        {
            var pathology = new Pathology();

            var pathDocNode = cdaDocument.SelectSingleNode(_documentXPaths.Get("PathologyDocument"));

            if (pathDocNode != null)
            {
                var pathologyReportName = cdaDocument.SelectSingleNode(pathDocNode, _documentXPaths.Get("PathologyReportName"));
                if (pathologyReportName != null)
                {
                    pathology.ReportName = pathologyReportName.InnerText;
                }

                var pathologyReportDateTime = cdaDocument.GetDateTimeValue(pathDocNode, _documentXPaths.Get("PathologyReportDateTime"));
                if (pathologyReportDateTime != null)
                {
                    pathology.ReportDateTime = pathologyReportDateTime.Value;
                }

                var pathologyReportStatus = cdaDocument.GetCodableText(pathDocNode, _documentXPaths.Get("PathologyReportStatus"));
                pathology.ReportStatus = pathologyReportStatus;

                var pathologyReportIdentifier = cdaDocument.GetId(pathDocNode, _documentXPaths.Get("PathologyReportIdentifier"));
                pathology.ReportIdentifier = pathologyReportIdentifier;

                var pathologyReportIntegrityCheck = cdaDocument.SelectSingleNode(pathDocNode, _documentXPaths.Get("PathologyReportIntegrityCheck"));
                if (pathologyReportIntegrityCheck != null)
                {
                    pathology.ReportIntegrityCheck = pathologyReportIntegrityCheck.Value;
                }

                var pathologyReportMediaType = cdaDocument.SelectSingleNode(pathDocNode, _documentXPaths.Get("PathologyReportMediaType"));
                if (pathologyReportMediaType != null)
                {
                    pathology.ReportMediaType = pathologyReportMediaType.Value;
                }

                var pathologyReportDocName = cdaDocument.SelectSingleNode(pathDocNode, _documentXPaths.Get("PathologyReportDocName"));
                if (pathologyReportDocName != null)
                {
                    pathology.ReportDocName = pathologyReportDocName.Value;
                }


                var pathXpath = _documentXPaths.Get("Pathologist");
                var pathNode  = cdaDocument.SelectSingleNode(pathXpath);

                var pathologistIdentifier = cdaDocument.SelectSingleNode(pathNode, _documentXPaths.Get("PathologistIdentifier"));
                if (pathologistIdentifier != null)
                {
                    pathology.PathologistIdentifier = pathologistIdentifier.Value.Replace("1.2.36.1.2001.1003.0.", "");
                }

                var pathologistOrganisationName = cdaDocument.SelectSingleNode(pathNode, _documentXPaths.Get("PathologistOrganisationName"));
                if (pathologistOrganisationName != null)
                {
                    pathology.OrganisationName = pathologistOrganisationName.InnerText;
                }

                var pathologistOrganisationIdentifier = cdaDocument.SelectSingleNode(pathNode, _documentXPaths.Get("PathologistOrganisationIdentifier"));
                if (pathologistOrganisationIdentifier != null)
                {
                    pathology.OrganisationIdentifier = pathologistOrganisationIdentifier.Value.Replace("1.2.36.1.2001.1003.0.", "");
                }

                if (pathXpath != null)
                {
                    List <Telecom> pathologistContactDetails = cdaDocument.GetTelecoms(pathXpath + "/" + _documentXPaths.Get("PathologistContactDetails"));
                    if (pathologistContactDetails != null)
                    {
                        pathology.ContactDetails = pathologistContactDetails;
                    }

                    var personName = cdaDocument.GetPersonName(pathXpath + "/" + _documentXPaths.Get("PathologistName"));
                    if (personName != null)
                    {
                        pathology.Pathologist = personName;
                    }
                }
            }

            // 1..* results
            pathology.PathologyTestResults = new List <PathologyTestResult>();

            var nodes = cdaDocument.SelectNodes(_documentXPaths.Get("PathologyTestResults"));

            if (nodes != null && nodes.Count > 0)
            {
                pathology.PathologyTestResults =
                    (from XmlNode node in nodes
                     select new PathologyTestResult
                {
                    TestResultName = cdaDocument.GetCodableText(node, _documentXPaths.Get("PathologyTestResultName")),
                    Discipline = cdaDocument.GetCodableText(node, _documentXPaths.Get("PathologyDiscipline")),
                    SpecimenCollectionDateTime = cdaDocument.GetDateTimeValue(node, _documentXPaths.Get("PathologyCollectionDateTime")).Value,
                    ObservationDateTime = cdaDocument.GetDateTimeValue(node, _documentXPaths.Get("PathologyObservationDateTime")).Value,
                    TestResultStatus = cdaDocument.GetCodableText(node, _documentXPaths.Get("PathologyTestResultStatus"))
                }
                    ).ToList();
            }

            return(pathology);
        }