{% for comp_label, comp_id, comp_dates, comp_antigens, comp_pra in [
('PRA Class I', 'chart1', comparison_class1.dates if comparison_class1 else [],
comparison_class1.antigens if comparison_class1 else [],
comparison_class1.pra_by_date if comparison_class1 else {}),
('PRA Class II', 'chart2', comparison_class2.dates if comparison_class2 else [],
comparison_class2.antigens if comparison_class2 else [],
comparison_class2.pra_by_date if comparison_class2 else {})
] %}
{% if comp_dates and comp_dates | length >= 1 %}
{{ comp_label }} — MFI 趨勢圖
點圖例可顯示/隱藏抗體
{% if comp_dates | length >= 2 %}
MFI 比較表
▲ 上升▼ 下降新增✖ 消失
Antigen
Allele
{% for d in comp_dates %}
{{ d }} PRA {{ comp_pra.get(d,'?') }}%
{% endfor %}
趨勢
{% for d in comp_dates %}
Max
Mean
{% endfor %}
{% for ag in comp_antigens %}
{{ ag.antigen }}
{{ ag.allele }}
{% for d in comp_dates %}
{% set val = ag.mfi_by_date.get(d) %}
{% if val %}
{{ val.max_mfi|int }}
{{ val.mean_mfi|int }}
{% else %}
-
-
{% endif %}
{% endfor %}
{% set first_val = ag.mfi_by_date.get(comp_dates[0]) %}
{% set last_val = ag.mfi_by_date.get(comp_dates[-1]) %}
{% if first_val and last_val %}
{% set diff = last_val.max_mfi - first_val.max_mfi %}
{% if diff > 500 %}▲ +{{ diff|int }}
{% elif diff < -500 %}▼ {{ diff|int }}
{% else %}–{% endif %}
{% elif last_val and not first_val %}新增
{% elif first_val and not last_val %}✖ 消失
{% endif %}