adding nursing notes

This commit is contained in:
Flatlogic Bot 2026-03-22 13:29:44 +00:00
parent e73384ddbc
commit bcd593fb90
4 changed files with 807 additions and 710 deletions

View File

@ -0,0 +1 @@
ALTER TABLE visits ADD COLUMN IF NOT EXISTS nursing_notes TEXT AFTER temperature;

View File

@ -227,6 +227,7 @@ if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST')
$symptoms = $_POST['symptoms'] ?? ''; $symptoms = $_POST['symptoms'] ?? '';
$diagnosis = $_POST['diagnosis'] ?? ''; $diagnosis = $_POST['diagnosis'] ?? '';
$treatment = $_POST['treatment_plan'] ?? ''; $treatment = $_POST['treatment_plan'] ?? '';
$nursing_notes = $_POST['nursing_notes'] ?? '';
if ($patient_id && ($doctor_id || $nurse_id)) { if ($patient_id && ($doctor_id || $nurse_id)) {
$db->beginTransaction(); $db->beginTransaction();
@ -241,8 +242,8 @@ if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST')
$address = $apt['address'] ?? null; $address = $apt['address'] ?? null;
} }
$stmt = $db->prepare("INSERT INTO visits (patient_id, doctor_id, nurse_id, visit_type, address, appointment_id, weight, blood_pressure, heart_rate, temperature, symptoms, diagnosis, treatment_plan) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); $stmt = $db->prepare("INSERT INTO visits (patient_id, doctor_id, nurse_id, visit_type, address, appointment_id, weight, blood_pressure, heart_rate, temperature, symptoms, diagnosis, treatment_plan, nursing_notes) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->execute([$patient_id, $doctor_id, $nurse_id, $visit_type, $address, $appointment_id, $weight, $bp, $hr, $temp, $symptoms, $diagnosis, $treatment]); $stmt->execute([$patient_id, $doctor_id, $nurse_id, $visit_type, $address, $appointment_id, $weight, $bp, $hr, $temp, $symptoms, $diagnosis, $treatment, $nursing_notes]);
$visit_id = $db->lastInsertId(); $visit_id = $db->lastInsertId();
$token_message = ''; $token_message = '';
@ -317,6 +318,7 @@ if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST')
$symptoms = $_POST['symptoms'] ?? ''; $symptoms = $_POST['symptoms'] ?? '';
$diagnosis = $_POST['diagnosis'] ?? ''; $diagnosis = $_POST['diagnosis'] ?? '';
$treatment = $_POST['treatment_plan'] ?? ''; $treatment = $_POST['treatment_plan'] ?? '';
$nursing_notes = $_POST['nursing_notes'] ?? '';
// Check for 24h restriction // Check for 24h restriction
$stmtSet = $db->prepare("SELECT setting_value FROM settings WHERE setting_key = 'disable_visit_edit_24h'"); $stmtSet = $db->prepare("SELECT setting_value FROM settings WHERE setting_key = 'disable_visit_edit_24h'");
@ -343,8 +345,8 @@ if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST')
if ($id && $doctor_id) { if ($id && $doctor_id) {
// Removed patient_id from UPDATE // Removed patient_id from UPDATE
$stmt = $db->prepare("UPDATE visits SET doctor_id = ?, weight = ?, blood_pressure = ?, heart_rate = ?, temperature = ?, symptoms = ?, diagnosis = ?, treatment_plan = ? WHERE id = ?"); $stmt = $db->prepare("UPDATE visits SET doctor_id = ?, weight = ?, blood_pressure = ?, heart_rate = ?, temperature = ?, symptoms = ?, diagnosis = ?, treatment_plan = ?, nursing_notes = ? WHERE id = ?");
$stmt->execute([$doctor_id, $weight, $bp, $hr, $temp, $symptoms, $diagnosis, $treatment, $id]); $stmt->execute([$doctor_id, $weight, $bp, $hr, $temp, $symptoms, $diagnosis, $treatment, $nursing_notes, $id]);
$stmt = $db->prepare("DELETE FROM visit_prescriptions WHERE visit_id = ?"); $stmt = $db->prepare("DELETE FROM visit_prescriptions WHERE visit_id = ?");
$stmt->execute([$id]); $stmt->execute([$id]);
if (isset($_POST['prescriptions']) && is_array($_POST['prescriptions'])) { if (isset($_POST['prescriptions']) && is_array($_POST['prescriptions'])) {

View File

@ -977,7 +977,7 @@
<select name="patient_id" id="visit_patient_id" class="form-select select2-modal" required> <select name="patient_id" id="visit_patient_id" class="form-select select2-modal" required>
<option value=""><?php echo __('select'); ?>...</option> <option value=""><?php echo __('select'); ?>...</option>
<?php foreach ($all_patients as $p): ?> <?php foreach ($all_patients as $p): ?>
<option value="<?php echo $p['id']; ?>"><?php echo htmlspecialchars($p['name']); ?></option> <option value="<?php echo $p['id']; ?>" data-dob="<?php echo $p['dob']; ?>" data-gender="<?php echo $p['gender']; ?>"><?php echo htmlspecialchars($p['name']); ?></option>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
</div> </div>
@ -990,6 +990,18 @@
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
</div> </div>
<div class="col-md-4 mb-3">
<label class="form-label"><?php echo __('gender'); ?></label>
<input type="text" id="visit_patient_gender" class="form-control" readonly>
</div>
<div class="col-md-4 mb-3">
<label class="form-label"><?php echo __('dob'); ?></label>
<input type="text" id="visit_patient_dob" class="form-control" readonly>
</div>
<div class="col-md-4 mb-3">
<label class="form-label"><?php echo __('age'); ?></label>
<input type="text" id="visit_patient_age" class="form-control" readonly>
</div>
<div class="col-md-12 mb-3"> <div class="col-md-12 mb-3">
<div class="form-check form-switch"> <div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="generate_token" name="generate_token" value="1"> <input class="form-check-input" type="checkbox" id="generate_token" name="generate_token" value="1">
@ -1018,6 +1030,10 @@
<label class="form-label"><?php echo __('temperature'); ?> (°C)</label> <label class="form-label"><?php echo __('temperature'); ?> (°C)</label>
<input type="number" step="0.1" name="temperature" id="visit_temperature" class="form-control"> <input type="number" step="0.1" name="temperature" id="visit_temperature" class="form-control">
</div> </div>
<div class="col-md-12 mb-3">
<label class="form-label"><?php echo __("nursing_notes"); ?></label>
<textarea name="nursing_notes" id="visit_nursing_notes" class="form-control" rows="3"></textarea>
</div>
</div> </div>
</div> </div>
@ -1376,6 +1392,11 @@ function showRecordVisitModal(patientId = null) {
document.querySelector('#prescriptionTable tbody').innerHTML = ''; document.querySelector('#prescriptionTable tbody').innerHTML = '';
addPrescriptionRow(); // Add one empty row addPrescriptionRow(); // Add one empty row
// Clear patient info
$('#visit_patient_gender').val('');
$('#visit_patient_dob').val('');
$('#visit_patient_age').val('');
if (patientId) { if (patientId) {
$('#visit_patient_id').val(patientId).trigger('change'); $('#visit_patient_id').val(patientId).trigger('change');
} else { } else {
@ -1435,6 +1456,23 @@ function showEditVisitModal(data) {
document.getElementById('visit_blood_pressure').value = data.blood_pressure || ''; document.getElementById('visit_blood_pressure').value = data.blood_pressure || '';
document.getElementById('visit_heart_rate').value = data.heart_rate || ''; document.getElementById('visit_heart_rate').value = data.heart_rate || '';
document.getElementById('visit_temperature').value = data.temperature || ''; document.getElementById('visit_temperature').value = data.temperature || '';
document.getElementById('visit_nursing_notes').value = data.nursing_notes || '';
// Populate new fields
$('#visit_patient_gender').val(data.patient_gender || '');
$('#visit_patient_dob').val(data.patient_dob || '');
if (data.patient_dob) {
const birthDate = new Date(data.patient_dob);
const today = new Date();
let age = today.getFullYear() - birthDate.getFullYear();
const m = today.getMonth() - birthDate.getMonth();
if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
age--;
}
$('#visit_patient_age').val(age);
} else {
$('#visit_patient_age').val('');
}
// Populate Summernote fields // Populate Summernote fields
$('#visit_symptoms').summernote('code', data.symptoms || ''); $('#visit_symptoms').summernote('code', data.symptoms || '');
@ -1815,6 +1853,29 @@ $(document).ready(function() {
] ]
}); });
}); });
// Update patient details in Visit Modal
$('#visit_patient_id').on('change', function() {
const selected = $(this).find('option:selected');
const dob = selected.data('dob');
const gender = selected.data('gender');
$('#visit_patient_gender').val(gender || '');
$('#visit_patient_dob').val(dob || '');
if (dob) {
const birthDate = new Date(dob);
const today = new Date();
let age = today.getFullYear() - birthDate.getFullYear();
const m = today.getMonth() - birthDate.getMonth();
if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
age--;
}
$('#visit_patient_age').val(age);
} else {
$('#visit_patient_age').val('');
}
});
}); });
</script> </script>
</body> </body>

1443
lang.php

File diff suppressed because it is too large Load Diff