billing: add patient history action and legacy-style OPD history view
This commit is contained in:
parent
1d2bfdb7a6
commit
7e4903bd68
|
|
@ -740,6 +740,7 @@ class Patient extends BaseController
|
||||||
|
|
||||||
$opdIds = array_column($opdList, 'opd_id');
|
$opdIds = array_column($opdList, 'opd_id');
|
||||||
$filesByOpd = [];
|
$filesByOpd = [];
|
||||||
|
$rxByOpd = [];
|
||||||
|
|
||||||
if ($opdIds && $this->db->tableExists('file_upload_data')) {
|
if ($opdIds && $this->db->tableExists('file_upload_data')) {
|
||||||
$fields = $this->db->getFieldNames('file_upload_data') ?? [];
|
$fields = $this->db->getFieldNames('file_upload_data') ?? [];
|
||||||
|
|
@ -779,15 +780,64 @@ class Patient extends BaseController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($opdIds && $this->db->tableExists('opd_prescription')) {
|
||||||
|
$rxFields = $this->db->getFieldNames('opd_prescription') ?? [];
|
||||||
|
$selectParts = [];
|
||||||
|
|
||||||
|
if (in_array('id', $rxFields, true)) {
|
||||||
|
$selectParts[] = 'id';
|
||||||
|
}
|
||||||
|
if (in_array('opd_id', $rxFields, true)) {
|
||||||
|
$selectParts[] = 'opd_id';
|
||||||
|
}
|
||||||
|
foreach (['date_opd_visit', 'queue_no', 'bp', 'diastolic', 'pulse', 'temp', 'spo2', 'complaints', 'diagnosis', 'investigation', 'advice'] as $col) {
|
||||||
|
if (in_array($col, $rxFields, true)) {
|
||||||
|
$selectParts[] = $col;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($selectParts !== [] && in_array('opd_id', $rxFields, true)) {
|
||||||
|
$rxRows = $this->db->table('opd_prescription')
|
||||||
|
->select(implode(',', $selectParts), false)
|
||||||
|
->whereIn('opd_id', $opdIds)
|
||||||
|
->orderBy('id', 'DESC')
|
||||||
|
->get()
|
||||||
|
->getResultArray();
|
||||||
|
|
||||||
|
foreach ($rxRows as $rxRow) {
|
||||||
|
$opdId = (int) ($rxRow['opd_id'] ?? 0);
|
||||||
|
if ($opdId <= 0 || isset($rxByOpd[$opdId])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$rxByOpd[$opdId] = $rxRow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$opdGroups = [];
|
$opdGroups = [];
|
||||||
foreach ($opdList as $row) {
|
foreach ($opdList as $row) {
|
||||||
$opdId = (int) $row['opd_id'];
|
$opdId = (int) $row['opd_id'];
|
||||||
|
$rx = $rxByOpd[$opdId] ?? null;
|
||||||
|
$rxSessionId = (int) (($rx['id'] ?? 0));
|
||||||
|
|
||||||
$opdGroups[] = [
|
$opdGroups[] = [
|
||||||
'opd_id' => $opdId,
|
'opd_id' => $opdId,
|
||||||
'opd_code' => $row['opd_code'] ?? '',
|
'opd_code' => $row['opd_code'] ?? '',
|
||||||
'doc_name' => $row['doc_name'] ?? '',
|
'doc_name' => $row['doc_name'] ?? '',
|
||||||
'opd_date' => !empty($row['apointment_date']) ? date('d-m-Y', strtotime($row['apointment_date'])) : '',
|
'opd_date' => !empty($row['apointment_date']) ? date('d-m-Y', strtotime($row['apointment_date'])) : '',
|
||||||
'queue_no' => !empty($row['queue_no']) ? ('Q:' . $row['queue_no']) : '',
|
'queue_no' => !empty($row['queue_no']) ? ('Q:' . $row['queue_no']) : '',
|
||||||
|
'rx_session_id' => $rxSessionId,
|
||||||
|
'rx_date' => !empty($rx['date_opd_visit']) ? date('d-m-Y', strtotime((string) $rx['date_opd_visit'])) : '',
|
||||||
|
'rx_queue_no' => !empty($rx['queue_no']) ? ('Q:' . $rx['queue_no']) : '',
|
||||||
|
'bp' => (string) ($rx['bp'] ?? ''),
|
||||||
|
'diastolic' => (string) ($rx['diastolic'] ?? ''),
|
||||||
|
'pulse' => (string) ($rx['pulse'] ?? ''),
|
||||||
|
'temp' => (string) ($rx['temp'] ?? ''),
|
||||||
|
'spo2' => (string) ($rx['spo2'] ?? ''),
|
||||||
|
'complaints' => (string) ($rx['complaints'] ?? ''),
|
||||||
|
'diagnosis' => (string) ($rx['diagnosis'] ?? ''),
|
||||||
|
'investigation' => (string) ($rx['investigation'] ?? ''),
|
||||||
|
'advice' => (string) ($rx['advice'] ?? ''),
|
||||||
'files' => $filesByOpd[$opdId] ?? [],
|
'files' => $filesByOpd[$opdId] ?? [],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
<div class="pagetitle">
|
<div class="pagetitle">
|
||||||
<h1>OPD Scans</h1>
|
<h1>OPD History</h1>
|
||||||
<nav>
|
<nav>
|
||||||
<ol class="breadcrumb">
|
<ol class="breadcrumb">
|
||||||
<li class="breadcrumb-item"><a href="javascript:load_form('<?= base_url('billing/patient/person_record') ?>/<?= esc($patient->id) ?>/0');">Profile</a></li>
|
<li class="breadcrumb-item"><a href="javascript:load_form('<?= base_url('billing/patient/person_record') ?>/<?= esc($patient->id) ?>/0');">Profile</a></li>
|
||||||
<li class="breadcrumb-item active">OPD Scans</li>
|
<li class="breadcrumb-item active">OPD History</li>
|
||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
<section class="section profile">
|
<section class="section profile">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h3 class="card-title mb-0">OPD Scans</h3>
|
<h3 class="card-title mb-0">OPD History</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p class="mb-3">Patient: <strong><?= esc($patient->p_fname ?? '') ?></strong></p>
|
<p class="mb-3">Patient: <strong><?= esc($patient->p_fname ?? '') ?></strong></p>
|
||||||
|
|
@ -31,9 +31,62 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-2">
|
||||||
|
<?php if ((int) ($group['rx_session_id'] ?? 0) > 0) { ?>
|
||||||
|
<a class="btn btn-primary btn-sm" target="_blank"
|
||||||
|
href="<?= base_url('Opd_prescription/opd_prescription_print/' . (int) $group['opd_id'] . '/' . (int) $group['rx_session_id']) ?>">
|
||||||
|
Prescription Print
|
||||||
|
</a>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<?php if (!empty($group['bp']) || !empty($group['diastolic']) || !empty($group['pulse']) || !empty($group['temp']) || !empty($group['spo2'])) { ?>
|
||||||
|
<div class="small text-muted mt-2">
|
||||||
|
<?php if (!empty($group['bp'])) { ?><span class="me-3"><strong>BP:</strong> <?= esc($group['bp']) ?></span><?php } ?>
|
||||||
|
<?php if (!empty($group['diastolic'])) { ?><span class="me-3"><strong>Diastolic:</strong> <?= esc($group['diastolic']) ?></span><?php } ?>
|
||||||
|
<?php if (!empty($group['pulse'])) { ?><span class="me-3"><strong>Pulse:</strong> <?= esc($group['pulse']) ?></span><?php } ?>
|
||||||
|
<?php if (!empty($group['temp'])) { ?><span class="me-3"><strong>Temp:</strong> <?= esc($group['temp']) ?></span><?php } ?>
|
||||||
|
<?php if (!empty($group['spo2'])) { ?><span class="me-3"><strong>SPO2:</strong> <?= esc($group['spo2']) ?></span><?php } ?>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<?php if (!empty($group['complaints']) || !empty($group['diagnosis']) || !empty($group['investigation']) || !empty($group['advice'])) { ?>
|
||||||
|
<div class="row g-2 mt-2">
|
||||||
|
<?php if (!empty($group['complaints'])) { ?>
|
||||||
|
<div class="col-12 col-lg-6">
|
||||||
|
<div class="border rounded p-2 bg-light small">
|
||||||
|
<strong>Complaints:</strong> <?= esc($group['complaints']) ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
<?php if (!empty($group['diagnosis'])) { ?>
|
||||||
|
<div class="col-12 col-lg-6">
|
||||||
|
<div class="border rounded p-2 bg-light small">
|
||||||
|
<strong>Diagnosis:</strong> <?= esc($group['diagnosis']) ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
<?php if (!empty($group['investigation'])) { ?>
|
||||||
|
<div class="col-12 col-lg-6">
|
||||||
|
<div class="border rounded p-2 bg-light small">
|
||||||
|
<strong>Investigation:</strong> <?= esc($group['investigation']) ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
<?php if (!empty($group['advice'])) { ?>
|
||||||
|
<div class="col-12 col-lg-6">
|
||||||
|
<div class="border rounded p-2 bg-light small">
|
||||||
|
<strong>Advice:</strong> <?= esc($group['advice']) ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
<?php if (empty($group['files'])) { ?>
|
<?php if (empty($group['files'])) { ?>
|
||||||
<div class="text-muted mt-2">No files for this OPD.</div>
|
<div class="text-muted mt-2">No scanned files for this OPD.</div>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
|
<div class="small fw-semibold mt-3 mb-1">Scanned Files</div>
|
||||||
<div class="row g-2 mt-2">
|
<div class="row g-2 mt-2">
|
||||||
<?php foreach ($group['files'] as $index => $file) { ?>
|
<?php foreach ($group['files'] as $index => $file) { ?>
|
||||||
<div class="col-6 col-md-3">
|
<div class="col-6 col-md-3">
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
<th>Age</th>
|
<th>Age</th>
|
||||||
<th>Last Visit</th>
|
<th>Last Visit</th>
|
||||||
<th>Insurance</th>
|
<th>Insurance</th>
|
||||||
|
<th>Patient History</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
@ -25,6 +26,11 @@
|
||||||
<td><?= esc(get_age_1($data[$i]->dob ?? null, $data[$i]->age ?? '', $data[$i]->age_in_month ?? '', $data[$i]->estimate_dob ?? '', $data[$i]->Last_Visit ?? null)) ?></td>
|
<td><?= esc(get_age_1($data[$i]->dob ?? null, $data[$i]->age ?? '', $data[$i]->age_in_month ?? '', $data[$i]->estimate_dob ?? '', $data[$i]->Last_Visit ?? null)) ?></td>
|
||||||
<td><?=$data[$i]->Last_Visit ?></td>
|
<td><?=$data[$i]->Last_Visit ?></td>
|
||||||
<td><?php echo ($data[$i]->insurance_id==0 ? 'Self': 'Insuranced'); ?></td>
|
<td><?php echo ($data[$i]->insurance_id==0 ? 'Self': 'Insuranced'); ?></td>
|
||||||
|
<td>
|
||||||
|
<a href="javascript:load_form('<?= base_url('billing/patient/show_profile_opd') ?>/<?=$data[$i]->id ?>/1');" class="btn btn-info btn-xs">
|
||||||
|
<span class="fa fa-history"></span> Patient History
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
@ -36,6 +42,7 @@
|
||||||
<th>Age</th>
|
<th>Age</th>
|
||||||
<th>Last Visit</th>
|
<th>Last Visit</th>
|
||||||
<th>Insurance</th>
|
<th>Insurance</th>
|
||||||
|
<th>Patient History</th>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user