Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Visit"/> class.
        /// </summary>
        /// <param name="staff">The staff.</param>
        /// <param name="appointmentDateTimeRange">The appointment date time range.</param>
        /// <param name="clinicalCase">The clinical case.</param>
        /// <param name="visitStatus">The visit status.</param>
        /// <param name="placeOfService">The place of service.</param>
        /// <param name="name">The name.</param>
        /// <param name="cptCode">The CPT code.</param>
        protected internal Visit(Staff staff, 
            DateTimeRange appointmentDateTimeRange,
            ClinicalCase clinicalCase,
            VisitStatus visitStatus,
            Location placeOfService,
            string name,
            string cptCode )
            : base(staff, appointmentDateTimeRange)
        {
            Check.IsNotNull ( clinicalCase, "Clinical case is required." );
            Check.IsNotNull ( visitStatus, "Visit status is required." );
            Check.IsNotNull ( placeOfService, "Location is required." );
            Check.IsNotNull ( name, "Name is required." );
            Check.IsNotNull ( cptCode, "CptCode is required." );

            if ( visitStatus.WellKnownName != WellKnownNames.VisitModule.VisitStatus.Scheduled )
            {
                throw new ArgumentException ( "Visits must always be created as scheduled visits." );
            }

            _clinicalCase = clinicalCase;
            _visitStatus = visitStatus;
            _serviceLocation = placeOfService;
            _name = name;
            _cptCode = cptCode;
            _activities = new List<Activity> ();
            _problems = new List<VisitProblem> ();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the appointment.
        /// </summary>
        /// <param name="staff">
        /// The staff.
        /// </param>
        /// <param name="appointmentDateTimeRange">
        /// The appointment date time range.
        /// </param>
        /// <returns>
        /// An Appointment.
        /// </returns>
        public Appointment CreateAppointment( Staff staff, DateTimeRange appointmentDateTimeRange )
        {
            var appointment = new Appointment ( staff, appointmentDateTimeRange );

            _appointmentRepository.MakePersistent ( appointment );

            return appointment;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Appointment"/> class.
        /// </summary>
        /// <param name="staff">The staff.</param>
        /// <param name="appointmentDateTimeRange">The appointment date time range.</param>
        protected internal Appointment( Staff staff, DateTimeRange appointmentDateTimeRange )
        {
            Check.IsNotNull ( staff, "Staff is required." );
            Check.IsNotNull ( appointmentDateTimeRange, "AppointmentDateTimeRange is required." );

            _staff = staff;
            _appointmentDateTimeRange = appointmentDateTimeRange;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Login to a session as given staff.
        /// </summary>
        /// <param name="staff">The staff.</param>
        public void LoginAs( Staff staff )
        {
            Check.IsNotNull ( staff, "Staff is required." );

            var claimsPrincipal = _currentClaimsPrincipalService.GetCurrentPrincipal ();

            _permissionClaimsManager.IssueSystemPermissionClaimsForStaff ( claimsPrincipal, staff );
            _permissionClaimsManager.IssueStaffKeyClaims ( claimsPrincipal, staff );
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates the staff.
        /// </summary>
        /// <param name="agency">The agency.</param>
        /// <param name="staffProfile">The staff profile.</param>
        /// <returns>
        /// A Staff
        /// </returns>
        public Staff CreateStaff( Agency agency, StaffProfile staffProfile)
        {
            var staff = new Staff(agency, staffProfile);

            AddStaffChecklistItemsAndStaffEvents(staff);

            _staffRepository.MakePersistent ( staff );

            return staff;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates the visit.
        /// </summary>
        /// <param name="staff">The staff.</param>
        /// <param name="appointmentDateTimeRange">The appointment date time range.</param>
        /// <param name="clinicalCase">The clinical case.</param>
        /// <param name="visitTemplate">The visit template.</param>
        /// <param name="serviceLocation">The service location.</param>
        /// <returns>
        /// A Visit.
        /// </returns>
        public Visit CreateVisit(Staff staff, 
            DateTimeRange appointmentDateTimeRange,
            ClinicalCase clinicalCase,
            VisitTemplate visitTemplate,
            Location serviceLocation )
        {
            var visitStatus = _visitStatusRepository.GetByWellKnownName ( WellKnownNames.VisitModule.VisitStatus.Scheduled );
            var visit = new Visit (staff, appointmentDateTimeRange, clinicalCase, visitStatus, serviceLocation, visitTemplate.Name, visitTemplate.CptCode );

            _visitRepository.MakePersistent ( visit );
            return visit;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClinicalCaseSignedComment"/> class.
        /// </summary>
        /// <param name="staff">The staff.</param>
        /// <param name="signedTimestamp">The signed timestamp.</param>
        /// <param name="signedNote">The signed note.</param>
        public ClinicalCaseSignedComment(
            Staff staff,
            DateTimeOffset signedTimestamp,
            string signedNote )
        {
            Check.IsNotNull ( staff, "Staff is required." );
            Check.IsNotNull ( signedTimestamp, "Signed timestamp is required." );
            Check.IsNotNullOrWhitespace ( signedNote, "Signed note is required." );

            _staff = staff;
            _signedTimestamp = signedTimestamp;
            _signedNote = signedNote;
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BillingOffice"/> class.
 /// </summary>
 /// <param name="agency">The agency.</param>
 /// <param name="administratorStaff">The administrator staff.</param>
 /// <param name="electronicTransmitterIdentificationNumber">The electronic transmitter identification number.</param>
 /// <param name="profile">The profile.</param>
 protected internal BillingOffice(
     Agency agency, Staff administratorStaff, string electronicTransmitterIdentificationNumber, BillingOfficeProfile profile )
     : this()
 {
     Check.IsNotNull ( agency, () => Agency );
     Check.IsNotNull ( administratorStaff, () => AdministratorStaff );
     Check.IsNotNull ( electronicTransmitterIdentificationNumber, () => ElectronicTransmitterIdentificationNumber );
     Check.IsNotNull ( profile, () => Profile );
     Agency = agency;
     AdministratorStaff = administratorStaff;
     ElectronicTransmitterIdentificationNumber = electronicTransmitterIdentificationNumber;
     Profile = profile;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProgramEnrollment"/> class.
        /// </summary>
        /// <param name="programOffering">The program offering.</param>
        /// <param name="clinicalCase">The clinical case.</param>
        /// <param name="enrollmentDate">The enrollment date.</param>
        /// <param name="enrollingStaff">The enrolling staff.</param>
        protected internal ProgramEnrollment(ProgramOffering programOffering, ClinicalCase clinicalCase, DateTime enrollmentDate, Staff enrollingStaff)
            : this()
        {
            Check.IsNotNull(programOffering, "Program Offering is required.");
            Check.IsNotNull(clinicalCase, "Clinical Case is required.");
            Check.IsNotNull(enrollmentDate, "Enrollment Date is required.");
            Check.IsNotNull(enrollingStaff, "Enrolling Staff is required.");

            _programOffering = programOffering;
            _clinicalCase = clinicalCase;
            _enrollmentDate = enrollmentDate;
            _enrollingStaff = enrollingStaff;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Creates the billing office.
        /// </summary>
        /// <param name="agency">The agency.</param>
        /// <param name="administratorStaff">The administrator staff.</param>
        /// <param name="electronicTransmitterIdentificationNumber">The electronic transmitter identification number.</param>
        /// <param name="profile">The profile.</param>
        /// <returns>The Billing Office.</returns>
        public BillingOffice CreateBillingOffice(
            Agency agency, Staff administratorStaff, string electronicTransmitterIdentificationNumber, BillingOfficeProfile profile )
        {
            Check.IsNotNull ( agency, "Agency is required." );
            Check.IsNotNull ( administratorStaff, "Administrator Staff is required." );
            Check.IsNotNull ( electronicTransmitterIdentificationNumber, "Electronic Transmitter Identification Number is required." );

            var billingOffice = new BillingOffice ( agency, administratorStaff, electronicTransmitterIdentificationNumber, profile );

            _billingOfficeRepository.MakePersistent ( billingOffice );

            return billingOffice;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SelfPayment"/> class.
        /// </summary>
        /// <param name="patient">The patient.</param>
        /// <param name="collectedByStaff">The collected by staff.</param>
        /// <param name="money">The money.</param>
        /// <param name="paymentMethod">The payment method.</param>
        /// <param name="collectedDate">The collected date.</param>
        protected internal SelfPayment( Patient patient, Staff collectedByStaff, Money money, PaymentMethod paymentMethod, DateTime? collectedDate )
        {
            Check.IsNotNull ( patient, () => Patient );
            Check.IsNotNull ( collectedByStaff, () => CollectedByStaff );
            Check.IsNotNull ( money, () => Money );
            Check.IsNotNull ( paymentMethod, () => PaymentMethod );
            Check.IsNotNull ( collectedDate, () => CollectedDate );

            _patient = patient;
            _collectedByStaff = collectedByStaff;
            _money = money;
            _paymentMethod = paymentMethod;
            _collectedDate = collectedDate;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Creates the self payment.
        /// </summary>
        /// <param name="patient">The patient.</param>
        /// <param name="staff">The staff.</param>
        /// <param name="money">The money.</param>
        /// <param name="paymentMethod">The payment method.</param>
        /// <param name="collectedDate">The collected date.</param>
        /// <returns>A Self Payment.</returns>
        public SelfPayment CreateSelfPayment( Patient patient, Staff staff, Money money, PaymentMethod paymentMethod, DateTime? collectedDate )
        {
            var selfPayment = new SelfPayment ( patient, staff, money, paymentMethod, collectedDate );
            SelfPayment createdSelfPayment = null;

            DomainRuleEngine.CreateRuleEngine ( selfPayment, "CreateSelfPaymentRuleSet" )
                .Execute ( () =>
                    {
                        createdSelfPayment = selfPayment;

                        _selfPaymentRepository.MakePersistent(createdSelfPayment);
                    });

            return createdSelfPayment;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AgencyContact"/> class.
        /// </summary>
        /// <param name="agencyContactType">
        /// The agency contact type.
        /// </param>
        /// <param name="contactStaff">
        /// The contact staff.
        /// </param>
        /// <param name="effectiveStartDate">
        /// The effective start date.
        /// </param>
        /// <param name="statusIndicator">
        /// The status indicator.
        /// </param>
        /// <param name="alternativeContactIndicator">
        /// The alternative contact indicator.
        /// </param>
        protected internal AgencyContact(
            AgencyContactType agencyContactType, 
            Staff contactStaff, 
            DateTime? effectiveStartDate, 
            bool statusIndicator, 
            bool alternativeContactIndicator)
        {
            Check.IsNotNull(agencyContactType, () => AgencyContactType);
            Check.IsNotNull(contactStaff, () => ContactStaff);

            _agencyContactType = agencyContactType;
            _contactStaff = contactStaff;
            _effectiveStartDate = effectiveStartDate;
            _statusIndicator = statusIndicator;
            _alternativeContactIndicator = alternativeContactIndicator;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LocationContact"/> class.
        /// </summary>
        /// <param name="locationContactType">Type of the location contact.</param>
        /// <param name="contactStaff">The contact staff.</param>
        /// <param name="effectiveDateRange">The effective date range.</param>
        /// <param name="statusIndicator">If set to <c>true</c> [status indicator].</param>
        /// <param name="alternativeContactIndicator">If set to <c>true</c> [alternative contact indicator].</param>
        protected internal LocationContact(
            LocationContactType locationContactType, 
            Staff contactStaff, 
            DateRange effectiveDateRange, 
            bool statusIndicator, 
            bool alternativeContactIndicator)
        {
            Check.IsNotNull(locationContactType, () => LocationContactType);
            Check.IsNotNull(contactStaff, () => ContactStaff);

            _locationContactType = locationContactType;
            _contactStaff = contactStaff;
            _effectiveDateRange = effectiveDateRange;
            _statusIndicator = statusIndicator;
            _alternativeContactIndicator = alternativeContactIndicator;
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Encounter"/> class.
        /// </summary>
        /// <param name="patientAccount">The patient account.</param>
        /// <param name="serviceLocation">The service location.</param>
        /// <param name="serviceProviderStaff">The service provider staff.</param>
        /// <param name="trackingNumber">The tracking number.</param>
        /// <param name="serviceDate">The service date.</param>
        protected internal Encounter(
            PatientAccount patientAccount,
            Location serviceLocation,
            Staff serviceProviderStaff,
            long trackingNumber,
            DateTime serviceDate)
            : this()
        {
            Check.IsNotNull ( patientAccount, "Patient account is required." );
            Check.IsNotNull ( serviceLocation, "Place of service is required." );
            Check.IsNotNull ( serviceProviderStaff, "Service provider staff is required." );
            Check.IsNotNull ( serviceDate, "Service date staff is required." );

            PatientAccount = patientAccount;
            ServiceLocation = serviceLocation;
            ServiceProviderStaff = serviceProviderStaff;
            TrackingNumber = trackingNumber;
            ServiceDate = serviceDate;
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Creates the program enrollment.
        /// </summary>
        /// <param name="programOffering">The program offering.</param>
        /// <param name="clinicalCase">The clinical case.</param>
        /// <param name="enrollmentDate">The enrollment date.</param>
        /// <param name="enrollingStaff">The enrolling staff.</param>
        /// <returns>
        /// A ProgramEnrollment.
        /// </returns>
        public ProgramEnrollment CreateProgramEnrollment(ProgramOffering programOffering, ClinicalCase clinicalCase, DateTime enrollmentDate, Staff enrollingStaff)
        {
            Check.IsNotNull(programOffering, "Program Offering is required.");
            Check.IsNotNull(clinicalCase, "Clinical Case is required.");
            Check.IsNotNull(enrollmentDate, "Enrollment Date is required.");
            Check.IsNotNull(enrollingStaff, "Enrolling Staff is required.");

            var newProgramEnrollment = new ProgramEnrollment ( programOffering, clinicalCase, enrollmentDate, enrollingStaff );
            ProgramEnrollment createdProgramEnrollment = null;

            DomainRuleEngine.CreateRuleEngine ( newProgramEnrollment, "CreateProgramEnrollmentRuleSet" )
                .WithContext ( enrollmentDate )
                .WithContext ( enrollingStaff )
                .Execute ( () =>
                    {
                        _programEnrollmentRepository.MakePersistent(newProgramEnrollment);
                        createdProgramEnrollment = newProgramEnrollment;
                    });

            return createdProgramEnrollment;
        }
Ejemplo n.º 17
0
        public void SetPrimaryLocation_GivenLocationButWithoutAgencyLocations_ValidationFailureEventIsRaised()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);
                var staff = new Staff(new Mock<Agency>().Object,
                          new StaffProfileBuilder().WithStaffName(new PersonNameBuilder().WithFirst("first name").WithLast("last name")));

                var location = new Location(
                    new Mock<Agency>().Object,
                    new LocationProfileBuilder().WithLocationName(new LocationNameBuilder().WithName("location name")));

                bool eventRaised = false;
                DomainEvent.Register<RuleViolationEvent>(p => eventRaised = true);

                // Exercise
                staff.SetPrimaryLocation(location);

                // Verify
                Assert.IsTrue(eventRaised);
            }
        }
Ejemplo n.º 18
0
        public void SetPrimaryLocation_GivenLocationButWithoutAgencyLocations_PrimaryLocationIsNotChanged()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture ( serviceLocatorFixture );

                var staff = new Staff(new Mock<Agency>().Object,
                        new StaffProfileBuilder().WithStaffName(new PersonNameBuilder().WithFirst("first name").WithLast("last name")));

                var location = new Location(
                    new Mock<Agency>().Object,
                    new LocationProfileBuilder().WithLocationName(new LocationNameBuilder().WithName("location name")));

                staff.SetPrimaryLocation(null);

                // Exercise
                staff.SetPrimaryLocation(location);

                // Verify
                Assert.IsTrue ( staff.PrimaryLocation == null );
            }
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Assigns the performed by staff.
 /// </summary>
 /// <param name="performedByStaff">The performed by staff.</param>
 /// <returns>A ClinicalCaseProfileBuilder.</returns>
 public ClinicalCaseProfileBuilder WithPerformedByStaff(Staff performedByStaff)
 {
     _performedByStaff = performedByStaff;
     return this;
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Destroys the staff.
 /// </summary>
 /// <param name="staff">The staff.</param>
 public void DestroyStaff( Staff staff )
 {
     Check.IsNotNull ( staff, "Staff is required." );
     _staffRepository.MakeTransient ( staff );
 }
Ejemplo n.º 21
0
        private void AddStaffChecklistItemsAndStaffEvents(Staff staff)
        {
            var staffChecklistItemTypes = _lookupValueRepository.GetAll ( typeof ( StaffChecklistItemType ) );
            staffChecklistItemTypes.ForEach(staffChecklistItem => staff.AddChecklistItem(new StaffChecklistItem((StaffChecklistItemType)staffChecklistItem)));

            var staffEventTypes = _lookupValueRepository.GetAll(typeof(StaffEventType));
            staffEventTypes.ForEach(staffEventType => staff.AddEvent(new StaffEvent((StaffEventType)staffEventType)));
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Issues the staff key claims.
        /// </summary>
        /// <param name="claimsPrincipal">The claims principal.</param>
        /// <param name="staff">The staff.</param>
        public void IssueStaffKeyClaims( IClaimsPrincipal claimsPrincipal, Staff staff )
        {
            Check.IsNotNull ( claimsPrincipal, "ClaimsPrincipal is required." );
            Check.IsNotNull ( staff, "Staff is required." );

            var realm = _federationAuthenticationModule.Realm;

            var claim = new Claim ( ClaimTypes.StaffKeyClaimType, staff.Key + string.Empty, realm );

            var identity = ( IClaimsIdentity )claimsPrincipal.Identity;
            identity.Claims.Add ( claim );

            Logger.Debug ( "Principal ({0}) is issued the following claim ({1}).", staff.StaffProfile.StaffName.Complete, claim.ToString () );
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Creates the encounter.
 /// </summary>
 /// <param name="patientAccount">The patient account.</param>
 /// <param name="placeOfService">The place of service.</param>
 /// <param name="serviceProvider">The service provider.</param>
 /// <param name="trackingNumber">The tracking number.</param>
 /// <param name="serviceDate">The service date.</param>
 /// <returns>An encounter.</returns>
 public Encounter CreateEncounter(PatientAccount patientAccount, Location placeOfService, Staff serviceProvider, long trackingNumber, DateTime serviceDate )
 {
     var encounter = new Encounter(patientAccount, placeOfService, serviceProvider, trackingNumber, serviceDate);
     _encounterRepository.MakePersistent(encounter);
     return encounter;
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Revises the administrator staff.
 /// </summary>
 /// <param name="administratorStaff">The administrator staff.</param>
 public virtual void ReviseAdministratorStaff( Staff administratorStaff )
 {
     Check.IsNotNull ( administratorStaff, () => AdministratorStaff );
     AdministratorStaff = administratorStaff;
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Issues the system permission claims for staff.
        /// </summary>
        /// <param name="claimsPrincipal">The claims principal.</param>
        /// <param name="staff">The staff.</param>
        public void IssueSystemPermissionClaimsForStaff( IClaimsPrincipal claimsPrincipal, Staff staff )
        {
            Check.IsNotNull ( claimsPrincipal, "ClaimsPrincipal is required." );
            Check.IsNotNull ( staff, "Staff is required." );

            var grantedRoles = staff.SystemRoles.Select ( x => x.SystemRole );
            var grantedPermissions = _systemPermissionService.FindGrantedSystemPermissions ( grantedRoles );
            IssueSystemPermissionClaimsForStaff ( claimsPrincipal, grantedPermissions, staff );
        }
Ejemplo n.º 26
0
        private void LoadEntitiesFromDomain( long patientKey, long staffKey, long agencyKey, long locationKey )
        {
            Logger.Debug ( "LoadEntitiesFromDomain - Loading Entities" );

            var patientCriteria =
                DetachedCriteria.For<Patient> ( "p" ).Add ( Restrictions.Eq ( Projections.Property ( "p.Key" ), patientKey ) );

            var staffCriteria = DetachedCriteria
                .For<Staff> ( "s" )
                .Add ( Restrictions.Eq ( Projections.Property ( "s.Key" ), staffKey ) );

            var agencyCriteria =
                DetachedCriteria.For<Agency> ( "a" ).Add ( Restrictions.Eq ( Projections.Property ( "a.Key" ), agencyKey ) );

            var locationCriteria =
                DetachedCriteria.For<Location> ( "l" ).Add ( Restrictions.Eq ( Projections.Property ( "l.Key" ), locationKey ) );

            var multiCriteria =
                _session.CreateMultiCriteria ()
                    .Add ( patientCriteria )
                    .Add ( staffCriteria )
                    .Add ( agencyCriteria )
                    .Add ( locationCriteria );

            var criteriaList = multiCriteria.List ();

            try
            {
                _patient = ( ( IList )criteriaList[0] )[0] as Patient;
            }
            catch ( ArgumentOutOfRangeException )
            {
                //// No patient with an Id of [_patientKey] was found.
                _patient = null;
            }
            _staff = ( ( IList )criteriaList[1] )[0] as Staff;
            _agency = ( ( IList )criteriaList[2] )[0] as Agency;
            _location = ( ( IList )criteriaList[3] )[0] as Location;
        }
Ejemplo n.º 27
0
 private LicensedPrescriberType BuildLicensedPrescriberType( Staff staff )
 {
     return new LicensedPrescriberType
         {
             ID = staff.Key.ToString (),
             LicensedPrescriberName = new PersonNameType
                 {
                     First = staff.StaffProfile.StaffName.First,
                     Last = staff.StaffProfile.StaffName.Last,
                     Middle = staff.StaffProfile.StaffName.Middle
                 },
             Dea = ExtractStaffIdentifier ( staff, StaffIdentifierType.Dea, true ),
             Npi = ExtractStaffIdentifier ( staff, StaffIdentifierType.Npi ),
         };
 }
Ejemplo n.º 28
0
        private static string ExtractStaffIdentifier( Staff staff, string identifierType, bool isRequired = false )
        {
            var candidate = staff.Identifiers.FirstOrDefault ( c => c.StaffIdentifierType.WellKnownName == identifierType );

            if ( candidate != null )
            {
                return candidate.IdentifierNumber;
            }

            if ( isRequired )
            {
                throw new ApplicationException ( string.Format ( "Staff Does not contain an Identifier of type {0}", identifierType ) );
            }

            return string.Empty;
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Rollbacks the emergency access.
        /// </summary>
        /// <param name="claimsPrincipal">The claims principal.</param>
        /// <param name="staff">The staff.</param>
        public void RollbackEmergencyAccess( IClaimsPrincipal claimsPrincipal, Staff staff )
        {
            Check.IsNotNull ( claimsPrincipal, "ClaimsPrincipal is required." );
            Check.IsNotNull ( staff, "Staff is required." );

            var identity = ( IClaimsIdentity )claimsPrincipal.Identity;
            identity.Claims.Clear ();
            IssueSystemPermissionClaims ( claimsPrincipal, staff.SystemAccount );
            IssueAccountKeyClaims ( claimsPrincipal, staff.SystemAccount );
            IssueSystemPermissionClaimsForStaff ( claimsPrincipal, staff );
            IssueStaffKeyClaims ( claimsPrincipal, staff );
        }
Ejemplo n.º 30
0
        private void IssueSystemPermissionClaimsForStaff(
            IPrincipal claimsPrincipal,
            IEnumerable<SystemPermission> grantedPermissions,
            Staff staff )
        {
            var identity = ( IClaimsIdentity )claimsPrincipal.Identity;
            var exsitingPermissions = FindExistingSystemPermissionWellKnownNames ( identity );

            var realm = _federationAuthenticationModule.Realm;

            foreach ( var grantedPermission in grantedPermissions )
            {
                if ( !exsitingPermissions.Any ( x => x == grantedPermission.WellKnownName ) )
                {
                    var claim = new Claim (
                        ClaimTypes.PermissionClaimType,
                        grantedPermission.WellKnownName,
                        realm );

                    identity.Claims.Add ( claim );

                    Logger.Debug ( "Staff ({0}) is issued the following claim ({1}).", staff.Key, claim.ToString () );
                }
                else
                {
                    Logger.Debug ( "Claim for permission ({0}) has already existed.", grantedPermission.WellKnownName );
                }
            }
        }