예제 #1
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
예제 #2
0
 def get_task_html(self, req: CamcopsRequest) -> str:
     score = self.total_score()
     exceeds_cutoff = score >= 2
     q_a = ""
     for q in range(1, Cage.NQUESTIONS + 1):
         q_a += tr_qa(
             str(q) + " — " + self.wxstring(req, "q" + str(q)),
             getattr(self,
                     "q" + str(q)))  # answer is itself Y/N/NULL  # noqa
     h = """
         <div class="{CssClass.SUMMARY}">
             <table class="{CssClass.SUMMARY}">
                 {tr_is_complete}
                 {total_score}
                 {over_threshold}
             </table>
         </div>
         <table class="{CssClass.TASKDETAIL}">
             <tr>
                 <th width="70%">Question</th>
                 <th width="30%">Answer</th>
             </tr>
             {q_a}
         </table>
     """.format(
         CssClass=CssClass,
         tr_is_complete=self.get_is_complete_tr(req),
         total_score=tr(req.wappstring("total_score"),
                        answer(score) + " / {}".format(self.NQUESTIONS)),
         over_threshold=tr_qa(self.wxstring(req, "over_threshold"),
                              get_yes_no(req, exceeds_cutoff)),
         q_a=q_a,
     )
     return h
예제 #3
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"""
예제 #4
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
예제 #5
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
예제 #6
0
파일: cesdr.py 프로젝트: tarun911/camcops
    def get_task_html(self, req: CamcopsRequest) -> str:
        score = self.total_score()
        answer_dict = {None: None}
        for option in range(self.N_ANSWERS):
            answer_dict[option] = str(option) + " – " + \
                self.wxstring(req, "a" + str(option))
        q_a = ""
        for q in range(1, self.N_QUESTIONS):
            q_a += tr_qa(
                self.wxstring(req, "q" + str(q) + "_s"),
                get_from_dict(answer_dict, getattr(self, "q" + str(q))))

        h = """
            <div class="{CssClass.SUMMARY}">
                <table class="{CssClass.SUMMARY}">
                    {tr_is_complete}
                    {total_score}
                    {depression_or_risk_of}
                    {provisional_diagnosis}
                </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] Presence of depression (or depression risk) is indicated by a
                score &ge; 16
            [2] Diagnostic criteria described at
                <a href="https://cesd-r.com/cesdr/">https://cesd-r.com/cesdr/</a>
            </div>
        """.format(  # noqa
            CssClass=CssClass,
            tr_is_complete=self.get_is_complete_tr(req),
            total_score=tr_qa(
                "{} (0–60)".format(req.wappstring("total_score")), score),
            depression_or_risk_of=tr_qa(
                self.wxstring(req, "depression_or_risk_of") +
                "? <sup>[1]</sup>", get_yes_no(req,
                                               self.has_depression_risk())),
            provisional_diagnosis=tr(
                'Provisional diagnosis <sup>[2]</sup>',
                self.wxstring(
                    req, "category_" + str(self.get_depression_category()))),
            q_a=q_a,
        )
        return h
예제 #7
0
 def get_task_html(self, req: CamcopsRequest) -> str:
     score = self.total_score()
     exceeds_cutoff = score >= 2
     q_a = ""
     for q in range(1, Cage.NQUESTIONS + 1):
         q_a += tr_qa(
             str(q) + " — " + self.wxstring(req, "q" + str(q)),
             getattr(self, "q" + str(q)),
         )  # answer is itself Y/N/NULL  # noqa
     total_score = tr(
         req.sstring(SS.TOTAL_SCORE),
         answer(score) + f" / {self.NQUESTIONS}",
     )
     over_threshold = tr_qa(
         self.wxstring(req, "over_threshold"),
         get_yes_no(req, exceeds_cutoff),
     )
     return f"""
예제 #8
0
    def get_task_html(self, req: CamcopsRequest) -> str:
        score = self.total_score()
        answer_dict = {None: None}
        for option in range(self.N_ANSWERS):
            answer_dict[option] = (str(option) + " – " +
                                   self.wxstring(req, "a" + str(option)))
        q_a = ""
        for q in range(1, self.N_QUESTIONS):
            q_a += tr_qa(
                self.wxstring(req, "q" + str(q) + "_s"),
                get_from_dict(answer_dict, getattr(self, "q" + str(q))),
            )

        tr_total_score = (tr_qa(f"{req.sstring(SS.TOTAL_SCORE)} (0–60)",
                                score), )
        tr_depression_or_risk_of = (tr_qa(
            self.wxstring(req, "depression_or_risk_of") + "? <sup>[1]</sup>",
            get_yes_no(req, self.has_depression_risk()),
        ), )
        return f"""
예제 #9
0
파일: mast.py 프로젝트: tarun911/camcops
 def get_task_html(self, req: CamcopsRequest) -> str:
     score = self.total_score()
     exceeds_threshold = self.exceeds_ross_threshold()
     main_dict = {
         None: None,
         "Y": req.wappstring("yes"),
         "N": req.wappstring("no")
     }
     q_a = ""
     for q in range(1, self.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_threshold}
             </table>
         </div>
         <table class="{CssClass.TASKDETAIL}">
             <tr>
                 <th width="80%">Question</th>
                 <th width="20%">Answer</th>
             </tr>
             {q_a}
         </table>
     """.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)),
         exceeds_threshold=tr_qa(self.wxstring(req, "exceeds_threshold"),
                                 get_yes_no(req, exceeds_threshold)),
         q_a=q_a,
     )
     return h
예제 #10
0
    def get_task_html(self, req: CamcopsRequest) -> str:
        score = self.total_score()
        num_symptomatic = self.num_symptomatic()
        num_symptomatic_b = self.num_symptomatic_b()
        num_symptomatic_c = self.num_symptomatic_c()
        num_symptomatic_d = self.num_symptomatic_d()
        num_symptomatic_e = self.num_symptomatic_e()
        ptsd = self.ptsd()
        answer_dict = {None: None}
        for option in range(5):
            answer_dict[option] = (str(option) + " – " +
                                   self.wxstring(req, "a" + str(option)))
        q_a = ""

        section_start = {
            1: "B (intrusion symptoms)",
            6: "C (avoidance)",
            8: "D (negative cognition/mood)",
            15: "E (arousal/reactivity)",
        }

        for q in range(1, self.N_QUESTIONS + 1):
            if q in section_start:
                section = section_start[q]
                q_a += subheading_spanning_two_columns(
                    f"DSM-5 section {section}")

            q_a += tr_qa(
                self.wxstring(req, "q" + str(q) + "_s"),
                get_from_dict(answer_dict, getattr(self, "q" + str(q))),
            )

        h = """
            <div class="{CssClass.SUMMARY}">
                <table class="{CssClass.SUMMARY}">
                    {tr_is_complete}
                    {total_score}
                    {num_symptomatic}
                    {dsm_criteria_met}
                </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] Questions with scores ≥2 are considered symptomatic; see
                    https://www.ptsd.va.gov/professional/assessment/adult-sr/ptsd-checklist.asp
                [2] ≥1 ‘B’ symptoms and ≥1 ‘C’ symptoms and ≥2 ‘D’ symptoms
                    and ≥2 ‘E’ symptoms.
            </div>
        """.format(  # noqa
            CssClass=CssClass,
            tr_is_complete=self.get_is_complete_tr(req),
            total_score=tr_qa(f"{req.sstring(SS.TOTAL_SCORE)} (0–80)", score),
            num_symptomatic=tr(
                "Number symptomatic <sup>[1]</sup>: B, C, D, E (total)",
                answer(num_symptomatic_b) + ", " + answer(num_symptomatic_c) +
                ", " + answer(num_symptomatic_d) + ", " +
                answer(num_symptomatic_e) + " (" + answer(num_symptomatic) +
                ")",
            ),
            dsm_criteria_met=tr_qa(
                self.wxstring(req, "dsm_criteria_met") + " <sup>[2]</sup>",
                get_yes_no(req, ptsd),
            ),
            q_a=q_a,
        )
        return h
예제 #11
0
파일: phq9.py 프로젝트: tarun911/camcops
    def get_task_html(self, req: CamcopsRequest) -> str:
        main_dict = {
            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")
        }
        q10_dict = {
            None: None,
            0: "0 — " + self.wxstring(req, "fa0"),
            1: "1 — " + self.wxstring(req, "fa1"),
            2: "2 — " + self.wxstring(req, "fa2"),
            3: "3 — " + self.wxstring(req, "fa3")
        }
        q_a = ""
        for i in range(1, self.N_MAIN_QUESTIONS + 1):
            nstr = str(i)
            q_a += tr_qa(self.wxstring(req, "q" + nstr),
                         get_from_dict(main_dict, getattr(self, "q" + nstr)))
        q_a += tr_qa("10. " + self.wxstring(req, "finalq"),
                     get_from_dict(q10_dict, self.q10))

        h = """
            <div class="{CssClass.SUMMARY}">
                <table class="{CssClass.SUMMARY}">
                    {tr_is_complete}
                    {total_score}
                    {depression_severity}
                    {n_symptoms}
                    {mds}
                    {ods}
                </table>
            </div>
            <div class="{CssClass.EXPLANATION}">
                Ratings are over the last 2 weeks.
            </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] Sum for questions 1–9.
                [2] Total score ≥20 severe, ≥15 moderately severe,
                    ≥10 moderate, ≥5 mild, &lt;5 none.
                [3] Number of questions 1–2 rated ≥2.
                [4] Number of questions 3–8 rated ≥2, or question 9
                    rated ≥1.
                [5] ≥1 core symptom and ≥5 total symptoms (as per
                    DSM-IV-TR page 356).
                [6] ≥1 core symptom and 2–4 total symptoms (as per
                    DSM-IV-TR page 775).
            </div>
        """.format(
            CssClass=CssClass,
            tr_is_complete=self.get_is_complete_tr(req),
            total_score=tr(
                req.wappstring("total_score") + " <sup>[1]</sup>",
                answer(self.total_score()) +
                " / {}".format(self.MAX_SCORE_MAIN)),
            depression_severity=tr_qa(
                self.wxstring(req, "depression_severity") + " <sup>[2]</sup>",
                self.severity(req)),
            n_symptoms=tr(
                "Number of symptoms: core <sup>[3]</sup>, other "
                "<sup>[4]</sup>, total",
                answer(self.n_core()) + "/2, " + answer(self.n_other()) +
                "/7, " + answer(self.n_total()) + "/9"),
            mds=tr_qa(
                self.wxstring(req, "mds") + " <sup>[5]</sup>",
                get_yes_no(req, self.is_mds())),
            ods=tr_qa(
                self.wxstring(req, "ods") + " <sup>[6]</sup>",
                get_yes_no(req, self.is_ods())),
            q_a=q_a,
        )
        return h
예제 #12
0
    def get_task_html(self, req: CamcopsRequest) -> str:
        freq_dict = {None: None}
        distress_dict = {None: None}
        for a in range(self.MIN_SCORE, self.MAX_SCORE + 1):
            freq_dict[a] = self.wxstring(req, "f" + str(a))
            distress_dict[a] = self.wxstring(req, "d" + str(a))

        heading_memory = self.wxstring(req, "h_memory")
        heading_everyday = self.wxstring(req, "h_everyday")
        heading_selfcare = self.wxstring(req, "h_selfcare")
        heading_behaviour = self.wxstring(req, "h_abnormalbehaviour")
        heading_mood = self.wxstring(req, "h_mood")
        heading_beliefs = self.wxstring(req, "h_beliefs")
        heading_eating = self.wxstring(req, "h_eating")
        heading_sleep = self.wxstring(req, "h_sleep")
        heading_motor = self.wxstring(req, "h_stereotypy_motor")
        heading_motivation = self.wxstring(req, "h_motivation")

        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

        h = """
            <div class="{CssClass.SUMMARY}">
                <table class="{CssClass.SUMMARY}">
                    {complete_tr}
                </table>
                <table class="{CssClass.SUMMARY}">
                    <tr>
                        <th>Subscale</th>
                        <th>Frequency (% of max)</th>
                        <th>Distress (% of max)</th>
                    </tr>
                    <tr>
                        <td>{heading_memory}</td>
                        <td>{mem_f}</td>
                        <td>{mem_d}</td>
                    </tr>
                    <tr>
                        <td>{heading_everyday}</td>
                        <td>{everyday_f}</td>
                        <td>{everyday_d}</td>
                    </tr>
                    <tr>
                        <td>{heading_selfcare}</td>
                        <td>{self_f}</td>
                        <td>{self_d}</td>
                    </tr>
                    <tr>
                        <td>{heading_behaviour}</td>
                        <td>{behav_f}</td>
                        <td>{behav_d}</td>
                    </tr>
                    <tr>
                        <td>{heading_mood}</td>
                        <td>{mood_f}</td>
                        <td>{mood_d}</td>
                    </tr>
                    <tr>
                        <td>{heading_beliefs}</td>
                        <td>{beliefs_f}</td>
                        <td>{beliefs_d}</td>
                    </tr>
                    <tr>
                        <td>{heading_eating}</td>
                        <td>{eating_f}</td>
                        <td>{eating_d}</td>
                    </tr>
                    <tr>
                        <td>{heading_sleep}</td>
                        <td>{sleep_f}</td>
                        <td>{sleep_d}</td>
                    </tr>
                    <tr>
                        <td>{heading_motor}</td>
                        <td>{motor_f}</td>
                        <td>{motor_d}</td>
                    </tr>
                    <tr>
                        <td>{heading_motivation}</td>
                        <td>{motivation_f}</td>
                        <td>{motivation_d}</td>
                    </tr>
                </table>
            </div>
            <table class="{CssClass.TASKDETAIL}">
                {tr_blanks}
                {tr_comments}
            </table>
            <table class="{CssClass.TASKDETAIL}">
                <tr>
                    <th width="50%">Question</th>
                    <th width="25%">Frequency (0–4)</th>
                    <th width="25%">Distress (0–4)</th>
                </tr>
        """.format(
            CssClass=CssClass,
            complete_tr=self.get_is_complete_tr(req),
            heading_memory=heading_memory,
            mem_f=answer(self.frequency_subscore(*self.QNUMS_MEMORY)),
            mem_d=answer(self.distress_subscore(*self.QNUMS_MEMORY)),
            heading_everyday=heading_everyday,
            everyday_f=answer(self.frequency_subscore(*self.QNUMS_EVERYDAY)),
            everyday_d=answer(self.distress_subscore(*self.QNUMS_EVERYDAY)),
            heading_selfcare=heading_selfcare,
            self_f=answer(self.frequency_subscore(*self.QNUMS_SELF)),
            self_d=answer(self.distress_subscore(*self.QNUMS_SELF)),
            heading_behaviour=heading_behaviour,
            behav_f=answer(self.frequency_subscore(*self.QNUMS_BEHAVIOUR)),
            behav_d=answer(self.distress_subscore(*self.QNUMS_BEHAVIOUR)),
            heading_mood=heading_mood,
            mood_f=answer(self.frequency_subscore(*self.QNUMS_MOOD)),
            mood_d=answer(self.distress_subscore(*self.QNUMS_MOOD)),
            heading_beliefs=heading_beliefs,
            beliefs_f=answer(self.frequency_subscore(*self.QNUMS_BELIEFS)),
            beliefs_d=answer(self.distress_subscore(*self.QNUMS_BELIEFS)),
            heading_eating=heading_eating,
            eating_f=answer(self.frequency_subscore(*self.QNUMS_EATING)),
            eating_d=answer(self.distress_subscore(*self.QNUMS_EATING)),
            heading_sleep=heading_sleep,
            sleep_f=answer(self.frequency_subscore(*self.QNUMS_SLEEP)),
            sleep_d=answer(self.distress_subscore(*self.QNUMS_SLEEP)),
            heading_motor=heading_motor,
            motor_f=answer(self.frequency_subscore(*self.QNUMS_STEREOTYPY)),
            motor_d=answer(self.distress_subscore(*self.QNUMS_STEREOTYPY)),
            heading_motivation=heading_motivation,
            motivation_f=answer(
                self.frequency_subscore(*self.QNUMS_MOTIVATION)),
            motivation_d=answer(
                self.distress_subscore(*self.QNUMS_MOTIVATION)),
            tr_blanks=tr(
                "Respondent confirmed that blanks are deliberate (N/A)",
                answer(get_yes_no(req, self.confirm_blanks))),
            tr_comments=tr("Comments", answer(self.comments, default="")),
        )
        h += subheading_spanning_three_columns(heading_memory)
        h += get_question_rows(*self.QNUMS_MEMORY)
        h += subheading_spanning_three_columns(heading_everyday)
        h += get_question_rows(*self.QNUMS_EVERYDAY)
        h += subheading_spanning_three_columns(heading_selfcare)
        h += get_question_rows(*self.QNUMS_SELF)
        h += subheading_spanning_three_columns(heading_behaviour)
        h += get_question_rows(*self.QNUMS_BEHAVIOUR)
        h += subheading_spanning_three_columns(heading_mood)
        h += get_question_rows(*self.QNUMS_MOOD)
        h += subheading_spanning_three_columns(heading_beliefs)
        h += get_question_rows(*self.QNUMS_BELIEFS)
        h += subheading_spanning_three_columns(heading_eating)
        h += get_question_rows(*self.QNUMS_EATING)
        h += subheading_spanning_three_columns(heading_sleep)
        h += get_question_rows(*self.QNUMS_SLEEP)
        h += subheading_spanning_three_columns(heading_motor)
        h += get_question_rows(*self.QNUMS_STEREOTYPY)
        h += subheading_spanning_three_columns(heading_motivation)
        h += get_question_rows(*self.QNUMS_MOTIVATION)
        h += """
            </table>
        """
        return h
예제 #13
0
파일: demqol.py 프로젝트: tarun911/camcops
 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, "proxy_instruction11"),
         12: self.wxstring(req, "proxy_instruction12"),
         21: self.wxstring(req, "proxy_instruction13"),
         32: self.wxstring(req, "proxy_instruction14"),
     }
     h = """
         <div class="{CssClass.SUMMARY}">
             <table class="{CssClass.SUMMARY}">
                 {is_complete_tr}
                 <tr>
                     <td>Total score ({min}–{max}), higher better</td>
                     <td>{t}</td>
                 </tr>
                 <tr>
                     <td>Total score extrapolated using incomplete
                     responses? <sup>[1]</sup></td>
                     <td>{e}</td>
                 </tr>
             </table>
         </div>
         <table class="{CssClass.TASKDETAIL}">
             <tr>
                 <th width="50%">Question</th>
                 <th width="50%">Answer</th>
             </tr>
     """.format(
         CssClass=CssClass,
         is_complete_tr=self.get_is_complete_tr(req),
         min=self.MIN_SCORE,
         max=self.MAX_SCORE,
         t=answer(ws.number_to_dp(total, DP)),
         e=answer(get_yes_no(req, extrapolated)),
     )
     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
예제 #14
0
 def get_task_html(self, req: CamcopsRequest) -> str:
     score = self.total_score()
     num_symptomatic = self.num_symptomatic()
     num_symptomatic_b = self.num_symptomatic_b()
     num_symptomatic_c = self.num_symptomatic_c()
     num_symptomatic_d = self.num_symptomatic_d()
     ptsd = self.ptsd()
     answer_dict = {None: None}
     for option in range(1, 6):
         answer_dict[option] = (str(option) + " – " +
                                self.wxstring(req, "option" + str(option)))
     q_a = ""
     if hasattr(self, "event") and hasattr(self, "eventdate"):
         # PCL-S
         q_a += tr_qa(self.wxstring(req, "s_event_s"), self.event)
         q_a += tr_qa(self.wxstring(req, "s_eventdate_s"), self.eventdate)
     for q in range(1, self.NQUESTIONS + 1):
         if q == 1 or q == 6 or q == 13:
             section = "B" if q == 1 else ("C" if q == 6 else "D")
             q_a += subheading_spanning_two_columns(
                 f"DSM-IV-TR section {section}")
         q_a += tr_qa(
             self.wxstring(req, "q" + str(q) + "_s"),
             get_from_dict(answer_dict, getattr(self, "q" + str(q))),
         )
     h = """
         <div class="{CssClass.SUMMARY}">
             <table class="{CssClass.SUMMARY}">
                 {tr_is_complete}
                 {total_score}
                 {num_symptomatic}
                 {dsm_criteria_met}
             </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] Questions with scores ≥3 are considered symptomatic.
             [2] ≥1 ‘B’ symptoms and ≥3 ‘C’ symptoms and
                 ≥2 ‘D’ symptoms.
         </div>
     """.format(
         CssClass=CssClass,
         tr_is_complete=self.get_is_complete_tr(req),
         total_score=tr_qa(f"{req.sstring(SS.TOTAL_SCORE)} (17–85)", score),
         num_symptomatic=tr(
             "Number symptomatic <sup>[1]</sup>: B, C, D (total)",
             answer(num_symptomatic_b) + ", " + answer(num_symptomatic_c) +
             ", " + answer(num_symptomatic_d) + " (" +
             answer(num_symptomatic) + ")",
         ),
         dsm_criteria_met=tr_qa(
             self.wxstring(req, "dsm_criteria_met") + " <sup>[2]</sup>",
             get_yes_no(req, ptsd),
         ),
         q_a=q_a,
     )
     return h
예제 #15
0
 def ynrow(qname: str, xstring_name: str,
           value: Optional[Union[int, bool]]) -> str:
     return plainrow(qname, xstring_name, get_yes_no(req, value))
예제 #16
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))

        h = """
            <div class="{CssClass.SUMMARY}">
                <table class="{CssClass.SUMMARY}">
                    {tr_is_complete}
                    {total_score}
                    {exceeds_standard_cutoff}
                </table>
            </div>
            <table class="{CssClass.TASKDETAIL}">
                <tr>
                    <th width="50%">Question</th>
                    <th width="50%">Answer</th>
                </tr>
                {q_a}
            </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.
            </div>
        """.format(
            CssClass=CssClass,
            tr_is_complete=self.get_is_complete_tr(req),
            total_score=tr(req.wappstring("total_score"),
                           answer(score) + " / 40"),
            exceeds_standard_cutoff=tr_qa(
                self.wxstring(req, "exceeds_standard_cutoff"),
                get_yes_no(req, exceeds_cutoff)),
            q_a=q_a,
        )
        return h