471 lines
24 KiB
HTML
471 lines
24 KiB
HTML
{% extends "base.html" %}
|
|
{% load static %}
|
|
|
|
{% block title %}Delete Specimen{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="d-flex align-items-center mb-3">
|
|
<div>
|
|
<ol class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="{% url 'laboratory:dashboard' %}">Laboratory</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'laboratory:specimen_list' %}">Specimens</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'laboratory:specimen_detail' object.pk %}">{{ object.specimen_id }}</a></li>
|
|
<li class="breadcrumb-item active">Delete</li>
|
|
</ol>
|
|
<h1 class="page-header mb-0">Delete Specimen</h1>
|
|
</div>
|
|
<div class="ms-auto">
|
|
<a href="{% url 'laboratory:specimen_detail' object.pk %}" class="btn btn-secondary">
|
|
<i class="fas fa-arrow-left me-2"></i>Back to Specimen
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row justify-content-center">
|
|
<div class="col-xl-8">
|
|
<div class="card">
|
|
<div class="card-header bg-danger text-white">
|
|
<h4 class="card-title mb-0">
|
|
<i class="fas fa-exclamation-triangle me-2"></i>
|
|
Confirm Specimen Deletion
|
|
</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="alert alert-warning">
|
|
<h5 class="alert-heading">
|
|
<i class="fas fa-exclamation-triangle me-2"></i>
|
|
Are you sure you want to delete this specimen?
|
|
</h5>
|
|
<p class="mb-0">
|
|
This action cannot be undone. The specimen and all associated data will be permanently removed from the system.
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Specimen Details -->
|
|
<div class="row mb-4">
|
|
<div class="col-md-6">
|
|
<div class="card bg-light">
|
|
<div class="card-body">
|
|
<h6 class="card-title">
|
|
<i class="fas fa-user-injured me-2"></i>Patient Information
|
|
</h6>
|
|
<div class="mb-2">
|
|
<strong>Patient:</strong> {{ object.patient.get_full_name }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>MRN:</strong> {{ object.patient.medical_record_number }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>DOB:</strong> {{ object.patient.date_of_birth|date:"M d, Y" }}
|
|
</div>
|
|
<div>
|
|
<strong>Age:</strong> {{ object.patient.age }} years
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="card bg-light">
|
|
<div class="card-body">
|
|
<h6 class="card-title">
|
|
<i class="fas fa-vial me-2"></i>Specimen Information
|
|
</h6>
|
|
<div class="mb-2">
|
|
<strong>Specimen ID:</strong> {{ object.specimen_id }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Type:</strong> {{ object.get_specimen_type_display }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Collection Date:</strong> {{ object.collection_date|date:"M d, Y g:i A" }}
|
|
</div>
|
|
<div>
|
|
<strong>Status:</strong>
|
|
<span class="badge bg-{% if object.status == 'collected' %}success{% elif object.status == 'processing' %}warning{% elif object.status == 'completed' %}info{% elif object.status == 'rejected' %}danger{% else %}secondary{% endif %}">
|
|
{{ object.get_status_display }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Collection Information -->
|
|
<div class="row mb-4">
|
|
<div class="col-12">
|
|
<div class="card bg-light">
|
|
<div class="card-body">
|
|
<h6 class="card-title">
|
|
<i class="fas fa-clipboard-check me-2"></i>Collection Information
|
|
</h6>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="mb-2">
|
|
<strong>Collected By:</strong> {{ object.collected_by.get_full_name }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Collection Site:</strong> {{ object.collection_site|default:"Not specified" }}
|
|
</div>
|
|
<div>
|
|
<strong>Volume:</strong> {{ object.volume|default:"Not specified" }}
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="mb-2">
|
|
<strong>Container:</strong> {{ object.container_type|default:"Standard" }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Priority:</strong> {{ object.get_priority_display }}
|
|
</div>
|
|
<div>
|
|
<strong>Condition:</strong> {{ object.condition|default:"Good" }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Associated Tests Warning -->
|
|
{% if associated_tests %}
|
|
<div class="row mb-4">
|
|
<div class="col-12">
|
|
<div class="card border-warning">
|
|
<div class="card-header bg-warning text-dark">
|
|
<h6 class="card-title mb-0">
|
|
<i class="fas fa-exclamation-triangle me-2"></i>
|
|
Associated Tests Warning
|
|
</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="alert alert-warning">
|
|
<strong>Warning:</strong> This specimen has {{ associated_tests|length }} associated test(s).
|
|
Deleting this specimen will affect these tests and may impact patient care.
|
|
</div>
|
|
|
|
<div class="table-responsive">
|
|
<table class="table table-sm">
|
|
<thead>
|
|
<tr>
|
|
<th>Test Name</th>
|
|
<th>Status</th>
|
|
<th>Ordered Date</th>
|
|
<th>Result Status</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for test in associated_tests %}
|
|
<tr>
|
|
<td>{{ test.test.name }}</td>
|
|
<td>
|
|
<span class="badge bg-{% if test.status == 'completed' %}success{% elif test.status == 'in_progress' %}warning{% else %}info{% endif %}">
|
|
{{ test.get_status_display }}
|
|
</span>
|
|
</td>
|
|
<td>{{ test.ordered_date|date:"M d, Y" }}</td>
|
|
<td>
|
|
{% if test.result %}
|
|
<span class="badge bg-success">Result Available</span>
|
|
{% else %}
|
|
<span class="badge bg-secondary">Pending</span>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Collection Notes -->
|
|
{% if object.collection_notes %}
|
|
<div class="row mb-4">
|
|
<div class="col-12">
|
|
<div class="card bg-light">
|
|
<div class="card-body">
|
|
<h6 class="card-title">
|
|
<i class="fas fa-comment me-2"></i>Collection Notes
|
|
</h6>
|
|
<div class="alert alert-info mb-0">
|
|
{{ object.collection_notes }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Deletion Form -->
|
|
<form method="post">
|
|
{% csrf_token %}
|
|
|
|
<div class="mb-3">
|
|
<label for="deletion_reason" class="form-label">
|
|
<strong>Reason for Deletion *</strong>
|
|
</label>
|
|
<select class="form-select" id="deletion_reason" name="deletion_reason" required>
|
|
<option value="">Select a reason</option>
|
|
<option value="collection_error">Collection Error</option>
|
|
<option value="insufficient_volume">Insufficient Volume</option>
|
|
<option value="contaminated">Contaminated Sample</option>
|
|
<option value="hemolyzed">Hemolyzed Sample</option>
|
|
<option value="clotted">Clotted Sample</option>
|
|
<option value="expired">Expired Sample</option>
|
|
<option value="patient_request">Patient Request</option>
|
|
<option value="physician_request">Physician Request</option>
|
|
<option value="duplicate_collection">Duplicate Collection</option>
|
|
<option value="wrong_patient">Wrong Patient</option>
|
|
<option value="quality_control">Quality Control Issue</option>
|
|
<option value="regulatory_compliance">Regulatory Compliance</option>
|
|
<option value="other">Other</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="deletion_notes" class="form-label">
|
|
<strong>Additional Notes</strong>
|
|
</label>
|
|
<textarea class="form-control"
|
|
id="deletion_notes"
|
|
name="deletion_notes"
|
|
rows="3"
|
|
placeholder="Provide additional details about why this specimen is being deleted..."></textarea>
|
|
<div class="form-text">
|
|
These notes will be recorded for audit purposes and quality assurance.
|
|
</div>
|
|
</div>
|
|
|
|
{% if associated_tests %}
|
|
<div class="mb-3">
|
|
<label for="test_action" class="form-label">
|
|
<strong>Action for Associated Tests *</strong>
|
|
</label>
|
|
<select class="form-select" id="test_action" name="test_action" required>
|
|
<option value="">Select action</option>
|
|
<option value="cancel_tests">Cancel all associated tests</option>
|
|
<option value="request_recollection">Request specimen recollection</option>
|
|
<option value="transfer_to_existing">Transfer tests to existing specimen</option>
|
|
<option value="manual_review">Require manual review</option>
|
|
</select>
|
|
<div class="form-text">
|
|
Choose what should happen to the {{ associated_tests|length }} associated test(s).
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input"
|
|
type="checkbox"
|
|
id="confirm_deletion"
|
|
name="confirm_deletion"
|
|
required>
|
|
<label class="form-check-label" for="confirm_deletion">
|
|
I understand that this action cannot be undone and confirm the deletion of this specimen.
|
|
</label>
|
|
</div>
|
|
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input"
|
|
type="checkbox"
|
|
id="notify_staff"
|
|
name="notify_staff">
|
|
<label class="form-check-label" for="notify_staff">
|
|
Notify relevant laboratory staff about this specimen deletion.
|
|
</label>
|
|
</div>
|
|
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input"
|
|
type="checkbox"
|
|
id="notify_physician"
|
|
name="notify_physician">
|
|
<label class="form-check-label" for="notify_physician">
|
|
Notify the ordering physician about this specimen deletion.
|
|
</label>
|
|
</div>
|
|
|
|
{% if object.status in 'processing,completed' %}
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input"
|
|
type="checkbox"
|
|
id="quality_review"
|
|
name="quality_review">
|
|
<label class="form-check-label" for="quality_review">
|
|
Trigger quality assurance review for this deletion.
|
|
</label>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="alert alert-info">
|
|
<h6 class="alert-heading">
|
|
<i class="fas fa-info-circle me-2"></i>What happens when you delete this specimen?
|
|
</h6>
|
|
<ul class="mb-0">
|
|
<li>The specimen record will be permanently removed from the system</li>
|
|
<li>All tracking history and collection data will be lost</li>
|
|
{% if associated_tests %}
|
|
<li>Associated tests will be affected based on your selection above</li>
|
|
<li>Test results may need to be invalidated or transferred</li>
|
|
{% endif %}
|
|
<li>Quality metrics and laboratory statistics will be updated</li>
|
|
<li>This action will be logged in the audit trail</li>
|
|
<li>Inventory tracking may be affected if containers are tracked</li>
|
|
<li>Billing records may need manual adjustment</li>
|
|
<li>Patient reports and medical records may be impacted</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="d-flex justify-content-between">
|
|
<a href="{% url 'laboratory:specimen_detail' object.pk %}" class="btn btn-secondary">
|
|
<i class="fas fa-times me-2"></i>Cancel
|
|
</a>
|
|
<button type="submit" class="btn btn-danger" onclick="return confirmDeletion()">
|
|
<i class="fas fa-trash me-2"></i>Delete Specimen
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Quality Control Warning -->
|
|
{% if object.condition in 'hemolyzed,clotted,contaminated,rejected' %}
|
|
<div class="card mt-4">
|
|
<div class="card-header bg-warning text-dark">
|
|
<h5 class="card-title mb-0">
|
|
<i class="fas fa-exclamation-triangle me-2"></i>
|
|
Quality Control Notice
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="alert alert-warning">
|
|
<strong>Quality Issue:</strong> This specimen has been flagged with condition: {{ object.condition }}.
|
|
Deleting specimens with quality issues may require additional documentation for compliance.
|
|
</div>
|
|
|
|
<div class="alert alert-info">
|
|
<strong>Recommendation:</strong> Consider documenting the quality issue in the laboratory quality
|
|
management system before deletion to maintain proper quality records.
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Processing Status Warning -->
|
|
{% if object.status in 'processing,completed' %}
|
|
<div class="card mt-4">
|
|
<div class="card-header bg-info text-white">
|
|
<h5 class="card-title mb-0">
|
|
<i class="fas fa-cog me-2"></i>
|
|
Processing Status Notice
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="alert alert-info">
|
|
<strong>Processing Status:</strong> This specimen has status "{{ object.get_status_display }}"
|
|
and may have been processed or analyzed. Deleting processed specimens may require supervisor approval.
|
|
</div>
|
|
|
|
{% if object.status == 'completed' %}
|
|
<div class="alert alert-warning">
|
|
<strong>Completed Specimen:</strong> This specimen has been marked as completed and may have
|
|
results associated with it. Consider the impact on patient care before deletion.
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Related Information -->
|
|
<div class="card mt-4">
|
|
<div class="card-header">
|
|
<h5 class="card-title">
|
|
<i class="fas fa-link me-2"></i>
|
|
Related Information
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<h6>Specimen Details</h6>
|
|
<ul class="list-unstyled">
|
|
<li><strong>Specimen ID:</strong> {{ object.specimen_id }}</li>
|
|
<li><strong>Internal ID:</strong> {{ object.pk }}</li>
|
|
<li><strong>Barcode:</strong> {{ object.barcode|default:"Not assigned" }}</li>
|
|
<li><strong>Created:</strong> {{ object.created_at|date:"M d, Y g:i A" }}</li>
|
|
</ul>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<h6>System Information</h6>
|
|
<ul class="list-unstyled">
|
|
<li><strong>Patient ID:</strong> {{ object.patient.pk }}</li>
|
|
<li><strong>Collector ID:</strong> {{ object.collected_by.pk }}</li>
|
|
<li><strong>Current Location:</strong> {{ object.current_location|default:"Lab" }}</li>
|
|
<li><strong>Last Updated:</strong> {{ object.updated_at|date:"M d, Y g:i A" }}</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function confirmDeletion() {
|
|
const reason = document.getElementById('deletion_reason').value;
|
|
const confirmed = document.getElementById('confirm_deletion').checked;
|
|
|
|
if (!reason) {
|
|
alert('Please select a reason for deletion.');
|
|
return false;
|
|
}
|
|
|
|
if (!confirmed) {
|
|
alert('Please confirm that you understand this action cannot be undone.');
|
|
return false;
|
|
}
|
|
|
|
{% if associated_tests %}
|
|
const testAction = document.getElementById('test_action').value;
|
|
if (!testAction) {
|
|
alert('Please select an action for the associated tests.');
|
|
return false;
|
|
}
|
|
{% endif %}
|
|
|
|
const specimenId = "{{ object.specimen_id }}";
|
|
const patientName = "{{ object.patient.get_full_name }}";
|
|
const specimenType = "{{ object.get_specimen_type_display }}";
|
|
const collectionDate = "{{ object.collection_date|date:'M d, Y g:i A' }}";
|
|
|
|
const message = `Are you absolutely sure you want to delete this specimen?\n\nPatient: ${patientName}\nSpecimen: ${specimenType}\nID: ${specimenId}\nCollected: ${collectionDate}\n\n{% if associated_tests %}This will affect {{ associated_tests|length }} associated test(s).\n\n{% endif %}This action cannot be undone and may affect patient care and reporting.`;
|
|
|
|
return confirm(message);
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// Auto-focus on deletion reason
|
|
document.getElementById('deletion_reason').focus();
|
|
|
|
// Show/hide additional notes based on reason
|
|
const reasonSelect = document.getElementById('deletion_reason');
|
|
const notesTextarea = document.getElementById('deletion_notes');
|
|
|
|
reasonSelect.addEventListener('change', function() {
|
|
if (this.value === 'other') {
|
|
notesTextarea.required = true;
|
|
notesTextarea.placeholder = 'Please specify the reason for deletion...';
|
|
} else {
|
|
notesTextarea.required = false;
|
|
notesTextarea.placeholder = 'Provide additional details about why this specimen is being deleted...';
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %}
|
|
|