コード例 #1
0
        public void GetOpenQueries()
        {
            //Arrange
            var dataStorage = new Mock<IDataStorage>();
            var clinic = new Clinic {Caption = "Clinic1"};
            var doctor1 = new User {FirstName = "DoctorFirst1", LastName = "DoctorLast1", Clinic = clinic};
            var doctor2 = new User {FirstName = "DoctorFirst2", LastName = "DoctorLast2", Clinic = clinic};
            var patient1 = new Patient {PatientNumber = 11, Doctor = doctor1};
            var patient2 = new Patient {PatientNumber = 12, Doctor = doctor2};
            var visit1 = new Visit {Caption = "Visit1", Patient = patient1};
            var visit2 = new Visit {Caption = "Visit2", Patient = patient2};
            var form1 = new Form {FormType = FormType.Happiness, Visit = visit1};
            var form2 = new Form {FormType = FormType.Demographics, Visit = visit2};
            var question1 = new Question {Form = form1};
            var question2 = new Question {Form = form2};
            var query1 = new Query {Id = 1, QueryText = "Text1", Question = question1};
            var query2 = new Query {Id = 2, QueryText = "Text2", AnswerText = "Answer1", Question = question2};

            var repository = new QueryRepository(dataStorage.Object);
            dataStorage.Setup(ds => ds.GetData<Query>()).Returns(new List<Query> {query1, query2});

            //Act
            var result = repository.GetOpenQueries();

            //Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Count(), Is.EqualTo(1));
            var query = result.ToList()[0];
            Assert.That(query.FormType, Is.EqualTo(FormType.Happiness));
            Assert.That(query.ClinicName, Is.EqualTo("Clinic1"));
            Assert.That(query.DoctorName, Is.EqualTo("DoctorLast1"));
            Assert.That(query.QuestionText, Is.EqualTo("Text1"));
            Assert.That(query.PatientNumber, Is.EqualTo(11));
            Assert.That(query.VisitName, Is.EqualTo("Visit1"));
        }
コード例 #2
0
        public List<Query> BuildQueries(User doctor, User supervisor)
        {
            var list = new List<Query>();

            int firstPatientNumber = doctor.Patients.First().PatientNumber;

            var query = new Query {
                Id = queryId++,
                QueryText = "Please use Country Name, not Code",
                QueryAuthor = supervisor,
                QueryTime = DateTime.Now.AddDays(-1),
                AnswerAuthor = doctor,
                AnswerText = "Corrected from “CAR” to “Central African Republic”",
                AnswerTime = DateTime.Now.AddDays(-0.75)
            };
            AssociateQueryWithQuestion(query, firstPatientNumber, VisitType.Baseline, FormType.Demographics,
                                       (formId) => DemographicFormDatas.Find(d => d.Form.Id == formId).Other);

            list.Add(query);

            query = new Query {
                Id = queryId++,
                QueryText = "Please specify the reason for high temperature",
                QueryAuthor = supervisor,
                QueryTime = DateTime.Now.AddDays(-1),
                AnswerAuthor = doctor,
                AnswerText = "Patient had flu-like symptoms occurr a day before the visit",
                AnswerTime = DateTime.Now.AddDays(-0.75)
            };
            AssociateQueryWithQuestion(query, firstPatientNumber, VisitType.Day1, FormType.Vitals,
                                       (formId) => VitalsFormDatas.Find(d => d.Form.Id == formId).Temperature);

            list.Add(query);

            query = new Query {
                Id = queryId++,
                QueryText = "Cardiogram image is not full",
                QueryAuthor = supervisor,
                QueryTime = DateTime.Now.AddDays(-1),
                AnswerAuthor = null,
                AnswerText = null,
                AnswerTime = null
            };
            AssociateQueryWithQuestion(query, firstPatientNumber, VisitType.Day1, FormType.Electrocardiogram,
                                       (formId) =>
                                       ElectrocardiogramFormDatas.Find(d => d.Form.Id == formId).ElectrocardiogramAttachment);

            list.Add(query);

            query = new Query {
                Id = queryId++,
                QueryText = "Was the measurement performed in regular conditions?",
                QueryAuthor = supervisor,
                QueryTime = DateTime.Now.AddDays(-1),
                AnswerAuthor = null,
                AnswerText = null,
                AnswerTime = null
            };
            AssociateQueryWithQuestion(query, firstPatientNumber, VisitType.Day10, FormType.Vitals,
                                       (formId) => VitalsFormDatas.Find(d => d.Form.Id == formId).HeartRate);

            list.Add(query);

            AddTemparatureQueries(list);
            AddHappinessChangeQueries(list);
            AddDemographicQueries(list);
            AddInventoryQueries(list);
            return list;
        }
コード例 #3
0
        private void AssociateQueryWithQuestion(Query query, int patientNumber, VisitType visitType, FormType formType,
		                                        Func<int, Question> questionFinder)
        {
            var patient = Patients.First(p => p.PatientNumber == patientNumber);
            var visit = patient.Visits.First(v => v.VisitType == visitType);
            var form = visit.Forms.First(f => f.FormType == formType);
            query.Question = questionFinder(form.Id);
        }
コード例 #4
0
        private void AddTemparatureQueries(List<Query> list)
        {
            Query query;
            foreach (var formData in VitalsFormDatas) {
                if (formData.Temperature.Value != null) {
                    double temperature = double.Parse(formData.Temperature.Value);
                    int dice = randomGenerator.Next(100);
                    if (temperature < 36.6 && dice < 90) {
                        query = new Query {
                            Id = queryId++,
                            QueryText = "Please specify the reason for reduced body temperature",
                            QueryAuthor = GetClinicSupervisor(formData.Form.Visit.Patient),
                            QueryTime = GetRandomQueryTime(formData),
                            AnswerAuthor = null,
                            AnswerText = null,
                            AnswerTime = null,
                            Question = formData.Temperature
                        };

                        dice = randomGenerator.Next(100);
                        if (dice > 60) {
                            query.AnswerAuthor = formData.Form.Visit.Patient.Doctor;
                            query.AnswerText = "It is the patient's regular body temperature";
                            query.AnswerTime = query.QueryTime.AddHours(randomGenerator.Next(5) + 1);
                        }
                        list.Add(query);
                    }
                    if (temperature > 36.6 && dice < 80) {
                        query = new Query {
                            Id = queryId++,
                            QueryText = "Please specify the reason for high body temperature",
                            QueryAuthor = GetClinicSupervisor(formData.Form.Visit.Patient),
                            QueryTime = GetRandomQueryTime(formData),
                            AnswerAuthor = null,
                            AnswerText = null,
                            AnswerTime = null,
                            Question = formData.Temperature
                        };

                        dice = randomGenerator.Next(100);
                        if (dice > 60) {
                            query.AnswerAuthor = formData.Form.Visit.Patient.Doctor;
                            query.AnswerText = "Patient had flu-like symptoms occurr a day before the visit";
                            query.AnswerTime = query.QueryTime.AddHours(randomGenerator.Next(5) + 1);
                        }
                        list.Add(query);
                    }
                }
            }
        }
コード例 #5
0
        private void AddInventoryQueries(List<Query> list)
        {
            Query query;
            int dice;
            foreach (var data in InventoryFormDatas.Where(d=> d.Form.FormStateValue == (int)FormState.Completed)) {
                dice = randomGenerator.Next(100);
                if (dice < 2) {
                    query = new Query {
                        Id = queryId++,
                        QueryText = "This Batch Number is registered as Unshipped, please check",
                        QueryAuthor = GetClinicSupervisor(data.Form.Visit.Patient),
                        QueryTime = GetRandomQueryTime(data),
                        AnswerAuthor = null,
                        AnswerText = null,
                        AnswerTime = null,
                        Question = data.BatchNumber
                    };

                    dice = randomGenerator.Next(100);
                    if (dice > 70) {
                        query.AnswerAuthor = data.Form.Visit.Patient.Doctor;
                        query.AnswerText = "Marked as Shipped";
                        query.AnswerTime = query.QueryTime.AddHours(randomGenerator.Next(5) + 1);
                    }
                    if (dice > 60) {
                        query.AnswerAuthor = data.Form.Visit.Patient.Doctor;
                        query.AnswerText = "Batch Number was corrected";
                        query.AnswerTime = query.QueryTime.AddHours(randomGenerator.Next(5) + 1);
                    }
                    list.Add(query);
                }
            }
        }
コード例 #6
0
        private void AddHappinessChangeQueries(List<Query> list)
        {
            Query query;
            var happinessFormPairs = from day1Happiness in HappinessFormDatas
                                     from day10Happiness in HappinessFormDatas
                                     where day1Happiness.Form.Visit.VisitTypeValue == (int) VisitType.Day1
                                           && day10Happiness.Form.Visit.VisitTypeValue == (int) VisitType.Day10
                                           && day1Happiness.Form.FormStateValue == (int)FormState.Completed
                                           && day10Happiness.Form.FormStateValue == (int)FormState.Completed
                                           && day1Happiness.Form.Visit.Patient.Id == day10Happiness.Form.Visit.Patient.Id
                                     select new {OriginalHappinessData = day1Happiness, ChangedHappinessData = day10Happiness};

            foreach (var happinessFormPair in happinessFormPairs) {
                int originalLevel;
                if(!int.TryParse(happinessFormPair.OriginalHappinessData.HappinessLevel.Value, out originalLevel))
                    continue;
                int changedLevel;
                if(!int.TryParse(happinessFormPair.ChangedHappinessData.HappinessLevel.Value, out changedLevel))
                    continue;

                if(changedLevel < originalLevel) {
                    query = new Query {
                        Id = queryId++,
                        QueryText = "Has patient explained this drop of happiness level?",
                        QueryAuthor = GetClinicSupervisor(happinessFormPair.ChangedHappinessData.Form.Visit.Patient),
                        QueryTime = GetRandomQueryTime(happinessFormPair.ChangedHappinessData),
                        AnswerAuthor = null,
                        AnswerText = null,
                        AnswerTime = null,
                        Question = happinessFormPair.ChangedHappinessData.HappinessLevel
                    };
                    list.Add(query);
                }

                if(originalLevel == 0) {
                    query = new Query {
                        Id = queryId++,
                        QueryText = "Has patient given the reason of so unhappy state?",
                        QueryAuthor = GetClinicSupervisor(happinessFormPair.OriginalHappinessData.Form.Visit.Patient),
                        QueryTime = GetRandomQueryTime(happinessFormPair.OriginalHappinessData),
                        AnswerAuthor = null,
                        AnswerText = null,
                        AnswerTime = null,
                        Question = happinessFormPair.OriginalHappinessData.HappinessLevel
                    };
                    list.Add(query);
                }
            }
        }
コード例 #7
0
        private void AddDemographicQueries(List<Query> list)
        {
            Query query;
            int dice;
            foreach (var data in DemographicFormDatas) {
                dice = randomGenerator.Next(100);
                if (data.Race.Value == ((int)Race.Other).ToString() && (dice < 80)) {
                    query = new Query {
                        Id = queryId++,
                        QueryText = "Please specify the Patient's Race in 'Other' field",
                        QueryAuthor = GetClinicSupervisor(data.Form.Visit.Patient),
                        QueryTime = GetRandomQueryTime(data),
                        AnswerAuthor = null,
                        AnswerText = null,
                        AnswerTime = null,
                        Question = data.Race
                    };

                    dice = randomGenerator.Next(100);
                    if (dice > 80) {
                        query.AnswerAuthor = data.Form.Visit.Patient.Doctor;
                        query.AnswerText = "We will contact patient to confirm race";
                        query.AnswerTime = query.QueryTime.AddHours(randomGenerator.Next(5) + 1);
                    }
                    list.Add(query);
                }
            }
        }
コード例 #8
0
            private void PrepareQueriesReportData()
            {
                supervisor1000 = new User {Id = 1000, FirstName = "First1000", LastName = "Last1000"};
                supervisor2000 = new User {Id = 2000, FirstName = "First2000", LastName = "Last2000"};

                doctor1 = new User {Id = 1, FirstName = "First1", LastName = "Last1"};
                doctor2 = new User {Id = 2, FirstName = "First2", LastName = "Last2"};
                doctor3 = new User {Id = 3, FirstName = "First3", LastName = "Last3"};

                form11 = new Form {Id = 11, Caption = "CRF11"};
                form12 = new Form {Id = 12, Caption = "CRF12"};
                form13 = new Form {Id = 13, Caption = "CRF13"};

                form21 = new Form {Id = 21, Caption = "CRF21"};
                form22 = new Form {Id = 22, Caption = "CRF22"};

                form31 = new Form {Id = 31, Caption = "CRF31"};
                form32 = new Form {Id = 32, Caption = "CRF32"};
                form33 = new Form {Id = 33, Caption = "CRF33"};
                form34 = new Form {Id = 34, Caption = "CRF34"};
                form35 = new Form {Id = 35, Caption = "CRF35"};

                question111 = new Question {Id = 111, Caption = "Question111", Form = form11};

                question121 = new Question {Id = 121, Caption = "Question121", Form = form12};
                question122 = new Question {Id = 122, Caption = "Question122", Form = form12};

                question211 = new Question {Id = 211, Caption = "Question211", Form = form21};
                question212 = new Question {Id = 212, Caption = "Question212", Form = form21};
                question213 = new Question {Id = 213, Caption = "Question213", Form = form21};

                question311 = new Question {Id = 311, Caption = "Question311", Form = form31};
                question321 = new Question {Id = 321, Caption = "Question321", Form = form32};
                question331 = new Question {Id = 331, Caption = "Question331", Form = form33};
                question341 = new Question {Id = 341, Caption = "Question341", Form = form34};
                question351 = new Question {Id = 351, Caption = "Question351", Form = form35};

                query1110 = new Query { Id = 1110, Question = question111, QueryAuthor = supervisor1000, QueryTime = DateTime.Today.AddDays(-1110), QueryText = "Query1110", AnswerAuthor = doctor1, AnswerText = "Reply1110", AnswerTime = DateTime.Today.AddDays(1110)};
                query1210 = new Query { Id = 1210, Question = question121, QueryAuthor = supervisor2000, QueryTime = DateTime.Today.AddDays(-1210), QueryText = "Query1210", AnswerAuthor = doctor1, AnswerText = "Reply1210", AnswerTime = DateTime.Today.AddDays(1210) };
                query1220 = new Query { Id = 1220, Question = question122, QueryAuthor = supervisor1000, QueryTime = DateTime.Today.AddDays(-1220), QueryText = "Query1220", AnswerAuthor = doctor1, AnswerText = "Reply1220", AnswerTime = DateTime.Today.AddDays(1220) };
                query2110 = new Query { Id = 2110, Question = question211, QueryAuthor = supervisor2000, QueryTime = DateTime.Today.AddDays(-2110), QueryText = "Query2110", AnswerAuthor = doctor2, AnswerText = "Reply2110", AnswerTime = DateTime.Today.AddDays(2110) };
                query2120 = new Query { Id = 2120, Question = question212, QueryAuthor = supervisor1000, QueryTime = DateTime.Today.AddDays(-2120), QueryText = "Query2120", AnswerAuthor = doctor2, AnswerText = "Reply2120", AnswerTime = DateTime.Today.AddDays(2120) };
                query2130 = new Query { Id = 2130, Question = question213, QueryAuthor = supervisor2000, QueryTime = DateTime.Today.AddDays(-2130), QueryText = "Query2130", AnswerAuthor = doctor2, AnswerText = "Reply2130", AnswerTime = DateTime.Today.AddDays(2130) };
                query3110 = new Query { Id = 3110, Question = question311, QueryAuthor = supervisor1000, QueryTime = DateTime.Today.AddDays(-3110), QueryText = "Query3110"};
                query3210 = new Query { Id = 3210, Question = question321, QueryAuthor = supervisor2000, QueryTime = DateTime.Today.AddDays(-3210), QueryText = "Query3210"};
                query3310 = new Query { Id = 3310, Question = question331, QueryAuthor = supervisor1000, QueryTime = DateTime.Today.AddDays(-3310), QueryText = "Query3310"};
                query3410 = new Query { Id = 3410, Question = question341, QueryAuthor = supervisor2000, QueryTime = DateTime.Today.AddDays(-3410), QueryText = "Query3410"};
                query3510 = new Query { Id = 3510, Question = question351, QueryAuthor = supervisor1000, QueryTime = DateTime.Today.AddDays(-3510), QueryText = "Query3510"};
            }
コード例 #9
0
            private void CheckQueryData(DataRow dataRow, Query query, bool wReply = true)
            {
                Assert.That(dataRow is QueriesReportDataSet.QueriesRow);
                var row = dataRow as QueriesReportDataSet.QueriesRow;
                Assert.That(row, Is.Not.Null);
                Assert.That(row.QueryId, Is.EqualTo(query.Id));
                Assert.That(row.CRF, Is.EqualTo(query.Question.Form.Caption));
                Assert.That(row.Question, Is.EqualTo(query.Question.Caption));
                Assert.That(row.QueryAuthor, Is.EqualTo(String.Format("{0} {1}", query.QueryAuthor.FirstName, query.QueryAuthor.LastName)));
                Assert.That(row.QueryTime, Is.EqualTo(query.QueryTime.ToString("MM/dd/yyyy HH:mm")));
                Assert.That(row.QueryText, Is.EqualTo(query.QueryText));

                if (wReply) {
                    Assert.That(row.ReplyAuthor, Is.EqualTo(String.Format("{0} {1}", query.AnswerAuthor.FirstName, query.AnswerAuthor.LastName)));
                    Assert.That(row.ReplyTime, Is.EqualTo(query.AnswerTime.Value.ToString("MM/dd/yyyy HH:mm")));
                    Assert.That(row.ReplyText, Is.EqualTo(query.AnswerText));
                }
                else {
                    Assert.That(String.IsNullOrEmpty(row.ReplyAuthor), Is.True);
                    Assert.That(row.ReplyTime, Is.EqualTo(String.Empty));
                    Assert.That(String.IsNullOrEmpty(row.ReplyText), Is.True);
                }
            }
コード例 #10
0
        public void MappingTest()
        {
            //Arrange
            var dataStorage = new Mock<IDataStorage>();
            var entity = new Query {
                Id = 1,
                AnswerAuthor = new User {Id = 11},
                AnswerText = "oldAnswer",
                QueryAuthor = new User {Id = 12},
                QueryText = "oldQuestion"
            };
            var updatedEntity = new Query {
                Id = 1,
                AnswerAuthor = new User {Id = 21},
                AnswerText = "newAnswer",
                QueryAuthor = new User {Id = 22},
                QueryText = "newQuestion"
            };
            var repository = new QueryRepository(dataStorage.Object);

            dataStorage.Setup(ds => ds.GetData<Query>()).Returns(new List<Query> {entity});
            //Act
            repository.Edit(updatedEntity);
            //Assert
            //Values are equal
            Assert.That(entity.AnswerAuthor, Is.EqualTo(updatedEntity.AnswerAuthor));
            Assert.That(entity.AnswerText, Is.EqualTo(updatedEntity.AnswerText));

            Assert.That(entity.QueryAuthor, Is.EqualTo(updatedEntity.QueryAuthor));
            Assert.That(entity.QueryText, Is.EqualTo(updatedEntity.QueryText));
        }
コード例 #11
0
            public void CorrectModelMapping()
            {
                //Arrange
                var dataStorage = new Mock<IDataStorage>();
                var repository = new QueryRepository(dataStorage.Object);

                var clinic = new Clinic {Caption = "Clinic"};
                var doctor = new User {FirstName = "DoctorFirst", LastName = "DoctorLast", Clinic = clinic};
                var patient = new Patient {Doctor = doctor};
                var visit = new Visit {Caption = "Visit", Patient = patient};
                var form1 = new Form {FormType = FormType.Happiness, Visit = visit};
                var question1 = new Question {Caption = "QuestionCaption1", Form = form1};
                var query1 = new Query {Id = 1, Question = question1};

                var form2 = new Form {FormType = FormType.Inventory, Visit = visit};
                var question2 = new Question {Caption = "QuestionCaption2", Form = form2};
                var query2 = new Query {Id = 2, Question = question2, AnswerText = "Answer"};

                dataStorage.Setup(ds => ds.GetData<Query>()).Returns(new List<Query> {query1, query2});

                //Act
                var result = repository.GetQueriesReportData();

                //Assert
                Assert.That(result, Is.Not.Null);
                Assert.That(result.Count(), Is.EqualTo(2));
                var dto = result.ToList()[0];
                Assert.That(dto.FormType, Is.EqualTo(FormType.Happiness));
                Assert.That(dto.ClinicName, Is.EqualTo("Clinic"));
                Assert.That(dto.DoctorName, Is.EqualTo("DoctorFirst DoctorLast"));
                Assert.That(dto.QuestionName, Is.EqualTo("QuestionCaption1"));
                Assert.That(dto.IsOpen, Is.True);

                dto = result.ToList()[1];
                Assert.That(dto.FormType, Is.EqualTo(FormType.Inventory));
                Assert.That(dto.ClinicName, Is.EqualTo("Clinic"));
                Assert.That(dto.DoctorName, Is.EqualTo("DoctorFirst DoctorLast"));
                Assert.That(dto.QuestionName, Is.EqualTo("QuestionCaption2"));
                Assert.That(dto.IsOpen, Is.False);
            }
コード例 #12
0
 private static Query GetStandardQuery(int queryId)
 {
     var query = new Query {
         Id = queryId,
         QueryText = "text",
         QueryAuthor = new User() {
             Role = ClinicalStudyRoles.Supervisor,
             LastName = "Smith",
             Photo = new byte[]{1,2,3},
         },
         AnswerText = "Big and accurate answer",
         AnswerAuthor = new User() {
             Role = ClinicalStudyRoles.Doctor,
             LastName = "Johnson",
             Photo = new byte[]{11,12,13}
         },
         Question = new Question {
             Id = 11,
             Caption = "Temperature",
             Form = new Form() {
                 Caption = "Demographics",
                 Visit = new Visit {
                     Caption = "Baseline",
                     Patient = new Patient {
                         Caption = "Subj A025",
                         PatientNumber = 25,
                         Doctor = new User { Login = CommonEmulatedUserName }
                     }
                 }
             }
         }
     };
     return query;
 }