hospital-management/templates/radiology/templates/report_template_detail.html
2025-08-12 13:33:25 +03:00

406 lines
18 KiB
HTML

{% extends "base.html" %}
{% load static %}
{% block title %}Report Template - {{ template.name }}{% endblock %}
{% block breadcrumb %}
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="{% url 'radiology:dashboard' %}">Radiology</a></li>
<li class="breadcrumb-item"><a href="{% url 'radiology:report_template_list' %}">Report Templates</a></li>
<li class="breadcrumb-item active">{{ template.name }}</li>
</ol>
{% endblock %}
{% block content %}
<div class="container-fluid">
<!-- Template Header -->
<div class="row mb-4">
<div class="col-12">
<div class="card">
<div class="card-header d-flex justify-content-between align-items-center">
<h3 class="card-title mb-0">
<i class="fas fa-file-alt me-2"></i>
Report Template: {{ template.name }}
</h3>
<div class="btn-group">
<button type="button" class="btn btn-outline-primary dropdown-toggle" data-bs-toggle="dropdown">
<i class="fas fa-cog"></i> Actions
</button>
<ul class="dropdown-menu">
{% if perms.radiology.change_reporttemplate %}
<li><a class="dropdown-item" href="{% url 'radiology:report_template_update' template.pk %}">
<i class="fas fa-edit"></i> Edit Template
</a></li>
{% endif %}
<li><a class="dropdown-item" href="#" onclick="duplicateTemplate()">
<i class="fas fa-copy"></i> Duplicate Template
</a></li>
<li><a class="dropdown-item" href="#" onclick="previewTemplate()">
<i class="fas fa-eye"></i> Preview Template
</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#" onclick="exportTemplate()">
<i class="fas fa-download"></i> Export Template
</a></li>
<li><a class="dropdown-item" href="#" onclick="shareTemplate()">
<i class="fas fa-share"></i> Share Template
</a></li>
{% if perms.radiology.delete_reporttemplate %}
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item text-danger" href="{% url 'radiology:report_template_delete' template.pk %}">
<i class="fas fa-trash"></i> Delete Template
</a></li>
{% endif %}
</ul>
</div>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-8">
<h4>{{ template.name }}</h4>
{% if template.description %}
<p class="text-muted mb-2">{{ template.description }}</p>
{% endif %}
<p class="text-muted">
<strong>Category:</strong> {{ template.get_category_display }} |
<strong>Modality:</strong> {{ template.get_modality_display }} |
<strong>Body Part:</strong> {{ template.get_body_part_display }}
</p>
</div>
<div class="col-md-4 text-end">
<span class="badge fs-6 {% if template.is_active %}bg-success{% else %}bg-secondary{% endif %}">
{% if template.is_active %}Active{% else %}Inactive{% endif %}
</span>
{% if template.is_default %}
<div class="mt-2">
<span class="badge bg-primary fs-6">
<i class="fas fa-star"></i> Default Template
</span>
</div>
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<!-- Template Content -->
<div class="col-lg-8 mb-4">
<!-- Clinical History Template -->
{% if template.clinical_history_template %}
<div class="card mb-4">
<div class="card-header">
<h5 class="card-title mb-0">
<i class="fas fa-history me-2"></i>Clinical History Template
</h5>
</div>
<div class="card-body">
<div class="template-content bg-light p-3 rounded">
{{ template.clinical_history_template|linebreaks }}
</div>
</div>
</div>
{% endif %}
<!-- Technique Template -->
{% if template.technique_template %}
<div class="card mb-4">
<div class="card-header">
<h5 class="card-title mb-0">
<i class="fas fa-cogs me-2"></i>Technique Template
</h5>
</div>
<div class="card-body">
<div class="template-content bg-light p-3 rounded">
{{ template.technique_template|linebreaks }}
</div>
</div>
</div>
{% endif %}
<!-- Findings Template -->
<div class="card mb-4">
<div class="card-header">
<h5 class="card-title mb-0">
<i class="fas fa-search me-2"></i>Findings Template
</h5>
</div>
<div class="card-body">
{% if template.findings_template %}
<div class="template-content bg-light p-3 rounded">
{{ template.findings_template|linebreaks }}
</div>
{% else %}
<p class="text-muted mb-0">No findings template defined.</p>
{% endif %}
</div>
</div>
<!-- Impression Template -->
<div class="card mb-4">
<div class="card-header">
<h5 class="card-title mb-0">
<i class="fas fa-lightbulb me-2"></i>Impression Template
</h5>
</div>
<div class="card-body">
{% if template.impression_template %}
<div class="template-content bg-light p-3 rounded">
{{ template.impression_template|linebreaks }}
</div>
{% else %}
<p class="text-muted mb-0">No impression template defined.</p>
{% endif %}
</div>
</div>
<!-- Recommendations Template -->
{% if template.recommendations_template %}
<div class="card mb-4">
<div class="card-header">
<h5 class="card-title mb-0">
<i class="fas fa-clipboard-list me-2"></i>Recommendations Template
</h5>
</div>
<div class="card-body">
<div class="template-content bg-light p-3 rounded">
{{ template.recommendations_template|linebreaks }}
</div>
</div>
</div>
{% endif %}
<!-- Template Variables -->
{% if template.template_variables %}
<div class="card mb-4">
<div class="card-header">
<h5 class="card-title mb-0">
<i class="fas fa-code me-2"></i>Template Variables
</h5>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-sm">
<thead>
<tr>
<th>Variable</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
<tbody>
{% for variable in template.parsed_variables %}
<tr>
<td><code>{{ variable.name }}</code></td>
<td>{{ variable.description }}</td>
<td><em>{{ variable.example }}</em></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endif %}
</div>
<!-- Template Metadata -->
<div class="col-lg-4">
<!-- Template Information -->
<div class="card mb-4">
<div class="card-header">
<h6 class="card-title mb-0">
<i class="fas fa-info-circle me-2"></i>Template Information
</h6>
</div>
<div class="card-body">
<div class="row g-2">
<div class="col-12">
<small class="text-muted d-block">Template ID</small>
<code class="small">{{ template.template_id }}</code>
</div>
<div class="col-6">
<small class="text-muted d-block">Version</small>
<span>{{ template.version }}</span>
</div>
<div class="col-6">
<small class="text-muted d-block">Status</small>
<span class="badge {% if template.is_active %}bg-success{% else %}bg-secondary{% endif %}">
{% if template.is_active %}Active{% else %}Inactive{% endif %}
</span>
</div>
<div class="col-12">
<small class="text-muted d-block">Created</small>
<span>{{ template.created_at|date:"M d, Y g:i A" }}</span>
</div>
<div class="col-12">
<small class="text-muted d-block">Last Modified</small>
<span>{{ template.updated_at|date:"M d, Y g:i A" }}</span>
</div>
{% if template.created_by %}
<div class="col-12">
<small class="text-muted d-block">Created By</small>
<span>{{ template.created_by.get_full_name }}</span>
</div>
{% endif %}
</div>
</div>
</div>
<!-- Usage Statistics -->
<div class="card mb-4">
<div class="card-header">
<h6 class="card-title mb-0">
<i class="fas fa-chart-bar me-2"></i>Usage Statistics
</h6>
</div>
<div class="card-body">
<div class="row g-2">
<div class="col-6">
<small class="text-muted d-block">Total Uses</small>
<h5 class="mb-0">{{ template.usage_count|default:0 }}</h5>
</div>
<div class="col-6">
<small class="text-muted d-block">This Month</small>
<h5 class="mb-0">{{ template.monthly_usage|default:0 }}</h5>
</div>
<div class="col-12">
<small class="text-muted d-block">Last Used</small>
<span>{{ template.last_used|date:"M d, Y"|default:"Never" }}</span>
</div>
<div class="col-12">
<small class="text-muted d-block">Average Rating</small>
<div class="d-flex align-items-center">
<div class="stars me-2">
{% for i in "12345" %}
<i class="fas fa-star {% if forloop.counter <= template.average_rating %}text-warning{% else %}text-muted{% endif %}"></i>
{% endfor %}
</div>
<span class="small text-muted">({{ template.rating_count }} reviews)</span>
</div>
</div>
</div>
</div>
</div>
<!-- Template Categories -->
<div class="card mb-4">
<div class="card-header">
<h6 class="card-title mb-0">
<i class="fas fa-tags me-2"></i>Categories & Tags
</h6>
</div>
<div class="card-body">
<div class="mb-3">
<small class="text-muted d-block">Category</small>
<span class="badge bg-primary">{{ template.get_category_display }}</span>
</div>
<div class="mb-3">
<small class="text-muted d-block">Modality</small>
<span class="badge bg-info">{{ template.get_modality_display }}</span>
</div>
<div class="mb-3">
<small class="text-muted d-block">Body Part</small>
<span class="badge bg-secondary">{{ template.get_body_part_display }}</span>
</div>
{% if template.tags %}
<div>
<small class="text-muted d-block">Tags</small>
{% for tag in template.tags_list %}
<span class="badge bg-light text-dark me-1">{{ tag }}</span>
{% endfor %}
</div>
{% endif %}
</div>
</div>
<!-- Recent Reports -->
<div class="card">
<div class="card-header">
<h6 class="card-title mb-0">
<i class="fas fa-clock me-2"></i>Recent Reports Using This Template
</h6>
</div>
<div class="card-body">
{% if recent_reports %}
<div class="list-group list-group-flush">
{% for report in recent_reports %}
<div class="list-group-item px-0 py-2">
<div class="d-flex justify-content-between align-items-start">
<div>
<h6 class="mb-1">{{ report.study.patient.get_full_name }}</h6>
<p class="mb-1 small text-muted">{{ report.study.study_description }}</p>
<small class="text-muted">{{ report.created_datetime|date:"M d, Y" }}</small>
</div>
<span class="badge {% if report.status == 'SIGNED' %}bg-success{% else %}bg-warning{% endif %}">
{{ report.get_status_display }}
</span>
</div>
</div>
{% endfor %}
</div>
<div class="mt-3">
<a href="{% url 'radiology:radiology_report_list' %}?template={{ template.pk }}" class="btn btn-outline-primary btn-sm w-100">
<i class="fas fa-external-link-alt"></i> View All Reports
</a>
</div>
{% else %}
<p class="text-muted mb-0">No reports have used this template yet.</p>
{% endif %}
</div>
</div>
</div>
</div>
</div>
<script>
function duplicateTemplate() {
if (confirm('Create a copy of this template?')) {
fetch(`/radiology/templates/{{ template.pk }}/duplicate/`, {
method: 'POST',
headers: {
'X-CSRFToken': '{{ csrf_token }}',
'Content-Type': 'application/json',
},
})
.then(response => response.json())
.then(data => {
if (data.success) {
window.location.href = `/radiology/templates/${data.template_id}/`;
} else {
alert('Error duplicating template: ' + data.error);
}
});
}
}
function previewTemplate() {
window.open(`/radiology/templates/{{ template.pk }}/preview/`, '_blank');
}
function exportTemplate() {
window.open(`/radiology/templates/{{ template.pk }}/export/`, '_blank');
}
function shareTemplate() {
// Implement template sharing functionality
alert('Template sharing functionality would be implemented here');
}
</script>
<style>
.template-content {
font-family: 'Courier New', monospace;
font-size: 0.9rem;
white-space: pre-wrap;
}
.stars .fa-star {
font-size: 0.8rem;
}
</style>
{% endblock %}