public void DicomPersonName_TwoNames_YieldsTwoValues() { var element = new DicomPersonName(DicomTag.ConsultingPhysicianName, new [] { "Doe^John", "Bar^Foo"}); var actual = element.Get<string[]>(); Assert.Equal(2, actual.Length); Assert.Equal("Bar^Foo", actual[1]); }
public void DicomPersonName_TwoNames_YieldsTwoValues() { var element = new DicomPersonName(DicomTag.ConsultingPhysicianName, new[] { "Doe^John", "Bar^Foo" }); var actual = element.Get <string[]>(); Assert.Equal(2, actual.Length); Assert.Equal("Bar^Foo", actual[1]); }
public void DicomPersonNameConstructorTest() { DicomPersonName target = new DicomPersonName(DicomTag.PatientName, "Last", "First", "Middle", "Prefix", "Suffix"); Assert.AreEqual("Last^First^Middle^Prefix^Suffix", target.Get<string>()); target = new DicomPersonName(DicomTag.PatientName, "Last", "First", "Middle", "", ""); Assert.AreEqual("Last^First^Middle", target.Get<string>()); target = new DicomPersonName(DicomTag.PatientName, "Last", "First", null, ""); Assert.AreEqual("Last^First", target.Get<string>()); target = new DicomPersonName(DicomTag.PatientName, "Last", "First", "", null, "Suffix"); Assert.AreEqual("Last^First^^^Suffix", target.Get<string>()); target = new DicomPersonName(DicomTag.PatientName, "", "", "", null, null); Assert.AreEqual("", target.Get<string>()); }
public void DicomPersonNameConstructorTest() { DicomPersonName target = new DicomPersonName(DicomTag.PatientName, "Last", "First", "Middle", "Prefix", "Suffix"); Assert.AreEqual("Last^First^Middle^Prefix^Suffix", target.Get <string>()); target = new DicomPersonName(DicomTag.PatientName, "Last", "First", "Middle", "", ""); Assert.AreEqual("Last^First^Middle", target.Get <string>()); target = new DicomPersonName(DicomTag.PatientName, "Last", "First", null, ""); Assert.AreEqual("Last^First", target.Get <string>()); target = new DicomPersonName(DicomTag.PatientName, "Last", "First", "", null, "Suffix"); Assert.AreEqual("Last^First^^^Suffix", target.Get <string>()); target = new DicomPersonName(DicomTag.PatientName, "", "", "", null, null); Assert.AreEqual("", target.Get <string>()); }
private static void WriteJsonPersonName(JsonWriter writer, DicomPersonName pn) { if (pn.Count != 0) { writer.WritePropertyName("Value"); writer.WriteStartArray(); foreach (var val in pn.Get <string[]>()) { if (string.IsNullOrEmpty(val)) { writer.WriteNull(); } else { var componentGroupValues = val.Split(_personNameComponentGroupDelimiter); int i = 0; writer.WriteStartObject(); foreach (var componentGroupValue in componentGroupValues) { // Based on standard http://dicom.nema.org/dicom/2013/output/chtml/part18/sect_F.2.html // 1. Empty values are skipped // 2. Leading componentGroups even if null need to have delimiters. Trailing componentGroup delimiter can be omitted if (!string.IsNullOrWhiteSpace(componentGroupValue)) { writer.WritePropertyName(_personNameComponentGroupNames[i]); writer.WriteValue(componentGroupValue); } i++; } writer.WriteEndObject(); } } writer.WriteEndArray(); } }
public void DicomPersonName_FamilyAndSurname_YieldsCompositeName() { var element = new DicomPersonName(DicomTag.ConsultingPhysicianName, "Doe", "John"); var actual = element.Get<string>(0); Assert.Equal("Doe^John", actual); }