{% if section_only -%}
# {{ section_header }}
{% else -%}
# {{ name }}

ID: {{ id }}

{% if definition -%}
## Definition (MyDisease.info)

{{ definition }}
{% endif -%}
{% if top_gene_score_labels -%}
Genes (Open Targets): {{ top_gene_score_labels | join(", ") }}
{% elif top_genes -%}
Genes (Open Targets): {{ top_genes | join(", ") }}
{% endif -%}
{% if treatment_landscape -%}
Treatments (MyChem.info indication search): {{ treatment_landscape | join(", ") }}
{% endif -%}
{% if recruiting_trial_count is not none -%}
Recruiting Trials (ClinicalTrials.gov): {{ recruiting_trial_count }}
{% endif -%}
{% if synonyms -%}
## Synonyms (MONDO / Disease Ontology via MyDisease.info)

{{ synonyms | join(", ") }}
{% endif -%}
{% if parents -%}
## Parents (MONDO / Disease Ontology via MyDisease.info)

{{ parents | join(", ") }}
{% endif -%}
{% endif -%}
{% if show_genes_section -%}
## Associated Genes

{% if gene_association_rows -%}
| Gene | Relationship | Source | OpenTargets |
|---|---|---|---|
{% for row in gene_association_rows -%}
| {{ row.gene }} | {{ row.relationship or "-" }} | {% if row.source_url %}[{{ row.source }}]({{ row.source_url }}){% else %}{{ row.source or "-" }}{% endif %} | {{ row.opentargets or "-" }} |
{% endfor -%}
{% elif associated_genes -%}
{{ associated_genes | join(", ") }}
{% else -%}
No associated genes found from active sources.
{% endif -%}
{% endif -%}
{% if show_pathways_section -%}
## Pathways (Reactome)

{% if pathways -%}
{% for p in pathways -%}
- {{ p.id }} - {{ p.name }}
{% endfor -%}
{% else -%}
No pathways found from active sources.
{% endif -%}
{% endif -%}
{% if show_phenotypes_section -%}
## Phenotypes

{% if phenotypes -%}
{% if key_features -%}
### Key Features

{% for feature in key_features -%}
- {{ feature }}
{% endfor -%}

These summarize the classic presentation; the table below is the comprehensive HPO annotation list.

{% elif has_definition -%}
{% if section_only -%}
Classic features are best summarized in the disease definition. Run `biomcp get disease {{ id }}` to review the definition; the table below is the comprehensive HPO annotation list.
{% else -%}
Classic features are best summarized in the disease definition above; the table below is the comprehensive HPO annotation list.
{% endif -%}

{% endif -%}
This phenotype section is source-backed and may be incomplete for the full disease presentation. Supplement with `biomcp search article -d "{{ literature_query }}" --type review --limit 5` when you need broader review coverage.

| HPO ID | Name | Evidence | Frequency | Onset | Sex | Stage | Source |
|---|---|---|---|---|---|---|---|
{% for row in phenotypes -%}
| {{ row.hpo_id }} | {{ row.name or "-" }} | {{ row.evidence or "-" }}{% if row.qualifiers %} ({{ row.qualifiers | join(", ") }}){% endif %} | {% if row.frequency_qualifier %}{{ row.frequency_qualifier }}{% elif row.frequency %}{{ row.frequency }}{% else %}-{% endif %} | {{ row.onset_qualifier or "-" }} | {{ row.sex_qualifier or "-" }} | {{ row.stage_qualifier or "-" }} | {% if row.source_url %}[{{ row.source }}]({{ row.source_url }}){% else %}{{ row.source or "-" }}{% endif %} |
{% endfor -%}
{% else -%}
No phenotype annotations found for this disease.
{% endif -%}
{% endif -%}
{% if show_clinical_features_section -%}
## Clinical Features (MedlinePlus)

{% if clinical_features -%}
| Rank | Feature | HPO | Confidence | Evidence | Source |
|---|---|---|---|---|---|
{% for row in clinical_features -%}
| {{ row.rank }} | {{ row.label }} | {{ row.hpo }} | {{ row.confidence }} | {{ row.evidence }} | {% if row.source_url %}[{{ row.source }}]({{ row.source_url }}){% else %}{{ row.source }}{% endif %} |
{% endfor -%}
{% else -%}
No MedlinePlus clinical features found for this disease.
{% endif -%}
{% endif -%}
{% if show_diagnostics_section -%}
## Diagnostics

{% if diagnostic_rows -%}
| Accession | Name | Type | Manufacturer / Lab | Source | Genes | Conditions |
|---|---|---|---|---|---|---|
{% for row in diagnostic_rows -%}
| {{ row.accession }} | {{ row.name }} | {{ row.test_type or "-" }} | {{ row.manufacturer_or_lab or "-" }} | {{ row.source_label }} | {{ row.genes_cell }} | {{ row.conditions_cell }} |
{% endfor -%}
{% if diagnostics_note -%}

{{ diagnostics_note }}
{% endif -%}
{% if diagnostic_search_command -%}

See also: `{{ diagnostic_search_command }}`
{% endif -%}
{% elif diagnostics_note -%}
{{ diagnostics_note }}
{% else -%}
No diagnostic tests found for this disease.
{% endif -%}
{% endif -%}
{% if show_variants_section -%}
## Variants

{% if variants -%}
{% if top_variant -%}
Top Variant: {{ top_variant.variant }}{% if top_variant.relationship %} - {{ top_variant.relationship }}{% endif %}{% if top_variant.source or top_variant.evidence_count is not none %} ({% if top_variant.source %}{{ top_variant.source }}{% endif %}{% if top_variant.source and top_variant.evidence_count is not none %}, {% endif %}{% if top_variant.evidence_count is not none %}{{ top_variant.evidence_count }} evidence item{% if top_variant.evidence_count != 1 %}s{% endif %}{% endif %}){% endif %}
{% endif -%}
| Variant | Relationship | Source | Evidence |
|---|---|---|---|
{% for row in variants -%}
| {{ row.variant }} | {{ row.relationship or "-" }} | {{ row.source or "-" }} | {% if row.evidence_count is not none %}{{ row.evidence_count }}{% else %}-{% endif %} |
{% endfor -%}
{% else -%}
No variant associations found for this disease.
{% endif -%}
{% endif -%}
{% if show_models_section -%}
## Models

{% if models -%}
| Model | Organism | Relationship | Source | Evidence |
|---|---|---|---|---|
{% for row in models -%}
| {{ row.model }} | {{ row.organism or "-" }} | {{ row.relationship or "-" }} | {% if row.source_url %}[{{ row.source }}]({{ row.source_url }}){% else %}{{ row.source or "-" }}{% endif %} | {% if row.evidence_count is not none %}{{ row.evidence_count }}{% else %}-{% endif %} |
{% endfor -%}
{% else -%}
No model associations found for this disease.
{% endif -%}
{% endif -%}
{% if show_prevalence_section -%}
## Prevalence

{% if prevalence -%}
| Estimate | Context | Source |
|---|---|---|
{% for row in prevalence -%}
| {{ row.estimate }} | {{ row.context or "-" }} | {{ row.source or "-" }} |
{% endfor -%}
{% elif prevalence_note -%}
{{ prevalence_note }}
{% else -%}
No prevalence data available.
{% endif -%}
{% endif -%}
{% if show_survival_section -%}
## Survival (SEER Explorer)

{% if survival -%}
Source: {{ survival_source_line }}

| Sex | Latest observed year | 5-year relative survival | 95% CI | Cases | Latest modeled |
|---|---|---|---|---|---|
{% for row in survival_summary_rows -%}
| {{ row.sex }} | {% if row.latest_observed_year is not none %}{{ row.latest_observed_year }}{% else %}-{% endif %} | {{ row.relative_survival or "-" }} | {{ row.ci_95 or "-" }} | {% if row.cases is not none %}{{ row.cases }}{% else %}-{% endif %} | {{ row.latest_modeled or "-" }} |
{% endfor -%}

### Recent History

| Sex | Year | 5-year relative survival | 95% CI | Cases |
|---|---|---|---|---|
{% for row in survival_history_rows -%}
| {{ row.sex }} | {{ row.year }} | {{ row.relative_survival }} | {{ row.ci_95 or "-" }} | {% if row.cases is not none %}{{ row.cases }}{% else %}-{% endif %} |
{% endfor -%}
{% elif survival_note -%}
{{ survival_note }}
{% else -%}
No SEER survival data available.
{% endif -%}
{% endif -%}
{% if show_funding_section -%}
## Funding (NIH Reporter)

{% if funding_rows -%}
| Project | PI | Organization | FY | Amount |
|---|---|---|---|---|
{% for row in funding_rows -%}
| {{ row.project_title }} | {{ row.pi_name }} | {{ row.organization }} | {{ row.fiscal_year }} | {{ row.award_amount }} |
{% endfor -%}

{{ funding_summary }}
{% elif funding_note -%}
{{ funding_note }}
{% else -%}
No NIH funding data found for this query.
{% endif -%}
{% endif -%}
{% if show_civic_section -%}
## CIViC

{% if civic -%}
- Evidence Items: {{ civic.evidence_total_count }}
- Assertions: {{ civic.assertion_total_count }}
{% if civic.assertions -%}
| Assertion | AMP Level | Molecular Profile | Therapies |
|---|---|---|---|
{% for row in civic.assertions -%}
| {{ row.name }} | {{ row.amp_level or "-" }} | {{ row.molecular_profile }} | {% if row.therapies %}{{ row.therapies | join(", ") }}{% else %}-{% endif %} |
{% endfor -%}
{% elif civic.evidence_items -%}
| Evidence | Level | Molecular Profile | Therapies |
|---|---|---|---|
{% for row in civic.evidence_items -%}
| {{ row.name }} | {{ row.evidence_level }} | {{ row.molecular_profile }} | {% if row.therapies %}{{ row.therapies | join(", ") }}{% else %}-{% endif %} |
{% endfor -%}
{% else -%}
No CIViC records returned for this disease query.
{% endif -%}
{% else -%}
No CIViC records returned for this disease query.
{% endif -%}
{% endif -%}
{% if show_disgenet_section -%}
## DisGeNET

{% if disgenet and disgenet.associations -%}
| Gene | Entrez ID | Score | PMIDs | Trials | EL | EI |
|---|---|---|---|---|---|---|
{% for row in disgenet.associations -%}
| {{ row.symbol }} | {% if row.entrez_id is defined and row.entrez_id is not none %}{{ row.entrez_id }}{% else %}-{% endif %} | {{ row.score | score }} | {% if row.publication_count is defined and row.publication_count is not none %}{{ row.publication_count }}{% else %}-{% endif %} | {% if row.clinical_trial_count is defined and row.clinical_trial_count is not none %}{{ row.clinical_trial_count }}{% else %}-{% endif %} | {{ row.evidence_level or "-" }} | {% if row.evidence_index is defined and row.evidence_index is not none %}{{ row.evidence_index | score }}{% else %}-{% endif %} |
{% endfor -%}
{% else -%}
No DisGeNET associations returned for this disease query.
{% endif -%}
{% endif -%}
{% if sections_block %}{{ sections_block }}
{% endif -%}
{% if related_block %}{{ related_block }}
{% endif -%}
