RSS Git Download  Clone
Raw Blame History
  [% META title = 'HMRN » Treatment & Trial Options' -%]

<!-- BEGIN [% template.name %] -->
	[% # PROCESS dumper.tt dump = opts %]

	[% # error_codes_dfv_js %]

	[% # PROCESS admin/misc_nav.tt page = 'error-codes' %]

  <h2 align="center">HMRN treatments &amp; clinical trial options</h2>

    [% IF dfv_errors %]
        <p class="error">[% c.config('msg').dfv_errors %]</p>
    [% END %]

	[% INCLUDE site/snippets/help.tt file = 'treatmentdetails' %]

	[% # PROCESS site/js/jquery.tt # already loaded in html_wrapper %]
	<script language="javascript" type="text/javascript">
	<!--
	
		function prepare_details_list() {		
			
			var type_val = $('#tx_type_id').val();      // type id
			var detail_val = $('#tx_detail').val();     // detail id		 
			
			// set url of rename details description link
			$('#rename_detail').attr("href", "treatment_rename/" + type_val + "/"  + detail_val );
			if ( detail_val ) {                         // show rename detail link if a detail selected  
				$('#span_rename_detail').show();
			} else {
				$('#span_rename_detail').hide();
				$('#rename_detail').attr("href", "" );
			}			
		}
		
		function prepare_type_list() {
						
			var tx_type_ids = [ [% opts.tx_type_ids.join(',') %] ]; // list of detail ids for type, if any
			
			var type_id_val = $('#tx_type_id').val(); 
			// does value of 'v' match any of tx_type_ids array:
			match = jQuery.grep(tx_type_ids, function (a) { return a == type_id_val; }); // alert(match);

			// if has a match (has detail values), show the details
			if ( match.length ) {
				$('#tx_detail').show();				
			} else {
				$('#tx_detail').hide();
			}
			// load details
			$('#tx_detail').load('[% app_url %]/hmrn_data/treatment_options', {
				tx_type_id: type_id_val	
			})			
			// show edit type name if a type has been selected
			if ( type_id_val ) {
				$('#span_rename_type').show();
				$('#rename_type').attr("href", "treatment_rename/" + type_id_val );				
			} else {
				$('#span_rename_type').hide();
				$('#rename_type').attr("href", "" );
			}
			// changed type, so hide detail rename too
			$('#span_rename_detail').hide();
			$('#rename_detail').attr("href", "" );

		}

		// tx_type_id onChange event for tx_detail_id select menu
		$(document).ready(function () {
			prepare_type_list();                              // Setting up for new page or back button
			prepare_details_list();
			$('#tx_type_id').change( prepare_type_list );     // drop down values changing
			$('#tx_detail').change( prepare_details_list );
		});		
	-->
	</script>

	<form method="post" action="[% app_url %]/hmrn/treatment_options"
      [% error_codes_onsubmit %] name="txDetails" id="txDetails">
			<p class="bold">
        1) Select treatment type:
        <select name="tx_type_id" id="tx_type_id" id="tx_type_id">
          <option value=""></option>
            [% FOREACH key IN opts.tx_types.keys.sort %]
            <option value="[% opts.tx_types.${key} %]">[% key %]</option>
            [% END %]
        </select>
		<span id="span_rename_type" style="display: none;" >
			[<a id="rename_type" href="">edit</a>]
		</span>
      </p>
      <div class="indent">
        <span class="bold">or add new:</span>
        <input type="text" size="25" name="new_tx_type" />
        [% error_tx_type_id %]
        [% site.html.submit %] [% site.html.reset %]
      </div>      
      
	  <p class="bold">
        2) Options for selected Tx type:
      </p>
        <!-- // replaced by ajax output after selection of tx_type_id: -->
      <div class="indent">
        <select name="tx_detail_id" id="tx_detail" [% site.html.readonly %]>			
          [% IF opts.tx_details.size %]
            <option value=""></option>
            [% FOREACH opt IN opts.tx_details %]
            <option value="[% opt.key %]">[% opt.value %]</option>
          [% END; END %]
        </select>
		
		<!--[<a href="http://localhost:8000/hilis4/hmrn_data/edit_mdt_date/192/7895">edit</a>]-->
		<span id="span_rename_detail" style="display: none;" >
			[<a id="rename_detail" href="">edit</a>]
		</span>
		
        <b>new</b>: <input type="text" size="35" name="new_tx_detail" />
        [% error_tx_detail_id %]
        [% site.html.submit %] [% site.html.reset %]
      </div>
	</form>
<!-- END [% template.name %] -->