<commit_before>{% extends "base.html" %}z

{% block extraScripts %}
  <script type="text/javascript" 
	src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js">
  </script>
  <script type="text/javascript" 
	src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js">
  </script>
  <script type="text/javascript" src="{{ STATIC_URL }}js/study_editing.js"></script>
  <script type="text/javascript">
	// This enables cancelling obsolete get_snp_url-requests.
    var get_snp_url_request;
    var get_snp_url_request_last_ref = '';
        
    // A check to make sure that javascripts that use autofill lists, 
    // don't crash and burn when the lists are missing
    var autofill_lists_available = false;
    {% if autofill_lists %}
        autofill_lists_available = true;);
    {% endif %}
    
	$(function() {
        {# Initialize interaction table relations management #}
		var interactionIndex = 0;
		{% for form in formsetInteraction %}
			interactCache[ interactionIndex ] = [];

			{% if form.genotypes.value.0 %}
				// Zoek de index op van de genotype rij
				interactCache[ interactionIndex ][ "genotypeNrs" ] = $( "tr#genotype_{{form.genotypes.value.0}}" ).index();
			{% endif %}
			
			{% if form.phenotypes.value.0 %}
				// Zoek de index op van de phenotype rij
				interactCache[ interactionIndex ][ "phenotypeNrs" ] = $( "tr#phenotype_{{form.phenotypes.value.0}}" ).index();
			{% endif %}

			{% if form.panels.value.0 %}
				// Zoek de index op van de panel rij
				interactCache[ interactionIndex ][ "panelNrs" ] = $( "tr#panel_{{form.panels.value.0}}" ).index();
			{% endif %}
			
			interactionIndex++;
		{% endfor %}
		
		{# Add autocompletion to the field with id 'id_study-0-year_of_publication' #}
		{# That is, the study's 'Year of publication' field #}
		var availableFields = [];
		{% for year in year_list %}
			availableFields.push("{{year}}");
		{% endfor %}
		$( "#id_study-0-year_of_publication" ).autocomplete({
			source: availableFields
		});
	});
  </script>

{% endblock %}

{% block body %}
	<div id="fade_background"></div>
	<div id="studylist">
		{% for form in formset %}
			{% if form.id.value == null or form.id.value == '' or form.id.value == None %}
				<form name="study_editing" method="post" action="/studies/create/">
			{% else %}
				<form name="study_editing" method="post" action="/studies/update/{{ form.id.value }}">
			{% endif %}
		  
		   
			{% csrf_token %}
			{{ formset.management_form }}
			{{ formsetGenotype.management_form }}
			{% for hid in form.hidden_fields %} {{hid}} {% endfor %}
			
			<div id="pagetabs">
				<ul>
					<li><a href="#studyInformation">Study information</a></li>
					<li><a href="#interactions">Interactions</a></li>
					<li><a href="#genotypes">Genotypes</a></li>
					<li><a href="#phenotypes">Phenotypes</a></li>
					<li><a href="#panels">Panels</a></li>
				</ul>
				<div id="studyInformation">
					<table>
						{% for field in form %}
							{% if not field.name == 'id' %}
								{% if field.errors %}
									<tr class = "error {{ field.name }}">
									<td class= "error"></td>
								{% else %}
									<tr class = "formfield {{ field.name }}">
									<td class= "formspacer"></td>
								{% endif %}
									{% if field.field.required %}
										<td><span class="required">
									{% else %}
										<td>
									{% endif %}
										{{ field.label_tag }}</td> 
									<td>
										{% if field.name == 'year_of_publication' %}
											<div class="ui-widget">
												{{ field }}
											</div>
										{% else %}
											{{ field }}
										{% endif %}
									{% if field.field.required %}
										</span></td>
									{% else %}
										</td>
									{% endif %}
									<td>
										{% if field.errors %}
											{% for error in field.errors %}
												{{ error|escape }} 
											{% endfor %}
										{% endif %}
									</td>
								</tr>
							{% endif %}		
						{% endfor %}
					</table>
				</div>
				<div id="interactions">
					<table id="interactionTable" class="interactions">
						<thead>
							<tr class="header" id="interaction_row">
								<th>Genotype</th>
								<th>Phenotype</th>
								<th>Panel</th>
								<th>Endpoint</th>
								<th>Ratios</th>
								<th></th>
							</tr>

						</thead>
						<tbody id="interaction">
							{% for form in formsetInteraction %}
								<tr id="interaction={{form.id.value}}">
									<td class="editable editable_genotype">
										{% if not form.genotypes.value.0 == None %}
											{% for gf in formsetGenotype %}
												{% if gf.id.value == form.genotypes.value.0 %}
													{% include 'study_editing/genotype_form.html' with gene=gf.gene.value snp_ref=gf.snp_ref.value snp_variant=gf.snp_variant.value %}
												{% endif %} 
											{% endfor %}
										{% else %}
											{% if interactionValues %}
												{% for item, value in interactionValues.items %}
													{% ifequal forloop.parentloop.counter forloop.counter %}
														{% include 'study_editing/genotype_form.html' with gene=value.gene snp_ref=value.snp_ref snp_variant=value.snp_variant %}
													{% endifequal %}
												{% endfor %}
											{% else %}
												{% include 'study_editing/genotype_form.html' with gene='' snp_ref='' snp_variant='' %}
											{% endif %}
										{% endif %}
									</td>								
									<td class="editable editable_phenotype">
										{% if not form.phenotypes.value.0 == None %}
											{% for pf in formsetPhenotype %}
												{% if pf.id.value == form.phenotypes.value.0 %}
													<a class="all" href="#" onClick="showFormByElement( this ); return false;">
														{{pf.phenotype_name.value}}
													</a>
													<div class="more_inputs">
														<label>Phenotype name</label><input class="label focus" type="text" name="phenotype-phenotype_name" value="{{pf.phenotype_name.value}}"><br />
														<label>Intake data</label><input class="" type="text" name="phenotype-intake_data" value="{{pf.intake_data.value}}"><br />
														<input type="button" onClick="saveFormByElement( this );" value="OK">
													</div>
												{% endif %} 
											{% endfor %}   
										{% else %}
											{% if interactionValues %}
												{% for item, value in interactionValues.items %}
													{% ifequal forloop.parentloop.counter forloop.counter %}
														<a class="all" href="#" onClick="showFormByElement( this ); return false;">
															{{value.phenotype_name}}
														</a>
														<div class="more_inputs">
															<label>Phenotype name</label><input class="label focus" type="text" name="phenotype-phenotype_name" value="{{value.phenotype_name}}"><br />
															<label>Intake data</label><input class="" type="text" name="phenotype-intake_data" value="{{value.intake_data}}"><br />
															<input type="button" onClick="saveFormByElement( this );" value="OK">
														</div>
													{% endifequal %}
												{% endfor %}
											{% else %}
												<a class="all" href="#" onClick="showFormByElement( this ); return false;">
													
												</a>
												<div class="more_inputs">
													<label>Phenotype name</label><input class="label focus" type="text" name="phenotype-phenotype_name" value=""><br />
													<label>Intake data</label><input class="" type="text" name="phenotype-intake_data" value=""><br />
													<input type="button" onClick="saveFormByElement( this );" value="OK">
												</div>
											{% endif %}
										{% endif %}
									</td>
									<td class="editable editable_panel">
										{% if not form.panels.value.0 == None %}						
											{% for p in formsetPanel %}
												{% if p.id.value == form.panels.value.0 %}
														<a class="all" href="#" onClick="showFormByElement( this ); return false;">
														{{p.panel_description.value}}
													</a>
													<div class="more_inputs">
														<label>Panel description</label><input class="label focus" type="text" name="panel-panel_description" value="{{p.panel_description.value}}"><br />
														<input type="button" onClick="saveFormByElement( this );" value="OK">
													</div>											
												{% endif %} 
											{% endfor %}
										{% else %}
											{% if interactionValues %}
												{% for item, value in interactionValues.items %}
													{% ifequal forloop.parentloop.counter forloop.counter %}
														<a class="all" href="#" onClick="showFormByElement( this ); return false;">
															{{value.panel_description}}
														</a>
														<div class="more_inputs">
															<label>Panel description</label><input class="label focus" type="text" name="panel-panel_description" value="{{value.panel_description}}"><br />
															<input type="button" onClick="saveFormByElement( this );" value="OK">
														</div>											
													{% endifequal %}
												{% endfor %}
											{% else %}
												<a class="all" href="#" onClick="showFormByElement( this ); return false;">
													
												</a>
												<div class="more_inputs">
													<label>Panel description</label><input class="label focus" type="text" name="panel-panel_description" value=""><br />
													<input type="button" onClick="saveFormByElement( this );" value="OK">
												</div>											
											{% endif %}
										{% endif %}
									</td>
									<td class="editable editable_endpoint">
										<a class="all" href="#" onClick="showFormByElement( this ); return false;">
											
										</a>
										<div class="more_inputs">
											<label>Endpoint (not saved yet)</label><input type="text" class="label focus" name="endpoint-endpoint" value=""><br />
											<input type="button" onClick="saveFormByElement( this );" value="OK">
										</div>
									</td>
									<td class="editable editable_ratios">
										<a class="all" href="#" onClick="showFormByElement( this ); return false;">
											{% if form.ratio_type.value %}{{ form.ratio_type.value }}{% endif %} {% if form.ratio.value %}{{ form.ratio.value }}{% endif %}
										</a>
										<div class="more_inputs">
											<label>Statistical model</label><input type="text" class=" focus" name="statistical_model" value="{% if form.statistical_model.value %}{{ form.statistical_model.value }}{% endif %}"><br />
											<label>P value</label><input type="text" class="" name="p_value" value="{% if form.p_value.value %}{{ form.p_value.value }}{% endif %}"><br />
											<label>Ratio type</label><input type="text" class="label" name="ratio_type" value="{% if form.ratio_type.value %}{{ form.ratio_type.value }}{% endif %}"><br />
											<label>Ratio value</label><input  type="text" class="label" name="ratio" value="{% if form.ratio.value %}{{ form.ratio.value }}{% endif %}"><br />
											<label>CI lower</label><input type="text"  class="" name="ci_lower" value="{% if form.ci_lower.value %}{{ form.ci_lower.value }}{% endif %}"><br />
											<label>CI upper</label><input type="text" class="" name="ci_upper" value="{% if form.ci_upper.value %}{{ form.ci_upper.value }}{% endif %}"><br />
											<label>Significant associations</label><input type="text" class="" name="significant_associations" value="{% if form.significant_associations.value %}{{ form.significant_associations.value }}{% endif %}"><br />
											<input type="button" onClick="saveFormByElement( this );" value="OK">
										</div>
									</td>
									<td class="buttons">
										<!-- <a onclick="editRow('interaction',this); return false;" href="#">edit</a> -->
										<a href="#" onClick="removeRow('interaction',this); return false;">remove</a>
										<input type="hidden" name="interaction_id" value="{{form.id.value}}">
									</td>
								</tr>
							{% endfor %}

								<tr class="addNew">
									<td class="editable  editable_genotype">
										{% include 'study_editing/genotype_form.html' with editable=1 gene='' snp_ref='' snp_variant='' %}
									</td>								
									<td class="editable editable_phenotype">
										{% include 'study_editing/phenotype_form.html' with editable=1 phenotype_name='' intake_data='' %}
									</td>	
									<td class="editable editable_panel"> 
										{% include 'study_editing/panel_form.html' with editable=1 panel_description='' %}
									</td>
									<td class="editable editable_endpoint">
										{% include 'study_editing/endpoint_form.html' with editable=1 endpoint='' %}
									</td>
									<td class="editable editable_ratios">
										{% include 'study_editing/ratios_form.html' with editable=1 statistical_model='' p_value='' ratio_type='' ratio='' ci_lower='' ci_upper='' significant_associations='' %}
									</td>
									<td class="buttons">
										<a href="#" onClick="saveRow('interaction',this); return false;">save</a>
										<!-- <a onclick="editRow('interaction',this); return false;" href="#">edit</a>
										<a href="#" onClick="removeRow('interaction',this); return false;">remove</a> --> 
									</td>
								</tr>

						</tbody>
					</table>
					<!-- <a href="#" onClick="addRow('interaction'); return false;">+</a>  -->
				</div>
				<div id="genotypes">
					<table id="genotypeTable" class="interactions">
						<thead>
							<tr class="header" id="genotype_row">
								<th id="gene">Gene name*</th>
								<th id="snp_ref">SNP ref</th>
								<th id="snp_variant">SNP variant</th>
								<th id="snp_name">SNP name</th>
								<th id="allele">Allele</th>
								<th id="mutation">Mutation</th>
								<th id="zygosity">Zygosity</th>
                                <th id="number_of_people_with_genotype">
                                    Number of people with genotype</th>
                                <th id="genotype_frequency">Frequency</th>
                                <th id="estimated_overal_frequency">
                                    Estimated overall frequency</th>
                                <th id="genotype_details">Genotype details</th>
							</tr>
						</thead>
						<tbody id="genotype">
							{% for form in formsetGenotype %}
								<tr id="genotype_{{form.id.value}}">
									<td class="editable">{% if form.gene.value %}{{ form.gene.value }}{% endif %}</td>
									<td class="editable">{% if form.snp_ref.value %}{{ form.snp_ref.value }}{% endif %}</td>
									<td class="editable">{% if form.snp_variant.value %}{{ form.snp_variant.value }}{% endif %}</td>
									<td class="editable">{% if form.snp_name.value %}{{ form.snp_name.value }}{% endif %}</td>
									<td class="editable">{% if form.allele.value %}{{ form.allele.value }}{% endif %}</td>
									<td class="editable">{% if form.mutation.value %}{{ form.mutation.value }}{% endif %}</td>
									<td class="editable">{% if form.zygosity.value %}{{ form.zygosity.value }}{% endif %}</td>
                                    
									<td class="editable">{% if form.number_of_people_with_genotype.value %}{{ form.number_of_people_with_genotype.value }}{% endif %}</td>
									<td class="editable">{% if form.genotype_frequency.value %}{{ form.genotype_frequency.value }}{% endif %}</td>
									<td class="editable">{% if form.estimated_overal_frequency.value %}{{ form.estimated_overal_frequency.value }}{% endif %}</td>
									<td class="editable">{% if form.genotype_details.value %}{{ form.genotype_details.value }}{% endif %}</td>
                                    
									<td class="buttons">
										<a onclick="editRow('genotype',this); return false;" href="#">edit</a>&nbsp;<a href="#" onClick="removeRow('genotype',this); return false;">remove</a>
										<input type="hidden" name="genotype_id" value="{{form.id.value}}">
									</td>
								</tr>
							{% endfor %}
						</tbody>
					</table>
					<a href="#" onClick="addRow('genotype'); return false;">+</a>				
				</div>
				<div id="phenotypes">

					<table id="phenotypeTable" class="interactions">
						<thead>
							<tr class="header" id="phenotype_row">
								<th id="phenotype_name">Name*</th>
								<th id="intake_data">Intake data*</th>
							</tr>
						</thead>
						<tbody id="phenotype">
							{% for form in formsetPhenotype %}
								<tr id="phenotype_{{form.id.value}}">
									<td class="editable">{% if form.phenotype_name.value %}{{ form.phenotype_name.value }}{% endif %}</td>
									<td class="editable">{% if form.intake_data.value %}{{ form.intake_data.value }}{% endif %}</td>
									<td class="buttons">
										<a onclick="editRow('phenotype',this); return false;" href="#">edit</a>&nbsp;<a href="#" onClick="removeRow('phenotype',this); return false;">remove</a>
										<input type="hidden" name="phenotype_id" value="{{form.id.value}}">
									</td>
								</tr>
							{% endfor %}
						</tbody>
					</table>
					<a href="#" onClick="addRow('phenotype'); return false;">+</a>				
				</div>
				
				<div id="panels">

					<table id="panelTable" class="interactions">
						<thead>
							<tr class="header" id="panel_row">
								<th id="panel_description">Panel description*</th>
								<th id="number_of_participants"># of participants</th>
								<th id="gender">Gender</th>
								<th id="mean_age">Mean age</th>
								<th id="additional_age_description">Additional age description</th>
							</tr>
						</thead>
						<tbody id="panel">
							{% for form in formsetPanel %}
								<tr id="panel_{{form.id.value}}">
									<td class="editable">{% if form.panel_description.value %}{{ form.panel_description.value }}{% endif %}</td>
									<td class="editable">{% if form.number_of_participants.value %}{{ form.number_of_participants.value }}{% endif %}</td>
									<td class="editable">{% if form.gender.value %}{{ form.gender.value }}{% endif %}</td>
									<td class="editable">{% if form.mean_age.value %}{{ form.mean_age.value }}{% endif %}</td>
									<td class="editable">{% if form.additional_age_description.value %}{{ form.additional_age_description.value }}{% endif %}</td>
									<td class="buttons">
										<a onclick="editRow('panel',this); return false;" href="#">edit</a>&nbsp;<a href="#" onClick="removeRow('panel',this); return false;">remove</a>
										<input type="hidden" name="panel_id" value="{{form.id.value}}">
									</td>
								</tr>
							{% endfor %}
						</tbody>
					</table>
					<a href="#" onClick="addRow('panel'); return false;">+</a>				
				</div>
				
			</div>
		</form>
	  {% endfor %}
	</div>
	<div id="contextmenu">
		<ul>
			<li><a href="#" onClick="submitData(); return false;">Update</a></li>
			<li>{% if not formset.0.id.value == null and not formset.0.id.value == '' and not formset.0.id.value == None %}
					<a href="/studies/view/{{ formset.0.id.value }}">
						Cancel
					</a>
				{% else %}
					<a href="/studies/">
						Cancel
					</a>
				{% endif %}
			</li>
		</ul>
	</div>

{% endblock body %}<commit_msg>Fixed JS syntax error in ´study_editing.html´.<commit_after>{% extends "base.html" %}z

{% block extraScripts %}
  <script type="text/javascript" 
	src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js">
  </script>
  <script type="text/javascript" 
	src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js">
  </script>
  <script type="text/javascript" src="{{ STATIC_URL }}js/study_editing.js"></script>
  <script type="text/javascript">
	// This enables cancelling obsolete get_snp_url-requests.
    var get_snp_url_request;
    var get_snp_url_request_last_ref = '';
        
    // A check to make sure that javascripts that use autofill lists, 
    // don't crash and burn when the lists are missing
    var autofill_lists_available = false;
    {% if autofill_lists %}
        autofill_lists_available = true);
    {% endif %}
    
	$(function() {
        {# Initialize interaction table relations management #}
		var interactionIndex = 0;
		{% for form in formsetInteraction %}
			interactCache[ interactionIndex ] = [];

			{% if form.genotypes.value.0 %}
				// Zoek de index op van de genotype rij
				interactCache[ interactionIndex ][ "genotypeNrs" ] = $( "tr#genotype_{{form.genotypes.value.0}}" ).index();
			{% endif %}
			
			{% if form.phenotypes.value.0 %}
				// Zoek de index op van de phenotype rij
				interactCache[ interactionIndex ][ "phenotypeNrs" ] = $( "tr#phenotype_{{form.phenotypes.value.0}}" ).index();
			{% endif %}

			{% if form.panels.value.0 %}
				// Zoek de index op van de panel rij
				interactCache[ interactionIndex ][ "panelNrs" ] = $( "tr#panel_{{form.panels.value.0}}" ).index();
			{% endif %}
			
			interactionIndex++;
		{% endfor %}
		
		{# Add autocompletion to the field with id 'id_study-0-year_of_publication' #}
		{# That is, the study's 'Year of publication' field #}
		var availableFields = [];
		{% for year in year_list %}
			availableFields.push("{{year}}");
		{% endfor %}
		$( "#id_study-0-year_of_publication" ).autocomplete({
			source: availableFields
		});
	});
  </script>

{% endblock %}

{% block body %}
	<div id="fade_background"></div>
	<div id="studylist">
		{% for form in formset %}
			{% if form.id.value == null or form.id.value == '' or form.id.value == None %}
				<form name="study_editing" method="post" action="/studies/create/">
			{% else %}
				<form name="study_editing" method="post" action="/studies/update/{{ form.id.value }}">
			{% endif %}
		  
		   
			{% csrf_token %}
			{{ formset.management_form }}
			{{ formsetGenotype.management_form }}
			{% for hid in form.hidden_fields %} {{hid}} {% endfor %}
			
			<div id="pagetabs">
				<ul>
					<li><a href="#studyInformation">Study information</a></li>
					<li><a href="#interactions">Interactions</a></li>
					<li><a href="#genotypes">Genotypes</a></li>
					<li><a href="#phenotypes">Phenotypes</a></li>
					<li><a href="#panels">Panels</a></li>
				</ul>
				<div id="studyInformation">
					<table>
						{% for field in form %}
							{% if not field.name == 'id' %}
								{% if field.errors %}
									<tr class = "error {{ field.name }}">
									<td class= "error"></td>
								{% else %}
									<tr class = "formfield {{ field.name }}">
									<td class= "formspacer"></td>
								{% endif %}
									{% if field.field.required %}
										<td><span class="required">
									{% else %}
										<td>
									{% endif %}
										{{ field.label_tag }}</td> 
									<td>
										{% if field.name == 'year_of_publication' %}
											<div class="ui-widget">
												{{ field }}
											</div>
										{% else %}
											{{ field }}
										{% endif %}
									{% if field.field.required %}
										</span></td>
									{% else %}
										</td>
									{% endif %}
									<td>
										{% if field.errors %}
											{% for error in field.errors %}
												{{ error|escape }} 
											{% endfor %}
										{% endif %}
									</td>
								</tr>
							{% endif %}		
						{% endfor %}
					</table>
				</div>
				<div id="interactions">
					<table id="interactionTable" class="interactions">
						<thead>
							<tr class="header" id="interaction_row">
								<th>Genotype</th>
								<th>Phenotype</th>
								<th>Panel</th>
								<th>Endpoint</th>
								<th>Ratios</th>
								<th></th>
							</tr>

						</thead>
						<tbody id="interaction">
							{% for form in formsetInteraction %}
								<tr id="interaction={{form.id.value}}">
									<td class="editable editable_genotype">
										{% if not form.genotypes.value.0 == None %}
											{% for gf in formsetGenotype %}
												{% if gf.id.value == form.genotypes.value.0 %}
													{% include 'study_editing/genotype_form.html' with gene=gf.gene.value snp_ref=gf.snp_ref.value snp_variant=gf.snp_variant.value %}
												{% endif %} 
											{% endfor %}
										{% else %}
											{% if interactionValues %}
												{% for item, value in interactionValues.items %}
													{% ifequal forloop.parentloop.counter forloop.counter %}
														{% include 'study_editing/genotype_form.html' with gene=value.gene snp_ref=value.snp_ref snp_variant=value.snp_variant %}
													{% endifequal %}
												{% endfor %}
											{% else %}
												{% include 'study_editing/genotype_form.html' with gene='' snp_ref='' snp_variant='' %}
											{% endif %}
										{% endif %}
									</td>								
									<td class="editable editable_phenotype">
										{% if not form.phenotypes.value.0 == None %}
											{% for pf in formsetPhenotype %}
												{% if pf.id.value == form.phenotypes.value.0 %}
													<a class="all" href="#" onClick="showFormByElement( this ); return false;">
														{{pf.phenotype_name.value}}
													</a>
													<div class="more_inputs">
														<label>Phenotype name</label><input class="label focus" type="text" name="phenotype-phenotype_name" value="{{pf.phenotype_name.value}}"><br />
														<label>Intake data</label><input class="" type="text" name="phenotype-intake_data" value="{{pf.intake_data.value}}"><br />
														<input type="button" onClick="saveFormByElement( this );" value="OK">
													</div>
												{% endif %} 
											{% endfor %}   
										{% else %}
											{% if interactionValues %}
												{% for item, value in interactionValues.items %}
													{% ifequal forloop.parentloop.counter forloop.counter %}
														<a class="all" href="#" onClick="showFormByElement( this ); return false;">
															{{value.phenotype_name}}
														</a>
														<div class="more_inputs">
															<label>Phenotype name</label><input class="label focus" type="text" name="phenotype-phenotype_name" value="{{value.phenotype_name}}"><br />
															<label>Intake data</label><input class="" type="text" name="phenotype-intake_data" value="{{value.intake_data}}"><br />
															<input type="button" onClick="saveFormByElement( this );" value="OK">
														</div>
													{% endifequal %}
												{% endfor %}
											{% else %}
												<a class="all" href="#" onClick="showFormByElement( this ); return false;">
													
												</a>
												<div class="more_inputs">
													<label>Phenotype name</label><input class="label focus" type="text" name="phenotype-phenotype_name" value=""><br />
													<label>Intake data</label><input class="" type="text" name="phenotype-intake_data" value=""><br />
													<input type="button" onClick="saveFormByElement( this );" value="OK">
												</div>
											{% endif %}
										{% endif %}
									</td>
									<td class="editable editable_panel">
										{% if not form.panels.value.0 == None %}						
											{% for p in formsetPanel %}
												{% if p.id.value == form.panels.value.0 %}
														<a class="all" href="#" onClick="showFormByElement( this ); return false;">
														{{p.panel_description.value}}
													</a>
													<div class="more_inputs">
														<label>Panel description</label><input class="label focus" type="text" name="panel-panel_description" value="{{p.panel_description.value}}"><br />
														<input type="button" onClick="saveFormByElement( this );" value="OK">
													</div>											
												{% endif %} 
											{% endfor %}
										{% else %}
											{% if interactionValues %}
												{% for item, value in interactionValues.items %}
													{% ifequal forloop.parentloop.counter forloop.counter %}
														<a class="all" href="#" onClick="showFormByElement( this ); return false;">
															{{value.panel_description}}
														</a>
														<div class="more_inputs">
															<label>Panel description</label><input class="label focus" type="text" name="panel-panel_description" value="{{value.panel_description}}"><br />
															<input type="button" onClick="saveFormByElement( this );" value="OK">
														</div>											
													{% endifequal %}
												{% endfor %}
											{% else %}
												<a class="all" href="#" onClick="showFormByElement( this ); return false;">
													
												</a>
												<div class="more_inputs">
													<label>Panel description</label><input class="label focus" type="text" name="panel-panel_description" value=""><br />
													<input type="button" onClick="saveFormByElement( this );" value="OK">
												</div>											
											{% endif %}
										{% endif %}
									</td>
									<td class="editable editable_endpoint">
										<a class="all" href="#" onClick="showFormByElement( this ); return false;">
											
										</a>
										<div class="more_inputs">
											<label>Endpoint (not saved yet)</label><input type="text" class="label focus" name="endpoint-endpoint" value=""><br />
											<input type="button" onClick="saveFormByElement( this );" value="OK">
										</div>
									</td>
									<td class="editable editable_ratios">
										<a class="all" href="#" onClick="showFormByElement( this ); return false;">
											{% if form.ratio_type.value %}{{ form.ratio_type.value }}{% endif %} {% if form.ratio.value %}{{ form.ratio.value }}{% endif %}
										</a>
										<div class="more_inputs">
											<label>Statistical model</label><input type="text" class=" focus" name="statistical_model" value="{% if form.statistical_model.value %}{{ form.statistical_model.value }}{% endif %}"><br />
											<label>P value</label><input type="text" class="" name="p_value" value="{% if form.p_value.value %}{{ form.p_value.value }}{% endif %}"><br />
											<label>Ratio type</label><input type="text" class="label" name="ratio_type" value="{% if form.ratio_type.value %}{{ form.ratio_type.value }}{% endif %}"><br />
											<label>Ratio value</label><input  type="text" class="label" name="ratio" value="{% if form.ratio.value %}{{ form.ratio.value }}{% endif %}"><br />
											<label>CI lower</label><input type="text"  class="" name="ci_lower" value="{% if form.ci_lower.value %}{{ form.ci_lower.value }}{% endif %}"><br />
											<label>CI upper</label><input type="text" class="" name="ci_upper" value="{% if form.ci_upper.value %}{{ form.ci_upper.value }}{% endif %}"><br />
											<label>Significant associations</label><input type="text" class="" name="significant_associations" value="{% if form.significant_associations.value %}{{ form.significant_associations.value }}{% endif %}"><br />
											<input type="button" onClick="saveFormByElement( this );" value="OK">
										</div>
									</td>
									<td class="buttons">
										<!-- <a onclick="editRow('interaction',this); return false;" href="#">edit</a> -->
										<a href="#" onClick="removeRow('interaction',this); return false;">remove</a>
										<input type="hidden" name="interaction_id" value="{{form.id.value}}">
									</td>
								</tr>
							{% endfor %}

								<tr class="addNew">
									<td class="editable  editable_genotype">
										{% include 'study_editing/genotype_form.html' with editable=1 gene='' snp_ref='' snp_variant='' %}
									</td>								
									<td class="editable editable_phenotype">
										{% include 'study_editing/phenotype_form.html' with editable=1 phenotype_name='' intake_data='' %}
									</td>	
									<td class="editable editable_panel"> 
										{% include 'study_editing/panel_form.html' with editable=1 panel_description='' %}
									</td>
									<td class="editable editable_endpoint">
										{% include 'study_editing/endpoint_form.html' with editable=1 endpoint='' %}
									</td>
									<td class="editable editable_ratios">
										{% include 'study_editing/ratios_form.html' with editable=1 statistical_model='' p_value='' ratio_type='' ratio='' ci_lower='' ci_upper='' significant_associations='' %}
									</td>
									<td class="buttons">
										<a href="#" onClick="saveRow('interaction',this); return false;">save</a>
										<!-- <a onclick="editRow('interaction',this); return false;" href="#">edit</a>
										<a href="#" onClick="removeRow('interaction',this); return false;">remove</a> --> 
									</td>
								</tr>

						</tbody>
					</table>
					<!-- <a href="#" onClick="addRow('interaction'); return false;">+</a>  -->
				</div>
				<div id="genotypes">
					<table id="genotypeTable" class="interactions">
						<thead>
							<tr class="header" id="genotype_row">
								<th id="gene">Gene name*</th>
								<th id="snp_ref">SNP ref</th>
								<th id="snp_variant">SNP variant</th>
								<th id="snp_name">SNP name</th>
								<th id="allele">Allele</th>
								<th id="mutation">Mutation</th>
								<th id="zygosity">Zygosity</th>
                                <th id="number_of_people_with_genotype">
                                    Number of people with genotype</th>
                                <th id="genotype_frequency">Frequency</th>
                                <th id="estimated_overal_frequency">
                                    Estimated overall frequency</th>
                                <th id="genotype_details">Genotype details</th>
							</tr>
						</thead>
						<tbody id="genotype">
							{% for form in formsetGenotype %}
								<tr id="genotype_{{form.id.value}}">
									<td class="editable">{% if form.gene.value %}{{ form.gene.value }}{% endif %}</td>
									<td class="editable">{% if form.snp_ref.value %}{{ form.snp_ref.value }}{% endif %}</td>
									<td class="editable">{% if form.snp_variant.value %}{{ form.snp_variant.value }}{% endif %}</td>
									<td class="editable">{% if form.snp_name.value %}{{ form.snp_name.value }}{% endif %}</td>
									<td class="editable">{% if form.allele.value %}{{ form.allele.value }}{% endif %}</td>
									<td class="editable">{% if form.mutation.value %}{{ form.mutation.value }}{% endif %}</td>
									<td class="editable">{% if form.zygosity.value %}{{ form.zygosity.value }}{% endif %}</td>
                                    
									<td class="editable">{% if form.number_of_people_with_genotype.value %}{{ form.number_of_people_with_genotype.value }}{% endif %}</td>
									<td class="editable">{% if form.genotype_frequency.value %}{{ form.genotype_frequency.value }}{% endif %}</td>
									<td class="editable">{% if form.estimated_overal_frequency.value %}{{ form.estimated_overal_frequency.value }}{% endif %}</td>
									<td class="editable">{% if form.genotype_details.value %}{{ form.genotype_details.value }}{% endif %}</td>
                                    
									<td class="buttons">
										<a onclick="editRow('genotype',this); return false;" href="#">edit</a>&nbsp;<a href="#" onClick="removeRow('genotype',this); return false;">remove</a>
										<input type="hidden" name="genotype_id" value="{{form.id.value}}">
									</td>
								</tr>
							{% endfor %}
						</tbody>
					</table>
					<a href="#" onClick="addRow('genotype'); return false;">+</a>				
				</div>
				<div id="phenotypes">

					<table id="phenotypeTable" class="interactions">
						<thead>
							<tr class="header" id="phenotype_row">
								<th id="phenotype_name">Name*</th>
								<th id="intake_data">Intake data*</th>
							</tr>
						</thead>
						<tbody id="phenotype">
							{% for form in formsetPhenotype %}
								<tr id="phenotype_{{form.id.value}}">
									<td class="editable">{% if form.phenotype_name.value %}{{ form.phenotype_name.value }}{% endif %}</td>
									<td class="editable">{% if form.intake_data.value %}{{ form.intake_data.value }}{% endif %}</td>
									<td class="buttons">
										<a onclick="editRow('phenotype',this); return false;" href="#">edit</a>&nbsp;<a href="#" onClick="removeRow('phenotype',this); return false;">remove</a>
										<input type="hidden" name="phenotype_id" value="{{form.id.value}}">
									</td>
								</tr>
							{% endfor %}
						</tbody>
					</table>
					<a href="#" onClick="addRow('phenotype'); return false;">+</a>				
				</div>
				
				<div id="panels">

					<table id="panelTable" class="interactions">
						<thead>
							<tr class="header" id="panel_row">
								<th id="panel_description">Panel description*</th>
								<th id="number_of_participants"># of participants</th>
								<th id="gender">Gender</th>
								<th id="mean_age">Mean age</th>
								<th id="additional_age_description">Additional age description</th>
							</tr>
						</thead>
						<tbody id="panel">
							{% for form in formsetPanel %}
								<tr id="panel_{{form.id.value}}">
									<td class="editable">{% if form.panel_description.value %}{{ form.panel_description.value }}{% endif %}</td>
									<td class="editable">{% if form.number_of_participants.value %}{{ form.number_of_participants.value }}{% endif %}</td>
									<td class="editable">{% if form.gender.value %}{{ form.gender.value }}{% endif %}</td>
									<td class="editable">{% if form.mean_age.value %}{{ form.mean_age.value }}{% endif %}</td>
									<td class="editable">{% if form.additional_age_description.value %}{{ form.additional_age_description.value }}{% endif %}</td>
									<td class="buttons">
										<a onclick="editRow('panel',this); return false;" href="#">edit</a>&nbsp;<a href="#" onClick="removeRow('panel',this); return false;">remove</a>
										<input type="hidden" name="panel_id" value="{{form.id.value}}">
									</td>
								</tr>
							{% endfor %}
						</tbody>
					</table>
					<a href="#" onClick="addRow('panel'); return false;">+</a>				
				</div>
				
			</div>
		</form>
	  {% endfor %}
	</div>
	<div id="contextmenu">
		<ul>
			<li><a href="#" onClick="submitData(); return false;">Update</a></li>
			<li>{% if not formset.0.id.value == null and not formset.0.id.value == '' and not formset.0.id.value == None %}
					<a href="/studies/view/{{ formset.0.id.value }}">
						Cancel
					</a>
				{% else %}
					<a href="/studies/">
						Cancel
					</a>
				{% endif %}
			</li>
		</ul>
	</div>

{% endblock body %}
{'fraction_non_alphanumeric': 0.17735762400489896, 'fraction_numerical': 0.0015819555011226782, 'mean_word_length': 2.2417700578990902, 'pattern_counts': {'":': 0, '<': 773, '<?xml version=': 0, '>': 773, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7582906', 'n_tokens_mistral': 18214, 'n_tokens_neox': 12282, 'n_words': 2351}