Пример #1
0
        /// <summary>
        /// Generates a "Dicom Instances Accessed" update event in the audit log (with ActionCode of Delete), according to DICOM Supplement 95.
        /// </summary>
        /// <remarks>
        /// This method automatically separates different patients into separately logged events, as required by DICOM.
        ///
        /// We chose to impleemnt the DicomInstancesAccessed audit log, as opposed to the DicomStudyDeleted audit message because the whole
        /// study isn't being deleted, just a series.
        /// </remarks>
        /// <param name="aeTitles">The application entities from which the instances were accessed.</param>
        /// <param name="instances">The studies that the series belong that are being deleted.</param>
        /// <param name="eventSource">The source user or application entity which invoked the operation.</param>
        /// <param name="eventResult">The result of the operation.</param>
        public static void LogDeleteSeries(IEnumerable <string> aeTitles, AuditedInstances instances, EventSource eventSource, EventResult eventResult)
        {
            if (!AuditingEnabled)
            {
                return;
            }

            try
            {
                var aeTitlesArray = ToArray(aeTitles);
                foreach (var patient in instances.EnumeratePatients())
                {
                    var auditHelper = new DicomInstancesAccessedAuditHelper(eventSource, eventResult, EventIdentificationContentsEventActionCode.D);
                    auditHelper.AddUser(eventSource);
                    if (aeTitlesArray.Length > 0)
                    {
                        auditHelper.AddUser(new AuditProcessActiveParticipant(aeTitlesArray));
                    }
                    auditHelper.AddPatientParticipantObject(patient);
                    foreach (var study in instances.EnumerateStudies(patient))
                    {
                        auditHelper.AddStudyParticipantObject(study);
                    }
                    Log(auditHelper);
                }
            }
            catch (Exception ex)
            {
                Platform.Log(LogLevel.Warn, ex, _messageAuditFailed);
            }
        }
Пример #2
0
        /// <summary>
        /// Generates a "Dicom Study Deleted" event in the audit log, according to DICOM Supplement 95.
        /// </summary>
        /// <remarks>
        /// This method automatically separates different patients into separately logged events, as required by DICOM.
        /// </remarks>
        /// <param name="aeTitle">The application entity from which the instances were deleted.</param>
        /// <param name="instances">The studies that were deleted.</param>
        /// <param name="eventSource">The source user or application entity which invoked the operation.</param>
        /// <param name="eventResult">The result of the operation.</param>
        public static void LogDeleteStudies(string aeTitle, AuditedInstances instances, EventSource eventSource, EventResult eventResult)
        {
            if (!AuditingEnabled)
            {
                return;
            }

            try
            {
                foreach (var patient in instances.EnumeratePatients())
                {
                    var auditHelper = new DicomStudyDeletedAuditHelper(eventSource, eventResult);
                    auditHelper.AddUserParticipant(eventSource);
                    auditHelper.AddUserParticipant(new AuditProcessActiveParticipant(aeTitle));
                    auditHelper.AddPatientParticipantObject(patient);
                    foreach (var study in instances.EnumerateStudies(patient))
                    {
                        auditHelper.AddStudyParticipantObject(study);
                    }
                    Log(auditHelper);
                }
            }
            catch (Exception ex)
            {
                Platform.Log(LogLevel.Warn, ex, _messageAuditFailed);
            }
        }
        private void AuditFailure(DicomProcessingResult result)
        {
            // This primarily happens with DICOMDIR files
            if (string.IsNullOrEmpty(result.StudyInstanceUid))
            {
                return;
            }

            if (!_context.FailedStudyAudits.ContainsKey(result.StudyInstanceUid))
            {
                var auditedInstances = new AuditedInstances();

                auditedInstances.AddInstance(result.PatientId, result.PatientsName,
                                             result.StudyInstanceUid);

                AuditHelper.LogImportStudies(auditedInstances, _context.AuditSource, EventResult.MajorFailure);

                _context.FailedStudyAudits.Add(result.StudyInstanceUid, result.StudyInstanceUid);
            }
        }
Пример #4
0
        /// <summary>
        /// Generates a "Data Export" event in the audit log, according to DICOM Supplement 95.
        /// </summary>
        /// <remarks>
        /// One audit event is generated for each file system volume to which data is exported.
        /// If the audited instances are not on a file system, a single event is generated with an empty media identifier.
        /// </remarks>
        /// <param name="instances">The files that were exported.</param>
        /// <param name="eventSource">The source user or application entity which invoked the operation.</param>
        /// <param name="currentAE">The current DICOM AE performing the operation.</param>
        /// <param name="eventResult">The result of the operation.</param>
        public static void LogExportStudies(AuditedInstances instances, EventSource eventSource, EventSource currentAE, EventResult eventResult)
        {
            if (!AuditingEnabled)
            {
                return;
            }

            try
            {
                var fileVolumes = new List <string>(instances.EnumerateFileVolumes());
                if (fileVolumes.Count == 0)
                {
                    fileVolumes.Add(string.Empty);
                }

                foreach (var volume in fileVolumes)
                {
                    var auditHelper = new DataExportAuditHelper(eventSource, eventResult, volume);
                    auditHelper.AddExporter(eventSource);
                    if (eventSource != currentAE)
                    {
                        auditHelper.AddExporter(currentAE);
                    }
                    foreach (var patient in instances.EnumeratePatients())
                    {
                        auditHelper.AddPatientParticipantObject(patient);
                    }
                    foreach (var study in instances.EnumerateStudies())
                    {
                        auditHelper.AddStudyParticipantObject(study);
                    }
                    Log(auditHelper);
                }
            }
            catch (Exception ex)
            {
                Platform.Log(LogLevel.Warn, ex, _messageAuditFailed);
            }
        }
Пример #5
0
        /// <summary>
        /// Generates a "DICOM Instances Transferred" received event in the audit log, according to DICOM Supplement 95.
        /// </summary>
        /// <remarks>
        /// This method automatically separates different patients into separately logged events, as required by DICOM.
        /// </remarks>
        /// <param name="localAETitle">The local application entity to which the transfer was completed.</param>
        /// <param name="remoteAETitle">The application entity from which the transfer was completed.</param>
        /// <param name="remoteHostName">The hostname of the application entity from which the transfer was completed.</param>
        /// <param name="instances">The studies that were transferred.</param>
        /// <param name="eventSource">The source user or application entity which invoked the operation.</param>
        /// <param name="eventResult">The result of the operation.</param>
        /// <param name="action">The action taken on the studies that were transferred.</param>
        public static void LogReceivedInstances(string localAETitle, string remoteAETitle, string remoteHostName, AuditedInstances instances, EventSource eventSource, EventResult eventResult, EventReceiptAction action)
        {
            if (!AuditingEnabled)
            {
                return;
            }

            try
            {
                foreach (var patient in instances.EnumeratePatients())
                {
                    var auditHelper = new DicomInstancesTransferredAuditHelper(eventSource, eventResult, action,
                                                                               remoteAETitle ?? localAETitle, remoteHostName ?? LocalHostname, localAETitle, LocalHostname);
                    foreach (var study in instances.EnumerateStudies(patient))
                    {
                        auditHelper.AddStudyParticipantObject(study);
                    }
                    Log(auditHelper);
                }
            }
            catch (Exception ex)
            {
                Platform.Log(LogLevel.Warn, ex, _messageAuditFailed);
            }
        }