492 lines
25 KiB
HTML
492 lines
25 KiB
HTML
{% extends "base.html" %}
|
|
{% load static %}
|
|
|
|
{% block title %}Delete Medication - 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:medication_list' %}">Medications</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'pharmacy:medication_detail' object.pk %}">{{ object.name }}</a></li>
|
|
<li class="breadcrumb-item active">Delete</li>
|
|
</ol>
|
|
<!-- END breadcrumb -->
|
|
|
|
<!-- BEGIN page-header -->
|
|
<h1 class="page-header">
|
|
Delete Medication
|
|
<small>{{ object.name }}</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 Medication 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">
|
|
<!-- Medication 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>Medication to be Deleted
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="mb-2"><strong>Generic Name:</strong> {{ object.generic_name }}</div>
|
|
<div class="mb-2"><strong>Brand Name:</strong> {{ object.brand_name|default:"Not specified" }}</div>
|
|
<div class="mb-2"><strong>Strength:</strong> {{ object.strength }}</div>
|
|
<div class="mb-2"><strong>Dosage Form:</strong> {{ object.get_dosage_form_display }}</div>
|
|
<div class="mb-2"><strong>Route:</strong> {{ object.get_route_display }}</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="mb-2"><strong>Manufacturer:</strong> {{ object.manufacturer|default:"Not specified" }}</div>
|
|
<div class="mb-2"><strong>NDC Number:</strong> {{ object.ndc_number|default:"Not specified" }}</div>
|
|
<div class="mb-2"><strong>Category:</strong> {{ object.get_category_display }}</div>
|
|
<div class="mb-2"><strong>Status:</strong>
|
|
{% if object.is_active %}
|
|
<span class="badge bg-success">Active</span>
|
|
{% else %}
|
|
<span class="badge bg-secondary">Inactive</span>
|
|
{% endif %}
|
|
</div>
|
|
<div class="mb-2">
|
|
{% if object.is_controlled %}
|
|
<span class="badge bg-warning text-dark">
|
|
<i class="fa fa-shield me-1"></i>Controlled Substance - Schedule {{ object.controlled_schedule }}
|
|
</span>
|
|
{% endif %}
|
|
{% if object.is_high_alert %}
|
|
<span class="badge bg-danger">
|
|
<i class="fa fa-exclamation-triangle me-1"></i>High Alert
|
|
</span>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</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.prescriptions.exists %}
|
|
<li><i class="fa fa-prescription text-danger me-2"></i>{{ object.prescriptions.count }} active prescription(s)</li>
|
|
{% endif %}
|
|
{% if object.inventory_items.exists %}
|
|
<li><i class="fa fa-boxes text-warning me-2"></i>{{ object.inventory_items.count }} inventory record(s)</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.is_high_alert %}
|
|
<li><i class="fa fa-exclamation-triangle text-danger me-2"></i>High alert medication</li>
|
|
{% endif %}
|
|
{% if object.is_active %}
|
|
<li><i class="fa fa-check text-info me-2"></i>Currently active in formulary</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-prescription me-2"></i>Prescriptions: {{ object.prescriptions.count }}</li>
|
|
<li><i class="fa fa-boxes me-2"></i>Inventory items: {{ object.inventory_items.count }}</li>
|
|
<li><i class="fa fa-pills me-2"></i>Dispensing records: {{ object.dispensing_records.count }}</li>
|
|
{% if object.drug_interactions.exists %}
|
|
<li><i class="fa fa-exclamation-triangle me-2"></i>Drug interactions: {{ object.drug_interactions.count }}</li>
|
|
{% endif %}
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Active Prescriptions Warning -->
|
|
{% if object.prescriptions.exists %}
|
|
<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 medication has {{ object.prescriptions.count }} active prescription(s). Deleting it may:</p>
|
|
<ul class="mb-2">
|
|
<li>Disrupt patient care and medication therapy</li>
|
|
<li>Create gaps in prescription history</li>
|
|
<li>Affect pharmacy workflow and dispensing</li>
|
|
<li>Impact insurance claims and billing</li>
|
|
<li>Remove important clinical documentation</li>
|
|
</ul>
|
|
<p class="mb-0"><strong>Consider marking as inactive instead of deleting.</strong></p>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Controlled Substance Warning -->
|
|
{% if 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 medication is a Schedule {{ object.controlled_schedule }} controlled substance. Deletion must be properly documented for DEA compliance and audit purposes.</p>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- High Alert Warning -->
|
|
{% if object.is_high_alert %}
|
|
<div class="alert alert-danger">
|
|
<h6 class="alert-heading">
|
|
<i class="fa fa-exclamation-triangle me-2"></i>High Alert Medication Warning
|
|
</h6>
|
|
<p class="mb-0">This is a high alert medication that requires special safety protocols. Deletion may affect safety procedures and clinical guidelines.</p>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Inventory Warning -->
|
|
{% if object.inventory_items.exists %}
|
|
<div class="alert alert-warning">
|
|
<h6 class="alert-heading">
|
|
<i class="fa fa-boxes me-2"></i>Inventory Warning
|
|
</h6>
|
|
<p class="mb-0">This medication has {{ object.inventory_items.count }} inventory record(s). Deleting the medication may affect inventory tracking and stock management.</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 medication, consider these alternatives:</p>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="d-grid gap-2">
|
|
<a href="{% url 'pharmacy:medication_deactivate' object.pk %}" class="btn btn-outline-warning">
|
|
<i class="fa fa-ban me-2"></i>Deactivate Medication
|
|
</a>
|
|
<a href="{% url 'pharmacy:medication_edit' object.pk %}" class="btn btn-outline-primary">
|
|
<i class="fa fa-edit me-2"></i>Edit Medication
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="d-grid gap-2">
|
|
<a href="{% url 'pharmacy:medication_discontinue' object.pk %}" class="btn btn-outline-secondary">
|
|
<i class="fa fa-stop me-2"></i>Discontinue
|
|
</a>
|
|
<a href="{% url 'pharmacy:medication_archive' object.pk %}" class="btn btn-outline-info">
|
|
<i class="fa fa-archive me-2"></i>Archive Medication
|
|
</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 medication entry</option>
|
|
<option value="error">Medication entered in error</option>
|
|
<option value="discontinued">Medication discontinued by manufacturer</option>
|
|
<option value="replaced">Replaced by newer formulation</option>
|
|
<option value="regulatory">Regulatory/FDA action</option>
|
|
<option value="formulary">Removed from formulary</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 deletion will be reported for DEA compliance
|
|
</label>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Active Prescriptions Confirmation -->
|
|
{% if object.prescriptions.exists %}
|
|
<div class="mb-3">
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" id="prescriptions_confirmation" name="prescriptions_confirmation" required>
|
|
<label class="form-check-label" for="prescriptions_confirmation">
|
|
<i class="fa fa-prescription text-danger me-1"></i>
|
|
I understand that deleting this medication will affect {{ object.prescriptions.count }} active prescription(s)
|
|
</label>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Inventory Confirmation -->
|
|
{% if object.inventory_items.exists %}
|
|
<div class="mb-3">
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" id="inventory_confirmation" name="inventory_confirmation" required>
|
|
<label class="form-check-label" for="inventory_confirmation">
|
|
<i class="fa fa-boxes text-warning me-1"></i>
|
|
I understand that deleting this medication will affect {{ object.inventory_items.count }} inventory record(s)
|
|
</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 medication</strong>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Form Actions -->
|
|
<div class="d-flex justify-content-between">
|
|
<div>
|
|
<a href="{% url 'pharmacy:medication_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 Medication
|
|
</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>Medication deletions are permanent and cannot be undone</li>
|
|
<li>All deletions are logged for audit purposes</li>
|
|
<li>Consider deactivation instead of deletion</li>
|
|
<li>Controlled substances require special documentation</li>
|
|
<li>Active prescriptions should be handled first</li>
|
|
<li>Inventory records may be affected</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">
|
|
Active Prescriptions
|
|
<span class="badge bg-primary rounded-pill">{{ object.prescriptions.count }}</span>
|
|
</div>
|
|
<div class="list-group-item d-flex justify-content-between align-items-center">
|
|
Inventory Records
|
|
<span class="badge bg-warning rounded-pill">{{ object.inventory_items.count }}</span>
|
|
</div>
|
|
<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>
|
|
{% if object.drug_interactions.exists %}
|
|
<div class="list-group-item d-flex justify-content-between align-items-center">
|
|
Drug Interactions
|
|
<span class="badge bg-danger rounded-pill">{{ object.drug_interactions.count }}</span>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- END panel -->
|
|
|
|
<!-- BEGIN panel -->
|
|
<div class="panel panel-inverse">
|
|
<div class="panel-heading">
|
|
<h4 class="panel-title">Medication Properties</h4>
|
|
</div>
|
|
<div class="panel-body">
|
|
<div class="d-flex flex-wrap gap-2">
|
|
{% if object.is_controlled %}
|
|
<span class="badge bg-warning text-dark">
|
|
<i class="fa fa-shield me-1"></i>Controlled - Schedule {{ object.controlled_schedule }}
|
|
</span>
|
|
{% endif %}
|
|
{% if object.is_high_alert %}
|
|
<span class="badge bg-danger">
|
|
<i class="fa fa-exclamation-triangle me-1"></i>High Alert
|
|
</span>
|
|
{% endif %}
|
|
{% if object.requires_refrigeration %}
|
|
<span class="badge bg-info">
|
|
<i class="fa fa-snowflake me-1"></i>Refrigeration Required
|
|
</span>
|
|
{% endif %}
|
|
{% if object.is_generic %}
|
|
<span class="badge bg-secondary">
|
|
<i class="fa fa-check me-1"></i>Generic Available
|
|
</span>
|
|
{% endif %}
|
|
{% if object.is_active %}
|
|
<span class="badge bg-success">
|
|
<i class="fa fa-check me-1"></i>Active
|
|
</span>
|
|
{% else %}
|
|
<span class="badge bg-secondary">
|
|
<i class="fa fa-ban me-1"></i>Inactive
|
|
</span>
|
|
{% endif %}
|
|
</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;
|
|
var prescriptionsConfirmed = true;
|
|
var inventoryConfirmed = true;
|
|
|
|
{% if object.is_controlled %}
|
|
controlledConfirmed = $('#controlled_confirmation').is(':checked');
|
|
{% endif %}
|
|
|
|
{% if object.prescriptions.exists %}
|
|
prescriptionsConfirmed = $('#prescriptions_confirmation').is(':checked');
|
|
{% endif %}
|
|
|
|
{% if object.inventory_items.exists %}
|
|
inventoryConfirmed = $('#inventory_confirmation').is(':checked');
|
|
{% endif %}
|
|
|
|
var reasonSelected = $('#deletion_reason').val() !== '';
|
|
|
|
if (finalConfirmed && controlledConfirmed && prescriptionsConfirmed && inventoryConfirmed && reasonSelected) {
|
|
$('#delete-btn').prop('disabled', false);
|
|
} else {
|
|
$('#delete-btn').prop('disabled', true);
|
|
}
|
|
}
|
|
|
|
// Check confirmations on change
|
|
$('#final_confirmation, #controlled_confirmation, #prescriptions_confirmation, #inventory_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
|
|
var confirmMessage = 'Are you absolutely sure you want to delete this medication?';
|
|
{% if object.prescriptions.exists %}
|
|
confirmMessage += '\n\nThis will affect {{ object.prescriptions.count }} active prescription(s).';
|
|
{% endif %}
|
|
{% if object.inventory_items.exists %}
|
|
confirmMessage += '\n\nThis will affect {{ object.inventory_items.count }} inventory record(s).';
|
|
{% endif %}
|
|
confirmMessage += '\n\nThis action cannot be undone.';
|
|
|
|
if (!confirm(confirmMessage)) {
|
|
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 %}
|
|
|