コード例 #1
0
        public void insertImageInfo(DicomInfo dicom)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(ConnectionManager.getConnection))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("spr_InsertImageProperties_v001", conn);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@id", SqlDbType.Int).Value             = dicom.databaseID;
                    cmd.Parameters.Add("@seriesUID", SqlDbType.VarChar).Value  = dicom.seriesUID;
                    cmd.Parameters.Add("@modality", SqlDbType.VarChar).Value   = dicom.modality;
                    cmd.Parameters.Add("@bodyPart", SqlDbType.VarChar).Value   = dicom.bodyPart;
                    cmd.Parameters.Add("@studyDesc", SqlDbType.VarChar).Value  = dicom.studyDesc;
                    cmd.Parameters.Add("@seriesDesc", SqlDbType.VarChar).Value = dicom.seriesDesc;
                    cmd.Parameters.Add("@sliceThick", SqlDbType.VarChar).Value = dicom.sliceThickness;

                    dicom.seriesID = (Int32)cmd.ExecuteScalar();
                    Console.WriteLine("Images Success");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine("");
            }
        }
コード例 #2
0
        public void insertPatient(DicomInfo dicom)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(ConnectionManager.getConnection))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("spr_InsertPatient_v001", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@id", SqlDbType.VarChar).Value       = dicom.pID;
                    cmd.Parameters.Add("@studyUID", SqlDbType.VarChar).Value = dicom.studyUID;
                    cmd.Parameters.Add("@birthday", SqlDbType.VarChar).Value = dicom.pBday;
                    cmd.Parameters.Add("@age", SqlDbType.VarChar).Value      = dicom.age;
                    cmd.Parameters.Add("@sex", SqlDbType.Char, 1).Value      = dicom.sex;
                    cmd.Parameters.Add("@series", SqlDbType.Int).Value       = 1;

                    dicom.databaseID = (Int32)cmd.ExecuteScalar();
                    Console.WriteLine("Patient Success");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine("");
            }
        }
コード例 #3
0
ファイル: Process.cs プロジェクト: g4idrijs/DIPS
        private void CheckIfPatientExist(DicomInfo dicom)
        {
            DAOGeneral dao = new DAOGeneral();

            if ((dicom.studyUID.Length != 0 && dicom.seriesUID.Length != 0) && dicom.imageUID.Length != 0)
            {
                dao.patientExist(dicom);
                if (dicom.patientExist == true)
                {
                    dao.seriesExist(dicom);
                }
                if (dicom.sameSeries == true)
                {
                    dao.retrieveImageNumber(dicom);
                }
            }
            else
            {
                dao.patientExistBackup(dicom);
                if (dicom.sameSeries == true)
                {
                    dao.retrieveImageNumber(dicom);
                }
            }

            if (dicom.patientExist == false)
            {
                PatientID id = new PatientID();
                dicom.pID = id.generate();
            }
            else if (dicom.sameSeries == false)
            {
                dao.updatePatientSeries(dicom);
            }
        }
コード例 #4
0
 public void updatePatientSeries(DicomInfo dicom)
 {
     using (SqlConnection conn = new SqlConnection(ConnectionManager.getConnection))
     {
         conn.Open();
         SqlCommand cmd3 = new SqlCommand("spr_UpdateSeriesAvailable_v001", conn);
         cmd3.CommandType = CommandType.StoredProcedure;
         cmd3.Parameters.Add("@databaseID", SqlDbType.Int).Value = dicom.databaseID;
         cmd3.ExecuteNonQuery();
     }
 }
コード例 #5
0
 public void processDicom(String filePath)
 {
     try
     {
         Process   task  = new Process();
         DicomInfo dicom = new DicomInfo();
         dicom.readFile = filePath;
         task.processDicom(dicom, filePath);
         Log.Series = dicom.seriesID;
     }
     catch (Exception e) { Console.WriteLine(e); }
 }
コード例 #6
0
 public void seriesExist(DicomInfo dicom)
 {
     using (SqlConnection conn = new SqlConnection(ConnectionManager.getConnection))
     {
         conn.Open();
         SqlCommand cmd = new SqlCommand("spr_CheckSeriesUIDExist_v001", conn);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.Add("@seriesUID", SqlDbType.VarChar).Value = dicom.seriesUID;
         SqlDataReader dataReader = cmd.ExecuteReader();
         if (dataReader.Read())
         {
             dicom.sameSeries = true;
             dicom.seriesID   = dataReader.GetInt32(0);
         }
         dataReader.Close();
     }
 }
コード例 #7
0
ファイル: readDicom.cs プロジェクト: g4idrijs/DIPS
        private void ExtractMetaData(FileStream fs, DicomInfo dicom)
        {
            DicomFileFormat dff = new DicomFileFormat();

            dff.Load(fs, DicomReadOptions.Default);
            dicom.patientName    = dff.Dataset.GetValueString(DicomTags.PatientsName);
            dicom.studyUID       = dff.Dataset.GetValueString(DicomTags.StudyInstanceUID);
            dicom.seriesUID      = dff.Dataset.GetValueString(DicomTags.SeriesInstanceUID);
            dicom.imageUID       = dff.Dataset.GetValueString(DicomTags.SOPInstanceUID);
            dicom.sex            = dff.Dataset.GetValueString(DicomTags.PatientsSex);
            dicom.pBday          = dff.Dataset.GetValueString(DicomTags.PatientsBirthDate);
            dicom.age            = dff.Dataset.GetValueString(DicomTags.PatientsAge);
            dicom.imgNumber      = dff.Dataset.GetValueString(DicomTags.InstanceNumber);
            dicom.modality       = dff.Dataset.GetValueString(DicomTags.Modality);
            dicom.bodyPart       = dff.Dataset.GetValueString(DicomTags.BodyPartExamined);
            dicom.studyDesc      = dff.Dataset.GetValueString(DicomTags.StudyDescription);
            dicom.seriesDesc     = dff.Dataset.GetValueString(DicomTags.SeriesDescription);
            dicom.sliceThickness = dff.Dataset.GetValueString(DicomTags.SliceThickness);
        }
コード例 #8
0
ファイル: readDicom.cs プロジェクト: g4idrijs/DIPS
        public void read(DicomInfo dicom)
        {
            FileStream fs = null;

            try
            {
                fs = new FileStream(dicom.readFile, FileMode.Open);
                ExtractMetaData(fs, dicom);
                nullCheck(dicom);
                fs.Close();
            }
            catch (Exception e)
            {
                fs.Close();
                dicom.fileReadable = false;
                Console.WriteLine("unable to read");
                Console.WriteLine(e);
            }
        }
コード例 #9
0
        public void imageExist(DicomInfo dicom)
        {
            using (SqlConnection conn = new SqlConnection(ConnectionManager.getConnection))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("spr_CheckSOPUIDExist_v001", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@sopUID", SqlDbType.VarChar).Value = dicom.imageUID;
                int count = (Int32)cmd.ExecuteScalar();

                if (count != 0)
                {
                    dicom.imageExist = true;
                }
                else
                {
                    Log.NeedUpdate = true;
                }
            }
        }
コード例 #10
0
 private Boolean allMatched(DicomInfo dicom, SqlDataReader dataReader)
 {
     if (!dicom.modality.Equals(dataReader.GetString(dataReader.GetOrdinal("Modality"))))
     {
         return(false);
     }
     if (!dicom.bodyPart.Equals(dataReader.GetString(dataReader.GetOrdinal("Body Parts"))))
     {
         return(false);
     }
     if (!dicom.studyDesc.Equals(dataReader.GetString(dataReader.GetOrdinal("Study Description"))))
     {
         return(false);
     }
     if (!dicom.seriesDesc.Equals(dataReader.GetString(dataReader.GetOrdinal("Series Description"))))
     {
         return(false);
     }
     return(true);
 }
コード例 #11
0
        public void retrieveImageNumber(DicomInfo dicom)
        {
            using (SqlConnection conn = new SqlConnection(ConnectionManager.getConnection))
            {
                conn.Open();
                SqlCommand cmd2 = new SqlCommand("spr_RetrieveImageNumber_v001", conn);
                cmd2.CommandType = CommandType.StoredProcedure;
                cmd2.Parameters.Add("@databaseID", SqlDbType.VarChar).Value = dicom.databaseID;
                cmd2.Parameters.Add("@classID", SqlDbType.VarChar).Value    = dicom.seriesID;
                cmd2.Parameters.Add("@number", SqlDbType.VarChar).Value     = dicom.imgNumber;
                int count = (Int32)cmd2.ExecuteScalar();

                if (count != 0)
                {
                    dicom.imageExist = true;
                }
                else
                {
                    Log.NeedUpdate = true;
                }
            }
        }
コード例 #12
0
        public void patientExistBackup(DicomInfo dicom)
        {
            using (SqlConnection conn = new SqlConnection(ConnectionManager.getConnection))
            {
                conn.Open();
                Encryption name = new Encryption();
                SqlCommand cmd  = new SqlCommand("spr_CheckPatientExist_v001", conn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@birthdate", SqlDbType.VarChar).Value = dicom.pBday;
                cmd.Parameters.Add("@age", SqlDbType.VarChar).Value       = dicom.age;
                cmd.Parameters.Add("@sex", SqlDbType.Char).Value          = dicom.sex;

                SqlDataReader dataReader = cmd.ExecuteReader();

                while (dataReader.Read())
                {
                    if (dicom.patientName.Length != 0 && dicom.patientExist == false)
                    {
                        int    tempID   = dataReader.GetInt32(dataReader.GetOrdinal("Patient ID"));
                        String tempName = dataReader.GetString(dataReader.GetOrdinal("Patient Name"));

                        if (name.Decrypt(tempName, tempID).Equals(dicom.patientName))
                        {
                            dicom.patientExist = true;
                            dicom.databaseID   = tempID;
                        }
                    }
                    if (dicom.patientExist == true && allMatched(dicom, dataReader))
                    {
                        dicom.sameSeries = true;
                        dicom.seriesID   = dataReader.GetInt32(dataReader.GetOrdinal("Series ID"));
                        break;
                    }
                }
                dataReader.Close();
            }
        }
コード例 #13
0
        public void insertImageFile(DicomInfo dicom, String filePath)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(ConnectionManager.getConnection))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("spr_InsertImages_v001", conn);
                    cmd.CommandType = CommandType.StoredProcedure;

                    readImage image = new readImage();
                    byte[]    blob  = image.blob(filePath);

                    cmd.Parameters.Add("@imgID", SqlDbType.Int).Value      = dicom.seriesID;
                    cmd.Parameters.Add("@imgUID", SqlDbType.VarChar).Value = dicom.imageUID;
                    cmd.Parameters.Add("@imgNum", SqlDbType.VarChar).Value = dicom.imgNumber;
                    if (blob != null)
                    {
                        cmd.Parameters.Add("@imgBlob", SqlDbType.VarBinary, blob.Length).Value = blob;
                    }

                    cmd.ExecuteNonQuery();
                    Console.WriteLine("Image File Success");
                }
            }
            catch (SqlException e)
            {
                if (e.Number == 2627)
                {
                    Console.WriteLine("image existed");
                }
                else
                {
                    Console.WriteLine(e);
                    Console.WriteLine("");
                }
            }
        }
コード例 #14
0
ファイル: Process.cs プロジェクト: g4idrijs/DIPS
        public void processDicom(DicomInfo dicom, String filePath)
        {
            verifyDicom verify     = new verifyDicom();
            Boolean     validDicom = verify.verify(filePath);

            if (validDicom == true)
            {
                dicom.fileReadable = true;
                readDicom reader = new readDicom();
                reader.read(dicom);

                if (dicom.fileReadable == true)
                {
                    CheckIfPatientExist(dicom);
                    InsertToDatabase database = new InsertToDatabase();
                    database.insert(dicom, filePath);
                }
            }
            else
            {
                Console.WriteLine("Not a Valid DICOM file");
            }
        }
コード例 #15
0
        public void insertName(DicomInfo dicom)
        {
            try
            {
                Encryption name       = new Encryption();
                String     encrypyted = name.Encrypt(dicom.patientName, dicom.databaseID);

                using (SqlConnection conn = new SqlConnection(ConnectionManager.getConnection))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("spr_InsertName_v001", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@id", SqlDbType.Int).Value        = dicom.databaseID;
                    cmd.Parameters.Add("@pName", SqlDbType.VarChar).Value = encrypyted;
                    cmd.ExecuteNonQuery();
                    Console.WriteLine("Name Success");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine("");
            }
        }
コード例 #16
0
ファイル: readDicom.cs プロジェクト: g4idrijs/DIPS
        public void nullCheck(DicomInfo dicom)
        {
            if (String.IsNullOrEmpty(dicom.patientName))
            {
                dicom.patientName = String.Empty;
            }
            else
            {
                try
                {
                    var splitName = new StringBuilder(dicom.patientName);
                    splitName.Replace('^', ' ');
                    dicom.patientName = splitName.ToString();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    dicom.patientName = dicom.patientName;
                }
            }

            if (dicom.studyUID == null)
            {
                dicom.studyUID = String.Empty;
            }
            if (dicom.seriesUID == null)
            {
                dicom.seriesUID = String.Empty;
            }
            if (dicom.imageUID == null)
            {
                dicom.imageUID = String.Empty;
            }
            if (String.IsNullOrEmpty(dicom.sex))
            {
                dicom.sex = String.Empty;
            }
            else if (dicom.sex[0] == 'M' || dicom.sex[0] == 'F')
            {
                dicom.sex = dicom.sex.Substring(0, 1);
            }
            if (!String.IsNullOrEmpty(dicom.imgNumber))
            {
                dicom.imgNumber = dicom.imgNumber.PadLeft(2, '0');
            }
            if (dicom.pBday == null)
            {
                dicom.pBday = String.Empty;
            }
            if (dicom.age == null)
            {
                dicom.age = String.Empty;
            }
            if (dicom.imgNumber == null)
            {
                dicom.imgNumber = String.Empty;
            }
            if (dicom.modality == null)
            {
                dicom.modality = String.Empty;
            }
            if (dicom.bodyPart == null)
            {
                dicom.bodyPart = String.Empty;
            }
            if (dicom.studyDesc == null)
            {
                dicom.studyDesc = String.Empty;
            }
            if (dicom.seriesDesc == null)
            {
                dicom.seriesDesc = String.Empty;
            }
            if (dicom.sliceThickness == null)
            {
                dicom.sliceThickness = String.Empty;
            }
        }