266 lines
16 KiB
HTML
266 lines
16 KiB
HTML
{% extends "base.html" %}
|
||
{% load static %}
|
||
|
||
{% block title %}Prescriptions - {{ 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-prescription me-2"></i>Prescription Management
|
||
</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>
|
||
{% for value, label in prescription_statuses %}
|
||
<option value="{{ value }}" {% if request.GET.status == value %}selected{% endif %}>{{ label }}</option>
|
||
{% endfor %}
|
||
</select>
|
||
</div>
|
||
<div class="col-md-2">
|
||
<select name="priority" class="form-select">
|
||
<option value="">All Priorities</option>
|
||
{% for value, label in priorities %}
|
||
<option value="{{ value }}" {% if request.GET.priority == value %}selected{% endif %}>{{ label }}</option>
|
||
{% endfor %}
|
||
</select>
|
||
</div>
|
||
<div class="col-md-2">
|
||
<input type="date" name="date_from" class="form-control"
|
||
value="{{ request.GET.date_from }}" placeholder="From Date">
|
||
</div>
|
||
<div class="col-md-2">
|
||
<input type="date" name="date_to" class="form-control"
|
||
value="{{ request.GET.date_to }}" placeholder="To Date">
|
||
</div>
|
||
<div class="col-md-3">
|
||
<input type="text" name="search" class="form-control"
|
||
value="{{ request.GET.search }}" placeholder="Search patients, medications, providers...">
|
||
</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>
|
||
|
||
<!-- Prescriptions Table -->
|
||
<div class="table-responsive">
|
||
<table class="table table-hover">
|
||
<thead>
|
||
<tr>
|
||
<th>Patient</th>
|
||
<th>Medication</th>
|
||
<th>Dosage</th>
|
||
<th>Provider</th>
|
||
<th>Prescribed</th>
|
||
<th>Status</th>
|
||
<th>Priority</th>
|
||
<th>Actions</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{% for prescription in prescriptions %}
|
||
<tr {% if prescription.priority == 'STAT' %}class="table-danger"{% elif prescription.priority == 'URGENT' %}class="table-warning"{% endif %}>
|
||
<td>
|
||
<strong>{{ prescription.patient.get_full_name }}</strong><br>
|
||
<small class="text-muted">
|
||
MRN: {{ prescription.patient.mrn }} •
|
||
{{ prescription.patient.age }}y {{ prescription.patient.get_gender_display }}
|
||
</small>
|
||
</td>
|
||
<td>
|
||
<strong>{{ prescription.medication.name }}</strong>
|
||
{% if prescription.medication.generic_name %}
|
||
<br><small class="text-muted">{{ prescription.medication.generic_name }}</small>
|
||
{% endif %}
|
||
</td>
|
||
<td>
|
||
{{ prescription.dosage }} {{ prescription.dosage_unit }}<br>
|
||
<small class="text-muted">
|
||
{{ prescription.frequency }} × {{ prescription.duration }} {{ prescription.duration_unit }}
|
||
</small>
|
||
</td>
|
||
<td>{{ prescription.prescribing_provider.get_full_name }}</td>
|
||
<td>{{ prescription.prescribed_datetime|date:"M d, Y H:i" }}</td>
|
||
<td>
|
||
{% if prescription.status == 'PENDING' %}
|
||
<span class="badge bg-warning">Pending</span>
|
||
{% elif prescription.status == 'VERIFIED' %}
|
||
<span class="badge bg-info">Verified</span>
|
||
{% elif prescription.status == 'IN_PROGRESS' %}
|
||
<span class="badge bg-primary">In Progress</span>
|
||
{% elif prescription.status == 'DISPENSED' %}
|
||
<span class="badge bg-success">Dispensed</span>
|
||
{% elif prescription.status == 'CANCELLED' %}
|
||
<span class="badge bg-danger">Cancelled</span>
|
||
{% elif prescription.status == 'ON_HOLD' %}
|
||
<span class="badge bg-secondary">On Hold</span>
|
||
{% endif %}
|
||
</td>
|
||
<td>
|
||
{% if prescription.priority == 'STAT' %}
|
||
<span class="badge bg-danger">STAT</span>
|
||
{% elif prescription.priority == 'URGENT' %}
|
||
<span class="badge bg-warning">Urgent</span>
|
||
{% elif prescription.priority == 'ROUTINE' %}
|
||
<span class="badge bg-info">Routine</span>
|
||
{% endif %}
|
||
</td>
|
||
<td>
|
||
<div class="btn-group btn-group-sm">
|
||
<a href="{% url 'pharmacy:prescription_detail' prescription.id %}"
|
||
class="btn btn-outline-primary" title="View Details">
|
||
<i class="fas fa-eye"></i>
|
||
</a>
|
||
{% if prescription.status == 'PENDING' %}
|
||
<button class="btn btn-outline-success"
|
||
title="Verify"
|
||
hx-post="{% url 'pharmacy:verify_prescription' prescription.id %}"
|
||
hx-confirm="Verify this prescription?"
|
||
hx-swap="none">
|
||
<i class="fas fa-check"></i>
|
||
</button>
|
||
{% elif prescription.status == 'VERIFIED' %}
|
||
<button class="btn btn-outline-info"
|
||
title="Dispense"
|
||
data-bs-toggle="modal"
|
||
data-bs-target="#dispense-modal-{{ prescription.id }}">
|
||
<i class="fas fa-hand-holding-medical"></i>
|
||
</button>
|
||
{% endif %}
|
||
<button class="btn btn-outline-warning"
|
||
title="Check Interactions"
|
||
hx-get="{% url 'pharmacy:drug_interaction_check' prescription.id %}"
|
||
hx-target="#interaction-results"
|
||
data-bs-toggle="modal"
|
||
data-bs-target="#interaction-modal">
|
||
<i class="fas fa-exclamation-triangle"></i>
|
||
</button>
|
||
<button class="btn btn-outline-secondary" title="Print">
|
||
<i class="fas fa-print"></i>
|
||
</button>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
{% empty %}
|
||
<tr>
|
||
<td colspan="8" class="text-center py-4">
|
||
<i class="fas fa-prescription fa-3x text-muted mb-3"></i>
|
||
<h5 class="text-muted">No prescriptions found</h5>
|
||
<p class="text-muted">No prescriptions match your current filters.</p>
|
||
</td>
|
||
</tr>
|
||
{% endfor %}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
|
||
<!-- Pagination -->
|
||
{% if is_paginated %}
|
||
<nav aria-label="Prescription pagination">
|
||
<ul class="pagination justify-content-center">
|
||
{% if page_obj.has_previous %}
|
||
<li class="page-item">
|
||
<a class="page-link" href="?page=1{% if request.GET.search %}&search={{ request.GET.search }}{% endif %}{% if request.GET.status %}&status={{ request.GET.status }}{% endif %}">First</a>
|
||
</li>
|
||
<li class="page-item">
|
||
<a class="page-link" href="?page={{ page_obj.previous_page_number }}{% if request.GET.search %}&search={{ request.GET.search }}{% endif %}{% if request.GET.status %}&status={{ request.GET.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 request.GET.search %}&search={{ request.GET.search }}{% endif %}{% if request.GET.status %}&status={{ request.GET.status }}{% endif %}">Next</a>
|
||
</li>
|
||
<li class="page-item">
|
||
<a class="page-link" href="?page={{ page_obj.paginator.num_pages }}{% if request.GET.search %}&search={{ request.GET.search }}{% endif %}{% if request.GET.status %}&status={{ request.GET.status }}{% endif %}">Last</a>
|
||
</li>
|
||
{% endif %}
|
||
</ul>
|
||
</nav>
|
||
{% endif %}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Drug Interaction Modal -->
|
||
<div class="modal fade" id="interaction-modal" tabindex="-1">
|
||
<div class="modal-dialog modal-lg">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title">Drug Interaction Check</h5>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||
</div>
|
||
<div class="modal-body" id="interaction-results">
|
||
<!-- Content loaded via HTMX -->
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Dispense Modals -->
|
||
{% for prescription in prescriptions %}
|
||
{% if prescription.status == 'VERIFIED' %}
|
||
<div class="modal fade" id="dispense-modal-{{ prescription.id }}" tabindex="-1">
|
||
<div class="modal-dialog">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title">Dispense Medication</h5>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||
</div>
|
||
<form hx-post="{% url 'pharmacy:dispense_medication' prescription.id %}">
|
||
<div class="modal-body">
|
||
<div class="mb-3">
|
||
<label class="form-label">Patient</label>
|
||
<p class="form-control-plaintext">{{ prescription.patient.get_full_name }}</p>
|
||
</div>
|
||
<div class="mb-3">
|
||
<label class="form-label">Medication</label>
|
||
<p class="form-control-plaintext">{{ prescription.medication.name }}</p>
|
||
</div>
|
||
<div class="mb-3">
|
||
<label class="form-label">Prescribed Quantity</label>
|
||
<p class="form-control-plaintext">{{ prescription.quantity }} {{ prescription.quantity_unit }}</p>
|
||
</div>
|
||
<div class="mb-3">
|
||
<label for="quantity_dispensed" class="form-label">Quantity to Dispense</label>
|
||
<input type="number" class="form-control" name="quantity_dispensed"
|
||
value="{{ prescription.quantity }}" max="{{ prescription.quantity }}" required>
|
||
</div>
|
||
<div class="mb-3">
|
||
<label for="lot_number" class="form-label">Lot Number</label>
|
||
<input type="text" class="form-control" name="lot_number" required>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||
<button type="submit" class="btn btn-primary">Dispense</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
{% endif %}
|
||
{% endfor %}
|
||
{% endblock %}
|
||
|