예제 #1
0
파일: DROC.cs 프로젝트: khaha2210/radio
        void EditWL()
        {
            try
            {
                DataRow _dr = null;
                frm_Registration newForm = new frm_Registration(m_intCurrDevice1);
                if (_currTab == AppType.AppEnum.TabMode.Acq)
                {
                    if (_LastDoubleMode == AppType.AppEnum.DoubleMode.WorkList)
                    {
                        Utility.GotoNewRow(grdWorkList, "colPATIENT_CODE", txtID2.Text.Trim());
                        if (grdWorkList.RowCount <= 0 || grdWorkList.CurrentRow == null)
                        {
                            Utility.ShowMsg("Bạn phải chọn Bệnh nhân trên lưới để sửa", "Thông báo");
                            grdWorkList.Focus();
                            return;
                        }
                        _dr = ((DataRowView)grdWorkList.CurrentRow.DataBoundItem).Row;
                        newForm.grdList = grdWorkList;
                    }
                    if (_LastDoubleMode == AppType.AppEnum.DoubleMode.StudyList)
                    {
                        Utility.GotoNewRow(grdStudyList, "colPATIENT_CODE1", txtID2.Text.Trim());
                        if (grdStudyList.RowCount <= 0 || grdStudyList.CurrentRow == null)
                        {
                            Utility.ShowMsg("Bạn phải chọn Bệnh nhân  trên lưới để sửa", "Thông báo");
                            grdStudyList.Focus();
                            return;
                        }
                        _dr = ((DataRowView)grdStudyList.CurrentRow.DataBoundItem).Row;
                        newForm.grdList = grdStudyList;
                    }
                }

                if (_currTab == AppType.AppEnum.TabMode.WorkList)
                {
                    if (grdWorkList.RowCount <= 0 || grdWorkList.CurrentRow == null)
                    {
                        Utility.ShowMsg("Bạn phải chọn Bệnh nhân trên lưới để sửa", "Thông báo");
                        grdWorkList.Focus();
                        return;
                    }
                    _dr = ((DataRowView)grdWorkList.CurrentRow.DataBoundItem).Row;
                    newForm.grdList = grdWorkList;
                }
                if (_currTab == AppType.AppEnum.TabMode.StudyList)
                {
                    if (grdStudyList.RowCount <= 0 || grdStudyList.CurrentRow == null)
                    {
                        Utility.ShowMsg("Bạn phải chọn Bệnh nhân  trên lưới để sửa", "Thông báo");
                        grdStudyList.Focus();
                        return;
                    }
                    _dr = ((DataRowView)grdStudyList.CurrentRow.DataBoundItem).Row;
                    newForm.grdList = grdStudyList;
                }

                newForm.ImgPath = txtImgDir.Text.Trim();


                newForm.Act = action.Update;
                //newForm.lblmsg1 = lblMsg;

                newForm.dr = _dr;
                Hasresult = new RegDetailController().HasResult(Convert.ToInt64(_dr["REG_ID"]));
                newForm.Hasresult = Hasresult;
                newForm.ShowDialog();
                if (newForm.blnRegOK)
                {
                    string Folder2Changed = "";
                    //Tự động update sang phần ACQ
                    UpdatePinforinAcqTab(Utility.Int32Dbnull(newForm.dr["Patient_ID"], -1));
                    //Kiểm tra nếu tên tuổi hoặc giới tính khác thông tin cũ thì tạo luồng cập nhật dữ liệu trong các file ảnh dicom
                    if (newForm.oldSex.Trim().ToUpper() != newForm.NewSex.Trim().ToUpper() || newForm.oldName.Trim().Replace(newForm.oldAge.Trim().ToUpper(), "").Trim().ToUpper() != newForm.NewName.Trim().Replace(newForm.NewAge.Trim().ToUpper(), "").Trim().ToUpper() || newForm.oldAge.Trim().ToUpper() != newForm.NewAge.Trim().ToUpper())
                    {

                        //Duyệt tất cả các ảnh trong thư mục ảnh của BN ở thời điểm hiện tại
                        if (newForm.oldFolderName.Trim().ToUpper() == newForm.newFolderName.Trim().ToUpper())
                        {
                            Folder2Changed = newForm.oldFolderName;
                        }
                        else//Tất cả các ảnh đã được chuyển sang thư mục mới-->Cần thay đổi thông tin dicomdataset trong thư mục mới
                        {
                            Folder2Changed = newForm.newFolderName;
                        }
                        //Thực hiện duyệt các file Dicom ko có chữ IDX
                        string[] files = Directory.GetFiles(newForm.oldFolderName);
                        foreach (string _fileName in files)
                        {
                            if (Path.GetExtension(_fileName).Trim().Contains("DCM") && !Path.GetExtension(_fileName).Trim().Contains("_IDX"))
                            {
                                try
                                {
                                    //Update DicomDataset
                                    //using (DicomDataSet ds = new DicomDataSet())
                                    //{
                                    //    ds.Load(_fileName, DicomDataSetLoadFlags.LoadAndClose);
                                    //    if (newForm.oldSex.Trim().ToUpper() != newForm.NewSex.Trim().ToUpper())
                                    //    {
                                    //        Leadtools.DicomDemos.Utils.SetTag(ds, DicomTag.PatientSex, newForm.NewSex.Trim().ToUpper(), true);
                                    //    }
                                    //    if (newForm.oldPID.Trim().ToUpper() != newForm.NewPID.Trim().ToUpper())
                                    //    {
                                    //        Leadtools.DicomDemos.Utils.SetTag(ds, DicomTag.PatientID, newForm.NewPID.Trim().ToUpper(), true);
                                    //    }
                                    //    if (newForm.oldName.Trim().ToUpper() != newForm.NewName.Trim().ToUpper())
                                    //    {
                                    //        Leadtools.DicomDemos.Utils.SetTag(ds, DicomTag.PatientName, newForm.NewName.Trim().ToUpper(), true);
                                    //    }
                                    //    if (newForm.oldAge.Trim().ToUpper() != newForm.NewAge.Trim().ToUpper())
                                    //    {
                                    //        Leadtools.DicomDemos.Utils.SetTag(ds, DicomTag.PatientAge, newForm.NewAge.Trim().ToUpper(), true);
                                    //    }
                                    //    ds.Save(_fileName, DicomDataSetSaveFlags.None);
                                    //}
                                }
                                catch
                                {
                                }
                            }

                        }

                        //Update Thumbnail
                        UpdateThumbnailImgFolder(Folder2Changed, Convert.ToInt32(_dr["REG_ID"]));

                    }


                }
            }
            catch
            {
            }
            finally
            {
                _CurrAct = action.FirstOrFinished;
            }
        }
예제 #2
0
파일: DROC.cs 프로젝트: khaha2210/radio
 void LoadScheduled(long Reg_ID, string RegNumber2)
 {
     try
     {
         DataTable _dtAcquisitionDataSource = new RegDetailController().GetAllData(Reg_ID).Tables[0];
         CreateScheduledThumbnail(_dtAcquisitionDataSource, RegNumber2);
     }
     catch
     {
     }
 }
예제 #3
0
파일: DROC.cs 프로젝트: khaha2210/radio
 void grdWorkList_CurrentCellChanged(object sender, EventArgs e)
 {
     RegDetailController _RegDetailController = new RegDetailController();
     try
     {
         cmdEditWL.Enabled = true;
         cmdDelWL.Enabled = true;
         if (grdWorkList.CurrentRow == null)
         {
             cmdEditWL.Enabled = false;
             cmdDelWL.Enabled = false;
         }
         Int64 RegID = Convert.ToInt64(Utility.sDbnull(Utility.GetObjectValueFromGridColumn(grdWorkList, "colReg_ID", grdWorkList.CurrentRow.Index)));
         Hasresult = _RegDetailController.HasResult(RegID);
         cmdDelWL.Enabled = !Hasresult;
     }
     catch
     {
     }
 }
예제 #4
0
파일: DROC.cs 프로젝트: khaha2210/radio
        private bool BackupDataToFolder(string folderName)
        {
            try
            {
                if (!Directory.Exists(folderName)) Directory.CreateDirectory(folderName);
                DataRow[] selectecRows = m_dtStudyListDataSource.Select("Chon=1");
                if (selectecRows.Length > 0)
                {
                    var xmlDoc = new XElement("PatientList", from c in selectecRows
                                                             select new XElement("Patient",
                                                                 new XElement("ID", Utility.sDbnull(c["Reg_ID"])),
                                                                 new XElement("PID", Utility.sDbnull(c["Patient_Code"])),
                                                                 new XElement("Age", Utility.sDbnull(c["Age"])),
                                                                 new XElement("PatientName", Utility.UnSignedCharacter(Utility.sDbnull(c["Patient_Name"])))));

                    foreach (var patient in xmlDoc.Elements())
                    {
                        Console.WriteLine(patient.ToString());
                        var idPhieu = Utility.Int32Dbnull(patient.Element("ID").Value, -1);
                        var pid = Utility.sDbnull(patient.Element("PID").Value, "");
                        if (idPhieu == -1) continue;
                        DataTable dt = new RegDetailController().GetAllData(idPhieu).Tables[0];
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            AddColumToDataTable(ref dt, "Dest_File", typeof(string));
                            foreach (DataRow dr in dt.Rows)
                            {
                                string RegNumber2 = dr["Reg_NUMBER"].ToString();
                                string sourceimgfile = txtImgDir.Text.Trim() + @"\" + SubDirLv1(RegNumber2) + @"\" + SubDirLv2_Patient(patient.Element("PID").Value, patient.Element("PatientName").Value, patient.Element("Age").Value) + @"\" + RegNumber2 + "_" + Utility.Int32Dbnull(dr["DETAIL_ID"]).ToString() + "_" + Utility.sDbnull(dr["ANATOMY_CODE"], "") + "_" + Utility.sDbnull(dr["PROJECTION_CODE"], "") + ".DCM";
                                if (File.Exists(sourceimgfile))
                                {
                                    string desimgfile = @"IMG\" + Path.GetFileName(sourceimgfile);
                                    // string desimgfile =  Path.GetFileName(sourceimgfile);

                                    patient.Add(new XElement("File", new XAttribute("FileName", desimgfile)));
                                    if (!Directory.Exists(Path.GetDirectoryName(desimgfile))) Directory.CreateDirectory(Path.GetDirectoryName(desimgfile));

                                    desimgfile = string.Format("{0}{1}{2}", folderName, Path.DirectorySeparatorChar, desimgfile);
                                    if (!Directory.Exists(Path.GetDirectoryName(desimgfile))) Directory.CreateDirectory(Path.GetDirectoryName(desimgfile));
                                    File.Copy(sourceimgfile, desimgfile, true);
                                }
                            }
                        }
                    }

                    xmlDoc.Save(string.Format("{0}{1}PatientList.xml", folderName, Path.DirectorySeparatorChar));
                    //Mã hóa file
                    var EncryptedString = Encrypt(xmlDoc.ToString(), Encoding.ASCII.GetBytes("V")[0]);
                    File.WriteAllBytes(string.Format("{0}{1}PatientList.dat", folderName, Path.DirectorySeparatorChar), EncryptedString);

                    // Copy Dicom Viewer
                    var miniDicomViewerFolder = "MiniDicomViewer";

                    foreach (string file in Directory.GetFiles(miniDicomViewerFolder))
                        File.Copy(file,
                                  string.Format("{0}{1}{2}", folderName, Path.DirectorySeparatorChar, Path.GetFileName(file)));
                }
                return true;
            }
            catch (Exception ex)
            {
                Utility.ShowMsg("Quá trình lưu trữ dữ liệu không thành công\n" + ex.Message, "Thông báo");
                return false;
            }
        }
예제 #5
0
파일: DROC.cs 프로젝트: khaha2210/radio
 void tryUpdatePrintCount()
 {
     try
     {
         Hashtable _temp = (Hashtable)htbDetail.Clone();
         foreach (int _detail_ID in htbDetail.Keys)
         {
             new RegDetailController().UpdateCountFields(_detail_ID, "PRINTCOUNT", 1);
             _temp[_detail_ID] = new RegDetailController().GetValueOfField(_detail_ID, "PRINTCOUNT");
         }
         htbDetail = (Hashtable)_temp.Clone();
     }
     catch
     {
     }
 }
예제 #6
0
파일: DROC.cs 프로젝트: khaha2210/radio
        void S2S_CC_All()
        {
            try
            {
               

                isS2Sing = true;
                SetTextWithErr(lblS2Smsg, "", false);

                if (grdStudyList.RowCount <= 0 ) return;
                //Save to Server
                DataTable dtServerList = GetServerList();
                if (dtServerList.Rows.Count <= 0)
                {
                    Utility.ShowMsg("Chưa tồn tại danh sách các PACS Server nên bạn không thể thực hiện thao tác gửi ảnh tới Server.\nBạn hãy vào mục cấu hình và khai báo các Servers.", "Thông báo");
                    return;
                }
                int TotalPatient = m_dtStudyListDataSource.Rows.Count;
                int idx = 0;
                //Duyệt qua danh sách các BN
                //Lấy về danh sách các StoreServer
                foreach (DataRow dr1 in dtServerList.Rows)
                {
                    if (Convert.ToInt32(dr1["isActive"]) == 1)//Nếu StoreServer đang được kích hoạt
                    {
                        idx = 0;
                        string LocalAETitle = dr1["CallingAETitle"].ToString();
                        string LocalAddress = dr1["LocalAddress"].ToString();
                        string RemoteAETitle = dr1["CalledAETitle"].ToString();
                        string RemoteHost = dr1["IPAddress"].ToString();
                        int Port = Convert.ToInt32(dr1["Port"]);
                        int LocalPort = Convert.ToInt32(dr1["LocalPort"]);

                        List<StorageInstance> _storageList = new List<StorageInstance>();
                        StorageScu _storageScu = new StorageScu(LocalAETitle, RemoteAETitle, RemoteHost, Port);
                        _storageScu.ImageStoreCompleted += new EventHandler<StorageInstance>(_storageScu_ImageStoreCompleted);
                        //Lấy danh sách các ảnh để đóng gói gửi vào Server
                        foreach (DataRow dr in m_dtStudyListDataSource.Rows)
                        {
                            idx++;
                            SetTextWithErr(lblS2Smsg, "Đang gửi: " + idx.ToString() + " / " + TotalPatient.ToString(), false);
                            if (dr["CHON"].ToString() == "1")//Nếu Bn đó chọn để gửi
                            {
                                long RegID = Convert.ToInt64(dr["Reg_ID"]);
                                DataTable _dtAcquisitionDataSource = new RegDetailController().GetAllData(RegID).Tables[0];
                                if (_dtAcquisitionDataSource != null && _dtAcquisitionDataSource.Rows.Count > 0)
                                {   
                                    #region Add file để gửi tới Store Server
                                    foreach (DataRow drimage in _dtAcquisitionDataSource.Rows)
                                    {
                                        string RegNumber2 = dr["Reg_NUMBER"].ToString();
                                        string sourceimgfile = txtImgDir.Text.Trim() + @"\" + SubDirLv1(RegNumber2) + @"\" + SubDirLv2_Patient(Utility.sDbnull(dr["Patient_Code"]), Utility.sDbnull(dr["Patient_Name"]), Utility.sDbnull(dr["Age"])) + @"\" + RegNumber2 + "_" + Utility.Int32Dbnull(drimage["DETAIL_ID"]).ToString() + "_" + Utility.sDbnull(drimage["ANATOMY_CODE"], "") + "_" + Utility.sDbnull(drimage["PROJECTION_CODE"], "") + ".DCM";
                                        if (File.Exists(sourceimgfile))
                                        {
                                            string ErrorMsg = "";
                                            string SuccessConnect = "";
                                            try
                                            {
                                                if (_storageScu == null) return;
                                                _storageList.Add(new StorageInstance(sourceimgfile));
                                                AppLogger.LogAction.AddLog2List(lstFPD560, "CC-->CStore Added file:" + sourceimgfile);

                                            }
                                            catch (Exception ex)
                                            {
                                                AppLogger.LogAction.AddLog2List(lstFPD560, "CC-->Exception:" + ex.Message);
                                            }
                                        }

                                    }
                                    #endregion

                                    //_storageScu.Send(LocalAETitle, RemoteAETitle, RemoteHost, Port);
                                        AppLogger.LogAction.AddLog2List(lstFPD560, "CC-->Send OK");

                                        if (new RegController().UpdateStatus(RegID, 3) == ActionResult.Success)
                                        {
                                            DataRow[] arrDr = m_dtStudyListDataSource.Select("REG_ID=" + RegID);
                                            if (arrDr.GetLength(0) > 0)
                                            {
                                                if (arrDr[0]["REGSTATUS"].ToString() != "2")
                                                    arrDr[0]["REGSTATUS"] = 3;
                                            }
                                            arrDr = m_dtWLDataSource.Select("REG_ID=" + RegID);
                                            if (arrDr.GetLength(0) > 0)
                                            {
                                                if (arrDr[0]["REGSTATUS"].ToString() != "2")
                                                    arrDr[0]["REGSTATUS"] = 3;
                                            }
                                            arrDr = m_dtWLDataSource_Suspending.Select("REG_ID=" + RegID);
                                            if (arrDr.GetLength(0) > 0)
                                            {
                                                if (arrDr[0]["REGSTATUS"].ToString() != "2")
                                                    arrDr[0]["REGSTATUS"] = 3;
                                            }
                                            m_dtStudyListDataSource.AcceptChanges();
                                            m_dtWLDataSource.AcceptChanges();
                                            m_dtWLDataSource_Suspending.AcceptChanges();

                                        }
                                }

                            }
                        }
                        if (_storageList.Count > 0)
                        {
                            while (!canbeContinued)
                            {
                            }
                            canbeContinued = false;
                            _storageScu.AddStorageInstanceList(_storageList);
                            _storageScu.BeginSend(InstanceSent, _storageScu);
                        }
                    }
                }
                //Update Datasource and reg Status
                SetTextWithErr(lblS2Smsg, "Đã gửi dữ liệu thành công!", false);
            }
            catch (Exception ex1)
            {
                AppLogger.LogAction.AddLog2List(lstFPD560, "CC-->Exception:" + ex1.Message);
            }
            finally
            {
                isS2Sing = false;
            }
        }