[% META title="Results" %] [% patient = data.patient_case.patient; request_data = data.as_tree; # save multiple lookups if undefined # PROCESS dumper.tt dump = # request_data; # all_results; # result_summaries; # results_summary_opts; # data_map.requested_tests; # data_files; # c.stash.error_msg; # validation_failures; # raw_lab_test_data.haematology_data; # section_with_result_errors; # c.debug('######################'); # to reveal any db calls from templates %] [% # PROCESS site/js/jquery.tt # already loaded in html_wrapper %] [% PROCESS record/content_header.tt %] [% IF c.is_lab_staff; patient_notes = patient.patient_note || outreach.demographics.patient_notes; INCLUDE site/previous_requests.tt; # don't use PROCESS or 'data' gets clobbered INCLUDE site/previous_lab_tests.tt IF previous_requests.size; %]

Patient notes:

[% END %]

Report [% div_name = 'lab_results'; INCLUDE site/snippets/toggleview.tt %]

[% PROCESS record/report.tt %]

Request notes: [% notes = request_data.request_general_note.detail %] [% site.html.submit UNLESS is_locked %]

Lab Investigations

[% haem_data = raw_lab_test_data.haematology_data %] [% IF haem_data AND ( haem_data.status.match('verified') OR c.user_can('modify_results') ) %]
[% div_name = 'HaemData'; INCLUDE site/snippets/toggleview.tt type = 'folder' %]
Haematology [% IF NOT haem_data.status.match('verified') %] [ UNVERIFIED ] [% END %]
[% INCLUDE result/haem_data.tt function = 'result'%]
[% END %] [% # FOREACH section IN all_results.keys.sort; # doesn't handle Genomics section names nsorted_sections = natural_sort(all_results.keys); # PROCESS dumper.tt dump = nsorted_sections; FOREACH section IN nsorted_sections; # PROCESS dumper.tt dump = all_results.item(section); # do some data manipulations: this_section = all_results.item(section); # PROCESS dumper.tt dump = this_section; sectionName = section.replace('\W', '_') | lower; # for result summary tmpls NEXT UNLESS this_section.is_active.match('yes'); # get list of active (ie requested) lab_test field labels: incomplete_tests = [ ]; active_tests = [ ]; # reset array for each section FOREACH entry IN this_section.panel; # PROCESS dumper.tt dump = entry; test_data = entry.value; # PROCESS dumper.tt dump = test_data; active_tests.push(entry.key) IF test_data.status; # been requested if defined status incomplete_tests.push(entry.key) IF test_data.status AND NOT test_data.status.match('complete'); END; # get list of resultable lab_test field labels: resultable_tests = [ ]; # reset array for each section FOREACH entry IN this_section.test; # PROCESS dumper.tt dump = entry; test_data = entry.value; # PROCESS dumper.tt dump = test_data; resultable_tests.push(test_data.field_label) IF test_data.has_results.match('yes'); active_tests.push(entry.key) IF test_data.status; # been requested if defined status incomplete_tests.push(entry.key) IF test_data.status AND NOT test_data.status.match('complete'); END; # PROCESS dumper.tt dump = active_tests; # PROCESS dumper.tt dump = resultable_tests; # PROCESS dumper.tt dump = incomplete_tests; %]
[% div_name = sectionName; INCLUDE site/snippets/toggleview.tt type = 'folder' %] [% PROCESS result/section_header.tt %]
[% site.html.ie_span_fix %] [% toggle_class = section_with_result_errors.match('^' _ sectionName _ '$') ? 'itemshow' : 'itemhidden' %]
[% # if section uses results import and not already got them: IF this_section.has_results_import.match('yes') AND NOT is_locked AND NOT result_summaries.item(section).results_summary; %] [% # load link to datafile if exists AND record screened: IF has_optional.initial_screen AND have_data_files(); # callback sub in C::Result::load() %]

[ import results data ]

[% END; END %]

Requests: [% div_name = sectionName _ '_requests'; INCLUDE site/snippets/toggleview.tt %] [% IF c.user_can('modify_results') AND incomplete_tests.size; USE url( app_url _ '/worklist/display/' _ this_section.id, request_id = data.id, display_format='Data Entry'); %] [% END %]

[% div_class = 'normal' # for panels.tt %]
[% IF this_section.panel.size; # PROCESS dumper.tt dump = this_section.panel %] [% div_class = 'indent' # override previous settings; for panels.tt %]

Investigations:

[% END %] [% UNLESS is_locked # can still view results section if locked %]
[% # IF we_still_need_this - only used by remote section (foreign_id) %] [% # END %] [% END %] [% PROCESS result/panels.tt IF this_section.panel.size %] [% PROCESS result/single_tests.tt IF this_section.test.size %] [% IF this_section.has_foreign_id.match('yes') %]

Remote system ID:

[% END %] [% IF this_section.has_section_notes.match('yes') %]

Section notes:

[% section_notes = lab_section_notes.item(this_section.id); meta_data = c.get_meta_data('ScreenLabTestDetail'); max_length = meta_data.column('test_details').length; %]

[% END %] [% UNLESS is_locked # can view results section if locked %]

[% site.html.submit %] [% site.html.reset %]

[% END # start form tag also blocked if record locked %]
[% IF this_section.has_result_summary.match('yes') OR resultable_tests.size %] [% PROCESS result/data_entry.tt %] [% END %]
[% END %]