private static void HandleFinding(Dictionary <string, List <MeasurementGroup> > findings, DicomContentItem finding) { string sitename = ""; foreach (var site in finding.Children()) { if (site.Type != DicomValueType.Container) { sitename = site.Dataset.GetCodeItem(DicomTag.ConceptCodeSequence).Meaning; //Debug.WriteLine(sitename); } else { var measurements = new List <Measurement>(); foreach (var rawmeasurement in site.Children()) { Measurement measurement = GetMeasurementFromRaw(rawmeasurement); measurements.Add(measurement); //measurement.PrintDebug(); } if (findings.ContainsKey(sitename)) { findings[sitename].AddRange(MeasurementGroup.GroupMeasurements(measurements)); } else { findings.Add(sitename, MeasurementGroup.GroupMeasurements(measurements)); } } } }
public void Children_NodeWithoutChildren_Success() { var contentItem = new DicomContentItem(new DicomCodeItem("113820", "DCM", "CT Acquisition Type"), DicomRelationship.Contains, new DicomCodeItem("113805", "DCM", "Constant Angle Acquisition")); Assert.Equal(0, contentItem.Children().Count()); }
public void Children_NodeWithoutChildren_Success() { var contentItem = new DicomContentItem(new DicomCodeItem("113820", "DCM", "CT Acquisition Type"), DicomRelationship.Contains, new DicomCodeItem("113805", "DCM", "Constant Angle Acquisition")); Assert.Empty(contentItem.Children()); }
private void AddTreeNode(DicomContentItem item, TreeNode parent) { var node = parent.Nodes.Add(item.ToString()); foreach (var child in item.Children()) { AddTreeNode(child, node); } }
public void Children_NodeWithChildren_Success() { var contentItem = new DicomContentItem( new DicomCodeItem("113820", "DCM", "CT Acquisition Type"), DicomRelationship.Contains, new DicomCodeItem("113805", "DCM", "Constant Angle Acquisition")); contentItem.Add(new DicomCodeItem("113961", "DCM", "Reconstruction Algorithm"), DicomRelationship.Contains, new DicomCodeItem("113962", "DCM", "Filtered Back Projection")); var children = contentItem.Children().ToList(); Assert.Equal(1, children.Count); Assert.Equal(new DicomCodeItem("113961", "DCM", null), children[0].Code); Assert.Equal(DicomRelationship.Contains, children[0].Relationship); Assert.Equal(new DicomCodeItem("113962", "DCM", null), children[0].Get<DicomCodeItem>()); }
public void Children_NodeWithChildren_Success() { var contentItem = new DicomContentItem( new DicomCodeItem("113820", "DCM", "CT Acquisition Type"), DicomRelationship.Contains, new DicomCodeItem("113805", "DCM", "Constant Angle Acquisition")); contentItem.Add(new DicomCodeItem("113961", "DCM", "Reconstruction Algorithm"), DicomRelationship.Contains, new DicomCodeItem("113962", "DCM", "Filtered Back Projection")); var children = contentItem.Children().ToList(); Assert.Single(children); Assert.Equal(new DicomCodeItem("113961", "DCM", null), children[0].Code); Assert.Equal(DicomRelationship.Contains, children[0].Relationship); Assert.Equal(new DicomCodeItem("113962", "DCM", null), children[0].Get <DicomCodeItem>()); }
private static Measurement GetMeasurementFromRaw(DicomContentItem raw) { DicomMeasuredValue measurementsequence = raw.Dataset.GetMeasuredValue(DicomTag.MeasuredValueSequence); IMeasurementHeader m = HeaderFactory.Parse(raw.Code.Meaning, (double)measurementsequence.Value, measurementsequence.Code.Meaning, measurementsequence.Code.Value); Measurement measurement = new Measurement(m); foreach (var child in raw.Children()) { string name; string value; if (child.Relationship == DicomRelationship.HasConceptModifier || child.Relationship == DicomRelationship.HasProperties) { if (!child.Code.Value.Equals("T5203-01")) { name = child.Code.Meaning; value = child.Dataset.GetDicomItem <DicomSequence>(DicomTag.ConceptCodeSequence).Items[0].GetString(DicomTag.CodeMeaning); measurement.AddProperty(name, value); } } } return(measurement); }
public PatientData(DicomContentItem patientcontainer) : this() { foreach (var child in patientcontainer.Children()) { DicomMeasuredValue measurementsequence; IMeasurementHeader temp; //Debug.WriteLine(child.Code + ": " + child.Get<string>()); switch (child.Code.Value) { case "121033": measurementsequence = child.Dataset.GetMeasuredValue(DicomTag.MeasuredValueSequence); try { temp = HeaderFactory.Parse("Age", (double)measurementsequence.Value, measurementsequence.Code.Meaning, measurementsequence.Code.Value); SupportedUnitsHelpers.Convert(temp, DurationUnit.Year365); } catch (Exception) { temp = new UnitHeaderAdapter("Age", new Duration((double)measurementsequence.Value, DurationUnit.Year365)); } Debug.WriteLine(temp); PatientAge = new Result(temp); break; case "121032": PatientSex = new StringResult("Sex", child.Dataset.GetCodeItem(DicomTag.ConceptCodeSequence).Meaning); Debug.WriteLine(PatientSex); break; case "8302-2": measurementsequence = child.Dataset.GetMeasuredValue(DicomTag.MeasuredValueSequence); temp = HeaderFactory.Parse("Height", (double)measurementsequence.Value, measurementsequence.Code.Meaning, measurementsequence.Code.Value); SupportedUnitsHelpers.Convert(temp, LengthUnit.Centimeter); Debug.WriteLine(temp); PatientHeight = new Result(temp); break; case "29463-7": measurementsequence = child.Dataset.GetMeasuredValue(DicomTag.MeasuredValueSequence); temp = HeaderFactory.Parse("Weight", (double)measurementsequence.Value, measurementsequence.Code.Meaning, measurementsequence.Code.Value); SupportedUnitsHelpers.Convert(temp, MassUnit.Kilogram); Debug.WriteLine(temp); PatientWeight = new Result(temp); break; case "F-008EC": measurementsequence = child.Dataset.GetMeasuredValue(DicomTag.MeasuredValueSequence); temp = HeaderFactory.Parse(child.Code.Meaning, (double)measurementsequence.Value, measurementsequence.Code.Meaning, "mmHg"); Debug.WriteLine(temp); SystolicBloodPressure = new Result(temp); break; case "F-008ED": measurementsequence = child.Dataset.GetMeasuredValue(DicomTag.MeasuredValueSequence); temp = HeaderFactory.Parse(child.Code.Meaning, (double)measurementsequence.Value, measurementsequence.Code.Meaning, "mmHg"); Debug.WriteLine(temp); DiastolicBloodPressure = new Result(temp); break; case "121029": PatientName = new StringResult("Patient Name", child.Get <string>().Replace('^', ' ').Trim()); PatientName.Value = PatientName.Value.Split(' ').Reverse().Aggregate((x, y) => { return((x + " " + y).Trim()); }); Debug.WriteLine(PatientName); break; case "121030": PatientID = new StringResult("Patient ID", child.Get <string>()); Debug.WriteLine(PatientID); break; case "T9910-08": ReferringPhysician = new StringResult("Referring Physician", child.Get <string>()); Debug.WriteLine(ReferringPhysician); break; case "T9910-04": ReasonForStudy = new StringResult("Reason For Study", child.Get <string>()); Debug.WriteLine(ReasonForStudy); break; case "121031": string input = child.Get <string>(); Debug.WriteLine("dob input: " + input); var numbers = Regex.Split(input, @"\D+").ToList().GetRange(1, 3).Select(x => int.Parse(x)).ToArray(); PatientDOB = new StringResult("DOB", new DateTime(numbers[0], numbers[1], numbers[2]).Date.ToShortDateString()); Debug.WriteLine(PatientDOB.Value); break; case "T9910-09": string dateinput = child.Get <string>(); Debug.WriteLine("exam date input: " + dateinput); var numbers2 = Regex.Split(dateinput, @"\D+").ToList().GetRange(1, 3).Select(x => int.Parse(x)).ToArray(); StudyDate = new StringResult("Study Date", new DateTime(numbers2[0], numbers2[1], numbers2[2]).Date.ToShortDateString()); Debug.WriteLine(StudyDate.Value); break; default: break; } } UpdateBSAResult(); Debug.WriteLine(PatientDOB.Value); }
private void AddTreeNode(DicomContentItem item, TreeNode parent) { var node = parent.Nodes.Add(item.ToString()); foreach (var child in item.Children()) AddTreeNode(child, node); }