public static DPersonName2 FromDicomString(string strPersonName) { if (strPersonName == null) { return(null); } if (strPersonName.EndsWith("=")) { strPersonName += "^"; } DPersonName2 name = new DPersonName2(); string[] gList = strPersonName.Split(GroupDelimiter); if (gList.Length > 0) { string strGroup = gList[0]; string[] cList = strGroup.Split(ComponentDelimiter); if (cList.Length > 0) { name.sFamilyName = cList[0]; } if (cList.Length > 1) { name.sFirstName = cList[1]; } if (cList.Length > 2) { name.sMiddleName = cList[2]; } if (cList.Length > 3) { name.sPrefix = cList[3]; } if (cList.Length > 4) { name.sSuffix = cList[4]; } } if (gList.Length > 1) { string strGroup = gList[1]; string[] cList = strGroup.Split(ComponentDelimiter); if (cList.Length > 0) { name.iFamilyName = cList[0]; } if (cList.Length > 1) { name.iFirstName = cList[1]; } if (cList.Length > 2) { name.iMiddleName = cList[2]; } if (cList.Length > 3) { name.iPrefix = cList[3]; } if (cList.Length > 4) { name.iSuffix = cList[4]; } } if (gList.Length > 2) { string strGroup = gList[2]; string[] cList = strGroup.Split(ComponentDelimiter); if (cList.Length > 0) { name.pFamilyName = cList[0]; } if (cList.Length > 1) { name.pFirstName = cList[1]; } if (cList.Length > 2) { name.pMiddleName = cList[2]; } if (cList.Length > 3) { name.pPrefix = cList[3]; } if (cList.Length > 4) { name.pSuffix = cList[4]; } } return(name); }
private DicomItem GetDicomItemValue(DicomVR vr, DicomTag tag, string[] list) { if (vr == DicomVR.AE) { return(new DicomApplicationEntity(tag, list.ToArray())); } else if (vr == DicomVR.AS) { return(new DicomAgeString(tag, list.ToArray())); } //else if (vr == DicomVR.AT) //{ // return new DicomAttributeTag(tag, EmptyBuffer.Value); //} else if (vr == DicomVR.CS) { return(new DicomCodeString(tag, list.ToArray())); } else if (vr == DicomVR.DA) { return(new DicomDate(tag, list.ToArray())); } else if (vr == DicomVR.DS) { return(new DicomDecimalString(tag, list.ToArray())); } else if (vr == DicomVR.DT) { return(new DicomDateTime(tag, list.ToArray())); } else if (vr == DicomVR.FD) { List <Double> dList = new List <double>(); foreach (string s in list) { dList.Add(Double.Parse(s)); } return(new DicomFloatingPointDouble(tag, dList.ToArray())); } else if (vr == DicomVR.FL) { List <float> fList = new List <float>(); foreach (string s in list) { fList.Add(float.Parse(s)); } return(new DicomFloatingPointSingle(tag, fList.ToArray())); } else if (vr == DicomVR.IS) { return(new DicomIntegerString(tag, list.ToArray())); } else if (vr == DicomVR.LO) { return(new DicomLongString(tag, DicomEncoding.Default, list.ToArray())); } else if (vr == DicomVR.LT) { return(new DicomLongText(tag, list.Cast <string>().First())); } //else if (vr == DicomVR.OB) //{ // return new DicomOtherByte(tag, EmptyBuffer.Value); //} else if (vr == DicomVR.OD) { List <Double> dList = new List <double>(); foreach (string s in list) { dList.Add(Double.Parse(s)); } return(new DicomOtherDouble(tag, dList.ToArray())); } else if (vr == DicomVR.OF) { List <float> fList = new List <float>(); foreach (string s in list) { fList.Add(float.Parse(s)); } return(new DicomOtherFloat(tag, fList.ToArray())); } //else if (vr == DicomVR.OW) //{ // return new DicomOtherWord(tag, EmptyBuffer.Value); //} else if (vr == DicomVR.PN) { if (DHelper.PersonNameEncodingRule.Enable) { DPersonName2 name = DPersonName2.FromDicomString(list.First()); if (name == null) { return(new DicomPersonName(tag, DicomEncoding.Default, EmptyBuffer.Value)); } return(new DicomPersonName(tag, DicomEncoding.Default, name.ToNamestring(new DPersonNameEncodingRule()))); } else { return(new DicomPersonName(tag, DicomEncoding.Default, list.ToArray())); } } else if (vr == DicomVR.SH) { return(new DicomShortString(tag, DicomEncoding.Default, list.ToArray())); } else if (vr == DicomVR.SL) { List <int> iList = new List <int>(); foreach (string s in list) { iList.Add(int.Parse(s)); } return(new DicomSignedLong(tag, iList.ToArray())); } //else if (vr == DicomVR.SQ) //{ // return new DicomSequence(tag); //} else if (vr == DicomVR.SS) { List <short> sList = new List <short>(); foreach (string s in list) { sList.Add(short.Parse(s)); } return(new DicomSignedShort(tag, sList.ToArray())); } else if (vr == DicomVR.ST) { return(new DicomShortText(tag, DicomEncoding.Default, list.First())); } else if (vr == DicomVR.TM) { return(new DicomTime(tag, list.ToArray())); } else if (vr == DicomVR.UC) { return(new DicomUnlimitedCharacters(tag, list.ToArray())); } else if (vr == DicomVR.UI) { return(new DicomUniqueIdentifier(tag, list.ToArray())); } else if (vr == DicomVR.UL) { List <uint> uList = new List <uint>(); foreach (string s in list) { uList.Add(uint.Parse(s)); } return(new DicomUnsignedLong(tag, uList.ToArray())); } //else if (vr == DicomVR.UN) //{ // return new DicomUnknown(tag, EmptyBuffer.Value); //} else if (vr == DicomVR.UR) { return(new DicomUniversalResource(tag, list.First())); } else if (vr == DicomVR.US) { List <ushort> uList = new List <ushort>(); foreach (string s in list) { uList.Add(ushort.Parse(s)); } return(new DicomUnsignedShort(tag, uList.ToArray())); } else if (vr == DicomVR.UT) { return(new DicomUnlimitedText(tag, list.First())); } return(null); }