Пример #1
0
 def get_task_html(self):
     h = u"""
         <div class="summary">
             <table class="summary">
     """
     h += self.get_is_complete_tr()
     h += tr_qa(u"Overall distress (0–10)", self.distress)
     h += u"""
             </table>
         </div>
         <div class="explanation">
             All questions relate to distress/problems “in the past week,
             including today” (yes = problem, no = no problem).
         </div>
         <table class="taskdetail">
             <tr>
                 <th width="50%">Question</th>
                 <th width="50%">Answer</th>
             </tr>
     """
     h += tr_qa(u"Distress (0 no distress – 10 extreme distress)",
                self.distress)
     h += subheading_spanning_two_columns("Practical problems")
     for i in range(1, 5 + 1):
         h += tr_qa(
             u"{}. {}".format(i, WSTRING("distressthermometer_q" + str(i))),
             get_yes_no_none(getattr(self, "q" + str(i)))
         )
     h += subheading_spanning_two_columns("Family problems")
     for i in range(6, 8 + 1):
         h += tr_qa(
             u"{}. {}".format(i, WSTRING("distressthermometer_q" + str(i))),
             get_yes_no_none(getattr(self, "q" + str(i)))
         )
     h += subheading_spanning_two_columns("Emotional problems")
     for i in range(9, 14 + 1):
         h += tr_qa(
             u"{}. {}".format(i, WSTRING("distressthermometer_q" + str(i))),
             get_yes_no_none(getattr(self, "q" + str(i)))
         )
     h += subheading_spanning_two_columns("Spiritual problems")
     for i in range(15, 15 + 1):
         h += tr_qa(
             u"{}. {}".format(i, WSTRING("distressthermometer_q" + str(i))),
             get_yes_no_none(getattr(self, "q" + str(i)))
         )
     h += subheading_spanning_two_columns("Physical problems")
     for i in range(16, DistressThermometer.NQUESTIONS + 1):
         h += tr_qa(
             u"{}. {}".format(i, WSTRING("distressthermometer_q" + str(i))),
             get_yes_no_none(getattr(self, "q" + str(i)))
         )
     h += subheading_spanning_two_columns("Other problems")
     h += tr_qa(WSTRING("distressthermometer_other_s"), self.other)
     h += u"""
         </table>
     """
     return h
Пример #2
0
 def get_task_html(self):
     score = self.total_score()
     exceeds_cutoff = score >= 2
     h = u"""
         <div class="summary">
             <table class="summary">
     """ + self.get_is_complete_tr()
     h += tr(WSTRING("total_score"), answer(score) + " / 4")
     h += tr_qa(WSTRING("cage_over_threshold"), get_yes_no(exceeds_cutoff))
     h += u"""
             </table>
         </div>
         <table class="taskdetail">
             <tr>
                 <th width="70%">Question</th>
                 <th width="30%">Answer</th>
             </tr>
     """
     for q in range(1, Cage.NQUESTIONS + 1):
         h += tr_qa(str(q) + u" — " + WSTRING("cage_q" + str(q)),
                    get_yes_no_none(getattr(self, "q" + str(q))))
     h += u"""
         </table>
     """
     return h
Пример #3
0
 def get_task_html(self):
     h = self.get_standard_clinician_block(True, self.comments) + u"""
         <div class="summary">
             <table class="summary">
     """ + self.get_is_complete_tr()
     h += tr_qa(WSTRING("date_pertains_to"),
                format_datetime_string(self.date_pertains_to,
                                       DATEFORMAT.LONG_DATE, default=None))
     h += tr_qa(WSTRING("meets_criteria"),
                get_yes_no_none(self.meets_criteria()))
     h += u"""
             </table>
         </div>
         <table class="taskdetail">
             <tr>
                 <th width="80%">Question</th>
                 <th width="20%">Answer</th>
             </tr>
     """
     h += self.text_row("icd10schizotypal_a")
     for i in range(1, Icd10Schizotypal.N_A + 1):
         h += self.get_twocol_bool_row_true_false(
             "a" + str(i), WSTRING("icd10schizotypal_a" + str(i)))
     h += self.get_twocol_bool_row_true_false(
         "b", WSTRING("icd10schizotypal_b"))
     h += u"""
         </table>
     """ + ICD10_COPYRIGHT_DIV
     return h
Пример #4
0
 def get_task_html(self):
     h = u"""
         <div class="summary">
             <table class="summary">
     """ + self.get_is_complete_tr()
     h += tr_qa("Utility", ws.number_to_dp(self.utility, DP, default=None))
     h += u"""
             </table>
         </div>
         <div class="explanation">
             Quality of life (QoL) has anchor values of 0 (none) and 1
             (perfect health). The Standard Gamble offers a trade-off to
             determine utility (QoL).
             Values &lt;0 and &gt;1 are possible with some gambles.
         </div>
         <table class="taskdetail">
             <tr><th width="50%">Measure</th><th width="50%">Value</th></tr>
     """
     h += tr_qa("Category choice: start time", self.category_start_time)
     h += tr_qa("Category choice: responded?",
                get_yes_no_none(self.category_responded))
     h += tr_qa("Category choice: response time",
                self.category_response_time)
     h += tr_qa("Category choice: category chosen", self.category_chosen)
     h += tr_qa("Gamble: fixed option", self.gamble_fixed_option)
     h += tr_qa("Gamble: lottery option for <i>p</i>",
                self.gamble_lottery_option_p)
     h += tr_qa(u"Gamble: lottery option for <i>q</i> = 1 – <i>p</i>",
                self.gamble_lottery_option_q)
     h += tr_qa("Gamble: lottery on left?",
                get_yes_no_none(self.gamble_lottery_on_left))
     h += tr_qa("Gamble: starting <i>p</i>", self.gamble_starting_p)
     h += tr_qa("Gamble: start time", self.gamble_start_time)
     h += tr_qa("Gamble: responded?",
                get_yes_no_none(self.gamble_responded))
     h += tr_qa("Gamble: response time", self.gamble_response_time)
     h += tr_qa("Gamble: <i>p</i>",
                ws.number_to_dp(self.gamble_p, DP, default=None))
     h += tr_qa("Calculated utility",
                ws.number_to_dp(self.utility, DP, default=None))
     h += u"""
         </table>
     """
     return h
Пример #5
0
 def get_task_html(self):
     h = (
         self.get_standard_clinician_block()
         + u"""
         <table class="taskdetail">
             <tr>
                 <td width="33%">Location:</td>
                 <td width="67%"><b>{}</b></td>
             </tr>
     """.format(
             ws.webify(self.location)
         )
     )
     h += tr_qa("Start:", format_datetime_string(self.start, DATEFORMAT.SHORT_DATETIME, None))
     h += tr_qa("End:", format_datetime_string(self.end, DATEFORMAT.SHORT_DATETIME, None))
     h += tr(italic("Calculated duration (hours:minutes)"), italic(get_duration_h_m(self.start, self.end)))
     h += tr_qa("Patient contact?", get_yes_no_none(self.patient_contact))
     h += tr_qa("Staff liaison?", get_yes_no_none(self.staff_liaison))
     h += tr_qa("Other liaison?", get_yes_no_none(self.other_liaison))
     h += tr_qa("Comment:", ws.webify(self.comment))
     return h
Пример #6
0
    def get_task_html(self):
        stagearray = self.get_stage_array()
        trialarray = self.get_trial_array()
        # THIS IS A NON-EDITABLE TASK, so we *ignore* the problem
        # of matching to no-longer-current records.
        # (See PhotoSequence.py for a task that does it properly.)

        # Provide HTML
        # HTML
        h = u"""
            <div class="summary">
                <table class="summary">
                    {}
                </table>
            </div>
            <div class="explanation">
                1. Simple discrimination (SD), and 2. reversal (SDr);
                3. compound discrimination (CD), and 4. reversal (CDr);
                5. intradimensional shift (ID), and 6. reversal (IDr);
                7. extradimensional shift (ED), and 8. reversal (EDr).
            </div>
            <table class="taskconfig">
                <tr>
                    <th width="50%">Configuration variable</th>
                    <th width="50%">Value</th>
                </tr>
        """.format(
            self.get_is_complete_tr(),
        )
        h += tr_qa(WSTRING("ided3d_last_stage"), self.last_stage)
        h += tr_qa(WSTRING("ided3d_max_trials_per_stage"),
                   self.max_trials_per_stage)
        h += tr_qa(WSTRING("ided3d_progress_criterion_x"),
                   self.progress_criterion_x)
        h += tr_qa(WSTRING("ided3d_progress_criterion_y"),
                   self.progress_criterion_y)
        h += tr_qa(WSTRING("ided3d_min_number"), self.min_number)
        h += tr_qa(WSTRING("ided3d_max_number"), self.max_number)
        h += tr_qa(WSTRING("ided3d_pause_after_beep_ms"),
                   self.pause_after_beep_ms)
        h += tr_qa(WSTRING("ided3d_iti_ms"), self.iti_ms)
        h += tr_qa(WSTRING("ided3d_counterbalance_dimensions")
                   + u"<sup>[1]</sup>",
                   self.counterbalance_dimensions)
        h += tr_qa(WSTRING("volume"), self.volume)
        h += tr_qa(WSTRING("ided3d_offer_abort"), self.offer_abort)
        h += tr_qa(WSTRING("ided3d_debug_display_stimuli_only"),
                   self.debug_display_stimuli_only)
        h += tr_qa(u"Shapes (as a JSON-encoded array of SVG "
                   u"definitions; X and Y range both –60 to +60)",
                   ws.webify(self.shape_definitions_svg))
        h += u"""
            </table>
            <table class="taskdetail">
                <tr><th width="50%">Measure</th><th width="50%">Value</th></tr>
        """
        h += tr_qa("Aborted?", get_yes_no_none(self.aborted))
        h += tr_qa("Finished?", get_yes_no_none(self.finished))
        h += tr_qa("Last trial completed", self.last_trial_completed)
        h += (
            u"""
                </table>
                <div>Stage specifications and results:</div>
            """
            + self.get_stage_html(stagearray)
            + u"<div>Trial-by-trial results:</div>"
            + self.get_trial_html(trialarray)
            + u"""
                <div class="footnotes">
                    [1] Counterbalancing of dimensions is as follows, with
                    notation X/Y indicating that X is the first relevant
                    dimension (for stages SD–IDr) and Y is the second relevant
                    dimension (for stages ED–EDr).
                    0: shape/colour.
                    1: colour/number.
                    2: number/shape.
                    3: shape/number.
                    4: colour/shape.
                    5: number/colour.
                </div>
            """
        )
        return h
Пример #7
0
 def get_task_html(self):
     DICTQ1 = {None: None}
     DICTQ3 = {None: None}
     DICTQ4 = {None: None}
     DICTQ5 = {None: None}
     DICTQ11 = {None: None}
     DICTQ12 = {None: None}
     for option in range(1, 5):
         DICTQ1[option] = WSTRING("gmcpq_q1_option" + str(option))
     for option in range(1, 6):
         DICTQ3[option] = WSTRING("gmcpq_q3_option" + str(option))
         DICTQ11[option] = WSTRING("gmcpq_q11_option" + str(option))
     for option in range(0, 6):
         prefix = str(option) + u" – " if option > 0 else ""
         DICTQ4[option] = prefix + WSTRING("gmcpq_q4_option" + str(option))
         DICTQ5[option] = prefix + WSTRING("gmcpq_q5_option" + str(option))
     for option in range(1, 17):
         DICTQ12[option] = WSTRING("gmcpq_ethnicity_option" + str(option))
     h = u"""
         <div class="summary">
             <table class="summary">
                 {}
             </table>
         </div>
         <table class="taskdetail">
             <tr>
                 <th width="60%">Question</th>
                 <th width="40%">Answer</th>
             </tr>
     """.format(self.get_is_complete_tr())
     ell = "&hellip; "  # horizontal ellipsis
     sep_row = subheading_spanning_two_columns("")
     blank_cell = td("", td_class="subheading")
     h += tr_qa(WSTRING("gmcpq_q_doctor"), ws.webify(self.doctor))
     h += sep_row
     h += tr_qa(WSTRING("gmcpq_q1"), get_from_dict(DICTQ1, self.q1))
     h += tr(td(WSTRING("gmcpq_q2")), blank_cell, literal=True)
     h += tr_qa(ell + WSTRING("gmcpq_q2_a"), get_yes_no_none(self.q2a))
     h += tr_qa(ell + WSTRING("gmcpq_q2_b"), get_yes_no_none(self.q2b))
     h += tr_qa(ell + WSTRING("gmcpq_q2_c"), get_yes_no_none(self.q2c))
     h += tr_qa(ell + WSTRING("gmcpq_q2_d"), get_yes_no_none(self.q2d))
     h += tr_qa(ell + WSTRING("gmcpq_q2_e"), get_yes_no_none(self.q2e))
     h += tr_qa(ell + WSTRING("gmcpq_q2_f"), get_yes_no_none(self.q2f))
     h += tr_qa(ell + ell + WSTRING("gmcpq_q2f_s"),
                ws.webify(self.q2f_details))
     h += tr_qa(WSTRING("gmcpq_q3"), get_from_dict(DICTQ3, self.q3))
     h += tr(td(WSTRING("gmcpq_q4")), blank_cell, literal=True)
     h += tr_qa(ell + WSTRING("gmcpq_q4_a"),
                get_from_dict(DICTQ4, self.q4a))
     h += tr_qa(ell + WSTRING("gmcpq_q4_b"),
                get_from_dict(DICTQ4, self.q4b))
     h += tr_qa(ell + WSTRING("gmcpq_q4_c"),
                get_from_dict(DICTQ4, self.q4c))
     h += tr_qa(ell + WSTRING("gmcpq_q4_d"),
                get_from_dict(DICTQ4, self.q4d))
     h += tr_qa(ell + WSTRING("gmcpq_q4_e"),
                get_from_dict(DICTQ4, self.q4e))
     h += tr_qa(ell + WSTRING("gmcpq_q4_f"),
                get_from_dict(DICTQ4, self.q4f))
     h += tr_qa(ell + WSTRING("gmcpq_q4_g"),
                get_from_dict(DICTQ4, self.q4g))
     h += tr(td(WSTRING("gmcpq_q5")), blank_cell, literal=True)
     h += tr_qa(ell + WSTRING("gmcpq_q5_a"),
                get_from_dict(DICTQ5, self.q5a))
     h += tr_qa(ell + WSTRING("gmcpq_q5_b"),
                get_from_dict(DICTQ5, self.q5b))
     h += tr_qa(WSTRING("gmcpq_q6"), get_yes_no_none(self.q6))
     h += tr_qa(WSTRING("gmcpq_q7"), get_yes_no_none(self.q7))
     h += tr_qa(WSTRING("gmcpq_q8"), get_yes_no_none(self.q8))
     h += tr_qa(WSTRING("gmcpq_q9_s"), ws.webify(self.q9))
     h += sep_row
     h += tr_qa(WSTRING("sex"), ws.webify(self.q10))
     h += tr_qa(WSTRING("gmcpq_q11"), get_from_dict(DICTQ11, self.q11))
     h += tr_qa(WSTRING("gmcpq_q12"), get_from_dict(DICTQ12, self.q12))
     h += tr_qa(ell + WSTRING("gmcpq_ethnicity_other_s"),
                ws.webify(self.q12_details))
     h += u"""
         </table>
     """
     return h
Пример #8
0
    def get_task_html(self):
        h = self.get_standard_clinician_block(True, self.comments) + u"""
            <div class="summary">
                <table class="summary">
        """ + self.get_is_complete_tr()
        h += tr_qa(WSTRING("date_pertains_to"),
                   format_datetime_string(self.date_pertains_to,
                                          DATEFORMAT.LONG_DATE, default=None))
        h += tr_qa(WSTRING("icd10pd_meets_general_criteria"),
                   get_yes_no_none(self.hasPD()))
        h += tr_qa(WSTRING("icd10_paranoid_pd_title"),
                   get_yes_no_none(self.hasParanoidPD()))
        h += tr_qa(WSTRING("icd10_schizoid_pd_title"),
                   get_yes_no_none(self.hasSchizoidPD()))
        h += tr_qa(WSTRING("icd10_dissocial_pd_title"),
                   get_yes_no_none(self.hasDissocialPD()))
        h += tr_qa(WSTRING("icd10_eu_pd_i_title"),
                   get_yes_no_none(self.hasEUPD_I()))
        h += tr_qa(WSTRING("icd10_eu_pd_b_title"),
                   get_yes_no_none(self.hasEUPD_B()))
        h += tr_qa(WSTRING("icd10_histrionic_pd_title"),
                   get_yes_no_none(self.hasHistrionicPD()))
        h += tr_qa(WSTRING("icd10_anankastic_pd_title"),
                   get_yes_no_none(self.hasAnankasticPD()))
        h += tr_qa(WSTRING("icd10_anxious_pd_title"),
                   get_yes_no_none(self.hasAnxiousPD()))
        h += tr_qa(WSTRING("icd10_dependent_pd_title"),
                   get_yes_no_none(self.hasDependentPD()))

        h += u"""
                </table>
            </div>
            <div>
                <p><i>Vignette:</i></p>
                <p>{}</p>
            </div>
            <table class="taskdetail">
                <tr>
                    <th width="80%">Question</th>
                    <th width="20%">Answer</th>
                </tr>
        """.format(
            answer(ws.webify(self.vignette), default_for_blank_strings=True)
        )

        # General
        h += subheading_spanning_two_columns(WSTRING("icd10pd_general"))
        h += self.get_twocol_bool_row_true_false("g1", WSTRING("icd10pd_G1"))
        h += self.pd_b_text("icd10pd_G1b")
        for i in range(1, Icd10SpecPD.N_GENERAL_1 + 1):
            h += self.get_twocol_bool_row_true_false(
                "g1_" + str(i), WSTRING("icd10pd_G1_" + str(i)))
        for i in range(2, Icd10SpecPD.N_GENERAL + 1):
            h += self.get_twocol_bool_row_true_false(
                "g" + str(i), WSTRING("icd10pd_G" + str(i)))

        # Paranoid, etc.
        h += self.standard_pd_html("paranoid", Icd10SpecPD.N_PARANOID)
        h += self.standard_pd_html("schizoid", Icd10SpecPD.N_SCHIZOID)
        h += self.standard_pd_html("dissocial", Icd10SpecPD.N_DISSOCIAL)

        # EUPD is special
        h += self.pd_heading("icd10_eu_pd_title")
        h += self.pd_skiprow("eu")
        h += self.pd_general_criteria_bits()
        h += self.pd_subheading("icd10_eu_pd_i_title")
        h += self.pd_b_text("icd10_eu_pd_i_B")
        for i in range(1, Icd10SpecPD.N_EUPD_I + 1):
            h += self.pd_basic_row("eu", i)
        h += self.pd_subheading("icd10_eu_pd_b_title")
        h += self.pd_b_text("icd10_eu_pd_b_B")
        for i in range(Icd10SpecPD.N_EUPD_I + 1, Icd10SpecPD.N_EU + 1):
            h += self.pd_basic_row("eu", i)

        # Back to plain ones
        h += self.standard_pd_html("histrionic", Icd10SpecPD.N_HISTRIONIC)
        h += self.standard_pd_html("anankastic", Icd10SpecPD.N_ANANKASTIC)
        h += self.standard_pd_html("anxious", Icd10SpecPD.N_ANXIOUS)
        h += self.standard_pd_html("dependent", Icd10SpecPD.N_DEPENDENT)

        # Done
        h += u"""
            </table>
        """ + ICD10_COPYRIGHT_DIV
        return h
Пример #9
0
 def get_task_html(self):
     total = self.total_score()
     distress = self.distress_score()
     intrusiveness = self.intrusiveness_score()
     frequency = self.frequency_score()
     h = u"""
         <div class="summary">
             <table class="summary">
     """ + self.get_is_complete_tr()
     h += tr_qa(u"{} <sup>[1]</sup> (0–32)".format(WSTRING("total_score")),
                total)
     h += tr_qa(u"{} (0–160)".format(WSTRING("caps_distress")),
                distress)
     h += tr_qa(u"{} (0–160)".format(WSTRING("caps_intrusiveness")),
                intrusiveness)
     h += tr_qa(u"{} (0–160)".format(WSTRING("caps_frequency")),
                frequency)
     h += u"""
             </table>
         </div>
         <div class="explanation">
             Anchor points: DISTRESS {distress1}, {distress5}.
             INTRUSIVENESS {intrusiveness1}, {intrusiveness5}.
             FREQUENCY {frequency1}, {frequency5}.
         </div>
         <table class="taskdetail">
             <tr>
                 <th width="60%">Question</th>
                 <th width="10%">Endorsed?</th>
                 <th width="10%">Distress (1–5)</th>
                 <th width="10%">Intrusiveness (1–5)</th>
                 <th width="10%">Frequency (1–5)</th>
             </tr>
     """.format(
         distress1=WSTRING("caps_distress_option1"),
         distress5=WSTRING("caps_distress_option5"),
         intrusiveness1=WSTRING("caps_intrusiveness_option1"),
         intrusiveness5=WSTRING("caps_intrusiveness_option5"),
         frequency1=WSTRING("caps_frequency_option1"),
         frequency5=WSTRING("caps_frequency_option5"),
     )
     for q in range(1, Caps.NQUESTIONS + 1):
         h += tr(
             WSTRING("caps_q" + str(q)),
             answer(get_yes_no_none(getattr(self, "endorse" + str(q)))),
             answer(getattr(self, "distress" + str(q))
                    if getattr(self, "endorse" + str(q)) else ""),
             answer(getattr(self, "intrusiveness" + str(q))
                    if getattr(self, "endorse" + str(q)) else ""),
             answer(getattr(self, "frequency" + str(q))
                    if getattr(self, "endorse" + str(q)) else "")
         )
     h += u"""
         </table>
         <div class="footnotes">
             [1] Total score: sum of endorsements (yes = 1, no = 0).
             Dimension scores: sum of ratings (0 if not endorsed).
             (Bell et al. 2006, PubMed ID 16237200)
         </div>
         <div class="copyright">
             CAPS: Copyright © 2005, Bell, Halligan & Ellis.
             Original article:
                 Bell V, Halligan PW, Ellis HD (2006).
                 The Cardiff Anomalous Perceptions Scale (CAPS): a new
                 validated measure of anomalous perceptual experience.
                 Schizophrenia Bulletin 32: 366–377.
             Published by Oxford University Press on behalf of the Maryland
             Psychiatric Research Center. All rights reserved. The online
             version of this article has been published under an open access
             model. Users are entitled to use, reproduce, disseminate, or
             display the open access version of this article for
             non-commercial purposes provided that: the original authorship
             is properly and fully attributed; the Journal and Oxford
             University Press are attributed as the original place of
             publication with the correct citation details given; if an
             article is subsequently reproduced or disseminated not in its
             entirety but only in part or as a derivative work this must be
             clearly indicated. For commercial re-use, please contact
             [email protected].<br>
             <b>This is a derivative work (partial reproduction, viz. the
             scale text).</b>
         </div>
     """
     return h
Пример #10
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
Пример #11
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
 def get_task_html(self):
     if self.modality == MODALITY_AUDITORY:
         modality = WSTRING("auditory")
     elif self.modality == MODALITY_VISUAL:
         modality = WSTRING("visual")
     else:
         modality = None
     h = u"""
         <div class="summary">
             <table class="summary">
                 {}
             </table>
         </div>
         <div class="explanation">
             The ExpDet-Threshold task measures visual and auditory
             thresholds for stimuli on a noisy background, using a
             single-interval up/down method. It is intended as a prequel to
             the Expectation–Detection task.
         </div>
         <table class="taskconfig">
             <tr>
                 <th width="50%">Configuration variable</th>
                 <th width="50%">Value</th>
             </tr>
     """.format(
         self.get_is_complete_tr(),
     )
     h += tr_qa("Modality", modality)
     h += tr_qa("Target number", self.target_number)
     h += tr_qa("Background filename", ws.webify(self.background_filename))
     h += tr_qa("Background intensity", self.background_intensity)
     h += tr_qa("Target filename", ws.webify(self.target_filename))
     h += tr_qa("(For visual targets) Target duration (s)",
                self.visual_target_duration_s)
     h += tr_qa("Start intensity (minimum)", self.start_intensity_min)
     h += tr_qa("Start intensity (maximum)", self.start_intensity_max)
     h += tr_qa("Initial (large) intensity step",
                self.initial_large_intensity_step)
     h += tr_qa("Main (small) intensity step",
                self.main_small_intensity_step)
     h += tr_qa("Number of trials in main sequence",
                self.num_trials_in_main_sequence)
     h += tr_qa("Probability of a catch trial", self.p_catch_trial)
     h += tr_qa("Prompt", self.prompt)
     h += tr_qa("Intertrial interval (ITI) (s)", self.iti_s)
     h += u"""
         </table>
         <table class="taskdetail">
             <tr><th width="50%">Measure</th><th width="50%">Value</th></tr>
     """
     h += tr_qa("Finished?", get_yes_no_none(self.finished))
     h += tr_qa("Logistic intercept",
                ws.number_to_dp(self.intercept,
                                DP))
     h += tr_qa("Logistic slope",
                ws.number_to_dp(self.slope, DP))
     h += tr_qa("Logistic k (= slope)",
                ws.number_to_dp(self.k, DP))
     h += tr_qa(u"Logistic theta (= –intercept/slope)",
                ws.number_to_dp(self.theta, DP))
     h += tr_qa("Intensity for {}% detection".format(100*LOWER_MARKER),
                ws.number_to_dp(self.logistic_x_from_p(LOWER_MARKER),
                                DP))
     h += tr_qa("Intensity for 50% detection",
                ws.number_to_dp(self.theta, DP))
     h += tr_qa("Intensity for {}% detection".format(100*UPPER_MARKER),
                ws.number_to_dp(self.logistic_x_from_p(UPPER_MARKER),
                                DP))
     h += u"""
         </table>
     """
     h += self.get_trial_html()
     return h
    def get_task_html(self):
        grouparray = self.get_group_array()
        trialarray = self.get_trial_array()
        # THIS IS A NON-EDITABLE TASK, so we *ignore* the problem
        # of matching to no-longer-current records.
        # (See PhotoSequence.py for a task that does it properly.)

        # Provide HTML
        # HTML
        h = u"""
            <div class="summary">
                <table class="summary">
                    {}
                </table>
            </div>
            <div class="explanation">
                Putative assay of propensity to hallucinations.
            </div>
            <table class="taskconfig">
                <tr>
                    <th width="50%">Configuration variable</th>
                    <th width="50%">Value</th>
                </tr>
        """.format(
            self.get_is_complete_tr(),
        )
        h += tr_qa("Number of blocks", self.num_blocks)
        h += tr_qa("Stimulus counterbalancing", self.stimulus_counterbalancing)
        h += tr_qa(u"“Detection” response on right?",
                   self.is_detection_response_on_right)
        h += tr_qa("Pause every <i>n</i> trials (0 = no pauses)",
                   self.pause_every_n_trials)
        h += tr_qa("Cue duration (s)", self.cue_duration_s)
        h += tr_qa(u"Visual cue intensity (0–1)", self.visual_cue_intensity)
        h += tr_qa(u"Auditory cue intensity (0–1)",
                   self.auditory_cue_intensity)
        h += tr_qa("ISI duration (s)", self.isi_duration_s)
        h += tr_qa("Visual target duration (s)", self.visual_target_duration_s)
        h += tr_qa("Visual background intensity",
                   self.visual_background_intensity)
        h += tr_qa("Visual target 0 (circle) intensity",
                   self.visual_target_0_intensity)
        h += tr_qa(u"Visual target 1 (“sun”) intensity",
                   self.visual_target_1_intensity)
        h += tr_qa("Auditory background intensity",
                   self.auditory_background_intensity)
        h += tr_qa("Auditory target 0 (tone) intensity",
                   self.auditory_target_0_intensity)
        h += tr_qa(u"Auditory target 1 (“moon”) intensity",
                   self.auditory_target_1_intensity)
        h += tr_qa("ITI minimum (s)", self.iti_min_s)
        h += tr_qa("ITI maximum (s)", self.iti_max_s)
        h += u"""
            </table>
            <table class="taskdetail">
                <tr><th width="50%">Measure</th><th width="50%">Value</th></tr>
        """
        h += tr_qa("Aborted?", get_yes_no_none(self.aborted))
        h += tr_qa("Finished?", get_yes_no_none(self.finished))
        h += tr_qa("Last trial completed", self.last_trial_completed)
        h += (
            u"""
                </table>
                <div>
                    Trial group specifications (one block is a full set of
                    all these trials):
                </div>
            """
            + self.get_group_html(grouparray)
            + u"""
                <div>
                    Detection probabilities by block and group (c &gt; 0 when
                    miss rate &gt; false alarm rate; c &lt; 0 when false alarm
                    rate &gt; miss rate):
                </div>
            """
            + self.get_html_correct_by_group_and_block(trialarray)
            + u"<div>Detection probabilities by block:</div>"
            + self.get_html_correct_by_block(trialarray)
            + u"<div>Detection probabilities by group:</div>"
            + self.get_html_correct_by_group(trialarray)
            + u"""
                <div>
                    Detection probabilities by half and high/low association
                    probability:
                </div>
            """
            + self.get_html_correct_by_half_and_probability(trialarray,
                                                            grouparray)
            + u"""
                <div>
                    Detection probabilities by block and high/low association
                    probability:
                </div>
            """
            + self.get_html_correct_by_block_and_probability(trialarray,
                                                             grouparray)
            + u"""
                <div>
                    Receiver operating characteristic (ROC) curves by group:
                </div>
            """
            + self.get_roc_figure_by_group(trialarray, grouparray, True)
            + self.get_roc_figure_by_group(trialarray, grouparray, False)
            + u"<div>First-half/last-half ROCs:</div>"
            + self.get_roc_figure_firsthalf_lasthalf(trialarray, True)
            + u"<div>Trial-by-trial results:</div>"
            + self.get_trial_html(trialarray)
        )
        return h
Пример #14
0
 def get_task_html(self):
     score = self.total_score()
     category = self.category()
     h = self.get_standard_clinician_block(True, self.comments) + u"""
         <div class="summary">
             <table class="summary">
     """ + self.get_is_complete_tr()
     h += tr(WSTRING("total_score"), answer(score) + " / 30")
     h += tr_qa(WSTRING("category") + " <sup>[1]</sup>", category)
     h += u"""
             </table>
         </div>
         <table class="taskdetail">
             <tr>
                 <th width="80%">Question</th>
                 <th width="20%">Score</th>
             </tr>
     """
     h += tr_qa(WSTRING("slums_alert_s"), get_yes_no_none(self.alert))
     h += tr_qa(WSTRING("slums_highschool_s"),
                get_yes_no_none(self.highschooleducation))
     h += tr_qa(WSTRING("slums_q1_s"), self.q1)
     h += tr_qa(WSTRING("slums_q2_s"), self.q2)
     h += tr_qa(WSTRING("slums_q3_s"), self.q3)
     h += tr(u"Q5 <sup>[2]</sup> (money spent, money left "
             u"[<i>scores 2</i>]",
             u", ".join([answer(x) for x in [self.q5a, self.q5b]]))
     h += tr_qa(u"Q6 (animal fluency) [<i>≥15 scores 3, 10–14 scores 2, "
                u"5–9 scores 1, 0–4 scores 0</i>]",
                self.q6)
     h += tr(u"Q7 (recall: apple, pen, tie, house, car)",
             u", ".join([answer(x) for x in [self.q7a, self.q7b, self.q7c,
                                             self.q7d, self.q7e]]))
     h += tr(u"Q8 (backwards: 648, 8537)",
             u", ".join([answer(x) for x in [self.q8b, self.q8c]]))
     h += tr(u"Q9 (clock: hour markers, time [<i>score 2 each</i>]",
             u", ".join([answer(x) for x in [self.q9a, self.q9b]]))
     h += tr(u"Q10 (X in triangle; which is biggest?)",
             u", ".join([answer(x) for x in [self.q10a, self.q10b]]))
     h += tr(u"Q11 (story: Female’s name? Job? When back to work? "
             u"State she lived in? [<i>score 2 each</i>])",
             u", ".join([answer(x) for x in [self.q11a, self.q11b,
                                             self.q11c, self.q11d]]))
     h += u"""
         </table>
         <table class="taskdetail">
     """
     h += subheading_spanning_two_columns("Images of tests: clock, shapes")
     h += tr(
         td(self.get_blob_png_html(self.clockpicture_blobid),
            td_width="50%", td_class="photo"),
         td(self.get_blob_png_html(self.shapespicture_blobid),
            td_width="50%", td_class="photo"),
         literal=True
     )
     h += u"""
         </table>
         <div class="footnotes">
             [1] With high school education:
             ≥27 normal, ≥21 MCI, ≤20 dementia.
             Without high school education:
             ≥25 normal, ≥20 MCI, ≤19 dementia.
             (Tariq et al. 2006, PubMed ID 17068312.)
             [2] Q4 (learning the five words) isn’t scored.
         </div>
     """
     return h