/// <summary> /// Creates the patient access event. /// </summary> /// <param name="patient">The patient.</param> /// <param name="patientAccessEventType">Type of the patient access event.</param> /// <param name="auditedContextDescription">The audited context description.</param> /// <param name="note">The note.</param> /// <returns> /// A PatientAccessEvent. /// </returns> public PatientAccessEvent CreatePatientAccessEvent( Patient patient, PatientAccessEventType patientAccessEventType, string auditedContextDescription, string note ) { var patientAccessEvent = new PatientAccessEvent(patient, patientAccessEventType, auditedContextDescription, note); return patientAccessEvent; }
/// <summary> /// Creates the patient access event. /// </summary> /// <param name="patient">The patient.</param> /// <param name="patientAccessEventType">Type of the patient access event.</param> /// <param name="auditedContextDescription">The audited context description.</param> /// <param name="note">The note.</param> /// <returns> /// A PatientAccessEvent. /// </returns> public PatientAccessEvent CreatePatientAccessEvent( Patient patient, PatientAccessEventType patientAccessEventType, string auditedContextDescription, string note) { var patientAccessEvent = new PatientAccessEvent(patient, patientAccessEventType, auditedContextDescription, note); return(patientAccessEvent); }
public void CreatePatientAccessEvent_GivenValidArguments_CreatesAnEvent() { var patientAccessEventFactory = new PatientAccessEventFactory(); var patient = new Mock <Patient> (); var patientAccessEventType = new Mock <PatientAccessEventType> (); PatientAccessEvent patientAccessEvent = patientAccessEventFactory.CreatePatientAccessEvent( patient.Object, patientAccessEventType.Object, "audited context decription", "some note"); Assert.IsNotNull(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(); }