Exemple #1
0
        /// <summary>
        /// If the ‘update’ parameter is true, replaces all the DataSet 'Series' table information with the corresponding information from the DicomDataSet.
        /// </summary>
        /// <param name="series">Row of the 'series' table that is being udpated</param>
        /// <param name="ds"></param>
        /// <param name="ds">The Leadtools.Dicom.DicomDataSet that is being stored</param>
        /// <param name="instanceDataSet">The DataSet that contains the patient, study, series, and instance tables</param>
        /// <param name="seriesInstanceUID">The SeriesInstanceUID of the study row being udpated</param>
        /// <param name="retrieveAE">retrieveAe">AE Title of the client doing the retrieval</param>
        /// <param name="update">If 'true', updates the DataSet 'Series' table information with the corresponding information from the DicomDataSet</param>
        /// <remarks>
        /// This method needs to change based on your schema.  For the MyDicomDb schema, we update all fields in the 'study' table
        /// <list>
        /// <item>SeriesNumber</item>
        /// <item>SeriesDate</item>
        /// <item>SeriesDescription</item>
        /// <item>Modality</item>
        /// <item>BodyPartExamined</item>
        /// </list>
        /// </remarks>
        private void FillSeriesInformation(MyDataSet.MySeriesTableRow series, DicomDataSet ds, MyDataSet instanceDataSet, string seriesInstanceUID, string retrieveAE, bool update)
        {
            // SeriesNumber
            int?seriesNumber = ds.MyGetIntValue(DicomTag.SeriesNumber);

            if (CanSetValue(seriesNumber, update, series, instanceDataSet.MySeriesTable.SeriesSeriesNumberColumn))
            {
                series.SeriesSeriesNumber = seriesNumber.Value;
            }

            // SeriesDate
            DateTime?seriesDate = ds.MyGetDateTime(DicomTag.SeriesDate, DicomTag.SeriesTime);

            if (CanSetValue(seriesDate, update, series, instanceDataSet.MySeriesTable.SeriesSeriesDateColumn))
            {
                series.SeriesSeriesDate = seriesDate.Value;
            }

            // SeriesDescription
            string seriesDescription = ds.MyGetStringValue(DicomTag.SeriesDescription, AutoTruncate, instanceDataSet.MySeriesTable.SeriesSeriesDescriptionColumn.MaxLength);

            if (CanSetValue(seriesDescription, update, series, instanceDataSet.MySeriesTable.SeriesSeriesDescriptionColumn))
            {
                series.SeriesSeriesDescription = seriesDescription;
            }

            // Modality
            string seriesModality = ds.MyGetStringValue(DicomTag.Modality, AutoTruncate, instanceDataSet.MySeriesTable.SeriesModalityColumn.MaxLength);

            if (CanSetValue(seriesModality, update, series, instanceDataSet.MySeriesTable.SeriesModalityColumn))
            {
                series.SeriesModality = seriesModality;
            }

            // BodyPartExamined
            string bodyPartExamined = ds.MyGetStringValue(DicomTag.BodyPartExamined, AutoTruncate, instanceDataSet.MySeriesTable.SeriesBodyPartExaminedColumn.MaxLength);

            if (CanSetValue(bodyPartExamined, update, series, instanceDataSet.MySeriesTable.SeriesBodyPartExaminedColumn))
            {
                series.SeriesBodyPartExamined = bodyPartExamined;
            }

            series.SeriesStudyId = -1;
        }
Exemple #2
0
        /// <summary>
        /// Adds a new row to the DataSet Study Table (MySeriesTable) if the DicomDataSet SeriesInstanceUID does not already exist
        /// </summary>
        /// <param name="ds">The Leadtools.Dicom.DicomDataSet that is being stored</param>
        /// <param name="instanceDataSet">The DataSet that contains the patient, study, series, and instance tables</param>
        /// <param name="updateExistentPatient">If 'true', update the existing patient with information from dicomDataSet</param>
        /// <param name="retrieveAe">retrieveAe">AE Title of the client doing the retrieval</param>
        private void FillSeriesData(DicomDataSet ds, MyDataSet instanceDataSet, bool updateExistentSeries, string retrieveAe)
        {
            // studyInstanceUID = GetStringValue(dicomDataSet, DicomTag.StudyInstanceUID, AutoTruncate, instanceDataSet.Series.MaxLength);
            string seriesInstanceUID = ds.MyGetStringValue(DicomTag.SeriesInstanceUID, AutoTruncate, instanceDataSet.MySeriesTable.SeriesSeriesInstanceUIDColumn.MaxLength);

            if (/* null == studyInstanceUID  || */ null == seriesInstanceUID)
            {
                return;
            }

            // MyDataSet.SeriesRow seriesRow = instanceDataSet.Series.FindBySeriesInstanceUID(seriesInstanceUID);
            MyDataSet.MySeriesTableRow seriesRow = null;
            DataRow[] rows = instanceDataSet.MySeriesTable.Select(string.Format("SeriesSeriesInstanceUID = '{0}'", seriesInstanceUID));
            MyDataSet.MySeriesTableRow[] seriesRows = (MyDataSet.MySeriesTableRow[])rows;
            if (seriesRows != null && seriesRows.Length > 0)
            {
                seriesRow = seriesRows[0];
            }

            bool seriesFound = (null != seriesRow);

            if (!seriesFound)
            {
                seriesRow = instanceDataSet.MySeriesTable.NewMySeriesTableRow();

                // seriesRow.StudyInstanceUID = studyInstanceUID;
                seriesRow.SeriesSeriesInstanceUID = seriesInstanceUID;

                instanceDataSet.MySeriesTable.AddMySeriesTableRow(seriesRow);
            }
            else if (!updateExistentSeries)
            {
                return;
            }

            FillSeriesInformation(seriesRow,
                                  ds,
                                  instanceDataSet,
                                  seriesInstanceUID,
                                  retrieveAe,
                                  updateExistentSeries);
        }
Exemple #3
0
        internal static void UpdateCompositeInstance
        (
            MyDataSet compositeInstanceDataSet,
            DbConnection connection,
            MyUpdateTableDelegate updateTable
        )
        {
            try
            {
                DbTransaction DbTransaction = null;

                connection.Open();

                try
                {
                    try
                    {
                        MyDataSet.MyPatientTableRow  patientRow = compositeInstanceDataSet.Tables["MyPatientTable"].Rows[0] as MyDataSet.MyPatientTableRow;
                        MyDataSet.MyStudyTableRow    studyRow   = compositeInstanceDataSet.Tables["MyStudyTable"].Rows[0] as MyDataSet.MyStudyTableRow;
                        MyDataSet.MySeriesTableRow   seriesRow  = compositeInstanceDataSet.Tables["MySeriesTable"].Rows[0] as MyDataSet.MySeriesTableRow;
                        MyDataSet.MyInstanceTableRow dimageRow  = compositeInstanceDataSet.Tables["MyInstanceTable"].Rows[0] as MyDataSet.MyInstanceTableRow;

                        int?patientId = -1;
                        int?studyId   = -1;
                        int?seriesId  = -1;

                        // *************************
                        // Patient
                        // *************************
                        DbTransaction = connection.BeginTransaction();
                        UpdatePatientDataset(compositeInstanceDataSet,
                                             connection,
                                             DbTransaction,
                                             updateTable);
                        DbTransaction.Commit();

                        // Use the last generated PatientId -- if RowState is 'unchanged', nothing gets updated in the patientRow
                        // In this case, we need to read the patientId from the database
                        patientId = patientRow.PatientId;
                        if (patientId == -1)
                        {
                            patientId = GetIntValue(connection, "MyPatientTable", "patientId", "PatientIdentification", patientRow.PatientIdentification);
                        }

                        // *************************
                        // Study
                        // *************************
                        DbTransaction = connection.BeginTransaction();
                        if ((studyRow.RowState != DataRowState.Unchanged && studyRow.StudyPatientId == -1) && (patientId != null))
                        {
                            studyRow.StudyPatientId = patientId.Value;
                        }
                        UpdateStudyDataset(compositeInstanceDataSet,
                                           connection,
                                           DbTransaction,
                                           updateTable);
                        DbTransaction.Commit();

                        studyId = studyRow.StudyId;
                        if (studyId == -1)
                        {
                            studyId = GetIntValue(connection, "MyStudyTable", "studyId", "StudyStudyInstanceUID", studyRow.StudyStudyInstanceUID);
                        }

                        // *************************
                        // Series
                        // *************************
                        // Use the last generated StudyId
                        DbTransaction = connection.BeginTransaction();
                        if ((seriesRow.RowState != DataRowState.Unchanged && seriesRow.SeriesStudyId == -1) && (studyId != null))
                        {
                            seriesRow.SeriesStudyId = studyId.Value;
                        }
                        UpdateSeriesDataset(compositeInstanceDataSet,
                                            connection,
                                            DbTransaction,
                                            updateTable);
                        DbTransaction.Commit();

                        seriesId = seriesRow.SeriesId;
                        if (seriesId == -1)
                        {
                            seriesId = GetIntValue(connection, "MySeriesTable", "SeriesId", "SeriesSeriesInstanceUID", seriesRow.SeriesSeriesInstanceUID);
                        }

                        // *************************
                        // Instance
                        // *************************
                        // Use the last generated SeriesId
                        DbTransaction = connection.BeginTransaction();
                        if ((dimageRow.RowState != DataRowState.Unchanged && dimageRow.ImageSeriesId == -1) && (seriesId != null))
                        {
                            dimageRow.ImageSeriesId = seriesId.Value;
                        }
                        UpdateInstanceDataset(compositeInstanceDataSet,
                                              connection,
                                              DbTransaction,
                                              updateTable);

                        DbTransaction.Commit();
                    }
                    catch (Exception exception)
                    {
                        System.Diagnostics.Debug.Assert(false, exception.ToString());

                        DbTransaction.Rollback();

                        throw;
                    }
                }
                finally
                {
                    connection.Close();
                }

                compositeInstanceDataSet.AcceptChanges();
            }
            catch (Exception exception)
            {
                System.Diagnostics.Debug.WriteLine(exception.Message);
                System.Diagnostics.Debug.Assert(false);

                throw;
            }
        }