[% META title="Report" %]
<!-- BEGIN report/default.tt -->
[%
# handles initial report, (optional) authorisation and diagnosis revision:
# 'authorisation_request' tt_param blocks loading of diagnosis, revision and
# morphology/comment fields, and previous diagnoses list, and
# disables all text, radio & checkbox fields - only diagnosis_id required
# 'pre-authorisation-check' query param sets 'revision' field to optional
%]
[% # PROCESS dumper.tt dump =
# c.session.param('UserProfile');
# c.stash.errs;
# history.reported;
# data.request_report.diagnosis;
# data.request_gross_description;
# previous_cases;
# result_summaries;
# raw_lab_test_data;
# lab_section_notes;
# previous_diagnoses_data;
# request_options;
# unrecognised_clinical_details;
# unrecognised_comment_words;
# highlighted_comment;
# diagnosis_change_options;
# unrecognised;
%]
[% # define some data structures:
request_data = data; # preserve 'data' in case it's overwritten in PROCESS's
report_data = data.request_report; # save multiple lookups if undefined
this_user = c.session.param('UserProfile');
%]
[% PROCESS site/popup.tt height=280, width=800, top=280 %]
<script type="text/javascript" src="/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="/js/jquery.textarea-expander.js"></script>
<script type="text/javascript" src="/speller/spellChecker.js"></script>
<script type="text/javascript" src="/js/changeText.js"></script>
[% INCLUDE site/js/openSpellChecker.tt form_name = 'reportForm' %]
<script type="text/javascript">
function load_add_word_result (uri, elem) {
$(elem).load(uri);
}
</script>
[%
IF authorisation_request;
this_form_action = 'pre_authorisation_check';
this_onsubmit = pre_authorisation_check_onsubmit;
this_dfv_js = pre_authorisation_check_dfv_js;
ELSE;
this_form_action = 'update_report';
this_onsubmit = report_onsubmit;
this_dfv_js = report_dfv_js;
END;
%]
[% IF dfv_errors %]
<p class="error">[% c.cfg('msg').dfv_errors %]</p>
[% END %]
[% this_dfv_js # set above %]
[% PROCESS record/patient_summary.tt %]
[% INCLUDE site/previous_cases.tt # don't use PROCESS or 'data' gets clobbered %]
[% PROCESS report/test_summary.tt %]
[% PROCESS report/result_summary.tt IF result_summaries.size %]
[% IF lab_section_notes.size
AND c.cfg('settings').report_display_notes.match('yes');
# create id => section_name map:
FOREACH section IN raw_lab_test_data.all_lab_sections;
# PROCESS dumper.tt dump = section.as_tree;
lab_sections.${section.id} = section.section_name;
END; # PROCESS dumper.tt dump = lab_sections; %]
<p class="title">Section notes:
[% div_name = 'notes'; INCLUDE site/snippets/toggleview.tt %]
</p>
<div id="[% div_name %]" class="itemhidden">
[% FOREACH section IN lab_section_notes; %]
<p class="indent">
<span class="title">[% lab_sections.item(section.key) %]:</span>
[% section.value %]
</p>
[% END %]
</div>
[% END %]
[% IF outstanding_tests.size; # PROCESS dumper.tt dump = outstanding_tests
have_outstanding_tests = 1 # flag for later %]
<p class="classname">
<span class="highlight"><strong>outstanding tests</strong></span>
</p>
<div class="indent">
[% FOREACH section IN outstanding_tests.keys %]
<p class="indent">
<span class="title">[% section %]:</span>
[% outstanding_tests.item(section).join(', ') %]
</p>
[% END %]
</div>
[% END %]
<p class="section_header">Report</p>
[% IF spelling_checked AND NOT has_unrecognised.size %]
<p class="info">
<span class="indent">Spellchecker reports no unrecognised words</span>
</p>
[% END %]
<form action="[% app_url %]/report/[% this_form_action %]/[% request_data.id %]"
method="post" [% this_onsubmit # set above %] name="reportForm" id="reportForm">
[% IF report_data.diagnosis # include diagnosis_id in case amendment: %]
<input type="hidden" name="_diagnosis_id" value="[% report_data.diagnosis.id %]" />
[% END %]
<table class="indent">
<tr>
<td class="label">General notes:</td>
<td class="content">
<textarea name="general_notes" rows="1" cols="70" class="expand20-200"
[% site.html.onfocus %] [% site.html.disabled IF authorisation_request %]
>[% request_data.request_general_note.detail %]</textarea>
</td>
</tr>
<tr>
<td class="label" style="vertical-align: top">Clinical details:</td>
<td class="content">
<textarea name="clinical_details" rows="1" cols="70" [% site.html.onfocus %]
class="expand20-200" [% site.html.disabled IF authorisation_request %]
id="clinical_details">[% report_data.clinical_details %]</textarea>
[% error_clinical_details %]
[% IF unrecognised_clinical_details_words.size %]
[% PROCESS report/highlight.tt
this_text = highlighted_clinical_details
this_field = 'clinical_details' %]
[% PROCESS report/speller.tt list = unrecognised_clinical_details_words %]
[% END %]
</td>
</tr>
[% IF want_gross_description OR request_data.request_gross_description %]
<tr>
<td class="label" style="vertical-align: top">Gross description:</td>
<td class="content">
<input type="hidden" name="_want_gross_description" value="1" />
<textarea name="gross_description" rows="1" cols="70" [% site.html.onfocus %]
class="expand20-200" [% site.html.disabled IF authorisation_request %]
>[% request_data.request_gross_description.detail %]</textarea>
[% error_gross_description %]
</td>
</tr>
[% END %]
<tr>
<td class="label">Specimen quality:</td>
<td class="content">
[% FOREACH option IN ['good', 'adequate', 'poor'];
quality_match = report_data.specimen_quality.match(option) ? 1 : 0 %]
<label>
<span class="[% quality_match ? 'title' : 'normal' %]">
[% option | ucfirst %]</span><input type="radio"
name="specimen_quality" value="[% option %]"
[% site.html.disabled IF authorisation_request %]
[% 'checked' IF quality_match %] />
</label>
<span style="margin-left: 0.5em" class="spacer"> </span>
[% END %]
[% error_specimen_quality %]
</td>
</tr>
[% UNLESS authorisation_request %]
<tr>
<td class="label" style="vertical-align: top">Morphology/Comment:</td>
<td class="content">
<textarea name="comment" rows="3" cols="70" class="expand20-500"
id="comment">[% report_data.comment | html %]</textarea>
[% error_comment %]
[% IF unrecognised_comment_words.size %]
[% PROCESS report/highlight.tt
this_text = highlighted_comment
this_field = 'comment' %]
[% PROCESS report/speller.tt list = unrecognised_comment_words %]
[% END %]
</td>
</tr>
[% END %]
<tr>
<td class="label" style="vertical-align: top">
Diagnosis:
</td>
<td class="content">
<select name="diagnosis_id">
<option value="">-- select one --</option>
[% FOREACH category IN diagnoses.keys.sort %]
<optgroup label="[% category %]">
[% FOREACH diagnosis IN diagnoses.item(category) %]
<option value="[% diagnosis.id %]" [% 'selected' IF
diagnosis.id == report_data.diagnosis.id
AND NOT authorisation_request %]>
[% diagnosis.name %]
</option>
[% END %]
</optgroup>
[% END %]
</select>
[% error_diagnosis_id %]
[% IF report_data.diagnosis AND NOT authorisation_request %]
<span class="title">Revision:</span>
<select name="revision">
<option value="">--</option>
[% FOREACH option IN diagnosis_change_options.keys.sort %]
<option value="[% option %]">[% option %]</option>
[% END %]
</select>
[% error_revision; error__diagnosis_id # could be either %]
[% END %]
[% IF previous_diagnoses AND c.user_can('report')
AND NOT authorisation_request %]
<p><i>Revisions [[% previous_diagnoses %]]:</i>
[% div_name = 'diagnoses'; INCLUDE site/snippets/toggleview.tt %]
</p>
<div id="[% div_name %]" class="itemhidden">
<ol>
[% FOREACH d IN previous_diagnoses_data %]
<li class="results">
[% d.diagnosis.name | html %]
[[% d.user.username | upper %]: [% d.reason %]]
[% d.time.strftime('%a %d.%b.%Y @ %T') %]
</li>
[% END %]
</ol>
[% END %]
</td>
</tr>
<tr>
<td class="label">Report by:</td>
<td>
[% IF history.reported.user %]
<span class="title">
[% history.reported.user.first_name | ucfirst; ' ';
history.reported.user.last_name | ucfirst %]
</span> on <span class="title">
[% history.reported.time.strftime('%a %d.%b.%Y @ %H:%M') %]
</span>
[% ELSE %]
<span class="grey">
[% this_user.first_name | ucfirst %]
[% this_user.last_name | ucfirst %]
</span>
[% END %]
</td>
</tr>
[% IF history.authorised %]
<tr>
<td class="label">Authorised by:</td>
<td>
<span class="title">
[% history.authorised.user.first_name | ucfirst; ' ';
history.authorised.user.last_name | ucfirst; %]
</span> on <span class="title">
[% history.authorised.time.strftime('%a %d.%b.%Y @ %H:%M') %]
</span>
</td>
</tr>
[% ELSIF status_options.authorised.is_active.match('yes')
AND ( c.query.param('pre-authorisation-check') OR self_authorisable ) %]
<tr>
<td class="label">Authorise report:</td>
<td>
[% IF this_user.username == history.reported.user.username %]
[% disable_submit = 1 %]
<span class="error">*** self-authorisation not permitted ***</span>
[% ELSE %]
<input type="checkbox" name="authorise" value="1" />
<input type="hidden" name="pre-authorisation-check" value="1" />
[% END %]
</td>
</tr>
[% END %]
<tr>
<td class="label">Request status:</td>
<td class="content">
[% FOREACH option IN [ 'new', 'relapse', 'default' ];
status_match = report_data.status.match(option) ? 1 : 0 %]
<label>
<span class="[% status_match ? 'title' : 'normal' %]">
[% option | ucfirst %]</span><input type="radio" name="status"
value="[% option %]" [% 'checked' IF status_match %]
[% site.html.disabled IF authorisation_request %] />
</label>
<span style="margin-left: 0.5em"> </span>
[% END %]
[% error_status %]
[% UNLESS previous_cases.this_id.size %]
<span class="red">** unknown patient details **</span>
[% END %]
</td>
</tr>
[% UNLESS authorisation_request %]
<tr>
<td class="label">Others:</td>
<td class="content">
[% IF request_options.teaching.is_active.match('yes') %]
Teaching case:
<input type="checkbox" name="teaching" value="1"
[% 'checked' IF request_options.teaching.is_selected %] />
[% END %]
</td>
</tr>
[% END %]
[% IF have_outstanding_tests %]
<tr>
<td colspan="2" class="borderless">
<input type="hidden" name="_have_outstanding_tests" value="1" />
<span class="indent">
<span class="normal">ACKNOWLEDGE OUTSTANDING TESTS:</span>
<input type="checkbox" name="confirm_outstanding" value="1" />
[% IF error_confirm_outstanding %]
[% error_confirm_outstanding %]
[% ELSE %]
<span class="warning">« required</span>
[% END %]
</span>
</td>
</tr>
[% END %]
[% IF history.authorised AND
NOT data.status_option.description.match('complete') AND
NOT have_outstanding_tests %]
<tr>
<td colspan="2" class="borderless">
<span class="indent"><!-- style="float: right" -->
<span class="normal">CONFIRM FINAL DIAGNOSIS:</span>
<input type="checkbox" name="final_diagnosis" value="1" />
</span>
[% error__diagnosis_id %]
</td>
</tr>
[% END %]
[% UNLESS disable_submit %]
<tr>
<td colspan="2" align="center" class="borderless">
<input type="button" value="Check Spelling" onClick="openSpellChecker();" />
[% IF spelling_checked # set flag for target rm update_report():
|| c.cfg('settings').require_spell_check.match('no') # not needed
|| authorisation_request # not needed %]
<input type="hidden" name="_spelling_checked" value="1" />
[% site.html.submit %]
[% ELSE %]
<input type="submit" value="Preview" style="color: #008000" />
[% END %]
[% site.html.reset %]
</td>
</tr>
[% END %]
</table>
</form>
<!-- END report/default.tt -->