RSS Git Download  Clone
Raw Blame History
    [% META title="Sample storage" %]
<!-- BEGIN [% template.name %] -->
    [% # PROCESS dumper.tt dump = specimen_map %]
    [% # PROCESS dumper.tt dump = specimens %]
    
  [% # define some data structures:
        # c.debug('##############'); # to reveal any db calls from templates
    data = request_data;
    patient = request_data.patient_case.patient; # not as_tree - preserve datetime objects %]

    <h2>
        Sample storage on [% patient.last_name | upper %],
        [% format_firstname(patient) || patient.first_name | ucfirst %]
        [ [% PROCESS site/lab_number.tt %] ]
    </h2>

    <h3 class="header">Current stock</h3>
    
    <p class="info indent">Number of vials in store: [% storage.size || 0 %]</p>
    
    [% IF storage.size %]
        <table class="indent">
            <tr>
                <td class="borderless"></td>
                <th>Specimen</th>
                <th>Location</th>
                <th>In</th>
                <th>Out</th>
                <td class="borderless"></td>
            </tr>
        [% FOREACH item IN storage %]
            <tr>
                <td>[% loop.count %]</td>
                <td>[% item.specimen.sample_code %]</td>
                <td>[% item.vial_id %]</td>
                <td>[% item.created_at.strftime('%d.%b.%Y') %]</td>
                <td>[% item.signed_out.strftime('%d.%b.%Y') %]</td>
                <td><a href="">[edit]</a></td>
            </tr>
        [% END %]
        </table>
    [% END %]
    
    [%
        sample_code = specimen_map.item(data.id).sample_code;
            # PROCESS dumper.tt dump = sample_code;
        available = [];
        
        FOREACH s IN sample_code;
            NEXT IF specimens.${s};
            available.push(s);
        END;
        
        IF available.size; # if any specimens not already stored
            # PROCESS dumper.tt dump = available;
    %]

    <p class="bold indent">Input new vial</p>
    
    <form action="[% app_url %]/storage/input/[% data.id %]" method="post">
        <table class="indent">
            <tr>
                <td>
                [% FOREACH specimen IN available %]
                <div>
                    <label><input type="radio" name="specimen" value="[% specimen %]"
                      [% IF available.size == 1; 'checked=1'; END %]  />
                        [% specimen %]</label>
                </div>
                [% END %]
                </td>
                <td><input type="text" name="vial_id" /></td>
                <td class="borderless">
                    <span class="error">&#171; place cursor here</span>
                    [% site.html.submit %]
                    [% site.html.reset %]
                </td>
            </tr>
        </table>
    </form>
    [% END %]

    [% IF storage.size %]    
    <h3 class="header">Output vials</h3>
    <form action="[% app_url %]/storage/output/[% data.id %]" method="post">
        
    </form>
    [% END %]

<!-- END [% template.name %] -->