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); }
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 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()); }
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()); }
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); }
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); }