コード例 #1
0
        public void CorrectlyParsesFullConsent()
        {
            var consent = ParseConsent(
                @"<consent date-given=""2017-03-12"" study-id=""42"">
                    <givenBy>
                        <match><identifier type=""nhs-number"">8877881</identifier></match>
                        <match><identifier type=""bradford-hospital-number"">1122112</identifier></match>
                    </givenBy>
                    <evidence>
                        <evidence type=""medway"">
                            <evidence type=""competent-status"">Delegated</evidence>
                            <evidence type=""consent-given-by"">Mother</evidence>
                            <evidence type=""consent-taken-by"">Betsey Trotwood</evidence>
                        </evidence>
                    </evidence>
                </consent>",
                personIdentifierTypes: Identifiers.Registry,
                KnownEvidence.Registry
                );

            consent.GivenBy
            .Should()
            .BeEquivalentTo(
                new IdentifierMatchSpecification(Identifiers.Definitions.NhsNumber.Value("8877881")),
                new IdentifierMatchSpecification(Identifiers.Definitions.HospitalNumber.Value("1122112"))
                );


            Assert.Collection(
                consent.Evidence,
                e =>
            {
                e.Should().BeEquivalentTo(
                    Evidences.ClientMedwayDto("Delegated", "Mother", "Betsey Trotwood"),
                    o => o.RespectingRuntimeTypes()
                    );
            },
                e =>
            {
                e.Should().BeEquivalentTo(
                    KnownEvidence.ImportFile.ClientDto(
                        KnownEvidence.ImportFileParts.BaseUri.ClientDto(XmlImportFileBaseUri),
                        KnownEvidence.ImportFileParts.LineNumber.ClientDto(1),
                        KnownEvidence.ImportFileParts.LinePosition.ClientDto(2)
                        ),
                    o => o.RespectingRuntimeTypes()
                    );
            }
                );
        }
コード例 #2
0
        public void SavesConsent()
        {
            var consentContext = Server.Host.Services.GetService <ConsentContext>();

            var study = consentContext.Add(new StudyEntity {
                Name = Random.String()
            }).Entity;
            var person = consentContext.Add(new PersonEntity()).Entity;

            consentContext.SaveChanges();

            var result = ApiClient.PutConsent(
                new ConsentSpecification
            {
                StudyId           = study.Id,
                DateGiven         = Random.Date().Date,
                GivenBy           = person.Id,
                PersonId          = person.Id,
                SubjectIdentifier = Random.String(15),
                Evidence          = new []
                {
                    Evidences.ClientMedwayDto(status: "Competent", givenBy: "Self", takenBy: "Jackson Pollock"),
                }
            });

            Assert.NotNull(result);
            var newConsentId  = Assert.IsType <long>(result);
            var consentEntity = consentContext.Set <ConsentEntity>()
                                .Include(_ => _.StudySubject)
                                .ThenInclude(_ => _.Study)
                                .Include(_ => _.StudySubject)
                                .ThenInclude(_ => _.Person)
                                .Include(_ => _.GivenBy)
                                .Single(_ => _.Id == newConsentId);

            Assert.NotNull(consentEntity);

            var evidence = consentContext.Set <GivenEvidenceEntity>().SingleOrDefault(_ => _.Consent.Id == newConsentId);

            using (new AssertionScope())
            {
                evidence.Should().NotBeNull();
                evidence.Value.Should().Be(
                    "<medway><competent-status>Competent</competent-status><consent-given-by>Self</consent-given-by><consent-taken-by>Jackson Pollock</consent-taken-by></medway>");
                evidence.Type.Should().Be("medway");
            }
        }