예제 #1
0
    def get_task_html(self, req: CamcopsRequest) -> str:
        main_dict = {
            None: None,
            0: "0 — " + self.wxstring(req, "q1to3_option0"),
            1: "1 — " + self.wxstring(req, "q1to3_option1"),
            2: "2 — " + self.wxstring(req, "q1to3_option2"),
            3: "3 — " + self.wxstring(req, "q1to3_option3"),
            4: "4 — " + self.wxstring(req, "q1to3_option4"),
        }
        q4_dict = {
            None: None,
            0: "0 — " + self.wxstring(req, "q4_option0"),
            2: "2 — " + self.wxstring(req, "q4_option2"),
            4: "4 — " + self.wxstring(req, "q4_option4"),
        }
        q_a = tr_qa(self.wxstring(req, "q1"),
                    get_from_dict(main_dict, self.q1))
        q_a += tr_qa(self.wxstring(req, "q2"),
                     get_from_dict(main_dict, self.q2))
        q_a += tr_qa(self.wxstring(req, "q3"),
                     get_from_dict(main_dict, self.q3))
        q_a += tr_qa(self.wxstring(req, "q4"), get_from_dict(q4_dict, self.q4))

        tr_total_score = tr(
            req.sstring(SS.TOTAL_SCORE),
            answer(self.total_score()) + f" / {self.MAX_SCORE}",
        )
        tr_positive = tr_qa(
            self.wxstring(req, "positive") + " <sup>[1]</sup>",
            get_yes_no(req, self.is_positive()),
        )
        return f"""
예제 #2
0
    def get_task_html(self, req: CamcopsRequest) -> str:
        c_dict = {
            0: "0 — " + self.wxstring(req, "a0_choice"),
            1: "1 — " + self.wxstring(req, "a1_choice"),
            2: "2 — " + self.wxstring(req, "a2_choice"),
        }
        s_dict = {
            0: "0 — " + self.wxstring(req, "a0_satisfaction"),
            1: "1 — " + self.wxstring(req, "a1_satisfaction"),
            2: "2 — " + self.wxstring(req, "a2_satisfaction"),
            3: "3 — " + self.wxstring(req, "a3_satisfaction"),
            4: "4 — " + self.wxstring(req, "a4_satisfaction"),
        }
        q_a = ""
        for i in range(1, self.N_CHOICE_QUESTIONS + 1):
            nstr = str(i)
            q_a += tr_qa(
                self.wxstring(req, "q" + nstr + "_choice"),
                get_from_dict(c_dict, getattr(self, "q" + nstr + "_choice")),
            )

        q_a += tr_qa(
            self.wxstring(req, "q1_satisfaction"),
            get_from_dict(s_dict, self.q1_satisfaction),
        )
        q_a += tr_qa(
            self.wxstring(req, "q2_satisfaction"),
            self.q2_satisfaction,
            default="",
        )

        return f"""
예제 #3
0
    def get_task_html(self, req: CamcopsRequest) -> str:
        score = self.total_score()
        main_dict = {None: None}
        q10_dict = {None: None}
        for option in range(0, 5):
            main_dict[option] = (
                str(option)
                + " — "
                + self.wxstring(req, "main_option" + str(option))
            )
            q10_dict[option] = (
                str(option)
                + " — "
                + self.wxstring(req, "q10_option" + str(option))
            )

        q_a = ""
        for q in range(1, 10):
            q_a += tr_qa(
                self.wxstring(req, "q" + str(q) + "_s"),
                get_from_dict(main_dict, getattr(self, "q" + str(q))),
            )
        q_a += (
            tr_qa(
                self.wxstring(req, "q10_s"), get_from_dict(q10_dict, self.q10)
            )
            + tr_qa(
                self.wxstring(req, "q11_s"), get_yes_no_none(req, self.q11)
            )
            + tr_qa(
                self.wxstring(req, "q12_s"), get_yes_no_none(req, self.q12)
            )
        )

        return f"""
예제 #4
0
    def get_task_html(self, req: CamcopsRequest) -> str:
        score = self.total_score()
        exceeds_cutoff = score >= 8
        q1_dict = {None: None}
        q2_dict = {None: None}
        q3_to_8_dict = {None: None}
        q9_to_10_dict = {None: None}
        for option in range(0, 5):
            q1_dict[option] = (str(option) + " – " +
                               self.wxstring(req, "q1_option" + str(option)))
            q2_dict[option] = (str(option) + " – " +
                               self.wxstring(req, "q2_option" + str(option)))
            q3_to_8_dict[option] = (
                str(option) + " – " +
                self.wxstring(req, "q3to8_option" + str(option)))
            if option != 1 and option != 3:
                q9_to_10_dict[option] = (
                    str(option) + " – " +
                    self.wxstring(req, "q9to10_option" + str(option)))

        q_a = tr_qa(self.wxstring(req, "q1_s"),
                    get_from_dict(q1_dict, self.q1))
        q_a += tr_qa(self.wxstring(req, "q2_s"),
                     get_from_dict(q2_dict, self.q2))
        for q in range(3, 8 + 1):
            q_a += tr_qa(
                self.wxstring(req, "q" + str(q) + "_s"),
                get_from_dict(q3_to_8_dict, getattr(self, "q" + str(q))),
            )
        q_a += tr_qa(self.wxstring(req, "q9_s"),
                     get_from_dict(q9_to_10_dict, self.q9))
        q_a += tr_qa(self.wxstring(req, "q10_s"),
                     get_from_dict(q9_to_10_dict, self.q10))

        return f"""
예제 #5
0
    def get_task_html(self, req: CamcopsRequest) -> str:
        score = self.total_score()
        q1_dict = {None: None}
        q2_dict = {None: None}
        q3_dict = {None: None}
        for option in range(0, 5):
            q1_dict[option] = str(option) + " – " + \
                self.wxstring(req, "q1_option" + str(option))
            if option == 0:  # special!
                q2_dict[option] = str(option) + " – " + \
                    self.wxstring(req, "c_q2_option0")
            else:
                q2_dict[option] = str(option) + " – " + \
                    self.wxstring(req, "q2_option" + str(option))
            q3_dict[option] = str(option) + " – " + \
                self.wxstring(req, "q3to8_option" + str(option))

        # noinspection PyUnresolvedReferences
        h = """
            <div class="{CssClass.SUMMARY}">
                <table class="{CssClass.SUMMARY}">
                    {tr_is_complete}
                    {total_score}
                </table>
            </div>
            <table class="{CssClass.TASKDETAIL}">
                <tr>
                    <th width="50%">Question</th>
                    <th width="50%">Answer</th>
                </tr>
                {q1}
                {q2}
                {q3}
            </table>
            <div class="{CssClass.COPYRIGHT}">
                AUDIT: Copyright © World Health Organization.
                Reproduced here under the permissions granted for
                NON-COMMERCIAL use only. You must obtain permission from the
                copyright holder for any other use.

                AUDIT-C: presumed to have the same restrictions.
            </div>
        """.format(
            CssClass=CssClass,
            tr_is_complete=self.get_is_complete_tr(req),
            total_score=tr(req.wappstring("total_score"),
                           answer(score) + " / 12"),
            q1=tr_qa(self.wxstring(req, "c_q1_question"),
                     get_from_dict(q1_dict, self.q1)),
            q2=tr_qa(self.wxstring(req, "c_q2_question"),
                     get_from_dict(q2_dict, self.q2)),
            q3=tr_qa(self.wxstring(req, "c_q3_question"),
                     get_from_dict(q3_dict, self.q3)),
        )
        return h
예제 #6
0
파일: fast.py 프로젝트: tarun911/camcops
 def get_task_html(self, req: CamcopsRequest) -> str:
     main_dict = {
         None: None,
         0: "0 — " + self.wxstring(req, "q1to3_option0"),
         1: "1 — " + self.wxstring(req, "q1to3_option1"),
         2: "2 — " + self.wxstring(req, "q1to3_option2"),
         3: "3 — " + self.wxstring(req, "q1to3_option3"),
         4: "4 — " + self.wxstring(req, "q1to3_option4"),
     }
     q4_dict = {
         None: None,
         0: "0 — " + self.wxstring(req, "q4_option0"),
         2: "2 — " + self.wxstring(req, "q4_option2"),
         4: "4 — " + self.wxstring(req, "q4_option4"),
     }
     q_a = tr_qa(self.wxstring(req, "q1"),
                 get_from_dict(main_dict, self.q1))  # noqa
     q_a += tr_qa(self.wxstring(req, "q2"),
                  get_from_dict(main_dict, self.q2))  # noqa
     q_a += tr_qa(self.wxstring(req, "q3"),
                  get_from_dict(main_dict, self.q3))  # noqa
     q_a += tr_qa(self.wxstring(req, "q4"), get_from_dict(q4_dict, self.q4))
     h = """
         <div class="{CssClass.SUMMARY}">
             <table class="{CssClass.SUMMARY}">
                 {tr_is_complete}
                 {total_score}
                 {positive}
             </table>
         </div>
         <table class="{CssClass.TASKDETAIL}">
             <tr>
                 <th width="60%">Question</th>
                 <th width="40%">Answer</th>
             </tr>
             {q_a}
         </table>
         <div class="{CssClass.FOOTNOTES}">
             [1] Negative if Q1 = 0. Positive if Q1 ≥ 3. Otherwise positive
                 if total score ≥ 3.
         </div>
     """.format(
         CssClass=CssClass,
         tr_is_complete=self.get_is_complete_tr(req),
         total_score=tr(
             req.wappstring("total_score"),
             answer(self.total_score()) + " / {}".format(self.MAX_SCORE)),
         positive=tr_qa(
             self.wxstring(req, "positive") + " <sup>[1]</sup>",
             get_yes_no(req, self.is_positive())),
         q_a=q_a,
     )
     return h
예제 #7
0
    def get_task_html(self, req: CamcopsRequest) -> str:
        main_dict = {
            None: None,
            0: "0 — " + self.wxstring(req, "old_option0"),
            1: "1 — " + self.wxstring(req, "old_option1"),
            2: "2 — " + self.wxstring(req, "old_option2"),
            3: "3 — " + self.wxstring(req, "old_option3"),
            4: "4 — " + self.wxstring(req, "old_option4"),
            5: "5 — " + self.wxstring(req, "old_option5"),
            6: "6 — " + self.wxstring(req, "old_option6"),
            7: "7 — " + self.wxstring(req, "old_option7"),
        }
        q19_dict = {
            None: None,
            1: self.wxstring(req, "q19_option1"),
            2: self.wxstring(req, "q19_option2"),
            3: self.wxstring(req, "q19_option3"),
            4: self.wxstring(req, "q19_option4"),
            5: self.wxstring(req, "q19_option5"),
            6: self.wxstring(req, "q19_option6"),
            7: self.wxstring(req, "q19_option7"),
        }
        q20_dict = {
            None: None,
            0: self.wxstring(req, "q20_option0"),
            1: self.wxstring(req, "q20_option1"),
            2: self.wxstring(req, "q20_option2"),
            3: self.wxstring(req, "q20_option3"),
            4: self.wxstring(req, "q20_option4"),
            5: self.wxstring(req, "q20_option5"),
            6: self.wxstring(req, "q20_option6"),
            7: self.wxstring(req, "q20_option7"),
        }

        q_a = ""
        for i in range(1, Bprs.NQUESTIONS - 1):  # only does 1-18
            q_a += tr_qa(
                self.wxstring(req, "q" + str(i) + "_title"),
                get_from_dict(main_dict, getattr(self, "q" + str(i))),
            )
        q_a += tr_qa(self.wxstring(req, "q19_title"),
                     get_from_dict(q19_dict, self.q19))
        q_a += tr_qa(self.wxstring(req, "q20_title"),
                     get_from_dict(q20_dict, self.q20))

        total_score = tr(
            req.sstring(SS.TOTAL_SCORE) +
            f" (0–{self.MAX_SCORE}; 18–{self.MAX_SCORE} if all rated) "
            "<sup>[1]</sup>",
            answer(self.total_score()),
        )
        return f"""
예제 #8
0
 def get_question_rows(first, last):
     html = ""
     for q in range(first, last + 1):
         f = getattr(self, "frequency" + str(q))
         d = getattr(self, "distress" + str(q))
         fa = ("{}: {}".format(f, get_from_dict(freq_dict, f))
               if f is not None else None)
         da = ("{}: {}".format(d, get_from_dict(distress_dict, d))
               if d is not None else None)
         html += tr(
             self.wxstring(req, "q" + str(q)),
             answer(fa),
             answer(da),
         )
     return html
예제 #9
0
    def get_task_html(self, req: CamcopsRequest) -> str:
        def bprs_string(x: str) -> str:
            return req.wxstring("bprs", x)

        main_dict = {
            None: None,
            0: "0 — " + bprs_string("old_option0"),
            1: "1 — " + bprs_string("old_option1"),
            2: "2 — " + bprs_string("old_option2"),
            3: "3 — " + bprs_string("old_option3"),
            4: "4 — " + bprs_string("old_option4"),
            5: "5 — " + bprs_string("old_option5"),
            6: "6 — " + bprs_string("old_option6"),
            7: "7 — " + bprs_string("old_option7"),
        }

        q_a = ""
        for i in range(1, self.NQUESTIONS + 1):
            q_a += tr_qa(
                self.wxstring(req, "q" + str(i) + "_s"),
                get_from_dict(main_dict, getattr(self, "q" + str(i))),
            )

        total_score = tr(
            req.sstring(SS.TOTAL_SCORE) +
            f" (0–{self.MAX_SCORE}; 24–{self.MAX_SCORE} if all rated)",
            answer(self.total_score()),
        )
        return f"""
예제 #10
0
 def addqa(_fieldname: str, _valuedict: Dict[int, str]) -> None:
     xstringname = _fieldname + "_q"
     q_a_list.append(
         tr_qa(
             self.xstring(req, xstringname),  # not wxstring
             get_from_dict(_valuedict, getattr(self, _fieldname)),
         ))
예제 #11
0
 def get_task_html(self, req: CamcopsRequest) -> str:
     score = self.total_score()
     severity = self.severity(req)
     answer_dicts_dict = {}
     for q in self.SCORED_QUESTIONS:
         d = {None: None}
         for option in range(0, 8):
             if option > 4 and q == "q10":
                 continue
             d[option] = self.wxstring(req, q + "_option" + str(option))
         answer_dicts_dict[q] = d
     q_a = ""
     for q in range(1, Ciwa.NSCOREDQUESTIONS + 1):
         q_a += tr_qa(
             self.wxstring(req, "q" + str(q) + "_s"),
             get_from_dict(
                 answer_dicts_dict["q" + str(q)],
                 getattr(self, "q" + str(q)),
             ),
         )
     tr_total_score = tr(req.sstring(SS.TOTAL_SCORE),
                         answer(score) + f" / {self.MAX_SCORE}")
     tr_severity = tr_qa(
         self.wxstring(req, "severity") + " <sup>[1]</sup>", severity)
     return f"""
예제 #12
0
    def get_task_html(self, req: CamcopsRequest) -> str:
        score = self.total_score()
        severity = self.severity(req)
        answer_dict = {None: None}
        for option in range(0, 4):
            answer_dict[option] = (str(option) + " — " +
                                   self.wxstring(req, "a" + str(option)))

        q_a = ""
        for q in range(1, self.NQUESTIONS + 1):
            q_a += tr_qa(
                self.wxstring(req, "q" + str(q)),
                get_from_dict(answer_dict, getattr(self, "q" + str(q))),
            )

        return """
            <div class="{CssClass.SUMMARY}">
                <table class="{CssClass.SUMMARY}">
                    {tr_is_complete}
                    {total_score}
                    {anxiety_severity}
                </table>
            </div>
            <div class="{CssClass.EXPLANATION}">
                Ratings are over the last 2 weeks.
            </div>
            <table class="{CssClass.TASKDETAIL}">
                <tr>
                    <th width="50%">Question</th>
                    <th width="50%">Answer</th>
                </tr>
                {q_a}
            </table>
            <div class="{CssClass.FOOTNOTES}">
                [1] ≥15 severe, ≥10 moderate, ≥5 mild.
                Score ≥10 identifies: generalized anxiety disorder with
                sensitivity 89%, specificity 82% (Spitzer et al. 2006, PubMed
                ID 16717171);
                panic disorder with sensitivity 74%, specificity 81% (Kroenke
                et al. 2010, PMID 20633738);
                social anxiety with sensitivity 72%, specificity 80% (Kroenke
                et al. 2010);
                post-traumatic stress disorder with sensitivity 66%,
                specificity 81% (Kroenke et al. 2010).
                The majority of evidence contributing to these figures comes
                from primary care screening studies.
            </div>
        """.format(
            CssClass=CssClass,
            tr_is_complete=self.get_is_complete_tr(req),
            total_score=tr(
                req.sstring(SS.TOTAL_SCORE),
                answer(score) + " / {}".format(self.MAX_SCORE),
            ),
            anxiety_severity=tr(
                self.wxstring(req, "anxiety_severity") + " <sup>[1]</sup>",
                severity,
            ),
            q_a=q_a,
        )
예제 #13
0
    def get_task_html(self, req: CamcopsRequest) -> str:
        q_a = ""

        for i in range(1, self.N_QUESTIONS + 1):
            nstr = str(i)
            answers = {
                None: None,
                1: "1 – " + self.wxstring(req, "q" + nstr + "_o1"),
                2: "2 – " + self.wxstring(req, "q" + nstr + "_o2"),
                3: "3 – " + self.wxstring(req, "q" + nstr + "_o3"),
                4: "4 – " + self.wxstring(req, "q" + nstr + "_o4"),
                5: "5 – " + self.wxstring(req, "q" + nstr + "_o5"),
            }

            q_a += tr_qa(
                nstr + ". " + self.wxstring(req, "q" + nstr + "_h"),
                get_from_dict(answers, getattr(self, "q" + str(i))),
            )

        q_a += tr_qa(
            ("Self-rated health on a visual analogue scale (0–100) "
             "<sup>[2]</sup>"),
            self.health_vas,
        )

        return f"""
예제 #14
0
파일: aims.py 프로젝트: tarun911/camcops
    def get_task_html(self, req: CamcopsRequest) -> str:
        score = self.total_score()
        main_dict = {None: None}
        q10_dict = {None: None}
        for option in range(0, 5):
            main_dict[option] = str(option) + " — " + \
                self.wxstring(req, "main_option" + str(option))
            q10_dict[option] = str(option) + " — " + \
                self.wxstring(req, "q10_option" + str(option))

        q_a = ""
        for q in range(1, 10):
            q_a += tr_qa(self.wxstring(req, "q" + str(q) + "_s"),
                         get_from_dict(main_dict, getattr(self, "q" + str(q))))
        q_a += (
            tr_qa(self.wxstring(req, "q10_s"), get_from_dict(
                q10_dict, self.q10)) + tr_qa(self.wxstring(req, "q11_s"),
                                             get_yes_no_none(req, self.q11)) +
            tr_qa(self.wxstring(req, "q12_s"), get_yes_no_none(req, self.q12)))

        h = """
            <div class="{CssClass.SUMMARY}">
                <table class="{CssClass.SUMMARY}">
                    {tr_is_complete}
                    {total_score}
                </table>
            </div>
            <table class="{CssClass.TASKDETAIL}">
                <tr>
                    <th width="50%">Question</th>
                    <th width="50%">Answer</th>
                </tr>
                {q_a}
            </table>
            <div class="{CssClass.FOOTNOTES}">
                [1] Only Q1–10 are scored.
            </div>
        """.format(
            CssClass=CssClass,
            tr_is_complete=self.get_is_complete_tr(req),
            total_score=tr(
                req.wappstring("total_score") + " <sup>[1]</sup>",
                answer(score) + " / 40"),
            q_a=q_a,
        )
        return h
예제 #15
0
파일: irac.py 프로젝트: tarun911/camcops
 def get_achieved_text(self, req: CamcopsRequest) -> str:
     achieveddict = {
         None: None,
         0: self.wxstring(req, "achieved_0"),
         1: self.wxstring(req, "achieved_1"),
         2: self.wxstring(req, "achieved_2"),
     }
     return get_from_dict(achieveddict, self.achieved)
예제 #16
0
 def get_task_html(self, req: CamcopsRequest) -> str:
     score = self.total_score()
     severity = self.severity(req)
     answer_dicts_dict = {}
     for q in self.SCORED_QUESTIONS:
         d = {None: None}
         for option in range(0, 8):
             if option > 4 and q == "q10":
                 continue
             d[option] = self.wxstring(req, q + "_option" + str(option))
         answer_dicts_dict[q] = d
     q_a = ""
     for q in range(1, Ciwa.NSCOREDQUESTIONS + 1):
         q_a += tr_qa(
             self.wxstring(req, "q" + str(q) + "_s"),
             get_from_dict(answer_dicts_dict["q" + str(q)],
                           getattr(self, "q" + str(q))))
     h = """
         <div class="{CssClass.SUMMARY}">
             <table class="{CssClass.SUMMARY}">
                 {tr_is_complete}
                 {total_score}
                 {severity}
             </table>
         </div>
         <table class="{CssClass.TASKDETAIL}">
             <tr>
                 <th width="35%">Question</th>
                 <th width="65%">Answer</th>
             </tr>
             {q_a}
             {subhead_vitals}
             {t}
             {hr}
             {bp}
             {rr}
         </table>
         <div class="{CssClass.FOOTNOTES}">
             [1] Total score ≥15 severe, ≥8 moderate, otherwise
                 mild/minimal.
         </div>
     """.format(
         CssClass=CssClass,
         tr_is_complete=self.get_is_complete_tr(req),
         total_score=tr(req.wappstring("total_score"),
                        answer(score) + " / {}".format(self.MAX_SCORE)),
         severity=tr_qa(
             self.wxstring(req, "severity") + " <sup>[1]</sup>", severity),
         q_a=q_a,
         subhead_vitals=subheading_spanning_two_columns(
             self.wxstring(req, "vitals_title")),
         t=tr_qa(self.wxstring(req, "t"), self.t),
         hr=tr_qa(self.wxstring(req, "hr"), self.hr),
         bp=tr(self.wxstring(req, "bp"),
               answer(self.sbp) + " / " + answer(self.dbp)),
         rr=tr_qa(self.wxstring(req, "rr"), self.rr),
     )
     return h
예제 #17
0
    def get_task_html(self, req: CamcopsRequest) -> str:
        score = self.total_score()
        exceeds_cutoff_1 = score >= 6
        exceeds_cutoff_2 = score >= 11
        main_dict = {
            None: None,
            "Y": req.sstring(SS.YES),
            "N": req.sstring(SS.NO),
        }
        q_a = ""
        for q in range(1, Dast.NQUESTIONS + 1):
            q_a += tr(
                self.wxstring(req, "q" + str(q)),
                answer(get_from_dict(main_dict, getattr(self, "q" + str(q)))) +
                " — " + answer(str(self.get_score(q))),
            )

        h = """
            <div class="{CssClass.SUMMARY}">
                <table class="{CssClass.SUMMARY}">
                    {tr_is_complete}
                    {total_score}
                    {exceeds_standard_cutoff_1}
                    {exceeds_standard_cutoff_2}
                </table>
            </div>
            <table class="{CssClass.TASKDETAIL}">
                <tr>
                    <th width="80%">Question</th>
                    <th width="20%">Answer</th>
                </tr>
                {q_a}
            </table>
            <div class="{CssClass.COPYRIGHT}">
                DAST: Copyright © Harvey A. Skinner and the Centre for
                Addiction and Mental Health, Toronto, Canada.
                Reproduced here under the permissions granted for
                NON-COMMERCIAL use only. You must obtain permission from the
                copyright holder for any other use.
            </div>
        """.format(
            CssClass=CssClass,
            tr_is_complete=self.get_is_complete_tr(req),
            total_score=tr(
                req.sstring(SS.TOTAL_SCORE),
                answer(score) + f" / {self.NQUESTIONS}",
            ),
            exceeds_standard_cutoff_1=tr_qa(
                self.wxstring(req, "exceeds_standard_cutoff_1"),
                get_yes_no(req, exceeds_cutoff_1),
            ),
            exceeds_standard_cutoff_2=tr_qa(
                self.wxstring(req, "exceeds_standard_cutoff_2"),
                get_yes_no(req, exceeds_cutoff_2),
            ),
            q_a=q_a,
        )
        return h
예제 #18
0
 def get_task_html(self, req: CamcopsRequest) -> str:
     (total, extrapolated) = self.totalscore_extrapolated()
     main_dict = {
         None: None,
         1: "1 — " + self.wxstring(req, "a1"),
         2: "2 — " + self.wxstring(req, "a2"),
         3: "3 — " + self.wxstring(req, "a3"),
         4: "4 — " + self.wxstring(req, "a4"),
         MISSING_VALUE: self.wxstring(req, "no_response"),
     }
     last_q_dict = {
         None: None,
         1: "1 — " + self.wxstring(req, "q29_a1"),
         2: "2 — " + self.wxstring(req, "q29_a2"),
         3: "3 — " + self.wxstring(req, "q29_a3"),
         4: "4 — " + self.wxstring(req, "q29_a4"),
         MISSING_VALUE: self.wxstring(req, "no_response"),
     }
     instruction_dict = {
         1: self.wxstring(req, "instruction11"),
         14: self.wxstring(req, "instruction12"),
         20: self.wxstring(req, "instruction13"),
         29: self.wxstring(req, "instruction14"),
     }
     # https://docs.python.org/2/library/stdtypes.html#mapping-types-dict
     # http://paltman.com/try-except-performance-in-python-a-simple-test/
     h = f"""
         <div class="{CssClass.SUMMARY}">
             <table class="{CssClass.SUMMARY}">
                 {self.get_is_complete_tr(req)}
                 <tr>
                     <td>Total score ({self.MIN_SCORE}–{self.MAX_SCORE}),
                         higher better</td>
                     <td>{answer(ws.number_to_dp(total, DP))}</td>
                 </tr>
                 <tr>
                     <td>Total score extrapolated using incomplete
                     responses? <sup>[1]</sup></td>
                     <td>{answer(get_yes_no(req, extrapolated))}</td>
                 </tr>
             </table>
         </div>
         <table class="{CssClass.TASKDETAIL}">
             <tr>
                 <th width="50%">Question</th>
                 <th width="50%">Answer</th>
             </tr>
     """
     for n in range(1, self.NQUESTIONS + 1):
         if n in instruction_dict:
             h += subheading_spanning_two_columns(instruction_dict.get(n))
         d = main_dict if n <= self.N_SCORED_QUESTIONS else last_q_dict
         q = self.get_q(req, n)
         a = get_from_dict(d, getattr(self, "q" + str(n)))
         h += tr_qa(q, a)
     h += END_DIV + COPYRIGHT_DIV
     return h
예제 #19
0
파일: iesr.py 프로젝트: tarun911/camcops
 def get_task_html(self, req: CamcopsRequest) -> str:
     option_dict = {None: None}
     for a in range(self.MIN_SCORE, self.MAX_SCORE + 1):
         option_dict[a] = req.wappstring("iesr_a" + str(a))
     h = """
         <div class="{CssClass.SUMMARY}">
             <table class="{CssClass.SUMMARY}">
                 {complete_tr}
                 <tr>
                     <td>Total score</td>
                     <td>{total} / {maxtotal}</td>
                 </td>
                 <tr>
                     <td>Avoidance score</td>
                     <td>{avoidance} / {maxavoidance}</td>
                 </td>
                 <tr>
                     <td>Intrusion score</td>
                     <td>{intrusion} / {maxintrusion}</td>
                 </td>
                 <tr>
                     <td>Hyperarousal score</td>
                     <td>{hyperarousal} / {maxhyperarousal}</td>
                 </td>
             </table>
         </div>
         <table class="{CssClass.TASKDETAIL}">
             {tr_event}
         </table>
         <table class="{CssClass.TASKDETAIL}">
             <tr>
                 <th width="75%">Question</th>
                 <th width="25%">Answer (0–4)</th>
             </tr>
     """.format(
         CssClass=CssClass,
         complete_tr=self.get_is_complete_tr(req),
         total=answer(self.total_score()),
         maxtotal=self.MAX_TOTAL,
         avoidance=answer(self.avoidance_score()),
         maxavoidance=self.MAX_AVOIDANCE,
         intrusion=answer(self.intrusion_score()),
         maxintrusion=self.MAX_INTRUSION,
         hyperarousal=answer(self.hyperarousal_score()),
         maxhyperarousal=self.MAX_HYPERAROUSAL,
         tr_event=tr_qa(req.wappstring("event"), self.event),
     )
     for q in range(1, self.NQUESTIONS + 1):
         a = getattr(self, "q" + str(q))
         fa = ("{}: {}".format(a, get_from_dict(option_dict, a))
               if a is not None else None)
         h += tr(self.wxstring(req, "q" + str(q)), answer(fa))
     h += """
         </table>
     """ + DATA_COLLECTION_UNLESS_UPGRADED_DIV
     return h
예제 #20
0
파일: phq15.py 프로젝트: tarun911/camcops
 def get_task_html(self, req: CamcopsRequest) -> str:
     score = self.total_score()
     nsevere = self.num_severe()
     somatoform_likely = nsevere >= 3
     severity = self.severity(req)
     answer_dict = {None: None}
     for option in range(0, 3):
         answer_dict[option] = str(option) + " – " + \
             self.wxstring(req, "a" + str(option))
     q_a = ""
     for q in range(1, self.NQUESTIONS + 1):
         q_a += tr_qa(
             self.wxstring(req, "q" + str(q)),
             get_from_dict(answer_dict, getattr(self, "q" + str(q))))
     h = """
         <div class="{CssClass.SUMMARY}">
             <table class="{CssClass.SUMMARY}">
                 {tr_is_complete}
                 {total_score}
                 {n_severe_symptoms}
                 {exceeds_somatoform_cutoff}
                 {symptom_severity}
             </table>
         </div>
         <table class="{CssClass.TASKDETAIL}">
             <tr>
                 <th width="70%">Question</th>
                 <th width="30%">Answer</th>
             </tr>
             {q_a}
         </table>
         <div class="{CssClass.FOOTNOTES}">
             [1] In males, maximum score is actually 28.
             [2] Questions with scores ≥2 are considered severe.
             [3] ≥3 severe symptoms.
             [4] Total score ≥15 severe, ≥10 moderate, ≥5 mild,
                 otherwise none.
         </div>
     """.format(
         CssClass=CssClass,
         tr_is_complete=self.get_is_complete_tr(req),
         total_score=tr(
             req.wappstring("total_score") + " <sup>[1]</sup>",
             answer(score) + " / {}".format(self.MAX_TOTAL)),
         n_severe_symptoms=tr_qa(
             self.wxstring(req, "n_severe_symptoms") + " <sup>[2]</sup>",
             nsevere),
         exceeds_somatoform_cutoff=tr_qa(
             self.wxstring(req, "exceeds_somatoform_cutoff") +
             " <sup>[3]</sup>", get_yes_no(req, somatoform_likely)),
         symptom_severity=tr_qa(
             self.wxstring(req, "symptom_severity") + " <sup>[4]</sup>",
             severity),
         q_a=q_a,
     )
     return h
예제 #21
0
    def get_task_html(self, req: CamcopsRequest) -> str:
        answers = {
            None: None,
            0: "0 — " + self.wxstring(req, "a0"),
            1: "1 — " + self.wxstring(req, "a1"),
            2: "2 — " + self.wxstring(req, "a2"),
            3: "3 — " + self.wxstring(req, "a3"),
            4: "4 — " + self.wxstring(req, "a4"),
        }
        subscore_html = ""
        answer_html = ""

        for info in self.GROUPS:
            heading = self.wxstring(req, info.heading_xstring_name)
            subscore = info.subscore(self)
            subscore_html += tr(heading, (answer(round(subscore, DISPLAY_DP)) +
                                          " / {}".format(info.max_score)))
            answer_html += subheading_spanning_two_columns(heading)
            for q in info.fieldnames:
                if q == self.OPTIONAL_Q:
                    # insert additional row
                    answer_html += tr_qa(self.xstring(req, "prefer_no_answer"),
                                         self.ignore_s_q7)
                answer_val = getattr(self, q)
                answer_html += tr_qa(self.wxstring(req, q),
                                     get_from_dict(answers, answer_val))

        tscore = round(self.total_score(), DISPLAY_DP)

        h = """
            <div class="{CssClass.SUMMARY}">
                 <table class="{CssClass.SUMMARY}">
                     {tr_is_complete}
                     {total_score}
                     {subscore_html}
                 </table>
            </div>
            <table class="{CssClass.TASKDETAIL}">
                <tr>
                    <th width="50%">Question</th>
                    <th width="50%">Answer</th>
                </tr>
                {answer_html}
        """.format(
            CssClass=CssClass,
            tr_is_complete=self.get_is_complete_tr(req),
            total_score=tr(
                req.wappstring("total_score"),
                answer(tscore) + " / {}".format(self.MAX_SCORE_TOTAL)),
            subscore_html=subscore_html,
            answer_html=answer_html,
        )
        h += """
            </table>
        """
        return h
예제 #22
0
 def get_rating_text(self, req: CamcopsRequest) -> Optional[str]:
     ratingdict = {
         None: None,
         0: req.wappstring(AS.SATIS_RATING_A_PREFIX + "0"),
         1: req.wappstring(AS.SATIS_RATING_A_PREFIX + "1"),
         2: req.wappstring(AS.SATIS_RATING_A_PREFIX + "2"),
         3: req.wappstring(AS.SATIS_RATING_A_PREFIX + "3"),
         4: req.wappstring(AS.SATIS_RATING_A_PREFIX + "4"),
     }
     return get_from_dict(ratingdict, self.rating)
예제 #23
0
 def get_task_html(self, req: CamcopsRequest) -> str:
     option_dict = {None: None}
     for a in range(self.MIN_PER_Q, self.MAX_PER_Q + 1):
         option_dict[a] = req.wappstring(AS.WSAS_A_PREFIX + str(a))
     q_a = ""
     for q in range(1, self.NQUESTIONS + 1):
         a = getattr(self, "q" + str(q))
         fa = get_from_dict(option_dict, a) if a is not None else None
         q_a += tr(self.wxstring(req, "q" + str(q)), answer(fa))
     return f"""
예제 #24
0
 def get_rating_text(self, req: CamcopsRequest) -> Optional[str]:
     ratingdict = {
         None: None,
         0: req.wappstring("satis_rating_a0"),
         1: req.wappstring("satis_rating_a1"),
         2: req.wappstring("satis_rating_a2"),
         3: req.wappstring("satis_rating_a3"),
         4: req.wappstring("satis_rating_a4"),
     }
     return get_from_dict(ratingdict, self.rating)
예제 #25
0
 def get_task_html(self, req: CamcopsRequest) -> str:
     main_dict = {
         None: None,
         1: "1 — " + self.wxstring(req, "wemwbs_a1"),
         2: "2 — " + self.wxstring(req, "wemwbs_a2"),
         3: "3 — " + self.wxstring(req, "wemwbs_a3"),
         4: "4 — " + self.wxstring(req, "wemwbs_a4"),
         5: "5 — " + self.wxstring(req, "wemwbs_a5"),
     }
     q_a = ""
     for i in range(1, self.N_QUESTIONS + 1):
         nstr = str(i)
         q_a += tr_qa(
             self.wxstring(req, "wemwbs_q" + nstr),
             get_from_dict(main_dict, getattr(self, "q" + nstr)),
         )
     h = """
         <div class="{css_summary}">
             <table class="{css_summary}">
                 {tr_is_complete}
                 {tr_total_score}
             </table>
         </div>
         <div class="{css_explanation}">
             Ratings are over the last 2 weeks.
         </div>
         <table class="{css_taskdetail}">
             <tr>
                 <th width="60%">Question</th>
                 <th width="40%">Answer</th>
             </tr>
             {q_a}
         </table>
         <div class="{css_copyright}">
             WEMWBS: from Tennant et al. (2007), <i>Health and Quality of
             Life Outcomes</i> 5:63,
             <a href="http://www.hqlo.com/content/5/1/63">
                 http://www.hqlo.com/content/5/1/63</a>;
             © 2007 Tennant et al.; distributed under the terms of the
             Creative Commons Attribution License.
         </div>
     """.format(
         css_summary=CssClass.SUMMARY,
         tr_is_complete=self.get_is_complete_tr(req),
         tr_total_score=tr(
             req.sstring(SS.TOTAL_SCORE),
             answer(self.total_score())
             + f" (range {self.MINTOTALSCORE}–{self.MAXTOTALSCORE})",
         ),
         css_explanation=CssClass.EXPLANATION,
         css_taskdetail=CssClass.TASKDETAIL,
         q_a=q_a,
         css_copyright=CssClass.COPYRIGHT,
     )
     return h
예제 #26
0
파일: fft.py 프로젝트: tarun911/camcops
 def get_rating_text(self, req: CamcopsRequest) -> str:
     ratingdict = {
         None: None,
         1: self.wxstring(req, "a1"),
         2: self.wxstring(req, "a2"),
         3: self.wxstring(req, "a3"),
         4: self.wxstring(req, "a4"),
         5: self.wxstring(req, "a5"),
         6: self.wxstring(req, "a6"),
     }
     return get_from_dict(ratingdict, self.rating)
예제 #27
0
파일: bprse.py 프로젝트: tarun911/camcops
    def get_task_html(self, req: CamcopsRequest) -> str:
        def bprs_string(x: str) -> str:
            return req.wxstring("bprs", x)

        main_dict = {
            None: None,
            0: "0 — " + bprs_string("old_option0"),
            1: "1 — " + bprs_string("old_option1"),
            2: "2 — " + bprs_string("old_option2"),
            3: "3 — " + bprs_string("old_option3"),
            4: "4 — " + bprs_string("old_option4"),
            5: "5 — " + bprs_string("old_option5"),
            6: "6 — " + bprs_string("old_option6"),
            7: "7 — " + bprs_string("old_option7")
        }

        q_a = ""
        for i in range(1, self.NQUESTIONS + 1):
            q_a += tr_qa(self.wxstring(req, "q" + str(i) + "_s"),
                         get_from_dict(main_dict, getattr(self, "q" + str(i))))

        h = """
            <div class="{CssClass.SUMMARY}">
                <table class="{CssClass.SUMMARY}">
                    {tr_is_complete}
                    {total_score}
                </table>
            </div>
            <div class="{CssClass.EXPLANATION}">
                Each question has specific answer definitions (see e.g. tablet
                app).
            </div>
            <table class="{CssClass.TASKDETAIL}">
                <tr>
                    <th width="60%">Question</th>
                    <th width="40%">Answer <sup>[1]</sup></th>
                </tr>
                {q_a}
            </table>
            <div class="{CssClass.FOOTNOTES}">
                [1] All answers are in the range 1–7, or 0 (not assessed, for
                    some).
            </div>
        """.format(
            CssClass=CssClass,
            tr_is_complete=self.get_is_complete_tr(req),
            total_score=tr(
                req.wappstring("total_score") +
                " (0–{maxscore}; 24–{maxscore} if all rated)".format(
                    maxscore=self.MAX_SCORE), answer(self.total_score())),
            q_a=q_a,
        )
        return h
예제 #28
0
파일: eq5d5l.py 프로젝트: tarun911/camcops
    def get_task_html(self, req: CamcopsRequest) -> str:
        q_a = ""

        for i in range(1, self.N_QUESTIONS + 1):
            nstr = str(i)
            answers = {
                None: None,
                1: "1 – " + self.wxstring(req, "q" + nstr + "_o1"),
                2: "2 – " + self.wxstring(req, "q" + nstr + "_o2"),
                3: "3 – " + self.wxstring(req, "q" + nstr + "_o3"),
                4: "4 – " + self.wxstring(req, "q" + nstr + "_o4"),
                5: "5 – " + self.wxstring(req, "q" + nstr + "_o5"),
            }

            q_a += tr_qa(nstr + ". " + self.wxstring(req, "q" + nstr + "_h"),
                         get_from_dict(answers, getattr(self, "q" + str(i))))

        q_a += tr_qa(("Self-rated health on a visual analogue scale (0–100) "
                      "<sup>[2]</sup>"), self.health_vas)

        h = """
            <div class="{CssClass.SUMMARY}">
                <table class="{CssClass.SUMMARY}">
                    {tr_is_complete}
                    {mcq_score}
                    {vis_score}
                </table>
            </div>
            <table class="{CssClass.TASKDETAIL}">
                <tr>
                    <th width="60%">Question</th>
                    <th width="40%">Answer</th>
                </tr>
                {q_a}
            </table>
            <div class="{CssClass.FOOTNOTES}">
                [1] This is a string of digits, not a directly meaningful 
                    number. Each digit corresponds to a question.
                    A score of 1 indicates no problems in any given dimension.
                    5 indicates extreme problems. Missing values are
                    coded as 9.
                [2] This is the visual analogue health score, with missing 
                    values coded as 999.
            </div>
        """.format(CssClass=CssClass,
                   tr_is_complete=self.get_is_complete_tr(req),
                   mcq_score=tr_qa("Health state code <sup>[1]</sup>",
                                   self.get_health_state_code()),
                   vis_score=tr_qa(
                       "Visual analogue scale summary number <sup>[2]</sup>",
                       self.get_vis_score_or_999()),
                   q_a=q_a)
        return h
예제 #29
0
 def get_task_html(self, req: CamcopsRequest) -> str:
     answer_dict = {None: None}
     for option in range(0, 3 + 1):
         answer_dict[option] = (str(option) + " — " +
                                self.wxstring(req, "a" + str(option)))
     q_a = ""
     for q in range(1, self.NQUESTIONS + 1):
         q_a += tr_qa(
             f"Q{q}. {self.wxstring(req, 'q' + str(q))}",
             get_from_dict(answer_dict, getattr(self, "q" + str(q))),
         )
     return f"""
예제 #30
0
 def get_task_html(self, req: CamcopsRequest) -> str:
     answer_dict = {None: None}
     for option in range(0, 3 + 1):
         answer_dict[option] = (str(option) + " — " +
                                self.wxstring(req, "a" + str(option)))
     h = """
         <div class="{CssClass.SUMMARY}">
             <table class="{CssClass.SUMMARY}">
                 {tr_is_complete}
     """.format(
         CssClass=CssClass,
         tr_is_complete=self.get_is_complete_tr(req),
     )
     h += tr_qa("Self-distraction (Q1, Q19)", self.self_distraction())
     h += tr_qa("Active coping (Q2, Q7)", self.active_coping())
     h += tr_qa("Denial (Q3, Q8)", self.denial())
     h += tr_qa("Substance use (Q4, Q11)", self.substance_use())
     h += tr_qa("Use of emotional support (Q5, Q15)",
                self.emotional_support())
     h += tr_qa("Use of instrumental support (Q10, Q23)",
                self.instrumental_support())
     h += tr_qa("Behavioural disengagement (Q6, Q16)",
                self.behavioural_disengagement())
     h += tr_qa("Venting (Q9, Q21)", self.venting())
     h += tr_qa("Positive reframing (Q12, Q17)", self.positive_reframing())
     h += tr_qa("Planning (Q14, Q25)", self.planning())
     h += tr_qa("Humour (Q18, Q28)", self.humour())
     h += tr_qa("Acceptance (Q20, Q24)", self.acceptance())
     h += tr_qa("Religion (Q22, Q27)", self.religion())
     h += tr_qa("Self-blame (Q13, Q26)", self.self_blame())
     h += """
             </table>
         </div>
         <div class="{CssClass.EXPLANATION}">
             Individual items are scored 0–3 (as in Carver 1997 PMID
             16250744), not 1–4 (as in
             http://www.psy.miami.edu/faculty/ccarver/sclBrCOPE.html).
             Summaries, which are all
             based on two items, are therefore scored 0–6.
         </div>
         <table class="{CssClass.TASKDETAIL}">
             <tr>
                 <th width="50%">Question</th>
                 <th width="50%">Answer</th>
             </tr>
     """.format(CssClass=CssClass)
     for q in range(1, self.NQUESTIONS + 1):
         h += tr_qa("Q{}. {}".format(q, self.wxstring(req, "q" + str(q))),
                    get_from_dict(answer_dict, getattr(self, "q" + str(q))))
     h += """
         </table>
     """
     return h