コード例 #1
0
        public static void CleanQRMappingList <TR>(XCollection <TR> qrList)
            where TR : QueryResultItem, IDicomMappingItem, new()
        {
            List <TR> garbageList = new List <TR>();

            foreach (TR item in qrList)
            {
                IDicomMappingItem dcmItem = item as IDicomMappingItem;
                if (dcmItem == null)
                {
                    continue;
                }

                if (!dcmItem.DPath.Enable ||
                    dcmItem.DPath.VR == DVR.SQ ||
                    dcmItem.DPath.VR == DVR.Unknown ||
                    dcmItem.DPath.Type != DPathType.Normal)
                {
                    garbageList.Add(item);
                }
            }
            foreach (TR item in garbageList)
            {
                qrList.Remove(item);
            }
        }
コード例 #2
0
        public static void CleanQCMappingList <TC>(XCollection <TC> qcList)
            where TC : QueryCriteriaItem, IDicomMappingItem, new()
        {
            List <TC> garbageList = new List <TC>();

            foreach (TC item in qcList)
            {
                IDicomMappingItem dcmItem = item as IDicomMappingItem;
                if (dcmItem == null)
                {
                    continue;
                }

                if (!dcmItem.DPath.Enable ||
                    dcmItem.DPath.VR == DVR.SQ ||
                    dcmItem.DPath.VR == DVR.Unknown ||
                    dcmItem.DPath.Type != DPathType.Normal ||
                    dcmItem.GWDataDBField.Table == GWDataDBTable.None)
                {
                    garbageList.Add(item);
                }
            }
            foreach (TC item in garbageList)
            {
                qcList.Remove(item);
            }
        }
コード例 #3
0
        private void GetGWDBField(ListViewItem item, IDicomMappingItem qr)
        {
            if (qr.DPath.VR == DVR.Unknown || qr.DPath.VR == DVR.SQ)
            {
                return;
            }
            GWDataDBField field = qr.GWDataDBField;

            if (field.Table == GWDataDBTable.None ||
                (qr.Translating.Type == TranslatingType.FixValue && _asQueryResult && _isInbound == false))
            {
                item.SubItems.Add("");
            }
            else
            {
                item.SubItems.Add(field.GetFullFieldName());
            }
            if (qr.Translating.Type == TranslatingType.None)
            {
                item.SubItems.Add("");
            }
            else
            {
                item.SubItems.Add(qr.Translating.ToString());
            }
            if (_isInbound && qr.RedundancyFlag)
            {
                item.SubItems.Add("True");
            }
        }
コード例 #4
0
        private void GroupByCatagory()
        {
            Dictionary <string, ArrayList> gList = new Dictionary <string, ArrayList>();

            foreach (ListViewItem item in this._listViewElement.Items)
            {
                IDicomMappingItem dcmItem = item.Tag as IDicomMappingItem;
                if (dcmItem == null)
                {
                    continue;
                }

                string text = dcmItem.DPath.Catagory;
                if (text.Length < 1)
                {
                    text = "Other";
                }
                if (gList.ContainsKey(text))
                {
                    ArrayList list = gList[text] as ArrayList;
                    if (list != null)
                    {
                        list.Add(item);
                    }
                }
                else
                {
                    ArrayList list = new ArrayList();
                    gList[text] = list;
                    list.Add(item);
                }
            }

            this._listViewElement.Groups.Clear();
            foreach (KeyValuePair <string, ArrayList> de in gList)
            {
                ListViewGroup g = new ListViewGroup(de.Key as string, HorizontalAlignment.Left);
                this._listViewElement.Groups.Add(g);

                ArrayList ilist = de.Value as ArrayList;
                if (ilist == null)
                {
                    return;
                }

                foreach (ListViewItem i in ilist)
                {
                    i.Group = g;
                }
            }

            this._listViewElement.ShowGroups = true;
        }
コード例 #5
0
 public virtual void SelectItem(IDicomMappingItem item)
 {
     foreach (ListViewItem i in this._listViewElement.Items)
     {
         IDicomMappingItem ii = i.Tag as IDicomMappingItem;
         if (ii == item)
         {
             i.Selected = true;
             i.EnsureVisible();
             break;
         }
     }
 }
コード例 #6
0
        protected virtual void _listViewElement_DoubleClick(object sender, EventArgs e)
        {
            IDicomMappingItem item = GetSelectedItem();

            if (item == null || item.GWDataDBField.Table != GWDataDBTable.None)
            {
                return;
            }
            if (DoubleClick != null)
            {
                DoubleClick(this, e);
            }
        }
コード例 #7
0
        protected virtual void _listViewElement_ItemChecked(object sender, ItemCheckedEventArgs e)
        {
            IDicomMappingItem dcmItem = e.Item.Tag as IDicomMappingItem;

            if (dcmItem == null)
            {
                return;
            }

            if (e.Item.Checked)
            {
                dcmItem.DPath.Enable = true;
                e.Item.ForeColor     = clrChecked;

                string str = e.Item.Text;
                if (str.Length > 0)
                {
                    int prefixLength = str.Length - str.TrimStart(PrefixChar).Length;
                    if (prefixLength > 0)
                    {
                        for (int i = e.Item.Index - 1; i >= 0; i--)
                        {
                            ListViewItem cItem = _listViewElement.Items[i];

                            string strSQ = cItem.Text;
                            if (strSQ.Length < 1)
                            {
                                continue;
                            }

                            int prefixLengthSQ = strSQ.Length - strSQ.TrimStart(PrefixChar).Length;
                            if (prefixLength - prefixLengthSQ == 1)
                            {
                                _checkLocked  = true;
                                cItem.Checked = true;
                                _checkLocked  = false;
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                dcmItem.DPath.Enable = false;
                e.Item.ForeColor     = clrUnchecked;
            }
        }
コード例 #8
0
        protected virtual void _listViewElement_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            if (_checkLocked)
            {
                return;
            }
            ListViewItem      item = this._listViewElement.Items[e.Index];
            IDicomMappingItem qr   = item.Tag as IDicomMappingItem;

            if (qr == null || qr.DPath.VR == DVR.Unknown)
            {
                e.NewValue = e.CurrentValue;
            }
            if (qr != null && qr.DPath.VR == DVR.SQ)
            {
                string strRoot = qr.DPath.Path;
                foreach (ListViewItem i in this._listViewElement.Items)
                {
                    IDicomMappingItem subqr = i.Tag as IDicomMappingItem;
                    if (subqr != null &&
                        subqr.DPath.Path.Length > strRoot.Length &&
                        subqr.DPath.Path.IndexOf(strRoot) == 0)
                    {
                        if (e.NewValue == CheckState.Unchecked)
                        {
                            i.Checked = false;
                        }
                        if (e.NewValue == CheckState.Checked)
                        {
                            i.Checked = true;
                        }
                    }
                }
            }
            if (/*_asQueryResult == false &&*/
                qr != null && qr.IsValid() == false)
            {
                e.NewValue = CheckState.Unchecked;
            }
        }
コード例 #9
0
        public static DElementListWrapper[] CreateQRElementList <TR>(XCollection <TR> qrList, DataSet dsQR)
            where TR : QueryResultItem, IDicomMappingItem
        {
            if (dsQR == null || qrList == null)
            {
                return(null);
            }

            List <DElementListWrapper> dcmResult = new List <DElementListWrapper>();

            if (dsQR.Tables.Count > 0)
            {
                foreach (DataRow dr in dsQR.Tables[0].Rows)
                {
                    DicomDataset dcmEleList = new DicomDataset();

                    int count = qrList.Count;
                    for (int index = 0; index < count; index++)
                    {
                        IDicomMappingItem qr = qrList[index] as IDicomMappingItem;
                        if (!qr.DPath.Enable)
                        {
                            continue;
                        }
                        List <string> tagList  = qr.DPath.GetTagGE(0);
                        ushort        uGroup   = DHelper.HexString2ushort(tagList[0]);
                        ushort        uElement = DHelper.HexString2ushort(tagList[1]);
                        DicomTag      tag      = new DicomTag(uGroup, uElement);
                        FillElement <TR>(dcmEleList, tag, qr.DPath.VR, ref index, 0, qrList, dr);
                    }

                    DElementListWrapper w = new DElementListWrapper(dcmEleList);
                    w.GUIDs.Add(DicomMappingHelper.GetGUID(dr));
                    dcmResult.Add(w);
                }
            }

            return(dcmResult.ToArray());
        }
コード例 #10
0
        public static void ModifyQCMappingList_DateTime <TC>(XCollection <TC> qcList, bool withBracket)
            where TC : QueryCriteriaItem, IDicomMappingItem, new()
        {
            if (qcList == null)
            {
                return;
            }
            bool found = true;

            while (found)
            {
                found = false;
                int count = qcList.Count;
                for (int index = 0; index < count; index++)
                {
                    TC item = qcList[index];

                    IDicomMappingItem dcmItem = item as IDicomMappingItem;
                    if (dcmItem == null)
                    {
                        continue;
                    }

                    if (dcmItem.DPath != null &&
                        dcmItem.DPath.Range == DRangeType.None &&
                        DHelper.IsDateTime(dcmItem.DPath.VR))
                    {
                        qcList.Remove(item);

                        QueryCriteriaItem itemB = dcmItem.Clone() as QueryCriteriaItem;
                        ((IDicomMappingItem)itemB).DPath.Range = DRangeType.Begin;
                        itemB.Operator    = QueryCriteriaOperator.EqualLargerThan;
                        itemB.SourceField = itemB.SourceField + "_BEGIN";

                        QueryCriteriaItem itemE = dcmItem.Clone() as QueryCriteriaItem;
                        ((IDicomMappingItem)itemE).DPath.Range = DRangeType.End;
                        itemE.Operator    = QueryCriteriaOperator.EqualSmallerThan;
                        itemE.SourceField = itemE.SourceField + "_END";

                        if (withBracket)    // for GetRule()
                        {
                            qcList.Insert(index, GetRightBracket <TC>());
                            qcList.Insert(index, GetRightBracket <TC>());

                            TC itemEE = GetFreeText <TC>("@" + itemE.SourceField + "=''");
                            itemEE.Type = QueryCriteriaType.And;
                            qcList.Insert(index, itemEE);

                            TC itemBB = GetFreeText <TC>("@" + itemB.SourceField + "=''");
                            itemBB.Type = QueryCriteriaType.None;
                            qcList.Insert(index, itemBB);

                            TC itemOr = GetLeftBracket <TC>();
                            itemOr.Type = QueryCriteriaType.Or;
                            qcList.Insert(index, itemOr);

                            qcList.Insert(index, GetRightBracket <TC>());

                            itemE.Type = QueryCriteriaType.And;
                            qcList.Insert(index, itemE);

                            itemB.Type = QueryCriteriaType.None;
                            qcList.Insert(index, itemB);

                            qcList.Insert(index, GetLeftBracket <TC>());

                            TC itemAnd = GetLeftBracket <TC>();
                            itemAnd.Type = QueryCriteriaType.And;
                            qcList.Insert(index, itemAnd);
                        }
                        else                // for NT Service to create QC DataSet
                        {
                            qcList.Insert(index, itemE);
                            qcList.Insert(index, itemB);
                        }

                        found = true;
                        break;
                    }
                }
            }
        }
コード例 #11
0
        private ListViewItem GetListViewItem(ref string prefix, IDicomMappingItem qr)
        {
            if (qr == null)
            {
                return(null);
            }
            ListViewItem item = new ListViewItem();

            // prefix handler
            if (qr.DPath.VR == DVR.Unknown && qr.DPath.Type == DPathType.BeginItem)
            {
                prefix += PrefixChar;
            }

            // display value
            if (qr.IsValid())
            {
                item.Checked = qr.DPath.Enable;
            }
            if (((_isInbound && _asQueryResult) || (!_isInbound && !_asQueryResult)) &&
                qr.Translating.Type == TranslatingType.FixValue)
            {
                item.Text = "";
                item.SubItems.Add("");
                item.SubItems.Add("");
            }
            else
            {
                string strName = qr.DPath.GetTagName();
                string strG = qr.DPath.GetGroupString();
                string strE = qr.DPath.GetElementString();
                string strTag = "", strVR = "";
                if (qr.DPath.VR == DVR.Unknown)
                {
                    strTag    = prefix + qr.DPath.Path;
                    item.Text = strTag;
                }
                else
                {
                    strVR     = qr.DPath.VR.ToString();
                    strTag    = prefix + "(" + strG + "," + strE + ")";
                    item.Text = strTag;
                    item.SubItems.Add(strVR);
                    item.SubItems.Add(GetTagDisplayName(strName));
                }
            }

            // display color
            int depth     = prefix.Length;
            int luminance = 255 - 20 * depth;

            item.BackColor = Color.FromArgb(luminance, luminance, luminance);

            // prefix handler
            if (qr.DPath.VR == DVR.Unknown && qr.DPath.Type == DPathType.EndItem)
            {
                if (prefix.Length == 1)
                {
                    prefix = "";
                }
                if (prefix.Length > 1)
                {
                    prefix = prefix.Substring(1);
                }
            }

            GetGWDBField(item, qr);
            item.Tag = qr;

            if (qr.DPath.VR == DVR.Unknown)
            {
                return(null);
            }
            return(item);
        }
コード例 #12
0
        public static DElementListWrapper[] CreateQRElementList <TR>(XCollection <TR> qrList, DataSet dsQR)
            where TR : QueryResultItem, IDicomMappingItem
        {
            if (qrList == null || dsQR == null || dsQR.Tables.Count < 1)
            {
                return(null);
            }

            DataTable dt       = dsQR.Tables[0];
            string    pkColumn = Program.ConfigMgt.Config.PrimaryKeyColumnName;

            if (!dt.Columns.Contains(pkColumn))
            {
                return(null);
            }

            Dictionary <string, List <DataRow> > drDict = new Dictionary <string, List <DataRow> >();

            foreach (DataRow dr in dt.Rows)
            {
                string key     = null;
                string pkValue = dr[pkColumn] as string;
                //if (pkValue != null || pkValue.Length > 0)
                if (pkValue != null && pkValue.Length > 0)
                {
                    key = pkValue;
                }
                else
                {
                    key = "_" + dt.Rows.IndexOf(dr).ToString();
                }

                if (drDict.ContainsKey(key))
                {
                    drDict[key].Add(dr);
                }
                else
                {
                    List <DataRow> drList = new List <DataRow>();
                    drDict.Add(key, drList);
                    drList.Add(dr);
                }
            }

            List <DElementListWrapper> dcmResult = new List <DElementListWrapper>();

            foreach (KeyValuePair <string, List <DataRow> > pair in drDict)
            {
                int          count      = qrList.Count;
                DicomDataset dcmEleList = new DicomDataset();
                for (int index = 0; index < count; index++)
                {
                    IDicomMappingItem qr = qrList[index] as IDicomMappingItem;
                    if (!qr.DPath.Enable)
                    {
                        continue;
                    }
                    //int tag = qr.DPath.GetTag(0);
                    List <string> tagList  = qr.DPath.GetTagGE(0);
                    ushort        uGroup   = DHelper.HexString2ushort(tagList[0]);
                    ushort        uElement = DHelper.HexString2ushort(tagList[1]);
                    DicomTag      tag      = new DicomTag(uGroup, uElement);
                    FillElement <TR>(dcmEleList, tag, qr.DPath.VR, ref index, 0, qrList, pair.Value.ToArray());
                    //dcmEleList.Add(ele);
                }
                DElementListWrapper w = new DElementListWrapper(dcmEleList);
                foreach (DataRow dr in pair.Value)
                {
                    w.GUIDs.Add(DicomMappingHelper.GetGUID(dr));
                }
                dcmResult.Add(w);
            }

            return(dcmResult.ToArray());
        }
コード例 #13
0
        public static void ModifyQCMappingList_CS <TC>(XCollection <TC> qcList, bool withBracket)
            where TC : QueryCriteriaItem, IDicomMappingItem, new()
        {
            if (qcList == null)
            {
                return;
            }
            bool found = true;

            while (found)
            {
                found = false;
                int count = qcList.Count;
                for (int index = 0; index < count; index++)
                {
                    TC item = qcList[index];

                    IDicomMappingItem dcmItem = item as IDicomMappingItem;
                    if (dcmItem == null)
                    {
                        continue;
                    }

                    if (dcmItem.DPath != null &&
                        dcmItem.DPath.VR == DVR.CS &&
                        dcmItem.DPath.Path == DicomMappingHelper.DataColumnName2DPath(item.SourceField))
                    {
                        qcList.Remove(item);

                        if (withBracket)    // for GetRule()
                        {
                            qcList.Insert(index, DicomMappingHelper.GetRightBracket <TC>());
                        }

                        for (int i = Program.ConfigMgt.Config.CSDivisionMAXCount - 1; i >= 0; i--)  // for GetRule() and for NT Service to create QC DataSet
                        {
                            QueryCriteriaItem itemSub = dcmItem.Clone() as QueryCriteriaItem;
                            itemSub.SourceField = itemSub.SourceField + "_" + i.ToString();
                            itemSub.Operator    = QueryCriteriaOperator.Like;
                            if (i == 0)
                            {
                                itemSub.Type = QueryCriteriaType.None;
                            }
                            else
                            {
                                itemSub.Type = QueryCriteriaType.Or;
                            }
                            qcList.Insert(index, itemSub);
                        }

                        if (withBracket)    // for GetRule()
                        {
                            TC itemAnd = DicomMappingHelper.GetLeftBracket <TC>();
                            itemAnd.Type = QueryCriteriaType.And;
                            qcList.Insert(index, itemAnd);
                        }

                        found = true;
                        break;
                    }
                }
            }
        }