/// <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); }
internal static PatientAccessEventType GetPatientAccessEventTypeByWellKnownName(ISession session, string wellKnownName) { IList result = session.CreateCriteria <PatientAccessEventType>() .Add(Restrictions.Eq("WellKnownName", wellKnownName)) .SetMaxResults(1) .List(); bool found = result != null && result.Count > 0; PatientAccessEventType lookupByWellKnownName = found ? result[0] as PatientAccessEventType : null; return(lookupByWellKnownName); }
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(); }
/// <summary> /// Initializes a new instance of the <see cref="PatientAccessEvent"/> class. /// </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> public PatientAccessEvent( Patient patient, PatientAccessEventType patientAccessEventType, string auditedContextDescription, string note ) { Check.IsNotNull ( patient, "Patient is required." ); Check.IsNotNull ( patientAccessEventType, "Patient access event is required." ); Check.IsNotNull(auditedContextDescription, "Audited context description is required."); Check.IsNotNullOrWhitespace ( note, "Note is required." ); _patient = patient; AuditedContextDescription = auditedContextDescription; _patientAccessEventType = patientAccessEventType; _note = note; }
/// <summary> /// Initializes a new instance of the <see cref="PatientAccessEvent"/> class. /// </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> public PatientAccessEvent( Patient patient, PatientAccessEventType patientAccessEventType, string auditedContextDescription, string note) { Check.IsNotNull(patient, "Patient is required."); Check.IsNotNull(patientAccessEventType, "Patient access event is required."); Check.IsNotNull(auditedContextDescription, "Audited context description is required."); Check.IsNotNullOrWhitespace(note, "Note is required."); _patient = patient; AuditedContextDescription = auditedContextDescription; _patientAccessEventType = patientAccessEventType; _note = note; }