{% if approval_no %}
Approval {{ ui_output_1[0] }}
Patient {{ ui_output_2[0] }}
{% set total_count = ui_output_8 | length %} {% set approved_count = namespace(value=0) %} {% for decision in ui_output_8 %} {% if 'Approved' in decision.get('Decision', '') and 'Disapproved' not in decision.get('Decision', '') %} {% set approved_count.value = approved_count.value + 1 %} {% endif %} {% endfor %} {% set rejected_count = total_count - approved_count.value %} {% set all_approved = approved_count.value == total_count and total_count > 0 %} {% set all_rejected = rejected_count == total_count and total_count > 0 %} {% if all_approved %}Approved{% elif all_rejected %}Rejected{% else %}Partial{% endif %} — {{ approved_count.value }}/{{ total_count }}
{% endif %}
{% if error is defined and error %} {% endif %} {% if errors and errors | length > 0 %} {% endif %} {% if approval_no %} {% set total_count = ui_output_8 | length %} {% set approved_count = namespace(value=0) %} {% for decision in ui_output_8 %} {% if 'Approved' in decision.get('Decision', '') and 'Disapproved' not in decision.get('Decision', '') %} {% set approved_count.value = approved_count.value + 1 %} {% endif %} {% endfor %} {% set rejected_count = total_count - approved_count.value %} {% set all_approved = approved_count.value == total_count and total_count > 0 %} {% set all_rejected = rejected_count == total_count and total_count > 0 %}

{% if all_approved %}All Services Approved{% elif all_rejected %}Services Rejected{% else %}Partial Approval{% endif %}

Decision based on CCHI policy guidelines and medical necessity analysis

{{ approved_count.value }} Approved {{ rejected_count }} Rejected {{ total_count }} Total
Request Info
Approval No {{ ui_output_1[0] }}
Request Date {{ ui_output_1[1] }}
Type {{ ui_output_1[2] }}
Processed
Patient Demographics
Full Name {{ ui_output_2[0] }}
DOB / Age {{ ui_output_2[1] }} ({{ ui_output_2[3] }}y)
Gender {{ ui_output_2[2] }}
ID/Iqama {{ ui_output_2[4] }}
Nationality {{ ui_output_2[5] }}
Insurance Info
Member ID {{ ui_output_3[0] }}
Plan Type {{ ui_output_3[1] }}
Health Dec. {{ ui_output_3[2] }}
Status {{ ui_output_3[3] | default('Active') }}
Provider Info
Facility {{ ui_output_4[0] }}
Physician {{ ui_output_4[1] }}
Specialty {{ ui_output_4[2] }}
License No. {{ ui_output_4[3] }}

Service Decisions

{% if ui_output_9 is string and ui_output_9 %} {{ ui_output_9 }} {% elif ui_output_9 and ui_output_9[0] is mapping and ui_output_9[0]['Category'] %} {{ ui_output_9[0]['Category'] }} {% endif %}
{% for decision in ui_output_8 %} {% set is_approved = 'Approved' in decision['Decision'] and 'Disapproved' not in decision['Decision'] %}

{{ decision['Service Name'] }}

#{{ loop.index }} Code: {{ decision['Internal Code'] }} {% if decision.get('Category Description') %} | {{ decision['Category Description'] }}{% endif %}

{% if decision.get('Category') %}
{{ decision['Category'] }}
{% endif %}
{{ decision['Requested Qty'] | default(1) }}
Requested
{% if is_approved %}{{ decision['Approved Qty'] | default(decision['Requested Qty'] | default(1)) }}{% else %}0{% endif %}
Approved
{% if is_approved %}A{% else %}D{% endif %}
Status
{% if not is_approved and decision.get('Rejection Code') %}
{{ decision['Rejection Code'] }}
Rej. Code
{% endif %}
{% if decision['Justification'] or decision.get('layer_trace') %}
{% if decision['Justification'] %}

Justification

{{ decision['Justification'] }}
{% endif %} {% if decision.get('layer_trace') %}

Decision Audit Trail

{% for trace in decision['layer_trace'] %} {% set trace_status = trace.get('result', 'skip') | lower %} {% if 'pass' in trace_status or 'approved' in trace_status %} {% set trace_class = 'pass' %} {% elif 'fail' in trace_status or 'reject' in trace_status or 'disapproved' in trace_status %} {% set trace_class = 'fail' %} {% else %} {% set trace_class = 'skip' %} {% endif %} {{ trace.get('layer', trace.get('name', 'Layer')) }} {% endfor %}
{% endif %}
{% endif %}
{% endfor %}

Clinical Assessment

Diagnosis Codes

{{ ui_output_5[0] | default('No diagnosis codes available') }}

Clinical Summary

{{ ui_output_5[2] | default('No clinical summary available') }}

Supporting Investigations

Radiology Findings

{{ ui_output_6[0] | default('No radiology findings available') }}

Laboratory Results

{{ ui_output_6[1] | default('No laboratory results available') }}

Past Medical History & Utilization Analysis

Historical Analysis

{{ ui_output_7 | default('No historical data available') }}

Communication Messages

{% if ui_output_0 %} {% if ui_output_0 is mapping %} {% if ui_output_0.english %}

English Message

{{ ui_output_0.english }}
{% endif %} {% if ui_output_0.arabic %}

الرسالة بالعربية

{{ ui_output_0.arabic }}
{% endif %} {% elif ui_output_0 is iterable and ui_output_0 is not string %} {% if ui_output_0[0] %}

English Message

{{ ui_output_0[0] }}
{% endif %} {% if ui_output_0[1] %}

الرسالة بالعربية

{{ ui_output_0[1] }}
{% endif %} {% else %}
{{ ui_output_0 }}
{% endif %} {% else %}

No messages available

{% endif %}

ملخص خدمة العملاء (Customer Service Agent Summary)

{% if ui_output_10 %}

ملخص شامل للحالة

{{ ui_output_10 }}
{% else %}

No customer service summary available

{% endif %}

Provider Response Messages

{% for decision in ui_output_8 %} {% set is_approved = 'Approved' in decision['Decision'] and 'Disapproved' not in decision['Decision'] %}
{{ decision['Service Name'] }} {% if is_approved %}Approved{% else %}Disapproved{% endif %}
{% if decision.get('Message Code') %} MSG: {{ decision['Message Code'] }} {% endif %} {% if not is_approved and decision.get('Rejection Code') %} {{ decision['Rejection Code'] }} {% elif is_approved %} Approved {% endif %}
{% if decision.get('Provider Message') or decision.get('Justification') %}
{{ decision.get('Provider Message', decision.get('Justification', 'No message available')) }}
{% endif %}
{% endfor %} {% if ui_output_8 | length == 0 %}

No provider response messages available

{% endif %}
{% endif %}