RSS Git Download  Clone
Raw Blame History
  [% META title = 'Admin » Linked Lab Tests' -%]
<!-- BEGIN [% template.name %] -->
    [% # PROCESS dumper.tt dump = sections %]
    [% # PROCESS dumper.tt dump = linked_tests_map %]
	[% # PROCESS dumper.tt dump = t.as_tree FOREACH t IN all_linked_tests %]
    [% # PROCESS dumper.tt dump = vars %]

    [% IF all_linked_tests.size %]
        <p class="header">Linked Lab Tests
			[% div_name = 'linked_tests'; INCLUDE site/snippets/toggleview.tt %]</p>
		[% class = c.query.param('lab_section_id') ? 'itemhidden' : 'normal' %]
		<div id="linked_tests" class="[% class %]">
          <table class="indent">
            <tr>
				<td class="borderless"></td>
                <th>Parent Test</th>
                <th>Linked Test</th>
                <td class="borderless"></td>
            </tr>
            [% FOREACH test IN all_linked_tests;
				# PROCESS dumper.tt dump = test.as_tree; %]
                <tr>
					<td>[% loop.count %]</td>
                    <td>
                        [% test.parent_lab_test.field_label %]
                        [[% test.parent_lab_test.lab_section.section_name %]]
                    </td>
                    <td>
                        [% test.linked_lab_test.field_label %]
                        [[% test.linked_lab_test.lab_section.section_name %]]
                    </td>
                    <td>
                        <a href="[% self_url %]?lab_section_id=[%
							test.parent_lab_test.lab_section_id %]&parent_test_id=[%
							test.parent_test_id %]">edit</a>
                    </td>
                </tr>
            [% END %]
          </table>
		</div>
    [% ELSE %]
        <p class="warning">No linked lab tests configured</p>
    [% END %]

    <p class="header">Configure Linked Lab Tests</p>

	<form method="get" action="[% c.query.self_url %]" name="section" id="section">
        <p class="bold">Select lab section of parent lab test:
            <select name="lab_section_id" onChange="submit()">
                <option value="">--</option>
                [% FOREACH section IN sections %]
                    <option value="[% section.id %]"
                        [% 'selected' IF section.id == c.query.param('lab_section_id') %]>
                        [% section.section_name %]</option>
                [% END %]
            </select>
        </p>
    </form>

    [% IF parent_tests.size; # PROCESS dumper.tt dump = parent_tests; %]
	<form method="get" action="[% c.query.self_url %]" name="parent-test"
            id="parent-test">
        <input type="hidden" value="[% vars.lab_section_id %]"
            name="lab_section_id" />

        <div class="indent">
          <p class="bold">1) Select parent lab test [
            <span class="red">pre-configured parent test(s) in red</span>
            [% UNLESS c.query.param('parent_test_id') %];
                <span class="error">warning: no parent lab test selected</span>
            [% END %]]
          </p>

          <table class="results">
            <tr>[% count = 1 %]
            [% FOREACH test IN parent_tests; # test.is_active;
				NEXT UNLESS test.is_active.match('yes');
                class = linked_tests_map.item(test.id) ? 'red' : 'normal' %]
              <td align="right" class="[% class %]" width="170">
                [% test.field_label | html %]
              </td>
              <td>
                <input type="radio" name="parent_test_id" value="[% test.id %]"
                    [% 'checked' IF test.id == vars.parent_test_id %] />
              </td>
              [% UNLESS loop.last OR ( count % 5 ) # don't start new table unless multiple of 6: %]
                </tr>
              </table>
              <table class="results">
                <tr>
              [% END %]
              [% count = count + 1 %]
            [% END %]
            [% '<td></td>' IF count == 1 # or get invalid html %]
            </tr>
          </table>
          [% # UNLESS c.query.param('parent_test_id' ) # need this anyway %]
              <div class="center">[% site.html.submit %]</div>
          [% # END %]
        </div>
    </form>
   [% END %]

    [% IF lab_tests.size %]
	<form method="get" action="[% app_url %]/admin/lab_test_linked/do_link/[%
        vars.parent_test_id %]" name="linked-test" id="linked-test">
      <div class="indent">
        <p class="bold">2) Select lab test(s) for linking:</p>

        <div class="menubody indent">
          [% FOREACH section IN lab_tests.keys.sort; # PROCESS dumper.tt dump = section %]
              [%
                  expand = 0; # auto-expand section if any tests already selected
                  panels = [ ];
                  tests  = [ ];
                  FOREACH entry IN lab_tests.item(section); # PROCESS dumper.tt dump = entry;
                       tests.push(entry.label) IF entry.test_type == 'test';
                      panels.push(entry.label) IF entry.test_type == 'panel';
                      IF entry.selected; expand = expand + 1; END;
                  END;
              # PROCESS dumper.tt dump = tests;
              # PROCESS dumper.tt dump = panels;
              %]

          <div class="linkwithicon">
            [% div_name = section.replace(' ', '_');
              INCLUDE site/snippets/toggleview.tt type = 'folder' %]
            <div class="aftericon">
              <span class="title">[% section %]</span>
            </div>
          </div>
                [% site.html.ie_span_fix %]
          <div class="[% expand ? 'normal' : 'itemhidden' %]" id="[% div_name %]">
            [% IF panels.size %]
              [% PROCESS admin/screen/test/row.tt test_type = 'panel' # shared with screen function %]
            [% END %]

            [% IF tests.size %]
              [% PROCESS admin/screen/test/row.tt test_type = 'test' # shared with screen function %]
            [% END %]
          </div>
          [% END %]
        </div>

        <div class="center">[% site.html.submit %] [% site.html.reset %]</div>
      </div>
    </form>
    [% END %]
<!-- END [% template.name %] -->