Esempio n. 1
0
        private static void LoadDomains(XmlElement root, ref ProInstrument pro)
        {
            foreach (XmlElement d in root.GetElementsByTagName("Domain"))
            {
                ProDomain dom = new ProDomain();
                dom.Name         = GetNodeValue(d, "Name");
                dom.Description  = GetNodeValue(d, "Description");
                dom.ScoreFormula = GetNodeValue(d, "ScoreFormula");
                dom.ScoringNote  = GetNodeValue(d, "ScoringNote");
                if (GetNodeValue(d, "BestScore") == "Highest")
                {
                    dom.HigherIsBetter = true;
                }
                else
                {
                    dom.HigherIsBetter = false;
                }
                switch (GetNodeValue(d, "Audience"))
                {
                case "Patient":
                    dom.Audience = UserTypes.Patient;
                    break;

                case "Patient,Physician":
                    dom.Audience = UserTypes.Patient | UserTypes.Physician;
                    break;

                case "Patient,Researcher":
                    dom.Audience = UserTypes.Patient | UserTypes.Researcher;
                    break;

                case "Patient,Physician,Researcher":
                    dom.Audience = UserTypes.Patient | UserTypes.Physician | UserTypes.Researcher;
                    break;

                case "Physician":
                    dom.Audience = UserTypes.Physician;
                    break;

                case "Physician,Researcher":
                    dom.Audience = UserTypes.Physician | UserTypes.Researcher;
                    break;

                case "Researcher":
                    dom.Audience = UserTypes.Researcher;
                    break;

                default:
                    break;
                }
                ProDomainResultRange result = new ProDomainResultRange();
                result.Start   = double.Parse(GetNodeValue(d, "Start"));
                result.End     = double.Parse(GetNodeValue(d, "End"));
                result.Meaning = GetNodeValue(d, "Meaning");
                dom.ResultRanges.Add(result);

                pro.Domains.Add(dom);
            }
        }
Esempio n. 2
0
 private static void LoadTags(XmlElement root, ref ProInstrument pro)
 {
     foreach (XmlElement t in root.GetElementsByTagName("Tag"))
     {
         Tag tag = new Tag();
         tag.TagName = GetNodeValue(t, "Name");
         tag.Value   = GetNodeValue(t, "Value");
         pro.Tags.Add(tag);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Gets the Last created Full Pro Instrument with the given name
 /// The data can be found in the Questionnaire Variable
 /// </summary>
 /// <param name="name">The name of the ProInstrument to retrieve</param>
 /// <returns>The ProInstrument found or null</returns>
 public OperationResultAsUserQuestionnaire GetFullProInstrumentByName(string name)
 {
     try
     {
         ProInstrument instrument = this.handler.QuestionnaireManager.GetFullProInstrumentByName(name);
         return(new OperationResultAsUserQuestionnaire(null, instrument, null, null));
     }
     catch (Exception ex)
     {
         return(new OperationResultAsUserQuestionnaire(ex, null, null, null));
     }
 }
Esempio n. 4
0
        public static ProInstrument Load(XmlElement root)
        {
            pro = new ProInstrument();

            LoadProProperties(root, ref pro);
            LoadSections(root, ref pro);
            LoadDomains(root, ref pro);
            LoadTags(root, ref pro);
            LoadIntroductionMessage(root, ref pro);

            return(pro);
        }
Esempio n. 5
0
        private static void LoadSections(XmlElement root, ref ProInstrument pro)
        {
            foreach (XmlElement s in root.GetElementsByTagName("Section"))
            {
                QuestionnaireSection sec = new QuestionnaireSection();
                sec.ActionId = GetNodeValue(s, "ActionId");

                LoadSectionElements(s, ref sec);
                LoadSectionInstructions(s, ref sec);

                pro.Sections.Add(sec);
            }
        }
        /// <summary>
        /// Gets the full questionniare. Only the Id or the name has to be provided
        /// </summary>
        /// <param name="id">The Id of the questionnaire. If null or empty is not used</param>
        /// <param name="name">The name of the questionniare. If null or empty is not used</param>
        /// <returns>The questionniare requested</returns>
        private Questionnaire GetFullQuestionnaire(int?id = null, string name = null)
        {
            Questionnaire result = this.QuestionnaireQuery(id, name).SingleOrDefault();

            if (result == null)
            {
                return(null);
            }

            if (result.GetType() == typeof(ProInstrument))
            {
                ProInstrument ins = (ProInstrument)result;
                ins.Domains = this.context.ProDomains.Where(d => d.Instrument.Id == result.Id).Include(d => d.ResultRanges).ToList();
            }

            result.Tags = this.context.QuestionnaireTags.Where(q => q.QuestionnaireName == result.Name).Select(q => q.Tag).ToList();

            result.Sections = result.Sections.OrderBy(p => p.OrderInInstrument).ToList();
            foreach (QuestionnaireSection section in result.Sections)
            {
                section.Instructions.Count();
                section.Elements = section.Elements.OrderBy(e => e.OrderInSection).ToList();
                foreach (QuestionnaireElement el in section.Elements)
                {
                    if (el.GetType() == typeof(QuestionnaireItem))
                    {
                        QuestionnaireItem item = (QuestionnaireItem)el;
                        item.OptionGroups = item.OptionGroups.OrderBy(o => o.OrderInItem).ToList();
                        item.OptionGroups = this.context.QuestionnaireItemOptionGroups.Where(og => og.Item.Id == item.Id).Include(og => og.Options).ToList();
                        foreach (QuestionnaireItemOptionGroup g in item.OptionGroups)
                        {
                            g.TextVersions = this.context.QuestionnaireItemOptionGroupTextVersions.Where(tv => tv.QuestionnaireItemOptionGroup.Id == g.Id).ToList();
                            g.Options      = g.Options.OrderBy(o => o.OrderInGroup).ToList();
                        }

                        item.Instructions = this.context.QuestionnaireItemInstructions.Where(i => i.Item.Id == item.Id).ToList();
                    }
                }
            }

            return(result);
        }
        /// <summary>
        /// Returns all Questionnaire Responses for a given Patient and Questionnaire for all times this Questionnaire was answered by this User
        /// </summary>
        /// <param name="patientId">The Id of the Patient to get the response for</param>
        /// <param name="questionnaireName">The name of the questionnaire you want to get the response for</param>
        /// <param name="questionnaireId">The optional Id of the questionnaire to filter on</param>
        /// <param name="episodeId">The optional Id of the episode to filter on</param>
        /// <param name="onlyCompleted">If true, only completed questionnaire responses are loaded.</param>
        /// <param name="audience">The list of user types to filter on that the domains must disclose to before they are loaded.</param>
        /// <typeparam name="T">The type of questionaire to look for. If <see cref="Questionnaire"/> is specified no filtering is applied.</typeparam>
        /// <returns>A Dictionary of Questionnaire Responses grouped by Episode and Questionnaire</returns>
        public Dictionary <Episode, Dictionary <string, List <QuestionnaireUserResponseGroup> > > GetAllQuestionnaireResponsesForPatient <T>(string patientId = null, string questionnaireName = null, int?questionnaireId = null, int?episodeId = null, bool onlyCompleted = true, params UserTypes[] audience) where T : Questionnaire
        {
            var query = this.context.QuestionnaireUserResponseGroups.Where(q => q.Id != null);

            if (!string.IsNullOrWhiteSpace(patientId))
            {
                query = query.Where(q => q.Patient.Id == patientId);
            }

            if (!string.IsNullOrWhiteSpace(questionnaireName))
            {
                query = query.Where(q => q.Questionnaire.Name == questionnaireName);
            }

            if (questionnaireId.HasValue && questionnaireId.Value > 0)
            {
                query = query.Where(q => q.Questionnaire.Name == this.context.Questionnaires.Where(qq => qq.Id == questionnaireId).Select(qq => qq.Name).FirstOrDefault());
            }

            if (episodeId.HasValue && episodeId.Value > 0)
            {
                query = query.Where(q => q.ScheduledQuestionnaireDate.AssignedQuestionnaire.Episode.Id == episodeId.Value);
            }

            if (typeof(T) != typeof(Questionnaire))
            {
                var subQuery = this.context.Questionnaires.OfType <T>();
                if (questionnaireName != null)
                {
                    subQuery = subQuery.Where(q => q.Name == questionnaireName);
                }

                var subQueryIds = subQuery.Select(q => q.Id);
                query = query.Where(q => subQueryIds.Contains(q.Questionnaire.Id));
            }

            query = query.Include(q => q.Questionnaire).Include(q => q.Responses.Select(r => r.Item)).Include(q => q.Responses.Select(r => r.Option)).Include(g => g.Patient).Include(g => g.ScheduledQuestionnaireDate.AssignedQuestionnaire.Episode.MileStones);

            if (onlyCompleted)
            {
                query = query.Where(q => q.Status == QuestionnaireUserResponseGroupStatus.Completed);
            }

            List <QuestionnaireUserResponseGroup> groups;

            groups = query.ToList();

            foreach (QuestionnaireUserResponseGroup g in groups)
            {
                if (g.Questionnaire.GetType() == typeof(ProInstrument))
                {
                    ProInstrument p           = (ProInstrument)g.Questionnaire;
                    var           domainQuery = this.context.ProDomains.Where(d => d.Instrument.Name == p.Name && d.Instrument.Id == this.context.Questionnaires.Where(q => q.Name == p.Name).OrderByDescending(q => q.Id).Select(q => q.Id).FirstOrDefault());
                    foreach (UserTypes t in audience)
                    {
                        domainQuery = domainQuery.Where(q => (q.Audience & t) == t);
                    }

                    p.Domains       = domainQuery.Include(d => d.ResultRanges).Include(d => d.Instrument).ToList();
                    g.Questionnaire = p;
                }

                foreach (QuestionnaireResponse r in g.Responses)
                {
                    r.Option = this.context.QuestionnaireItemOptions.Where(o => o.Id == r.Option.Id).Include(o => o.Group).SingleOrDefault();
                }
            }

            Dictionary <Episode, Dictionary <string, List <QuestionnaireUserResponseGroup> > > result = new Dictionary <Episode, Dictionary <string, List <QuestionnaireUserResponseGroup> > >();

            result = groups.Where(g => g.ScheduledQuestionnaireDate != null).GroupBy(g => g.ScheduledQuestionnaireDate.AssignedQuestionnaire.Episode).ToDictionary(g => g.Key, g => g.GroupBy(g2 => g2.Questionnaire.Name).ToDictionary(g2 => g2.Key, g2 => g2.ToList()));
            result.Add(new Episode(), groups.Where(g => g.ScheduledQuestionnaireDate == null).GroupBy(g => g.Questionnaire.Name).ToDictionary(g => g.Key, g => g.ToList()));

            return(result);
        }
        /// <summary>
        /// Adds a full Pro Instrument to the database, including all related objects such as ProItem and ProOption
        /// </summary>
        /// <param name="questionnaire">The <see cref="Questionnaire"/> to add to the database</param>
        public void AddFullQuestionnaire(Questionnaire questionnaire)
        {
            if (this.context.QuestionnaireConcepts.Any(pc => pc.Id == questionnaire.Concept.Id || pc.Name.Equals(questionnaire.Concept.Name, StringComparison.CurrentCultureIgnoreCase)))
            {
                questionnaire.Concept = this.context.QuestionnaireConcepts.Where(pc => pc.Id == questionnaire.Concept.Id || pc.Name.Equals(questionnaire.Concept.Name, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
                this.context.Entry(questionnaire.Concept).State = System.Data.Entity.EntityState.Modified;
            }
            else
            {
                this.context.QuestionnaireConcepts.Add(questionnaire.Concept);
            }

            this.context.Questionnaires.Add(questionnaire);

            foreach (QuestionnaireIntroductionMessage m in questionnaire.IntroductionMessages)
            {
                m.Questionnaire = questionnaire;
                this.context.QuestionnaireIntroductionMessages.Add(m);
            }

            foreach (QuestionnaireDescription desc in questionnaire.Descriptions)
            {
                desc.Questionnaire = questionnaire;
                this.context.QuestionnaireDescriptions.Add(desc);
            }

            if (questionnaire.GetType() == typeof(ProInstrument))
            {
                ProInstrument inst = (ProInstrument)questionnaire;
                foreach (ProDomain dom in inst.Domains)
                {
                    dom.Instrument = questionnaire;
                    this.context.ProDomains.Add(dom);
                    foreach (ProDomainResultRange range in dom.ResultRanges)
                    {
                        range.Domain = dom;
                        this.context.ProDomainResultRanges.Add(range);
                    }
                }
            }

            int sectionOrderCount = 0;

            foreach (QuestionnaireSection sec in questionnaire.Sections)
            {
                sec.OrderInInstrument = sectionOrderCount++;
                int itemOrderCount = 0;
                sec.Questionnaire = questionnaire;
                this.context.QuestionnaireSections.Add(sec);
                foreach (QuestionnaireSectionInstruction instruction in sec.Instructions)
                {
                    instruction.Section = sec;
                    this.context.QuestionnaireSectionInstructions.Add(instruction);
                }

                foreach (QuestionnaireElement element in sec.Elements)
                {
                    element.OrderInSection = itemOrderCount++;
                    foreach (QuestionnaireElementTextVersion version in element.TextVersions)
                    {
                        version.QuestionnaireElement = element;
                        this.context.QuestionnaireElementTextVersions.Add(version);
                    }

                    if (element.GetType() == typeof(QuestionnaireText))
                    {
                        QuestionnaireText text = (QuestionnaireText)element;
                        text.Section = sec;
                        this.context.QuestionnaireElements.Add(text);
                    }
                    else if (element.GetType() == typeof(QuestionnaireItem))
                    {
                        QuestionnaireItem item = (QuestionnaireItem)element;
                        item.Section = sec;
                        this.context.QuestionnaireElements.Add(item);
                        foreach (QuestionnaireItemInstruction instruction in item.Instructions)
                        {
                            instruction.Item = item;
                            this.context.QuestionnaireItemInstructions.Add(instruction);
                        }

                        int groupOrderCount = 0;
                        foreach (QuestionnaireItemOptionGroup group in item.OptionGroups)
                        {
                            foreach (QuestionnaireItemOptionGroupTextVersion version in group.TextVersions)
                            {
                                version.QuestionnaireItemOptionGroup = group;
                                this.context.QuestionnaireItemOptionGroupTextVersions.Add(version);
                            }

                            group.OrderInItem = groupOrderCount++;
                            group.Item        = item;
                            this.context.QuestionnaireItemOptionGroups.Add(group);
                            int optionOrderCount = 0;
                            foreach (QuestionnaireItemOption o in group.Options)
                            {
                                o.OrderInGroup = optionOrderCount++;
                                o.Group        = group;
                                this.context.QuestionnaireItemOptions.Add(o);
                            }
                        }
                    }
                }
            }

            try
            {
                this.context.SaveChanges();

                foreach (Tag t in questionnaire.Tags)
                {
                    this.AddTagToQuestionnaireByName(t, questionnaire.Name);
                }
            }
            catch (DbEntityValidationException e)
            {
                string errorResult = string.Empty;
                foreach (var eve in e.EntityValidationErrors)
                {
                    errorResult += "Entity of type \" " + eve.Entry.Entity.GetType().Name + "\" in state \"" + eve.Entry.State + "\" has the following validation errors: \n";
                    foreach (var ve in eve.ValidationErrors)
                    {
                        errorResult += "- Property: \"" + ve.PropertyName + "\", Error: \"" + ve.ErrorMessage + "\" \n";
                    }
                }

                throw new DbEntityValidationException(errorResult, e);
            }
        }
Esempio n. 9
0
        public void AddFullProInstrumentTest()
        {
            ProInstrument pro = new ProInstrument();

            pro.Name     = "OES2";
            pro.Status   = QuestionnaireStatus.Indevelopment;
            pro.IsActive = true;

            pro.Tags.Add(new Tag()
            {
                TagName = "Gender", Value = "Male"
            });
            pro.Tags.Add(new Tag()
            {
                TagName = "Gender", Value = "Female"
            });

            {
                ProDomain d1 = new ProDomain();
                d1.Name         = "Total Domain";
                d1.Audience     = PCHI.Model.Users.UserTypes.Patient;
                d1.Description  = "Hello";
                d1.ScoreFormula = "{OES.1} + {OES.2}";
                {
                    ProDomainResultRange r1 = new ProDomainResultRange();
                    r1.Start   = 0;
                    r1.End     = 10;
                    r1.Meaning = "Great";
                    d1.ResultRanges.Add(r1);
                }
                {
                    ProDomainResultRange r2 = new ProDomainResultRange();
                    r2.Start   = 11;
                    r2.End     = 20;
                    r2.Meaning = "Oops";
                    d1.ResultRanges.Add(r2);
                }
                pro.Domains.Add(d1);
            }

            {
                ProDomain d2 = new ProDomain();
                d2.Name         = "Sleep Domain";
                d2.Audience     = PCHI.Model.Users.UserTypes.Patient;
                d2.Description  = "Hello";
                d2.ScoreFormula = "{OES.1} + {OES.2}";
                {
                    ProDomainResultRange r1 = new ProDomainResultRange();
                    r1.Start   = 0;
                    r1.End     = 10;
                    r1.Meaning = "Great";
                    d2.ResultRanges.Add(r1);
                }
                {
                    ProDomainResultRange r2 = new ProDomainResultRange();
                    r2.Start   = 11;
                    r2.End     = 20;
                    r2.Meaning = "Oops";
                    d2.ResultRanges.Add(r2);
                }
                pro.Domains.Add(d2);
            }

            pro.Concept = new QuestionnaireConcept()
            {
                Name = "Elbow", Description = "Tests Elbow Condition"
            };
            {
                QuestionnaireSection section = new QuestionnaireSection()
                {
                    OrderInInstrument = 1, Questionnaire = pro
                };
                pro.Sections.Add(section);
                AddTextToSection(section, "Intro1", @"", Platform.Classic | Platform.Chat, Instance.Baseline | Instance.Followup);
                AddTextToSection(section, "Intro2", @"Please make sure you answer all the questions that follow by ticking one option for every question.", Platform.Classic | Platform.Chat, Instance.Baseline | Instance.Followup);
            }

            {
                //Dictionary<int, string> options = null;
                //var options;// = new MyDictionary();

                QuestionnaireSection section = new QuestionnaireSection()
                {
                    OrderInInstrument = 2, Questionnaire = pro
                };
                pro.Sections.Add(section);
                {
                    // same options apply to items 1 to 4
                    MyDictionary options = new MyDictionary()
                    {
                        { 4, new ValuesOption()
                          {
                              Action = "", Text = "No difficulty"
                          } }, { 3, new ValuesOption()
                                 {
                                     Action = "", Text = "A little bit of difficulty"
                                 } }, { 2, new ValuesOption()
                                        {
                                            Action = "", Text = "Moderate difficulty"
                                        } }, { 1, new ValuesOption()
                                               {
                                                   Action = "", Text = "Extreme difficulty"
                                               } }, { 0, new ValuesOption()
                                                      {
                                                          Action = "", Text = "Impossible to do"
                                                      } }
                    };

                    QuestionnaireItem qi = AddItemToSection(section, "OES.1", "1.", @"<strong>During the past 4 weeks</strong>, have you had difficulty lifting things in your home, such as putting out the rubbish, <u>because of your elbow problem</u>?", Platform.Classic | Platform.Chat, Instance.Baseline | Instance.Followup);
                    AddOptionGroupToItem(qi, options, 0, QuestionnaireResponseType.List);

                    qi = AddItemToSection(section, "OES.2", "2.", @"<strong>During the past 4 weeks</strong>, have you had difficulty lifting things in your home, such as putting out the rubbish, <u>because of your elbow problem</u>?", Platform.Classic | Platform.Chat, Instance.Baseline | Instance.Followup);
                    AddOptionGroupToItem(qi, options, 0, QuestionnaireResponseType.List);

                    qi = AddItemToSection(section, "OES.3", "3.", @"<strong>During the past 4 weeks</strong>, have you had difficulty washing yourself all over, <u>because of your elbow problem</u>?", Platform.Classic | Platform.Chat, Instance.Baseline | Instance.Followup);
                    AddOptionGroupToItem(qi, options, 0, QuestionnaireResponseType.List);

                    qi = AddItemToSection(section, "OES.4", "4.", @"<strong>During the past 4 weeks</strong>, have you had difficulty dressing yourself, <u>because of your elbow problem</u>?", Platform.Classic | Platform.Chat, Instance.Baseline | Instance.Followup);
                    AddOptionGroupToItem(qi, options, 0, QuestionnaireResponseType.List);

                    qi      = AddItemToSection(section, "OES.5", "5.", @"How difficult is for you to get up and down off the floor/gound?", Platform.Classic | Platform.Chat, Instance.Baseline | Instance.Followup);
                    options = new MyDictionary()
                    {
                        { 0, new ValuesOption()
                          {
                              Action = "", Text = "Extreme difficulty"
                          } }, { 100, new ValuesOption()
                                 {
                                     Action = "", Text = "No difficulty at all"
                                 } }
                    };
                    AddOptionGroupToItem(qi, options, 10, QuestionnaireResponseType.Range);

                    qi      = AddItemToSection(section, "OES.6", "6.", @"How much trouble do you have with sexual activity because of your hip?", Platform.Classic | Platform.Chat, Instance.Baseline | Instance.Followup);
                    options = new MyDictionary()
                    {
                        { 0, new ValuesOption()
                          {
                              Action = "MakeItemNotApplicable", Text = "This is not relevant to me"
                          } }
                    };
                    AddOptionGroupToItem(qi, options, 0, QuestionnaireResponseType.ConditionalItem);
                    options = new MyDictionary()
                    {
                        { 0, new ValuesOption()
                          {
                              Action = "", Text = "Several trouble"
                          } }, { 100, new ValuesOption()
                                 {
                                     Action = "", Text = "No trouble at all"
                                 } }
                    };
                    AddOptionGroupToItem(qi, options, 10, QuestionnaireResponseType.Range);

                    qi      = AddItemToSection(section, "OES.7", "7.", @"How much trouble do you have pushing, pulling, lifting or carrying heavy objects at work?", Platform.Classic | Platform.Chat, Instance.Baseline | Instance.Followup);
                    options = new MyDictionary()
                    {
                        { 0, new ValuesOption()
                          {
                              Action = "MakeItemNotApplicable", Text = "I do not do these actions in my activities"
                          } }
                    };
                    AddOptionGroupToItem(qi, options, 0, QuestionnaireResponseType.ConditionalItem);
                    options = new MyDictionary()
                    {
                        { 0, new ValuesOption()
                          {
                              Action = "", Text = "Several trouble"
                          } }, { 100, new ValuesOption()
                                 {
                                     Action = "", Text = "No trouble at all"
                                 } }
                    };
                    AddOptionGroupToItem(qi, options, 10, QuestionnaireResponseType.Range);

                    qi      = AddItemToSection(section, "OES.8", "8.", @"How concern are you about cutting/changing directions during your sport or recreational activities?", Platform.Classic | Platform.Chat, Instance.Baseline | Instance.Followup);
                    options = new MyDictionary()
                    {
                        { 0, new ValuesOption()
                          {
                              Action = "MakeItemNotApplicable", Text = "I do not do this action in my activities"
                          } }
                    };
                    AddOptionGroupToItem(qi, options, 0, QuestionnaireResponseType.ConditionalItem);
                    options = new MyDictionary()
                    {
                        { 0, new ValuesOption()
                          {
                              Action = "", Text = "Extremly concerned"
                          } }, { 100, new ValuesOption()
                                 {
                                     Action = "", Text = "Not concerned at all"
                                 } }
                    };
                    AddOptionGroupToItem(qi, options, 10, QuestionnaireResponseType.Range);

                    qi      = AddItemToSection(section, "OES.9", "9.", @"Please indicate the sport or instrument which is most important to you:", Platform.Classic | Platform.Chat, Instance.Baseline | Instance.Followup);
                    options = new MyDictionary()
                    {
                        { 0, new ValuesOption()
                          {
                              Action = "", Text = ""
                          } }
                    };
                    AddOptionGroupToItem(qi, options, 0, QuestionnaireResponseType.Text);

                    qi = AddItemToSection(section, "OES.10", "10.", @"Enter your comments below:", Platform.Classic | Platform.Chat, Instance.Baseline | Instance.Followup);
                    AddOptionGroupToItem(qi, options, 0, QuestionnaireResponseType.Text);

                    //Part to add the definition for the body control
                    qi      = AddItemToSection(section, "OES.11", "11.", @"Select the parts of your body with some kind of mal functioning:", Platform.Classic | Platform.Chat, Instance.Baseline | Instance.Followup);
                    options = new MyDictionary()
                    {
                        { 0, new ValuesOption()
                          {
                              Action = "", Text = "Burning"
                          } }, { 1, new ValuesOption()
                                 {
                                     Action = "", Text = "Numbness"
                                 } }, { 2, new ValuesOption()
                                        {
                                            Action = "", Text = "Pins-Needles"
                                        } }, { 3, new ValuesOption()
                                               {
                                                   Action = "", Text = "Stabbing"
                                               } }, { 4, new ValuesOption()
                                                      {
                                                          Action = "", Text = "Ache"
                                                      } }
                    };
                    AddOptionGroupToItem(qi, options, 0, QuestionnaireResponseType.MultiSelect);

                    //Optiongroup for each body part

                    /*
                     * qiog1.OrderInItem = 1;
                     * {
                     *  qiog1.Options.Add(new QuestionnaireItemOption() { Text = "None", Value = 0, Group = qiog1 });
                     *  qiog1.Options.Add(new QuestionnaireItemOption() { Text = "Mild", Value = 1, Group = qiog1 });
                     *  qiog1.Options.Add(new QuestionnaireItemOption() { Text = "Moderate", Value = 2, Group = qiog1 });
                     *  qiog1.Options.Add(new QuestionnaireItemOption() { Text = "Severe", Value = 3, Group = qiog1 });
                     *  qiog1.Options.Add(new QuestionnaireItemOption() { Text = "Unbearable", Value = 4, Group = qiog1 });
                     *  qiog1.Item = q1;
                     * }
                     *
                     * q1.OptionGroups.Add(qiog1);
                     * section.Elements.Add(q1);
                     * q1.Section = section;
                     * */
                }
            }

            {
                QuestionnaireSection section = new QuestionnaireSection()
                {
                    OrderInInstrument = 3, Questionnaire = pro
                };
                pro.Sections.Add(section);
                AddTextToSection(section, "Footer1", @"Thank you for answering. You are done now and the results will be reported to your physician.", Platform.Classic, Instance.Baseline | Instance.Followup);
                AddTextToSection(section, "Footer1", @"Thank you for answering. You are done now and I will evaluate the results as soon as possible.", Platform.Chat, Instance.Baseline | Instance.Followup);
            }

            new AccessHandlerManager().QuestionnaireAccessHandler.AddFullQuestionnaire(pro);
        }
Esempio n. 10
0
        private static void LoadIntroductionMessage(XmlElement root, ref ProInstrument pro)
        {
            XmlElement elementIntroductionMessages = (XmlElement)root.GetElementsByTagName("IntroductionMessages")[0];

            foreach (XmlElement elementTextVersion in elementIntroductionMessages.GetElementsByTagName("TextVersion"))
            {
                QuestionnaireIntroductionMessage intro = new QuestionnaireIntroductionMessage();
                intro.Text = GetNodeValue(elementTextVersion, "Text");

                switch (GetNodeValue(elementTextVersion, "Audience"))
                {
                case "Patient":
                    intro.Audience = UserTypes.Patient;
                    break;

                case "Patient,Physician":
                    intro.Audience = UserTypes.Patient | UserTypes.Physician;
                    break;

                case "Patient,Researcher":
                    intro.Audience = UserTypes.Patient | UserTypes.Researcher;
                    break;

                case "Patient,Physician,Researcher":
                    intro.Audience = UserTypes.Patient | UserTypes.Physician | UserTypes.Researcher;
                    break;

                case "Physician":
                    intro.Audience = UserTypes.Physician;
                    break;

                case "Physician,Researcher":
                    intro.Audience = UserTypes.Physician | UserTypes.Researcher;
                    break;

                case "Researcher":
                    intro.Audience = UserTypes.Researcher;
                    break;

                default:
                    break;
                }
                switch (GetNodeValue(elementTextVersion, "SupportedInstances"))
                {
                case "Baseline":
                    intro.SetSupportedInstances(Instance.Baseline);
                    break;

                case "Baseline,FollowUp":
                    intro.SetSupportedInstances(Instance.Baseline | Instance.Followup);
                    break;

                case "FollowUp":
                    intro.SetSupportedInstances(Instance.Followup);
                    break;

                default:
                    break;
                }

                switch (GetNodeValue(elementTextVersion, "SupportedPlatforms"))
                {
                case "Chat":
                    intro.SetSupportedPlatforms(Platform.Chat);
                    break;

                case "Chat,Classic":
                    intro.SetSupportedPlatforms(Platform.Chat | Platform.Classic);
                    break;

                case "Chat,Mobile":
                    intro.SetSupportedPlatforms(Platform.Chat | Platform.Mobile);
                    break;

                case "Chat,Classic,Mobile":
                    intro.SetSupportedPlatforms(Platform.Chat | Platform.Classic | Platform.Mobile);
                    break;

                case "Classic":
                    intro.SetSupportedPlatforms(Platform.Classic);
                    break;

                case "Classic,Mobile":
                    intro.SetSupportedPlatforms(Platform.Classic | Platform.Mobile);
                    break;

                case "Mobile":
                    intro.SetSupportedPlatforms(Platform.Mobile);
                    break;

                default:
                    break;
                }
                pro.IntroductionMessages.Add(intro);
            }
        }
Esempio n. 11
0
        private static void LoadProProperties(XmlElement root, ref ProInstrument pro)
        {
            pro.Name              = GetNodeValue(root, "ShortName");
            pro.DisplayName       = GetNodeValue(root, "DisplayName");
            pro.DefaultFormatName = GetNodeValue(root, "DefaultFormatName");
            pro.Concept           = new QuestionnaireConcept();

            XmlElement con = (XmlElement)root.GetElementsByTagName("Concept")[0];

            pro.Concept.Name        = GetNodeValue(con, "Name");
            pro.Concept.Description = GetNodeValue(con, "Description");
            pro.IsActive            = true;

            XmlElement descon = (XmlElement)root.GetElementsByTagName("Descriptions")[0];

            foreach (XmlElement descriptionsTextVersion in descon.GetElementsByTagName("TextVersion"))
            {
                QuestionnaireDescription des = new QuestionnaireDescription();
                des.Text = GetNodeValue(descriptionsTextVersion, "Text");
                switch (GetNodeValue(descriptionsTextVersion, "Audience"))
                {
                case "Patient":
                    des.Audience = UserTypes.Patient;
                    break;

                case "Patient,Physician":
                    des.Audience = UserTypes.Patient | UserTypes.Physician;
                    break;

                case "Patient,Researcher":
                    des.Audience = UserTypes.Patient | UserTypes.Researcher;
                    break;

                case "Patient,Physician,Researcher":
                    des.Audience = UserTypes.Patient | UserTypes.Physician | UserTypes.Researcher;
                    break;

                case "Physician":
                    des.Audience = UserTypes.Physician;
                    break;

                case "Physician,Researcher":
                    des.Audience = UserTypes.Physician | UserTypes.Researcher;
                    break;

                case "Researcher":
                    des.Audience = UserTypes.Researcher;
                    break;

                default:
                    break;
                }
                switch (GetNodeValue(descriptionsTextVersion, "SupportedInstances"))
                {
                case "Baseline":
                    des.SetSupportedInstances(Instance.Baseline);
                    break;

                case "Baseline,FollowUp":
                    des.SetSupportedInstances(Instance.Baseline | Instance.Followup);
                    break;

                case "FollowUp":
                    des.SetSupportedInstances(Instance.Followup);
                    break;

                default:
                    break;
                }

                switch (GetNodeValue(descriptionsTextVersion, "SupportedPlatforms"))
                {
                case "Chat":
                    des.SetSupportedPlatforms(Platform.Chat);
                    break;

                case "Chat,Classic":
                    des.SetSupportedPlatforms(Platform.Chat | Platform.Classic);
                    break;

                case "Chat,Mobile":
                    des.SetSupportedPlatforms(Platform.Chat | Platform.Mobile);
                    break;

                case "Chat,Classic,Mobile":
                    des.SetSupportedPlatforms(Platform.Chat | Platform.Classic | Platform.Mobile);
                    break;

                case "Classic":
                    des.SetSupportedPlatforms(Platform.Classic);
                    break;

                case "Classic,Mobile":
                    des.SetSupportedPlatforms(Platform.Classic | Platform.Mobile);
                    break;

                case "Mobile":
                    des.SetSupportedPlatforms(Platform.Mobile);
                    break;

                default:
                    break;
                }
                pro.Descriptions.Add(des);
            }
        }