Example #1
0
 /// <summary>
 /// Audits the patient read access.
 /// </summary>
 /// <param name="patientAccessEvent">The patient access event.</param>
 public void AuditPatientReadAccess(PatientAccessEvent patientAccessEvent)
 {
     if (!_patientAccessEventRepository.IsPatientReadAccessAuditedToday(patientAccessEvent, _systemAccountProvider.SystemAccount.Key))
     {
         _patientAccessEventRepository.MakePersistent(patientAccessEvent);
     }
 }
 /// <summary>
 /// Audits the patient read access.
 /// </summary>
 /// <param name="patientAccessEvent">The patient access event.</param>
 public void AuditPatientReadAccess(PatientAccessEvent patientAccessEvent)
 {
     if (!_patientAccessEventRepository.IsPatientReadAccessAuditedToday(patientAccessEvent, _systemAccountProvider.SystemAccount.Key))
     {
         _patientAccessEventRepository.MakePersistent ( patientAccessEvent );
     }
 }
        internal void AuditPatientAccess(object entity, AbstractEvent @event, string patientAccessEventType, Func<string> getAuditNote)
        {
            var patientAccessAuditable = entity as IPatientAccessAuditable;

            var aggregateNode = entity as IAggregateNode;
            var aggregateRoot = entity as IAggregateRoot;

            if (aggregateNode != null)
            {
                aggregateRoot = aggregateNode.AggregateRoot;
                patientAccessAuditable = aggregateRoot as IPatientAccessAuditable;
            }

            if (patientAccessAuditable == null)
            {
                return;
            }

            string noteResult = getAuditNote();

            if ( string.IsNullOrWhiteSpace ( noteResult ) )
            {
                return;
            }

            Patient patient = patientAccessAuditable.AuditedPatient;

            ISession session = @event.Session.GetSession(EntityMode.Poco);

            PatientAccessEventType eventType = PatientAccessEventTypeHelper.GetPatientAccessEventTypeByWellKnownName(
                session, patientAccessEventType);

            var eventAccessEntry = new PatientAccessEvent(patient, eventType, patientAccessAuditable.AuditedContextDescription, noteResult)
                {
                    AggregateRootTypeName = aggregateRoot.GetType().FullName,
                    AggregateRootKey = aggregateRoot.Key,
                    AggregateNodeTypeName = aggregateNode == null ? null : aggregateNode.GetType().FullName
                };

            if (aggregateNode != null)
            {
                if ((aggregateNode as IEntity) != null)
                {
                    eventAccessEntry.AggregateNodeKey = (aggregateNode as IEntity).Key;
                }
            }

            session.Save(eventAccessEntry);

            session.Flush();
        }