Beispiel #1
0
 def get_task_html(self, req: CamcopsRequest) -> str:
     score = self.total_score()
     q_a = ""
     for f in FIELDNAMES:
         v = getattr(self, f)
         q_a += tr_qa(self.wxstring(req, f), get_yes_no_unknown(req, v))
     return f"""
Beispiel #2
0
 def get_task_html(self, req: CamcopsRequest) -> str:
     h = """
         <div class="{CssClass.SUMMARY}">
             <table class="{CssClass.SUMMARY}">
                 {complete_tr}
                 <tr>
                     <td>Endorsed</td>
                     <td>{e} / 12</td>
                 </td>
                 <tr>
                     <td>Severity score</td>
                     <td>{s} / 36</td>
                 </td>
                 <tr>
                     <td>Distress score</td>
                     <td>{d} / 60</td>
                 </td>
             </table>
         </div>
         <table class="{CssClass.TASKDETAIL}">
             <tr>
                 <th width="40%">Question</th>
                 <th width="20%">Endorsed</th>
                 <th width="20%">Severity (patient)</th>
                 <th width="20%">Distress (carer)</th>
             </tr>
     """.format(
         CssClass=CssClass,
         complete_tr=self.get_is_complete_tr(req),
         e=self.n_endorsed(),
         s=self.severity_score(),
         d=self.distress_score(),
     )
     for q in range(1, self.NQUESTIONS + 1):
         qstr = str(q)
         e = getattr(self, ENDORSED + qstr)
         s = getattr(self, SEVERITY + qstr)
         d = getattr(self, DISTRESS + qstr)
         qtext = "<b>{}:</b> {}".format(
             self.wxstring(req, "t" + qstr),
             self.wxstring(req, "q" + qstr),
         )
         etext = get_yes_no_unknown(req, e)
         if e:
             stext = self.wxstring(req, "severity_{}".format(s), s,
                                   provide_default_if_none=False)
             dtext = self.wxstring(req, "distress_{}".format(d), d,
                                   provide_default_if_none=False)
         else:
             stext = ""
             dtext = ""
         h += tr(qtext, answer(etext), answer(stext), answer(dtext))
     h += """
         </table>
     """ + DATA_COLLECTION_UNLESS_UPGRADED_DIV
     return h
Beispiel #3
0
    def get_task_html(self, req: CamcopsRequest) -> str:
        score_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"),
        }

        rows = ""
        for i in range(1, self.N_SCORED_QUESTIONS + 1):
            q_field = "q" + str(i)
            question_cell = "{}. {}".format(i, self.wxstring(req, q_field))
            answer_cell = get_from_dict(score_dict, getattr(self, q_field))

            rows += tr_qa(question_cell, answer_cell)

        rows += tr_qa(
            "16. " + self.wxstring(req, "q16"), get_yes_no_unknown(req, "q16")
        )

        html = """
            <div class="{CssClass.SUMMARY}">
                <table class="{CssClass.SUMMARY}">
                    {tr_is_complete}
                    {total_score}
                </table>
            </div>
            <table class="{CssClass.TASKDETAIL}">
                <tr>
                    <th width="60%">Question</th>
                    <th width="40%">Answer</th>
                </tr>
                {rows}
            </table>
            <div class="{CssClass.FOOTNOTES}">
                [1] Sum for questions 1–15.
            </div>
        """.format(
            CssClass=CssClass,
            tr_is_complete=self.get_is_complete_tr(req),
            total_score=tr(
                req.sstring(SS.TOTAL_SCORE) + " <sup>[1]</sup>",
                answer(self.total_score()) + f" / {self.MAX_SCORE_MAIN}",
            ),
            rows=rows,
        )
        return html
Beispiel #4
0
def ctv_info_pd(req: CamcopsRequest, condition: str,
                has_it: Optional[bool]) -> CtvInfo:
    return CtvInfo(content=condition + ": " + get_yes_no_unknown(req, has_it))
Beispiel #5
0
 def pd_general_criteria_bits(self, req: CamcopsRequest) -> str:
     return """
         <tr><td>{}</td><td><i><b>{}</b></i></td></tr>
     """.format(self.wxstring(req, "general_criteria_must_be_met"),
                get_yes_no_unknown(req, self.has_pd()))
Beispiel #6
0
 def get_research_opt_out_answer(self,
                                 req: CamcopsRequest) -> Optional[str]:
     return get_yes_no_unknown(req, getattr(self, self.FN_RESEARCH_OPT_OUT))
Beispiel #7
0
 def get_contact_by_email_answer(self,
                                 req: CamcopsRequest) -> Optional[str]:
     return get_yes_no_unknown(req, getattr(self, self.FN_CONTACT_BY_EMAIL))