466 lines
18 KiB
HTML
466 lines
18 KiB
HTML
{% extends 'base.html' %}
|
|
{% load static %}
|
|
|
|
{% block title %}Operative Notes{% endblock %}
|
|
|
|
{% block css %}
|
|
<style>
|
|
.stats-card {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
border-radius: 0.5rem;
|
|
padding: 1.5rem;
|
|
margin-bottom: 1rem;
|
|
border: none;
|
|
}
|
|
|
|
.stats-card .stats-icon {
|
|
font-size: 2.5rem;
|
|
opacity: 0.8;
|
|
}
|
|
|
|
.stats-card .stats-number {
|
|
font-size: 2rem;
|
|
font-weight: bold;
|
|
margin: 0.5rem 0;
|
|
}
|
|
|
|
.filter-section {
|
|
background: #f8f9fa;
|
|
border-radius: 0.375rem;
|
|
padding: 1.5rem;
|
|
margin-bottom: 1.5rem;
|
|
}
|
|
|
|
.note-card {
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.375rem;
|
|
padding: 1.5rem;
|
|
margin-bottom: 1rem;
|
|
background: white;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.note-card:hover {
|
|
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
|
transform: translateY(-2px);
|
|
}
|
|
|
|
.note-header {
|
|
display: flex;
|
|
justify-content: between;
|
|
align-items: center;
|
|
margin-bottom: 1rem;
|
|
padding-bottom: 0.5rem;
|
|
border-bottom: 1px solid #dee2e6;
|
|
}
|
|
|
|
.procedure-badge {
|
|
font-size: 0.875rem;
|
|
padding: 0.25rem 0.75rem;
|
|
border-radius: 1rem;
|
|
}
|
|
|
|
.urgency-badge {
|
|
font-size: 0.75rem;
|
|
padding: 0.25rem 0.5rem;
|
|
border-radius: 0.25rem;
|
|
}
|
|
|
|
.note-content {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
gap: 1rem;
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.note-actions {
|
|
display: flex;
|
|
gap: 0.5rem;
|
|
justify-content: flex-end;
|
|
}
|
|
|
|
.status-indicator {
|
|
width: 12px;
|
|
height: 12px;
|
|
border-radius: 50%;
|
|
display: inline-block;
|
|
margin-right: 0.5rem;
|
|
}
|
|
|
|
.status-draft { background-color: #6c757d; }
|
|
.status-pending { background-color: #ffc107; }
|
|
.status-signed { background-color: #28a745; }
|
|
.status-amended { background-color: #17a2b8; }
|
|
|
|
@media (max-width: 768px) {
|
|
.note-content {
|
|
grid-template-columns: 1fr;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.note-actions {
|
|
flex-direction: column;
|
|
}
|
|
|
|
.filter-section {
|
|
padding: 1rem;
|
|
}
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<div id="content" class="app-content">
|
|
<!-- Page Header -->
|
|
<div class="d-flex align-items-center mb-3">
|
|
<div>
|
|
<ol class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="{% url 'core:dashboard' %}">Dashboard</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'operating_theatre:dashboard' %}">Operating Theatre</a></li>
|
|
<li class="breadcrumb-item active">Operative Notes</li>
|
|
</ol>
|
|
<h1 class="page-header mb-0">
|
|
<i class="fas fa-file-medical me-2"></i>Operative Notes
|
|
</h1>
|
|
</div>
|
|
<div class="ms-auto">
|
|
<a href="{% url 'operating_theatre:surgical_note_create' %}" class="btn btn-primary">
|
|
<i class="fas fa-plus me-1"></i>New Note
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Statistics Cards -->
|
|
<div class="row mb-4">
|
|
<div class="col-lg-3 col-md-6">
|
|
<div class="stats-card">
|
|
<div class="d-flex align-items-center">
|
|
<div class="flex-grow-1">
|
|
<div class="stats-number">{{ stats.total_notes }}</div>
|
|
<div>Total Notes</div>
|
|
</div>
|
|
<div class="stats-icon">
|
|
<i class="fas fa-file-medical"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-3 col-md-6">
|
|
<div class="stats-card">
|
|
<div class="d-flex align-items-center">
|
|
<div class="flex-grow-1">
|
|
<div class="stats-number">{{ stats.pending_signature }}</div>
|
|
<div>Pending Signature</div>
|
|
</div>
|
|
<div class="stats-icon">
|
|
<i class="fas fa-signature"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-3 col-md-6">
|
|
<div class="stats-card">
|
|
<div class="d-flex align-items-center">
|
|
<div class="flex-grow-1">
|
|
<div class="stats-number">{{ stats.today_notes }}</div>
|
|
<div>Today's Notes</div>
|
|
</div>
|
|
<div class="stats-icon">
|
|
<i class="fas fa-calendar-day"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-3 col-md-6">
|
|
<div class="stats-card">
|
|
<div class="d-flex align-items-center">
|
|
<div class="flex-grow-1">
|
|
<div class="stats-number">{{ stats.overdue_notes }}</div>
|
|
<div>Overdue</div>
|
|
</div>
|
|
<div class="stats-icon">
|
|
<i class="fas fa-exclamation-triangle"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Filters -->
|
|
<div class="filter-section">
|
|
<form method="get" id="filterForm">
|
|
<div class="row">
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label class="form-label">Date Range</label>
|
|
<select class="form-select" name="date_range">
|
|
<option value="">All Dates</option>
|
|
<option value="today" {% if request.GET.date_range == 'today' %}selected{% endif %}>Today</option>
|
|
<option value="week" {% if request.GET.date_range == 'week' %}selected{% endif %}>This Week</option>
|
|
<option value="month" {% if request.GET.date_range == 'month' %}selected{% endif %}>This Month</option>
|
|
<option value="custom" {% if request.GET.date_range == 'custom' %}selected{% endif %}>Custom Range</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label class="form-label">Status</label>
|
|
<select class="form-select" name="status">
|
|
<option value="">All Status</option>
|
|
<option value="draft" {% if request.GET.status == 'draft' %}selected{% endif %}>Draft</option>
|
|
<option value="pending" {% if request.GET.status == 'pending' %}selected{% endif %}>Pending Signature</option>
|
|
<option value="signed" {% if request.GET.status == 'signed' %}selected{% endif %}>Signed</option>
|
|
<option value="amended" {% if request.GET.status == 'amended' %}selected{% endif %}>Amended</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label class="form-label">Surgeon</label>
|
|
<select class="form-select" name="surgeon">
|
|
<option value="">All Surgeons</option>
|
|
{% for surgeon in surgeons %}
|
|
<option value="{{ surgeon.id }}" {% if request.GET.surgeon == surgeon.id|stringformat:"s" %}selected{% endif %}>
|
|
{{ surgeon.get_full_name }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label class="form-label">Search</label>
|
|
<div class="input-group">
|
|
<input type="text" class="form-control" name="search"
|
|
value="{{ request.GET.search }}" placeholder="Patient name, procedure...">
|
|
<button class="btn btn-outline-secondary" type="submit">
|
|
<i class="fas fa-search"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row mt-3">
|
|
<div class="col-12">
|
|
<button type="submit" class="btn btn-primary me-2">
|
|
<i class="fas fa-filter me-1"></i>Apply Filters
|
|
</button>
|
|
<a href="{% url 'operating_theatre:surgical_note_list' %}" class="btn btn-outline-secondary">
|
|
<i class="fas fa-times me-1"></i>Clear
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Notes List -->
|
|
<div class="row">
|
|
{% for note in notes %}
|
|
<div class="col-12">
|
|
<div class="note-card">
|
|
<div class="note-header">
|
|
<div class="d-flex align-items-center">
|
|
<span class="status-indicator status-{{ note.status }}"></span>
|
|
<h5 class="mb-0 me-3">{{ note.patient.get_full_name }}</h5>
|
|
<span class="procedure-badge badge bg-primary">{{ note.procedure_name }}</span>
|
|
{% if note.urgency == 'emergency' %}
|
|
<span class="urgency-badge badge bg-danger ms-2">Emergency</span>
|
|
{% elif note.urgency == 'urgent' %}
|
|
<span class="urgency-badge badge bg-warning ms-2">Urgent</span>
|
|
{% endif %}
|
|
</div>
|
|
<div class="text-muted">
|
|
<small>{{ note.surgery_date|date:"M d, Y H:i" }}</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="note-content">
|
|
<div>
|
|
<div class="mb-2">
|
|
<strong>Patient ID:</strong> {{ note.patient.patient_id }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Surgeon:</strong> {{ note.primary_surgeon.get_full_name }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Operating Room:</strong> {{ note.operating_room.name }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Duration:</strong>
|
|
{% if note.surgery_end_time %}
|
|
{{ note.surgery_duration }} minutes
|
|
{% else %}
|
|
In Progress
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="mb-2">
|
|
<strong>Status:</strong>
|
|
{% if note.status == 'draft' %}
|
|
<span class="badge bg-secondary">Draft</span>
|
|
{% elif note.status == 'pending' %}
|
|
<span class="badge bg-warning">Pending Signature</span>
|
|
{% elif note.status == 'signed' %}
|
|
<span class="badge bg-success">Signed</span>
|
|
{% elif note.status == 'amended' %}
|
|
<span class="badge bg-info">Amended</span>
|
|
{% endif %}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Created:</strong> {{ note.created_at|date:"M d, Y H:i" }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Last Updated:</strong> {{ note.updated_at|date:"M d, Y H:i" }}
|
|
</div>
|
|
{% if note.signed_at %}
|
|
<div class="mb-2">
|
|
<strong>Signed:</strong> {{ note.signed_at|date:"M d, Y H:i" }}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="note-actions">
|
|
<a href="{% url 'operating_theatre:operative_note_detail' note.pk %}"
|
|
class="btn btn-outline-primary btn-sm">
|
|
<i class="fas fa-eye me-1"></i>View
|
|
</a>
|
|
{% if note.status == 'draft' or note.status == 'pending' %}
|
|
<a href="{% url 'operating_theatre:operative_note_edit' note.pk %}"
|
|
class="btn btn-outline-secondary btn-sm">
|
|
<i class="fas fa-edit me-1"></i>Edit
|
|
</a>
|
|
{% endif %}
|
|
{% if note.status == 'pending' and note.primary_surgeon == request.user %}
|
|
<button class="btn btn-success btn-sm" onclick="signNote('{{ note.pk }}')">
|
|
<i class="fas fa-signature me-1"></i>Sign
|
|
</button>
|
|
{% endif %}
|
|
<div class="dropdown">
|
|
<button class="btn btn-outline-secondary btn-sm dropdown-toggle"
|
|
type="button" data-bs-toggle="dropdown">
|
|
<i class="fas fa-ellipsis-v"></i>
|
|
</button>
|
|
<ul class="dropdown-menu">
|
|
<li>
|
|
<a class="dropdown-item" href="{% url 'operating_theatre:operative_note_print' note.pk %}">
|
|
<i class="fas fa-print me-2"></i>Print
|
|
</a>
|
|
</li>
|
|
<li>
|
|
<a class="dropdown-item" href="{% url 'operating_theatre:operative_note_pdf' note.pk %}">
|
|
<i class="fas fa-file-pdf me-2"></i>Download PDF
|
|
</a>
|
|
</li>
|
|
{% if note.status == 'signed' %}
|
|
<li>
|
|
<a class="dropdown-item" href="#" onclick="amendNote('{{ note.pk }}')">
|
|
<i class="fas fa-edit me-2"></i>Amend Note
|
|
</a>
|
|
</li>
|
|
{% endif %}
|
|
<li><hr class="dropdown-divider"></li>
|
|
<li>
|
|
<a class="dropdown-item text-danger" href="#" onclick="deleteNote('{{ note.pk }}')">
|
|
<i class="fas fa-trash me-2"></i>Delete
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% empty %}
|
|
<div class="col-12">
|
|
<div class="text-center py-5">
|
|
<i class="fas fa-file-medical fa-3x text-muted mb-3"></i>
|
|
<h5 class="text-muted">No operative notes found</h5>
|
|
<p class="text-muted">No notes match your current filters.</p>
|
|
<a href="{% url 'operating_theatre:surgical_note_create' %}" class="btn btn-primary">
|
|
<i class="fas fa-plus me-1"></i>Create First Note
|
|
</a>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
|
|
<!-- Pagination -->
|
|
{% if is_paginated %}
|
|
<div class="d-flex justify-content-center mt-4">
|
|
<nav>
|
|
<ul class="pagination">
|
|
{% if page_obj.has_previous %}
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page=1{% if request.GET.urlencode %}&{{ request.GET.urlencode }}{% endif %}">First</a>
|
|
</li>
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page={{ page_obj.previous_page_number }}{% if request.GET.urlencode %}&{{ request.GET.urlencode }}{% endif %}">Previous</a>
|
|
</li>
|
|
{% endif %}
|
|
|
|
<li class="page-item active">
|
|
<span class="page-link">{{ page_obj.number }} of {{ page_obj.paginator.num_pages }}</span>
|
|
</li>
|
|
|
|
{% if page_obj.has_next %}
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page={{ page_obj.next_page_number }}{% if request.GET.urlencode %}&{{ request.GET.urlencode }}{% endif %}">Next</a>
|
|
</li>
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page={{ page_obj.paginator.num_pages }}{% if request.GET.urlencode %}&{{ request.GET.urlencode }}{% endif %}">Last</a>
|
|
</li>
|
|
{% endif %}
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block js %}
|
|
<script>
|
|
function signNote(noteId) {
|
|
if (confirm('Sign this operative note? Once signed, the note cannot be edited without creating an amendment.')) {
|
|
$.ajax({
|
|
url: `/operating-theatre/notes/${noteId}/sign/`,
|
|
method: 'POST',
|
|
data: {
|
|
'csrfmiddlewaretoken': '{{ csrf_token }}'
|
|
},
|
|
success: function(response) {
|
|
if (response.success) {
|
|
location.reload();
|
|
} else {
|
|
alert('Error signing note: ' + response.error);
|
|
}
|
|
},
|
|
error: function() {
|
|
alert('Error signing note');
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
function amendNote(noteId) {
|
|
const reason = prompt('Enter reason for amendment:');
|
|
if (reason) {
|
|
window.location.href = `/operating-theatre/notes/${noteId}/amend/?reason=${encodeURIComponent(reason)}`;
|
|
}
|
|
}
|
|
|
|
function deleteNote(noteId) {
|
|
if (confirm('Delete this operative note? This action cannot be undone.')) {
|
|
window.location.href = `/operating-theatre/notes/${noteId}/delete/`;
|
|
}
|
|
}
|
|
|
|
// Auto-submit form on filter change
|
|
$('#filterForm select').on('change', function() {
|
|
$('#filterForm').submit();
|
|
});
|
|
</script>
|
|
{% endblock %}
|
|
|