예제 #1
0
 /// <inheritdoc />
 public WhenRecordingNewConsent_ForAnExistingStudySubject_WithoutActiveConsent()
 {
     A.CallTo(() => Consents.FindActiveConsent(StudySubject))
     .Returns(null);
     RecordConsent(
         Evidences.ServerMedwayDto(takenBy: "Peter Crowther"),
         2.January(1837));
 }
예제 #2
0
        private void Clear()
        {
            BookingDate = Date = DateTime.Today;

            SelectedMode    = Modes.OrderBy(x => x.Rank).FirstOrDefault();
            SelectedOutcome = Outcomes.OrderBy(x => x.Rank).FirstOrDefault();
            if (null != Consents)
            {
                SelectedConsent = Consents.OrderBy(x => x.Rank).FirstOrDefault();
            }
        }
예제 #3
0
 public object Clone()
 {
     return(new OAuthUser
     {
         Id = Id,
         Claims = Claims == null ? new Dictionary <string, string>() : Claims.ToDictionary(s => s.Key, s => s.Value),
         Consents = Consents == null ? new List <OAuthConsent>() : Consents.Select(c => (OAuthConsent)c.Clone()).ToList(),
         Credentials = Credentials == null ? new List <OAuthUserCredential>() : Credentials.Select(c => (OAuthUserCredential)c.Clone()).ToList(),
         CreateDateTime = CreateDateTime,
         UpdateDateTime = UpdateDateTime
     });
 }
예제 #4
0
            public WhenTryingToRecordConsent_ForAnExistingStudySubject_WithActiveConsent()
            {
                var dateGiven     = 3.November(1472);
                var givenEvidence = Array.Empty <IIdentifierValueDto>();

                existingConsentId = new ConsentIdentity(43);

                A.CallTo(() => Consents.FindActiveConsent(StudySubject))
                .Returns(existingConsentId);

                RecordConsent(givenEvidence, dateGiven);
            }
예제 #5
0
 private void InitialiseBindingData(long studyId, string subjectIdentifier)
 {
     StudySubject = subjects.GetStudySubject(new StudyIdentity(studyId), subjectIdentifier);
     if (StudySubject == null)
     {
         return;
     }
     Consents        = consents.GetConsentsForSubject(new StudyIdentity(studyId), subjectIdentifier);
     CurrentConsent  = Consents.FirstOrDefault();
     ConsentIsActive = CurrentConsent != null && CurrentConsent.DateWithdrawn == null;
     Identifiers     = identity.GetPersonIdentifiers(StudySubject.PersonId);
 }
예제 #6
0
 private void LoadTest()
 {
     if (null != TestResult)
     {
         Id              = TestResult.Id;
         Date            = TestResult.Date;
         SelectedMode    = Modes.FirstOrDefault(x => x.ItemId == TestResult.Mode);
         SelectedOutcome = Outcomes.FirstOrDefault(x => x.ItemId == TestResult.Outcome);
         SelectedConsent = Consents.FirstOrDefault(x => x.ItemId == TestResult.Consent);
         BookingDate     = TestResult.BookingDate;
     }
 }
예제 #7
0
        private void Clear()
        {
            BookingDate = Date = DateTime.Today;

            SelectedMode    = Modes.OrderBy(x => x.Rank).FirstOrDefault();
            SelectedOutcome = Outcomes.OrderBy(x => x.Rank).FirstOrDefault();
            if (null != Consents)
            {
                SelectedConsent = Consents.OrderBy(x => x.Rank).FirstOrDefault();
            }
            SelectedReasonNotContacted = ReasonsNotContacted.OrderBy(x => x.Rank).FirstOrDefault();
            ReasonNotContactedOther    = string.Empty;
        }
예제 #8
0
 public object Clone()
 {
     return(new OAuthUser
     {
         Id = Id,
         Claims = Claims == null ? new List <Claim>() : Claims.Select(_ => new Claim(_.Type, _.Value, _.ValueType)).ToList(),
         AuthenticationTime = AuthenticationTime,
         Consents = Consents == null ? new List <OAuthConsent>() : Consents.Select(c => (OAuthConsent)c.Clone()).ToList(),
         Credentials = Credentials == null ? new List <OAuthUserCredential>() : Credentials.Select(c => (OAuthUserCredential)c.Clone()).ToList(),
         CreateDateTime = CreateDateTime,
         UpdateDateTime = UpdateDateTime
     });
 }
예제 #9
0
 private void SetOutcome()
 {
     //
     if (null != SelectedOutcome && !SelectedOutcome.ItemId.IsNullOrEmpty() &&
         SelectedOutcome.ItemId == new Guid("b25f0a50-852f-11e7-bb31-be2e44b06b34"))  //Contacted
     {
         EnableBooking = EnableConsent = true;
     }
     else
     {
         EnableBooking   = EnableConsent = false;
         SelectedConsent = Consents.OrderBy(x => x.Rank).FirstOrDefault();
     }
 }
예제 #10
0
            public WhenTryingToRecordConsent_ForAnExistingStudySubject_WithActiveConsentForDifferentIdentifiers()
            {
                var givenEvidence = new [] { A.Dummy <Evidence>() };
                var dateGiven     = 3.November(1472);

                existingConsent = new Consent(StudySubject, dateGiven, Random.Long(), givenEvidence);
                A.CallTo(
                    () =>
                    Consents.FindActiveConsent(
                        StudySubject))
                .Returns(null);

                RecordConsent(Array.Empty <IIdentifierValueDto>(), dateGiven);
            }
예제 #11
0
        public ConsentIdentity FindActiveConsent(StudySubject studySubject)
        {
            var consents =
                Consents.Where(
                    _ => _.StudySubject.Person.Id == studySubject.PersonId.Id &&
                    _.StudySubject.Study.Id == studySubject.StudyId.Id &&
                    _.StudySubject.SubjectIdentifier == studySubject.SubjectIdentifier &&
                    _.DateWithdrawn == null);


            var consentId = consents.Select(_ => (long?)_.Id).SingleOrDefault();

            return(consentId == null ? null : new ConsentIdentity(consentId.Value));
        }
예제 #12
0
 private void HandleConsentAdded(object sender, NotificationEventArgs e)
 {
     Consents.Add(new ConsentPageViewModel
     {
         Title       = e.Title,
         Description = e.Description,
         AuthReqId   = e.AuthReqId,
         Permissions = new ObservableCollection <PermissionViewModel>(e.Permissions.Select(p => new PermissionViewModel
         {
             DisplayName  = p.DisplayName,
             PermissionId = p.PermissionId,
             IsSelected   = true
         }))
     });
 }
예제 #13
0
 private void LoadTest()
 {
     if (null != TestResult)
     {
         Id                         = TestResult.Id;
         Date                       = TestResult.Date;
         SelectedMode               = Modes.FirstOrDefault(x => x.ItemId == TestResult.Mode);
         SelectedOutcome            = Outcomes.FirstOrDefault(x => x.ItemId == TestResult.Outcome);
         SelectedConsent            = Consents.FirstOrDefault(x => x.ItemId == TestResult.Consent);
         BookingDate                = TestResult.BookingDate;
         SelectedReasonNotContacted =
             ReasonsNotContacted.FirstOrDefault(x => x.ItemId == TestResult.ReasonNotContacted);
         ReasonNotContactedOther = TestResult.ReasonNotContactedOther;
     }
 }
예제 #14
0
 public object Clone()
 {
     return(new OAuthUser
     {
         Id = Id,
         Status = Status,
         Credentials = Credentials == null ? new List <OAuthUserCredential>() : Credentials.Select(_ => (OAuthUserCredential)_.Clone()).ToList(),
         OAuthUserClaims = Claims == null ? new List <OAuthUserClaim>() : OAuthUserClaims.Select(_ => (OAuthUserClaim)_.Clone()).ToList(),
         DeviceRegistrationToken = DeviceRegistrationToken,
         Consents = Consents == null ? new List <OAuthConsent>() : Consents.Select(c => (OAuthConsent)c.Clone()).ToList(),
         CreateDateTime = CreateDateTime,
         UpdateDateTime = UpdateDateTime,
         Sessions = Sessions.Select(s => (OAuthUserSession)s.Clone()).ToList(),
         OTPCounter = OTPCounter,
         OTPKey = OTPKey
     });
 }
예제 #15
0
        /// <inheritdoc />
        public ConsentIdentity AddConsent(Common.Consent.Consent consent)
        {
            var subject = StudySubjects.FindStudySubjectForPerson(consent.StudySubject.StudyId, consent.StudySubject.PersonId).FirstOrDefault();

            if (subject == null)
            {
                throw new NotImplementedException($"StudySubject#{consent.StudySubject} not found");
            }

            PersonEntity givenBy = null;

            if (consent.GivenByPersonId != null)
            {
                givenBy = People.Get(consent.GivenByPersonId.Value);
                if (givenBy == null)
                {
                    throw new NotImplementedException($"Person#{consent.GivenByPersonId} not found");
                }
            }

            var saved = Consents.Add(
                new ConsentEntity {
                DateProvided = consent.DateGiven, GivenBy = givenBy, StudySubject = subject
            });

            foreach (var evidence in consent.GivenEvidence)
            {
                Evidence.Add(
                    new GivenEvidenceEntity
                {
                    Value   = EvidenceRegistry.MarshallToXml(evidence).ToString(SaveOptions.DisableFormatting),
                    Type    = evidence.Definition.SystemName,
                    Consent = saved
                });
            }

            return(new ConsentIdentity(saved.Id));
        }
예제 #16
0
 public void AddConsent(ConsentPageViewModel notification)
 {
     Consents.Add(notification);
 }
예제 #17
0
 public void RemoveConsent(ConsentPageViewModel notification)
 {
     Consents.Remove(notification);
 }
예제 #18
0
 private IQueryable <ConsentEntity> ConsentsFor(long studyId, string subjectIdentifier)
 {
     return(Consents.Where(
                c => c.StudySubject.SubjectIdentifier == subjectIdentifier &&
                c.StudySubject.Study.Id == studyId));
 }
예제 #19
0
        public void RejectConsent(string consentId)
        {
            var consent = Consents.SingleOrDefault(c => c.Id == consentId);

            Consents.Remove(consent);
        }