Ejemplo n.º 1
0
        /*
         * Creates and modifies the meta header for this dataset
         */
        private void InsertMetaHeader(ref DicomDataSet pDS)
        {
            DicomElement element;

            // Add File Meta Information Version
            element = pDS.FindFirstElement(null, DemoDicomTags.FileMetaInformationVersion, false);
            if (element == null)
            {
                element = pDS.InsertElement(null, false, DemoDicomTags.FileMetaInformationVersion, DicomVRType.OB, false, 0);
            }
            byte[] cValue = new byte[2] {
                0, 1
            };
            pDS.SetBinaryValue(element, cValue, 2);

            // Implementation Class UID
            element = pDS.FindFirstElement(null, DemoDicomTags.ImplementationClassUID, false);
            if (element == null)
            {
                element = pDS.InsertElement(null, false, DemoDicomTags.ImplementationClassUID, DicomVRType.UI, false, 0);
            }
            pDS.SetConvertValue(element, LEAD_IMPLEMENTATION_CLASS_UID, 1);

            // Implementation Version Name
            element = pDS.FindFirstElement(null, DemoDicomTags.ImplementationVersionName, false);
            if (element == null)
            {
                element = pDS.InsertElement(null, false, DemoDicomTags.ImplementationVersionName, DicomVRType.UI, false, 0);
            }
            pDS.SetConvertValue(element, LEAD_IMPLEMENTATION_VERSION_NAME, 1);
        }
Ejemplo n.º 2
0
        private DicomDataSet BuildDataset(DicomClient client, StorageCommit.StorageCommit commit, string serverAE)
        {
            DicomDataSet ds      = new DicomDataSet(null);
            DicomElement success = null;
            DicomElement failed  = null;

            ds.Initialize(DicomClassType.Undefined, DicomDataSetInitializeType.ExplicitVRLittleEndian);
            ds.InsertElementAndSetValue(DicomTag.TransactionUID, commit.TransactionUID);
            ds.InsertElementAndSetValue(DicomTag.RetrieveAETitle, serverAE);

            if (commit.SameStudy && !commit.IsSameStudy())
            {
                Logger.Global.Error("Storage Commit AddIn", "N-EVENT-REPORT: Referenced SOP Sequence does not have same StudyInstanceUID");
                foreach (StorageCommitItem item in commit.Items)
                {
                    item.Status = DicomCommandStatusType.ProcessingFailure;
                }
            }

            if (commit.SuccessCount > 0)
            {
                success = ds.InsertElement(null, true, DicomTag.ReferencedSOPSequence, DicomVRType.SQ, true, 0);
            }

            if (commit.FailedCount > 0)
            {
                failed = ds.InsertElement(null, true, DicomTag.FailedSOPSequence, DicomVRType.SQ, true, 0);
            }

            foreach (StorageCommitItem item in commit.Items)
            {
                DicomElement sequence     = null;
                DicomElement sequenceItem = null;

                if (item.Status == DicomCommandStatusType.Success)
                {
                    sequence = success;
                }
                else
                {
                    sequence = failed;
                }

                sequenceItem = ds.InsertElement(sequence, true, DicomTag.Item, DicomVRType.SQ, false, -1);
                ds.InsertElementAndSetValue(sequenceItem, true, DicomTag.ReferencedSOPClassUID, item.SOPClassUID);
                ds.InsertElementAndSetValue(sequenceItem, true, DicomTag.ReferencedSOPInstanceUID, item.SOPInstanceUID);

                if (sequence == failed)
                {
                    ds.InsertElementAndSetValue(sequenceItem, true, DicomTag.FailureReason, Convert.ToInt16(item.Status));
                }
            }

            return(ds);
        }
Ejemplo n.º 3
0
        public static void SetTag(DicomDataSet dcm, long Sequence, long Tag, object TagValue)
        {
            DicomElement seqElement = dcm.FindFirstElement(null, Sequence, true);
            DicomElement seqItem    = null;
            DicomElement item       = null;

            if (seqElement == null)
            {
                seqElement = dcm.InsertElement(null, false, Tag, DicomVRType.SQ, true, -1);
            }

            seqItem = dcm.GetChildElement(seqElement, false);
            if (seqItem == null)
            {
#if (LTV15_CONFIG)
                seqItem = dcm.InsertElement(seqElement, true, DicomTagType.SequenceDelimitationItem, DicomVRType.SQ, true, -1);
#else
                seqItem = dcm.InsertElement(seqElement, true, DicomTag.SequenceDelimitationItem, DicomVRType.SQ, true, -1);
#endif
            }

            item = dcm.GetChildElement(seqItem, true);
            while (item != null)
            {
#if (LTV15_CONFIG)
                if ((long)item.Tag == Tag)
                {
                    break;
                }
#else
                if (item.Tag == Tag)
                {
                    break;
                }
#endif

                item = dcm.GetNextElement(item, true, true);
            }

            if (item == null)
            {
                item = dcm.InsertElement(seqItem, true, Tag, DicomVRType.UN, false, -1);
            }
            dcm.SetConvertValue(item, TagValue.ToString(), 1);
        }
Ejemplo n.º 4
0
        public void SendDownloadRequest(object param)
        {
            try
            {
                DicomDataSet ds = new DicomDataSet();

                //you can set what ever elements you need, PatientID, StudyInstanceUID, SeriesInstnaceUID...
                //if you need to create private tags to set custom information we have to do it like this:
                // check this link for more information about creating custom tags:
                //https://www.leadtools.com/help/leadtools/v175/dh/di/leadtools.dicom~leadtools.dicom.dicomdataset~createprivatecreatordataelement.html

                {
                    DicomElement privateCreatorElement = ds.CreatePrivateCreatorDataElement(null, 0x0017, 0x0012, "DownloadService");

                    DicomElement element = ds.InsertElement(null, false, CustomTags.JobID, DicomVRType.LT, false, 0);

                    if (null != element)
                    {
                        ds.SetStringValue(element, param.ToString(), DicomCharacterSetType.Default); //(0x11,0x0010)
                    }
                    else
                    {
                        throw new Exception("Can't Insert Element");
                    }
                }

                byte presentation = GetPresentation();

                SendNActionRequest(presentation, 1, CustomUID.DownloadImagesClass, CustomUID.DownloadImagesInstance, 1, ds);

                Wait(); //blocks until we receive the response from the server
                Release();

                if (_status != DicomCommandStatusType.Success)
                {
                    throw new ApplicationException("Error adding a c-move job: " + _status.ToString());
                }
                else
                {
                    //success, the server received the request and processing the message.
                }
            }
            catch (Exception e)
            {
                Logger.Global.Log(string.Empty, string.Empty, -1, string.Empty, string.Empty, -1, DicomCommandType.Undefined, DateTime.Now,
                                  LogType.Information, MessageDirection.None, e.Message, null, null);

                throw;
            }
        }
Ejemplo n.º 5
0
        /*
         * Sets the necessary UIDs in the Dataset
         */
        private void SetInstanceUIDs(ref DicomDataSet pDS)
        {
            DicomElement element;

            // Set STUDY INSTANCE UID
            element = pDS.FindFirstElement(null, DemoDicomTags.StudyInstanceUID, false);
            if (element == null)
            {
                element = pDS.InsertElement(null, false, DemoDicomTags.StudyInstanceUID, DicomVRType.UI, false, 0);
            }
            pDS.SetConvertValue(element, Utils.GenerateDicomUniqueIdentifier(), 1);

            // Set SERIES INSTANCE UID
            element = pDS.FindFirstElement(null, DemoDicomTags.SeriesInstanceUID, false);
            if (element == null)
            {
                element = pDS.InsertElement(null, false, DemoDicomTags.SeriesInstanceUID, DicomVRType.UI, false, 0);
            }
            pDS.SetConvertValue(element, Utils.GenerateDicomUniqueIdentifier(), 1);

            // Set SOP INSTANCE UID
            element = pDS.FindFirstElement(null, DemoDicomTags.SOPInstanceUID, false);
            if (element == null)
            {
                element = pDS.InsertElement(null, false, DemoDicomTags.SOPInstanceUID, DicomVRType.UI, false, 0);
            }
            pDS.SetConvertValue(element, Utils.GenerateDicomUniqueIdentifier(), 1);

            // Media Storage SOP Instance UID
            element = pDS.FindFirstElement(null, DemoDicomTags.MediaStorageSOPInstanceUID, false);
            if (element == null)
            {
                element = pDS.InsertElement(null, false, DemoDicomTags.MediaStorageSOPInstanceUID, DicomVRType.UI, false, 0);
            }
            pDS.SetConvertValue(element, Utils.GenerateDicomUniqueIdentifier(), 1);
        }
Ejemplo n.º 6
0
        private void BuildDataSet( )
        {
            long         code    = -1;
            DicomTag     tag     = null;
            DicomElement element = null;

            element = _Dataset.FindFirstElement(null, _PreviousCode, false);


            code = OrientationConfigDialog.GetTag(comboBoxTags.Text);

            if (code == -1)
            {
                _Dataset.Reset( );

                dicomPropertyGrid.DataSet = _Dataset;

                MessageBox.Show("Invalid Tag", "Error with tag", MessageBoxButtons.OK, MessageBoxIcon.Error);

                comboBoxTags.Focus( );
            }
            else
            {
                if (element != null && element.Tag != code)
                {
                    _TagValue = null;
                }

                _PreviousCode = code;

                tag = DicomTagTable.Instance.Find(code);

                _Dataset.Reset();

                if (_TagValue != null)
                {
                    _Dataset.InsertElementAndSetValue(code, _TagValue);
                }
                else
                {
                    _Dataset.InsertElement(null, false, code, tag != null ? tag.VR : DicomVRType.UN, tag != null && tag.VR == DicomVRType.SQ, -1);
                }

                dicomPropertyGrid.DataSet = _Dataset;
            }
        }
Ejemplo n.º 7
0
        public static DicomExceptionCode InsertKeyElement(DicomDataSet dcmRsp, DicomDataSet dcmReq, long tag)
        {
            DicomExceptionCode ret = DicomExceptionCode.Success;
            DicomElement       element;

            try
            {
                element = dcmReq.FindFirstElement(null, tag, true);
                if (element != null)
                {
                    dcmRsp.InsertElement(null, false, tag, DicomVRType.UN, false, 0);
                }
            }
            catch (DicomException de)
            {
                ret = de.Code;
            }

            return(ret);
        }
Ejemplo n.º 8
0
        public static DicomExceptionCode SetTag(DicomDataSet dcm, long tag, byte[] tagValue)
        {
            DicomExceptionCode ret = DicomExceptionCode.Success;
            DicomElement       element;

            if (tagValue == null)
            {
                return(DicomExceptionCode.Parameter);
            }

            element = dcm.FindFirstElement(null, tag, true);
            if (element == null)
            {
                element = dcm.InsertElement(null, false, tag, DicomVRType.UN, false, 0);
            }

            dcm.SetBinaryValue(element, tagValue, tagValue.Length);

            return(ret);
        }
Ejemplo n.º 9
0
        public static DicomExceptionCode InsertKeyElement(DicomDataSet response, DicomDataSet request, long Tag)
        {
            DicomExceptionCode ret = DicomExceptionCode.Success;
            DicomElement       element;

            try
            {
                element = request.FindFirstElement(null, Tag, true);
                if (element != null)
                {
                    response.InsertElement(null, false, Tag, DicomVRType.UN, false, 0);
                }
            }
            catch (DicomException de)
            {
                ret = de.Code;
            }

            return(ret);
        }
Ejemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dcm"></param>
        /// <param name="tag"></param>
        /// <param name="tagValue"></param>
        /// <returns></returns>
        public static DicomExceptionCode SetTag(DicomDataSet dcm, long tag, object tagValue, bool tree)
        {
            DicomExceptionCode ret = DicomExceptionCode.Success;
            DicomElement       element;

            if (tagValue == null)
            {
                return(DicomExceptionCode.Parameter);
            }

            element = dcm.FindFirstElement(null, tag, tree);
            if (element == null)
            {
                element = dcm.InsertElement(null, false, tag, DicomVRType.UN, false, 0);
            }

            if (element == null)
            {
                return(DicomExceptionCode.Parameter);
            }

            try
            {
                string s = tagValue.ToString();
                if (IsAscii(s))
                {
                    dcm.SetConvertValue(element, s, 1);
                }
                else
                {
                    dcm.SetStringValue(element, s, DicomCharacterSetType.UnicodeInUtf8);
                }
            }
            catch (DicomException de)
            {
                ret = de.Code;
            }

            return(ret);
        }
Ejemplo n.º 11
0
      public static void SetTag(DicomDataSet dcm,long Sequence,long Tag,object TagValue)
      {
          DicomElement seqElement = dcm.FindFirstElement(null, Sequence, true);
          DicomElement seqItem = null;
          DicomElement item = null;

          if(seqElement==null)
          {
              seqElement = dcm.InsertElement(null, false, Tag, DicomVRType.SQ, true, -1);
          }

          seqItem = dcm.GetChildElement(seqElement, false);
          if (seqItem == null)
          {
#if (LTV15_CONFIG)
              seqItem = dcm.InsertElement(seqElement, true, DicomTagType.SequenceDelimitationItem, DicomVRType.SQ, true, -1);
#else
              seqItem = dcm.InsertElement(seqElement, true, DicomTag.SequenceDelimitationItem, DicomVRType.SQ, true, -1);
#endif
          }

          item = dcm.GetChildElement(seqItem, true);
          while(item!=null)
          {
#if (LTV15_CONFIG)
              if ((long)item.Tag == Tag)
                  break;
#else
              if (item.Tag == Tag)
                  break;
#endif

              item = dcm.GetNextElement(item, true, true);
          }

          if(item==null)
          {
              item = dcm.InsertElement(seqItem, true, Tag, DicomVRType.UN, false, -1);              
          }
          dcm.SetConvertValue(item, TagValue.ToString(), 1);
      }
Ejemplo n.º 12
0
      /// <summary>
      /// 
      /// </summary>
      /// <param name="dcm"></param>
      /// <param name="tag"></param>
      /// <param name="tagValue"></param>
      /// <returns></returns>
      public static DicomExceptionCode SetTag(DicomDataSet dcm, long tag, object tagValue, bool tree)
      {
         DicomExceptionCode ret = DicomExceptionCode.Success;
         DicomElement element;

         if (tagValue == null)
            return DicomExceptionCode.Parameter;

         element = dcm.FindFirstElement(null, tag, tree);
         if (element == null)
         {
            element = dcm.InsertElement(null, false, tag, DicomVRType.UN, false, 0);
         }

         if (element == null)
            return DicomExceptionCode.Parameter;

         try
         {
            dcm.SetConvertValue(element, tagValue.ToString(), 1);
         }
         catch (DicomException de)
         {
            ret = de.Code;
         }

         return ret;
      }
Ejemplo n.º 13
0
        private DicomDataSet InitResponseDS(QueryLevel level)
        {
            DicomDataSet rspDs = new DicomDataSet();

            rspDs.Initialize(DicomClassType.Undefined, DicomDataSetInitializeType.ExplicitVRLittleEndian);
            switch (level)
            {
            case QueryLevel.Patient:
                Utils.SetTag(rspDs, DemoDicomTags.QueryRetrieveLevel, "PATIENT");

                // Required Keys
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.PatientName);

                // Optional Keys
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.PatientBirthDate);
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.PatientBirthTime);
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.PatientSex);
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.EthnicGroup);
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.PatientComments);
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.NumberOfPatientRelatedStudies);
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.NumberOfPatientRelatedSeries);
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.NumberOfPatientRelatedInstances);
                break;

            case QueryLevel.Study:
                Utils.SetTag(rspDs, DemoDicomTags.QueryRetrieveLevel, "STUDY");

                // Require Keys
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.StudyDate);
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.StudyTime);
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.AccessionNumber);
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.StudyID);

                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.PatientName);
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.PatientID);

                // Optional Keys
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.StudyDescription);
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.ReferringPhysicianName);
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.NumberOfStudyRelatedSeries);
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.NumberOfStudyRelatedInstances);
                break;

            case QueryLevel.Series:
                Utils.SetTag(rspDs, DemoDicomTags.QueryRetrieveLevel, "SERIES");

                // Required Keys
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.Modality);
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.SeriesNumber);
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.SeriesDate);

                // Optional Keys
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.NumberOfSeriesRelatedInstances);
                break;

            case QueryLevel.Image:
                Utils.SetTag(rspDs, DemoDicomTags.QueryRetrieveLevel, "IMAGE");

                // Required Keys
                Utils.InsertKeyElement(rspDs, ds, DemoDicomTags.InstanceNumber);
                break;
            }

            if (_Class == DicomUidType.PatientRootQueryFind && level != QueryLevel.Study)
            {
                rspDs.InsertElement(null, false, DemoDicomTags.PatientID, DicomVRType.UN, false, 0);
            }

            if (level == QueryLevel.Study || level == QueryLevel.Series ||
                level == QueryLevel.Image)
            {
                rspDs.InsertElement(null, false, DemoDicomTags.StudyInstanceUID, DicomVRType.UN, false, 0);
            }

            if (level == QueryLevel.Series || level == QueryLevel.Image)
            {
                rspDs.InsertElement(null, false, DemoDicomTags.SeriesInstanceUID, DicomVRType.UN, false, 0);
            }

            if (level == QueryLevel.Image)
            {
                rspDs.InsertElement(null, false, DemoDicomTags.SOPInstanceUID, DicomVRType.UN, false, 0);
            }

            return(rspDs);
        }
Ejemplo n.º 14
0
        private void AddSecheduledProcedureStepSequenceAttributes(DicomDataSet ResponseDicomDS, DicomElement item)
        {
            ResponseDicomDS.InsertElement(item, true, DemoDicomTags.ScheduledStationAETitle, DicomVRType.UN, false, 0);
            ResponseDicomDS.InsertElement(item, true, DemoDicomTags.ScheduledProcedureStepStartDate, DicomVRType.UN, false, 0);
            ResponseDicomDS.InsertElement(item, true, DemoDicomTags.ScheduledProcedureStepStartTime, DicomVRType.UN, false, 0);
            ResponseDicomDS.InsertElement(item, true, DemoDicomTags.Modality, DicomVRType.UN, false, 0);
            ResponseDicomDS.InsertElement(item, true, DemoDicomTags.ScheduledPerformingPhysicianName, DicomVRType.UN, false, 0);
            ResponseDicomDS.InsertElement(item, true, DemoDicomTags.ScheduledProcedureStepDescription, DicomVRType.UN, false, 0);
            ResponseDicomDS.InsertElement(item, true, DicomTag.ScheduledStationName, DicomVRType.UN, false, 0);
            ResponseDicomDS.InsertElement(item, true, DemoDicomTags.ScheduledProcedureStepLocation, DicomVRType.UN, false, 0);
            DicomElement sequence = ResponseDicomDS.InsertElement(item, true, DemoDicomTags.ScheduledProtocolCodeSequence, DicomVRType.SQ, true, 0);

            sequence = ResponseDicomDS.InsertElement(sequence, true, DemoDicomTags.Item, DicomVRType.SQ, true, 0);
            ResponseDicomDS.InsertElement(sequence, true, DicomTag.CodeValue, DicomVRType.UN, false, 0);
            ResponseDicomDS.InsertElement(sequence, true, DicomTag.CodingSchemeDesignator, DicomVRType.UN, false, 0);
            ResponseDicomDS.InsertElement(sequence, true, DicomTag.CodeMeaning, DicomVRType.UN, false, 0);
            ResponseDicomDS.InsertElement(item, true, DicomTag.PreMedication, DicomVRType.UN, false, 0);
            ResponseDicomDS.InsertElement(item, true, DemoDicomTags.ScheduledProcedureStepID, DicomVRType.UN, false, 0);
            ResponseDicomDS.InsertElement(item, true, DicomTag.RequestedContrastAgent, DicomVRType.UN, false, 0);
        }
Ejemplo n.º 15
0
      public static DicomExceptionCode SetTag(DicomDataSet dcm, long tag, byte[] tagValue)
      {
         DicomExceptionCode ret = DicomExceptionCode.Success;
         DicomElement element;

         if(tagValue == null)
            return DicomExceptionCode.Parameter;

         element = dcm.FindFirstElement(null, tag, true);
         if(element == null)
         {
            element = dcm.InsertElement(null, false, tag, DicomVRType.UN, false, 0);
         }

         dcm.SetBinaryValue(element, tagValue, tagValue.Length);

         return ret;
      }
Ejemplo n.º 16
0
        /*
         * Initializes a blank dataset to send back to the SCU
         */
        private DicomDataSet PrepareResponseDS()
        {
            try
            {
                DicomDataSet ResponseDicomDS = new DicomDataSet();

                ResponseDicomDS.Initialize(DicomClassType.Undefined, DicomDataSetInitializeType.ImplicitVRLittleEndian);

                DicomElement element;

                // Scheduled Procedure Step
                element = ds.FindFirstElement(null, DemoDicomTags.ScheduledProcedureStepSequence, false);
                if (element != null)
                {
                    DicomElement sequence = null;
                    DicomElement item     = null;
                    sequence = ResponseDicomDS.InsertElement(null, false, DemoDicomTags.ScheduledProcedureStepSequence, DicomVRType.SQ, true, 0);
                    if (sequence != null)
                    {
                        item = ResponseDicomDS.InsertElement(sequence, true, DemoDicomTags.Item, DicomVRType.SQ, false, 0);
                    }

                    if (item != null)
                    {
                        element = ds.GetChildElement(element, true);
                        if (element != null)
                        {
                            element = ds.GetChildElement(element, true);

                            if (element == null)
                            {
                                AddSecheduledProcedureStepSequenceAttributes(ResponseDicomDS, item);
                            }
                            else
                            {
                                while (element != null)
                                {
                                    switch (element.Tag)
                                    {
                                    case DemoDicomTags.ScheduledStationAETitle:
                                    case DemoDicomTags.ScheduledProcedureStepStartDate:
                                    case DemoDicomTags.ScheduledProcedureStepStartTime:
                                    case DemoDicomTags.Modality:
                                    case DemoDicomTags.ScheduledPerformingPhysicianName:
                                    case DemoDicomTags.ScheduledProcedureStepDescription:
                                    case DemoDicomTags.ScheduledProcedureStepLocation:
                                    case DemoDicomTags.ScheduledProcedureStepID:
                                        ResponseDicomDS.InsertElement(item, true, element.Tag, DicomVRType.UN, false, 0);
                                        break;
                                    }

                                    element = ds.GetNextElement(element, true, true);
                                }
                            }
                        }
                        else
                        {
                            AddSecheduledProcedureStepSequenceAttributes(ResponseDicomDS, item);
                        }
                    }
                }

                // Requested Procedure
                Utils.InsertKeyElement(ResponseDicomDS, ds, DemoDicomTags.RequestedProcedureID);
                Utils.InsertKeyElement(ResponseDicomDS, ds, DemoDicomTags.RequestedProcedureDescription);
                Utils.InsertKeyElement(ResponseDicomDS, ds, DemoDicomTags.StudyInstanceUID);
                Utils.InsertKeyElement(ResponseDicomDS, ds, DemoDicomTags.RequestedProcedurePriority);
                Utils.InsertKeyElement(ResponseDicomDS, ds, DemoDicomTags.ReasonForTheRequestedProcedure);

                // Imaging Service Request
                Utils.InsertKeyElement(ResponseDicomDS, ds, DemoDicomTags.AccessionNumber);
                Utils.InsertKeyElement(ResponseDicomDS, ds, DemoDicomTags.RequestingPhysician);
                Utils.InsertKeyElement(ResponseDicomDS, ds, DemoDicomTags.ReferringPhysicianName);

                // Visit Identification
                Utils.InsertKeyElement(ResponseDicomDS, ds, DemoDicomTags.AdmissionID);
                Utils.InsertKeyElement(ResponseDicomDS, ds, DemoDicomTags.InstitutionName);

                // Patient Identification
                Utils.InsertKeyElement(ResponseDicomDS, ds, DemoDicomTags.PatientName);
                Utils.InsertKeyElement(ResponseDicomDS, ds, DemoDicomTags.PatientID);

                // Patient Demographic
                Utils.InsertKeyElement(ResponseDicomDS, ds, DemoDicomTags.PatientBirthDate);
                Utils.InsertKeyElement(ResponseDicomDS, ds, DemoDicomTags.PatientSex);
                Utils.InsertKeyElement(ResponseDicomDS, ds, DemoDicomTags.PatientWeight);

                return(ResponseDicomDS);
            }
            catch (Exception ex)
            {
                // Throw the exception and let the calling function handle it.
                throw ex;
            }
        }
Ejemplo n.º 17
0
      public static DicomExceptionCode InsertKeyElement(DicomDataSet dcmRsp, DicomDataSet dcmReq, long tag)
      {
         DicomExceptionCode ret = DicomExceptionCode.Success;
         DicomElement element;

         try
         {
            element = dcmReq.FindFirstElement(null, tag, true);
            if(element != null)
            {
               dcmRsp.InsertElement(null, false, tag, DicomVRType.UN, false, 0);
            }
         }
         catch(DicomException de)
         {
            ret = de.Code;
         }

         return ret;
      }
Ejemplo n.º 18
0
        private void CheckFileMetaInfo(DicomDataSet ds)
        {
            DicomElement Temp;
            string       szValue;

            // File Meta Information Version
            DicomElement Element = ds.FindFirstElement(null, DemoDicomTags.FileMetaInformationVersion, false);

            if (Element == null)
            {
                Element = ds.InsertElement(null, false, DemoDicomTags.FileMetaInformationVersion, DicomVRType.UN, false, 0);
            }
            if (Element != null)
            {
                byte[] Values = new byte[2];
                Values[0] = 0x00;
                Values[1] = 0x01;

                ds.SetByteValue(Element, Values, 2);
            }

            // Media Storage SOP Class UID
            Element = ds.FindFirstElement(null, DemoDicomTags.MediaStorageSOPClassUID, false);
            if (Element == null)
            {
                Element = ds.InsertElement(null, false, DemoDicomTags.MediaStorageSOPClassUID, DicomVRType.UN, false, 0);
            }
            if (Element != null)
            {
                Temp = ds.FindFirstElement(null, DemoDicomTags.SOPClassUID, false);
                if (Temp != null)
                {
                    szValue = ds.GetStringValue(Temp, 0);
                    if (szValue != string.Empty)
                    {
                        ds.SetStringValue(Element, szValue, DicomCharacterSetType.Default);
                    }
                }
            }

            // Media Storage SOP Instance UID
            Element = ds.FindFirstElement(null, DemoDicomTags.MediaStorageSOPInstanceUID, false);
            if (Element == null)
            {
                Element = ds.InsertElement(null, false, DemoDicomTags.MediaStorageSOPInstanceUID, DicomVRType.UN, false, 0);
            }
            if (Element != null)
            {
                Temp = ds.FindFirstElement(null, DemoDicomTags.SOPInstanceUID, false);
                if (Temp != null)
                {
                    szValue = ds.GetStringValue(Temp, 0);
                    if (szValue != string.Empty)
                    {
                        ds.SetStringValue(Element, szValue, DicomCharacterSetType.Default);
                    }
                }
            }

            // Implementation Class UID
            Element = ds.FindFirstElement(null, DemoDicomTags.ImplementationClassUID, false);
            if (Element == null)
            {
                Element = ds.InsertElement(null, false, DemoDicomTags.ImplementationClassUID, DicomVRType.UN, false, 0);
            }
            if (Element != null)
            {
                ds.SetStringValue(Element, LEAD_IMPLEMENTATION_CLASS_UID, DicomCharacterSetType.Default);
            }

            // Implementation Version Name
            Element = ds.FindFirstElement(null, DemoDicomTags.ImplementationVersionName, false);
            if (Element == null)
            {
                Element = ds.InsertElement(null, false, DemoDicomTags.ImplementationVersionName, DicomVRType.UN, false, 0);
            }
            if (Element != null)
            {
                ds.SetStringValue(Element, LEAD_IMPLEMENTATION_VERSION_NAME, DicomCharacterSetType.Default);
            }
        }