Пример #1
0
        private void OnReceiveMWLQuery(DicomServer server, byte presentationId, DicomMessage message)
        {
            var tagList = new List<DicomTag>();

            string specificCharacterSet = string.Empty;

            foreach (var attrib in message.DataSet)
            {
                tagList.Add(attrib.Tag);

                if (!attrib.IsNull)
                {
                    switch (attrib.Tag.TagValue)
                    {
                        case DicomTags.SpecificCharacterSet:
                            specificCharacterSet = message.DataSet[DicomTags.SpecificCharacterSet];
                            break;

                        #region Case Scheduled Procedure Step Seq

                        case DicomTags.ScheduledProcedureStepSequence:
                            DicomAttributeSQ sequence = attrib as DicomAttributeSQ;
                            DicomSequenceItem sqSubItems = sequence[0];

                            foreach (var sqSubItem in sqSubItems)
                            {
                                if(sqSubItem.IsNull)
                                    continue;

                                tagList.Add(sqSubItem.Tag);

                                switch (sqSubItem.Tag.TagValue)
                                {
                                    case DicomTags.ScheduledStationName:
                                        break;
                                    case DicomTags.Modality:
                                        break;
                                    case DicomTags.ScheduledPerformingPhysiciansName:
                                        break;
                                    case DicomTags.ScheduledProcedureStepStartDate:
                                        break;
                                    case DicomTags.ScheduledProcedureStepStartTime:
                                        break;

                                    // Optional Matching keys
                                    case DicomTags.ScheduledProcedureStepLocation:
                                        break;
                                    case DicomTags.ScheduledProcedureStepDescription:
                                        break;
                                    case DicomTags.RequestedProcedureId:
                                        break;
                                    case DicomTags.ScheduledProcedureStepId:
                                        break;
                                    default:
                                        break;
                                }
                            }
                            break;

                        #endregion

                        case DicomTags.PatientId:
                            break;
                        case DicomTags.PatientsName:
                            break;

                        //Optional Matching Keys
                        case DicomTags.AccessionNumber:
                            break;

                        case DicomTags.ReferringPhysiciansName:
                            break;
                        default:
                            break;
                    }
                }
            }

            // Populate result Information from Db
            List<DicomMessage> results = new List<DicomMessage>();

            var msg = new DicomMessage();
            msg.DataSet.SpecificCharacterSet = specificCharacterSet;
            ModalityWorklistIod iod = new ModalityWorklistIod(msg.DataSet);
            iod.SetCommonTags();

            iod.PatientIdentificationModule.PatientId = "1402001111";
            iod.PatientIdentificationModule.PatientsName = new PersonName("测试");
            iod.PatientIdentificationModule.PatientsSex = PatientsSex.M;
            iod.PatientIdentificationModule.PatientsBirthDate = new DateTime(2011, 11, 19);

            var spssIod = new ScheduledProcedureStepSequenceIod();
            spssIod.SetCommonTags();
            spssIod.DicomAttributeProvider[DicomTags.ScheduledProcedureStepStartDate].SetString(0, "20141119");
            spssIod.DicomAttributeProvider[DicomTags.ScheduledProcedureStepStartTime].SetString(0, "143806");

            iod.ScheduledProcedureStepModule.ScheduledProcedureStepSequenceList.Clear();
            iod.ScheduledProcedureStepModule.ScheduledProcedureStepSequenceList.Add(spssIod);

          results.Add(msg);
            try
            {
                foreach (var dicomMessage in results)
                {
                    if (_cancelReceived)
                    {
                        throw new DicomException("DICOM C-Cancel Received");
                    }
                    
                    server.SendCFindResponse(presentationId, message.MessageId, dicomMessage,
                                                         DicomStatuses.Pending);
                }
                
            }
            catch (Exception)
            {
                if (_cancelReceived)
                {
                    var errorResponse = new DicomMessage();
                    server.SendCFindResponse(presentationId, message.MessageId, errorResponse,
                                                DicomStatuses.Cancel);
                }

                return;
            }

            var finalResponse = new DicomMessage();
            server.SendCFindResponse(presentationId, message.MessageId, finalResponse, DicomStatuses.Success);
        }
Пример #2
0
        /// <summary>
        /// Sets the common tags for a typical Modality Worklist Request.
        /// </summary>
        public static void SetCommonTags(IDicomAttributeProvider dicomAttributeProvider)
        {
            ModalityWorklistIod iod = new ModalityWorklistIod(dicomAttributeProvider);
            //iod.PatientIdentificationModule.PatientsName.FirstName = "*";
            iod.DicomAttributeProvider[DicomTags.PatientsName].SetStringValue("*");
            iod.SetAttributeNull(DicomTags.PatientId);
            iod.SetAttributeNull(DicomTags.PatientsBirthDate);
            iod.SetAttributeNull(DicomTags.PatientsBirthTime);
            iod.SetAttributeNull(DicomTags.PatientsWeight);
            iod.SetAttributeNull(DicomTags.RequestedProcedureId);
            iod.SetAttributeNull(DicomTags.RequestedProcedureDescription);
            iod.SetAttributeNull(DicomTags.StudyInstanceUid);
            iod.SetAttributeNull(DicomTags.ReasonForTheRequestedProcedure);
            iod.SetAttributeNull(DicomTags.RequestedProcedureComments);
            iod.SetAttributeNull(DicomTags.RequestedProcedurePriority);
            iod.SetAttributeNull(DicomTags.ImagingServiceRequestComments);
            iod.SetAttributeNull(DicomTags.RequestingPhysician);
            iod.SetAttributeNull(DicomTags.ReferringPhysiciansName);
            iod.SetAttributeNull(DicomTags.RequestedProcedureLocation);
            iod.SetAttributeNull(DicomTags.AccessionNumber);
            iod.SetAttributeNull(DicomTags.PatientsSex);

            ScheduledProcedureStepSequenceIod scheduledProcedureStepSequenceIod = new ScheduledProcedureStepSequenceIod();
            scheduledProcedureStepSequenceIod.SetCommonTags();
            iod.ScheduledProcedureStepModule.ScheduledProcedureStepSequenceList.Add(scheduledProcedureStepSequenceIod);

            //// TODO: this better and easier...
            //DicomAttributeSQ dicomAttributeSQ = dicomAttributeProvider[DicomTags.ScheduledProcedureStepSequence] as DicomAttributeSQ;
            //DicomSequenceItem dicomSequenceItem = new DicomSequenceItem();
            //dicomAttributeSQ.Values = dicomSequenceItem;

            //dicomSequenceItem[DicomTags.Modality].SetNullValue();
            //dicomSequenceItem[DicomTags.ScheduledProcedureStepId].SetNullValue();
            //dicomSequenceItem[DicomTags.ScheduledProcedureStepDescription].SetNullValue();
            //dicomSequenceItem[DicomTags.ScheduledStationAeTitle].SetNullValue();
            //dicomSequenceItem[DicomTags.ScheduledProcedureStepStartDate].SetNullValue();
            //dicomSequenceItem[DicomTags.ScheduledProcedureStepStartTime].SetNullValue();
            //dicomSequenceItem[DicomTags.ScheduledPerformingPhysiciansName].SetNullValue();
            //dicomSequenceItem[DicomTags.ScheduledProcedureStepLocation].SetNullValue();
            //dicomSequenceItem[DicomTags.ScheduledProcedureStepStatus].SetNullValue();
            //dicomSequenceItem[DicomTags.CommentsOnTheScheduledProcedureStep].SetNullValue();

        }