当前位置: 首页>>代码示例>>C#>>正文


C# DcmDataset.AddElementWithValue方法代码示例

本文整理汇总了C#中Dicom.Data.DcmDataset.AddElementWithValue方法的典型用法代码示例。如果您正苦于以下问题:C# DcmDataset.AddElementWithValue方法的具体用法?C# DcmDataset.AddElementWithValue怎么用?C# DcmDataset.AddElementWithValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dicom.Data.DcmDataset的用法示例。


在下文中一共展示了DcmDataset.AddElementWithValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnReceiveCFindRequest

        protected override void OnReceiveCFindRequest(byte presentationID, ushort messageID, DcmPriority priority, Dicom.Data.DcmDataset query)
        {
            TryInterpretStringsInDatasetUsingCorrectEncoding(query);

            Trace.WriteLine(String.Format("{0} Receive C-Find from {1} (marked as anonymous:{2})", DateTime.Now, this.Associate.CallingAE, _flagAnonymousAccess));
            Trace.WriteLine(query.Dump());

               using( var database = new MedicalISDataContext() )
            {
                var queryLevel = query.GetString(DicomTags.QueryRetrieveLevel, null);

                if (queryLevel == "PATIENT")
                {
                    IQueryable<Patient> patients = PatientQueries.GetMatchingPatients(database, query, _flagAnonymousAccess);

                    patients = patients.Take(Settings.Default.MaxNumberOfStudiesReturned);

                    foreach (var currentPatient in patients)
                    {
                        foreach (var currentStudy in currentPatient.Studies)
                        {
                            var p = currentPatient;

                            var response = new DcmDataset
                            {
                                SpecificCharacterSetEncoding = query.SpecificCharacterSetEncoding
                            };

                            // Map saved study tags to output

                            response.AddElementWithValue(DicomTags.RetrieveAETitle, "CURAPACS");
                            response.AddElementWithValue(DicomTags.QueryRetrieveLevel, "PATIENT");

                            response.AddElementWithValue(DicomTags.PatientID, p.ExternalPatientID);
                            response.AddElementWithValue(DicomTags.PatientsName, p.LastName + "^" + p.FirstName);
                            response.AddElementWithValue(DicomTags.PatientsBirthDate, p.BirthDateTime.Value);

                            response.AddElementWithValue(DicomTags.StudyInstanceUID, currentStudy.StudyInstanceUid);
                            response.AddElementWithValue(DicomTags.AccessionNumber, currentStudy.AccessionNumber);
                            response.AddElementWithValue(DicomTags.StudyDescription, currentStudy.Description);
                            response.AddElementWithValue(DicomTags.ModalitiesInStudy, currentStudy.ModalityAggregation);

                            if (currentStudy.PerformedDateTime.HasValue)
                            {
                                response.AddElementWithValue(DicomTags.StudyDate, currentStudy.PerformedDateTime.Value);
                                response.AddElementWithValue(DicomTags.StudyTime, currentStudy.PerformedDateTime.Value);
                            }

                            response.AddElementWithValue(DicomTags.NumberOfStudyRelatedSeries, currentStudy.Series.Count);
                            response.AddElementWithValue(DicomTags.NumberOfStudyRelatedInstances, (from s in currentStudy.Series select s.Images.Count).Sum());

                            if (_flagAnonymousAccess)
                                AnonymizeDatasetBasedOnStudyInfo(response);

                            SendCFindResponse(presentationID, messageID, response, DcmStatus.Pending);
                        }
                    }
                }
                else if (queryLevel == "STUDY")
                {
                    IQueryable<Study> studies = StudyQueries.GetMatchingStudies(database, query, _flagAnonymousAccess);

                    studies = studies.Take(Settings.Default.MaxNumberOfStudiesReturned);

                    foreach (var currentStudy in studies)
                    {
                        var p = currentStudy.Patient;

                        var response = new DcmDataset
                                           {
                                               SpecificCharacterSetEncoding = query.SpecificCharacterSetEncoding
                                           };

                        // Map saved study tags to output

                        response.AddElementWithValue(DicomTags.RetrieveAETitle, "CURAPACS");
                        response.AddElementWithValue(DicomTags.QueryRetrieveLevel, "STUDY");

                        response.AddElementWithValue(DicomTags.PatientID, p.ExternalPatientID);
                        response.AddElementWithValue(DicomTags.PatientsName, p.LastName + "^" + p.FirstName);
                        response.AddElementWithValue(DicomTags.PatientsBirthDate, p.BirthDateTime.Value);

                        response.AddElementWithValue(DicomTags.StudyInstanceUID, currentStudy.StudyInstanceUid);
                        response.AddElementWithValue(DicomTags.AccessionNumber, currentStudy.AccessionNumber);
                        response.AddElementWithValue(DicomTags.StudyDescription, currentStudy.Description);
                        response.AddElementWithValue(DicomTags.ModalitiesInStudy, currentStudy.ModalityAggregation);

                        if (currentStudy.PerformedDateTime.HasValue)
                        {
                            response.AddElementWithValue(DicomTags.StudyDate, currentStudy.PerformedDateTime.Value);
                            response.AddElementWithValue(DicomTags.StudyTime, currentStudy.PerformedDateTime.Value);
                        }

                        response.AddElementWithValue(DicomTags.NumberOfStudyRelatedSeries, currentStudy.Series.Count);
                        response.AddElementWithValue(DicomTags.NumberOfStudyRelatedInstances, (from s in currentStudy.Series select s.Images.Count).Sum());

                        if (! String.IsNullOrEmpty(query.GetString(DicomTags.PatientsSex, null)))
                        {
                            response.AddElementWithValue(DicomTags.PatientsSex, Settings.Default.AlwaysRespondWithGender);
                        }
//.........这里部分代码省略.........
开发者ID:curasystems,项目名称:dicomserver,代码行数:101,代码来源:CImageServer.cs

示例2: OnReceiveNGetRequest

        protected override void OnReceiveNGetRequest(byte presentationID, ushort messageID,
            DicomUID requestedClass, DicomUID requestedInstance, DicomTag[] attributes)
        {
            if (requestedClass == DicomUID.PrinterSOPClass && requestedInstance == DicomUID.PrinterSOPInstance) {
                DcmDataset ds = new DcmDataset(DicomTransferSyntax.ImplicitVRLittleEndian);
                ds.AddElementWithValue(DicomTags.PrinterStatus, "NORMAL");
                ds.AddElementWithValue(DicomTags.PrinterStatus, "NORMAL");
                ds.AddElementWithValue(DicomTags.PrinterName, _config.PrinterName);
                ds.AddElementWithValue(DicomTags.Manufacturer, "N/A");
                ds.AddElementWithValue(DicomTags.ManufacturersModelName, "N/A");
                ds.AddElementWithValue(DicomTags.DeviceSerialNumber, "N/A");
                ds.AddElementWithValue(DicomTags.SoftwareVersions, "N/A");
                ds.SetDateTime(DicomTags.DateOfLastCalibration, DicomTags.TimeOfLastCalibration, DateTime.Now);

                SendNGetResponse(presentationID, messageID, requestedClass, requestedInstance, ds, DcmStatus.Success);
                return;
            }

            if (requestedClass == DicomUID.PrintJobSOPClass) {
                DcmPrintJob job = null;

                foreach (DcmPrintJob pj in _jobs) {
                    if (pj.SOPInstanceUID == requestedInstance) {
                        job = pj;
                        break;
                    }
                }

                if (job == null) {
                    job = new DcmPrintJob(requestedInstance);
                    job.ExecutionStatus = "DONE";
                    job.CreationDateTime = DateTime.Today;
                    job.PrintPriority = _session.PrintPriority;
                    job.PrinterName = _config.PrinterName;
                    job.Originator = Associate.CallingAE;
                }

                SendNGetResponse(presentationID, messageID, requestedClass, requestedInstance, job.Dataset, DcmStatus.Success);
                return;
            }

            if (requestedClass == DicomUID.PrinterConfigurationRetrievalSOPClass && requestedInstance == DicomUID.PrinterConfigurationRetrievalSOPInstance) {
                DcmDataset ds = new DcmDataset(DicomTransferSyntax.ImplicitVRLittleEndian);
                DcmDataset config = new DcmDataset(DicomTransferSyntax.ImplicitVRLittleEndian);

                DcmItemSequence sq = new DcmItemSequence(DicomTags.PrinterConfigurationSequence);
                sq.AddSequenceItem(config);
                ds.AddItem(sq);

                SendNGetResponse(presentationID, messageID, requestedClass, requestedInstance, ds, DcmStatus.Success);
                return;
            }

            SendAbort(DcmAbortSource.ServiceProvider, DcmAbortReason.NotSpecified);
        }
开发者ID:k11hao,项目名称:mdcm-printscp,代码行数:55,代码来源:NPrintService.cs

示例3: Transform

		public void Transform(DcmDataset dataset) {
			dataset.AddElementWithValue(_tag, DicomUID.Generate());
		}
开发者ID:hide1980,项目名称:mdcm,代码行数:3,代码来源:DicomTransform.cs

示例4: ToDataset

 public DcmDataset ToDataset()
 {
     DcmDataset dataset = new DcmDataset();
     switch (QueryRetrieveLevel) {
     case DcmQueryRetrieveLevel.Patient:
         dataset.AddElementWithValue(DicomTags.QueryRetrieveLevel, "PATIENT");
         dataset.AddElementWithValue(DicomTags.PatientID, PatientID);
         break;
     case DcmQueryRetrieveLevel.Study:
         dataset.AddElementWithValue(DicomTags.QueryRetrieveLevel, "STUDY");
         if (!String.IsNullOrEmpty(PatientID))
             dataset.AddElementWithValue(DicomTags.PatientID, PatientID);
         dataset.AddElementWithValue(DicomTags.StudyInstanceUID, StudyInstanceUID);
         break;
     case DcmQueryRetrieveLevel.Series:
         dataset.AddElementWithValue(DicomTags.QueryRetrieveLevel, "SERIES");
         if (!String.IsNullOrEmpty(PatientID))
             dataset.AddElementWithValue(DicomTags.PatientID, PatientID);
         if (!String.IsNullOrEmpty(StudyInstanceUID))
             dataset.AddElementWithValue(DicomTags.StudyInstanceUID, StudyInstanceUID);
         dataset.AddElementWithValue(DicomTags.SeriesInstanceUID, SeriesInstanceUID);
         break;
     case DcmQueryRetrieveLevel.Image:
         dataset.AddElementWithValue(DicomTags.QueryRetrieveLevel, "IMAGE");
         if (!String.IsNullOrEmpty(PatientID))
             dataset.AddElementWithValue(DicomTags.PatientID, PatientID);
         if (!String.IsNullOrEmpty(StudyInstanceUID))
             dataset.AddElementWithValue(DicomTags.StudyInstanceUID, StudyInstanceUID);
         if (!String.IsNullOrEmpty(SeriesInstanceUID))
             dataset.AddElementWithValue(DicomTags.SeriesInstanceUID, SeriesInstanceUID);
         dataset.AddElementWithValue(DicomTags.SOPInstanceUID, SOPInstanceUID);
         break;
     default:
         break;
     }
     return dataset;
 }
开发者ID:fo-dicom,项目名称:mdcm,代码行数:37,代码来源:CMoveClient.cs

示例5: UpdateDataset

		public void UpdateDataset(DcmDataset dataset) {
			if (_lossy) {
				DcmCodeString cs = dataset.GetCS(DicomTags.ImageType);
				if (cs != null) {
					string[] values = cs.GetValues();
					values[0] = "DERIVED";
					cs.SetValues(values);
				}

				dataset.AddElementWithValue(DicomTags.SOPInstanceUID, DicomUID.Generate());

				// FIXME: append existing values
				dataset.AddElementWithValue(DicomTags.LossyImageCompression, "01");
				dataset.AddElementWithValue(DicomTags.LossyImageCompressionMethod, _lossyMethod);
				dataset.AddElementWithValue(DicomTags.LossyImageCompressionRatio, _lossyRatio);
			}
			dataset.AddElementWithValue(DicomTags.NumberOfFrames, _frames);
			dataset.AddElementWithValue(DicomTags.Columns, _width);
			dataset.AddElementWithValue(DicomTags.Rows, _height);
			dataset.AddElementWithValue(DicomTags.HighBit, _highBit);
			dataset.AddElementWithValue(DicomTags.BitsStored, _bitsStored);
			dataset.AddElementWithValue(DicomTags.BitsAllocated, _bitsAllocated);
			dataset.AddElementWithValue(DicomTags.SamplesPerPixel, _samplesPerPixel);
			dataset.AddElementWithValue(DicomTags.PixelRepresentation, _pixelRepresentation);
			dataset.AddElementWithValue(DicomTags.PhotometricInterpretation, _photometricInterpretation);
			if (SamplesPerPixel == 1) {
				dataset.AddElementWithValue(DicomTags.RescaleSlope, _rescaleSlope);
				dataset.AddElementWithValue(DicomTags.RescaleIntercept, _rescaleIntercept);
				//if (_pixelPaddingValue != 0)
				//    dataset.AddElementWithValue(DicomTags.PixelPaddingValue, _pixelPaddingValue);
			}
			else {
				dataset.AddElementWithValue(DicomTags.PlanarConfiguration, _planarConfiguration);
			}
			dataset.AddItem(_pixelDataItem);
		}
开发者ID:mcmssupereditor,项目名称:mdcm,代码行数:36,代码来源:DcmPixelData.cs

示例6: PerformQueryOrRelease

		private void PerformQueryOrRelease() {
			if (_moveQueries.Count > 0) {
				byte pcid = Associate.FindAbstractSyntax(MoveSopClassUID);
				if (Associate.GetPresentationContextResult(pcid) == DcmPresContextResult.Accept) {
					CMoveQuery query = _moveQueries.Dequeue();
					DcmDataset dataset = new DcmDataset(Associate.GetAcceptedTransferSyntax(pcid));
					switch (query.QueryRetrieveLevel) {
					case DcmQueryRetrieveLevel.Patient:
						dataset.AddElementWithValue(DicomTags.QueryRetrieveLevel, "PATIENT");
						dataset.AddElementWithValue(DicomTags.PatientID, query.PatientID);
						break;
					case DcmQueryRetrieveLevel.Study:
						dataset.AddElementWithValue(DicomTags.QueryRetrieveLevel, "STUDY");
						dataset.AddElementWithValue(DicomTags.PatientID, query.PatientID);
						dataset.AddElementWithValue(DicomTags.StudyInstanceUID, query.StudyInstanceUID);
						break;
					case DcmQueryRetrieveLevel.Series:
						dataset.AddElementWithValue(DicomTags.QueryRetrieveLevel, "SERIES");
						dataset.AddElementWithValue(DicomTags.PatientID, query.PatientID);
						dataset.AddElementWithValue(DicomTags.StudyInstanceUID, query.StudyInstanceUID);
						dataset.AddElementWithValue(DicomTags.SeriesInstanceUID, query.SeriesInstanceUID);
						break;
					case DcmQueryRetrieveLevel.Image:
						dataset.AddElementWithValue(DicomTags.QueryRetrieveLevel, "IMAGE");
						dataset.AddElementWithValue(DicomTags.PatientID, query.PatientID);
						dataset.AddElementWithValue(DicomTags.StudyInstanceUID, query.StudyInstanceUID);
						dataset.AddElementWithValue(DicomTags.SeriesInstanceUID, query.SeriesInstanceUID);
						dataset.AddElementWithValue(DicomTags.SOPInstanceUID, query.SOPInstanceUID);
						break;
					default:
						break;
					}
					_current = query;
					SendCMoveRequest(pcid, 1, DestinationAE, Priority, dataset);
				}
				else {
					Log.Info("{0} -> Presentation context rejected: {1}", LogID, Associate.GetPresentationContextResult(pcid));
					SendReleaseRequest();
				}
			}
			else {
				SendReleaseRequest();
			}
		}
开发者ID:mcmssupereditor,项目名称:mdcm,代码行数:44,代码来源:CMoveClient.cs

示例7: MakeGreyDicom

        public string MakeGreyDicom(byte[] greybytes, ushort imgwidth, ushort imgheight)
        {
            DcmUID studyUid = DcmUID.Generate();
            DcmUID seriesUid = DcmUID.Generate(studyUid, 1);
            DcmUID instUid = DcmUID.Generate(seriesUid, 1);
            DcmDataset data = new DcmDataset(DcmTS.ExplicitVRBigEndian);//.ImplicitVRLittleEndian  ok
            data.AddElementWithValue(DcmTags.SOPClassUID, DcmUIDs.CTImageStorage);//ComputedRadiographyImageStorage  ok
            //data.AddElementWithValue(DcmTags.SOPClassUID, DcmUIDs .SecondaryCapture);
            data.AddElementWithValue(DcmTags.StudyInstanceUID, studyUid);
            data.AddElementWithValue(DcmTags.SeriesInstanceUID, seriesUid);
            data.AddElementWithValue(DcmTags.SOPInstanceUID, instUid);//"1.3.6.1.4.1.30071.6.635719267134010719.1.1"

            //data.AddElementWithValue(DcmTags.MediaStorageSOPClassUID, DcmUIDs.ImplicitVRLittleEndian);
            //data.AddElementWithValueString(DcmTags.MediaStorageSOPClassUID, DcmUIDs.ComputedRadiographyImageStorage.ToString());

            //type 2 attributes
            ////data.AddElement(DcmTags.PrinterStatus);
            if (tags.ContainsKey("0010,0020"))
                data.AddElementWithValueString(DcmTags.PatientID, tags["0010,0020"].Substring(5));
            if (tags.ContainsKey("0010,0010"))
                data.AddElementWithValueString(DcmTags.PatientsName, tags["0010,0010"].Substring(5));
            if (tags.ContainsKey("0010,0030"))
                data.AddElementWithValueString(DcmTags.PatientsBirthDate, tags["0010,0030"].Substring(5));
            if (tags.ContainsKey("0010,0040"))
                data.AddElementWithValueString(DcmTags.PatientsSex, tags["0010,0040"].Substring(5));
            if (tags.ContainsKey("0010,1010"))
                data.AddElementWithValueString(DcmTags.PatientsAge, tags["0010,1010"].Substring(5));

            if (tags.ContainsKey("0008,0005"))
                data.AddElementWithValueString(DcmTags.SpecificCharacterSet, tags["0008,0005"].Substring(5));
            if (tags.ContainsKey("0008,0008"))
                data.AddElementWithValueString(DcmTags.ImageType, tags["0008,0008"].Substring(5));
            //if (tags.ContainsKey("0008,0016"))
            //    data.AddElementWithValueString(DcmTags.ContentTime, DateTime.Now.ToString());
            //if (tags.ContainsKey("0008,0018"))
            //    data.AddElementWithValueString(DcmTags.ContentTime, DateTime.Now.ToString());
            if (tags.ContainsKey("0008,0020"))
                data.AddElementWithValueString(DcmTags.StudyDate, tags["0008,0020"].Substring(5));
            if (tags.ContainsKey("0008,0021"))
                data.AddElementWithValueString(DcmTags.SeriesDate, tags["0008,0021"].Substring(5));
            if (tags.ContainsKey("0008,0022"))
                data.AddElementWithValueString(DcmTags.AcquisitionDate, tags["0008,0022"].Substring(5));
            if (tags.ContainsKey("0008,0023"))
                data.AddElementWithValueString(DcmTags.ContentDate, tags["0008,0023"].Substring(5));
            if (tags.ContainsKey("0008,002a"))
                data.AddElementWithValueString(DcmTags.AcquisitionDateTime, tags["0008,002a"].Substring(5));
            if (tags.ContainsKey("0008,0030"))
                data.AddElementWithValueString(DcmTags.StudyTime, tags["0008,0030"].Substring(5));
            if (tags.ContainsKey("0008,0031"))
                data.AddElementWithValueString(DcmTags.SeriesTime, tags["0008,0031"].Substring(5));
            if (tags.ContainsKey("0008,0032"))
                data.AddElementWithValueString(DcmTags.AcquisitionTime, tags["0008,0032"].Substring(5));
            if (tags.ContainsKey("0008,0033"))
                data.AddElementWithValueString(DcmTags.ContentTime, tags["0008,0033"].Substring(5));

            if (tags.ContainsKey("0008,0050"))
                data.AddElementWithValueString(DcmTags.AcquisitionNumber, tags["0008,0050"].Substring(5));
            if (tags.ContainsKey("0008,0060"))
                data.AddElementWithValueString(DcmTags.Modality, tags["0008,0060"].Substring(5));
            if (tags.ContainsKey("0008,0070"))
                data.AddElementWithValueString(DcmTags.Manufacturer, tags["0008,0070"].Substring(5));
            if (tags.ContainsKey("0008,0080"))
                data.AddElementWithValueString(DcmTags.InstitutionName, tags["0008,0080"].Substring(5));
            if (tags.ContainsKey("0008,0081"))
                data.AddElementWithValueString(DcmTags.InstitutionAddress, tags["0008,0081"].Substring(5));
            if (tags.ContainsKey("0008,0090"))
                data.AddElementWithValueString(DcmTags.ReferringPhysiciansName, tags["0008,0090"].Substring(5));
            if (tags.ContainsKey("0008,1010"))
                data.AddElementWithValueString(DcmTags.StationName, tags["0008,1010"].Substring(5));
            if (tags.ContainsKey("0008,1030"))
                data.AddElementWithValueString(DcmTags.StudyDescription, tags["0008,1030"].Substring(5));
            if (tags.ContainsKey("0008,103e"))
                data.AddElementWithValueString(DcmTags.SeriesDescription, tags["0008,103e"].Substring(5));
            if (tags.ContainsKey("0008,1090"))
                data.AddElementWithValueString(DcmTags.ManufacturersModelName, tags["0008,1090"].Substring(5));

            if (tags.ContainsKey("0018,0010"))
                data.AddElementWithValueString(DcmTags.ContrastBolusAgent, tags["0018,0010"].Substring(5));
            if (tags.ContainsKey("0018,0015"))
                data.AddElementWithValueString(DcmTags.BodyPartExamined, tags["0018,0015"].Substring(5));
            if (tags.ContainsKey("0018,0050"))
                data.AddElementWithValueString(DcmTags.SliceThickness, tags["0018,0050"].Substring(5));
            if (tags.ContainsKey("0018,0060"))
                data.AddElementWithValueString(DcmTags.KVP, tags["0018,0060"].Substring(5));
            if (tags.ContainsKey("0018,0090"))
                data.AddElementWithValueString(DcmTags.DataCollectionDiameter, tags["0018,0090"].Substring(5));
            if (tags.ContainsKey("0018,1000"))
                data.AddElementWithValueString(DcmTags.DeviceSerialNumber, tags["0018,1000"].Substring(5));
            if (tags.ContainsKey("0018,1020"))
                data.AddElementWithValueString(DcmTags.SoftwareVersions, tags["0018,1020"].Substring(5));
            if (tags.ContainsKey("0018,1030"))
                data.AddElementWithValueString(DcmTags.ProtocolName, tags["0018,1030"].Substring(5));
            if (tags.ContainsKey("0018,1041"))
                data.AddElementWithValueString(DcmTags.ContrastBolusVolume, tags["0018,1041"].Substring(5));
            if (tags.ContainsKey("0018,1042"))
                data.AddElementWithValueString(DcmTags.ContrastBolusStartTime, tags["0018,1042"].Substring(5));
            if (tags.ContainsKey("0018,1043"))
                data.AddElementWithValueString(DcmTags.ContrastBolusStopTime, tags["0018,1043"].Substring(5));
            if (tags.ContainsKey("0018,1044"))
                data.AddElementWithValueString(DcmTags.ContrastBolusTotalDose, tags["0018,1044"].Substring(5));
//.........这里部分代码省略.........
开发者ID:GitHubxsy,项目名称:ChangeDicomTag,代码行数:101,代码来源:Program.cs


注:本文中的Dicom.Data.DcmDataset.AddElementWithValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。