Example #1
0
        public void ConfigureCommand(DicomCommand command)
        {
            try
            {
                if (null == _configManager)
                {
                    if (ServiceLocator.IsRegistered <StorageModuleConfigurationManager> ( ))
                    {
                        _configManager = ServiceLocator.Retrieve <StorageModuleConfigurationManager> ( );
                    }
                    else
                    {
                        throw new InvalidOperationException("No " + typeof(StorageModuleConfigurationManager).Name + " registered.");
                    }
                }


                if (command is CStoreCommand)
                {
                    ConfigureCStoreCommand(command, _configManager.GetStorageAddInsSettings( ).StoreAddIn);
                }

                if (command is InstanceCStoreCommand)
                {
                    ConfigureInstanceCStoreCommand(command, _configManager.GetStorageAddInsSettings( ).StoreAddIn);
                }
            }
            catch (Exception exception)
            {
                LogEvent("Failed to configure CStore Command, default configuration will be applied.^\n" + exception.Message, command.RequestDataSet);
            }
        }
Example #2
0
        public void ConfigureCommand(DicomCommand command)
        {
            try
            {
                AdvancedSettings            settings;
                WorklistAddInsConfiguration worklistConfig;

                settings       = AdvancedSettings.Open(AddInsSession.ServiceDirectory);
                worklistConfig = GetWorklistAddInsSettings(settings);

                if (null != settings)
                {
                    if (command is NSetCommand)
                    {
                        ConfigureNSetCommand(command, worklistConfig);
                    }

                    if (command is MppsNSetCommand)
                    {
                        ConfigureMppsNSetCommand(command, worklistConfig);
                    }
                }
            }
            catch (Exception exception)
            {
                LogEvent("Failed to configure Modality Performed Procedure NSet Command, default configuration will be applied.^\n" + exception.Message, command.RequestDataSet);
            }
        }
Example #3
0
        private static void ConfigureQueryCFindCommand
        (
            DicomCommand command,
            QueryAddInConfigurationElement queryConfig
        )
        {
            QueryCFindCommand queryFindCommand;


            queryFindCommand = command as QueryCFindCommand;

            if (null != queryFindCommand)
            {
                queryFindCommand.QueryConfiguration.IncludePatientRelatedInstances = queryConfig.DataSetResponseOptions.IncludeNumberOfPatientInstances;
                queryFindCommand.QueryConfiguration.IncludePatientRelatedSeries    = queryConfig.DataSetResponseOptions.IncludeNumberOfPatientSeries;
                queryFindCommand.QueryConfiguration.IncludePatientRelatedStudies   = queryConfig.DataSetResponseOptions.IncludeNumberOfPatientStudies;
                queryFindCommand.QueryConfiguration.IncludeSeriesRelatedInstances  = queryConfig.DataSetResponseOptions.IncludeNumberOfSeriesInstances;
                queryFindCommand.QueryConfiguration.IncludeStudyRelatedInstances   = queryConfig.DataSetResponseOptions.IncludeNumberOfStudyInstances;
                queryFindCommand.QueryConfiguration.IncludeStudyRelatedSeries      = queryConfig.DataSetResponseOptions.IncludeNumberOfStudySeries;
                queryFindCommand.QueryConfiguration.QueryIODPath = queryConfig.QueryIODPath;

                queryFindCommand.LimitResponses   = queryConfig.LimitCFindRsp;
                queryFindCommand.MaximumResponses = queryConfig.MaximumCFindRspCount;
                queryFindCommand.ServiceStatus    = queryConfig.ServiceStatus;
            }
        }
Example #4
0
        public static void ConfigureCStoreCommand
        (
            DicomCommand command,
            StoreAddInConfigurationElement storeConfig
        )
        {
            CStoreCommand storeCommand;


            storeCommand = command as CStoreCommand;

            if (null != storeCommand)
            {
                storeCommand.Configuration.DataSetStorageLocation = storeConfig.StorageLocation;
#if (LEADTOOLS_V19_OR_LATER)
                storeCommand.Configuration.HangingProtocolLocation = storeConfig.HangingProtocolLocation;
#endif
                storeCommand.Configuration.OverwriteBackupLocation = storeConfig.OverwriteBackupLocation;
                storeCommand.Configuration.DicomFileExtension      = storeConfig.StoreFileExtension;

                storeCommand.Configuration.DirectoryStructure.CreatePatientFolder = storeConfig.DirectoryStructure.CreatePatientFolder;
                storeCommand.Configuration.DirectoryStructure.CreateSeriesFolder  = storeConfig.DirectoryStructure.CreateSeriesFolder;
                storeCommand.Configuration.DirectoryStructure.CreateStudyFolder   = storeConfig.DirectoryStructure.CreateStudyFolder;
                storeCommand.Configuration.DirectoryStructure.UsePatientName      = storeConfig.DirectoryStructure.UsePatientName;
                storeCommand.Configuration.DirectoryStructure.SplitPatientId      = storeConfig.DirectoryStructure.SplitPatientId;

                foreach (SaveImageFormatElement imageFormatElement in storeConfig.ImagesFormat)
                {
                    SaveImageFormat imageFormat = GetImageFormat(imageFormatElement);

                    storeCommand.Configuration.OtherImageFormat.Add(imageFormat);
                }

                storeCommand.Configuration.SaveThumbnail = storeConfig.CreateThumbnailImage;

                if (storeCommand.Configuration.SaveThumbnail)
                {
                    storeCommand.Configuration.ThumbnailFormat = GetImageFormat(storeConfig.ThumbnailFormat);
                }

#if (LEADTOOLS_V20_OR_LATER)
                storeCommand.Configuration.SaveMetadataOptions.StoreJson     = storeConfig.JsonStore;
                storeCommand.Configuration.SaveMetadataOptions.SaveJsonFlags =
                    (storeConfig.JsonTrimWhiteSpace     ? DicomDataSetSaveJsonFlags.TrimWhiteSpace   : DicomDataSetSaveJsonFlags.None) |
                    (storeConfig.JsonWriteKeyword       ? DicomDataSetSaveJsonFlags.WriteKeyword     : DicomDataSetSaveJsonFlags.None) |
                    (storeConfig.JsonMinify             ? DicomDataSetSaveJsonFlags.Minify           : DicomDataSetSaveJsonFlags.None) |
                    (storeConfig.JsonIgnoreBinaryData   ? DicomDataSetSaveJsonFlags.IgnoreBinaryData : DicomDataSetSaveJsonFlags.None);

                storeCommand.Configuration.SaveMetadataOptions.StoreXml     = storeConfig.XmlStore;
                storeCommand.Configuration.SaveMetadataOptions.SaveXmlFlags =
                    (storeConfig.XmlTrimWhiteSpace      ? DicomDataSetSaveXmlFlags.TrimWhiteSpace       : DicomDataSetSaveXmlFlags.None) |
                    (storeConfig.XmlTrimWhiteSpace      ? DicomDataSetSaveXmlFlags.WriteFullEndElement  : DicomDataSetSaveXmlFlags.None) |
                    (storeConfig.XmlTrimWhiteSpace      ? DicomDataSetSaveXmlFlags.IgnoreBinaryData     : DicomDataSetSaveXmlFlags.IgnoreBinaryData);
                storeCommand.Configuration.SaveMetadataOptions.StoreXml = storeConfig.XmlStore;
#endif // #if (LEADTOOLS_V20_OR_LATER)
            }
        }
Example #5
0
        public void ConfigureCommand(DicomCommand command)
        {
            if (command is MediaNCreateCommand)
            {
                MediaNCreateCommand mediaCreateCommand;


                mediaCreateCommand = ( MediaNCreateCommand )command;

                mediaCreateCommand.DefaultMediaProfile = AddInsSession.AddInConfiguration.DefaultProfile;
            }
        }
Example #6
0
        private static void ConfigureMppsNSetCommand
        (
            DicomCommand command,
            WorklistAddInsConfiguration worklistConfig
        )
        {
            MppsNSetCommand mppsSetCommand;


            mppsSetCommand = command as MppsNSetCommand;

            if (null != mppsSetCommand)
            {
                mppsSetCommand.PPSConfiguration.ModalityPerformedProcedureStepIODPath = worklistConfig.ModaliyPerformedProcedureSetIODPath;
            }
        }
        public void ConfigureCommand(DicomCommand command)
        {
            try
            {
                AdvancedSettings            settings;
                WorklistAddInsConfiguration worklistConfig;

                settings       = AdvancedSettings.Open(AddInsSession.ServiceDirectory);
                worklistConfig = GetWorklistAddInsSettings(settings);



                if (null != worklistConfig)
                {
                    if (DataAccessServices.IsDataAccessServiceRegistered <IWorklistDataAccessAgent> ( ))
                    {
                        IWorklistDataAccessAgent dataAccess = DataAccessServices.GetDataAccessService <IWorklistDataAccessAgent> ( );

                        if (dataAccess is WorklistDbDataAccessAgent)
                        {
                            if (worklistConfig.LimitNumberOfResponses)
                            {
                                (( WorklistDbDataAccessAgent )dataAccess).NumberOfMatchingWlResponses = worklistConfig.NumberOfMatchingResponses;
                            }
                            else
                            {
                                (( WorklistDbDataAccessAgent )dataAccess).NumberOfMatchingWlResponses = -1;
                            }
                        }
                    }

                    if (command is CFindCommand)
                    {
                        ConfigureCFindCommand(command, worklistConfig);
                    }

                    if (command is MWLCFindCommand)
                    {
                        ConfigureQueryCFindCommand(command, worklistConfig);
                    }
                }
            }
            catch (Exception exception)
            {
                LogEvent("Failed to configure Modality Worklist CFind Command, default configuration will be applied.^\n" + exception.Message, command.RequestDataSet);
            }
        }
        private static void ConfigureNCreateCommand
        (
            DicomCommand command,
            WorklistAddInsConfiguration worklistConfig
        )
        {
            NCreateCommand createCommand;


            createCommand = command as NCreateCommand;

            if (null != createCommand)
            {
                createCommand.Configuration.AllowExtraElements   = worklistConfig.ModalityPerformedProcedureCreateValidation.AllowExtraElements;
                createCommand.Configuration.AllowPrivateElements = worklistConfig.ModalityPerformedProcedureCreateValidation.AllowPrivateElements;
            }
        }
Example #9
0
        private static void ConfigureNSetCommand
        (
            DicomCommand command,
            WorklistAddInsConfiguration worklistConfig
        )
        {
            NSetCommand setCommand;


            setCommand = command as NSetCommand;

            if (null != setCommand)
            {
                setCommand.Configuration.AllowExtraElements   = worklistConfig.ModalityPerformedProcedureSetValidation.AllowExtraElements;
                setCommand.Configuration.AllowPrivateElements = worklistConfig.ModalityPerformedProcedureSetValidation.AllowPrivateElements;
            }
        }
        private static void ConfigureMppsNCreateCommand
        (
            DicomCommand command,
            WorklistAddInsConfiguration worklistConfig
        )
        {
            MppsNCreateCommand mppsCreateCommand;


            mppsCreateCommand = command as MppsNCreateCommand;

            if (null != mppsCreateCommand)
            {
                mppsCreateCommand.PPSConfiguration.ModalityPerformedProcedureStepIODPath      = worklistConfig.ModaliyPerformedProcedureCreateIODPath;
                mppsCreateCommand.PPSConfiguration.ValidateRelationalAttributesAccordingToIHE = worklistConfig.ModalityPerformedProcedureCreateValidation.ValidateRelationalToIHERules;
            }
        }
Example #11
0
        private static void ConfigureCFindCommand
        (
            DicomCommand command,
            QueryAddInConfigurationElement findConfig
        )
        {
            CFindCommand findCommand;


            findCommand = command as CFindCommand;

            if (null != findCommand)
            {
                findCommand.Configuration.AllowExtraElements   = findConfig.DataSetRequestValidation.AllowExtraElements;
                findCommand.Configuration.AllowMultipleItems   = findConfig.DataSetRequestValidation.AllowMultipleItemsSequence;
                findCommand.Configuration.AllowPrivateElements = findConfig.DataSetRequestValidation.AllowPrivateElements;
                findCommand.Configuration.AllowZeroItemCount   = findConfig.DataSetRequestValidation.AllowZeroItemsSequence;
            }
        }
        private static void ConfigureCFindCommand
        (
            DicomCommand command,
            WorklistAddInsConfiguration findConfig
        )
        {
            CFindCommand findCommand;


            findCommand = command as CFindCommand;

            if (null != findCommand)
            {
                findCommand.Configuration.AllowExtraElements   = findConfig.ModalityWorklistValidation.AllowExtraElements;
                findCommand.Configuration.AllowMultipleItems   = findConfig.ModalityWorklistValidation.AllowMultipleItemsSequence;
                findCommand.Configuration.AllowPrivateElements = findConfig.ModalityWorklistValidation.AllowPrivateElements;
                findCommand.Configuration.AllowZeroItemCount   = findConfig.ModalityWorklistValidation.AllowZeroItemsSequence;
            }
        }
        private static void ConfigureQueryCFindCommand
        (
            DicomCommand command,
            WorklistAddInsConfiguration findConfig
        )
        {
            MWLCFindCommand queryFindCommand;


            queryFindCommand = command as MWLCFindCommand;

            if (null != queryFindCommand)
            {
                queryFindCommand.MWLConfiguration.ExcludeCompletedStatus            = findConfig.EliminateCompletedMWL;
                queryFindCommand.MWLConfiguration.ExcludeDiscontinuedStatus         = findConfig.EliminateDiscontinuedMWL;
                queryFindCommand.MWLConfiguration.ExcludeInProgressStatus           = findConfig.EliminateInProgressMWL;
                queryFindCommand.MWLConfiguration.LimitMWLResponseToClientStationAE = findConfig.UseStationAETitleForMatching;
                queryFindCommand.MWLConfiguration.ModalityWorklistIODPath           = findConfig.ModaliyWorklistIODPath;
            }
        }
Example #14
0
        public static void ConfigureInstanceCStoreCommand
        (
            DicomCommand command,
            StoreAddInConfigurationElement storeConfig
        )
        {
            InstanceCStoreCommand instanceStoreCommand;


            instanceStoreCommand = command as InstanceCStoreCommand;

            if (null != instanceStoreCommand)
            {
                instanceStoreCommand.InstanceConfiguration.CreateBackupForDuplicateSop = storeConfig.CreateBackupBeforeOverwrite;
                instanceStoreCommand.InstanceConfiguration.UpdateInstanceData          = storeConfig.DatabaseOptions.UpdateExistentInstance;
                instanceStoreCommand.InstanceConfiguration.UpdatePatientData           = storeConfig.DatabaseOptions.UpdateExistentPatient;
                instanceStoreCommand.InstanceConfiguration.UpdateSeriesData            = storeConfig.DatabaseOptions.UpdateExistentSeries;
                instanceStoreCommand.InstanceConfiguration.UpdateStudyData             = storeConfig.DatabaseOptions.UpdateExistentStudy;

                instanceStoreCommand.InstanceConfiguration.ValidateDuplicateSopInstanceUID = storeConfig.PreventStoringDuplicateInstance;
            }
        }
 public virtual void NAction(ActiveAssociation assoc, IDimse request)
 {
     IDicomCommand requestCmd = request.DicomCommand;
     var rspCmd = new DicomCommand();
     rspCmd.InitNActionRSP(requestCmd.MessageID, requestCmd.RequestedSOPClassUniqueId, requestCmd.RequestedSOPInstanceUniqueId, Success);
     DataSet rspData = null;
     try {
         rspData = DoNAction(assoc, request, rspCmd);
     }
     catch (DcmServiceException e) {
         e.WriteTo(rspCmd);
     }
     IDimse rsp = _associationFactory.NewDimse(request.PresentationContextId(), rspCmd, rspData);
     assoc.Association.Write(rsp);
     DoAfterRsp(assoc, rsp);
 }
Example #16
0
        public DicomCommandStatusType OnNAction(DicomClient Client, byte PresentationId, int MessageID, string AffectedClass, string Instance, int Action, DicomDataSet Request, DicomDataSet Response)
        {
            ClientSession clientSession             = null;
            INActionClientSessionProxy sessionProxy = null;
            DicomCommand patientUpdateCommand       = null;

            CompositeInstanceDataSet.InstanceRow[] instanceRows = null;

            if (_TemporaryDirectory == null)
            {
                _TemporaryDirectory = Client.Server.TemporaryDirectory;
            }

            if (Instance != PatientUpdaterConstants.UID.PatientUpdateInstance)
            {
                return(DicomCommandStatusType.InvalidObjectInstance);
            }

            if (clientSession != null)
            {
                clientSession.NActionResponse -= clientSession_NActionResponse;
                clientSession = null;
            }

            clientSession = new ClientSession(Client);
            clientSession.NActionResponse += new EventHandler <NActionResponseEventArgs>(clientSession_NActionResponse);
            sessionProxy         = new NActionClientSessionProxy(clientSession, PresentationId, MessageID, AffectedClass, Instance, Action, Response);
            patientUpdateCommand = DicomCommandFactory.GetInstance().CreateNActionCommand(sessionProxy, Request);

            _ClientSession = clientSession;
            _SessionProxy  = sessionProxy;


            //
            // If we are deleting we need to get the instance rows
            //
            List <string> studyInstanceUids;

            instanceRows = GetInstanceRows(Action, Request, out studyInstanceUids);

            ConfigureCommand(patientUpdateCommand as PatientUpdaterCommand);
            _ClientSession.ProcessNActionRequest(PresentationId, MessageID, AffectedClass, Instance, Action, patientUpdateCommand).WaitOne();

            if (_Status == DicomCommandStatusType.Success)
            {
                //
                // We need to delete the dicom files according to the user options
                //
                if (Action == PatientUpdaterConstants.Action.DeletePatient || Action == PatientUpdaterConstants.Action.DeleteSeries)
                {
                    if (instanceRows != null)
                    {
                        DicomFileDeleter deleter = new DicomFileDeleter();

                        try
                        {
                            StorageAddInsConfiguration storageSettings = Module.StorageConfigManager.GetStorageAddInsSettings();

                            deleter.DicomFileDeleted      += new EventHandler <Leadtools.Medical.Winforms.EventBrokerArgs.DicomFileDeletedEventArgs>(deleter_DicomFileDeleted);
                            deleter.DicomFileDeleteFailed += new EventHandler <Leadtools.Medical.Winforms.EventBrokerArgs.DicomFileDeletedEventArgs>(deleter_DicomFileDeleteFailed);
                            if (storageSettings != null)
                            {
                                deleter.DeleteFilesOnDatabaseDelete = storageSettings.StoreAddIn.DeleteFiles;
                                deleter.BackupFilesOnDatabaseDelete = storageSettings.StoreAddIn.BackupFilesOnDelete;
                                deleter.BackupFilesOnDeleteFolder   = storageSettings.StoreAddIn.DeleteBackupLocation;
                            }
                            deleter.Delete(null, instanceRows);
                        }
                        catch (Exception e)
                        {
                            Logger.Global.Error(Module.Source, "[Patient Updater] " + e.Message);
                        }
                        finally
                        {
                            deleter.DicomFileDeleted      -= deleter_DicomFileDeleted;
                            deleter.DicomFileDeleteFailed -= deleter_DicomFileDeleteFailed;
                        }
                    }
                }

                //
                // If auto update is enabled we need to forward this message to associated ae title
                //
                if (Module.Options != null && Module.Options.EnableAutoUpdate && Module.UpdateQueue != null)
                {
                    AutoUpdateItem item = new AutoUpdateItem(Client.AETitle)
                    {
                        Action = Action, ClientAE = Client.Server.AETitle
                    };

                    if (Action == PatientUpdaterConstants.Action.MergePatient && (instanceRows != null))
                    {
                        MergePatient mergePatientData = Request.Get <MergePatient>(null);
                        foreach (string studyInstanceUid in studyInstanceUids)
                        {
                            mergePatientData.ReferencedStudySequence.Add(new StudyInstanceReference(studyInstanceUid));
                        }
                        mergePatientData.PatientToMerge.Clear();
                        Request.Set(mergePatientData);
                    }
                    else if (studyInstanceUids.Count > 0)
                    {
                        DeletePatient deletePatientData = Request.Get <DeletePatient>(null);
                        foreach (string studyInstanceUid in studyInstanceUids)
                        {
                            deletePatientData.ReferencedStudySequence.Add(new StudyInstanceReference(studyInstanceUid));
                        }
                        Request.Set(deletePatientData);
                    }


                    // Request.InsertElementAndSetValue(DicomTag.ReferencedStudySequence)
                    item.Dicom = Request;

                    if (ShouldAutoUpdate(item.Action))
                    {
                        Module.UpdateQueue.AddItem(item);
                    }
                }
            }
            return(_Status);
        }
 public virtual Dimse NewDimse(int presentationContextId, DicomCommand dicomCommand, IDataSource dataSource)
 {
     return new Dimse(presentationContextId, dicomCommand, null, dataSource);
 }