Example #1
0
        public static PersonNameRule GetDefault()
        {
            PersonNameRule rule = new PersonNameRule();

            rule.SelectedGroup = PersonNameGroupType.SingleByte;
            rule.Components.Clear();
            rule.Components.Add(new PersonNameComponent(PersonNameComponentType.FamilyName, "Family Name"));
            rule.Components.Add(new PersonNameComponent(PersonNameComponentType.GivenName, "Given Name"));
            rule.Components.Add(new PersonNameComponent(PersonNameComponentType.MiddleName, "Middle Name"));
            rule.Components.Add(new PersonNameComponent(PersonNameComponentType.Prefix, "Prefix"));
            rule.Components.Add(new PersonNameComponent(PersonNameComponentType.Suffix, "Suffix"));
            return(rule);
        }
Example #2
0
        private static void FillDataSet <TC>(Hashtable dr, ref int index, int depth, XCollection <TC> qcList, DicomDataset eleList)
            where TC : MappingItem, IDicomMappingItem
        {
            int count = qcList.Count;

            for (; index < count; index++)
            {
                TC qc = qcList[index] as TC;
                if (qc.Translating.Type == TranslatingType.FixValue)
                {
                    continue;
                }
                if (qc.DPath.Type == DPathType.BeginItem)
                {
                    continue;
                }
                if (qc.DPath.Type == DPathType.EndItem && depth > 0)
                {
                    break;
                }
                if (!qc.DPath.Enable)
                {
                    continue;
                }

                //int tag = qc.DPath.GetTag(depth);
                //DicomItem ele = eleList(tag);
                List <string> tagList = qc.DPath.GetTagGE(depth);
                if (tagList == null)
                {
                    continue;
                }

                ushort    uGroup   = DHelper.HexString2ushort(tagList[0]);
                ushort    uElement = DHelper.HexString2ushort(tagList[1]);
                DicomItem ele      = eleList.Get <DicomItem>(new DicomTag(uGroup, uElement));
                if (ele == null || ConvertDicomVRToDVR(ele.ValueRepresentation) != qc.DPath.VR)
                {
                    if (qc.DPath.VR == DVR.SQ)
                    {
                        continue;
                    }
                    dr[qc.SourceField] = GetSQLString <TC>(qc, (ele == null) ? "" : eleList.Get <string>(new DicomTag(uGroup, uElement)));
                    continue;
                }

                if (qc.DPath.VR == DVR.SQ)
                {
                    int           d             = depth + 1;
                    DicomDataset  sqList        = null;
                    DicomSequence dicomSequence = (DicomSequence)ele;
                    if (dicomSequence.Items.Count > 0)     //support one sequence item only
                    {
                        sqList = dicomSequence.Items[0];
                    }
                    index++;
                    if (sqList == null)
                    {
                        sqList = new DicomDataset();
                    }
                    FillDataSet <TC>(dr, ref index, d, qcList, sqList);
                    break;
                }
                else
                {
                    string value = eleList.Get <string>(new DicomTag(uGroup, uElement));
                    if (DHelper.IsDateTime(qc.DPath.VR))
                    {
                        DVR realVR = qc.DPath.VR;

                        // ------ merge TM to DT ------
                        if (uGroup == DicomTag.ScheduledProcedureStepStartDate.Group && uElement == DicomTag.ScheduledProcedureStepStartDate.Element)
                        {
                            string eleTM = eleList.Get <string>(DicomTag.ScheduledProcedureStepStartTime);
                            if (eleTM != null)
                            {
                                string   strTM     = eleTM;
                                string[] strTMList = strTM.Split('-');
                                string[] strDAList = value.Split('-');
                                if (strTMList.Length > 0 && strDAList.Length > 0)
                                {
                                    if (strDAList.Length == 1 && strDAList[0].Length > 0)
                                    {
                                        if (strTMList.Length == 1 && strTMList[0].Length > 0)
                                        {
                                            realVR = DVR.DT;
                                            if (strTM.Length > 6)
                                            {
                                                strTM = strTM.Substring(0, 6);
                                            }
                                            value += strTM;
                                        }
                                        else if (strTMList.Length == 2)
                                        {
                                            realVR = DVR.DT;
                                            string beginTM = strTMList[0];
                                            string endTM   = strTMList[1];
                                            if (beginTM.Length < 1)
                                            {
                                                beginTM = "000000";
                                            }
                                            if (endTM.Length < 1)
                                            {
                                                endTM = "235959";
                                            }
                                            if (beginTM.Length > 6)
                                            {
                                                beginTM = beginTM.Substring(0, 6);
                                            }
                                            if (endTM.Length > 6)
                                            {
                                                endTM = endTM.Substring(0, 6);
                                            }
                                            value = strDAList[0] + beginTM + "-" + strDAList[0] + endTM;
                                        }
                                    }
                                    else if (strDAList.Length == 2)
                                    {
                                        if (strTMList.Length == 1 && strTMList[0].Length > 0)
                                        {
                                            realVR = DVR.DT;
                                            if (strTM.Length > 6)
                                            {
                                                strTM = strTM.Substring(0, 6);
                                            }
                                            value = strDAList[0] + strTM + "-" + strDAList[1] + strTM;
                                        }
                                        else if (strTMList.Length == 2)
                                        {
                                            realVR = DVR.DT;
                                            string beginTM = strTMList[0];
                                            string endTM   = strTMList[1];
                                            if (beginTM.Length < 1)
                                            {
                                                beginTM = "000000";
                                            }
                                            if (endTM.Length < 1)
                                            {
                                                endTM = "235959";
                                            }
                                            if (beginTM.Length > 6)
                                            {
                                                beginTM = beginTM.Substring(0, 6);
                                            }
                                            if (endTM.Length > 6)
                                            {
                                                endTM = endTM.Substring(0, 6);
                                            }
                                            value = strDAList[0] + beginTM + "-" + strDAList[1] + endTM;
                                        }
                                    }
                                }
                            }
                        }
                        // ----------------------------

                        if (qc.DPath.Range == DRangeType.None)
                        {
                            DDateTime2 singleddt = DDateTime2.FromDateTime(realVR, value);
                            object     singledt  = (singleddt != null) ? singleddt.GetDateTime() : null;
                            //value = (singledt != null) ? ((DateTime)singledt).ToString(GWDataDB.DateTimeFormat) : "";
                            value = GetGWDTStartString(singledt, realVR);
                            dr[qc.SourceField] = GetSQLString <TC>(qc, value);
                            continue;
                        }

                        TC qcStart = qc;
                        if (qcStart.DPath.Range != DRangeType.Begin)
                        {
                            continue;
                        }

                        TC qcEnd = qcList[index + 1];
                        if (qcEnd == null || qcEnd.DPath.Range != DRangeType.End)
                        {
                            continue;
                        }

                        index++;

                        object     dtStart = null, dtEnd = null;
                        DDateTime2 ddt = DDateTime2.FromDateTime(realVR, value);
                        if (ddt != null)
                        {
                            switch (ddt.Type)
                            {
                            case DDateTimeType.SINGLE:
                            {
                                dtStart = dtEnd = ddt.GetDateTime();
                                break;
                            }

                            case DDateTimeType.START_ONLY:
                            {
                                dtStart = ddt.GetStartDateTime();
                                break;
                            }

                            case DDateTimeType.END_ONLY:
                            {
                                dtEnd = ddt.GetEndDateTime();
                                break;
                            }

                            case DDateTimeType.RANGE:
                            {
                                dtStart = ddt.GetStartDateTime();
                                dtEnd   = ddt.GetEndDateTime();
                                break;
                            }
                            }
                        }

                        string strStart = "", strEnd = "";
                        strStart = GetGWDTStartString(dtStart, realVR);
                        strEnd   = GetGWDTEndString(dtEnd, realVR);
                        dr[qcStart.SourceField] = strStart;
                        dr[qcEnd.SourceField]   = strEnd;
                    }
                    else if (qc.DPath.VR == DVR.PN)
                    {
                        value = PersonNameRule.Parse(value);
                        dr[qc.SourceField] = GetSQLString <TC>(qc, value);
                    }
                    else
                    {
                        dr[qc.SourceField] = GetSQLString <TC>(qc, value);
                    }
                    break;
                }
            }
        }