def get_task_html(self, req: CamcopsRequest) -> str: return self.get_common_task_html( req, req.wappstring("satis_ref_spec_rating_q"), req.wappstring("satis_good_q"), req.wappstring("satis_bad_q") )
def get_trackers(self, req: CamcopsRequest) -> List[TrackerInfo]: return [ TrackerInfo( value=self.total_score(), plot_label="PHQ-9 total score (rating depressive symptoms)", axis_label="Score for Q1-9 (out of {})".format( self.MAX_SCORE_MAIN), axis_min=-0.5, axis_max=self.MAX_SCORE_MAIN + 0.5, axis_ticks=[ TrackerAxisTick(27, "27"), TrackerAxisTick(25, "25"), TrackerAxisTick(20, "20"), TrackerAxisTick(15, "15"), TrackerAxisTick(10, "10"), TrackerAxisTick(5, "5"), TrackerAxisTick(0, "0"), ], horizontal_lines=[19.5, 14.5, 9.5, 4.5], horizontal_labels=[ TrackerLabel(23, req.wappstring("severe")), TrackerLabel(17, req.wappstring("moderately_severe")), TrackerLabel(12, req.wappstring("moderate")), TrackerLabel(7, req.wappstring("mild")), TrackerLabel(2.25, req.wappstring("none")), ]) ]
def get_task_html(self, req: CamcopsRequest) -> str: return self.get_common_task_html( req, req.wappstring(AS.SATIS_REF_SPEC_RATING_Q), req.wappstring(AS.SATIS_GOOD_Q), req.wappstring(AS.SATIS_BAD_Q), )
def get_task_html(self, req: CamcopsRequest) -> str: min_score = 0 max_score = 3 crippled = not self.extrastrings_exist(req) a = self.anxiety_score() d = self.depression_score() h = """ <div class="{CssClass.SUMMARY}"> <table class="{CssClass.SUMMARY}"> {is_complete_tr} <tr> <td>{sa}</td><td>{a} / {maxa}</td> </tr> <tr> <td>{sd}</td><td>{d} / 21</td> </tr> </table> </div> <div class="{CssClass.EXPLANATION}"> All questions are scored from 0–3 (0 least symptomatic, 3 most symptomatic). </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), sa=req.wappstring("hads_anxiety_score"), a=answer(a), maxa=self.MAX_ANX_SCORE, sd=req.wappstring("hads_depression_score"), d=answer(d), ) for n in range(1, self.NQUESTIONS + 1): if crippled: q = "HADS: Q{}".format(n) else: q = "Q{}. {}".format( n, self.wxstring(req, "q" + str(n) + "_stem")) if n in self.ANXIETY_QUESTIONS: q += " (A)" if n in self.DEPRESSION_QUESTIONS: q += " (D)" v = getattr(self, "q" + str(n)) if crippled or v is None or v < min_score or v > max_score: a = v else: a = "{}: {}".format(v, self.wxstring(req, "q{}_a{}".format(n, v))) h += tr_qa(q, a) h += """ </table> """ + DATA_COLLECTION_UNLESS_UPGRADED_DIV return h
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
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.wappstring("yes"), "N": req.wappstring("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.wappstring("total_score"), answer(score) + " / {}".format(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
def severity(self, req: CamcopsRequest) -> str: score = self.total_score() if score >= 31: return req.wappstring("very_severe") elif score >= 25: return req.wappstring("moderate_to_severe") elif score >= 18: return req.wappstring("mild_to_moderate") else: return req.wappstring("mild")
def severity(self, req: CamcopsRequest) -> str: score = self.total_score() if score >= 15: return req.wappstring("severe") elif score >= 10: return req.wappstring("moderate") elif score >= 5: return req.wappstring("mild") else: return req.wappstring("none")
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)
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)
def get_trackers(self, req: CamcopsRequest) -> List[TrackerInfo]: return [TrackerInfo( value=self.total_score(), plot_label="GAD-7 total score", axis_label="Total score (out of 21)", axis_min=-0.5, axis_max=self.MAX_SCORE + 0.5, horizontal_lines=[14.5, 9.5, 4.5], horizontal_labels=[ TrackerLabel(17, req.wappstring("severe")), TrackerLabel(12, req.wappstring("moderate")), TrackerLabel(7, req.wappstring("mild")), TrackerLabel(2.25, req.wappstring("none")), ] )]
def get_trackers(self, req: CamcopsRequest) -> List[TrackerInfo]: return [ TrackerInfo(value=self.total_score(), plot_label="CIWA total score", axis_label="Total score (out of {})".format( self.MAX_SCORE), axis_min=-0.5, axis_max=self.MAX_SCORE + 0.5, horizontal_lines=[14.5, 7.5], horizontal_labels=[ TrackerLabel(17, req.wappstring("severe")), TrackerLabel(11, req.wappstring("moderate")), TrackerLabel(3.75, req.wappstring("mild")), ]) ]
def get_trackers(self, req: CamcopsRequest) -> List[TrackerInfo]: return [ TrackerInfo( value=self.total_score(), plot_label="HAM-A total score", axis_label="Total score (out of {})".format(self.MAX_SCORE), axis_min=-0.5, axis_max=self.MAX_SCORE + 0.5, horizontal_lines=[30.5, 24.5, 17.5], horizontal_labels=[ TrackerLabel(33, req.wappstring("very_severe")), TrackerLabel(27.5, req.wappstring("moderate_to_severe")), TrackerLabel(21, req.wappstring("mild_to_moderate")), TrackerLabel(8.75, req.wappstring("mild")), ]) ]
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
def get_task_html(self, req: CamcopsRequest) -> str: if self.rating is not None: r = "{}. {}".format(self.rating, self.get_rating_text(req)) else: r = None h = """ <div class="{CssClass.SUMMARY}"> <table class="{CssClass.SUMMARY}"> {tr_is_complete} </table> </div> <table class="{CssClass.TASKDETAIL}"> <tr> <th width="50%">Question</th> <th width="50%">Answer</th> </tr> {service} {rating} </table> """.format( CssClass=CssClass, tr_is_complete=self.get_is_complete_tr(req), service=tr_qa(req.wappstring("satis_service_being_rated"), self.service), rating=tr_qa(self.wxstring(req, "q"), r), ) return h
def category(self, req: CamcopsRequest) -> str: score = self.total_score() if self.highschooleducation == 1: if score >= 27: return req.wappstring("normal") elif score >= 21: return self.wxstring(req, "category_mci") else: return self.wxstring(req, "category_dementia") else: if score >= 25: return req.wappstring("normal") elif score >= 20: return self.wxstring(req, "category_mci") else: return self.wxstring(req, "category_dementia")
def get_trackers(self, req: CamcopsRequest) -> List[TrackerInfo]: return [ TrackerInfo(value=self.total_score(), plot_label="MOCA total score", axis_label="Total score (out of {})".format( self.MAX_SCORE), axis_min=-0.5, axis_max=(self.MAX_SCORE + 0.5), horizontal_lines=[25.5], horizontal_labels=[ TrackerLabel(26, req.wappstring("normal"), LabelAlignment.bottom), TrackerLabel(25, req.wappstring("abnormal"), LabelAlignment.top), ]) ]
def get_trackers(self, req: CamcopsRequest) -> List[TrackerInfo]: return [ TrackerInfo( value=self.total_score(), plot_label="PHQ-15 total score (rating somatic symptoms)", axis_label="Score for Q1-15 (out of {})".format( self.MAX_TOTAL), axis_min=-0.5, axis_max=self.MAX_TOTAL + 0.5, horizontal_lines=[14.5, 9.5, 4.5], horizontal_labels=[ TrackerLabel(22, req.wappstring("severe")), TrackerLabel(12, req.wappstring("moderate")), TrackerLabel(7, req.wappstring("mild")), TrackerLabel(2.25, req.wappstring("none")), ]) ]
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
def get_task_html(self, req: CamcopsRequest) -> str: return """ {clinician_comments} <div class="{CssClass.SUMMARY}"> <table class="{CssClass.SUMMARY}"> {tr_is_complete} {date_pertains_to} {meets_criteria} </table> </div> <div class="{CssClass.EXPLANATION}"> {icd10_symptomatic_disclaimer} </div> <table class="{CssClass.TASKDETAIL}"> <tr> <th width="80%">Question</th> <th width="20%">Answer</th> </tr> {mixture_or_rapid_alternation} {duration_at_least_2_weeks} </table> {ICD10_COPYRIGHT_DIV} """.format( clinician_comments=self.get_standard_clinician_comments_block( req, self.comments), CssClass=CssClass, tr_is_complete=self.get_is_complete_tr(req), date_pertains_to=tr_qa( req.wappstring(AS.DATE_PERTAINS_TO), format_datetime(self.date_pertains_to, DateFormat.LONG_DATE, default=None), ), meets_criteria=tr_qa( req.sstring(SS.MEETS_CRITERIA), get_true_false_none(req, self.meets_criteria()), ), icd10_symptomatic_disclaimer=req.wappstring( AS.ICD10_SYMPTOMATIC_DISCLAIMER), mixture_or_rapid_alternation=self.get_twocol_bool_row_true_false( req, "mixture_or_rapid_alternation", self.wxstring(req, "a")), duration_at_least_2_weeks=self.get_twocol_bool_row_true_false( req, "duration_at_least_2_weeks", self.wxstring(req, "b")), ICD10_COPYRIGHT_DIV=ICD10_COPYRIGHT_DIV, )
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
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
def get_task_html(self, req: CamcopsRequest) -> str: score = self.total_score() likelihood = self.likelihood(req) 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)))) + " — " + str(self.get_score(q))) h = """ <div class="{CssClass.SUMMARY}"> <table class="{CssClass.SUMMARY}"> {tr_is_complete} {total_score} {problem_likelihood} </table> </div> <table class="{CssClass.TASKDETAIL}"> <tr> <th width="80%">Question</th> <th width="20%">Answer</th> </tr> {q_a} </table> <div class="{CssClass.FOOTNOTES}"> [1] Total score ≥3 probable, ≥2 possible, 0–1 unlikely. </div> """.format( CssClass=CssClass, tr_is_complete=self.get_is_complete_tr(req), total_score=tr(req.wappstring("total_score"), answer(score) + " / {}".format(self.NQUESTIONS)), problem_likelihood=tr_qa( self.wxstring(req, "problem_likelihood") + " <sup>[1]</sup>", likelihood), q_a=q_a, ) return h
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"""
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
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
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, http://www.hqlo.com/content/5/1/63; © 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.wappstring("total_score"), answer(self.total_score()) + " (range {}–{})".format( self.MINTOTALSCORE, self.MAXTOTALSCORE ) ), css_explanation=CssClass.EXPLANATION, css_taskdetail=CssClass.TASKDETAIL, q_a=q_a, css_copyright=CssClass.COPYRIGHT, ) return h
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
def get_task_html(self, req: CamcopsRequest) -> str: q_a = self.text_row(req, "a") for i in range(1, self.N_A + 1): q_a += self.get_twocol_bool_row_true_false( req, "a" + str(i), self.wxstring(req, "a" + str(i))) q_a += self.get_twocol_bool_row_true_false(req, "b", self.wxstring(req, "b")) h = """ {clinician_comments} <div class="{CssClass.SUMMARY}"> <table class="{CssClass.SUMMARY}"> {tr_is_complete} {date_pertains_to} {meets_criteria} </table> </div> <table class="{CssClass.TASKDETAIL}"> <tr> <th width="80%">Question</th> <th width="20%">Answer</th> </tr> {q_a} </table> {ICD10_COPYRIGHT_DIV} """.format( clinician_comments=self.get_standard_clinician_comments_block( req, self.comments), CssClass=CssClass, tr_is_complete=self.get_is_complete_tr(req), date_pertains_to=tr_qa( req.wappstring("date_pertains_to"), format_datetime(self.date_pertains_to, DateFormat.LONG_DATE, default=None)), meets_criteria=tr_qa(req.wappstring("meets_criteria"), get_yes_no_none(req, self.meets_criteria())), q_a=q_a, ICD10_COPYRIGHT_DIV=ICD10_COPYRIGHT_DIV, ) return h
def get_description(self, req: CamcopsRequest) -> str: if self.meets_criteria_mania_psychotic_schizophrenic(): return self.wxstring(req, "category_manic_psychotic_schizophrenic") elif self.meets_criteria_mania_psychotic_icd(): return self.wxstring(req, "category_manic_psychotic") elif self.meets_criteria_mania_nonpsychotic(): return self.wxstring(req, "category_manic_nonpsychotic") elif self.meets_criteria_hypomania(): return self.wxstring(req, "category_hypomanic") elif self.meets_criteria_none(): return self.wxstring(req, "category_none") else: return req.wappstring("unknown")