389 lines
20 KiB
HTML
389 lines
20 KiB
HTML
{% extends "base.html" %}
|
|
{% load static %}
|
|
|
|
{% block title %}Delete Prescription - Pharmacy{% endblock %}
|
|
|
|
{% block content %}
|
|
<!-- BEGIN breadcrumb -->
|
|
<ol class="breadcrumb float-xl-end">
|
|
<li class="breadcrumb-item"><a href="{% url 'core:dashboard' %}">Dashboard</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'pharmacy:dashboard' %}">Pharmacy</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'pharmacy:prescription_list' %}">Prescriptions</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'pharmacy:prescription_detail' object.pk %}">{{ object.prescription_number }}</a></li>
|
|
<li class="breadcrumb-item active">Delete</li>
|
|
</ol>
|
|
<!-- END breadcrumb -->
|
|
|
|
<!-- BEGIN page-header -->
|
|
<h1 class="page-header">
|
|
Delete Prescription
|
|
<small>{{ object.prescription_number }}</small>
|
|
</h1>
|
|
<!-- END page-header -->
|
|
|
|
<div class="row">
|
|
<div class="col-xl-8">
|
|
<!-- BEGIN panel -->
|
|
<div class="panel panel-inverse">
|
|
<div class="panel-heading">
|
|
<h4 class="panel-title">Confirm Prescription Deletion</h4>
|
|
<div class="panel-heading-btn">
|
|
<a href="javascript:;" class="btn btn-xs btn-icon btn-default" data-toggle="panel-expand"><i class="fa fa-expand"></i></a>
|
|
</div>
|
|
</div>
|
|
<div class="panel-body">
|
|
<!-- Prescription Information -->
|
|
<div class="card border-danger mb-4">
|
|
<div class="card-header bg-danger text-white">
|
|
<h5 class="card-title mb-0">
|
|
<i class="fa fa-exclamation-triangle me-2"></i>Prescription to be Deleted
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="mb-2"><strong>Prescription Number:</strong> {{ object.prescription_number }}</div>
|
|
<div class="mb-2"><strong>Patient:</strong> {{ object.patient.full_name }}</div>
|
|
<div class="mb-2"><strong>Medication:</strong> {{ object.medication.name }}</div>
|
|
<div class="mb-2"><strong>Dosage:</strong> {{ object.dosage }} {{ object.dosage_unit }}</div>
|
|
<div class="mb-2"><strong>Quantity:</strong> {{ object.quantity }}</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="mb-2"><strong>Prescriber:</strong> {{ object.prescriber.full_name }}</div>
|
|
<div class="mb-2"><strong>Status:</strong>
|
|
<span class="badge bg-{{ object.status|lower }}">{{ object.get_status_display }}</span>
|
|
</div>
|
|
<div class="mb-2"><strong>Date Prescribed:</strong> {{ object.date_prescribed|date:"M d, Y" }}</div>
|
|
<div class="mb-2"><strong>Due Date:</strong> {{ object.due_date|date:"M d, Y"|default:"Not specified" }}</div>
|
|
{% if object.is_controlled %}
|
|
<div class="mb-2">
|
|
<span class="badge bg-warning text-dark">
|
|
<i class="fa fa-shield me-1"></i>Controlled Substance
|
|
</span>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
{% if object.instructions %}
|
|
<div class="mt-3">
|
|
<strong>Instructions:</strong>
|
|
<div class="text-muted">{{ object.instructions }}</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Impact Assessment -->
|
|
<div class="card border-warning mb-4">
|
|
<div class="card-header bg-warning text-dark">
|
|
<h5 class="card-title mb-0">
|
|
<i class="fa fa-assessment me-2"></i>Impact Assessment
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<h6 class="text-danger">Potential Issues:</h6>
|
|
<ul class="list-unstyled">
|
|
{% if object.status == 'dispensed' %}
|
|
<li><i class="fa fa-exclamation-triangle text-danger me-2"></i>Prescription has already been dispensed</li>
|
|
{% endif %}
|
|
{% if object.status == 'in_progress' %}
|
|
<li><i class="fa fa-clock text-warning me-2"></i>Prescription is currently being processed</li>
|
|
{% endif %}
|
|
{% if object.is_controlled %}
|
|
<li><i class="fa fa-shield text-warning me-2"></i>Controlled substance requires special handling</li>
|
|
{% endif %}
|
|
{% if object.refills_remaining > 0 %}
|
|
<li><i class="fa fa-refresh text-info me-2"></i>{{ object.refills_remaining }} refill(s) remaining</li>
|
|
{% endif %}
|
|
{% if object.urgent %}
|
|
<li><i class="fa fa-exclamation text-danger me-2"></i>Marked as urgent prescription</li>
|
|
{% endif %}
|
|
</ul>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<h6 class="text-info">Related Records:</h6>
|
|
<ul class="list-unstyled">
|
|
<li><i class="fa fa-user me-2"></i>Patient: {{ object.patient.full_name }}</li>
|
|
<li><i class="fa fa-user-md me-2"></i>Prescriber: {{ object.prescriber.full_name }}</li>
|
|
{% if object.dispensing_records.exists %}
|
|
<li><i class="fa fa-history me-2"></i>{{ object.dispensing_records.count }} dispensing record(s)</li>
|
|
{% endif %}
|
|
{% if object.interaction_checks.exists %}
|
|
<li><i class="fa fa-exclamation-triangle me-2"></i>{{ object.interaction_checks.count }} interaction check(s)</li>
|
|
{% endif %}
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Status-Specific Warnings -->
|
|
{% if object.status == 'dispensed' %}
|
|
<div class="alert alert-danger">
|
|
<h6 class="alert-heading">
|
|
<i class="fa fa-exclamation-triangle me-2"></i>Critical Warning
|
|
</h6>
|
|
<p class="mb-2">This prescription has already been dispensed to the patient. Deleting it may:</p>
|
|
<ul class="mb-2">
|
|
<li>Create gaps in the patient's medication history</li>
|
|
<li>Affect insurance claims and billing records</li>
|
|
<li>Impact regulatory compliance and audit trails</li>
|
|
<li>Remove important clinical documentation</li>
|
|
</ul>
|
|
<p class="mb-0"><strong>Consider marking as cancelled instead of deleting.</strong></p>
|
|
</div>
|
|
{% elif object.status == 'in_progress' %}
|
|
<div class="alert alert-warning">
|
|
<h6 class="alert-heading">
|
|
<i class="fa fa-clock me-2"></i>Processing Warning
|
|
</h6>
|
|
<p class="mb-0">This prescription is currently being processed. Deleting it may disrupt the pharmacy workflow and confuse staff members.</p>
|
|
</div>
|
|
{% elif object.is_controlled %}
|
|
<div class="alert alert-warning">
|
|
<h6 class="alert-heading">
|
|
<i class="fa fa-shield me-2"></i>Controlled Substance Warning
|
|
</h6>
|
|
<p class="mb-0">This prescription contains controlled substances. Deletion must be properly documented for DEA compliance and audit purposes.</p>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Alternative Actions -->
|
|
<div class="card border-info mb-4">
|
|
<div class="card-header bg-info text-white">
|
|
<h5 class="card-title mb-0">
|
|
<i class="fa fa-lightbulb me-2"></i>Alternative Actions
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<p class="mb-3">Instead of deleting this prescription, consider these alternatives:</p>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="d-grid gap-2">
|
|
<a href="{% url 'pharmacy:prescription_cancel' object.pk %}" class="btn btn-outline-warning">
|
|
<i class="fa fa-ban me-2"></i>Cancel Prescription
|
|
</a>
|
|
<a href="{% url 'pharmacy:prescription_edit' object.pk %}" class="btn btn-outline-primary">
|
|
<i class="fa fa-edit me-2"></i>Edit Prescription
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="d-grid gap-2">
|
|
<a href="{% url 'pharmacy:prescription_hold' object.pk %}" class="btn btn-outline-secondary">
|
|
<i class="fa fa-pause me-2"></i>Put on Hold
|
|
</a>
|
|
<a href="{% url 'pharmacy:prescription_archive' object.pk %}" class="btn btn-outline-info">
|
|
<i class="fa fa-archive me-2"></i>Archive Prescription
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Confirmation Form -->
|
|
<form method="post" id="delete-form">
|
|
{% csrf_token %}
|
|
|
|
<!-- Reason for Deletion -->
|
|
<div class="mb-3">
|
|
<label for="deletion_reason" class="form-label">Reason for Deletion <span class="text-danger">*</span></label>
|
|
<select class="form-select" id="deletion_reason" name="deletion_reason" required>
|
|
<option value="">Select reason...</option>
|
|
<option value="duplicate">Duplicate prescription</option>
|
|
<option value="error">Prescription entered in error</option>
|
|
<option value="patient_request">Patient request</option>
|
|
<option value="prescriber_request">Prescriber request</option>
|
|
<option value="system_error">System error</option>
|
|
<option value="other">Other (specify below)</option>
|
|
</select>
|
|
</div>
|
|
|
|
<!-- Additional Notes -->
|
|
<div class="mb-3">
|
|
<label for="deletion_notes" class="form-label">Additional Notes</label>
|
|
<textarea class="form-control" id="deletion_notes" name="deletion_notes" rows="3"
|
|
placeholder="Provide additional details about the deletion..."></textarea>
|
|
<div class="form-text">These notes will be recorded in the audit log.</div>
|
|
</div>
|
|
|
|
<!-- Controlled Substance Confirmation -->
|
|
{% if object.is_controlled %}
|
|
<div class="mb-3">
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" id="controlled_confirmation" name="controlled_confirmation" required>
|
|
<label class="form-check-label" for="controlled_confirmation">
|
|
<i class="fa fa-shield text-warning me-1"></i>
|
|
I acknowledge that this controlled substance prescription deletion will be reported for DEA compliance
|
|
</label>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Final Confirmation -->
|
|
<div class="mb-4">
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" id="final_confirmation" name="final_confirmation" required>
|
|
<label class="form-check-label" for="final_confirmation">
|
|
<strong>I understand that this action cannot be undone and confirm the deletion of this prescription</strong>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Form Actions -->
|
|
<div class="d-flex justify-content-between">
|
|
<div>
|
|
<a href="{% url 'pharmacy:prescription_detail' object.pk %}" class="btn btn-secondary">
|
|
<i class="fa fa-arrow-left me-2"></i>Cancel
|
|
</a>
|
|
</div>
|
|
<div>
|
|
<button type="submit" class="btn btn-danger" id="delete-btn" disabled>
|
|
<i class="fa fa-trash me-2"></i>Delete Prescription
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<!-- END panel -->
|
|
</div>
|
|
|
|
<div class="col-xl-4">
|
|
<!-- BEGIN panel -->
|
|
<div class="panel panel-inverse">
|
|
<div class="panel-heading">
|
|
<h4 class="panel-title">Deletion Guidelines</h4>
|
|
</div>
|
|
<div class="panel-body">
|
|
<div class="alert alert-warning">
|
|
<h6 class="alert-heading">Important Guidelines</h6>
|
|
<ul class="mb-0 small">
|
|
<li>Prescription deletions are permanent and cannot be undone</li>
|
|
<li>All deletions are logged for audit purposes</li>
|
|
<li>Consider alternatives before deleting</li>
|
|
<li>Controlled substances require special documentation</li>
|
|
<li>Dispensed prescriptions should rarely be deleted</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="card border-info">
|
|
<div class="card-header bg-info text-white">
|
|
<h6 class="card-title mb-0">Audit Information</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="small">
|
|
<div><strong>User:</strong> {{ request.user.get_full_name }}</div>
|
|
<div><strong>Date:</strong> {{ "now"|date:"M d, Y H:i" }}</div>
|
|
<div><strong>IP Address:</strong> {{ request.META.REMOTE_ADDR }}</div>
|
|
<div><strong>Session:</strong> {{ request.session.session_key|slice:":8" }}...</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- END panel -->
|
|
|
|
<!-- BEGIN panel -->
|
|
<div class="panel panel-inverse">
|
|
<div class="panel-heading">
|
|
<h4 class="panel-title">Related Records</h4>
|
|
</div>
|
|
<div class="panel-body">
|
|
<div class="list-group list-group-flush">
|
|
<div class="list-group-item d-flex justify-content-between align-items-center">
|
|
Patient Records
|
|
<span class="badge bg-primary rounded-pill">{{ object.patient.prescriptions.count }}</span>
|
|
</div>
|
|
{% if object.dispensing_records.exists %}
|
|
<div class="list-group-item d-flex justify-content-between align-items-center">
|
|
Dispensing Records
|
|
<span class="badge bg-success rounded-pill">{{ object.dispensing_records.count }}</span>
|
|
</div>
|
|
{% endif %}
|
|
{% if object.interaction_checks.exists %}
|
|
<div class="list-group-item d-flex justify-content-between align-items-center">
|
|
Interaction Checks
|
|
<span class="badge bg-warning rounded-pill">{{ object.interaction_checks.count }}</span>
|
|
</div>
|
|
{% endif %}
|
|
<div class="list-group-item d-flex justify-content-between align-items-center">
|
|
Refills Remaining
|
|
<span class="badge bg-info rounded-pill">{{ object.refills_remaining }}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- END panel -->
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block js %}
|
|
<script>
|
|
$(document).ready(function() {
|
|
// Enable delete button only when all confirmations are checked
|
|
function checkConfirmations() {
|
|
var finalConfirmed = $('#final_confirmation').is(':checked');
|
|
var controlledConfirmed = true;
|
|
|
|
{% if object.is_controlled %}
|
|
controlledConfirmed = $('#controlled_confirmation').is(':checked');
|
|
{% endif %}
|
|
|
|
var reasonSelected = $('#deletion_reason').val() !== '';
|
|
|
|
if (finalConfirmed && controlledConfirmed && reasonSelected) {
|
|
$('#delete-btn').prop('disabled', false);
|
|
} else {
|
|
$('#delete-btn').prop('disabled', true);
|
|
}
|
|
}
|
|
|
|
// Check confirmations on change
|
|
$('#final_confirmation, #controlled_confirmation, #deletion_reason').on('change', checkConfirmations);
|
|
|
|
// Form submission confirmation
|
|
$('#delete-form').on('submit', function(e) {
|
|
var reason = $('#deletion_reason').val();
|
|
var notes = $('#deletion_notes').val();
|
|
|
|
if (reason === 'other' && !notes.trim()) {
|
|
e.preventDefault();
|
|
toastr.error('Please provide additional details when selecting "Other" as the reason.');
|
|
$('#deletion_notes').focus();
|
|
return false;
|
|
}
|
|
|
|
// Final confirmation dialog
|
|
if (!confirm('Are you absolutely sure you want to delete this prescription? This action cannot be undone.')) {
|
|
e.preventDefault();
|
|
return false;
|
|
}
|
|
|
|
// Show loading state
|
|
$('#delete-btn').prop('disabled', true).html('<i class="fa fa-spinner fa-spin me-2"></i>Deleting...');
|
|
|
|
return true;
|
|
});
|
|
|
|
// Reason change handler
|
|
$('#deletion_reason').on('change', function() {
|
|
if ($(this).val() === 'other') {
|
|
$('#deletion_notes').prop('required', true);
|
|
$('#deletion_notes').closest('.mb-3').find('.form-text').text('Required when "Other" is selected.');
|
|
} else {
|
|
$('#deletion_notes').prop('required', false);
|
|
$('#deletion_notes').closest('.mb-3').find('.form-text').text('These notes will be recorded in the audit log.');
|
|
}
|
|
checkConfirmations();
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %}
|
|
|