コード例 #1
0
ファイル: cpft_lps.py プロジェクト: parijatsahai/camcops
 def get_clinical_text(self):
     diagnoses = self.get_psychiatric_diagnoses() + \
         self.get_medical_diagnoses()
     return [
         {
             "heading": ws.webify(WSTRING("cpft_lps_dis_discharge_reason")),
             "content": self.get_discharge_reason()
         },
         {
             "heading": ws.webify(
                 WSTRING("cpft_lps_dis_referral_reason_t")),
             "content": ", ".join(self.get_referral_reasons())
         },
         {
             "heading": ws.webify(WSTRING("cpft_lps_dis_diagnoses_t")),
             "content": ", ".join(diagnoses)
         },
         {
             "heading": ws.webify(WSTRING("cpft_lps_dis_management_t")),
             "content": ", ".join(self.get_managements())
         },
         {
             "heading": ws.webify(WSTRING("cpft_lps_dis_outcome_t")),
             "content": self.outcome
         },
     ]
コード例 #2
0
ファイル: diagnosis.py プロジェクト: parijatsahai/camcops
 def get_clinical_text(self):
     fielddictlist = []
     items = self.get_items()
     for item in items:
         fielddictlist.append({
             "content": u"<b>{}</b>: {}".format(ws.webify(item.code),
                                                ws.webify(item.description))
         })
     return fielddictlist
コード例 #3
0
ファイル: cpft_lps.py プロジェクト: parijatsahai/camcops
 def get_psychiatric_diagnoses(self):
     psychiatric_diagnoses = [
         WSTRING("cpft_lps_dis_diagnosis_no_active_mental_health_problem")
     ] if self.diagnosis_no_active_mental_health_problem else []
     for i in range(1, 4 + 1):  # magic number
         if getattr(self, "diagnosis_psych_" + str(i) + "_icd10code"):
             psychiatric_diagnoses.append(
                 ws.webify(getattr(self, "diagnosis_psych_" +
                                   str(i) + "_icd10code"))
                 + u" – "
                 + ws.webify(getattr(self, "diagnosis_psych_" +
                                     str(i) + "_description"))
             )
     return psychiatric_diagnoses
コード例 #4
0
ファイル: bdi.py プロジェクト: parijatsahai/camcops
    def get_task_html(self):
        score = self.total_score()
        h = u"""
            <div class="summary">
                <table class="summary">
        """
        h += self.get_is_complete_tr()
        h += tr(WSTRING("total_score"), answer(score) + " / 63")
        h += u"""
                </table>
            </div>
            <div class="explanation">
                All questions are scored from 0–3
                (0 free of symptoms, 3 most symptomatic).
            </div>
            <table class="taskdetail">
                <tr>
                    <th width="70%">Question</th>
                    <th width="30%">Answer</th>
                </tr>
        """
        h += tr_qa(WSTRING("bdi_which_scale"), ws.webify(self.bdi_scale))

        for q in xrange(1, Bdi.NQUESTIONS + 1):
            h += tr_qa(u"{} {}".format(WSTRING("question"), q), getattr(self, "q" + str(q)))
        h += (
            u"""
            </table>
        """
            + DATA_COLLECTION_ONLY_DIV
        )
        return h
コード例 #5
0
ファイル: cpft_lps.py プロジェクト: parijatsahai/camcops
 def get_medical_diagnoses(self):
     medical_diagnoses = []
     for i in range(1, 4 + 1):  # magic number
         if getattr(self, "diagnosis_medical_" + str(i)):
             medical_diagnoses.append(
                 ws.webify(getattr(self, "diagnosis_medical_" + str(i))))
     return medical_diagnoses
コード例 #6
0
 def get_html_table_row(self):
     return (u"<tr>" + u"<td>{}</td>" * 13 + u"</th>").format(
         self.trial,
         self.trial_ignoring_catch_trials,
         self.target_presented,
         self.target_time,
         ws.number_to_dp(self.intensity, DP),
         self.choice_time,
         self.responded,
         self.response_time,
         self.response_latency_ms,
         self.yes,
         self.no,
         ws.webify(self.caught_out_reset),
         ws.webify(self.trial_num_in_calculation_sequence)
     )
コード例 #7
0
 def get_note_as_html(self):
     """Return an HTML-formatted version of the note."""
     return u"[{dt}, {user}]<br><b>{note}</b>".format(
         dt=self.note_at or "?",
         user=self.user or "?",
         note=ws.webify(self.note) or "",
     )
コード例 #8
0
ファイル: photo.py プロジェクト: parijatsahai/camcops
 def get_html_table_rows(self):
     return u"""
         <tr class="subheading"><td>Photo {}: <b>{}</b></td></tr>
         <tr><td>{}</td></tr>
     """.format(
         self.seqnum + 1, ws.webify(self.description),
         self.get_blob_png_html(),
     )
コード例 #9
0
ファイル: contactlog.py プロジェクト: parijatsahai/camcops
 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
コード例 #10
0
ファイル: icd10manic.py プロジェクト: parijatsahai/camcops
 def get_clinical_text(self):
     if not self.is_complete():
         return CTV_DICTLIST_INCOMPLETE
     dl = [{
         "content": "Pertains to: {}. Category: {}.".format(
             format_datetime_string(self.date_pertains_to,
                                    DATEFORMAT.LONG_DATE),
             self.get_description()
         )
     }]
     if self.comments:
         dl.append({"content": ws.webify(self.comments)})
     return dl
コード例 #11
0
ファイル: photo.py プロジェクト: parijatsahai/camcops
 def get_task_html(self):
     return self.get_standard_clinician_block() + u"""
         <table class="taskdetail">
             <tr class="subheading"><td>Description</td></tr>
             <tr><td>{}</td></tr>
             <tr class="subheading"><td>Photo</td></tr>
             <tr><td>{}</td></tr>
         </table>
     """.format(
         answer(ws.webify(self.description), default="(No description)",
                default_for_blank_strings=True),
         # ... xhtml2pdf crashes if the contents are empty...
         self.get_blob_png_html(self.photo_blobid, self.rotation)
     )
コード例 #12
0
ファイル: progressnote.py プロジェクト: parijatsahai/camcops
 def get_task_html(self):
     # Avoid tables - PDF generator crashes if text is too long.
     h = self.get_standard_clinician_block() + u"""
         <div class="heading">
             {heading_location}
         </div>
         <div>
             {location}
         </div>
         <div class="heading">
             {heading_note}
         </div>
         <div>
             {note}
         </div>
     """.format(
         heading_location=WSTRING("location"),
         location=answer(ws.webify(self.location),
                         default_for_blank_strings=True),
         heading_note=WSTRING("progressnote_note"),
         note=answer(ws.webify(self.note), default_for_blank_strings=True),
     )
     return h
コード例 #13
0
ファイル: cc_session.py プロジェクト: parijatsahai/camcops
 def get_current_user_html(self, offer_main_menu=True):
     """HTML showing current database/user, +/- link to main menu."""
     if self.user:
         user = "******".format(ws.webify(self.user))
     else:
         user = ""
     database = cc_html.get_database_title_string()
     if offer_main_menu:
         menu = """ <a href="{}">Return to main menu</a>.""".format(
             cc_html.get_url_main_menu())
     else:
         menu = ""
     if not user and not database and not menu:
         return ""
     return "<div>{} {}{}</div>".format(database, user, menu)
コード例 #14
0
 def get_clinical_text(self):
     if not self.is_complete():
         return CTV_DICTLIST_INCOMPLETE
     c = self.meets_general_criteria()
     if c is None:
         category = "Unknown if met or not met"
     elif c:
         category = "Met"
     else:
         category = "Not met"
     dl = [{
         "content":  "Pertains to: {}. General criteria for "
                     "schizophrenia: {}.".format(
                         format_datetime_string(self.date_pertains_to,
                                                DATEFORMAT.LONG_DATE),
                         category)
     }]
     if self.comments:
         dl.append({"content": ws.webify(self.comments)})
     return dl
コード例 #15
0
ファイル: cc_session.py プロジェクト: parijatsahai/camcops
def get_filter_html(filter_name,
                    filter_value,
                    clear_action,
                    apply_field_html,
                    apply_action,
                    filter_list):
    """HTML to view or change a filter."""
    # returns: found a filter?
    no_filter_value = (
        filter_value is None
        or (
            isinstance(filter_value, basestring)
            and not filter_value
        )
    )
    if no_filter_value:
        filter_list.append(u"""
                    {filter_name}: {apply_field_html}
                    <br>
        """.format(
            filter_name=filter_name,
            apply_field_html=apply_field_html,
            # apply_action=apply_action,
        ))
        #            <input type="submit" name="{apply_action}" value="Filter">
        return False
    else:
        filter_list.append(u"""
                    {filter_name}: <b>{filter_value}</b>
                    <input type="submit" name="{clear_action}" value="Clear">
                    {apply_field_html}
                    <br>
        """.format(
            filter_name=filter_name,
            filter_value=ws.webify(filter_value),
            clear_action=clear_action,
            apply_field_html=apply_field_html,
            # apply_action=apply_action
        ))
        #            <input type="submit" name="{apply_action}" value="Filter">
        return True
コード例 #16
0
 def get_ctv_subheading(self, wstringname):
     return {
         "subheading": ws.webify(WSTRING(wstringname)),
         "skip_if_no_content": False
     }
コード例 #17
0
ファイル: gmcpq.py プロジェクト: parijatsahai/camcops
 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
コード例 #18
0
ファイル: icd10specpd.py プロジェクト: parijatsahai/camcops
    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
コード例 #19
0
ファイル: cc_user.py プロジェクト: parijatsahai/camcops
def add_user(form):
    """Add a user, and return HTML success/failure message."""
    username = ws.get_cgi_parameter_str(form, PARAM.USERNAME)
    password_1 = ws.get_cgi_parameter_str(form, PARAM.PASSWORD_1)
    password_2 = ws.get_cgi_parameter_str(form, PARAM.PASSWORD_2)
    must_change_password = ws.get_cgi_parameter_bool(
        form, PARAM.MUST_CHANGE_PASSWORD)

    may_use_webviewer = ws.get_cgi_parameter_bool(
        form, PARAM.MAY_USE_WEBVIEWER)
    may_view_other_users_records = ws.get_cgi_parameter_bool(
        form, PARAM.MAY_VIEW_OTHER_USERS_RECORDS)
    view_all_patients_when_unfiltered = ws.get_cgi_parameter_bool(
        form, PARAM.VIEW_ALL_PTS_WHEN_UNFILTERED)
    may_upload = ws.get_cgi_parameter_bool(form, PARAM.MAY_UPLOAD)
    superuser = ws.get_cgi_parameter_bool(form, PARAM.SUPERUSER)
    may_register_devices = ws.get_cgi_parameter_bool(
        form, PARAM.MAY_REGISTER_DEVICES)
    may_use_webstorage = ws.get_cgi_parameter_bool(
        form, PARAM.MAY_USE_WEBSTORAGE)
    may_dump_data = ws.get_cgi_parameter_bool(form, PARAM.MAY_DUMP_DATA)
    may_run_reports = ws.get_cgi_parameter_bool(form, PARAM.MAY_RUN_REPORTS)
    may_add_notes = ws.get_cgi_parameter_bool(form, PARAM.MAY_ADD_NOTES)

    user = User(username, False)
    if user.user:
        return user_management_failure_message(
            "User already exists: " + username)
    if not is_username_permissible(username):
        return user_management_failure_message(
            "Invalid username: "******"Passwords don't mach")
    if len(password_1) < MINIMUM_PASSWORD_LENGTH:
        return user_management_failure_message(
            "Password must be at least {} characters".format(
                MINIMUM_PASSWORD_LENGTH
            ))

    user = User(username, True)
    user.set_password(password_1)

    user.may_use_webviewer = may_use_webviewer
    user.may_view_other_users_records = may_view_other_users_records
    user.view_all_patients_when_unfiltered = view_all_patients_when_unfiltered
    user.may_upload = may_upload
    user.superuser = superuser
    user.may_register_devices = may_register_devices
    user.may_use_webstorage = may_use_webstorage
    user.may_dump_data = may_dump_data
    user.may_run_reports = may_run_reports
    user.may_add_notes = may_add_notes

    user.save()
    if must_change_password:
        user.force_password_change()

    audit(
        (
            "User created: {}: "
            "may_use_webviewer={}, "
            "may_view_other_users_records={}, "
            "view_all_patients_when_unfiltered={}, "
            "may_upload={}, "
            "superuser={}, "
            "may_register_devices={}, "
            "may_use_webstorage={}, "
            "may_dump_data={}, "
            "may_run_reports={}, "
            "may_add_notes={}, "
            "must_change_password={}"
        ).format(
            user.user,
            may_use_webviewer,
            may_view_other_users_records,
            view_all_patients_when_unfiltered,
            may_upload,
            superuser,
            may_register_devices,
            may_use_webstorage,
            may_dump_data,
            may_run_reports,
            may_add_notes,
            must_change_password
        )
    )
    return user_management_success_message("User " + user.user + " created")
コード例 #20
0
ファイル: cc_user.py プロジェクト: parijatsahai/camcops
def manage_users(session):
    """HTML to view/edit users."""
    allusers = pls.db.fetch_all_objects_from_db(User, User.TABLENAME,
                                                User.FIELDS, True)
    allusers = sorted(allusers, key=lambda k: k.user)
    output = pls.WEBSTART + u"""
        {}
        <h1>Manage users</h1>
        <ul>
            <li><a href="{}">Add user</a></li>
        </ul>
        <table>
            <tr>
                <th>User name</th>
                <th>Actions</th>
                <th>Locked out?</th>
                <th>Last password change (UTC)</th>
                <th>May use web viewer?</th>
                <th>May view other users’ records?</th>
                <th>Sees all patients’ records when unfiltered?</th>
                <th>May upload data?</th>
                <th>May manage users?</th>
                <th>May register tablet devices?</th>
                <th>May use webstorage?</th>
                <th>May dump data?</th>
                <th>May run reports?</th>
                <th>May add notes?</th>
                <th>Click to delete use</th>
            </tr>
    """.format(
        session.get_current_user_html(),
        cc_html.get_generic_action_url(ACTION.ASK_TO_ADD_USER),
    ) + cc_html.WEBEND
    for u in allusers:
        if u.is_locked_out():
            enableuser = "******".format(
                get_url_enable_user(u.user)
            )
            lockedmsg = "Yes, until {}".format(cc_dt.format_datetime(
                u.locked_out_until(),
                DATEFORMAT.ISO8601
            ))
        else:
            enableuser = ""
            lockedmsg = "No"
        output += u"""
            <tr>
                <td>{username}</td>
                <td>
                    <a href="{url_edit}">Edit permissions</a>
                    | <a href="{url_changepw}">Change password</a>
                    {enableuser}
                </td>
                <td>{lockedmsg}</td>
                <td>{lastpwchange}</td>
                <td>{may_use_webviewer}</td>
                <td>{may_view_other_users_records}</td>
                <td>{view_all_patients_when_unfiltered}</td>
                <td>{may_upload}</td>
                <td>{superuser}</td>
                <td>{may_register_devices}</td>
                <td>{may_use_webstorage}</td>
                <td>{may_dump_data}</td>
                <td>{may_run_reports}</td>
                <td>{may_add_notes}</td>
                <td><a href="{url_delete}">Delete user {username}</a></td>
            </tr>
        """.format(
            url_edit=get_url_edit_user(u.user),
            url_changepw=cc_html.get_url_enter_new_password(u.user),
            enableuser=enableuser,
            lockedmsg=lockedmsg,
            lastpwchange=ws.webify(u.last_password_change_utc),
            may_use_webviewer=cc_html.get_yes_no(u.may_use_webviewer),
            may_view_other_users_records=cc_html.get_yes_no(
                u.may_view_other_users_records),
            view_all_patients_when_unfiltered=cc_html.get_yes_no(
                u.view_all_patients_when_unfiltered),
            may_upload=cc_html.get_yes_no(u.may_upload),
            superuser=cc_html.get_yes_no(u.superuser),
            may_register_devices=cc_html.get_yes_no(u.may_register_devices),
            may_use_webstorage=cc_html.get_yes_no(u.may_use_webstorage),
            may_dump_data=cc_html.get_yes_no(u.may_dump_data),
            may_run_reports=cc_html.get_yes_no(u.may_run_reports),
            may_add_notes=cc_html.get_yes_no(u.may_add_notes),
            url_delete=get_url_ask_delete_user(u.user),
            username=u.user,
        )
    output += u"""
        </table>
    """ + cc_html.WEBEND
    return output
コード例 #21
0
ファイル: cc_string.py プロジェクト: parijatsahai/camcops
def WXSTRING(taskname, stringname, default=None):
    """Returns a web-safe version of an XSTRING (see above)."""
    return ws.webify(XSTRING(taskname, stringname, default))
コード例 #22
0
ファイル: cc_session.py プロジェクト: parijatsahai/camcops
    def get_current_filter_html(self):
        """HTML showing current filters and offering ways to set them."""
        # Consider also multiple buttons in a single form:
        # http://stackoverflow.com/questions/942772
        # ... might allow "apply all things entered here" button
        # ... HOWEVER, I think this would break the ability to press Enter
        # after entering information in any box (which is nice).
        found_one = False
        filters = []
        id_filter_values = []
        id_filter_descs = []
        for n in range(1, NUMBER_OF_IDNUMS + 1):
            nstr = str(n)
            id_filter_values.append(getattr(self, "filter_idnum" + nstr))
            id_filter_descs.append(pls.get_id_desc(n))
        id_filter_value = None
        id_filter_name = "ID number"
        for index, value in enumerate(id_filter_values):
            if value is not None:
                id_filter_value = value
                id_filter_name = id_filter_descs[index]
        which_idnum_temp = u"""
                {picker}
                <input type="number" name="{PARAM.IDNUM_VALUE}">
        """.format(
            picker=cc_html.get_html_which_idnum_picker(PARAM.WHICH_IDNUM),
            PARAM=PARAM,
        )
        found_one = get_filter_html(
            id_filter_name,
            id_filter_value,
            ACTION.CLEAR_FILTER_IDNUMS,
            which_idnum_temp,
            ACTION.APPLY_FILTER_IDNUMS,
            filters
        ) or found_one
        found_one = get_filter_html(
            "Surname",
            self.filter_surname,
            ACTION.CLEAR_FILTER_SURNAME,
            """<input type="text" name="{}">""".format(PARAM.SURNAME),
            ACTION.APPLY_FILTER_SURNAME,
            filters
        ) or found_one
        found_one = get_filter_html(
            "Forename",
            self.filter_forename,
            ACTION.CLEAR_FILTER_FORENAME,
            """<input type="text" name="{}">""".format(PARAM.FORENAME),
            ACTION.APPLY_FILTER_FORENAME,
            filters
        ) or found_one
        found_one = get_filter_html(
            "Date of birth",
            cc_dt.format_datetime(self.get_filter_dob(), DATEFORMAT.LONG_DATE),
            ACTION.CLEAR_FILTER_DOB,
            """<input type="date" name="{}">""".format(PARAM.DOB),
            ACTION.APPLY_FILTER_DOB,
            filters
        ) or found_one
        found_one = get_filter_html(
            "Sex",
            self.filter_sex,
            ACTION.CLEAR_FILTER_SEX,
            cc_html.get_html_sex_picker(param=PARAM.SEX,
                                        selected=self.filter_sex,
                                        offer_all=True),
            ACTION.APPLY_FILTER_SEX,
            filters
        ) or found_one
        found_one = get_filter_html(
            "Task type",
            self.filter_task,
            ACTION.CLEAR_FILTER_TASK,
            cc_task.get_task_filter_dropdown(self.filter_task),
            ACTION.APPLY_FILTER_TASK,
            filters
        ) or found_one
        found_one = get_filter_html(
            "Task completed",
            cc_html.get_yes_no_none(self.filter_complete),
            ACTION.CLEAR_FILTER_COMPLETE,
            """
                <select name="{PARAM.COMPLETE}">
                    <option value="">(all)</option>
                    <option value="1"{selected_1}>Complete</option>
                    <option value="0"{selected_0}>Incomplete</option>
                </select>
            """.format(PARAM=PARAM,
                       selected_1=ws.option_selected(self.filter_complete, 1),
                       selected_0=ws.option_selected(self.filter_complete, 0)),
            ACTION.APPLY_FILTER_COMPLETE,
            filters
        ) or found_one
        found_one = get_filter_html(
            "Include old (overwritten) versions",
            cc_html.get_yes_no_none(self.filter_include_old_versions),
            ACTION.CLEAR_FILTER_INCLUDE_OLD_VERSIONS,
            """
                <select name="{PARAM.INCLUDE_OLD_VERSIONS}">
                    <option value="">(exclude)</option>
                    <option value="1"{y}>Include</option>
                    <option value="0"{n}>Exclude</option>
                </select>
            """.format(PARAM=PARAM,
                       y=ws.option_selected(self.filter_include_old_versions,
                                            1),
                       n=ws.option_selected(self.filter_include_old_versions,
                                            0)),
            ACTION.APPLY_FILTER_INCLUDE_OLD_VERSIONS,
            filters
        ) or found_one
        found_one = get_filter_html(
            "Tablet device",
            self.filter_device,
            ACTION.CLEAR_FILTER_DEVICE,
            cc_device.get_device_filter_dropdown(self.filter_device),
            ACTION.APPLY_FILTER_DEVICE,
            filters
        ) or found_one
        found_one = get_filter_html(
            "Adding user",
            self.filter_user,
            ACTION.CLEAR_FILTER_USER,
            """<input type="text" name="{}">""".format(PARAM.USER),
            ACTION.APPLY_FILTER_USER,
            filters
        ) or found_one
        found_one = get_filter_html(
            "Start date (UTC)",
            cc_dt.format_datetime(self.get_filter_start_datetime(),
                                  DATEFORMAT.LONG_DATE),
            ACTION.CLEAR_FILTER_START_DATETIME,
            """<input type="date" name="{}">""".format(PARAM.START_DATETIME),
            ACTION.APPLY_FILTER_START_DATETIME,
            filters
        ) or found_one
        found_one = get_filter_html(
            "End date (UTC)",
            cc_dt.format_datetime(self.get_filter_end_datetime(),
                                  DATEFORMAT.LONG_DATE),
            ACTION.CLEAR_FILTER_END_DATETIME,
            """<input type="date" name="{}">""".format(PARAM.END_DATETIME),
            ACTION.APPLY_FILTER_END_DATETIME,
            filters
        ) or found_one
        found_one = get_filter_html(
            "Text contents",
            ws.webify(self.filter_text),
            ACTION.CLEAR_FILTER_TEXT,
            """<input type="text" name="{}">""".format(PARAM.TEXT),
            ACTION.APPLY_FILTER_TEXT,
            filters
        ) or found_one

        clear_filter_html = u"""
                <input type="submit" name="{ACTION.CLEAR_FILTERS}"
                        value="Clear all filters">
                <br>
        """.format(
            ACTION=ACTION,
        )
        no_filters_applied = "<p><b><i>No filters applied</i></b></p>"
        html = u"""
            <form class="filter" method="POST" action="{script}">

                <input type="hidden" name="{PARAM.ACTION}"
                        value="{ACTION.FILTER}">

                <input type="submit" class="important"
                        name="{ACTION.APPLY_FILTERS}"
                        value="Apply new filters">
                <br>
                <!-- First submit button is default on pressing Enter,
                which is why the Apply button is at the top of the form -->

                {clearbutton}

                {filters}
            </form>
        """.format(
            script=pls.SCRIPT_NAME,
            ACTION=ACTION,
            PARAM=PARAM,
            clearbutton=clear_filter_html if found_one else no_filters_applied,
            filters="".join(filters),
        )
        return html
コード例 #23
0
ファイル: bdi.py プロジェクト: parijatsahai/camcops
 def get_clinical_text(self):
     if not self.is_complete():
         return CTV_DICTLIST_INCOMPLETE
     return [{"content": u"{} total score {}/63".format(ws.webify(self.bdi_scale), self.total_score())}]
コード例 #24
0
ファイル: progressnote.py プロジェクト: parijatsahai/camcops
 def get_clinical_text(self):
     return [{"content": ws.webify(self.note)}]
コード例 #25
0
 def subsubhead_text(self, fieldname):
     return self.subsubheading(fieldname) + u'<div><b>{}</b></div>'.format(
         ws.webify(getattr(self, fieldname))
     )
コード例 #26
0
ファイル: cc_string.py プロジェクト: parijatsahai/camcops
def WSTRING(stringname):
    """Returns a web-safe version of a string from the XML string file."""
    return ws.webify(LSTRING(stringname))
コード例 #27
0
ファイル: gass.py プロジェクト: parijatsahai/camcops
 def get_task_html(self):
     score = self.total_score()
     ANSWER_DICT = {None: "?"}
     for option in range(0, 4):
         ANSWER_DICT[option] = (
             str(option) + u" — " + WSTRING("gass_option" + str(option)))
     h = u"""
         <div class="summary">
             <table class="summary">
                 {}
                 <tr><td>{}</td><td><b>{}</b> / 63</td></tr>
             </table>
         </div>
         <div class="explanation">
             Ratings pertain to the past week.
         </div>
         <table class="taskdetail">
             <tr>
                 <th width="65%">Question</th>
                 <th width="20%">Answer</th>
                 <th width="15%">Distressing?</th><
             /tr>
     """.format(
         self.get_is_complete_tr(),
         WSTRING("total_score"), score
     )
     h += self.get_group_html(Gass.list_sedation,
                              WSTRING("gass_group_sedation"),
                              ANSWER_DICT)
     h += self.get_group_html(Gass.list_cardiovascular,
                              WSTRING("gass_group_cardiovascular"),
                              ANSWER_DICT)
     h += self.get_group_html(Gass.list_epse,
                              WSTRING("gass_group_epse"),
                              ANSWER_DICT)
     h += self.get_group_html(Gass.list_anticholinergic,
                              WSTRING("gass_group_anticholinergic"),
                              ANSWER_DICT)
     h += self.get_group_html(Gass.list_gastrointestinal,
                              WSTRING("gass_group_gastrointestinal"),
                              ANSWER_DICT)
     h += self.get_group_html(Gass.list_genitourinary,
                              WSTRING("gass_group_genitourinary"),
                              ANSWER_DICT)
     if self.is_female():
         h += self.get_group_html(Gass.list_prolactinaemic_female,
                                  WSTRING("gass_group_prolactinaemic") +
                                  " (" + WSTRING("female") + ")",
                                  ANSWER_DICT)
     else:
         h += self.get_group_html(Gass.list_prolactinaemic_male,
                                  WSTRING("gass_group_prolactinaemic") +
                                  " (" + WSTRING("male") + ")",
                                  ANSWER_DICT)
     h += self.get_group_html(Gass.list_weightgain,
                              WSTRING("gass_group_weightgain"),
                              ANSWER_DICT)
     h += u"""
             <tr class="subheading"><td colspan="3">{}</td></tr>
             <tr><td colspan="3">{}</td></tr>
         </table>
     """.format(
         WSTRING("gass_medication_hint"),
         ws.webify(self.medication)
     )
     return h
コード例 #28
0
ファイル: diagnosis.py プロジェクト: parijatsahai/camcops
 def get_html_table_row(self):
     return tr(
         self.seqnum + 1,
         answer(ws.webify(self.code)),
         answer(ws.webify(self.description)),
     )
コード例 #29
0
ファイル: ided3d.py プロジェクト: parijatsahai/camcops
    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
コード例 #30
0
 def get_ctv_description_content(self, x):
     return {
         "description": ws.webify(WSTRING(x)),
         "content": ws.webify(getattr(self, x))
     }