418 lines
21 KiB
HTML
418 lines
21 KiB
HTML
{% extends "base.html" %}
|
|
{% load static %}
|
|
|
|
{% block title %}Delete Lab Result{% 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:lab_result_list' %}">Results</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'laboratory:lab_result_detail' object.pk %}">Result #{{ object.pk }}</a></li>
|
|
<li class="breadcrumb-item active">Delete</li>
|
|
</ol>
|
|
<h1 class="page-header mb-0">Delete Lab Result</h1>
|
|
</div>
|
|
<div class="ms-auto">
|
|
<a href="{% url 'laboratory:lab_result_detail' object.pk %}" class="btn btn-secondary">
|
|
<i class="fas fa-arrow-left me-2"></i>Back to Result
|
|
</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 Lab Result 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 lab result?
|
|
</h5>
|
|
<p class="mb-0">
|
|
This action cannot be undone. The lab result and all associated data will be permanently removed from the system.
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Result 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.order.patient.get_full_name }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>MRN:</strong> {{ object.order.patient.medical_record_number }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>DOB:</strong> {{ object.order.patient.date_of_birth|date:"M d, Y" }}
|
|
</div>
|
|
<div>
|
|
<strong>Age:</strong> {{ object.order.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-flask me-2"></i>Test Information
|
|
</h6>
|
|
<div class="mb-2">
|
|
<strong>Test:</strong> {{ object.test.name }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Result:</strong>
|
|
<span class="fw-bold {% if object.abnormal_flag %}text-warning{% else %}text-success{% endif %}">
|
|
{{ object.result_value }} {{ object.unit|default:"" }}
|
|
</span>
|
|
{% if object.abnormal_flag %}
|
|
<span class="badge bg-warning ms-2">{{ object.get_abnormal_flag_display }}</span>
|
|
{% endif %}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Reference Range:</strong> {{ object.reference_range|default:"Not specified" }}
|
|
</div>
|
|
<div>
|
|
<strong>Status:</strong>
|
|
<span class="badge bg-{% if object.status == 'final' %}success{% elif object.status == 'preliminary' %}warning{% else %}info{% endif %}">
|
|
{{ object.get_status_display }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Order 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-list me-2"></i>Order Information
|
|
</h6>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="mb-2">
|
|
<strong>Order ID:</strong> {{ object.order.pk }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Ordered Date:</strong> {{ object.order.ordered_date|date:"M d, Y g:i A" }}
|
|
</div>
|
|
<div>
|
|
<strong>Ordering Physician:</strong> {{ object.order.ordering_physician.get_full_name }}
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="mb-2">
|
|
<strong>Priority:</strong> {{ object.order.get_priority_display }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Department:</strong> {{ object.order.department.name }}
|
|
</div>
|
|
<div>
|
|
<strong>Clinical Notes:</strong> {{ object.order.clinical_notes|truncatewords:10|default:"None" }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Performance 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-user-md me-2"></i>Performance Information
|
|
</h6>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="mb-2">
|
|
<strong>Performed By:</strong> {{ object.performed_by.get_full_name }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Performed Date:</strong> {{ object.performed_at|date:"M d, Y g:i A" }}
|
|
</div>
|
|
{% if object.verified_by %}
|
|
<div>
|
|
<strong>Verified By:</strong> {{ object.verified_by.get_full_name }}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
<div class="col-md-6">
|
|
{% if object.verified_at %}
|
|
<div class="mb-2">
|
|
<strong>Verified Date:</strong> {{ object.verified_at|date:"M d, Y g:i A" }}
|
|
</div>
|
|
{% endif %}
|
|
<div class="mb-2">
|
|
<strong>Result ID:</strong> {{ object.pk }}
|
|
</div>
|
|
<div>
|
|
<strong>Created:</strong> {{ object.created_at|date:"M d, Y g:i A" }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{% if object.comments %}
|
|
<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>Comments
|
|
</h6>
|
|
<div class="alert alert-info mb-0">
|
|
{{ object.comments }}
|
|
</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="erroneous_result">Erroneous Result</option>
|
|
<option value="sample_contamination">Sample Contamination</option>
|
|
<option value="equipment_malfunction">Equipment Malfunction</option>
|
|
<option value="data_entry_error">Data Entry Error</option>
|
|
<option value="duplicate_result">Duplicate Result</option>
|
|
<option value="patient_request">Patient Request</option>
|
|
<option value="physician_request">Physician Request</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 lab result is being deleted..."></textarea>
|
|
<div class="form-text">
|
|
These notes will be recorded for audit purposes and quality assurance.
|
|
</div>
|
|
</div>
|
|
|
|
<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 lab result.
|
|
</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 result deletion.
|
|
</label>
|
|
</div>
|
|
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input"
|
|
type="checkbox"
|
|
id="reorder_test"
|
|
name="reorder_test">
|
|
<label class="form-check-label" for="reorder_test">
|
|
Automatically reorder this test if sample is still available.
|
|
</label>
|
|
</div>
|
|
|
|
<div class="alert alert-info">
|
|
<h6 class="alert-heading">
|
|
<i class="fas fa-info-circle me-2"></i>What happens when you delete this lab result?
|
|
</h6>
|
|
<ul class="mb-0">
|
|
<li>The lab result will be permanently removed from the system</li>
|
|
<li>The associated lab order status may be updated to "pending"</li>
|
|
<li>Patient reports and medical records will be affected</li>
|
|
<li>Quality metrics and laboratory statistics will be updated</li>
|
|
<li>This action will be logged in the audit trail</li>
|
|
<li>Billing records may need manual adjustment</li>
|
|
<li>Clinical decision support alerts may be triggered</li>
|
|
<li>The ordering physician may need to be notified</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="d-flex justify-content-between">
|
|
<a href="{% url 'laboratory:lab_result_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 Lab Result
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Critical Result Warning -->
|
|
{% if object.abnormal_flag in 'HH,LL' %}
|
|
<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>
|
|
Critical Result Warning
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="alert alert-warning">
|
|
<strong>Critical Result:</strong> This result has been flagged as critical ({{ object.get_abnormal_flag_display }}).
|
|
Deleting critical results requires additional documentation and may trigger quality review processes.
|
|
</div>
|
|
|
|
<div class="alert alert-info">
|
|
<strong>Recommendation:</strong> Consider correcting the result instead of deleting it,
|
|
or ensure proper documentation of the deletion reason for regulatory compliance.
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Verified Result Warning -->
|
|
{% if object.verified_by %}
|
|
<div class="card mt-4">
|
|
<div class="card-header bg-info text-white">
|
|
<h5 class="card-title mb-0">
|
|
<i class="fas fa-check-circle me-2"></i>
|
|
Verified Result Notice
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="alert alert-info">
|
|
<strong>Verified Result:</strong> This result has been verified by {{ object.verified_by.get_full_name }}
|
|
on {{ object.verified_at|date:"M d, Y g:i A" }}. Deleting verified results may require additional approvals.
|
|
</div>
|
|
|
|
{% if object.status == 'final' %}
|
|
<div class="alert alert-warning">
|
|
<strong>Final Result:</strong> This result has final status and may have been included in patient reports
|
|
or used for clinical decisions. Consider the impact 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>Result Details</h6>
|
|
<ul class="list-unstyled">
|
|
<li><strong>Result ID:</strong> {{ object.pk }}</li>
|
|
<li><strong>Test Code:</strong> {{ object.test.code|default:"N/A" }}</li>
|
|
<li><strong>LOINC Code:</strong> {{ object.test.loinc_code|default:"N/A" }}</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>Order ID:</strong> {{ object.order.pk }}</li>
|
|
<li><strong>Patient ID:</strong> {{ object.order.patient.pk }}</li>
|
|
<li><strong>Test ID:</strong> {{ object.test.pk }}</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;
|
|
}
|
|
|
|
const resultId = "{{ object.pk }}";
|
|
const testName = "{{ object.test.name }}";
|
|
const patientName = "{{ object.order.patient.get_full_name }}";
|
|
const resultValue = "{{ object.result_value }} {{ object.unit|default:'' }}";
|
|
|
|
const message = `Are you absolutely sure you want to delete this lab result?\n\nPatient: ${patientName}\nTest: ${testName}\nResult: ${resultValue}\nResult ID: ${resultId}\n\nThis 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 lab result is being deleted...';
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %}
|
|
|