155 lines
7.2 KiB
HTML
155 lines
7.2 KiB
HTML
{% load static %}
|
|
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">Update Bed Status</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<form id="updateBedStatusForm" method="post" action="{% url 'inpatients:update_bed_status' bed_id=bed.id %}">
|
|
{% csrf_token %}
|
|
|
|
<div class="bed-info mb-3">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<p><strong>Ward:</strong> {{ bed.ward.name }}</p>
|
|
<p><strong>Room:</strong> {{ bed.room_number }}</p>
|
|
<p><strong>Bed:</strong> {{ bed.bed_number }}</p>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<p><strong>Current Status:</strong>
|
|
<span class="badge bg-{{ bed.status|lower }}">
|
|
{{ bed.get_status_display }}
|
|
</span>
|
|
</p>
|
|
<p><strong>Bed Type:</strong> {{ bed.get_bed_type_display }}</p>
|
|
<p><strong>Room Type:</strong> {{ bed.get_room_type_display }}</p>
|
|
</div>
|
|
</div>
|
|
|
|
{% if bed.current_patient %}
|
|
<div class="alert alert-warning mt-2 mb-0">
|
|
<i class="fa fa-exclamation-triangle"></i> This bed is currently occupied by <strong>{{ bed.current_patient.get_full_name }}</strong>.
|
|
Changing the status will affect the patient's admission.
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="status" class="form-label">New Status <span class="text-danger">*</span></label>
|
|
<select class="form-select" id="status" name="status" required>
|
|
<option value="">Select new status</option>
|
|
{% for status_code, status_name in statuses %}
|
|
<option value="{{ status_code }}" {% if bed.status == status_code %}disabled{% endif %}>
|
|
{{ status_name }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
|
|
<div class="status-info mb-3" id="status-info-container" style="display: none;">
|
|
<div class="alert alert-info">
|
|
<div id="available-info" class="status-info-content" style="display: none;">
|
|
<h6><i class="fa fa-check-circle"></i> Available</h6>
|
|
<p>This bed will be marked as ready for patient assignment. If the bed was previously in cleaning status, the cleaning timestamp will be updated.</p>
|
|
</div>
|
|
|
|
<div id="occupied-info" class="status-info-content" style="display: none;">
|
|
<h6><i class="fa fa-user"></i> Occupied</h6>
|
|
<p>This status is automatically set when a patient is assigned to the bed. You should not manually set this status.</p>
|
|
</div>
|
|
|
|
<div id="reserved-info" class="status-info-content" style="display: none;">
|
|
<h6><i class="fa fa-bookmark"></i> Reserved</h6>
|
|
<p>This bed will be marked as reserved for an upcoming admission. It will not be available for other patients.</p>
|
|
</div>
|
|
|
|
<div id="cleaning-info" class="status-info-content" style="display: none;">
|
|
<h6><i class="fa fa-broom"></i> Cleaning</h6>
|
|
<p>This bed will be marked as currently being cleaned. Once cleaning is complete, update the status to Available.</p>
|
|
</div>
|
|
|
|
<div id="maintenance-info" class="status-info-content" style="display: none;">
|
|
<h6><i class="fa fa-tools"></i> Maintenance</h6>
|
|
<p>This bed will be marked as undergoing maintenance or repairs. The maintenance timestamp will be updated.</p>
|
|
</div>
|
|
|
|
<div id="blocked-info" class="status-info-content" style="display: none;">
|
|
<h6><i class="fa fa-ban"></i> Blocked</h6>
|
|
<p>This bed will be marked as temporarily unavailable for assignment. Please provide a reason in the notes field.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="notes" class="form-label">Notes</label>
|
|
<textarea class="form-control" id="notes" name="notes" rows="3" placeholder="Enter any additional information about this status change"></textarea>
|
|
<div class="form-text">Please provide details about why you're changing the status.</div>
|
|
</div>
|
|
|
|
{% if bed.current_patient and bed.status == 'OCCUPIED' %}
|
|
<div class="alert alert-danger">
|
|
<i class="fa fa-exclamation-circle"></i> <strong>Warning:</strong> This bed is currently occupied by a patient.
|
|
Changing the status will affect the patient's admission. You should transfer the patient to another bed first.
|
|
</div>
|
|
{% endif %}
|
|
</form>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
|
<button type="submit" form="updateBedStatusForm" class="btn btn-primary">
|
|
<i class="fa fa-save"></i> Update Status
|
|
</button>
|
|
</div>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
// Show status info when status is selected
|
|
$('#status').change(function() {
|
|
// Hide all status info
|
|
$('.status-info-content').hide();
|
|
|
|
// Show the selected one
|
|
var selectedStatus = $(this).val().toLowerCase();
|
|
if (selectedStatus) {
|
|
$('#status-info-container').show();
|
|
$('#' + selectedStatus + '-info').show();
|
|
} else {
|
|
$('#status-info-container').hide();
|
|
}
|
|
|
|
// Make notes required for certain statuses
|
|
if (selectedStatus === 'blocked' || selectedStatus === 'maintenance') {
|
|
$('#notes').attr('required', true);
|
|
$('#notes').closest('.mb-3').find('.form-text').html('<span class="text-danger">Required for this status change.</span>');
|
|
} else {
|
|
$('#notes').removeAttr('required');
|
|
$('#notes').closest('.mb-3').find('.form-text').html('Please provide details about why you\'re changing the status.');
|
|
}
|
|
});
|
|
|
|
// Form validation
|
|
$('#updateBedStatusForm').submit(function(e) {
|
|
var status = $('#status').val();
|
|
var notes = $('#notes').val();
|
|
|
|
if (!status) {
|
|
e.preventDefault();
|
|
alert('Please select a new status.');
|
|
return false;
|
|
}
|
|
|
|
{% if bed.current_patient and bed.status == 'OCCUPIED' %}
|
|
if (confirm('Warning: This bed is currently occupied by a patient. Are you sure you want to change the status?')) {
|
|
return true;
|
|
} else {
|
|
e.preventDefault();
|
|
return false;
|
|
}
|
|
{% endif %}
|
|
|
|
return true;
|
|
});
|
|
});
|
|
</script>
|
|
|