Spaces:
Sleeping
Sleeping
File size: 8,986 Bytes
6ea020b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | {% extends "base.html" %}
{% block title %}No Sample Holdings | LIS{% endblock %}
{% block content %}
<div class="bg-white rounded-xl shadow-sm border border-slate-200 overflow-hidden mt-6">
<div class="p-6 border-b border-slate-200 bg-slate-50 flex justify-between items-center">
<h2 class="text-xl font-bold text-slate-800">🚫 No Sample Holding Area</h2>
<span class="bg-red-100 text-red-800 text-sm px-3 py-1 rounded-full font-bold border border-red-200 shadow-sm">
{{ orders|length }} Missing Samples
</span>
</div>
<div class="overflow-x-auto">
<table class="w-full text-left border-collapse min-w-max">
<thead>
<tr class="bg-slate-100 border-b border-slate-200">
<th class="px-6 py-3 text-xs font-bold text-slate-600 uppercase tracking-wider">Order Date</th>
<th class="px-6 py-3 text-xs font-bold text-slate-600 uppercase tracking-wider">Patient Name</th>
<th class="px-6 py-3 text-xs font-bold text-slate-600 uppercase tracking-wider">Patient ID</th>
<th class="px-6 py-3 text-xs font-bold text-slate-600 uppercase tracking-wider">Test / Package</th>
<th class="px-6 py-3 text-xs font-bold text-slate-600 uppercase tracking-wider">Reason</th>
<th class="px-6 py-3 text-xs font-bold text-slate-600 uppercase tracking-wider text-center">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100 bg-white">
{% for order in orders %}
<tr class="hover:bg-slate-50 group transition">
<td class="px-6 py-5 text-sm font-medium text-slate-700 align-middle">
{{ order.order_date.strftime('%Y-%m-%d %H:%M') }}
</td>
<td class="px-6 py-5 align-middle">
<div class="flex items-center gap-3">
<div class="w-9 h-9 rounded-full bg-slate-200 flex items-center justify-center text-slate-600 font-bold text-sm border border-slate-300 shadow-sm">
{{ order.patient.full_name[:2]|upper }}
</div>
<div>
<h3 class="text-sm font-bold text-slate-800">{{ order.patient.full_name }}</h3>
</div>
</div>
</td>
<td class="px-6 py-5 align-middle">
<span class="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-mono font-medium bg-slate-100 text-slate-700 border border-slate-200 shadow-inner">
{{ order.patient.patient_id }}
</span>
</td>
<td class="px-6 py-5 align-middle">
<div class="flex flex-col gap-1.5">
{% if order.package_name %}
<span class="text-xs font-bold text-slate-500 uppercase tracking-wider">📦 {{ order.package_name }}</span>
{% endif %}
<span class="px-3 py-1 inline-flex items-center justify-center text-xs font-bold rounded-full text-red-700 bg-red-50 border border-red-200 w-max shadow-sm">
{{ order.test.test_name }}
</span>
</div>
</td>
<td class="px-6 py-5 align-middle">
<span class="text-sm font-medium text-slate-600 {% if not order.no_sample_reason %}italic text-slate-400{% endif %}">
{{ order.no_sample_reason or 'No reason provided' }}
</span>
</td>
<td class="px-6 py-5 text-center align-middle">
<button onclick="receiveSample({{ order.id }}, this.getAttribute('data-test-name'))" data-test-name="{{ order.test.test_name }}" class="bg-emerald-600 hover:bg-emerald-700 text-white px-4 py-2 rounded-lg text-sm font-bold transition duration-200 shadow flex items-center gap-2 mx-auto">
<span>✅ Receive Sample</span>
</button>
</td>
</tr>
{% else %}
<tr>
<td colspan="6" class="px-6 py-16 text-center text-slate-500 bg-slate-50/50">
<div class="flex flex-col items-center justify-center gap-3">
<div class="text-5xl opacity-80 mb-2 filter drop-shadow-sm">🎉</div>
<h3 class="text-lg font-bold text-slate-700">All Clear!</h3>
<p class="text-sm text-slate-500 font-medium">There are no tests missing samples in the holding queue.</p>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<script>
let currentReceiveOrderId = null;
function receiveSample(orderId, testName) {
currentReceiveOrderId = orderId;
document.getElementById('receiveTestName').textContent = 'Test: ' + (testName || 'Unknown');
document.getElementById('btnConfirmReceive').textContent = 'Receive Sample';
document.getElementById('btnConfirmReceive').disabled = false;
const modal = document.getElementById('receiveSampleModal');
const content = document.getElementById('receiveModalContent');
modal.classList.remove('hidden');
setTimeout(() => {
content.classList.remove('scale-95', 'opacity-0');
content.classList.add('scale-100', 'opacity-100');
}, 10);
}
function closeReceiveModal() {
const modal = document.getElementById('receiveSampleModal');
const content = document.getElementById('receiveModalContent');
content.classList.remove('scale-100', 'opacity-100');
content.classList.add('scale-95', 'opacity-0');
setTimeout(() => {
modal.classList.add('hidden');
}, 200);
}
function confirmReceiveSample() {
document.getElementById('btnConfirmReceive').textContent = 'Processing...';
document.getElementById('btnConfirmReceive').disabled = true;
fetch('/api/no-sample/receive/' + currentReceiveOrderId, {
method: 'POST',
headers: { 'Content-Type': 'application/json' }
})
.then(res => res.json())
.then(data => {
if(data.success) {
window.location.reload();
} else {
alert('Error: ' + data.message);
closeReceiveModal();
document.getElementById('btnConfirmReceive').disabled = false;
}
})
.catch(e => {
console.error(e);
alert('Exception: Failed to communicate with server');
closeReceiveModal();
document.getElementById('btnConfirmReceive').disabled = false;
});
}
</script>
<!-- Confirm Receive Sample Modal -->
<div id="receiveSampleModal" class="hidden fixed inset-0 z-[1000] flex items-center justify-center bg-black/40 backdrop-blur-sm transition-opacity">
<div class="bg-white rounded-[20px] shadow-2xl w-full max-w-md overflow-hidden transform scale-95 opacity-0 transition-all duration-200" id="receiveModalContent">
<!-- Header -->
<div class="bg-emerald-50/70 px-6 py-5 border-b border-emerald-100 flex flex-col">
<div class="flex items-center gap-2 text-emerald-800 font-bold text-lg tracking-tight">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path></svg>
Receive Sample
</div>
<div class="text-emerald-600 text-[13px] font-semibold mt-1" id="receiveTestName">Test: </div>
</div>
<!-- Body -->
<div class="p-6 pb-2">
<p class="text-slate-700 text-[15px] font-medium leading-relaxed tracking-wide">Are you sure you want to mark this sample as received? <br><br>The test will be sent cleanly back to the Result Entry workflows.</p>
</div>
<!-- Footer -->
<div class="px-6 py-4 bg-white border-t border-slate-100 flex justify-end gap-3 flex-row-reverse pb-6 mt-2">
<button onclick="confirmReceiveSample()" id="btnConfirmReceive" class="px-5 py-2.5 bg-[#10b981] hover:bg-[#059669] text-white font-bold rounded-lg shadow-sm transition-colors text-sm">
Receive Sample
</button>
<button onclick="closeReceiveModal()" class="px-5 py-2.5 bg-white border border-slate-300 hover:bg-slate-50 text-slate-700 font-bold rounded-lg shadow-sm transition-colors text-sm">
Cancel
</button>
</div>
</div>
</div>
{% endblock %}
|