RSS Git Download  Clone
Raw Blame History
<!-- BEGIN [% template.name %] -->
  [%  # INCLUDE dumper.tt dump = # automatic = session, vars, params, request & settings
       # settings;
       # session;
       # request;
       # params;
       # env;
       # errs;
       # vars;
    %]

    [% # pds_.tt also sets pds_code param & 'is_validated' if SMSP-0000
        IF pds.size; pds_display = PROCESS pds.tt; END;
        # flag for loading info and setting submit button text:
        generate_pdf = ( params.item('_skip_pds') || is_validated );
        PROCESS headers.tt; # sets header
    %]

    <div class="container">
    <div class="row">
      <img src="[% request.uri_base %]/images/[% header.logos.large %]" alt=""
          class="img-responsive" border="0" align="right" />
    </div>

    <div class="row">
        <fieldset><legend>HMDS [% 'BCR-ABL Monitoring' IF params.bcr_abl_req %]
            Request Form</legend></fieldset>
    </div>

  <form class="form-horizontal" action="[% request.uri_base %]/"
        [% IF generate_pdf %]target="_blank"[% END %] method="post">
    <input type="hidden" name="pds_code" value="[% pds.ErrorCode
        || params.pds_code # latter if _skip_pds employed %]" />

    <div class="row">
        <div class="text-info indent strong">
            <span class="pull-right">
                [<a href="[% request.uri_base;
                    '/bcr-abl' IF params.bcr_abl_req %]">load new request form</a>]
            </span>

            [% IF vars.found_patient.match('yes') %]
                Matching patient details found
                <span class="found">please check and amend if necessary</span>
            [% ELSIF vars.found_patient.match('no'); # use para for extra spacing: %]
                <p class="bg-info">No matching patient details found</p>
            [% END %]
        </div>

        [% IF errs %]
            <p class="dfv-err">Form validation failed, please correct error(s) below:</p>
        [% ELSIF generate_pdf %]
            <p class="bg-success col-md-7 indent">Form passed validation. Please check
                details are correct and re-submit. The completed request form
                will open in a new tab/window as a PDF. Please print it and send
                with your specimen(s) to the laboratory at the address provided.
            </p>
            <input type="hidden" name="generate_pdf" value="1" />
        [% ELSE %]
        <!--[if lt IE 10]>
            <p class="strong">All <span class="text-danger">highlighted</span>
                fields are required:</p>
            [%# can't use this - submits watermark as field content !!
                INCLUDE watermarks.tt; # placeholder doesn't work IE <10 %]
        <![endif]-->
        [% END %]
    </div>

    [% IF pds.size %]
        <div class="row">
            <div class="col-md-8">[% pds_display %]</div>
        </div>
    [% END %]

    <div class="row">
        <div class="indent">
            <fieldset>
              [% class = vars.found_patient.match('yes') ? 'found' : 'normal' %]
              <div class="col-md-8 [% class # pale background if found %]">
                <!-- Text input-->
                <div class="form-group">
                  <label class="col-md-2 control-label text-danger" for="nhs_number">
                    NHS number</label>
                  <div class="col-md-4">
                    [% errs.nhs_number %]
                    <div id="nhsno_result" class="dfv-err"></div>
                  <input id="nhs_number" name="nhs_number" placeholder="required field"
                        class="form-control input-md" required="" type="text"
                        value="[% params.nhs_number %]">
                  </div>
                </div>

                <!-- Text input-->
                <div class="form-group">
                  <label class="col-md-2 control-label text-danger" for="last_name">
                    Last name</label>
                  <div class="col-md-4">
                    [% errs.last_name %]
                  <input id="last_name" name="last_name" placeholder="required field"
                        class="form-control input-md" required="" type="text"
                        value="[% params.last_name.upper %]" />
                  </div>
                </div>

                <!-- Text input-->
                <div class="form-group">
                  <label class="col-md-2 control-label text-danger" for="first_name">Forename</label>
                  <div class="col-md-4">
                    [% errs.first_name %]
                  <input id="first_name" name="first_name" placeholder="required field"
                        class="form-control input-md" required="" type="text"
                        value="[% params.first_name %]" />
                  </div>
                </div>

                <!-- Text input-->
                <div class="form-group">
                  <label class="col-md-2 control-label" for="middle_name">Middle name</label>
                  <div class="col-md-4">
                    [% errs.middle_name %]
                  <input id="middle_name" name="middle_name" placeholder="optional field"
                        class="form-control input-md" type="text"
                        value="[% params.middle_name %]" />
                  </div>
                </div>

                <!-- Text input-->
                <div class="form-group">
                  <label class="col-md-2 control-label text-danger" for="textinput">
                    Date of Birth</label>
                  <div class="col-md-4">
                    [% errs.day OR errs.month OR errs.year %]
                    [% INCLUDE dateselect.tt %]
                  </div>
                </div>

                <!-- Multiple Radios (inline) -->
                <div class="form-group">
                  <label class="col-md-2 control-label text-danger" for="radios">
                    Gender</label>
                  <div class="col-md-3">
                    [% errs.gender %]
                    <label class="radio-inline" for="gender-0">
                      <input name="gender" id="gender-0" value="M" type="radio"
                      [% 'checked' IF params.gender.match('M') %] />M
                    </label>
                    <label class="radio-inline" for="gender-1">
                      <input name="gender" id="gender-1" value="F" type="radio"
                      [% 'checked' IF params.gender.match('F') %] />F
                    </label>
                    <label class="radio-inline" for="gender-2">
                      <input name="gender" id="gender-2" value="U" type="radio"
                      [% 'checked' IF params.gender.match('U') %] />U
                    </label>
                  </div>
                </div>
              </div>

            [% IF vars.cml_data.size; # PROCESS dumper.tt dump = vars.cml_data;
                USE date = DateTime(today = 1); # PROCESS dumper.tt dump = date
            %]
              <div class="col-md-12">
                <h4>Previous BCR-ABL results
                    [% '[last 5]' IF vars.cml_data.results.size == 5 %]</h4>
                [% IF vars.cml_data.results.size %]
                  <ol id="bcr-abl-results">
                  [% FOREACH row IN vars.cml_data.results;
                      delta = row.registered.delta_days(date).delta_days;
                      class = row.result.match('BCR-ABL : ABL ratio') AND
                          delta < vars.min_delta ? 'highlight' : 'normal';
                  %]
                      <li>[% row.registered.strftime('%d.%b.%Y') %]
                          [<span class="[% class %]">[% delta %]d</span>]
                          [% row.result %]</li>
                  [% END %]
                  </ol>
                [% ELSE %]
                  <p class="text-info strong bg-info">
                    <span class="indent">None</span>
                  </p>
                [% END %]
              </div>

                [% BLOCK reason %]
                    <div class="col-md-12">
                        <input type="hidden" name="reason_required" value="1" />
                        <div class="form-group">
                          <label class="col-md-2 control-label text-danger"
                                for="reason">Reason for request
                          </label>
                          <div class="col-md-4">
                              [% IF errs.reason; errs.reason; ELSIF NOT skip_min_delta %]
                                <span class="dfv-err">Last result &lt;
                                  [% vars.min_delta %] days ago</span>[% END %]
                            <input id="reason" name="reason" type="text"
                                placeholder="required field"
                                class="form-control input-md"
                                value="[% params.reason %]" />
                          </div>
                        </div>
                    </div>
                [% END %]

                [%
                    IF vars.cml_data.date_last;
                        delta_days =
                            vars.cml_data.date_last.delta_days(date).delta_days;
                        INCLUDE reason IF delta_days < vars.min_delta;
                    ELSIF errs.reason; # errs.reason if failed validation
                        INCLUDE reason;
                    END;
                %]
            [% ELSIF params.reason; # form submission, passed validation
              INCLUDE reason skip_min_delta = 1; # skip info message
            END %]

              <div class="col-md-12">
                <!-- Text input-->
                <div class="form-group">
                  <label class="col-md-2 control-label" for="patient_number">
                    Patient/unit number
                  </label>
                  <div class="col-md-4">
                    [% errs.patient_number %]
                  <input id="patient_number" name="patient_number" type="text"
                        placeholder="optional field" class="form-control input-md"
                        value="[% params.patient_number %]" />
                  </div>
                </div>

                <!-- Text input-->
                <div class="form-group">
                  <label class="col-md-2 control-label text-danger" for="location">
                    Referring hospital
                  </label>
                  <div class="col-md-4">
                    [% IF errs.location_id; errs.location_id; ELSE %]
                        <div class="text-info text-centre strong bg-info">select
                            from suggestion list (min 3 chars):</div>
                    [% END %]
                    <input id="location" name="location_name" placeholder="required field"
                        class="form-control input-md" required="" type="text"
                        value="[% params.location_name %]" />
                    <input type="hidden" id="location_id" name="location_id"
                        value="[% params.location_id # in case resubmitted %]" />
                  </div>
                </div>

                <!-- Text input-->
                <div class="form-group">
                  <label class="col-md-2 control-label text-danger" for="referrer">
                    Consultant</label>
                  <div class="col-md-4">
                    [% IF errs.referrer; errs.referrer; ELSE %]
                        <div class="text-info text-centre strong bg-info">select
                            from suggestion list (min 3 chars):</div>
                    [% END %]
                  <input id="referrer" name="referrer" placeholder="required field"
                        class="form-control input-md" required="" type="text"
                        value="[% params.referrer %]" />
                  </div>
                </div>
                
                <!-- jquery autosuggest js -->
                <script type="text/javascript">
                  $( '#location' ).autocomplete({
                    source: "[% uri_for_autosuggest_location %]",
                    select: function( event, ui ) { // alert(ui.item.id);
                      $('#location_id').val(ui.item.id);
                      var newURL = '/ajax/jquery_referrer?location_id=' + ui.item.id;
                      $('#referrer').autocomplete('option', 'source', newURL);
                    }
                  });
                  $( '#referrer' ).autocomplete({
                    source: "[% uri_for_autosuggest_referrer %]",
                  });
                </script>

                <hr />

                <!-- Radio input-->
                <div class="form-group">
                    [% errs.doi %]
                  <label class="col-md-4 text-danger" for="doi">
                    Danger of infection sample?
                  </label>
                  <label class="radio-inline">
                      <input type="radio" name="doi" id="doi-yes" value="YES"
                        [% 'checked' IF params.doi.match('YES') %] /> YES
                  </label>
                  <label class="radio-inline">
                      <input type="radio" name="doi" id="doi-no" value="NO"
                        [% 'checked' IF params.doi.match('NO') %] /> NO
                  </label>
                </div>
                <!-- Radio input-->
                <div class="form-group">
                    [% errs.tb %]
                  <label class="col-md-4 text-danger" for="tb">
                    Microbiological or radiological evidence of TB?
                  </label>
                  <label class="radio-inline">
                      <input type="radio" name="tb" id="tb-yes" value="YES"
                      [% 'checked' IF params.tb.match('YES') %] /> YES
                  </label>
                  <label class="radio-inline">
                      <input type="radio" name="tb" id="tb-no" value="NO"
                        [% 'checked' IF params.tb.match('NO') %] /> NO
                  </label>
                </div>
                <!-- Radio input-->
                <div class="form-group">
                    [% errs.previous %]
                  <label class="col-md-4 text-danger" for="previous">
                    Previously investigated by [% header.lab_name %]?
                  </label>
                  <label class="radio-inline">
                      <input type="radio" name="previous" id="previous-yes" value="YES"
                        [% 'checked' IF params.previous.match('YES')
                            || vars.found_patient.match('yes') %] />
                        [% class= vars.found_patient.match('yes') ? 'previous' : 'normal' %]
                        <span class="[% class %]">YES</span>
                  </label>
                  <label class="radio-inline">
                      <input type="radio" name="previous" id="previous-no" value="NO"
                        [% 'checked' IF params.previous.match('NO') %] /> NO
                  </label>
                  <label class="radio-inline">
                      <input type="radio" name="previous" id="previous-unknown" value="UNKNOWN"
                        [% 'checked' IF params.previous.match('UNKNOWN') %] /> UNKNOWN
                  </label>
                </div>

                <hr />

                <!-- Text input-->
                <div class="form-group">
                  <label class="col-md-2 control-label text-danger" for="specimen">
                    Specimen type(s)
                  </label>
                  <div class="col-md-4">
                  [% errs.specimen %]
                  [% DEFAULT params.specimen = 'veneous blood' IF params.bcr_abl_req %]
                  <input id="specimen" name="specimen" placeholder="required field"
                        class="form-control input-md" required="" type="text"
                        value="[% params.specimen %]" />
                  </div>
                </div>

                <!-- Text input-->
                <div class="form-group">
                  <label class="col-md-2 control-label" for="sample_ref">
                    Sample ref
                  </label>
                  <div class="col-md-4">
                    [% errs.sample_ref %]
                  <input id="sample_ref" name="sample_ref" placeholder="optional field"
                        class="form-control input-md" type="text"
                        value="[% params.sample_ref %]" />
                  </div>
                </div>

                <!-- Text input-->
                [% UNLESS params.bcr_abl_req %]
                <div class="form-group">
                  <label class="col-md-3 control-label" for="report_to">
                    Who should report be returned to?
                  </label>
                  <div class="col-md-4">
                    [% errs.report_to %]
                  <input id="report_to" name="report_to" value="[% params.report_to %]"
                      placeholder="optional; only required if NOT referring consultant"
                      class="form-control input-md" type="text" />
                  </div>
                </div>
                [% END %]
                <hr />

            [%
              IF params.bcr_abl_req;
                INCLUDE bcr_abl_fields.tt;
              ELSE %]
                <!-- Text input-->
                <div class="form-group">
                  <label class="col-md-2 control-label text-danger" for="clinical_details">
                    Clinical details &amp; suspected diagnosis
                  </label>
                  <div class="col-md-5">
                    [% errs.clinical_details %]
                    <textarea id="clinical_details" name="clinical_details"
                        class="form-control" rows="3">[% params.clinical_details %]</textarea>
                  </div>
                </div>

                <!-- Text input-->
                <div class="form-group">
                  <label class="col-md-3 control-label text-danger" for="treatment">
                    Chemo/radiotherapy details?
                  </label>
                  <div class="col-md-4">
                    [% errs.treatment %]
                  <input id="treatment" name="treatment" placeholder="required field"
                        class="form-control input-md" required="" type="text"
                        value="[% params.treatment %]" />
                  </div>
                </div>
            [% END %]
                <hr />

                <div class="form-group">
                    <label class="col-md-1 control-label text-danger" for="hb">
                        Hb</label>
                    <div class="col-md-1">
                        [% errs.hb %]
                        <input type="text" class="form-control" id="hb" required
                            name="hb" placeholder="req'd" value="[% params.hb %]" />
                    </div>
                    <label class="col-md-1 control-label text-danger" for="wbc">
                        WBC</label>
                    <div class="col-md-1">
                        [% errs.wbc %]
                        <input type="text" class="form-control" id="wbc" required
                            name="wbc" placeholder="req'd" value="[% params.wbc %]" />
                    </div>
                    <label class="col-md-1 control-label text-danger" for="wbc">
                        Plts</label>
                    <div class="col-md-1">
                        [% errs.plt %]
                        <input type="text" class="form-control" id="plt" required
                            name="plt" placeholder="req'd" value="[% params.plt %]" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-1 control-label" for="lymphs">Lymphs</label>
                    <div class="col-md-1">
                        [% errs.lymphs %]
                        <input type="text" class="form-control" id="lymphs"
                            name="lymph" value="[% params.lymph %]" />
                    </div>
                    <label class="col-md-1 control-label" for="neut">Neut</label>
                    <div class="col-md-1">
                        [% errs.neut %]
                        <input type="text" class="form-control" id="neut"
                            name="neut" value="[% params.neut %]" />
                    </div>
                    <label class="col-md-1 control-label" for="other">Other</label>
                    <div class="col-md-1">
                        [% errs.other %]
                        <input type="text" class="form-control" id="other"
                            name="other" value="[% params.other %]" />
                    </div>
                </div>

                <hr />

                <!-- Text input-->
                <div class="form-group">
                  <label class="col-md-2 control-label text-danger" for="requested_by">
                    Requested by
                  </label>
                  <div class="col-md-4">
                    [% errs.requested_by %]
                  <input id="requested_by" name="requested_by" required="" type="text"
                        placeholder="full name required" class="form-control input-md"
                        value="[% params.requested_by || session.user.first_name.ucfirst
                          _ ' ' _ session.user.last_name.ucfirst %]" />
                  </div>
                </div>

                <!-- Text input-->
                <div class="form-group">
                  <label class="col-md-2 control-label text-danger" for="contact">
                    Contact details
                  </label>
                  <div class="col-md-4">
                    [% errs.contact %]
                  <input id="contact" name="contact" placeholder="required field"
                        class="form-control input-md" required="" type="text"
                        value="[% params.contact %]" />
                  </div>
                </div>
<!-- // moved to pdf form for manual completion
                <h4 class="text-info">To be completed on date of specimen:</h4>
               <div class="form-group">
                  <label class="col-md-2 control-label" for="taken_by">
                    Specimen taken by
                  </label>
                  <div class="col-md-4">
                    [% errs.taken_by %]
                  <input id="taken_by" name="taken_by" placeholder="full name required"
                        class="form-control input-md" type="text"
                        value="[% params.taken_by %]" />
                  </div>
                </div>

                <div class="form-group">
                  <label class="col-md-2 control-label" for="datetime">
                    Date &amp; time of sample
                  </label>
                  <div class="col-md-4">
                    [% errs.datetime %]
                  <input id="datetime" name="datetime" placeholder="dd/mm/yyyy hh:mm"
                        class="form-control input-md" type="text"
                        value="[% params.datetime %]" />
                  </div>
                </div>
-->

                <!-- Button -->
                <div class="col-sm-offset-5 control-group">
                  <label class="control-label" for="submit"></label>
                  <div class="controls">
                    [% IF generate_pdf; btn_type = 'success'; btn_label = 'Submit';
                        ELSE; btn_type = 'primary'; btn_label = 'Validate'; END %]
                    <input id="submit" name="submit" type="submit"
                      value="[% btn_label %]" class="btn btn-[% btn_type %]" />
                  </div>
                </div>
              </div>
            </fieldset>
        </div>
    </div>
  </div>
  </form>

    <script type="text/javascript">
        // nhs number ajax validation:
        $('#nhs_number').blur(function() { // alert("Handler for .blur() called.");
            var formData = { 'nhs_number' : $('input[name=nhs_number]').val() };
            var appMethod = "[% uri_for_nhs_number_validation %]";
            $.ajax({
                url: appMethod,
                data: formData,
                type: 'post',
                dataType: 'json',
                // the response is passed to the function
                success: function( json ) { // alert(json.result);
                    $( "#nhsno_result" ).text(json.result);
                },
            });
            // this also works as a simple 'get' request:
            // $.get( appMethod, formData )
            // .done( function(data) { $( "#nhsno_result" ).text(data) } );
        });
    </script>
<!-- END [% template.name %] -->