226 lines
14 KiB
HTML
226 lines
14 KiB
HTML
{% extends "base.html" %}
|
|
{% load static %}
|
|
|
|
{% block title %}Surgical Cases - {{ block.super }}{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title mb-0">
|
|
<i class="fas fa-procedures me-2"></i>Surgical Cases
|
|
</h4>
|
|
</div>
|
|
|
|
<div class="card-body">
|
|
<!-- Filters -->
|
|
<form method="get" class="mb-3">
|
|
<div class="row">
|
|
<div class="col-md-2">
|
|
<select name="status" class="form-select">
|
|
<option value="">All Status</option>
|
|
<option value="SCHEDULED" {% if status == 'SCHEDULED' %}selected{% endif %}>Scheduled</option>
|
|
<option value="IN_PROGRESS" {% if status == 'IN_PROGRESS' %}selected{% endif %}>In Progress</option>
|
|
<option value="COMPLETED" {% if status == 'COMPLETED' %}selected{% endif %}>Completed</option>
|
|
<option value="CANCELLED" {% if status == 'CANCELLED' %}selected{% endif %}>Cancelled</option>
|
|
<option value="DELAYED" {% if status == 'DELAYED' %}selected{% endif %}>Delayed</option>
|
|
</select>
|
|
</div>
|
|
<div class="col-md-2">
|
|
<select name="priority" class="form-select">
|
|
<option value="">All Priorities</option>
|
|
<option value="EMERGENCY" {% if priority == 'EMERGENCY' %}selected{% endif %}>Emergency</option>
|
|
<option value="URGENT" {% if priority == 'URGENT' %}selected{% endif %}>Urgent</option>
|
|
<option value="ELECTIVE" {% if priority == 'ELECTIVE' %}selected{% endif %}>Elective</option>
|
|
</select>
|
|
</div>
|
|
<div class="col-md-2">
|
|
<select name="room_id" class="form-select">
|
|
<option value="">All Rooms</option>
|
|
{% for room in rooms %}
|
|
<option value="{{ room.room_id }}" {% if room_id == room.room_id|stringformat:"s" %}selected{% endif %}>
|
|
{{ room.room_number }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
<div class="col-md-2">
|
|
<input type="date" name="date_from" class="form-control"
|
|
value="{{ date_from }}" placeholder="From Date">
|
|
</div>
|
|
<div class="col-md-3">
|
|
<input type="text" name="search" class="form-control"
|
|
value="{{ search }}" placeholder="Search cases, patients...">
|
|
</div>
|
|
<div class="col-md-1">
|
|
<button type="submit" class="btn btn-primary w-100">
|
|
<i class="fas fa-search"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
|
|
<!-- Cases Table -->
|
|
<div class="table-responsive">
|
|
<table class="table table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th>Case #</th>
|
|
<th>Patient</th>
|
|
<th>Procedure</th>
|
|
<th>Surgeon</th>
|
|
<th>Scheduled</th>
|
|
<th>Room</th>
|
|
<th>Priority</th>
|
|
<th>Status</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for case in page_obj %}
|
|
<tr {% if case.priority == 'EMERGENCY' %}class="table-danger"{% elif case.priority == 'URGENT' %}class="table-warning"{% endif %}>
|
|
<td>
|
|
<strong>{{ case.case_number }}</strong>
|
|
{% if case.encounter %}
|
|
<br><small class="text-muted">Enc: {{ case.encounter.id }}</small>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
<strong>{{ case.patient.get_full_name }}</strong><br>
|
|
<small class="text-muted">
|
|
MRN: {{ case.patient.mrn }} •
|
|
{{ case.patient.age }}y {{ case.patient.get_gender_display }}
|
|
</small>
|
|
</td>
|
|
<td>
|
|
{% for procedure in case.procedures.all %}
|
|
<strong>{{ procedure.procedure_name }}</strong>
|
|
{% if procedure.cpt_code %}
|
|
<br><small class="text-muted">{{ procedure.cpt_code }}</small>
|
|
{% endif %}
|
|
{% if not forloop.last %}<br>{% endif %}
|
|
{% endfor %}
|
|
</td>
|
|
<td>
|
|
{{ case.primary_surgeon.get_full_name }}
|
|
{% if case.anesthesiologist %}
|
|
<br><small class="text-muted">Anesthesia: {{ case.anesthesiologist.get_full_name }}</small>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
{{ case.scheduled_start_time|date:"M d, Y H:i" }}
|
|
{% if case.estimated_duration %}
|
|
<br><small class="text-muted">{{ case.estimated_duration }}min</small>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
{% if case.operating_room %}
|
|
{{ case.operating_room.room_number }}
|
|
{% else %}
|
|
<span class="text-muted">TBD</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
{% if case.priority == 'EMERGENCY' %}
|
|
<span class="badge bg-danger">Emergency</span>
|
|
{% elif case.priority == 'URGENT' %}
|
|
<span class="badge bg-warning">Urgent</span>
|
|
{% elif case.priority == 'ELECTIVE' %}
|
|
<span class="badge bg-info">Elective</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
{% if case.status == 'SCHEDULED' %}
|
|
<span class="badge bg-info">Scheduled</span>
|
|
{% elif case.status == 'IN_PROGRESS' %}
|
|
<span class="badge bg-success">In Progress</span>
|
|
{% elif case.status == 'COMPLETED' %}
|
|
<span class="badge bg-success">Completed</span>
|
|
{% elif case.status == 'CANCELLED' %}
|
|
<span class="badge bg-danger">Cancelled</span>
|
|
{% elif case.status == 'DELAYED' %}
|
|
<span class="badge bg-warning">Delayed</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
<div class="btn-group btn-group-sm">
|
|
<a href="{% url 'operating_theatre:case_detail' case.case_id %}"
|
|
class="btn btn-outline-primary" title="View Details">
|
|
<i class="fas fa-eye"></i>
|
|
</a>
|
|
{% if case.status == 'SCHEDULED' %}
|
|
<button class="btn btn-outline-success"
|
|
title="Start Case"
|
|
hx-post="{% url 'operating_theatre:start_case' case.case_id %}"
|
|
hx-confirm="Start this surgical case?"
|
|
hx-swap="none">
|
|
<i class="fas fa-play"></i>
|
|
</button>
|
|
{% elif case.status == 'IN_PROGRESS' %}
|
|
<button class="btn btn-outline-info"
|
|
title="Complete Case"
|
|
hx-post="{% url 'operating_theatre:complete_case' case.case_id %}"
|
|
hx-confirm="Complete this surgical case?"
|
|
hx-swap="none">
|
|
<i class="fas fa-check"></i>
|
|
</button>
|
|
{% endif %}
|
|
<button class="btn btn-outline-secondary" title="Print">
|
|
<i class="fas fa-print"></i>
|
|
</button>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% empty %}
|
|
<tr>
|
|
<td colspan="9" class="text-center py-4">
|
|
<i class="fas fa-procedures fa-3x text-muted mb-3"></i>
|
|
<h5 class="text-muted">No surgical cases found</h5>
|
|
<p class="text-muted">No surgical cases match your current filters.</p>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- Pagination -->
|
|
{% if page_obj.has_other_pages %}
|
|
<nav aria-label="Surgical cases pagination">
|
|
<ul class="pagination justify-content-center">
|
|
{% if page_obj.has_previous %}
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page=1{% if search %}&search={{ search }}{% endif %}{% if status %}&status={{ status }}{% endif %}">First</a>
|
|
</li>
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page={{ page_obj.previous_page_number }}{% if search %}&search={{ search }}{% endif %}{% if status %}&status={{ status }}{% endif %}">Previous</a>
|
|
</li>
|
|
{% endif %}
|
|
|
|
<li class="page-item active">
|
|
<span class="page-link">
|
|
Page {{ 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 search %}&search={{ search }}{% endif %}{% if status %}&status={{ status }}{% endif %}">Next</a>
|
|
</li>
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page={{ page_obj.paginator.num_pages }}{% if search %}&search={{ search }}{% endif %}{% if status %}&status={{ status }}{% endif %}">Last</a>
|
|
</li>
|
|
{% endif %}
|
|
</ul>
|
|
</nav>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|