Exemple #1
0
        public EntityBase GetStudyById(string studyid)
        {
            StudyEntity study = null;

            using (var session = _driver.Session())
            {
                session.WriteTransaction(tx =>
                {
                    var result = tx.Run("MATCH (s:Study) " +
                                        "WHERE s.studyid = $studyid " +
                                        "RETURN s", new { studyid });

                    foreach (var record in result)
                    {
                        //Get as an INode instance to access properties.
                        var node = record["s"].As <Neo4j.Driver.V1.INode>();

                        study = new StudyEntity
                        {
                            StudyId     = node["studyid"].As <string>(),
                            Name        = node["name"].As <string>(),
                            Description = node["description"].As <string>(),
                            Id          = node.Id.As <int>()
                        };
                    }
                });
            }

            return(study);
        }
Exemple #2
0
        public List <EntityBase> GetStudiesByProjectId(string projectid)
        {
            List <EntityBase> studies = new List <EntityBase>();

            using (var session = _driver.Session())
            {
                session.WriteTransaction(tx =>
                {
                    var result = tx.Run("MATCH (p:Project {projectid: {projectid}})-[c:CONTAINS]-(s:Study)" +
                                        "RETURN s", new { projectid });


                    foreach (var record in result)
                    {
                        //Get as an INode instance to access properties.
                        var node          = record["s"].As <Neo4j.Driver.V1.INode>();
                        StudyEntity study = new StudyEntity
                        {
                            StudyId     = node["studyid"].As <string>(),
                            Name        = node["name"].As <string>(),
                            Description = node["description"].As <string>(),
                            Id          = node.Id.As <int>()
                        };
                        studies.Add(study);
                    }
                });
            }

            return(studies);
        }
        public void FindsAConsentedPersonWhenConsentIsRequired()
        {
            var personOneAgain = createContext.Find <PersonEntity>(personOne.Id);
            var study          = new StudyEntity {
                Name = Random.String()
            };
            var subject = new StudySubjectEntity
            {
                Person = personOneAgain, Study = study, SubjectIdentifier = Random.String()
            };
            var consent = new ConsentEntity
            {
                DateProvided = DateTime.Today, GivenBy = personOneAgain, StudySubject = subject
            };

            createContext.AddRange(study, subject, consent);
            createContext.SaveChanges();

            repository.FindPersonBy(
                new PersonIdentifierSpecification(Identifiers.NhsNumber(personOneNhsNumber))
                )?.Id.Should().Be(personOne.Id);

            repository.FindPersonBy(
                new CompositePersonSpecification(
                    new PersonIdentifierSpecification(Identifiers.NhsNumber(personOneNhsNumber)),
                    new ConsentedPersonSpecification(new StudyIdentity(study.Id))
                    )
                ).Should().Be((PersonIdentity)personOne.Id);
        }
        public void UpdateStudy()
        {
            string      studyid = CreateStudy();
            StudyEntity study   = (StudyEntity)GetStudyById(studyid);

            study.Description = study.Description + " - Updated";
            study.Name        = study.Name + " - Updated";
            _neo4jRepo.UpdateStudy(study);
        }
Exemple #5
0
        static void Main(string[] args)
        {
            //C#操作任何类型的内存

            //1.托管类型
            var instance = new StudyEntity();

            //2.栈内存(stack memory )
            unsafe
            {
                var stackMemory = stackalloc byte[100];
            }

            //3.本机内存(native memory )
            IntPtr nativeMemory0 = default(IntPtr), nativeMemory1 = default(IntPtr);

            try
            {
                unsafe
                {
                    nativeMemory0 = Marshal.AllocHGlobal(256);
                    nativeMemory1 = Marshal.AllocCoTaskMem(256);
                }
            }
            finally
            {
                Marshal.FreeHGlobal(nativeMemory0);
                Marshal.FreeCoTaskMem(nativeMemory1);
            }



            Console.WriteLine("Happy New Year!");

            Console.ReadKey(true);
        }
 public void Update(StudyEntity study)
 {
     _studies.RemoveAll(dto => dto.Id == study.Id);
     _studies.Add(study);
 }
 public void Create(StudyEntity study)
 {
     _studies.Add(study);
 }
Exemple #8
0
        /// <inheritdoc />
        public ConsentRepositoryTests(ITestOutputHelper outputHelper, DatabaseFixture fixture) : base(outputHelper, fixture)
        {
            readContext   = CreateNewContextInSameTransaction();
            updateContext = CreateNewContextInSameTransaction();
            createContext = CreateNewContextInSameTransaction();


            study = createContext.Studies.Add(new StudyEntity {
                Name = Random.String()
            }).Entity;

            var consentedPerson = createContext.People.Add(new PersonEntity()).Entity;

            consentedStudySubject = createContext.Add(new StudySubjectEntity {
                Study = study, Person = consentedPerson, SubjectIdentifier = "Consented"
            }).Entity;
            createContext.Add(
                new ConsentEntity
            {
                StudySubject  = consentedStudySubject,
                DateProvided  = 1.December(1965),
                DateWithdrawn = 1.January(1966),
                GivenBy       = consentedPerson
            });

            activeConsent = createContext.Add(
                new ConsentEntity
            {
                StudySubject = consentedStudySubject,
                DateProvided = 1.February(1966),
                GivenBy      = consentedPerson
            }).Entity;

            var unconsentedPerson = createContext.People.Add(new PersonEntity()).Entity;

            createContext.Add(
                new StudySubjectEntity {
                Study = study, Person = unconsentedPerson, SubjectIdentifier = "Unconsented"
            });

            var withdrawnConsent = createContext.Add(new PersonEntity()).Entity;
            var withdrawnSubject = createContext.Add(
                new StudySubjectEntity {
                Study = study, Person = withdrawnConsent, SubjectIdentifier = "Withdrawn"
            }).Entity;

            withdrawnSubjectWithdrawnDate = 5.January(2018);
            createContext.Add(new ConsentEntity
            {
                StudySubject  = withdrawnSubject,
                DateProvided  = 1.December(2017),
                DateWithdrawn = withdrawnSubjectWithdrawnDate,
                GivenBy       = withdrawnConsent
            });


            createContext.SaveChanges();

            studyId             = new StudyIdentity(study.Id);
            consentedPersonId   = consentedPerson;
            unconsentedPersonId = unconsentedPerson;
            withdrawnPersonId   = withdrawnConsent;

            consents = CreateConsentRepository(readContext);

            studySubjects = CreateStudySubjectRepository(readContext);
            studies       = CreateStudyRepository(readContext);
        }