예제 #1
0
 def section_row_html(self, text):
     return tr_span_col(text, cols=3, tr_class="subheading")
예제 #2
0
    def get_task_html(self):
        h = self.get_standard_clinician_block() + u"""
            <div class="summary">
                <table class="summary">
                    {}
                </table>
            </div>
            <table class="taskdetail">
                <col width="40%">
                <col width="60%">
        """.format(
            self.get_is_complete_tr(),
        )
        h += tr_qa(WSTRING("cpft_lps_dis_discharge_date"),
                   format_datetime_string(self.discharge_date,
                                          DATEFORMAT.LONG_DATE_WITH_DAY,
                                          default=None), "")
        h += tr_qa(WSTRING("cpft_lps_dis_discharge_reason"),
                   self.get_discharge_reason(), "")
        h += tr_qa(
            WSTRING("cpft_lps_dis_leaflet_or_discharge_card_given"),
            get_yes_no_none(self.leaflet_or_discharge_card_given), "")
        h += tr_qa(WSTRING("cpft_lps_dis_frequent_attender"),
                   get_yes_no_none(self.frequent_attender), "")
        h += tr_qa(
            WSTRING("cpft_lps_dis_patient_wanted_copy_of_letter"),
            self.patient_wanted_copy_of_letter, "")
        h += tr_qa(WSTRING("cpft_lps_dis_gaf_at_first_assessment"),
                   self.gaf_at_first_assessment, "")
        h += tr_qa(WSTRING("cpft_lps_dis_gaf_at_discharge"),
                   self.gaf_at_discharge, "")

        h += subheading_spanning_two_columns(
            WSTRING("cpft_lps_dis_referral_reason_t"))
        h += tr_span_col(answer(", ".join(self.get_referral_reasons())),
                         cols=2)
        h += tr_qa(
            WSTRING("cpft_lps_dis_referral_reason_transplant_organ"),
            self.referral_reason_transplant_organ, "")
        h += tr_qa(
            WSTRING("cpft_lps_dis_referral_reason_other_detail"),
            self.referral_reason_other_detail, "")

        h += subheading_spanning_two_columns(
            WSTRING("cpft_lps_dis_diagnoses_t"))
        h += tr_qa(WSTRING("cpft_lps_dis_psychiatric_t"),
                   "<br>".join(self.get_psychiatric_diagnoses()), "")
        h += tr_qa(WSTRING("cpft_lps_dis_medical_t"),
                   "<br>".join(self.get_medical_diagnoses()), "")

        h += subheading_spanning_two_columns(
            WSTRING("cpft_lps_dis_management_t"))
        h += tr_span_col(answer(", ".join(self.get_managements())), cols=2)
        h += tr_qa(WSTRING("cpft_lps_dis_management_other_detail"),
                   self.management_other_detail, "")

        h += subheading_spanning_two_columns(WSTRING("cpft_lps_dis_outcome_t"))
        h += tr_qa(WSTRING("cpft_lps_dis_outcome_t"),
                   self.outcome, "")
        h += tr_qa(
            WSTRING("cpft_lps_dis_outcome_hospital_transfer_detail"),
            self.outcome_hospital_transfer_detail, "")
        h += tr_qa(WSTRING("cpft_lps_dis_outcome_other_detail"),
                   self.outcome_other_detail, "")

        h += u"""
            </table>
        """
        return h
예제 #3
0
 def get_task_html(self):
     SEVERITY_DICT = {
         None: None,
         1: WSTRING("cgisch_i_option1"),
         2: WSTRING("cgisch_i_option2"),
         3: WSTRING("cgisch_i_option3"),
         4: WSTRING("cgisch_i_option4"),
         5: WSTRING("cgisch_i_option5"),
         6: WSTRING("cgisch_i_option6"),
         7: WSTRING("cgisch_i_option7"),
     }
     CHANGE_DICT = {
         None: None,
         1: WSTRING("cgisch_ii_option1"),
         2: WSTRING("cgisch_ii_option2"),
         3: WSTRING("cgisch_ii_option3"),
         4: WSTRING("cgisch_ii_option4"),
         5: WSTRING("cgisch_ii_option5"),
         6: WSTRING("cgisch_ii_option6"),
         7: WSTRING("cgisch_ii_option7"),
         9: WSTRING("cgisch_ii_option9"),
     }
     h = self.get_standard_clinician_block() + u"""
         <div class="summary">
             <table class="summary">
                 {}
             </table>
         </div>
         <table class="taskdetail">
             <tr>
                 <th width="70%">Question</th>
                 <th width="30%">Answer <sup>[1]</sup></th>
             </tr>
     """.format(self.get_is_complete_tr())
     h += subheading_spanning_two_columns(WSTRING("cgisch_i_title"))
     h += tr_span_col(WSTRING("cgisch_i_question"), cols=2)
     h += tr_qa(WSTRING("cgisch_q1"),
                get_from_dict(SEVERITY_DICT, self.severity1))
     h += tr_qa(WSTRING("cgisch_q2"),
                get_from_dict(SEVERITY_DICT, self.severity2))
     h += tr_qa(WSTRING("cgisch_q3"),
                get_from_dict(SEVERITY_DICT, self.severity3))
     h += tr_qa(WSTRING("cgisch_q4"),
                get_from_dict(SEVERITY_DICT, self.severity4))
     h += tr_qa(WSTRING("cgisch_q5"),
                get_from_dict(SEVERITY_DICT, self.severity5))
     h += subheading_spanning_two_columns(WSTRING("cgisch_ii_title"))
     h += tr_span_col(WSTRING("cgisch_ii_question"), cols=2)
     h += tr_qa(WSTRING("cgisch_q1"),
                get_from_dict(CHANGE_DICT, self.change1))
     h += tr_qa(WSTRING("cgisch_q2"),
                get_from_dict(CHANGE_DICT, self.change2))
     h += tr_qa(WSTRING("cgisch_q3"),
                get_from_dict(CHANGE_DICT, self.change3))
     h += tr_qa(WSTRING("cgisch_q4"),
                get_from_dict(CHANGE_DICT, self.change4))
     h += tr_qa(WSTRING("cgisch_q5"),
                get_from_dict(CHANGE_DICT, self.change5))
     h += u"""
         </table>
         <div class="footnotes">
             [1] All questions are scored 1–7, or 9 (not applicable, for
             change questions).
             {postscript}
         </div>
     """.format(
         postscript=WSTRING("cgisch_ii_postscript"),
     )
     return h
예제 #4
0
    def get_task_html(self):
        PERSON_MARITAL_STATUS = get_nhs_dd_person_marital_status()
        ETHNIC_CATEGORY_CODE = get_nhs_dd_ethnic_category_code()
        if self.lps_division == "G":
            banner_class = "banner_referral_general_adult"
            division_name = WSTRING("cpft_lps_service_G")
        elif self.lps_division == "O":
            banner_class = "banner_referral_old_age"
            division_name = WSTRING("cpft_lps_service_O")
        elif self.lps_division == "S":
            banner_class = "banner_referral_substance_misuse"
            division_name = WSTRING("cpft_lps_service_S")
        else:
            banner_class = ""
            division_name = None

        if self.referral_priority == "R":
            priority_name = WSTRING("cpft_lps_referral_priority_R")
        elif self.referral_priority == "U":
            priority_name = WSTRING("cpft_lps_referral_priority_U")
        elif self.referral_priority == "E":
            priority_name = WSTRING("cpft_lps_referral_priority_E")
        else:
            priority_name = None

        potential_admission_reasons = [
            "admission_reason_overdose",
            "admission_reason_self_harm_not_overdose",
            "admission_reason_confusion",
            "admission_reason_trauma",
            "admission_reason_falls",
            "admission_reason_infection",
            "admission_reason_poor_adherence",
            "admission_reason_other",
        ]
        admission_reasons = []
        for r in potential_admission_reasons:
            if getattr(self, r):
                admission_reasons.append(WSTRING("cpft_lps_referral_f_" + r))

        h = u"""
            <div class="banner {}">{} referral at {}</div>
            <div class="summary">
                <table class="summary">
                    {}
                </table>
            </div>
            <table class="taskdetail">
                <col width="25%">
                <col width="25%">
                <col width="25%">
                <col width="25%">
        """.format(
            banner_class,
            answer(division_name, default_for_blank_strings=True),
            answer(format_datetime_string(
                self.referral_date_time,
                DATEFORMAT.SHORT_DATETIME_WITH_DAY_NO_TZ,
                default=None)),
            self.get_is_complete_tr(),
        )
        h += subheading_spanning_four_columns(
            WSTRING("cpft_lps_referral_t_about_referral"))
        h += u"""
            <tr>
                <td>{}</td><td>{}</td>
                <td>{}</td><td class="highlight">{}</td>
            </tr>
        """.format(
            WSTRING("cpft_lps_referral_f_referral_method"),
            answer(self.referral_method),
            WSTRING("cpft_lps_referral_f_referral_priority"),
            answer(self.referral_priority, default_for_blank_strings=True)
            + ": " + answer(priority_name)
        )
        h += self.four_column_row(
            WSTRING("cpft_lps_referral_f_referrer_name"),
            self.referrer_name,
            WSTRING("cpft_lps_referral_f_referring_specialty"),
            self.referring_specialty
        )
        h += self.four_column_row(
            WSTRING("cpft_lps_referral_f_referrer_contact_details"),
            self.referrer_contact_details,
            WSTRING("cpft_lps_referral_f_referring_specialty_other"),
            self.referring_specialty_other
        )
        h += self.four_column_row(
            WSTRING("cpft_lps_referral_f_referring_consultant"),
            self.referring_consultant,
            "",
            ""
        )
        h += subheading_spanning_four_columns(
            WSTRING("cpft_lps_referral_t_patient"))
        h += u"""
            <tr>
                <td>{}</td><td>{}</td>
                <td>{}</td><td class="highlight">{}</td>
            </tr>
        """.format(
            WSTRING("cpft_lps_referral_f_admission_date"),
            answer(format_datetime_string(self.admission_date,
                                          DATEFORMAT.LONG_DATE,
                                          default=None), ""),
            WSTRING("cpft_lps_referral_f_patient_location"),
            answer(self.patient_location)
        )
        h += self.four_column_row(
            WSTRING("cpft_lps_referral_f_estimated_discharge_date"),
            format_datetime_string(self.estimated_discharge_date,
                                   DATEFORMAT.LONG_DATE, ""),
            WSTRING("cpft_lps_referral_f_patient_aware_of_referral"),
            get_yes_no_none(self.patient_aware_of_referral)
        )
        h += self.four_column_row(
            WSTRING("cpft_lps_referral_f_marital_status"),
            PERSON_MARITAL_STATUS.get(self.marital_status_code, INVALID_VALUE),
            WSTRING("cpft_lps_referral_f_interpreter_required"),
            get_yes_no_none(self.interpreter_required)
        )
        h += self.four_column_row(
            WSTRING("cpft_lps_referral_f_ethnic_category"),
            ETHNIC_CATEGORY_CODE.get(self.ethnic_category_code, INVALID_VALUE),
            WSTRING("cpft_lps_referral_f_sensory_impairment"),
            get_yes_no_none(self.sensory_impairment)
        )
        h += subheading_spanning_four_columns(
            WSTRING("cpft_lps_referral_t_admission_reason"))
        h += tr_span_col(answer(u", ".join(admission_reasons), ""), cols=4)
        h += subheading_spanning_four_columns(
            WSTRING("cpft_lps_referral_t_other_people"))
        h += self.tr_qa(
            WSTRING("cpft_lps_referral_f_existing_psychiatric_teams"),
            self.existing_psychiatric_teams, "")
        h += self.tr_qa(
            WSTRING("cpft_lps_referral_f_care_coordinator"),
            self.care_coordinator, "")
        h += self.tr_qa(
            WSTRING("cpft_lps_referral_f_other_contact_details"),
            self.other_contact_details, "")
        h += subheading_spanning_four_columns(
            WSTRING("cpft_lps_referral_t_referral_reason"))
        h += tr_span_col(answer(self.referral_reason, ""), cols=4)
        h += u"""
            </table>
        """
        return h
예제 #5
0
    def get_task_html(self):
        a = self.attn_score()
        m = self.mem_score()
        f = self.fluency_score()
        l = self.lang_score()
        v = self.vsp_score()
        t = a + m + f + l + v
        figurehtml = ""
        if self.is_complete():
            FIGSIZE = (FULLWIDTH_PLOT_WIDTH/3, FULLWIDTH_PLOT_WIDTH/4)
            WIDTH = 0.9
            fig = plt.figure(figsize=FIGSIZE)
            ax = fig.add_subplot(1, 1, 1)
            scores = numpy.array([a, m, f, l, v])
            maxima = numpy.array([18, 26, 14, 26, 16])
            y = 100 * scores/maxima
            x_labels = ["Attn", "Mem", "Flu", "Lang", "VSp"]
            N = len(y)
            xvar = numpy.arange(N)
            ax.bar(xvar, y, WIDTH, color="b")
            ax.set_ylabel("%")
            ax.set_xticks(xvar + WIDTH/2)
            ax.set_xticklabels(x_labels)
            ax.set_xlim(0 - (1 - WIDTH), len(scores))
            plt.tight_layout()  # or the ylabel drops off the figure
            # fig.autofmt_xdate()
            figurehtml = get_html_from_pyplot_figure(fig)
        return (
            self.get_standard_clinician_block(True, self.comments)
            + u"""
                <div class="summary">
                    <table class="summary">
                        <tr>
                            {is_complete}
                            <td class="figure" rowspan="7">{figure}</td>
                        </td>
            """.format(is_complete=self.get_is_complete_td_pair(),
                       figure=figurehtml)
            + tr("Total ACE-III score <sup>[1]</sup>", answer(t) + " / 100")
            + tr("Attention", answer(a) + " / 18 ({}%)".format(100*a/18))
            + tr("Memory", answer(m) + " / 26 ({}%)".format(100*m/26))
            + tr("Fluency", answer(f) + " / 14 ({}%)".format(100*f/14))
            + tr("Language", answer(l) + " / 26 ({}%)".format(100*l/26))
            + tr("Visuospatial", answer(v) + " / 16 ({}%)".format(100*v/16))
            + u"""
                    </table>
                </div>
                <table class="taskdetail">
                    <tr>
                        <th width="75%">Question</th>
                        <th width="25%">Answer/score</td>
                    </tr>
            """
            + tr_qa("Age on leaving full-time education",
                    self.age_at_leaving_full_time_education)
            + tr_qa("Occupation", ws.webify(self.occupation))
            + tr_qa("Handedness", ws.webify(self.handedness))

            + subheading_spanning_two_columns("Attention")
            + tr("Day? Date? Month? Year? Season?",
                 u", ".join([answer(x) for x in [self.attn_time1,
                                                 self.attn_time2,
                                                 self.attn_time3,
                                                 self.attn_time4,
                                                 self.attn_time5]]))
            + tr("House number/floor? Street/hospital? Town? County? Country?",
                 u", ".join([answer(x) for x in [self.attn_place1,
                                                 self.attn_place2,
                                                 self.attn_place3,
                                                 self.attn_place4,
                                                 self.attn_place5]]))
            + tr("Repeat: Lemon? Key? Ball?",
                 u", ".join([answer(x) for x in [self.attn_repeat_word1,
                                                 self.attn_repeat_word2,
                                                 self.attn_repeat_word3]]))
            + tr("Repetition: number of trials <i>(not scored)</i>",
                 answer(self.attn_num_registration_trials,
                        formatter_answer=italic))
            + tr(
                "Serial subtractions: First correct? Second? Third? Fourth? "
                "Fifth?",
                u", ".join([answer(x) for x in [
                    self.attn_serial7_subtraction1,
                    self.attn_serial7_subtraction2,
                    self.attn_serial7_subtraction3,
                    self.attn_serial7_subtraction4,
                    self.attn_serial7_subtraction5]]))

            + subheading_spanning_two_columns("Memory (1)")
            + tr("Recall: Lemon? Key? Ball?",
                 u", ".join([answer(x) for x in [self.mem_recall_word1,
                                                 self.mem_recall_word2,
                                                 self.mem_recall_word3]]))

            + subheading_spanning_two_columns("Fluency")
            + tr(u"Score for words beginning with ‘P’ <i>(≥18 scores 7, 14–17 "
                 u"scores 6, 11–13 scores 5, 8–10 scores 4, 6–7 scores 3, "
                 u"4–5 scores 2, 2–3 scores 1, 0–1 scores 0)</i>",
                 answer(self.fluency_letters_score) + " / 7")
            + tr(u"Score for animals <i>(≥22 scores 7, 17–21 scores 6, "
                 u"14–16 scores 5, 11–13 scores 4, 9–10 scores 3, "
                 u"7–8 scores 2, 5–6 scores 1, &lt;5 scores 0)</i>",
                 answer(self.fluency_animals_score) + " / 7")

            + subheading_spanning_two_columns("Memory (2)")
            + tr(
                "Third trial of address registration: Harry? Barnes? 73? "
                "Orchard? Close? Kingsbridge? Devon?",
                u", ".join([answer(x) for x in [
                    self.mem_repeat_address_trial3_1,
                    self.mem_repeat_address_trial3_2,
                    self.mem_repeat_address_trial3_3,
                    self.mem_repeat_address_trial3_4,
                    self.mem_repeat_address_trial3_5,
                    self.mem_repeat_address_trial3_6,
                    self.mem_repeat_address_trial3_7]]))
            + tr("Current PM? Woman who was PM? USA president? USA president "
                 "assassinated in 1960s?",
                 u", ".join([answer(x) for x in [self.mem_famous1,
                                                 self.mem_famous2,
                                                 self.mem_famous3,
                                                 self.mem_famous4]]))

            + subheading_spanning_two_columns("Language")
            + tr(u"<i>Practice trial (“Pick up the pencil and then the "
                 u"paper”)</i>",
                 answer(self.lang_follow_command_practice,
                        formatter_answer=italic))
            + tr_qa(u"“Place the paper on top of the pencil”",
                    self.lang_follow_command1)
            + tr_qa(u"“Pick up the pencil but not the paper”",
                    self.lang_follow_command2)
            + tr_qa(u"“Pass me the pencil after touching the paper”",
                    self.lang_follow_command3)
            + tr(
                u"Sentence-writing: point for ≥2 complete sentences about "
                u"the one topic? Point for correct grammar and spelling?",
                u", ".join([answer(x) for x in [
                    self.lang_write_sentences_point1,
                    self.lang_write_sentences_point2]]))
            + tr(
                u"Repeat: caterpillar? eccentricity? unintelligible? "
                u"statistician? <i>(score 2 if all correct, 1 if 3 correct, "
                u"0 if ≤2 correct)</i>",
                u"<i>{}, {}, {}, {}</i> (score <b>{}</b> / 2)".format(
                    answer(self.lang_repeat_word1, formatter_answer=italic),
                    answer(self.lang_repeat_word2, formatter_answer=italic),
                    answer(self.lang_repeat_word3, formatter_answer=italic),
                    answer(self.lang_repeat_word4, formatter_answer=italic),
                    self.get_repeat_word_score(),
                ))
            + tr_qa(u"Repeat: “All that glitters is not gold”?",
                    self.lang_repeat_sentence1)
            + tr_qa(u"Repeat: “A stitch in time saves nine”?",
                    self.lang_repeat_sentence2)
            + tr("Name pictures: spoon, book, kangaroo/wallaby",
                 u", ".join([answer(x) for x in [self.lang_name_picture1,
                                                 self.lang_name_picture2,
                                                 self.lang_name_picture3]]))
            + tr("Name pictures: penguin, anchor, camel/dromedary",
                 u", ".join([answer(x) for x in [self.lang_name_picture4,
                                                 self.lang_name_picture5,
                                                 self.lang_name_picture6]]))
            + tr("Name pictures: harp, rhinoceros/rhino, barrel/keg/tub",
                 u", ".join([answer(x) for x in [self.lang_name_picture7,
                                                 self.lang_name_picture8,
                                                 self.lang_name_picture9]]))
            + tr("Name pictures: crown, alligator/crocodile, "
                 "accordion/piano accordion/squeeze box",
                 u", ".join([answer(x) for x in [self.lang_name_picture10,
                                                 self.lang_name_picture11,
                                                 self.lang_name_picture12]]))
            + tr(
                "Identify pictures: monarchy? marsupial? Antarctic? nautical?",
                u", ".join([answer(x) for x in [self.lang_identify_concept1,
                                                self.lang_identify_concept2,
                                                self.lang_identify_concept3,
                                                self.lang_identify_concept4]]))
            + tr_qa("Read all successfully: sew, pint, soot, dough, height",
                    self.lang_read_words_aloud)

            + subheading_spanning_two_columns("Visuospatial")
            + tr("Copy infinity", answer(self.vsp_copy_infinity) + " / 1")
            + tr("Copy cube", answer(self.vsp_copy_cube) + " / 2")
            + tr("Draw clock with numbers and hands at 5:10",
                 answer(self.vsp_draw_clock) + " / 5")
            + tr("Count dots: 8, 10, 7, 9",
                 u", ".join([answer(x) for x in [self.vsp_count_dots1,
                                                 self.vsp_count_dots2,
                                                 self.vsp_count_dots3,
                                                 self.vsp_count_dots4]]))
            + tr("Identify letters: K, M, A, T",
                 u", ".join([answer(x) for x in [self.vsp_identify_letter1,
                                                 self.vsp_identify_letter2,
                                                 self.vsp_identify_letter3,
                                                 self.vsp_identify_letter4]]))

            + subheading_spanning_two_columns("Memory (3)")
            + tr("Recall address: Harry? Barnes? 73? Orchard? Close? "
                 "Kingsbridge? Devon?",
                 u", ".join([answer(x) for x in [self.mem_recall_address1,
                                                 self.mem_recall_address2,
                                                 self.mem_recall_address3,
                                                 self.mem_recall_address4,
                                                 self.mem_recall_address5,
                                                 self.mem_recall_address6,
                                                 self.mem_recall_address7]]))
            + tr("Recognize address: Jerry Barnes/Harry Barnes/Harry "
                 "Bradford?",
                 self.get_recog_text((self.mem_recall_address1 == 1
                                      and self.mem_recall_address2 == 1),
                                     self.mem_recognize_address1))
            + tr("Recognize address: 37/73/76?",
                 self.get_recog_text((self.mem_recall_address3 == 1),
                                     self.mem_recognize_address2))
            + tr(
                "Recognize address: Orchard Place/Oak Close/Orchard "
                "Close?",
                self.get_recog_text(
                    (self.mem_recall_address4 == 1
                     and self.mem_recall_address5 == 1),
                    self.mem_recognize_address3))
            + tr("Recognize address: Oakhampton/Kingsbridge/Dartington?",
                 self.get_recog_text((self.mem_recall_address6 == 1),
                                     self.mem_recognize_address4))
            + tr("Recognize address: Devon/Dorset/Somerset?",
                 self.get_recog_text((self.mem_recall_address7 == 1),
                                     self.mem_recognize_address5))

            + subheading_spanning_two_columns("Photos of test sheet")
            + tr_span_col(self.get_blob_png_html(self.picture1_blobid,
                                                 self.picture1_rotation),
                          td_class="photo")
            + tr_span_col(self.get_blob_png_html(self.picture2_blobid,
                                                 self.picture2_rotation),
                          td_class="photo")
            + u"""
                </table>
                <div class="footnotes">
                    [1] In the ACE-R (the predecessor of the ACE-III),
                    scores ≤82 had sensitivity 0.84 and specificity 1.0 for
                    dementia, and scores ≤88 had sensitivity 0.94 and
                    specificity 0.89 for dementia, in a context of patients
                    with AlzD, FTD, LBD, MCI, and controls
                    (Mioshi et al., 2006, PMID 16977673).
                </div>
                <div class="copyright">
                    ACE-III: Copyright © 2012, John Hodges.
                    “The ACE-III is available for free. The copyright is held
                    by Professor John Hodges who is happy for the test to be
                    used in clinical practice and research projects. There is
                    no need to contact us if you wish to use the ACE-III in
                    clinical practice.”
                    (ACE-III FAQ, 7 July 2013, www.neura.edu.au).
                </div>
            """
        )